【问题标题】:Invalid user credentials Paypal Sandbox test account无效的用户凭据 Paypal Sandbox 测试帐户
【发布时间】:2014-04-05 16:04:34
【问题描述】:

我正在使用最新的Paypal SDK for iOS,尝试在沙盒环境中测试登录和支付交易。我已经在沙盒测试帐户页面中创建了一个企业帐户。所以我有一个用户电子邮件、密码和签名。但我无法使用这些凭据登录。我收到以下错误响应:

PayPal SDK: Request has failed with error: invalid_user - Incorrect username/password. Please try again. (401) | PayPal Debug-ID: c3dd83c83d43e | Details: (
        {
        "error_description" = "Invalid user credentials";
    }
).

我无法理解无效凭据的原因。我必须使用哪些凭据才能从 iOS SDK 登录沙盒帐户?还是我的代码中遗漏了什么?

代码

- (void)viewDidLoad
{
    //paypal setup
    // Set up payPalConfig
    _payPalConfig = [[PayPalConfiguration alloc] init];
    _payPalConfig.acceptCreditCards = YES;
    _payPalConfig.languageOrLocale = @"en";
    _payPalConfig.merchantName = @"Merchant nmae";
    _payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
    _payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:@"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
    _payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
    self.environment = PayPalEnvironmentSandbox;
    self.payPalConfig.acceptCreditCards = NO;

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];

    // Preconnect to PayPal early
    [PayPalMobile preconnectWithEnvironment:self.environment];
}

- (IBAction)makePayment:(UIButton *)sender {
if([self.amount.text isEqualToString:@""])
{
    [[[UIAlertView alloc] initWithTitle:@"Message" message:@"Please enter amount to proceed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
    return;
}

    self.resultText = nil;

    PayPalPayment *payment = [[PayPalPayment alloc] init];
    payment.amount = [[NSDecimalNumber alloc] initWithString:self.amount.text];
    payment.currencyCode = @"GBP";
    payment.shortDescription = @"Payment for Web77";

    if (!payment.processable) {
        // This particular payment will always be processable. If, for
        // example, the amount was negative or the shortDescription was
        // empty, this payment wouldn't be processable, and you'd want
        // to handle that here.

        [[[UIAlertView alloc] initWithTitle:@"Message" message:@"Payment is unprocessable" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
        return;
    }

    PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment configuration:self.payPalConfig delegate:self];

    [self presentViewController:paymentViewController animated:YES completion:nil];

}

#pragma mark PayPalPaymentDelegate methods

- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment {
    NSLog(@"PayPal Payment Success!");
    self.resultText = [completedPayment description];

    [[[UIAlertView alloc] initWithTitle:@"Message" message:@"Please enter amount to proceed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];


    [self sendCompletedPaymentToServer:completedPayment]; // Payment was processed successfully; send to server for verification and fulfillment
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController {
    NSLog(@"PayPal Payment Canceled");
    self.resultText = nil;
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark Proof of payment validation

- (void)sendCompletedPaymentToServer:(PayPalPayment *)completedPayment {
    // TODO: Send completedPayment.confirmation to server
    NSLog(@"Here is your proof of payment:\n\n%@\n\nSend this to your server for confirmation and fulfillment.", completedPayment.confirmation);
}

注意:我已经用沙盒环境的贝宝客户端 ID 初始化了PayPalMobile

附加问题: merchantName 应该包含什么?应该和paypal网站上提到的一样吗?

【问题讨论】:

  • 嘿,你找到解决办法了吗?
  • 有什么解决办法吗?

标签: ios paypal paypal-sandbox


【解决方案1】:

@engr-anum this information 有帮助吗?

在测试您的应用时,在 SDK 的 UI 中登录 PayPal 时,您应该使用个人沙盒帐户电子邮件和密码。即,不是您的 Sandbox 业务凭据。

您可以在Sandbox accounts 页面上创建企业和个人沙盒帐户。

关于merchantName:正如您将在此属性的头文件的cmets 中看到的,merchantName 仅在您使用PayPalFuturePaymentViewController 时适用。它与PayPalPaymentViewController 无关。

【讨论】:

  • 首先,感谢您的回复。我现在无法路由到登录屏幕,因为在显示之前我收到一条错误消息..there was an error connecting to paypal servers.
  • 此外控制台显示:PayPal SDK: Request has failed with error: pp_service_error_json_parse_error - System error. Please try again later. (500) | PayPal Debug-ID: 908535aa5fe13 | Details: ( { "ns_error" = "Error Domain=NSCocoaErrorDomain Code=3840 \"The operation couldn\U2019t be completed. (Cocoa error 3840.)\" (No value.) UserInfo=0xa9afb60 {NSDebugDescription=No value.}"; } ).
  • 另外,每当我尝试为沙盒创建个人测试帐户时,总是会遇到一些错误并且失败。可能是服务器上存在一些问题..
  • 在查找调试 ID 后,您确定从您创建的应用程序中输入了正确的客户端 ID 以使用 Mobile SDK?我看到的错误表明与此有关。
猜你喜欢
  • 2015-03-12
  • 1970-01-01
  • 2013-02-26
  • 1970-01-01
  • 2021-09-30
  • 1970-01-01
  • 1970-01-01
  • 2014-07-23
  • 2013-06-10
相关资源
最近更新 更多