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