使用STPAPIClient.shared().confirmPaymentIntent()
确认付款意向时出现以下错误
我正在执行的代码:
STPAPIClient.shared().confirmPaymentIntent(with: paymentIntentParams, completion: { (paymentIntent, error) in
if let error = error {
// handle error
} else if let paymentIntent = paymentIntent {
// see below to handle the confirmed PaymentIntent
if paymentIntent.status == .requiresAction {
guard let redirectContext = STPRedirectContext(paymentIntent: paymentIntent, completion: { clientSecret, redirectError in
// Fetch the latest status of the Payment Intent if necessary
STPAPIClient.shared().retrievePaymentIntent(withClientSecret: clientSecret) { paymentIntent, error in
// Check paymentIntent.status
}
})else{
// This PaymentIntent action is not yet supported by the SDK.
return;
}
redirectContext.startRedirectFlow(from: self)
}else{
// Show success message
}
}
})
最佳答案
如果您使用的是stripe connect
(直接收费)功能,则需要在前端侧创建带区实例时传递带区连接的帐户ID(stripeAccount
)。见下面的例子
var stripe = Stripe(STRIPE_PUBLIC_KEY, { stripeAccount: "{{ connected_account }}" });