Here's how I did it for an example application. I built a basket in my application (just a simple dictionary of elements that I can add and subtract from a normal workflow), and in the upper right corner of the application there is a button that says "Checkout". At this point, the user will be presented taking into account their basket and using the MPL Paypal library. I am making a request to create a pay with paypal button.
UIButton *button = [[PayPal getPayPalInst] getPayButtonWithTarget:self andAction:initiatePayment andButtonType:BUTTON_294x43];
Then, in my Initiate Payment method, I fill the basket.
(void)initiatePayment { [preapprovalField resignFirstResponder]; [PayPal getPayPalInst].shippingEnabled = TRUE; [PayPal getPayPalInst].dynamicAmountUpdateEnabled = TRUE; [PayPal getPayPalInst].feePayer = FEEPAYER_EACHRECEIVER; PayPalPayment *payment = [[[PayPalPayment alloc] init] autorelease]; payment.recipient = @" test_11111111_biz@testing.com "; payment.paymentCurrency = @"USD"; payment.description = @"Cart Checkout"; payment.merchantName = @"Fake Store O Stuff"; payment.subTotal = [NSDecimalNumber decimalNumberWithString:@"10"]; payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease]; payment.invoiceData.invoiceItems = [NSMutableArray array]; for(invoiceItem cartItem in Cart.Items) { PayPalInvoiceItem *item = [[[PayPalInvoiceItem alloc] init] autorelease]; item.totalPrice = cartItem.totalPrice; item.name = cartItem.name; [payment.invoiceData.invoiceItems addObject:item]; } payment.invoiceData.totalShipping = [NSDecimalNumber decimalNumberWithString:@"2"]; payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:@"0.35"]; [[PayPal getPayPalInst] checkoutWithPayment:payment]; }
source share