#pablo-araujo_api
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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
Hi ๐ are you maintaining an existing Token based integration?
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
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"}
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and then I can create the setupintent with the payment method created, right?
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
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
I am not immediately sure of the syntax here but am looking. Can you check in your dashboard logs and send me the request ID from the time that you got the error? https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I'm cheking the logs and the request is not correct, I'm giving a try to make it work
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"
one question more, the return-url is required, what is it used for?
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
checking the API doc, I don't see the token attribute for the payment_method_metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
why? is it hidden for any special reason?
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