gpt4 book ai didi

java - 将购买的商品详细信息发送到 PayPal?

转载 作者:搜寻专家 更新时间:2023-11-01 09:22:36 24 4
gpt4 key购买 nike

我需要发送购买的元素 list 以及使用 Paypal 付款的元素 list ,以便买家和供应商可以看到购买或出售了哪些产品。这是我所做的相同的 fragment ,遵循 Github code of PayPalCheckout但我得到 We'are sorry dialog每一次。这是我的代码 fragment

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;
}

请指出这里的问题是什么?

最佳答案

实际上那些 b/c/d/f 等参数来自 PayPalPayment 类。我只是给出了它的 Json 格式。这是 PayPalPayment 类的样子- PayPalPayment.java

关于java - 将购买的商品详细信息发送到 PayPal?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53500119/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com