#pablo-araujo_api

1 messages ยท Page 1 of 1 (latest)

worldly gobletBOT
#

๐Ÿ‘‹ 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/1283081796992499764

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

autumn heathBOT
versed agate
#

well, is it possible? if I have a token like tok_visa, and I want to create a setup intent for that token to allow me to reuse this payment method in the future

deep pebble
#

Hi ๐Ÿ‘‹ are you maintaining an existing Token based integration?

versed agate
#

yes

#

we have an integration with a 3rd-party that allow to collect the card info from a phone call and tokenize the card

#

in another hand for the online customers we use the common way of capturing the payment method info create a confirmation token and confirm a setup intent

#

but we have the exception that I commented before. Our main concern is that the credit card tokenized can be reused in the future

deep pebble
#

Hm, I'm trying to remember the right way to work with Tokens. Do you have a testmode flow where you can try this? I'm thinking you may be able to create a Source from the Token, and then pass the Source to Setup Intent in the payment_method field.

#

Oh, sorry, I was mistaken and found what I was looking for. I'd suggest creating a Payment Method from the Token. You can do so using this endpoint:
https://docs.stripe.com/api/payment_methods/create
You'll pass card in for type, and then the Token's ID in the card.token field:
card: {token: "tok_visa"}

worldly gobletBOT
versed agate
#

and then I can create the setupintent with the payment method created, right?

molten ocean
#

I actually think there is an easier way to do this. Will test and get back to you in a minute

#

Alright, apologies for the delay. So there is a hidden parameter on the SetupIntent create method that you can use.

#

This is what the parameters look like in javascript

  payment_method_data:
  {
    type: 'card',
    card: {
      token: 'tok_visa'
    }
  },
  confirm: true,
  return_url: url
}

Basically there is a payment_method_data parameter that tells the intent to create a new PaymentMethod given the data you pass it. There is a sub-parameter within it for card info and you can pass token: 'tok_123' to that. The intent will then create a PM from the token data and confirm itself with that PM

versed agate
#

oh! nice

#

let me test it

#

I'm testing from the Stripe CLI and I have stripe setup_intents create --confirm=true --payment-method-data[type]=card --payment-method-data[card][token]=tok_visa but I get an invalid object data, how would be? I'm testing with Stripe CLI because it allow me do quick test to understand how works

molten ocean
versed agate
#

I'm cheking the logs and the request is not correct, I'm giving a try to make it work

molten ocean
#

Oh

#

payment_method_data

#

I think you need to use underscores

versed agate
#

thank you

molten ocean
#

Ah here we go stripe setup_intents create -d "payment_method_data[type]=card" -d "payment_method_data[card][token]=tok_visa"

#

Or this
stripe setup_intents create -d payment_method_data[type]="card" -d payment_method_data[card][token]="tok_visa"

versed agate
#

one question more, the return-url is required, what is it used for?

molten ocean
#

Some payment methods require a full page redirect to take payment. If they do, the return URL is where we send them after the payment is finished.

#

Cards do not require a redirect but other PMs do, I can send the doc where you can check

versed agate
#

why? is it hidden for any special reason?

molten ocean
#

I do know that that is hidden on purpose but I am honestly not sure why. Your integration is fine to use that parameter though. Still fully supported