繁体   English   中英

Paypal iOS集成

[英]paypal iOS integration

我做了按钮,当我按下它时调用此方法,在iPhone模拟器5上我遇到了错误,在iPhone模拟器4.3上工作成功,但是在按下按钮不止一次之后:

- (void)simplePayment {
//dismiss any native keyboards

[PayPal initializeWithAppID:@"APP-80W284485P519543T" forEnvironment:ENV_SANDBOX];

//optional, set shippingEnabled to TRUE if you want to display shipping
//options to the user, default: TRUE
[PayPal getPayPalInst].shippingEnabled = TRUE;

//optional, set dynamicAmountUpdateEnabled to TRUE if you want to compute
//shipping and tax based on the user's address choice, default: FALSE
[PayPal getPayPalInst].dynamicAmountUpdateEnabled = TRUE;

//optional, choose who pays the fee, default: FEEPAYER_EACHRECEIVER
[PayPal getPayPalInst].feePayer = FEEPAYER_EACHRECEIVER;

//for a payment with a single recipient, use a PayPalPayment object
PayPalPayment *payment = [[[PayPalPayment alloc] init] autorelease];
payment.recipient = @"example-merchant-1@paypal.com";
payment.paymentCurrency = @"USD";
payment.description = @"Teddy Bear";
payment.merchantName = @"Joe's Bear Emporium";

//subtotal of all items, without tax and shipping
payment.subTotal = [NSDecimalNumber decimalNumberWithString:@"10"];

//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"];
payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:@"0.35"];

//invoiceItems is a list of PayPalInvoiceItem objects
//NOTE: sum of totalPrice for all items must equal payment.subTotal
//NOTE: example only shows a single item, but you can have more than one
payment.invoiceData.invoiceItems = [NSMutableArray array];
PayPalInvoiceItem *item = [[[PayPalInvoiceItem alloc] init] autorelease];
item.totalPrice = payment.subTotal;
item.name = @"Teddy";
[payment.invoiceData.invoiceItems addObject:item];

[[PayPal getPayPalInst] checkoutWithPayment:payment];

}

iPhone 5模拟器错误

> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString
> rangeOfString:options:range:locale:]: nil argument'
> 
> *** First throw call stack: (0x142df1c 0x15c052e 0x13cfd38 0x13cfcaa 0xd00681 0xd0e35c 0x5400e 0x6a373 0x70958 0x6e823 0x543d9b 0x765be
> 0x763a1 0x545144 0x5453bb 0x546138 0x4b5b41 0x4bb031 0x4b531f 0x51fb
> 0x9889 0x54de 0x34df 0x2ff4 0x48084c 0x4807e2 0x52777a 0x527c4a
> 0x526ee4 0x4a6002 0x4a620a 0x48c60c 0x47fd52 0x1b968f6 0x13fd31a
> 0x1358d07 0x1356e93 0x1356750 0x1356671 0x1b950c3 0x1b95188 0x47dc29
> 0x294c 0x2885 0x1) terminate called throwing an exceptionsharedlibrary
> apply-load-rules all Current language:  auto; currently objective-c
> (gdb)

我应该使用贝宝按钮吗?

UIButton *button = [[PayPal getPayPalInst] getPayButtonWithTarget:self andAction:action andButtonType:type];

设备和操作系统版本的库支持。 Mobile Payments库完全支持OS 4.0和Apple iPad。 您可以将库文件编译为以下配置:

•3.0、3.1.x(仅适用于iPhone)•3.2(仅适用于iPad)•3.x(通用)•4.x

该演示应用程序还完全支持OS 4.0和Apple iPad。 您可以将演示应用程序编译为上述配置。 单个库文件可用于支持SDK 4.0及更低版本的armv6和armv7体系结构。 目前仅支持Xcode 3.2.3。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM