27

我正在实施 Paypal 的新 REST API Pay with Paypal 方法,可以在此处引用: https ://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/

付款执行良好,完全符合应有的方式。用户选择使用 Paypal 付款,然后被重定向到 Paypal 站点,预计他将在该站点登录并批准付款。我发送 Paypal 的 JSON 数据几乎是上面链接中指定的,我的看起来像这样:

{
  "intent":"sale",
  "redirect_urls":{
    "return_url":"http://<return URL here>",
    "cancel_url":"http://<cancel URL here>"
  },
  "payer":{
    "payment_method":"paypal"
  },
  "transactions":[
    {
      "amount":{
        "total":"7.47",
        "currency":"USD"
      },
      "description":"This is the payment description."
    }
  ]

}

当它将用户重定向到贝宝网站时,描述和总金额列显示为空白

我不确定这是否是 Paypal 的 REST API 上的错误,但我相信我提供了必要的描述 + 支付金额以反映在此页面上。如果未显示此信息,这通常会对用户产生威慑作用,因为他们肯定希望看到他们在 Paypal 网站上支付的金额,即使该金额已列在我的网站上。

这是它的样子:

在此处输入图像描述

对于那些想表明用户没有登录的人,好吧,即使在登录后,描述和当前购买栏仍然是空白的。

我是否遗漏了任何需要发送到 Paypal 以指示此描述数据的参数?

注意:对于实时服务器和沙盒服务器,此问题仍然存在。

4

2 回答 2

39

上一页左侧面板显示: 1. 订单商品详情。您可以将项目列表作为交易详细信息的一部分包含在付款资源中。此处将显示相同的内容。2. 交易金额的组成部分,例如运费、税金等,如果您在请求中包含它们。

尝试此请求以查看示例:

{
    "intent": "sale",
    "payer": {
        "payment_method": "paypal"
    },
    "redirect_urls": {
        "return_url": "http://<return url>",
        "cancel_url": "http://<cancle url>"
    },
    "transactions": [
        {
            "amount": {
                "total": "8.00",
                "currency": "USD",
                "details": {
                    "subtotal": "6.00",
                    "tax": "1.00",
                    "shipping": "1.00"
                }
            },
            "description": "This is payment description.",
            "item_list": { 
                "items":[
                    {
                        "quantity":"3", 
                        "name":"Hat", 
                        "price":"2.00",  
                        "sku":"product12345", 
                        "currency":"USD"
                    }
                ]
            }
        }
    ]
}
于 2013-04-09T04:54:54.803 回答
-1

谢谢你。Madhu 记得使用 rest-api 库!

Details amountDetails = new Details();
                    amountDetails.setSubtotal(autoregistro.getPedido().getItems().get(0).getTotal().toPlainString());
                    amountDetails.setTax("0");
                    amountDetails.setShipping("0");

                    Amount amount = new Amount();
                    amount.setCurrency("USD");
                    amount.setTotal(autoregistro.getPedido().getItems().get(0).getTotal().toPlainString());
                    // amount.setTotal("7.47"); // Los decimales deben ser con punto
                    amount.setDetails(amountDetails);

                    Item item = new Item();
                    item.setCurrency("USD");
                    item.setQuantity("1");
                    item.setName(autoregistro.getPedido().getItems().get(0).getDescripcion());
                    item.setPrice(amountDetails.getSubtotal());

                    List<Item> items = new ArrayList<Item>();
                    items.add(item);

                    ItemList itemList = new ItemList();
                    itemList.setItems(items);

                    Transaction transaction = new Transaction();
                    transaction.setDescription(item.getName());
                    transaction.setAmount(amount);
                    transaction.setItemList(itemList);

                    List<Transaction> transactions = new ArrayList<Transaction>();
                    transactions.add(transaction);

                    Payer payer = new Payer();
                    payer.setPaymentMethod("paypal");
                    // payer.setPaymentMethod("credit_card");

                    Payment payment = new Payment();
                    payment.setIntent("sale");
                    payment.setPayer(payer);
                    payment.setTransactions(transactions);
                    RedirectUrls redirectUrls = new RedirectUrls();
                    redirectUrls.setCancelUrl(this.configParameters.getAutoregistroURL() + "/pay_paypal?cancel=true");
                    redirectUrls.setReturnUrl(this.configParameters.getAutoregistroURL() + "/pay_paypal?success=true");
                    payment.setRedirectUrls(redirectUrls);

                    Payment createdPayment = payment.create(apiContext);
于 2015-03-19T17:24:38.717 回答