I'm exploring whether it's possible for me to implement an idea I've had in iOS. However, the idea depends on being able to give users money. Is this possible in iOS? I know Apple wants you to use StoreKit when taking money from users (in-app purchases, etc), but is there even a mechanism in StoreKit to give money to users, and if not, do the iOS rules let one use a third-party service like PayPal to give users money?
Asked
Active
Viewed 1,166 times
0
-
StoreKit can't do it. Not sure about whether the rules would allow you to use another service for it… – Amy Worrall Aug 26 '12 at 17:17
-
@AmyWorrall, thanks for the info on StoreKit. After further googling, I found this site (http://www.squidoo.com/iphone-apps-that-reward-you-with-cash-and-gift-cards) which seems to suggest that one can have apps that permit transfers to users using PayPal. – Mike Lawrence Aug 26 '12 at 17:33
1 Answers
3
Yes, one can use a third party service like Paypal for payment. To implement Paypal mechanism go through the following steps.
1) Download Mobile Payment Libraries for iOS form here
2) import PayPal.h file in header file of your View Controller.
3) include following frameworks in project -- Security.framework, MapKit, ImageIO, SystemConfiguration
4) also include following two libraries file - libz.dylib, libxml2.dylib
5) Create a button for payment like
UIButton checkOutBtn=[[PayPal getPayPalInst] getPayButtonWithTarget:self andAction:@selector(payWithPayPal) andButtonType:BUTTON_152x33 andButtonText:BUTTON_TEXT_PAY];
checkOutBtn.frame=CGRectMake(60, 100, 200, 45);
[self.view addSubview:checkOutBtn];
6) implement button action method using following code:
-(void) payWithPayPal
{
[PayPal getPayPalInst].shippingEnabled=TRUE;
[PayPal getPayPalInst].dynamicAmountUpdateEnabled=TRUE;
[PayPal getPayPalInst].feePayer=FEEPAYER_EACHRECEIVER;
PayPalPayment *payment=[[[PayPalPayment alloc] init] autorelease];
payment.recipient=@"xyz@paypal.com";
payment.paymentCurrency=@"USD";
payment.description = @"Paypal";
payment.merchantName = @"Title Name";
//subtotal of all items, without tax and shipping
payment.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%1.2f", 5320.50 ]]; // total Price
//invoiceData is a PayPalInvoiceData object which contains tax, shipping, and a list of PayPalInvoiceItem objects
payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease];
payment.invoiceData.totalShipping = [NSDecimalNumber decimalNumberWithString:@"2"]; // Shipping Cost
payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:@"0.35"]; // Tax On Product
//invoiceItems is a list of PayPalInvoiceItem objects
//NOTE: sum of totalPrice for all items must equal payment.subTotal
payment.invoiceData.invoiceItems = [NSMutableArray array];
PayPalInvoiceItem *item = [[[PayPalInvoiceItem alloc] init] autorelease];
item.totalPrice = payment.subTotal;
item.name = @"Product Name";
[payment.invoiceData.invoiceItems addObject:item];
[[PayPal getPayPalInst] checkoutWithPayment:payment];
}
7) Use following delegates
-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus
{
NSLog(@"Successfully Paid");
}
-(void)paymentCanceled
{
NSLog(@"Cancelled");
}
- (void)paymentFailedWithCorrelationID:(NSString *)correlationID
{
NSLog(@"Failed");
}
-(void)paymentLibraryExit
{
NSLog(@"Exit");
}

Himanshu Mahajan
- 4,779
- 2
- 36
- 29
-
I tried Your code But its getting crash 2013-02-13 11:43:49.689 IAGDapp[2348:15e03] -[PayPal setFeePayer:]: unrecognized selector sent to instance 0x82a3140 2013-02-13 11:43:49.689 IAGDapp[2348:15e03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PayPal setFeePayer:]: unrecognized selector sent to instance 0x82a3140' *** First throw call stack: like this can you please suggest me what is the problem is? – KAREEM MAHAMMED Feb 13 '13 at 06:16
-
I'm posting my comments just in case others came upon this post from google. Currently, there are Mobile Payment Libraries provided by Paypal (https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index). Have downloaded zip archive with libraries and demo project. However, it's only possible to pay using existing paypal account, so it's not possible to pay directly with credit card without logging. It looks like Paypal is trying to deprecate this libraries and there's even a new iOS SDK project, however Android SDK still missing (they say coming soon) – Centurion Mar 28 '13 at 15:23