Pay with Paypal through Paypal REST API does not show up payment description on Paypal Sandbox or live sites

大憨熊 提交于 2019-11-30 01:32:39
Deepesh Dwivedi

The left hand pan in above page displays: 1. Item details from order. You can include item list as part of the transaction details in payment resource. The same will be displayed here. 2. Components of the transaction amount e.g. shipping amount, tax, etc. if you include them in request.

Try this request to see example:

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

Thank you. Madhu remember to use the rest-api library!

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