Skip to content
Snippets Groups Projects
Commit 75ef76e1 authored by mattwire's avatar mattwire
Browse files

If stripe customer is stored in CiviCRM but does not exist, delete and recreate it

parent 117484b0
Branches
Tags
1 merge request!217Implement Stripe Checkout (with support for SEPA and ACH)
......@@ -717,13 +717,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Customer was found in civicrm database, fetch from Stripe.
try {
$stripeCustomer = $this->stripeClient->customers->retrieve($stripeCustomerID);
$shouldDeleteStripeCustomer = $stripeCustomer->isDeleted();
} catch (Exception $e) {
$err = self::parseStripeException('retrieve_customer', $e);
throw new PaymentProcessorException('Failed to retrieve Stripe Customer: ' . $err['code']);
\Civi::log()->error('Failed to retrieve Stripe Customer: ' . $err['code']);
$shouldDeleteStripeCustomer = TRUE;
}
if ($stripeCustomer->isDeleted()) {
// Customer doesn't exist, create a new one
if ($shouldDeleteStripeCustomer) {
// Customer doesn't exist or was deleted, create a new one
CRM_Stripe_Customer::delete($customerParams);
try {
$stripeCustomer = CRM_Stripe_Customer::create($customerParams, $this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment