【问题标题】:Pay with Paypal through Paypal REST API does not show up payment description on Paypal Sandbox or live sites通过 Paypal REST API 使用 Paypal 付款不会在 Paypal Sandbox 或实时网站上显示付款说明
【发布时间】:2013-03-30 22:14:52
【问题描述】:

我正在实施 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 以指示此描述数据的参数?

注意:实时服务器和沙盒服务器都存在此问题。

【问题讨论】:

    标签: rest paypal paypal-sandbox


    【解决方案1】:

    上页左侧平移显示: 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"
                        }
                    ]
                }
            }
        ]
    }
    

    【讨论】:

    • 谢谢。 Paypal rest api 仍处于测试阶段,需要认真重写文档。顺便说一句,谢谢。
    • 嗨 Deepesh,我正在使用 1.4.3 版的贝宝。但我没有任何方法可以发送项目详细信息。请帮助我。
    • 我不相信其余 api 目前支持项目列表或事务列表。
    • 在 REST API 操场中粘贴该确切示例并添加有效的重定向 URL 会创建一个有效的请求,但是当您遵循批准 URL 时,侧边栏不会显示付款说明。
    • 2015 年年中,这仍然是一个猜谜游戏,以使用 PayPal 文档 (REST API) 完成任务。太多选项排序不当且描述不明确。
    【解决方案2】:

    谢谢。 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);
    

    【讨论】:

    • 请提供更好的解释以配合您的代码。
    猜你喜欢
    • 2014-06-15
    • 2011-11-21
    • 2014-09-23
    • 2016-08-30
    • 2017-07-13
    • 2013-08-29
    • 2013-02-20
    • 2011-09-16
    • 2017-05-13
    相关资源
    最近更新 更多