-1

I'm struggling with a PayFast onsite integration.

PayFast is failing to redirect following a successful payment. It looks as though my urls are being changed.

$data = [
// Merchant details
'merchant_id' => 'xxx', //required
'merchant_key' => 'xxx', //required
'return_url' => 'https://www.example.co.za/signup/success_temp.php', // optional
'cancel_url' => 'https://www.example.co.za/signup/cancel.php', // optional
'notify_url'=> 'https://www.example.co.za/signup/notify.php', // optional];

$data_subscription = [
// Payment methods
'payment_method' => 'cc', // *optional - Must include for subscriptions

// Subscriptions
'subscription_type' => '1', // required
'billing_date' => $billing_date, // *optional
'recurring_amount' => $recurring_amount, // *optional
'frequency' => '3', // required
'cycles' => '0' // required];

// Add subscription data to $data
if (1 == 1) {
$data = array_merge($data, $data_subscription);
}

From here I run the standard PayFast code for their online integration but the return_url comes back: https:\/\/www.example.co.za\/signup\/success_temp.php

And the cancel_url: https:\/\/www.example.co.za\/signup\/cancel.php

I have tested the redirect to google.com and I get the same issue.

Any ideas where I have gone wrong?

  • You're setting `return_url` and `cancel_url` in the code you've written. E.g. line 5 of your code: `'return_url' => 'https://www.example.co.za/signup/success_temp.php'` – Joundill Feb 20 '22 at 22:05
  • Thanks for the reply. Yes, the url I set is correct. However, when Payfast attempts to redirect to the url, it is changed to https:\/\/www.example.co.za\/signup\/success_temp.php. I'm trying to establish what could be adding the backslashes before each forward slash. – Just_James Feb 21 '22 at 07:23

1 Answers1

0

The error doesn't have to do with the URLs. The default Payfast code echoes a JSON object with the forward slashes escaped.

I believe there must be an error with my notify_url. If the notify_url doesn't return a 200 then they don't redirect to your return_url.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 21 '22 at 18:40