Skip to content
Snippets Groups Projects
Commit 58776193 authored by Jamie McClelland's avatar Jamie McClelland Committed by mattwire
Browse files

Always try to update a credit card

Otherwise we may ignore a credit card provided by a user
and instead charge the one associated with their account.

https://lab.civicrm.org/extensions/stripe/issues/4
parent 4df2ca40
No related branches found
No related tags found
1 merge request!95.1
......@@ -486,23 +486,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
}
// Avoid the 'use same token twice' issue while still using latest card.
if (!empty($params['is_secondary_financial_transaction'])) {
// This is a Contribution page with "Separate Membership Payment".
// Charge is coming through for the 2nd time.
// Don't update customer again or we will get "token_already_used" error from Stripe.
}
else {
$stripeCustomer->card = $card_token;
$updatedStripeCustomer = $this->stripeCatchErrors('save', $stripeCustomer, $params);
if ($this->isErrorReturn($updatedStripeCustomer)) {
if (($updatedStripeCustomer['type'] == 'invalid_request_error') && ($updatedStripeCustomer['code'] == 'token_already_used')) {
// This error is ok, we've already used the token during create_customer
}
else {
self::handleErrorNotification($updatedStripeCustomer, $params['stripe_error_url']);
return $updatedStripeCustomer;
}
$stripeCustomer->card = $card_token;
$updatedStripeCustomer = $this->stripeCatchErrors('save', $stripeCustomer, $params);
if ($this->isErrorReturn($updatedStripeCustomer)) {
if (($updatedStripeCustomer['type'] == 'invalid_request_error') && ($updatedStripeCustomer['code'] == 'token_already_used')) {
// This error is ok, we've already used the token during create_customer
}
else {
self::handleErrorNotification($updatedStripeCustomer, $params['stripe_error_url']);
return $updatedStripeCustomer;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment