PayPalのPHP SDKを使用していますが、支払いの実行に問題があります(400、エラーコード:PAYER_CANNOT_PAY)。残高が不足しているサンドボックス購入者アカウント(PAYER_CANNOT_PAY)
サンドボックスの設定:アプリケーション
作成されたサンドボックスの買い手は、バランスとリンククレジットでアカウント作成し
開発者アカウントを作成し
- ビジネスサンドボックスアカウントを作成し
カード
コード:サンドボックスアカウントで
が支払いを作成ペイパル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);
アプリケーションは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"
},
}
これはなぜ失敗しているのですか?
ありがとうございます!
いいえ、あなたがそうした場合、支払いをしようとするとエラーが発生します。今日このコードは機能しています。 Paypalのサンドボックスはバグです。サンドボックスの通知はまだ暗号化されています(このバグに関する通知があります)。通知の検索が機能しない、トランザクションがサンドボックスのアカウントに表示されないなど – krex