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
68a602de
Commit
68a602de
authored
8 years ago
by
Peter Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
make Upgrader more forgiving
parent
306830e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Stripe/Upgrader.php
+30
-25
30 additions, 25 deletions
CRM/Stripe/Upgrader.php
with
30 additions
and
25 deletions
CRM/Stripe/Upgrader.php
+
30
−
25
View file @
68a602de
...
...
@@ -127,6 +127,7 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
}
}
catch
(
CiviCRM_API3_Exception
$e
)
{
CRM_Core_Error
::
debug_log_message
(
"Cannot find a PaymentProcessorType named Stripe."
,
$out
=
false
);
return
;
}
}
...
...
@@ -186,7 +187,7 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
));
}
catch
(
Exception
$e
)
{
$this
->
ctx
->
log
->
info
(
'Update 4704 failed. Has Stripe been removed as a payment processor?
'
);
CRM_Core_Error
::
debug_log_message
(
'Update 4704 failed. Has Stripe been removed as a payment processor?'
,
$out
=
false
);
return
;
}
try
{
...
...
@@ -195,17 +196,19 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
'customer'
=>
$customer_id
,
'limit'
=>
1
,
));
if
(
!
empty
(
$subscription
))
{
$query_params
=
array
(
1
=>
array
(
$subscription
[
'data'
][
0
][
'id'
],
'String'
),
2
=>
array
(
$customer_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
'UPDATE civicrm_stripe_subscriptions SET subscription_id = %1 where customer_id = %2;'
,
$query_params
);
}
}
catch
(
Exception
$e
)
{
CRM_Core_Error
::
fatal
(
'Cannot find Stripe API key: '
.
$e
->
getMessage
());
return
;
catch
(
Exception
$e
)
{
// Don't quit here. A missing customer in Stipe is OK. They don't exist, so they can't have a subscription.
$debug_code
=
'Cannot find Stripe API key: '
.
$e
->
getMessage
();
CRM_Core_Error
::
debug_log_message
(
$debug_code
,
$out
=
false
);
}
if
(
!
empty
(
$subscription
[
'data'
][
0
][
'id'
]))
{
$query_params
=
array
(
1
=>
array
(
$subscription
[
'data'
][
0
][
'id'
],
'String'
),
2
=>
array
(
$customer_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
'UPDATE civicrm_stripe_subscriptions SET subscription_id = %1 where customer_id = %2;'
,
$query_params
);
unset
(
$subscription
);
}
}
}
...
...
@@ -257,22 +260,24 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
$test_mode
=
(
int
)
!
$subscriptions
->
is_live
;
try
{
// Fetch the recurring contribution Id.
$recur_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
array
(
'sequential'
=>
1
,
'return'
=>
"contribution_recur_id"
,
'invoice_id'
=>
$subscriptions
->
invoice_id
,
'contribution_test'
=>
$test_mode
,
$recur_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
array
(
'sequential'
=>
1
,
'return'
=>
"contribution_recur_id"
,
'invoice_id'
=>
$subscriptions
->
invoice_id
,
'contribution_test'
=>
$test_mode
,
));
if
(
!
empty
(
$recur_id
))
{
$p
=
array
(
1
=>
array
(
$recur_id
,
'Integer'
),
2
=>
array
(
$subscriptions
->
invoice_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
'UPDATE civicrm_stripe_subscriptions SET contribution_recur_id = %1 WHERE invoice_id = %2;'
,
$p
);
}
}
catch
(
CiviCRM_API3_Exception
$e
)
{
return
;
catch
(
CiviCRM_API3_Exception
$e
)
{
// Don't quit here. If we can't find the recurring ID for a single customer, make a note in the error log and carry on.
$debug_code
=
'Recurring contribution search: '
.
$e
->
getMessage
();
CRM_Core_Error
::
debug_log_message
(
$debug_code
,
$out
=
false
);
}
if
(
!
empty
(
$recur_id
))
{
$p
=
array
(
1
=>
array
(
$recur_id
,
'Integer'
),
2
=>
array
(
$subscriptions
->
invoice_id
,
'String'
),
);
CRM_Core_DAO
::
executeQuery
(
'UPDATE civicrm_stripe_subscriptions SET contribution_recur_id = %1 WHERE invoice_id = %2;'
,
$p
);
}
}
return
TRUE
;
...
...
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