1

I'm using the api to process contributions from some custom pages I have created, specifically the call to civicrm_api3('Contribution', 'transact', $params).

When I use PayPal Standard as my payment gateway how do I get the Cancel URL and Success URL to point back to the pages I have created? I can't see a way to override the default urls.

The Success url is http://example.com/administrator/?option=com_civicrm&task=civicrm/contribute/transact&_qf_ThankYou_display=1&qfKey= However I would like to redirect to http://example.com/index.php?option=com_xxx&task=payments.success

The Cancel url is http://example.com/administrator/?option=com_civicrm&task=civicrm/contribute/transact&_qf_Main_display=1&cancel=1&qfKey= However I would like to redirect to http://example.com/index.php?option=com_xxx&task=payments.cancel

Do I need to create my own Payment Gateway that inherits from the PayPal Payement Gateway? Or can I redirect the CiviCRM Tranact pages to point to the pages I need?

2
  • This question can be improved by adding details like the wrong return URLs you're currently seeing. (You can replace your site domain with example.org for anonymity.) Nov 9, 2017 at 20:46
  • I'd also recommend running a transaction and observing the URLs your browser moves through as it completes the transaction (via browser devel tools). You may see something like paypal.com/asdf => example.org/civicrm/ipn/1 => example.org/civicrm/contribute/thanks => example.org/, and those steps are all potentially significant. Nov 9, 2017 at 20:48

1 Answer 1

3

I used the alterPaymentProcessorParams Hook to override the parameters 'return' and 'cancel_return'.

The code looks like this:

function civicrm_alterPaymentProcessorParams($paymentObj,  &$rawParams,  &$cookedParams) 
{  
    if ($paymentObj->_processorName == "PayPal Standard") 
    {    
        if (!empty($rawParams['successUrl'])) {
            $cookedParams['return'] = $rawParams['successUrl'];
        }
        if (!empty($rawParams['cancelUrl'])) {
            $cookedParams['cancel_return'] = $rawParams['cancelUrl']; 
        }
    }  
}

$rawParams is the parameters that you passed to the payment processor in CiviCRM and cookedParams is what is passed from CiviCRM on to the Payment Site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.