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
1b903715
Commit
1b903715
authored
6 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Support Joomla/WP for IDS detection on webhooks
parent
9c47e9b7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
5.1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Payment/StripeIPN.php
+10
-9
10 additions, 9 deletions
CRM/Core/Payment/StripeIPN.php
stripe.php
+29
-23
29 additions, 23 deletions
stripe.php
with
39 additions
and
32 deletions
CRM/Core/Payment/StripeIPN.php
+
10
−
9
View file @
1b903715
...
...
@@ -270,7 +270,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
'contribution_status_id'
=>
"In Progress"
));
return
TRUE
;
return
;
// Failed recurring payment.
case
'invoice.payment_failed'
:
...
...
@@ -314,7 +314,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
'modified_date'
=>
$fail_date
,
));
return
TRUE
;
return
;
// Subscription is cancelled
case
'customer.subscription.deleted'
:
...
...
@@ -331,14 +331,14 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
CRM_Core_DAO
::
executeQuery
(
"DELETE FROM civicrm_stripe_subscriptions
WHERE subscription_id = %1"
,
$query_params
);
return
TRUE
;
return
;
// One-time donation and per invoice payment.
case
'charge.succeeded'
:
//$this->setInfo();
// TODO: Implement this so we can mark payments as failed?
// Not implemented.
return
TRUE
;
return
;
// Subscription is updated. Delete existing recurring contribution and start a fresh one.
// This tells a story to site admins over editing a recurring contribution record.
...
...
@@ -346,7 +346,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
$this
->
setInfo
();
if
(
empty
(
$this
->
previous_plan_id
))
{
// Not a plan change...don't care.
return
TRUE
;
return
;
}
$new_civi_invoice
=
md5
(
uniqid
(
rand
(),
TRUE
));
...
...
@@ -430,7 +430,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
));
}
}
return
TRUE
;
return
;
// Keep plans table in sync with Stripe when a plan is deleted.
case
'plan.deleted'
:
...
...
@@ -444,10 +444,10 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
CRM_Core_DAO
::
executeQuery
(
"DELETE FROM civicrm_stripe_plans WHERE
plan_id = %1 AND processor_id = %2 and is_live = %3"
,
$query_params
);
return
TRUE
;
return
;
}
// Unhandled event type.
return
TRUE
;
return
;
}
/**
...
...
@@ -594,6 +594,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
public
function
exception
(
$message
)
{
$errorMessage
=
'StripeIPN Exception: Event: '
.
$this
->
event_type
.
' Error: '
.
$message
;
Civi
::
log
()
->
debug
(
$errorMessage
);
throw
new
CRM_Core_Exception
(
$errorMessage
);
//throw new CRM_Core_Exception($errorMessage);
exit
();
}
}
This diff is collapsed.
Click to expand it.
stripe.php
+
29
−
23
View file @
1b903715
...
...
@@ -39,22 +39,12 @@ function stripe_civicrm_uninstall() {
* Implementation of hook_civicrm_enable().
*/
function
stripe_civicrm_enable
()
{
$UF_webhook_paths
=
array
(
"Drupal"
=>
"/civicrm/payment/ipn/NN"
,
"Joomla"
=>
"/index.php/component/civicrm/?task=civicrm/payment/ipn/NN"
,
"WordPress"
=>
"/?page=CiviCRM&q=civicrm/payment/ipn/NN"
);
// Use Drupal path as default if the UF isn't in the map above
$webookhook_path
=
(
array_key_exists
(
CIVICRM_UF
,
$UF_webhook_paths
))
?
CIVICRM_UF_BASEURL
.
$UF_webhook_paths
[
CIVICRM_UF
]
:
CIVICRM_UF_BASEURL
.
$UF_webhook_paths
[
'Drupal'
];
$UFWebhookPath
=
stripe_get_webhook_path
(
TRUE
);
CRM_Core_Session
::
setStatus
(
"
<br />Don't forget to set up Webhooks in Stripe so that recurring contributions are ended!
<br />Webhook path to enter in Stripe:
<br/><em>
$
webook
hook
_p
ath
</em>
<br/><em>
$
UFWeb
hook
P
ath
</em>
<br />Replace NN with the actual payment processor ID configured on your site.
<br />
"
,
...
...
@@ -210,21 +200,37 @@ function stripe_civicrm_buildForm($formName, &$form) {
}
}
/**
* Get the path of the webhook depending on the UF (eg Drupal, Joomla, Wordpress)
*
* @param bool $includeBaseUrl
*
* @return string
*/
function
stripe_get_webhook_path
(
$includeBaseUrl
=
TRUE
)
{
$UFWebhookPaths
=
[
"Drupal"
=>
"civicrm/payment/ipn/NN"
,
"Joomla"
=>
"?option=com_civicrm&task=civicrm/payment/ipn/NN"
,
"WordPress"
=>
"?page=CiviCRM&q=civicrm/payment/ipn/NN"
];
// Use Drupal path as default if the UF isn't in the map above
$UFWebhookPath
=
(
array_key_exists
(
CIVICRM_UF
,
$UFWebhookPaths
))
?
$UFWebhookPaths
[
CIVICRM_UF
]
:
$UFWebhookPaths
[
'Drupal'
];
if
(
$includeBaseUrl
)
{
return
CIVICRM_UF_BASEURL
.
'/'
.
$UFWebhookPath
;
}
return
$UFWebhookPath
;
}
/*
* Implementation of hook_idsException.
*
* Ensure webhooks don't get caught in the IDS check.
*/
function
stripe_civicrm_idsException
(
&
$skip
)
{
// Handle old method.
$skip
[]
=
'civicrm/stripe/webhook'
;
$result
=
civicrm_api3
(
'PaymentProcessor'
,
'get'
,
array
(
'sequential'
=>
1
,
'return'
=>
"id"
,
'class_name'
=>
"Payment_stripe"
,
'is_active'
=>
1
,
));
foreach
(
$result
[
'values'
]
as
$value
)
{
$skip
[]
=
'civicrm/payment/ipn/'
.
$value
[
'id'
];
}
// Path is always set to civicrm/payment/ipn (checked on Drupal/Joomla)
$skip
[]
=
'civicrm/payment/ipn'
;
}
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