PayPal Plus Sandbox - Pay upon Invoice

橙三吉。 提交于 2019-12-08 01:59:36

问题


I'm integrating PayPal Plus, successfully on my site, except "Pay upon Invoice".

Here's my JavaScript code for integrating the payment wall:

<script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js"
type="text/javascript"></script>

<script type="application/javascript">
var ppp = PAYPAL.apps.PPP({
"approvalUrl": "<?= $createPaymentArr['links'][1]['href']; ?>",
"placeholder": "ppplus",
"language": "de_DE",
"mode": "sandbox",
"showPuiOnSandbox": "true",
"country": "DE"
});
</script>

When I try to use "Pay upon Invoice" I get this error message: "Unfortunately we can not process your purchase."

My API call:

$fields = '{
    "intent":"sale",
    "redirect_urls":{
      "return_url":"http://XYZ.info/ABC/paypal/index.php",
      "cancel_url":"http://XYZ.info/ABC/paypal/index.php"
    },
    "payer":{
      "payment_method":"paypal"
    },
    "transactions":[
    {
      "amount":{
        "total":"7.47",
        "currency":"EUR",
        "details":{
          "subtotal":"7.41",
          "tax":"0.03",
          "shipping":"0.03"
        }
      },
        "item_list":{
            "items":[
                {
                    "quantity":"1",
                    "name":"XYZ",
                    "price":"7.41",
                    "currency":"EUR"
                }
            ],
            "shipping_address":{
              "line1":"XYZ Straße 587",
              "city":"OPA",
              "postal_code":"12345",
              "country_code":"DE"
            }
        },
      "description":"XYZ.info Warenkorb"
    }
  ]
}';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api".$mode.".paypal.com/v1/payments/payment",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $fields,
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer ".$arr['access_token'],
    "Content-Type: application/json"
  ),
));

回答1:


You need to patch the payment before showing the iframe. During the patch, simply supply the shipping address. Then payment upon invoice works, even in the sandbox.



来源:https://stackoverflow.com/questions/36307650/paypal-plus-sandbox-pay-upon-invoice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!