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
1cd04b68
Commit
1cd04b68
authored
2 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Fix 387 paid multi-participant registration fails
parent
2a3429e6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Payment/Stripe.php
+28
-1
28 additions, 1 deletion
CRM/Core/Payment/Stripe.php
CRM/Stripe/PaymentIntent.php
+11
-1
11 additions, 1 deletion
CRM/Stripe/PaymentIntent.php
with
39 additions
and
2 deletions
CRM/Core/Payment/Stripe.php
+
28
−
1
View file @
1cd04b68
...
...
@@ -636,9 +636,36 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$intentParams
[
'statement_descriptor_suffix'
]
=
$this
->
getDescription
(
$params
,
'statement_descriptor_suffix'
);
$intentParams
[
'statement_descriptor'
]
=
$this
->
getDescription
(
$params
,
'statement_descriptor'
);
if
(
!
$propertyBag
->
has
(
'paymentIntentID'
)
&&
!
empty
(
$paymentMethodID
))
{
// We came in via a flow that did not know the amount before submit (eg. multiple event participants)
// We need to create a paymentIntent
$stripePaymentIntent
=
new
CRM_Stripe_PaymentIntent
(
$this
);
$stripePaymentIntent
->
setDescription
(
$this
->
getDescription
(
$params
));
$stripePaymentIntent
->
setReferrer
(
$_SERVER
[
'HTTP_REFERER'
]
??
''
);
$stripePaymentIntent
->
setExtraData
(
$params
[
'extra_data'
]
??
[]);
$paymentIntentParams
=
[
'paymentMethodID'
=>
$paymentMethodID
,
'customer'
=>
$stripeCustomer
->
id
,
'capture'
=>
FALSE
,
'amount'
=>
$propertyBag
->
getAmount
(),
'currency'
=>
$propertyBag
->
getCurrency
(),
];
$processIntentResult
=
$stripePaymentIntent
->
processPaymentIntent
(
$paymentIntentParams
);
if
(
$processIntentResult
->
ok
&&
!
empty
(
$processIntentResult
->
data
[
'success'
]))
{
$paymentIntentID
=
$processIntentResult
->
data
[
'paymentIntent'
][
'id'
];
}
else
{
\Civi
::
log
(
'stripe'
)
->
error
(
'Attempted to create paymentIntent from paymentMethod during doPayment failed: '
.
print_r
(
$processIntentResult
,
TRUE
));
}
}
// This is where we actually charge the customer
try
{
$intent
=
$this
->
stripeClient
->
paymentIntents
->
retrieve
(
$propertyBag
->
getCustomProperty
(
'paymentIntentID'
));
if
(
empty
(
$paymentIntentID
))
{
$paymentIntentID
=
$propertyBag
->
getCustomProperty
(
'paymentIntentID'
);
}
$intent
=
$this
->
stripeClient
->
paymentIntents
->
retrieve
(
$paymentIntentID
);
if
(
$intent
->
amount
!=
$this
->
getAmount
(
$params
))
{
$intentParams
[
'amount'
]
=
$this
->
getAmount
(
$params
);
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/PaymentIntent.php
+
11
−
1
View file @
1cd04b68
...
...
@@ -308,12 +308,19 @@ class CRM_Stripe_PaymentIntent {
return
$resultObject
;
}
/**
* @param array $params
*
* @return object
* @throws \Stripe\Exception\ApiErrorException
*/
public
function
processPaymentIntent
(
$params
)
{
/*
$params = [
// Either paymentIntentID or paymentMethodID must be set
'paymentIntentID' => 'pi_xx',
'paymentMethodID' => 'pm_xx',
'customer' => 'cus_xx', // required if paymentMethodID is set
'capture' => TRUE/FALSE,
'amount' => '12.05',
'currency' => 'USD',
...
...
@@ -348,9 +355,12 @@ class CRM_Stripe_PaymentIntent {
$intentParams
[
'capture_method'
]
=
'manual'
;
// Setup the card to be saved and used later
$intentParams
[
'setup_future_usage'
]
=
'off_session'
;
if
(
$params
[
'paymentMethodID'
])
{
if
(
isset
(
$params
[
'paymentMethodID'
])
)
{
$intentParams
[
'payment_method'
]
=
$params
[
'paymentMethodID'
];
}
if
(
isset
(
$params
[
'customer'
]))
{
$intentParams
[
'customer'
]
=
$params
[
'customer'
];
}
$intent
=
$this
->
paymentProcessor
->
stripeClient
->
paymentIntents
->
create
(
$intentParams
);
}
catch
(
Exception
$e
)
{
// Save the "error" in the paymentIntent table in in case investigation is required.
...
...
This diff is collapsed.
Click to expand it.
mattwire
@mattwire
mentioned in issue
#387 (closed)
·
2 years ago
mentioned in issue
#387 (closed)
mentioned in issue #387
Toggle commit list
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