1

这是 iPhone 应用程序中 Paypal (Sandbox) 错误“589023”的解决方案

-(无效)payWithPayPal{

for (int i=0;i PayPal *payPal=[PayPal getPayPalInst];

payPal.shippingEnabled = FALSE;

payPal.dynamicAmountUpdateEnabled = NO;

payPal.feePayer = FEEPAYER_EACHRECEIVER;

PayPalPayment *payment = [[[PayPalPayment alloc] init] autorelease];

payment.recipient = @"UKMCA2010@GMAIL.COM";    

payment.paymentCurrency = @"USD";

payment.description = @"Payment Discription here...";

SampleSingleton *sample=[SampleSingleton sharedInstance];

payment.merchantName =[sample getStrRestaurantName]; 

payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease];

payment.invoiceData.invoiceItems = [NSMutableArray array];   

PayPalInvoiceItem *item = [[PayPalInvoiceItem alloc] init];


item.totalPrice=[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f", 126.34545]]; // If u give xxx.xx , no need to give the %.2f , u can give directly %f

    item.name = objTempReceived.strItemName;



    item.itemId = @"Item ID";



    [payment.invoiceData.invoiceItems addObject:item];

    [item release];
}



payment.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",126.34545]]; //Total and Subtotal must be equal

payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",3.34]];

NSLog(@"Total Tax is :%@",[payment.invoiceData.totalTax stringValue]);

[payPal checkoutWithPayment:payment];

}

这里总和小计和税只允许在.(点)后两位数字:(234.xx)。因此,通过使用 %.2f 可以完美地工作。

4

0 回答 0