【问题标题】:InvalidRequestException Invalid Client Secret - Stripe payment sdkInvalidRequestException 无效的客户端密码 - 条纹支付 sdk
【发布时间】:2020-11-11 18:52:32
【问题描述】:

我正在尝试接受付款,但在 sdk 的回调中收到此错误。

代码:

val params = cardInputWidget.paymentMethodCreateParams
        if (params != null) {
            val confirmParams =
                ConfirmPaymentIntentParams.createWithPaymentMethodCreateParams(params, clientSecret)
            stripe = Stripe(
                applicationContext,
                PaymentConfiguration.getInstance(applicationContext).publishableKey)

            stripe.confirmPayment(this, confirmParams)
        }


override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    stripe.onPaymentResult(requestCode, data, object : ApiResultCallback<PaymentIntentResult> {
        override fun onSuccess(result: PaymentIntentResult) {
            val paymentIntent = result.intent
            val status = paymentIntent.status
            if (status == StripeIntent.Status.Succeeded) {
                val gson = GsonBuilder().setPrettyPrinting().create()
                showToast("Payment succeeded " + gson.toJson(paymentIntent))
            } else {
                showToast("Payment Error: "+paymentIntent.lastPaymentError?.message ?: "")
            }
        }

        override fun onError(e: Exception) {
            showToast("Payment failed "+e.message)
        }
    })
}

onError 总是被调用!

这是sdk的内部代码:

【问题讨论】:

  • 这在 StackOverflow 上调试会很棘手。您发送的客户端密码似乎有问题。要么它被截断/不正确,要么它来自不同的 Stripe 帐户,而您使用了错误的 API 密钥? Stripe 的支持团队会让您更幸运:support.stripe.com/contact
  • 我正在使用来自同一帐户的发布密钥和客户端密码,但仍然出现错误。我没有从文档和 GitHub 问题中获得任何帮助。
  • 您需要先使用 PaymentConfiguration.init( applicationContext, "pk_test_TYooMQauvdEDq54NiTphI7jx" ) 初始化您的 Stripe PaymentConfiguration 实例

标签: android stripe-payments


【解决方案1】:

您正在使用confirmPayment 方法而不是confirmSetupIntent 方法。一种用于使用客户端密码确认支付意图,另一种用于使用客户端密码确认设置意图。查看有关保存和重复使用付款方式的条带文档:https://stripe.com/docs/payments/save-and-reuse

【讨论】:

  • 这很有帮助。谢谢。
猜你喜欢
  • 2017-03-09
  • 2013-01-05
  • 1970-01-01
  • 2020-09-03
  • 2017-09-14
  • 2021-09-27
  • 2016-12-15
  • 2021-03-12
  • 2021-02-03
相关资源
最近更新 更多