#kppro_api

1 messages ยท Page 1 of 1 (latest)

tulip hearthBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1228048498084151318

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

dense pelicanBOT
pseudo helm
#

Hi ๐Ÿ‘‹

Hmmm this seems ... odd. Is there a reason you aren't using Stripe on your mobile app to save the payment method directly to the Customer?

pallid sun
#

we use the stripe sdk but not the stripe checkout

#

but maybe we are missing a step on the mobile app

#

we add the card manually like this from our own interface

val cardParams = CardParams(number, expMonth, expYear, verifCode)

    Global.stripeClient?.createCardToken(
        cardParams,
        callback = object : ApiResultCallback<Token> {
            override fun onSuccess(result: Token) {
                // Send token to your server
                listener.onCardValid(result, cardParams)
            }

            override fun onError(e: Exception) {
                // Show localized error message
                listener.onCardSaveError(e.localizedMessage ?: "")
            }
        })
pseudo helm
#

Is this on iOS or Android?

pallid sun
#

we have both. this is the android code

pseudo helm
pallid sun
#

as the app is already in production with thousands of users. if a server fix is possible, would be better for us

pseudo helm
#

So when you create the Setup Intent,

  1. You should set setup_future_usage: "off_session" if you expect to charge the PM without the Customer
pallid sun
#

we don't charge them off session, they always are active in the app and go through the checkout flow to buy their groceries

#

is an attach + SetupIntent ok ?

def attach_user_payment_method(self, payment_method_id: str) -> stripe.PaymentMethod:
self.set_stripe_lib()

try:

    payment_method = stripe.PaymentMethod.retrieve(payment_method_id)
    if not payment_method.customer:
        payment_method = stripe.PaymentMethod.attach(
            payment_method_id,
            customer=self.stripe_customer
        )

    setup_intent = stripe.SetupIntent.create(
        payment_method=payment_method_id,
        customer=self.stripe_customer,
        usage="on_session", 
    )

    return payment_method
#

mostly it's working with the current solution, but some banks seems to require SCA / 3DS authenttication when the card is attached to the user. and we don't have yet implemented that in the save card page. we are looking for a quick fix before a better implementation

pseudo helm
#

There isn't one for the SCA requirement

#

You need to be able to redirect the customer to the bank-hosted 3DS authentication page. The easiest way to do that is to use our Payment Sheet to save the card in the first place

pallid sun
#

I agree. Boss don't like the component look though ๐Ÿ˜ฆ so we need to keep the custom integration for now

#

the bank-hosted 3DS authentication page for adding a credit card to the profile is what we would like to avoid

#

because we have this setup but on the checkout, when the user click pay, then if 3DS needed he is redirected

#

so we were hopping by adding the "on_session" param to be able to avoid the 3DS page when just adding a card to the profile

pseudo helm
#

Nope

#

In fact that makes it more likely that they will request 3DS because the Customer is on-session and therefore available to provide authentication

pallid sun
#

ok I see

tulip hearthBOT
pallid sun
#

so we will still have to implement 3DS redirect when the user is only adding a card to his profile then.

#

once we have done that, should we keep server side the current :

payment_method = stripe.PaymentMethod.attach(
payment_method_id, customer=self.stripe_customer
)
?

#

or is is better to use

setup_intent = stripe.SetupIntent.create(
payment_method=payment_method_id,
customer=self.stripe_customer,
setup_future_usage='off_session',
confirm=True
)

pseudo helm
#

That will imply that, when you want to charge the payment method, the customer is not available to perform 3DS authentication.

#

It can cut down on the 3DS requirements but banks can and do request 3DS at any time. There is no way to completely avoid it

pallid sun
#

that is why I thought off_session was the more likely to trigger the 3DS now, because after the user won't be able to do 3DS auth because he will be charged off session

#

but if you say on_session is even worse.. ๐Ÿ˜† there is nothing we can do, except implementing 3DS redirect in both situation

#

so this param won't change anything for us, one way or another

#

thanks for the clarification we will add this redirect

pseudo helm
#

I think that's the right approach!