gpt4 book ai didi

android - 如何从 Paypal 新 SDK 添加多件商品购买

转载 作者:行者123 更新时间:2023-11-29 01:49:38 24 4
gpt4 key购买 nike

我正在集成 PayPal 新 SDK。我已经在我的代码中成功集成了新的 SDK。单个项目成功完成。但我想比如何整合多个项目。

public void onBuyPressed(View pressed) {
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("100.0"), "USD", "hipster jeans");

Intent intent = new Intent(this, PaymentActivity.class);

intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

startActivityForResult(intent, 0);
}

最佳答案

使用更新的 SDK,您可以通过这种方式指定更多项目:

PayPalItem ppi1 = new PayPalItem("Item 1", 1, new BigDecimal(100.0), "USD", "Pid1");
PayPalItem ppi2 = new PayPalItem("Item 2", 1, new BigDecimal(100.0), "USD", "Pid2");
PayPalItem[] ppis = new PayPalItem[]{ppi1, ppi2};

// this is optional, for specifing extra costs
PayPalPaymentDetails pd = new PayPalPaymentDetails(
PayPalItem.getItemTotal(ppis), // price
new BigDecimal(10.0), // shipment costs
new BigDecimal(0) // taxes
);

PayPalPayment payment = new PayPalPayment(
new BigDecimal(210.0), "USD", "Item 1 and 2", PayPalPayment.PAYMENT_INTENT_SALE);
payment.items(ppis);
payment.paymentDetails(pd);

Intent intent = new Intent(MainActivity.this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
startActivityForResult(intent, 0);

从 iOS 演示翻译为 Android :)

关于android - 如何从 Paypal 新 SDK 添加多件商品购买,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19049364/

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