Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
84d00048
Commit
84d00048
authored
6 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Fix token_already_used
parent
a26693c6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
5.1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Core/Payment/Stripe.php
+14
-6
14 additions, 6 deletions
CRM/Core/Payment/Stripe.php
with
14 additions
and
6 deletions
CRM/Core/Payment/Stripe.php
+
14
−
6
View file @
84d00048
...
...
@@ -124,13 +124,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @return string errorMessage (or statusbounce if URL is specified)
*/
public
function
handleErrorNotification
(
$err
,
$bounceURL
=
NULL
)
{
$errorMessage
=
'
Oops! Looks like there was an error.
Payment Response: <br />'
.
$errorMessage
=
'Payment Response: <br />'
.
'Type: '
.
$err
[
'type'
]
.
'<br />'
.
'Code: '
.
$err
[
'code'
]
.
'<br />'
.
'Message: '
.
$err
[
'message'
]
.
'<br />'
;
Civi
::
log
()
->
debug
(
'Stripe Payment Error: '
.
$errorMessage
);
if
(
$bounceURL
)
{
CRM_Core_Error
::
statusBounce
(
$errorMessage
,
$bounceURL
);
CRM_Core_Error
::
statusBounce
(
$errorMessage
,
$bounceURL
,
'Payment Error'
);
}
return
$errorMessage
;
}
...
...
@@ -483,6 +485,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return
$stripeCustomer
;
}
}
// 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".
...
...
@@ -491,11 +494,16 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
else
{
$stripeCustomer
->
card
=
$card_token
;
$
response
=
$this
->
stripeCatchErrors
(
'save'
,
$stripeCustomer
,
$params
);
if
(
isset
(
$response
)
&&
$this
->
isErrorReturn
(
$
response
))
{
self
::
handleErrorNotification
(
$response
,
$params
[
'stripe_error_url'
]);
return
$response
;
$
stripeCustomer
=
$this
->
stripeCatchErrors
(
'save'
,
$stripeCustomer
,
$params
);
if
(
$this
->
isErrorReturn
(
$
stripeCustomer
))
{
if
((
$stripeCustomer
[
'type'
]
==
'invalid_request_error'
)
&&
(
$stripeCustomer
[
'code'
]
==
'token_already_used'
))
{
// This error is ok, we've already used the token during create_customer
}
else
{
self
::
handleErrorNotification
(
$stripeCustomer
,
$params
[
'stripe_error_url'
]);
return
$stripeCustomer
;
}
}
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment