【发布时间】:2019-04-29 05:16:55
【问题描述】:
我需要发送购买的物品清单以及正在使用 Paypal 完成付款的物品,以便买家和供应商可以看到购买或出售了哪些产品。这是我为同样做的事情的 sn-p,遵循 Github code of PayPalCheckout,但我每次都得到。这是我的代码 sn-p
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;
}
请提出这里有什么问题?
【问题讨论】:
-
需要查看从该代码生成并发送到 PayPal 的原始请求。
-
这些是在 PayPalPayment 中添加的项目。
PayPalItem(name=Chinx Tier, quantity=1, price=79.950000, currency=USD, sku-2086) -
好的,但这不是我要求的。我们需要准确了解发送到 PayPal 的内容。也许 PayPalItem 函数对数据做了一些有趣的事情。也许其他东西正在以某种方式过滤数据,并且请求正在其中获取 PayPal 不喜欢的时髦数据。解决此问题的第一步是准确查看我们发送给 PayPal 的内容。不是我们认为我们发送到 PayPal 的内容。如果原始请求看起来不错,那么我们可以进行下一步,但这是第一步。
-
这是 PayPalPayment 的 Json 字符串,然后将其发送到 Paypal 的 PaymentActivity。
{"b":28.8629,"c":"USD","d":"Ching Flix,Syncers Flix","f":{"b":28.8629,"c":0.0,"d":0.0},"g":"sale","h":[{"b":"Ching Flix","c":1,"d":12,"e":"USD","f":"sku-6167"},{"b":"Syncers Flix","c":1,"d":20.0700,"e":"USD","f":"sku-6498"}],"i":false} -
这不是 PayPal 接受的格式。你有 a/b/c/d 作为参数名称..??
标签: java android paypal paypal-sandbox