Skip to content
Snippets Groups Projects
Commit 3ce9d64d authored by mattwire's avatar mattwire
Browse files

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

parent 7c41c3c3
No related branches found
No related tags found
No related merge requests found
......@@ -67,10 +67,10 @@ class CRM_Stripe_Utils_Check_Webhook {
else {
$messages[] = new CRM_Utils_Check_Message(
'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'],
2 => $pp['id'],
3 => $webhook_path,
3 => urldecode($webhook_path),
]),
E::ts('Stripe - Webhook'),
\Psr\Log\LogLevel::WARNING,
......
......@@ -210,7 +210,25 @@ function stripe_civicrm_buildForm($formName, &$form) {
*/
function stripe_get_webhook_path($includeBaseUrl = TRUE, $pp_id = 'NN') {
// 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;
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment