我正在尝试将Paypal集成为我的Laravel 5.8
网站中的付款网关。为此,我使用Laravel-Omnipay软件包,该软件包将Omnipay
集成到Laravel中。
对于我的Paypal
商业帐户,我已经设置了凭据。将Paypal沙箱与以下代码结合使用:
Route::get('paypal', function() {
$gateway = Omnipay::create('PayPal_Rest');
$gateway->initialize(array(
'clientId' => 'MySandboxClientId',
'secret' => 'MySandboxSecret',
'testMode' => true,
));
$card = new CreditCard(array(
'firstName' => 'first name',
'lastName' => 'last name',
'number' => '5498876202508868',
'cvv' => '123',
'expiryMonth' => '09',
'expiryYear' => '2024',
'billingAddress1' => '1 Scrubby Creek Road',
'billingCountry' => 'AU',
'billingCity' => 'Scrubby Creek',
'billingPostcode' => '4999',
'billingState' => 'QLD',
));
try {
$transaction = $gateway->purchase(array(
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'card' => $card,
));
$response = $transaction->send();
$data = $response->getData();
dd($data);
echo "Gateway purchase response data == " . print_r($data, true) . "\n";
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
}
} catch (\Exception $e) {
echo "Exception caught while attempting authorize.\n";
echo "Exception type == " . get_class($e) . "\n";
echo "Message == " . $e->getMessage() . "\n";
}
});
但是,当我尝试使用自己的信用卡转为实时付款时。我可能遇到Unauthorized payment.
错误。我使用的代码与上面的代码相同,我只是用实时沙箱凭据替换了clientId和secret。
如何实时拨打REST Api。我需要进行1美元的交易,以便测试卡是否有效。
答案 0 :(得分:1)
根据贝宝(Paypal)文档, ,
未经帐户所有者许可,通过借记卡或信用卡,银行帐户或PayPal帐户进行的任何付款都是未经授权的付款。
当PayPal认为付款未经授权时,我们会暂停付款。在我们确定付款是否被授权之前,无法提取资金。
如果付款未经授权,则款项将退回到发送者的帐户中。符合“贝宝卖家保护”资格准则的卖家受到保护。
所以这可能是信用卡问题。请尝试使用其他信用卡或按照此处提到的说明进行操作。 Unauthorized error paypal