余额不起作用的沙盒买家帐户(PAYER_CANNOT_PAY)

时间:2017-05-20 15:06:29

标签: php paypal paypal-sandbox

我正在使用Paypal的PHP SDK,但我在执行付款时遇到问题(400,错误代码:PAYER_CANNOT_PAY)。

沙箱设置:

  1. 创建了商业沙盒帐户

  2. 创建了开发者帐户

  3. 创建了应用

  4. 使用余额和关联的信用卡创建沙盒买方帐户

  5. 代码:

    1. 使用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);
      
    2. App将用户重定向到Paypal沙盒登录页面

    3. 使用沙盒帐户登录(付款部分为空)

    4. 使用令牌,paymentID,payerID和状态(成功)重定向用户

    5. 执行付款< - 来自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);
      
    6. 错误:

      {
      "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"
      },
      

      }

      知道为什么会失败吗?

      提前谢谢!

2 个答案:

答案 0 :(得分:0)

也许付款被买家的银行卡拒绝了。没有集成问题。尝试使用其他帐户确认您的集成。

答案 1 :(得分:0)

您确定您没有尝试使用作为卖家的相同开发者帐户登录和付款吗?您需要确保为买家和卖家使用单独的沙盒帐户。