Omnipay Payfast notify_url Laravel 4

时间:2014-01-28 06:09:35

标签: laravel-4 omnipay

我试图完成我的omnipay laravel 4和Payfast Integration。我正处于成功进行交易的阶段,但我无法使notify_url正常工作。

$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();
    }

我有一个POST路由设置来接收ITN响应

                $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();
            }   

对notify_url的唯一区别是我调用了CompletePurchase方法。这里的任何帮助将不胜感激。 ITN Payfast文档位于:payfast itn documentation

1 个答案:

答案 0 :(得分:0)

Payfast使用returnUrl进行付款退回和通知:

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

因此,您只需将completePurchase()请求放在返回URL上,然后删除通知URL。