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
d24d0cbd
Commit
d24d0cbd
authored
9 years ago
by
Joshua Walker
Browse files
Options
Downloads
Patches
Plain Diff
Fix for
#123
Fixes
#123
, typo in Webhook.php.
parent
d635f6ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Stripe/Page/Webhook.php
+53
-53
53 additions, 53 deletions
CRM/Stripe/Page/Webhook.php
with
53 additions
and
53 deletions
CRM/Stripe/Page/Webhook.php
+
53
−
53
View file @
d24d0cbd
...
...
@@ -103,7 +103,7 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
'id'
=>
$pending_contrib_check
[
'id'
],
'trxn_id'
=>
$transaction_id
,
'fee_amount'
=>
$fee
)
;
)
))
;
return
;
}
...
...
@@ -251,57 +251,57 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
// This has failed more than once. Now what?
}
break
;
//Subscription is cancelled
case
'customer.subscription.deleted'
:
// Find the recurring contribution in CiviCRM by mapping it from Stripe.
$query_params
=
array
(
1
=>
array
(
$customer_id
,
'String'
),
);
$rel_info_query
=
CRM_Core_DAO
::
executeQuery
(
"SELECT invoice_id
FROM civicrm_stripe_subscriptions
WHERE customer_id = %1"
,
$query_params
);
if
(
!
empty
(
$rel_info_query
))
{
$rel_info_query
->
fetch
();
if
(
!
empty
(
$rel_info_query
->
invoice_id
))
{
$invoice_id
=
$rel_info_query
->
invoice_id
;
}
else
{
CRM_Core_Error
::
Fatal
(
"Error relating this customer (
$customer_id
) to the one in civicrm_stripe_subscriptions"
);
exit
();
}
}
// Fetch Civi's info about this recurring contribution
$recur_contribution
=
civicrm_api3
(
'ContributionRecur'
,
'get'
,
array
(
'sequential'
=>
1
,
'return'
=>
"id"
,
'invoice_id'
=>
$invoice_id
));
if
(
!
$recur_contribution
[
'id'
])
{
CRM_Core_Error
::
Fatal
(
"ERROR: Stripe triggered a Webhook on an invoice not found in civicrm_contribution_recur: "
.
$stripe_event_data
);
exit
();
}
//Cancel the recurring contribution
$result
=
civicrm_api3
(
'ContributionRecur'
,
'cancel'
,
array
(
'sequential'
=>
1
,
'id'
=>
$recur_contribution
[
'id'
]
));
//Delete the record from Stripe's subscriptions table
$query_params
=
array
(
1
=>
array
(
$invoice_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
"DELETE FROM civicrm_stripe_subscriptions
WHERE invoice_id = %1"
,
$query_params
);
break
;
//Subscription is cancelled
case
'customer.subscription.deleted'
:
// Find the recurring contribution in CiviCRM by mapping it from Stripe.
$query_params
=
array
(
1
=>
array
(
$customer_id
,
'String'
),
);
$rel_info_query
=
CRM_Core_DAO
::
executeQuery
(
"SELECT invoice_id
FROM civicrm_stripe_subscriptions
WHERE customer_id = %1"
,
$query_params
);
if
(
!
empty
(
$rel_info_query
))
{
$rel_info_query
->
fetch
();
if
(
!
empty
(
$rel_info_query
->
invoice_id
))
{
$invoice_id
=
$rel_info_query
->
invoice_id
;
}
else
{
CRM_Core_Error
::
Fatal
(
"Error relating this customer (
$customer_id
) to the one in civicrm_stripe_subscriptions"
);
exit
();
}
}
// Fetch Civi's info about this recurring contribution
$recur_contribution
=
civicrm_api3
(
'ContributionRecur'
,
'get'
,
array
(
'sequential'
=>
1
,
'return'
=>
"id"
,
'invoice_id'
=>
$invoice_id
));
if
(
!
$recur_contribution
[
'id'
])
{
CRM_Core_Error
::
Fatal
(
"ERROR: Stripe triggered a Webhook on an invoice not found in civicrm_contribution_recur: "
.
$stripe_event_data
);
exit
();
}
//Cancel the recurring contribution
$result
=
civicrm_api3
(
'ContributionRecur'
,
'cancel'
,
array
(
'sequential'
=>
1
,
'id'
=>
$recur_contribution
[
'id'
]
));
//Delete the record from Stripe's subscriptions table
$query_params
=
array
(
1
=>
array
(
$invoice_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
"DELETE FROM civicrm_stripe_subscriptions
WHERE invoice_id = %1"
,
$query_params
);
break
;
// One-time donation and per invoice payment.
...
...
@@ -315,4 +315,4 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
parent
::
run
();
}
}
}
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