stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.12k stars 981 forks source link

How to clear connect Stripe account? #1830

Closed darkengine closed 3 years ago

darkengine commented 3 years ago

Summary

Our software can help users collect payments from their clients. And can charge our users.

When helping users collect payments from their clients, we call Stripe API to set their Stripe account (Connect account) by:

[[STPAPIClient sharedClient] setStripeAccount: connect_stripe_account];

However, when we want to charge our users after that. We cannot find any API to clear this setting.

We try

[[STPAPIClient sharedClient] setStripeAccount:nil];

and

[[STPAPIClient sharedClient] setStripeAccount:@""];

but neither works.

Code to reproduce

iOS version

"os_version": "14.0.1"

Installation method

CocoaPods

SDK version

"bindings_version": "21.6.0"

Other information

yuki-stripe commented 3 years ago

Hi @darkengine,

setStripeAccount:nil should work, can you say more about what behavior you're seeing? cc @aliriaz-stripe

darkengine commented 3 years ago

Hi @darkengine,

setStripeAccount:nil should work, can you say more about what behavior you're seeing? cc @aliriaz-stripe

We collect payment from user using PaymentIntent. Our backend create a PaymentIntent and send the secret to iOS app. Then we confirm the payment intent with card params with this secret. And we got error message:

Error Domain=com.stripe.lib Code=50 "There was an unexpected error -- try again in a few seconds" UserInfo={NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:StripeErrorCodeKey=resource_missing, com.stripe.lib:ErrorParameterKey=intent, com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:ErrorMessageKey=No such payment_intent: 'pi_3J7zAAGUQds679Aw0Gswwsbs'}

We had checked Stripe dashboard. This payment intent was created under our main Stripe account - this is correct. But iOS Stripe SDK looks for payment intent with previous ConnectAccount (user's Stripe account). So the "No such payment_intent" happens.

We had called "[[STPAPIClient sharedClient] setStripeAccount:nil];" before confirming payment intent. However, it doesn't work for some reason.

darkengine commented 3 years ago

Hi @darkengine,

setStripeAccount:nil should work, can you say more about what behavior you're seeing? cc @aliriaz-stripe

Sorry for bothering you. I had put the restore ConnectAccount statement in the "viewDidAppear" callback, which makes the SDK set back to ConnectAccount.