我正在使用 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 用户名和密码。有几个原因。