Paypal iOS始终返回相同的Paypal id
我们正在开发和应用程序,允许用户添加用户信用贝宝。为了在iOS中做到这一点,我们需要:Paypal iOS始终返回相同的Paypal id,ios,paypal,paypal-sandbox,Ios,Paypal,Paypal Sandbox,我们正在开发和应用程序,允许用户添加用户信用贝宝。为了在iOS中做到这一点,我们需要: NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; float value = [[numberFormatter numberFromString:self.tfBalance
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];
代表:
#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文档中,他们说:
使用MSDK 2.x成功付款后,MSDK会将有关付款的数据返回到您的应用程序(由MSDK从REST API接收)
服务器可以存储来自上述响应的唯一付款id值
因为paypal id是检查服务器中paypal操作的标识符。但PayPal SDK for iOS总是返回相同的id(在Android中运行良好),所以我不知道这是沙箱问题还是我做错了什么
有人有过同样的问题吗
提前感谢看起来您正在使用的库已经非常旧了2.0.0,因此它缩短了创建时间。您是否尝试过使用最新的PayPal SDK复制此行为 您看到的响应来自PayPal docs,我们使用的是cocoapods的2.6.1。我建议您在这里用实际响应打开问题,以便我们可以查看它。完美@Romk1n我们会这样做您可能在模拟中运行,但没有输出我们无法验证。谢谢@Romk1n,这确实是一个愚蠢的问题。如果你把答案贴出来,我会给你正确的答案。
{
"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"
}