Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Calling self.intentCreationCallback?(.success(clientSecret)) after intent was confirmed on the server causes error #4531

Closed
Ariandr opened this issue Feb 3, 2025 · 3 comments
Labels

Comments

@Ariandr
Copy link

Ariandr commented Feb 3, 2025

Summary

We have the integration with manual confirmation_method on the server.
Using PaymentSheet.FlowController we collect a payment method on iOS, send it to the server. Then the server creates a payment intent with the provided payment method and immediately confirms it. If the payment intent is confirmed right away without the next action needed, we return payment_intent_client_secret to the iOS client and call this:

...

self.intentCreationCallback?(.success(clientSecret))

Which gives this error:
ERROR apiError(StripeCore.StripeAPIError(type: StripeCore.StripeAPIError.ErrorType.invalidRequestError, code: Optional("resource_missing"), docUrl: Optional(https://stripe.com/docs/error-codes/resource-missing), message: Optional("Risorsa payment_intent non trovata: \'pi_3QoMsmGZhTdR0Vyo0EFXXXX\'"), param: Optional("intent"), statusCode: Optional(404), requestID: Optional("req_UiMP9kIq1XXXXX"), _allResponseFieldsStorage: Optional(6 fields)))

PaymentSheet.IntentConfiguration config is this:

var intentConfig = PaymentSheet.IntentConfiguration(
            mode: .payment(amount: Int(totalPrice * 100), currency: currency.code, captureMethod: .manual),
            confirmHandler: { [weak self] paymentMethod, shouldSavePaymentMethod, intentCreationCallback in
                self?.handleConfirm(paymentMethod, shouldSavePaymentMethod, intentCreationCallback)
            })

Code to reproduce

self.intentCreationCallback?(.success(clientSecret))

iOS version

iOS 18.2

Installation method

Cocoapods

SDK version

Stripe 23.29.2

Other information

When the next action is required and we call self.intentCreationCallback?(.success(clientSecret)) on iOS, it launches 3D Secure flow on iOS without issues. But if it's not required and intent was confirmed right away, we see this issue.

So the thing is that the payment on its own works perfectly, just the iOS SDK shows the error in case the intent was confirmed right away on the server.

Question

What should we do in this case? Apparently, the intent is correct and it does exist, payment is successfully executed.

We are migrating to Payment Element from Basic integration and there is no way to make it work with Apple Pay sheet correctly in this case.

@Ariandr
Copy link
Author

Ariandr commented Feb 3, 2025

Just to provide more context about our migration to Payment Element, one issue in SDK was fixed related to our case, so now it's the second one remaining that blocks the complete transition to Payment Element.

@Ariandr
Copy link
Author

Ariandr commented Feb 3, 2025

Well, actually found a solution, but would like to hear from you a better way to do this if there is any.

STPAPIClient.shared.stripeAccount = connectedAccountId
self.intentCreationCallback?(.success(clientSecret))
STPAPIClient.shared.stripeAccount = nil

@Ariandr Ariandr changed the title [BUG] Calling self.intentCreationCallback?(.success(clientSecret)) after intent was confirmed on the server causes error [Question] Calling self.intentCreationCallback?(.success(clientSecret)) after intent was confirmed on the server causes error Feb 3, 2025
@Ariandr
Copy link
Author

Ariandr commented Feb 6, 2025

I close it for now, since the workaround is okay.

@Ariandr Ariandr closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant