Developer's Guide
Mobile Payments Library Developer Guide and Reference – Android OS Edition July 2011 13
In the following example, the buyer checks out with a parallel or chained payment for multiple
recipients:
PayPalReceiverDetails receiver0, receiver1;
receiver0 = new PayPalReceiverDetails();
…
//setup receiver details
…
PayPalAdvancedPayment advPayment = new PayPalAdvancedPayment();
advPayment.setCurrency("USD");
advPayment.getReceivers().add(receiver0);
advPayment.getReceivers().add(receiver1);
Intent paypalIntent = PayPal.getInstance().checkout(advPayment, this);
this.startActivityForResult(paypalIntent, 1);
For more information on receivers and how to use them, see “Custom Objects in the Mobile
Payments Library” on page 23.
Parameter
Description
intent:
(Required) A PayPalPayment object that contains information
about the payment. Create this intent with the following code:
Intent checkoutIntent = new Intent(this,
PayPalActivity.class);
For the properties of this object type, see “PayPalPayment” on page
24.
requestCode:
(Required) Use any integer for the request code. When you get the
onActivityResult() callback from the Library Activity, you
can use this request code to know that the results are coming from the
Library activity.
Note: On older devices and/or firmware, starting the activity may take significant time to
complete, resulting in an “Activity is not responding” popup if the user attempts to enter input
during this time. It is recommended to create a loading thread with an animation of some sort if
you witness this regularly.
Dynamic Amount Calculation
The Mobile Payments Library allows you to modify the payment based on the buyer‟s shipping
address. For instance, you might want to recalculate the tax amount based on the buyer‟s location.
To enable this, use the optional method enableDynamicAmountCalculation() (see
“Optional Methods” below. You must provide the logic that creates the new payment values
based on the buyer‟s address. The library includes a PaymentAdjuster class for this.
To use this feature, one of your classes (not an Activity) must implement “PaymentAdjuster”, as
well as implement “Serializable”. For simplicity, we recommend creating a new class that does
this. This class must include the following methods: