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

后端 未结 2 1507
北荒
北荒 2020-12-25 12:06

I am implementing Paypal\'s new REST API Pay with Paypal method that can be referenced here: https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypa

相关标签:
2条回答
  • 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"
                        }
                    ]
                }
            }
        ]
    }
    
    0 讨论(0)
  • 2020-12-25 12:28

    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);
    
    0 讨论(0)
提交回复
热议问题