Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mjwshared
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
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
mjwshared
Commits
fcff16f1
Commit
fcff16f1
authored
4 years ago
by
mattwire
Committed by
mattwire
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Catch errors processing webhooks and continue processing the list of pending webhooks
parent
f7e59773
No related branches found
No related tags found
1 merge request
!20
Merge 1.0 into master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/v3/Job/ProcessPaymentprocessorWebhooks.php
+19
-7
19 additions, 7 deletions
api/v3/Job/ProcessPaymentprocessorWebhooks.php
with
19 additions
and
7 deletions
api/v3/Job/ProcessPaymentprocessorWebhooks.php
+
19
−
7
View file @
fcff16f1
...
...
@@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/
use
Civi\Api4\PaymentprocessorWebhook
;
/**
* This job performs various housekeeping actions related to the Stripe payment processor
*
...
...
@@ -21,20 +23,20 @@
function
civicrm_api3_job_process_paymentprocessor_webhooks
(
$params
)
{
if
(
$params
[
'delete_old'
]
!==
0
&&
!
empty
(
$params
[
'delete_old'
]))
{
// Delete all locally recorded webhooks that are older than 3 months
\Civi\Api4\
PaymentprocessorWebhook
::
delete
()
PaymentprocessorWebhook
::
delete
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'created_date'
,
'<'
,
$params
[
'delete_old'
])
->
execute
();
}
$paymentProcessorWebhooks
=
\Civi\Api4\
PaymentprocessorWebhook
::
get
()
$paymentProcessorWebhooks
=
PaymentprocessorWebhook
::
get
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'processed_date'
,
'IS NULL'
)
->
addWhere
(
'status'
,
'IS NULL'
)
->
execute
();
$results
=
[];
if
(
!
empty
(
$paymentProcessorWebhooks
->
rowCount
))
{
\Civi\Api4\
PaymentprocessorWebhook
::
update
()
PaymentprocessorWebhook
::
update
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'id'
,
'IN'
,
$paymentProcessorWebhooks
->
column
(
'id'
))
->
addValue
(
'status'
,
'processing'
)
...
...
@@ -45,10 +47,20 @@ function civicrm_api3_job_process_paymentprocessor_webhooks($params) {
->
getById
(
$webhook
[
'payment_processor_id'
]);
switch
(
$paymentProcessor
->
getPaymentProcessor
()[
'class_name'
])
{
case
'Payment_Stripe'
:
$results
[
$webhook
[
'id'
]]
=
civicrm_api3
(
'Stripe'
,
'Ipn'
,
[
'evtid'
=>
$webhook
[
'event_id'
],
'ppid'
=>
$webhook
[
'payment_processor_id'
]
])[
'values'
];
try
{
$results
[
$webhook
[
'id'
]]
=
civicrm_api3
(
'Stripe'
,
'Ipn'
,
[
'evtid'
=>
$webhook
[
'event_id'
],
'ppid'
=>
$webhook
[
'payment_processor_id'
]
])[
'values'
];
}
catch
(
Exception
$e
)
{
\Civi
::
log
()
->
error
(
'Error processing webhook (ID: '
.
$webhook
[
'id'
]
.
'): '
.
$e
->
getMessage
());
PaymentprocessorWebhook
::
update
()
->
setCheckPermissions
(
FALSE
)
// Replace with ::update(FALSE) when minversion = 5.29
->
addWhere
(
'id'
,
'='
,
$webhook
[
'id'
])
->
addValue
(
'status'
,
'error'
)
->
execute
();
}
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