function commerce_stripe_pi_cardonfile_delete in Commerce Stripe Payment Intent 7
Card on file callback: deletes the associated customer payment profile.
1 string reference to 'commerce_stripe_pi_cardonfile_delete'
File
- ./
commerce_stripe_pi.module, line 1849 - Payment intent stripe payment integration.
Code
function commerce_stripe_pi_cardonfile_delete($form, &$form_state, $payment_method, $card_data) {
if (!commerce_stripe_pi_load_library()) {
return FALSE;
}
// Fetch the customer id and payment method id from $card_data->remote_id.
list($customer_id, $payment_method_id) = explode('|', $card_data->remote_id);
if (empty($payment_method_id) || empty($customer_id)) {
return TRUE;
}
try {
$payment_method = PaymentMethod::retrieve($payment_method_id);
$payment_method
->detach();
return TRUE;
} catch (Exception $e) {
drupal_set_message(t('We received the following error processing your card: %error. Please enter your information again or try a different card.', array(
'%error' => $e
->getMessage(),
)), 'error');
watchdog('commerce_stripe_pi', 'Following error received when deleting card @stripe_pi_error.', array(
'@stripe_pi_error' => $e
->getMessage(),
), WATCHDOG_NOTICE);
return FALSE;
}
}