Sending purchased items details to the PayPal.
kotdroid
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Nov-27-2018
04:36 AM
Hello, I need to send the list of item purchased and whose payments are being done using Paypal so that the buyer as well as the vendor can see that what products have the been purchased or sold. Here is the snippet of what I did for the same, by following the Github code of PayPalCheckout but I get
We'are sorry dialog each time.
Here is my code snippet I used, Now please anyone suggest what is the issue here.
/** * Preparing final cart amount that needs to be sent to PayPal for payment */ private PayPalPayment prepareFinalCart() { List<PayPalItem> productsInCart = new ArrayList<>(); double price; for (Program program : mPrograms) { if (null != program.programPrices.get(program.selectedPriceIndex).priceAfterDiscount) { price = program.programPrices.get(program.selectedPriceIndex).priceAfterDiscount; } else { price = program.programPrices.get(program.selectedPriceIndex).price; } PayPalItem item = new PayPalItem(program.type, 1, //Quantity new BigDecimal(price), //price Config.DEFAULT_CURRENCY, // currency + String.valueOf(program.id)); // stock keeping unit productsInCart.add(item); } if (App.sCouponDetails != null) { App.sCouponDetails.calculateDiscount(mFinalCost); } PayPalItem[] items = new PayPalItem[productsInCart.size()]; items = productsInCart.toArray(items); // Total amount BigDecimal subtotal = new BigDecimal(mFinalCost); // If you have shipping cost, add it here BigDecimal shipping = new BigDecimal("0.0"); // If you have tax, add it here BigDecimal tax = new BigDecimal("0.0"); PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails(shipping, subtotal, tax); BigDecimal amount = subtotal.add(shipping).add(tax); // Getting Purchased Programs type StringBuilder programsType = new StringBuilder(); for (int i = 0; i < mPrograms.size(); i++) { if (i == mPrograms.size() - 1) { programsType.append(mPrograms.get(i).type); } else { programsType.append(mPrograms.get(i).type).append(","); } } PayPalPayment payment = new PayPalPayment(amount, Config.DEFAULT_CURRENCY, "Total Amount: "/*programsType.toString()*/, Config.PAYMENT_INTENT); payment.items(items).paymentDetails(paymentDetails); // Custom field like invoice_number etc., //payment.custom("This is text that will be associated with the payment that the app can use."); return payment; }
1 REPLY 1
kotdroid
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec-01-2018
04:07 AM
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Can't capture order, loop on action-required in REST APIs
- Need Help Upgrading to PayPal complete payments in PayPal Upgrade Community
- capture error in Sandbox Environment
- Malformed json request when creating an order in REST APIs
- Transaction with PP button does not show product description in PayPal Payments Standard