Paypal with iphone shopping cart button

I am creating an application in which I need to integrate PayPal. I have enabled the PayPal button, but I do not know how to add a shopping cart button so that I can summarize all the products.

+6
source share
2 answers

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]; } 
+2
source

I do not think that Apple will allow you to do this. They do not allow payment methods other than in-app purchases.

-1
source

Source: https://habr.com/ru/post/895434/


All Articles