【问题标题】:Getting error in integrating Paypal ios sdk with swift 5将 Paypal ios sdk 与 swift 5 集成时出错
【发布时间】:2020-06-04 10:05:19
【问题描述】:

我正在尝试将 paypal sdk 集成到 swift 5 中。我已经编写了所有代码,但仍然显示“不允许向该商家付款(无效的客户 ID)”,而相同的客户 ID 运行良好在安卓中。任何帮助深表感谢。 在 Appdelegate 我写道 PayPalMobile.initializeWithClientIds(forEnvironments: [PayPalEnvironmentProduction: "test",

    PayPalEnvironmentSandbox : "test"])
[![enter image description here][1]][1]


    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) //This is the total price of all the items
    // Optional: include payment details
    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) //This is the total price including shipping and tax
    let payment = PayPalPayment(amount: total, currencyCode: "USD", shortDescription: "Weavers", 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)
    }
    else {
        // 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.
        print("Payment not processalbe: (payment)")
    }

【问题讨论】:

  • PayPal iOS SDK 已被弃用很长时间。但无论如何,它可能在您的仪表板配置中。
  • 感谢您的回复先生。你能否详细说明我如何解决这个问题。 Dashboard config 是指在 paypal 帐户中吗?
  • 我已经在我的项目中安装了 pod ‘PayPal-iOS-SDK’
  • 嗨,我猜 PayPal sdk 已被弃用。所以你可以尝试实现 Braintree 它也提供 PayPal 支持。 appcoda.com/braintree-ios-integration
  • 好的。非常感谢

标签: ios swift xcode paypal swift5


【解决方案1】:

PayPal iOS SDK 已弃用,不应用于新的集成。

如果您需要原生 SDK,支持PayPal Express Checkout via the Braintree Mobile SDK

【讨论】:

    猜你喜欢
    • 2017-08-06
    • 2013-08-18
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 2013-02-25
    • 2016-01-01
    • 2016-12-06
    相关资源
    最近更新 更多