gpt4 book ai didi

ios - Stripe SCA 需要处理下一步操作

转载 作者:行者123 更新时间:2023-11-28 13:28:45 28 4
gpt4 key购买 nike

我以前在这个应用程序中使用字符串,但后端开发人员所做的所有事情现在都改变了它们的实现,并通过 SCA 支持欧洲支付变更(支持 3D 安全身份验证),所以现在我需要在我的本地添加库代码,但我停留在这个地方。

我从服务器获得了客户端 ID,但处理下一个操作会给我类似这样的错误。

Error Domain=STPPaymentHandlerErrorDomain Code=1 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorMessageKey=The PaymentIntent requires a PaymentMethod or Source to be attached before using STPPaymentHandler., NSLocalizedDescription=There was an unexpected error -- try again in a few seconds}

没有找到相关文件here

这是我的代码

//Api called on server for client id
MyAPIClient.sharedClient.createAndConfirmPaymentIntent(paymentResult,
amount: self.paymentContext.paymentAmount,
returnURL: "payments-example://stripe-redirect",
shippingAddress: self.paymentContext.shippingAddress,
shippingMethod: self.paymentContext.selectedShippingMethod) { (clientSecret, error) in
guard let clientSecret = clientSecret else {
completion(.error, error ?? NSError(domain: StripeDomain, code: 123, userInfo: [NSLocalizedDescriptionKey: "Unable to parse clientSecret from response"]))
return
}
STPPaymentHandler.shared().handleNextAction(forPayment: clientSecret, authenticationContext: paymentContext, returnURL: "payments-example://stripe-redirect") { (status, handledPaymentIntent, actionError) in
switch (status) {
case .succeeded:
guard let handledPaymentIntent = handledPaymentIntent else {
completion(.error, actionError ?? NSError(domain: StripeDomain, code: 123, userInfo: [NSLocalizedDescriptionKey: "Unknown failure"]))
return
}
if (handledPaymentIntent.status == .requiresConfirmation) {
// Confirm again on the backend
MyAPIClient.sharedClient.confirmPaymentIntent(handledPaymentIntent) { clientSecret, error in
guard let clientSecret = clientSecret else {
completion(.error, error ?? NSError(domain: StripeDomain, code: 123, userInfo: [NSLocalizedDescriptionKey: "Unable to parse clientSecret from response"]))
return
}

// Retrieve the Payment Intent and check the status for success
STPAPIClient.shared().retrievePaymentIntent(withClientSecret: clientSecret) { (paymentIntent, retrieveError) in
guard let paymentIntent = paymentIntent else {
completion(.error, retrieveError ?? NSError(domain: StripeDomain, code: 123, userInfo: [NSLocalizedDescriptionKey: "Unable to parse payment intent from response"]))
return
}

if paymentIntent.status == .succeeded {
completion(.success, nil)
}
else {
completion(.error, NSError(domain: StripeDomain, code: 123, userInfo: [NSLocalizedDescriptionKey: "Authentication failed."]))
}
}
}
} else {
// Success
completion(.success, nil)
}
case .failed:
completion(.error, actionError)
case .canceled:
completion(.userCancellation, nil)
}
}

最佳答案

我的解决方法是调用 paymentManager.confirmPayment(withParams: params, authenticationContext: self) 而不是 handleNextAction

关于ios - Stripe SCA 需要处理下一步操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57855534/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com