Paypal iOS SDK Sandbox付款时出错

时间:2015-10-21 16:23:00

标签: ios paypal paypal-sandbox

我使用的是Paypal SDK 2.12.3。当我通过Paypal付款时,有时我在进行交易时低于警惕。

enter image description here

在我的控制台中得到了这个: PayPal SDK:请求失败并显示错误:PAYER_ACTION_REQUIRED - 系统错误(PAYER_ACTION_REQUIRED)。请稍后再试。 (400)| PayPal Debug-ID:982dc2baccecb [sandbox,PayPal iOS SDK 2.12.3]

这是我的paypal代码

// This method is called when user presses payment button
- (IBAction)pay {

    NSMutableArray *items = [[NSMutableArray alloc] init];
    for (NSDictionary *dictCart in arrCartData) {

        PayPalItem *item1 = [PayPalItem itemWithName:dictCart[@"name"]
                                        withQuantity:[dictCart[@"qty"] intValue]
                                           withPrice:[NSDecimalNumber decimalNumberWithString:dictCart[@"amount"]]
                                        withCurrency:@"USD"
                                             withSku:dictCart[@"badge_id"]];

        [items addObject:item1];
    }

    NSDecimalNumber *subtotal = [PayPalItem totalPriceForItems:items];
    NSDecimalNumber *shipping = [[NSDecimalNumber alloc] initWithString:[NSString stringWithFormat:@"%d",[Utility getShippingCharge]]];
    NSDecimalNumber *tax = [[NSDecimalNumber alloc] initWithString:@"0.00"];
    NSDecimalNumber *total = [[subtotal decimalNumberByAdding:shipping] decimalNumberByAdding:tax];

PayPalPaymentDetails *paymentDetails = [PayPalPaymentDetails paymentDetailsWithSubtotal:subtotal
                                                                               withShipping:shipping
                                                                                    withTax:tax];
    PayPalPayment *payment = [[PayPalPayment alloc] init];
    payment.amount = total;
    payment.currencyCode = @"USD";
    payment.shortDescription = @"Badges";
    payment.items = items;  
    payment.paymentDetails = paymentDetails;

    self.payPalConfig.acceptCreditCards = YES;
    PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                                                configuration:self.payPalConfig
                                                                                                     delegate:self];
    [self presentViewController:paymentViewController animated:YES completion:nil];
}

// This method is called from viewDidLoad
- (void)setupPaypalConfig
{
    _payPalConfig = [[PayPalConfiguration alloc] init];
    _payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionPayPal;
    [PayPalMobile preconnectWithEnvironment:PayPalEnvironmentSandbox];
}

0 个答案:

没有答案