私はボタンを実行し、それを押すとこのメソッドを呼び出し、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];
}
iPhone5シミュレータでエラーが発生しました
> 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];