Skip to content
Snippets Groups Projects
Commit 43038bdb authored by mattwire's avatar mattwire
Browse files

Delete customer from civicrm if it doesn't exist at Stripe

parent 989004d8
Branches
Tags
1 merge request!95.1
......@@ -476,6 +476,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
if ($this->isErrorReturn($stripeCustomer)) {
if (($stripeCustomer['type'] == 'invalid_request_error') && ($stripeCustomer['code'] == 'resource_missing')) {
// Customer doesn't exist, create a new one
CRM_Stripe_Customer::delete($customerParams);
$stripeCustomer = CRM_Stripe_Customer::create($customerParams, $this);
}
if ($this->isErrorReturn($stripeCustomer)) {
......
......@@ -98,10 +98,11 @@ class CRM_Stripe_Customer {
}
return $stripeCustomer;
}
/**
* Delete a Stripe customer from the CiviCRM database
*
* @param $params
* @param array $params
*
* @throws \CRM_Core_Exception
*/
......@@ -118,8 +119,9 @@ class CRM_Stripe_Customer {
2 => [$params['is_live'], 'Boolean'],
3 => [$params['processor_id'], 'Integer'],
];
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_stripe_customers
WHERE contact_id = %1 AND is_live = %2 AND processor_id = %3", $queryParams);
$sql = "DELETE FROM civicrm_stripe_customers
WHERE contact_id = %1 AND is_live = %2 AND processor_id = %3";
CRM_Core_DAO::executeQuery($sql, $queryParams);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment