【问题标题】:Omnipay Payfast notify_url Laravel 4Omnipay Payfast notify_url Laravel 4
【发布时间】:2014-02-19 07:30:14
【问题描述】:

我正在尝试完成我的 omnipay laravel 4 和 Payfast 集成。我现在可以成功进行交易,但无法让 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

【问题讨论】:

    标签: laravel-4 omnipay


    【解决方案1】:

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

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

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

    【讨论】:

    • Heya Adrian,感谢您的帮助,我已经根据您的信息进行了设置,但我得到了一个:缺少 PDT 或 ITN 变量错误。
    • 但是我可以在使用 PDT 方法时让它工作,虽然这在 Payfast 上已被贬值,但 ITN 只返回 Missing PDT ITN 错误。
    猜你喜欢
    • 2017-05-25
    • 1970-01-01
    • 2014-01-12
    • 2014-03-29
    • 2014-12-07
    • 2014-12-22
    • 2016-05-08
    • 2016-03-18
    • 2020-03-04
    相关资源
    最近更新 更多