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
306830e3
Commit
306830e3
authored
8 years ago
by
Joshua Walker
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #188 from h-c-c/4.7-dev_CRM-19945-workaround
workaround for CRM-19945
parents
fd66a345
a8239d27
Branches
Branches containing commit
Tags
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
+21
-5
21 additions, 5 deletions
CRM/Stripe/Page/Webhook.php
with
21 additions
and
5 deletions
CRM/Stripe/Page/Webhook.php
+
21
−
5
View file @
306830e3
...
...
@@ -39,6 +39,18 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
'options'
=>
array
(
'limit'
=>
1
,
'sort'
=>
'id DESC'
),
'contribution_test'
=>
$test_mode
,
));
// Workaround for CRM-19945.
try
{
$recurring_info
->
previous_completed_contribution_id
=
civicrm_api3
(
'contribution'
,
'getvalue'
,
array
(
'return'
=>
'id'
,
'contribution_recur_id'
=>
$recurring_info
->
id
,
'contribution_status_id'
=>
array
(
'IN'
=>
array
(
'Completed'
)),
'options'
=>
array
(
'limit'
=>
1
,
'sort'
=>
'id DESC'
),
'contribution_test'
=>
$test_mode
,
));
}
catch
(
Exception
$e
)
{
// This is fine....could only be a pending in the db.
}
if
(
!
empty
(
$recurring_info
->
previous_contribution_id
))
{
//$previous_contribution_query->fetch();
}
...
...
@@ -192,7 +204,10 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
// prorated invoices.
$result
=
civicrm_api3
(
'Contribution'
,
'repeattransaction'
,
array
(
'contribution_recur_id'
=>
$recurring_info
->
id
,
// Actually, don't use contribution_recur_id until CRM-19945 patches make it in to 4.6/4.7
// and we have a way to require a minimum minor CiviCRM version.
//'contribution_recur_id' => $recurring_info->id,
'original_contribution_id'
=>
$recurring_info
->
previous_completed_contribution_id
,
'contribution_status_id'
=>
"Completed"
,
'receive_date'
=>
$receive_date
,
'trxn_id'
=>
$charge_id
,
...
...
@@ -274,7 +289,8 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
}
else
{
// Create a new Failed contribution
// Record a Failed contribution. Use repeattransaction for this when CRM-19984
// patch makes it in 4.6/4.7.
$result
=
civicrm_api3
(
'Contribution'
,
'create'
,
array
(
'contribution_recur_id'
=>
$recurring_info
->
id
,
'contribution_status_id'
=>
"Failed"
,
...
...
@@ -415,7 +431,7 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
CRM_Core_DAO
::
executeQuery
(
"UPDATE civicrm_stripe_subscriptions
SET contribution_recur_id = %1 where subscription_id = %2"
,
$query_params
);
// Find out if the plan is ascociated with a membership and if so
// Find out if the plan is ascociated with a membership and if so
// adjust it to the new level.
$membership_result
=
civicrm_api3
(
'Membership'
,
'get'
,
array
(
...
...
@@ -430,8 +446,8 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
$new_membership_type_id
=
substr
(
$plan_name_elements
[
0
],
strrpos
(
$plan_name_elements
[
0
],
'_'
)
+
1
);
}
// Adjust to the new membership level.
if
(
!
empty
(
$new_membership_type_id
)
&&
!
empty
(
$membership_result
[
'values'
][
0
][
'id'
])
)
{
// Adjust to the new membership level.
if
(
!
empty
(
$new_membership_type_id
))
{
$membership_id
=
$membership_result
[
'values'
][
0
][
'id'
];
$result
=
civicrm_api3
(
'Membership'
,
'create'
,
array
(
'sequential'
=>
1
,
...
...
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