0

Im trying to complete my omnipay laravel 4 and Payfast Integration. I am at the point where i can successfully make a transaction, but I'm having trouble getting the notify_url to work.

$gateway = Omnipay::create('PayFast');
    $gateway->setMerchantId = '10000100';
    $gateway->setMerchantKey = '46f0cd694581a';

    $response = $gateway->purchase([
            'merchant_id' => '10000100',
            'merchant_key' => '46f0cd694581a', 
            'return_url' => 'http://signup.areweup.co.za/return',
            'cancel_url' => 'http://signup.areweup.co.za/cancel',
            'notify_url' => 'http://signup.areweup.co.za/notify',
            'name_first' => 'Warren',
            'name_last'  => 'Hansen',
            'm_payment_id' => '8542',
            'amount' => '39.00', 
            'item_name' => 'Are We Up',
            'description' => 'Peace of mind at just R39 a month.'
            ])->send();

    if ($response->isSuccessful()) {
        // payment was successful: update database
        print_r($response);
    } elseif ($response->isRedirect()) {
        // redirect to offsite payment gateway
        $response->redirect();
    } else {
        // payment failed: display message to customer
        echo $response->getMessage();
    }

I have a POST route setup to receive the ITN response

                $gateway = Omnipay::create('PayFast');
            $gateway->setMerchantId = '10000100';
            $gateway->setMerchantKey = '46f0cd694581a';

            $response = $gateway->CompletePurchase([
                    'merchant_id' => '10000100',
                    'merchant_key' => '46f0cd694581a', 
                    'return_url' => 'http://signup.areweup.co.za/return',
                    'cancel_url' => 'http://signup.areweup.co.za/cancel',
                    'notify_url' => 'http://signup.areweup.co.za/notify',
                    'name_first' => 'Warren',
                    'name_last'  => 'Hansen',
                    'm_payment_id' => '8542',
                    'amount' => '39.00', 
                    'item_name' => 'Are We Up',
                    'description' => 'Peace of mind at just R39 a month.'
                    ])->send();

            if ($response->isSuccessful()) {
                // payment was successful: update database
                print_r($response);
            } elseif ($response->isRedirect()) {
                // redirect to offsite payment gateway
                $response->redirect();
            } else {
                // payment failed: display message to customer
                echo $response->getMessage();
            }   

Only difference on the notify_url is that im calling the CompletePurchase method. Any help here would be greatly appreciated. The ITN Payfast Documentation is here:payfast itn documentation

Woogygun
  • 1
  • 2

1 Answers1

0

Payfast uses the returnUrl for both payment return and notifications:

https://github.com/omnipay/payfast/blob/master/src/Omnipay/PayFast/Message/PurchaseRequest.php#L52

So you should simply put the completePurchase() request on the return URL and remove the notify URL.

Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70
  • Heya Adrian, thanks for the help man, I've got it setup as per your info about but im getting an: Missing PDT or ITN variables error. – Woogygun Feb 16 '14 at 09:33
  • However i can get it to work when using the PDT method, this has been depreciated on Payfast though, ITN just returns the Missing PDT ITN error. – Woogygun Feb 16 '14 at 12:10