无效的用户凭证Paypal沙盒测试账户。

3

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

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);
}

注意: 我已经使用PayPal沙箱环境的PayPal客户端ID初始化了PayPalMobile

附加问题: merchantName应该包含什么?是否应与PayPal网站上提到的相同?


嘿,你找到解决方案了吗? - va05
有没有解决方案? - iniyan
1个回答

2

@engr-anum,这里有相关信息,能帮到你吗?

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

您可以在沙盒账户页面上创建商业和个人沙盒账户。

关于merchantName:正如您在此属性的头文件注释中所看到的,merchantName仅适用于使用PayPalFuturePaymentViewController时。对于PayPalPaymentViewController,它是不相关的。


首先,感谢您的回复。我现在无法进入登录界面,因为在显示之前我收到了一个错误消息:“连接到PayPal服务器时出错”。 - NightFury
此外,控制台显示如下内容: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.}"; } ). - NightFury
每当我尝试在沙盒中创建个人测试帐户时,总是会遇到一些错误导致失败。可能是服务器出了问题。 - NightFury
在查找调试ID后,您确定已经输入了从创建用于使用移动SDK的应用程序中获取的正确clientID吗?我看到的错误提示与此有关。 - PP_MTS_Cory

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接