我正在使用Paypal的PHP SDK,但我在执行付款时遇到问题(400,错误代码:PAYER_CANNOT_PAY)。
沙箱设置:
创建了商业沙盒帐户
创建了开发者帐户
创建了应用
使用余额和关联的信用卡创建沙盒买方帐户
代码:
使用Paypal SDK创建付款
$cred = new OAuthTokenCredential("$clientID", "$secret", $sdkConfig);
$cred->accessToken = $cred->getAccessToken($sdkConfig);
$apiContext = new ApiContext($cred);
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123") // Similar to `item_number` in Classic API
->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(5)
->setSku("321321")
->setPrice(2);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50);
$amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://test.dev/paypal?success=true")
->setCancelUrl("http://test.dev/paypal?success=false");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
$request = clone $payment;
$payment->create($apiContext);
App将用户重定向到Paypal沙盒登录页面
使用沙盒帐户登录(付款部分为空)
使用令牌,paymentID,payerID和状态(成功)重定向用户
执行付款< - 来自API 400的回复,PAYER_CANNOT_PAY
$paymentId = $request->all()['paymentId'];
$payment = Payment::get($paymentId, $apiContext);
$execution = new PaymentExecution();
$execution->setPayerId($request->all()['PayerID']);
$payment->execute($execution, $apiContext);
错误:
{
"status": 400,
"duration_time": 156,
"body": {
"message": "The combination of payer and payee settings mean that this buyer can't pay this seller.",
"debug_id": "debugid",
"details": [],
"name": "PAYER_CANNOT_PAY",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors"
},
}
知道为什么会失败吗?
提前谢谢!
答案 0 :(得分:0)
也许付款被买家的银行卡拒绝了。没有集成问题。尝试使用其他帐户确认您的集成。
答案 1 :(得分:0)
您确定您没有尝试使用作为卖家的相同开发者帐户登录和付款吗?您需要确保为买家和卖家使用单独的沙盒帐户。