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
684f4a2d
Commit
684f4a2d
authored
4 years ago
by
mattwire
Committed by
mattwire
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixes to processing invoice.payment_failed
parent
ddba85ef
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!152
6.6 to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Payment/StripeIPN.php
+11
-9
11 additions, 9 deletions
CRM/Core/Payment/StripeIPN.php
CRM/Stripe/Api.php
+5
-2
5 additions, 2 deletions
CRM/Stripe/Api.php
with
16 additions
and
11 deletions
CRM/Core/Payment/StripeIPN.php
+
11
−
9
View file @
684f4a2d
...
...
@@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/
use
Civi\Api4\PaymentprocessorWebhook
;
/**
* Class CRM_Core_Payment_StripeIPN
*/
...
...
@@ -184,7 +186,7 @@ class CRM_Core_Payment_StripeIPN {
// This returns all webhooks that match the uniqueIdentifier above and have not been processed.
// For example this would match both invoice.finalized and invoice.payment_succeeded events which must be
// processed sequentially and not simultaneously.
$paymentProcessorWebhooks
=
\Civi\Api4\
PaymentprocessorWebhook
::
get
()
$paymentProcessorWebhooks
=
PaymentprocessorWebhook
::
get
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'payment_processor_id'
,
'='
,
$this
->
_paymentProcessor
->
getID
())
->
addWhere
(
'identifier'
,
'='
,
$uniqueIdentifier
)
...
...
@@ -223,7 +225,7 @@ class CRM_Core_Payment_StripeIPN {
// So we will record this webhook but will not process now (it will be processed later by the scheduled job).
}
\Civi\Api4\
PaymentprocessorWebhook
::
create
()
PaymentprocessorWebhook
::
create
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addValue
(
'payment_processor_id'
,
$this
->
_paymentProcessor
->
getID
())
->
addValue
(
'trigger'
,
$this
->
eventType
)
...
...
@@ -252,7 +254,7 @@ class CRM_Core_Payment_StripeIPN {
}
catch
(
Exception
$e
)
{
$success
=
FALSE
;
\Civi
::
log
()
->
error
(
'
StripeIPN: process
Webhook failed. '
.
$e
->
getMessage
());
\Civi
::
log
()
->
error
(
"
StripeIPN: process
EventType failed. EventID:
{
$this
->
eventID
}
: "
.
$e
->
getMessage
());
}
$uniqueIdentifier
=
$this
->
getWebhookUniqueIdentifier
();
...
...
@@ -261,7 +263,7 @@ class CRM_Core_Payment_StripeIPN {
// If for some reason we ended up with multiple webhooks with the same identifier and same eventType this would
// update all of them as "processed". That is ok because we don't need to process the "same" webhook multiple
// times. Even if they have different event IDs but the same identifier/eventType.
\Civi\Api4\
PaymentprocessorWebhook
::
update
()
PaymentprocessorWebhook
::
update
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'identifier'
,
'='
,
$uniqueIdentifier
)
->
addWhere
(
'trigger'
,
'='
,
$this
->
eventType
)
...
...
@@ -535,7 +537,7 @@ class CRM_Core_Payment_StripeIPN {
$this
->
receive_date
=
$this
->
retrieve
(
'receive_date'
,
'String'
,
FALSE
);
$this
->
amount
=
$this
->
retrieve
(
'amount'
,
'String'
,
FALSE
);
if
((
$this
->
getData
()
->
object
->
object
!==
'charge'
)
&&
(
$this
->
charge_id
!==
NULL
))
{
if
((
$this
->
getData
()
->
object
->
object
!==
'charge'
)
&&
(
!
empty
(
$this
->
charge_id
)
))
{
$charge
=
$this
->
_paymentProcessor
->
stripeClient
->
charges
->
retrieve
(
$this
->
charge_id
);
$balanceTransactionID
=
CRM_Stripe_Api
::
getObjectParam
(
'balance_transaction'
,
$charge
);
}
...
...
@@ -601,15 +603,15 @@ class CRM_Core_Payment_StripeIPN {
];
// A) One-off contribution
if
(
$this
->
charge_id
)
{
if
(
!
empty
(
$this
->
charge_id
)
)
{
$paymentParams
[
'trxn_id'
]
=
$this
->
charge_id
;
$contribution
=
civicrm_api3
(
'Mjwpayment'
,
'get_contribution'
,
$paymentParams
);
}
$contribution
=
civicrm_api3
(
'Mjwpayment'
,
'get_contribution'
,
$paymentParams
);
// B2) Contribution linked to subscription and we have invoice_id
if
(
!
$contribution
[
'count'
])
{
unset
(
$paymentParams
[
'trxn_id'
]);
if
(
$this
->
invoice_id
)
{
if
(
!
empty
(
$this
->
invoice_id
)
)
{
$paymentParams
[
'order_reference'
]
=
$this
->
invoice_id
;
$contribution
=
civicrm_api3
(
'Mjwpayment'
,
'get_contribution'
,
$paymentParams
);
}
...
...
@@ -618,7 +620,7 @@ class CRM_Core_Payment_StripeIPN {
// B1) Contribution linked to subscription and we have subscription_id
if
(
!
$contribution
[
'count'
])
{
unset
(
$paymentParams
[
'trxn_id'
]);
if
(
$this
->
subscription_id
)
{
if
(
!
empty
(
$this
->
subscription_id
)
)
{
$paymentParams
[
'order_reference'
]
=
$this
->
subscription_id
;
$contribution
=
civicrm_api3
(
'Mjwpayment'
,
'get_contribution'
,
$paymentParams
);
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/Api.php
+
5
−
2
View file @
684f4a2d
...
...
@@ -102,8 +102,11 @@ class CRM_Stripe_Api {
return
(
string
)
$stripeObject
->
customer
;
case
'failure_message'
:
$stripeCharge
=
\Stripe\Charge
::
retrieve
(
$stripeObject
->
charge
);
return
(
string
)
$stripeCharge
->
failure_message
;
if
(
!
empty
(
$stripeObject
->
charge
))
{
$stripeCharge
=
\Stripe\Charge
::
retrieve
(
$stripeObject
->
charge
);
return
(
string
)
$stripeCharge
->
failure_message
;
}
return
''
;
}
break
;
...
...
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