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
59e18019
Commit
59e18019
authored
9 years ago
by
BorislavZlatanov
Browse files
Options
Downloads
Plain Diff
Resolved merge conflicts
parents
59356122
3fee1676
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CRM/Core/Payment/Stripe.php
+9
-2
9 additions, 2 deletions
CRM/Core/Payment/Stripe.php
CRM/Stripe/Page/Webhook.php
+52
-1
52 additions, 1 deletion
CRM/Stripe/Page/Webhook.php
README.md
+53
-46
53 additions, 46 deletions
README.md
js/civicrm_stripe.js
+5
-3
5 additions, 3 deletions
js/civicrm_stripe.js
with
119 additions
and
52 deletions
CRM/Core/Payment/Stripe.php
+
9
−
2
View file @
59e18019
...
...
@@ -574,8 +574,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// card to be charged immediately. So, since Stripe only supports one
// subscription per customer, we have to cancel the existing active
// subscription first.
if
(
!
empty
(
$stripe_customer
->
subscription
)
&&
$stripe_customer
->
subscription
->
status
==
'active'
)
{
$stripe_customer
->
cancelSubscription
();
$subscriptions
=
$stripe_customer
->
offsetGet
(
'subscriptions'
);
$data
=
$subscriptions
->
offsetGet
(
'data'
);
if
(
!
empty
(
$data
))
{
$status
=
$data
[
0
]
->
offsetGet
(
'status'
);
if
(
$status
==
'active'
)
{
$stripe_customer
->
cancelSubscription
();
}
}
// Attach the Subscription to the Stripe Customer.
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/Page/Webhook.php
+
52
−
1
View file @
59e18019
...
...
@@ -251,6 +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
;
// One-time donation and per invoice payment.
...
...
@@ -264,4 +315,4 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
parent
::
run
();
}
}
}
This diff is collapsed.
Click to expand it.
README.md
+
53
−
46
View file @
59e18019
CiviCRM Stripe Payment Processor
--------------------------------
Version 1.8+ of this extension
*must*
use Stripe's latest API version (at least 2013-12-03).
Go to _Account Settings_ -> _API Keys_ tab -> click _Upgrade available_ button.
More info on how to change: https://stripe.com/docs/upgrades#how-can-i-upgrade-my-api
CONFIGURATION
-------------
All configuration is in the standard Payment Processors settings area in CiviCRM admin.
WEBHOOK & RECURRING PAYMENTS
---------
The Webhook.php file is registered to the path of civicrm/stripe/webhook
You will have to make a Webhook rule in your Stripe.com account and enter this path for recurring charges to end!
For Drupal: https://example.com/civicrm/stripe/webhook
For Joomla: https://example.com/index.php/component/civicrm/?task=civicrm/stripe/webhook
For Wordpress: https://example.com/?page=CiviCRM&q=civicrm/stripe/webhook
INSTALLATION
------------
For CiviCRM 4.4 & up:
1) Your CiviCRM 'Resource URLs' must be set to the extensions directory
relative to Drupal/CRM base. Example: /sites/all/civicrm_extensions/
*NOT the full server path like /var/www/sites/all/civicrm_extensions/*
The admin page for Resource URLs is: /civicrm/admin/setting/url
2) Install extension via CiviCRM's "Manage Extensions" page.
GOOD TO KNOW
------------
*
The stripe-php package has been added to this project & no longer needs to be
downloaded separately.
*
You do not need the separate civicrm_stripe CMS module for 4.2 & up
*
There will no longer be branches for each version. The branches will be:
*
Civi's major.minor-dev, and we will create releases (tags) for each new release version.
*
Example: 4.6-dev.
AUTHOR INFO
-----------
Joshua Walker
http://drastikbydesign.com
https://drupal.org/user/433663
OTHER CREDITS
-------------
Big thanks to rgburton & Swingline0 for adding wonderful new features to the project.
CiviCRM Stripe Payment Processor
--------------------------------
Version 1.8+ of this extension
*must*
use Stripe's latest API version (at least 2013-12-03).
Go to _Account Settings_ -> _API Keys_ tab -> click _Upgrade available_ button.
More info on how to change: https://stripe.com/docs/upgrades#how-can-i-upgrade-my-api
CONFIGURATION
-------------
All configuration is in the standard Payment Processors settings area in CiviCRM admin.
WEBHOOK & RECURRING PAYMENTS
---------
The Webhook.php file is registered to the path of civicrm/stripe/webhook
You will have to make a Webhook rule in your Stripe.com account and enter this path for recurring charges to end!
For Drupal: https://example.com/civicrm/stripe/webhook
For Joomla: https://example.com/index.php/component/civicrm/?task=civicrm/stripe/webhook
For Wordpress: https://example.com/?page=CiviCRM&q=civicrm/stripe/webhook
INSTALLATION
------------
For CiviCRM 4.4 & up:
1) Your CiviCRM 'Resource URLs' must be set to the extensions directory
relative to Drupal/CRM base. Example: /sites/all/civicrm_extensions/
*NOT the full server path like /var/www/sites/all/civicrm_extensions/*
The admin page for Resource URLs is: /civicrm/admin/setting/url
2) Install extension via CiviCRM's "Manage Extensions" page.
CANCELLING RECURRING CONTRIBUTIONS
------------
You can cancel a recurring contribution from the Stripe.com dashboard. Go to Customers and then to the specific customer.
Inside the customer you will see a Subscriptions section. Click Cancel on the subscription you want to cancel.
Stripe.com will cancel the subscription and will send a webhook to your site (if you have set the webhook options correctly).
Then the stripe_civicrm extension will process the webhook and cancel the Civi recurring contribution.
GOOD TO KNOW
------------
*
The stripe-php package has been added to this project & no longer needs to be
downloaded separately.
*
You do not need the separate civicrm_stripe CMS module for 4.2 & up
*
There will no longer be branches for each version. The branches will be:
*
Civi's major.minor-dev, and we will create releases (tags) for each new release version.
*
Example: 4.6-dev.
AUTHOR INFO
-----------
Joshua Walker
http://drastikbydesign.com
https://drupal.org/user/433663
OTHER CREDITS
-------------
Big thanks to rgburton & Swingline0 for adding wonderful new features to the project.
This diff is collapsed.
Click to expand it.
js/civicrm_stripe.js
+
5
−
3
View file @
59e18019
...
...
@@ -143,9 +143,11 @@
if
(
$
(
'
#priceset
'
).
length
)
{
additionalParticipants
=
cj
(
"
#additional_participants
"
).
val
();
// The currentTotal is already being calculated in Form/Contribution/Main.tpl.
if
(
currentTotal
==
0
&&
!
additionalParticipants
)
{
// This is also hit when "Going back", but we already have stripe_token.
return
true
;
if
(
typeof
currentTotal
!==
'
undefined
'
)
{
if
(
currentTotal
==
0
&&
!
additionalParticipants
)
{
// This is also hit when "Going back", but we already have stripe_token.
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