You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUG] Calling intentCreationCallback(.success(clientSecret)) causes inconsistent behavior for manual payment confirmation on the server between card methods and Apple Pay
#4609
Open
Ariandr opened this issue
Feb 28, 2025
· 3 comments
We are migrating from Basic Integration and Connect payments to the Payment Element with manual payment confirmation on the server.
Payment methods are shared to the Connected accounts from the main Stripe account and payment intents are created on connected accounts as well.
More context here: #4536
Problem description:
When we pay and payment succeeds, we execute this code.
STPAPIClient.shared.stripeAccount = connectedAccountId // We set the account id that was used for Payment Intent creation
self.intentCreationCallback?(.success(paymentIntentClientSecret)) // Returned from API after its creation/confirmation
STPAPIClient.shared.stripeAccount = nil // Remove it to use the main Stripe account header
Issue:
When we pay with a card method and the payment succeeds without next action required and we call self.intentCreationCallback?(.success(clientSecret)), it causes this error on the iOS side. Doesn't affect the real world payment of course, but probably not ideal. Error Domain=com.stripe.lib Code=50 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorParameterKey=intent, com.stripe.lib:StripeRequestIDKey=req_phphzDVNMVa14c, NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:StripeErrorCodeKey=resource_missing, com.stripe.lib:ErrorMessageKey=No such payment_intent: 'pi_3QxTM0GZhTdR0Vyo03xQZKka', com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:hintKey=No matching PaymentIntent could be found. Ensure you are creating a PaymentIntent server side and using the same publishable key on both client and server. You can find more information at https://stripe.com/docs/api/payment_intents/create}
BUT:
If we pay with Apple Pay and the payment succeeds without next action required and we call self.intentCreationCallback?(.success(clientSecret)), it closes the system Apple payment popup with success and no issue is printed. If we don't call self.intentCreationCallback?(.success(clientSecret)), the system Apple Payment popup will collapse with an error.
Short Summary:
When using Apple Pay and the payment succeeds on the first attempt, we need to call self.intentCreationCallback?(.success(clientSecret)).
But when using a card payment method the payment succeeds on the first attempt, we do not need to call self.intentCreationCallback?(.success(clientSecret)) to not get the error.
Question:
Can it be handled in a proper way that we can call self.intentCreationCallback?(.success(clientSecret)) without needing to know if it was an Apple Pay method or a card method?
iOS version
Relevant to all, but tested on iOS 18
Installation method
Cocoapods
SDK version
23.29.2
The text was updated successfully, but these errors were encountered:
Hi @yuki-stripe
Understanding the context, what thoughts do you have?
I guess that this behavior of SDK might have been overlooked because Payment Element wasn't tested a lot with the manual payment finalization flow on the server.
I think this is happening because the SDK fetches the PaymentIntent after this line is called: STPAPIClient.shared.stripeAccount = nil // Remove it to use the main Stripe account header
If you can delay un-setting that until after the call to FlowController.confirm calls its completion block, that might fix it.
Summary
We are migrating from Basic Integration and Connect payments to the Payment Element with
manual
payment confirmation on the server.Payment methods are shared to the Connected accounts from the main Stripe account and payment intents are created on connected accounts as well.
More context here:
#4536
Problem description:
When we pay and payment succeeds, we execute this code.
Issue:
When we pay with a card method and the payment succeeds without
next action
required and we call self.intentCreationCallback?(.success(clientSecret)), it causes this error on the iOS side. Doesn't affect the real world payment of course, but probably not ideal.Error Domain=com.stripe.lib Code=50 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorParameterKey=intent, com.stripe.lib:StripeRequestIDKey=req_phphzDVNMVa14c, NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:StripeErrorCodeKey=resource_missing, com.stripe.lib:ErrorMessageKey=No such payment_intent: 'pi_3QxTM0GZhTdR0Vyo03xQZKka', com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:hintKey=No matching PaymentIntent could be found. Ensure you are creating a PaymentIntent server side and using the same publishable key on both client and server. You can find more information at https://stripe.com/docs/api/payment_intents/create}
BUT:
If we pay with Apple Pay and the payment succeeds without
next action
required and we call self.intentCreationCallback?(.success(clientSecret)), it closes the system Apple payment popup with success and no issue is printed. If we don't call self.intentCreationCallback?(.success(clientSecret)), the system Apple Payment popup will collapse with an error.Short Summary:
When using Apple Pay and the payment succeeds on the first attempt, we need to call
self.intentCreationCallback?(.success(clientSecret))
.But when using a card payment method the payment succeeds on the first attempt, we do not need to call
self.intentCreationCallback?(.success(clientSecret))
to not get the error.Question:
Can it be handled in a proper way that we can call self.intentCreationCallback?(.success(clientSecret)) without needing to know if it was an Apple Pay method or a card method?
iOS version
Relevant to all, but tested on iOS 18
Installation method
Cocoapods
SDK version
23.29.2
The text was updated successfully, but these errors were encountered: