我正在使用 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();
}
});
我明白了:
AbstractRequest.php 第 122 行中的 InvalidRequestException:
卡参数必填
似乎我必须使用客户的信用卡信息开始购买,而我不想收集这些信息(因此首先使用 PayPal)。有什么方法可以在不使用信用卡的情况下使用该 API?
我不喜欢使用 Express API,因为我不想在我的代码中使用我的 PayPal 用户名和密码。出于几个原因。
最佳答案
Card 数组字段是必需的。不需要输入信用卡号,但您需要提供一些信息。
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.
关于php - 使用 Omnipay 将 PayPal REST API 集成到 Laravel - 需要卡参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27838250/