Commit 3ce9d64d authored by mattwire's avatar mattwire

Fix webhook path on wordpress and false errors from the webhook check

parent 7c41c3c3
...@@ -67,10 +67,10 @@ class CRM_Stripe_Utils_Check_Webhook { ...@@ -67,10 +67,10 @@ class CRM_Stripe_Utils_Check_Webhook {
else { else {
$messages[] = new CRM_Utils_Check_Message( $messages[] = new CRM_Utils_Check_Message(
'stripe_webhook', 'stripe_webhook',
E::ts('The %1 (%2) Payment Processor does not have a webhook configured. This is only required for recurring contributions. You can review from your Stripe account, under Developers > Webhooks. The webhook URL is: %3', [ E::ts('The %1 (%2) Payment Processor does not have a valid webhook configured for this website. This is only required for recurring contributions. You can review from your Stripe account, under Developers > Webhooks. The webhook URL is: %3', [
1 => $pp['name'], 1 => $pp['name'],
2 => $pp['id'], 2 => $pp['id'],
3 => $webhook_path, 3 => urldecode($webhook_path),
]), ]),
E::ts('Stripe - Webhook'), E::ts('Stripe - Webhook'),
\Psr\Log\LogLevel::WARNING, \Psr\Log\LogLevel::WARNING,
......
...@@ -210,7 +210,25 @@ function stripe_civicrm_buildForm($formName, &$form) { ...@@ -210,7 +210,25 @@ function stripe_civicrm_buildForm($formName, &$form) {
*/ */
function stripe_get_webhook_path($includeBaseUrl = TRUE, $pp_id = 'NN') { function stripe_get_webhook_path($includeBaseUrl = TRUE, $pp_id = 'NN') {
// Assuming frontend URL because that's how the function behaved before. // Assuming frontend URL because that's how the function behaved before.
return CRM_Utils_System::url('civicrm/payment/ipn/' . $pp_id, NULL, $includeBaseUrl, NULL, TRUE, TRUE); // @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
// return CRM_Utils_System::url('civicrm/payment/ipn/' . $pp_id, NULL, $includeBaseUrl, NULL, FALSE, 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) {
$sepChar = (substr(CIVICRM_UF_BASEURL, -1) == '/') ? '' : '/';
return CIVICRM_UF_BASEURL . $sepChar . $UFWebhookPath;
}
return $UFWebhookPath;
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment