Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
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
Rich
Stripe
Commits
d3f6c83d
Commit
d3f6c83d
authored
5 years ago
by
mattwire
Committed by
mattwire
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update webhook version
parent
509e3f8d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/Stripe.php
+1
-1
1 addition, 1 deletion
CRM/Core/Payment/Stripe.php
CRM/Stripe/Webhook.php
+3
-3
3 additions, 3 deletions
CRM/Stripe/Webhook.php
CRM/Stripe/WebhookTrait.php
+8
-27
8 additions, 27 deletions
CRM/Stripe/WebhookTrait.php
with
12 additions
and
31 deletions
CRM/Core/Payment/Stripe.php
+
1
−
1
View file @
d3f6c83d
...
...
@@ -12,7 +12,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*
* @var string
*/
const
API_VERSION
=
'2019-0
2
-1
9
'
;
const
API_VERSION
=
'2019-0
5
-1
6
'
;
/**
* Mode of operation: live or test.
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/Webhook.php
+
3
−
3
View file @
d3f6c83d
...
...
@@ -4,7 +4,7 @@ use CRM_Stripe_ExtensionUtil as E;
class
CRM_Stripe_Webhook
{
use
CRM_Stripe_Webhook
_
Trait
;
use
CRM_Stripe_WebhookTrait
;
/**
* Checks whether the payment processors have a correctly configured
...
...
@@ -20,7 +20,7 @@ class CRM_Stripe_Webhook {
]);
foreach
(
$result
[
'values'
]
as
$paymentProcessor
)
{
$webhook_path
=
self
::
getWebhookPath
(
TRUE
,
$paymentProcessor
[
'id'
]);
$webhook_path
=
self
::
getWebhookPath
(
$paymentProcessor
[
'id'
]);
\Stripe
::
setApiKey
(
CRM_Core_Payment_Stripe
::
getSecretKey
(
$paymentProcessor
));
try
{
...
...
@@ -88,7 +88,7 @@ class CRM_Stripe_Webhook {
$params
=
[
'enabled_events'
=>
self
::
getDefaultEnabledEvents
(),
'url'
=>
self
::
getWebhookPath
(
TRUE
,
$paymentProcessorId
),
'url'
=>
self
::
getWebhookPath
(
$paymentProcessorId
),
'api_version'
=>
CRM_Core_Payment_Stripe
::
getApiVersion
(),
'connect'
=>
FALSE
,
];
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/WebhookTrait.php
+
8
−
27
View file @
d3f6c83d
<?php
/**
* https://civicrm.org/licensing
*/
trait
CRM_Stripe_Webhook
_
Trait
{
trait
CRM_Stripe_WebhookTrait
{
/**********************
* MJW_Webhook_Trait: 20190
602
* MJW_Webhook_Trait: 20190
707
*********************/
/**
...
...
@@ -13,34 +16,12 @@ trait CRM_Stripe_Webhook_Trait {
/**
* Get the path of the webhook depending on the UF (eg Drupal, Joomla, Wordpress)
*
* @param bool $includeBaseUrl
* @param string $pp_id
* @param string $paymentProcessorId
*
* @return string
*/
public
static
function
getWebhookPath
(
$includeBaseUrl
=
TRUE
,
$paymentProcessorId
=
'NN'
)
{
// Assuming frontend URL because that's how the function behaved before.
// @fixme this doesn't return the right webhook path on Wordpress (often includes an extra path between .com and ? eg. abc.com/xxx/?page=CiviCRM
// We can't use CRM_Utils_System::url('civicrm/payment/ipn/' . $paymentProcessorId, NULL, $includeBaseUrl, NULL, FALSE, TRUE);
// because it returns the query string urlencoded and the base URL non urlencoded so we can't use to match existing webhook URLs
$UFWebhookPaths
=
[
"Drupal"
=>
"civicrm/payment/ipn/
{
$paymentProcessorId
}
"
,
"Joomla"
=>
"?option=com_civicrm&task=civicrm/payment/ipn/
{
$paymentProcessorId
}
"
,
"WordPress"
=>
"?page=CiviCRM&q=civicrm/payment/ipn/
{
$paymentProcessorId
}
"
];
$basePage
=
''
;
$config
=
CRM_Core_Config
::
singleton
();
if
(
!
empty
(
$config
->
wpBasePage
)
&&
$config
->
userFramework
==
'WordPress'
)
{
// Add in the wordpress base page to the URL.
$basePage
=
(
substr
(
$config
->
wpBasePage
,
-
1
)
==
'/'
)
?
$config
->
wpBasePage
:
"
$config->wpBasePage
/"
;
}
// 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
CRM_Utils_System
::
baseURL
()
.
$basePage
.
$UFWebhookPath
;
}
public
static
function
getWebhookPath
(
$paymentProcessorId
)
{
$UFWebhookPath
=
CRM_Utils_System
::
url
(
'civicrm/payment/ipn/'
.
$paymentProcessorId
,
NULL
,
TRUE
,
NULL
,
FALSE
,
TRUE
);
return
$UFWebhookPath
;
}
...
...
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