gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 16:18:03 25 4
gpt4 key购买 nike

我们正在开发允许用户通过 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com