0

我有一个电子商务网站,它使用 Omnipay 重定向到 Paypal 快速结账。它将正确地将用户重定向到 Paypal,并返回带有 payerID 和所有内容的成功消息。但是,它实际上不收取任何款项,也不会在我们的贝宝账户上显示为已收取任何款项。我不确定这是贝宝问题还是 Omnipay 的配置问题。我想 Paypal 会处理这部分,但由于它不起作用(在我们的旧网站上它工作正常,但我们不使用 Omnipay。)

    $gateway = Omnipay::gateway('paypal');

    //production
    $gateway->setUsername('11111111');
    $gateway->setPassword('1111111111');
    $gateway->setSignature('111111111');

    $cardInput = array(
        'firstName' => $info['first_name_bill'],
        'lastName' => $info['last_name_bill'],
        'billingAddress1' => $info['street_address_1_bill'],
        'billingAddress2' => $info['street_address_2_bill'],
        'billingPhone' => $info['phone_bill'],
        'billingCity' => $info['city_bill'],
        'billingState' => $info['state_bill'],
        'billingPostCode' => $info['zip_bill'],
        'shippingAddress1' => $info['street_address_1_ship'],
        'shippingAddress2' => $info['street_address_2_ship'],
        'shippingPhone' => $info['phone_ship'],
        'shippingCity' => $info['city_ship'],
        'shippingState' => $info['state_ship'],
        'shippingPostCode' => $info['zip_ship'],
    );

    $card = Omnipay::creditCard($cardInput);

    //live
    $response = Omnipay::purchase(
        array(
            'cancelUrl' => 'http://store.site.com/cart/cancel-payment',
            'returnUrl' => 'http://store.site.com/cart/successful-payment',
            'amount' => Input::get('total'),
            'currency' => 'USD',
            'card' => $card,
            'description' => 'Stuff'
        )
    )->send();

    if ($response->isSuccessful()) {
        return Redirect('cart/successful-payment');
    } elseif ($response->isRedirect()) {
        $response->redirect(); // this will automatically forward the customer
    } else {
        return Redirect::back()->with('error', 'There was a problem. Please try again.');
    }
} else {
    return Redirect::to('cart/successful-payment');
}

所以基本上这会做的是将他们重定向到 Paypal 进行付款,然后重定向回我们的商店。这一切都很好。他们可以输入他们的卡号,然后在提交后返回我们的商店。问题是在它得到回报后,通过贝宝没有任何反应。没有订单或付款被交换。

4

1 回答 1

1

在您的返回函数中,执行此 URL 时调用的函数:http: //store.site.com/cart/successful-payment您需要调用 completePurchase。像这样的东西:

        $gateway = Omnipay::gateway('paypal');

        //production
        $gateway->setUsername('11111111');
        $gateway->setPassword('1111111111');
        $gateway->setSignature('111111111');
        $purchaseId = $_GET['PayerID'];
        $response = $gateway->completePurchase([
            'transactionReference' => $purchaseId
        ])->send();
        // .. check $response here.
于 2015-02-13T20:38:01.663 回答