2

我正在使用 L5 并希望将我的 PayPal 购买集成到该系统中。沙箱已经设置好了,我可以使用真正的 PayPal API 包完成所有付款,但是因为我想尝试使用 Omnipay 来完成,所以我有点挣扎:

当我执行此代码时:

Route::get('test', function()
{
$gateway = Omnipay::create('PayPal_Rest');
$gateway->setClientId('{my id}');
$gateway->setSecret('{my secret}');
$gateway->setTestMode(true);

$params = array(
    'cancelUrl' => 'http://webshop.app',
    'returnUrl' => 'http://webshop.app/testresp',
    'name'  => 'Your Purchase',
    'description' => 'Your Description',
    'amount' => '15.99',
    'currency' => 'EUR'
);

Session::put('params', $params);
Session::save();

$resp = $gateway->purchase($params)->send();

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

我明白了: InvalidRequestException in AbstractRequest.php line 122: The card parameter is required

似乎我必须使用客户的信用卡信息开始购买,我不想收集这些信息(因此首先使用 PayPal)。有没有办法在不使用信用卡的情况下使用该 API?

我不喜欢使用 Express API,因为我不想在我的代码中使用我的 PayPal 用户名和密码。有几个原因。

4

2 回答 2

1

The Card array field is required. it's not required to insert credit card number, but you will need to provide some information.

From the official docs:

Even off-site gateways make use of the CreditCard object, because often you need to pass customer billing or shipping details through to the gateway.

于 2015-01-08T21:28:58.103 回答
0

查看我的omnipay-paypal网关代码分支的以下分支: https ://github.com/delatbabel/omnipay-paypal/tree/accept-paypal-payments

这包括允许您不通过信用卡并让 PayPal 进行付款处理的代码。

我已经提交了一个 PR,但它还没有被合并到主 omnipay-paypal 存储库中。

于 2015-02-13T20:49:55.657 回答