Developer's Guide
Mobile Payments Library Developer Guide and Reference –iOS Edition August 2012 31
Implementation File
The following snippet shows a simplified version of the
PaymentViewController and
illustrates the library methods for an advanced parallel payment. For reference, see the demo
application source.
- (void)viewDidLoad {
PayPalPaymentType paymentType = HARD_GOODS;
//Get the PayPal Library button.
//We will be handling the callback,
//so we declare 'self' as the target.
//We want a large button, so we use BUTTON_278x43.
//Our checkout method is 'payWithPayPal',
//and we pass through our payment type.
//We can move the button afterward if desired.
UIButton *button = [[PayPal getInstance]
getPayButtonWithTarget:self andAction:@selector(payWithPayPal)
andButtonType:BUTTON_278x43;
[super viewDidLoad];
}
-(void)payWithPayPal {
//Advanced Payment
PayPal *ppMEP = [PayPal getInstance];
ppMEP.shippingEnabled = forDelivery;
ppMEP.dynamicAmountUpdateEnabled = TRUE;
ppMEP.feePayer = FEEPAYER_EACHRECEIVER;
PayPalAdvancedPayment *payment = [[[PayPalAdvancedPayment alloc]
init] autorelease];
payment.paymentCurrency = @"USD";
payment.paymentType = paymentType;
payment.paymentSubType = paymentSubType;
payment.receiverPaymentDetails = [NSMutableArray array];
NSArray *emails = [NSArray arrayWithObjects:
@"
recipient1@email.com",
@"recipient2@email.com",
@"recipient3@email.com",
nil];
for (int i = 0; i < emails.count; i++) {
PPReceiverPaymentDetails *details =
[[[PPReceiverPaymentDetails
alloc] init] autorelease];
String order, tax, shipping;
order = orderAmount[i];