ios - Paypal iOS 总是返回相同的 Paypal ID

标签 ios paypal paypal-sandbox

我们正在开发允许用户通过 paypal 添加用户信用的应用程序。为了在 iOS 中做到这一点,我们这样做:

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
    float value = [[numberFormatter numberFromString:self.tfBalance.text] floatValue];
    value = value * 1.04;
    // Create a PayPalPayment
    PayPalPayment *payment = [[PayPalPayment alloc] init];

    // Amount, currency, and description
    payment.amount = [[NSDecimalNumber alloc] initWithString:[NSString stringWithFormat:@"%.2f", value]];
    payment.currencyCode = @"EUR";
    payment.shortDescription = [NSString stringWithFormat:@"Añadir Saldo: %@+4%% comisión PayPal", self.tfBalance.text];


    payment.intent = PayPalPaymentIntentSale;
    PayPalPaymentViewController *paymentViewController;
    paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                   configuration:self.payPalConfiguration
                                                                        delegate:self];

    // Present the PayPalPaymentViewController.
    [self presentViewController:paymentViewController animated:YES completion:nil];

委托(delegate)人:

#pragma mark - PayPal delegate
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController
             didCompletePayment:(PayPalPayment *)completedPayment {
// Payment was processed successfully; send to server for verification and fulfillment.
[self verifyCompletedPayment:completedPayment];

// Dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController {
// The payment was canceled; dismiss the PayPalPaymentViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)verifyCompletedPayment:(PayPalPayment *)completedPayment {
// Verificamos en el servidor si se ha realizado el pago
NSDictionary* response = [completedPayment.confirmation objectForKey:@"response"];
NSString* paypalId = [response objectForKey:@"id"];
[[MMApplicationModel sharedInstance].restManager createPayPalOperation:paypalId amount:[completedPayment.amount stringValue] completionHandler:^(bool verified) {
    if(verified){
        [self.tfBalance setText:@""];
        [self performSelectorInBackground:@selector(refreshBalance) withObject:nil];
    }
    else{
        //Mostramos el error
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        [self showMessage:NSLocalizedString(@"topup_error_creating_operation", nil) withTitle:NSLocalizedString(@"error", nil) andTag:0];
    }
}];
}

问题是在 PayPal SDK 文档中,他们说:

After a successful payment is made with the MSDK 2.x, the MSDK returns data to your app about the payment (received by the MSDK from the REST API).

{
"client": {
"environment": "sandbox",
"paypal_sdk_version": "2.0.0",
"platform": "iOS",
"product_name": "PayPal iOS SDK;"
},
"response": {
"create_time": "2014-02-12T22:29:49Z",
"id": "PAY-564191241M8701234KL57LXI",
"intent": "sale",
"state": "approved"
},
"response_type": "payment"
}

You server can store the unique payment id value from the above response.

因为paypal id是服务器端检查paypal操作的标识。但是适用于 iOS 的 PayPal-SDK 总是返回相同的 ID(在 Android 中运行良好)所以我不知道这是沙盒问题还是我做错了什么。

有人遇到同样的问题吗?

提前致谢

最佳答案

看起来您使用的库是很旧的 2.0.0,所以它是创建时间。您是否尝试过使用最新的 PayPal SDK 重现此行为 https://github.com/paypal/PayPal-iOS-SDK/releases/tag/2.6.1

关于ios - Paypal iOS 总是返回相同的 Paypal ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26785572/

相关文章:

paypal - 将资金从商户账户转移到信用卡/借记卡持有人银行,可能使用 ACH

ruby-on-rails - Paypal - 付款后重定向到我自己的页面

ios - Pebble Watch 在应用程序处于后台模式时将数据推送到 iOS

Paypal 和计算国际运费?

ios - 插入行后重新加载 tableView

paypal - 更改 PayPal 订阅金额

c# - Paypal 沙盒保险库 : C# The operation has timed out (HTTP request timeout was set to 30000ms)

paypal-sandbox - 如何在 PayPal Express Checkout 中设置新帐户创建选项?

iphone - 没有 UIScrollView 的 iOS UIPageControl

iphone - UISegmentedControl 空索引