2

我正在集成 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);
}
4

2 回答 2

1

使用更新后的 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 :)

于 2014-06-23T12:44:32.893 回答
0

paypal mobile sdks 不提供当前支持。我在 github paypal 论坛上查询过,你可以在这里验证:https ://github.com/paypal/PayPal-Android-SDK/issues/30

于 2013-12-03T08:55:26.230 回答