无效的用户凭据PayPalEnvironmentProduction

时间:2017-03-17 03:50:12

标签: paypal

我在iOS上使用PaypalSDK(2.16.2),我可以在PayPalEnvironmentSandbox中登录和付款,当我将应用程序切换到PayPalEnvironmentProduction时,我在xcode响应中收到以下错误:

PayPal SDK: Request has failed with error: invalid_user - Incorrect username/password. Please try again。 (401) | PayPal Debug-ID: b2cedad5b6842, b2cedad5b6842 [live, PayPal iOS SDK 2.16.2] | Details: (
        {
        "error_description" = "Invalid user credentialenter code heres";
    }
).

我确定我的帐户和密码是正确的(Android应用和网页可以登录),我无法理解凭据无效的原因?

代码

  override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        successView.isHidden = true

        // Set up payPalConfig
        payPalConfig.acceptCreditCards = false
        payPalConfig.merchantName = "shopins"
        payPalConfig.merchantPrivacyPolicyURL = URL(string: "https://www.paypal.com/webapps/mpp/ua/privacy-full")
        payPalConfig.merchantUserAgreementURL = URL(string: "https://www.paypal.com/webapps/mpp/ua/useragreement-full")
        payPalConfig.languageOrLocale = Locale.preferredLanguages[0] 
        payPalConfig.payPalShippingAddressOption = .payPal;
      }
     override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        PayPalMobile.preconnect(withEnvironment: PayPalEnvironmentProduction)
      }
  @IBAction func buyClothingAction(_ sender: AnyObject) {
    resultText = ""

    let item1 = PayPalItem(name: "Old jeans with holes", withQuantity: 2, withPrice: NSDecimalNumber(string: "84.99"), withCurrency: "USD", withSku: "Hip-0037")
    let item2 = PayPalItem(name: "Free rainbow patch", withQuantity: 1, withPrice: NSDecimalNumber(string: "0.00"), withCurrency: "USD", withSku: "Hip-00066")
    let item3 = PayPalItem(name: "Long-sleeve plaid shirt (mustache not included)", withQuantity: 1, withPrice: NSDecimalNumber(string: "37.99"), withCurrency: "USD", withSku: "Hip-00291")

    let items = [item1, item2, item3]
    let subtotal = PayPalItem.totalPrice(forItems: items)
    let shipping = NSDecimalNumber(string: "5.99")
    let tax = NSDecimalNumber(string: "2.50")
    let paymentDetails = PayPalPaymentDetails(subtotal: subtotal, withShipping: shipping, withTax: tax)

    let total = subtotal.adding(shipping).adding(tax)

    let payment = PayPalPayment(amount: total, currencyCode: "USD", shortDescription: "Hipster Clothing", intent: .sale)

    payment.items = items
    payment.paymentDetails = paymentDetails

    if (payment.processable) {
      let paymentViewController = PayPalPaymentViewController(payment: payment, configuration: payPalConfig, delegate: self)
      present(paymentViewController!, animated: true, completion: nil)
    }
  }
  func payPalPaymentDidCancel(_ paymentViewController: PayPalPaymentViewController) {
    resultText = ""
    successView.isHidden = true
    paymentViewController.dismiss(animated: true, completion: nil)
  }

  func payPalPaymentViewController(_ paymentViewController: PayPalPaymentViewController, didComplete completedPayment: PayPalPayment) {
    paymentViewController.dismiss(animated: true, completion: { () -> Void in
      self.resultText = completedPayment.description
      self.showSuccess()
    })
  }

我很困惑为什么PayPalEnvironmentSandbox没有问题,但PayPalEnvironmentProduction无法正常使用

0 个答案:

没有答案