Paypal iOS总是返回相同的paypal id

时间:2014-11-06 17:23:01

标签: 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];

代表:

#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接收)。

{
"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"
}
  

您的服务器可以存储上述响应中的唯一付款ID值。

由于paypal id是检查服务器中paypal操作的标识符。但是,适用于iOS的PayPal-SDK始终返回相同的ID(在Android中运行良好),所以我不知道它是否是沙盒问题,或者我做错了什么。

有没有人有同样的问题?

提前致谢

1 个答案:

答案 0 :(得分:2)

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