#jacky_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/1303590376921108490
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
});
==============================================================
const { error } = await stripe.confirmSetup({
elements,
confirmParams: {
payment_method_data: {
billing_details: {
name: "Joe",
address: {
city: "Hong Kong",
country: "HK",
line1: "Test Street",
line2: "Test building 12/F",
},
email: email,
},
},
return_url: `${window.location.origin}/${router.locale}/account/wallet/deposit/card/link/result?session_id={CHECKOUT_SESSION_ID}`,
},
});
So my APi ver is kinda old still at 2022-11-15
When i try to add allow_redisplay I found out that it is the new feature. but when I try customer_consent_collected it still not a valid option to use.
Um that last Doc is more about Terminal API. I think you should just ignore customer_consent_collected and just use allow_redisplay
I tried to put the allow_redisplay like below, not valid ,Am I missing something
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always'
}
});
==================================
const { error } = await stripe.confirmSetup({
elements,
confirmParams: {
payment_method_data: {
billing_details: {
name: "Joe",
address: {
city: "Hong Kong",
country: "HK",
line1: "Test Street",
line2: "Test building 12/F",
},
email: email,
},
allow_redisplay: 'always',
},
return_url: `${window.location.origin}/${router.locale}/account/wallet/deposit/card/link/result?session_id={CHECKOUT_SESSION_ID}`,
},
});
Can you find your request id (req_xxx) from Stripe Dashboard? 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.
request id of Setup intent?
either works
Pleast wait a second . It said parameter_missing - payment_method_data[type]. Lets me add it first and re-create a new log
{
"customer": "cus_RA3YzSX1NSDQaX",
"payment_method_data": {
"allow_redisplay": "always",
"type": <required>
},
"payment_method_types": {
"0": "card"
},
"usage": "off_session"
}
===================================================
what should I put on the payment_method_data_type
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always',
type: ["card"]
}
});
req_pe1cKiLbbpVKdM
invalid_request_error - payment_method_data[type]
Invalid string: {:"0"=>"card"}
{
"customer": "cus_RA3YzSX1NSDQaX",
"payment_method_data": {
"allow_redisplay": "always",
"type": {
"0": "card"
}
},
"payment_method_types": {
"0": "card"
},
"usage": "off_session"
}
Same issue
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always',
type: ['card']
}
});
req_c35leKVGCESlQX
invalid_request_error - payment_method_data[type]
Invalid string: {:"0"=>"card"}
{
"customer": "cus_RA3YzSX1NSDQaX",
"payment_method_data": {
"allow_redisplay": "always",
"type": {
"0": "card"
}
},
"payment_method_types": {
"0": "card"
},
"usage": "off_session"
}
==========================================
So I switch to
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always',
type: "card"
}
});
req_yMoyKUIRg8zWO5
parameter_missing - payment_method_data[card]
Missing required param: payment_method_data[card].
{
"customer": "cus_RA3YzSX1NSDQaX",
"payment_method_data": {
"allow_redisplay": "always",
"type": "card",
"card": <required>
},
"payment_method_types": {
"0": "card"
},
"usage": "off_session"
}
Hmm okie gimme some time to test this
don't know if below info will be useful for you.
const setupIntent = await stripe.setupIntents.`create`({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always',
type: "card"
}
});
No overload matches this call.
Overload 1 of 2, '(params?: SetupIntentCreateParams | undefined, options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Type '"card"' is not assignable to type 'Type'.
Overload 2 of 2, '(options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Object literal may only specify known properties, and 'payment_method_types' does not exist in type 'RequestOptions'.ts(2769)
================================================================================================
const setupIntent = await stripe.setupIntents.`create`({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always',
type: ['card']
}
});
No overload matches this call.
Overload 1 of 2, '(params?: SetupIntentCreateParams | undefined, options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Type 'string[]' is not assignable to type 'Type'.
Overload 2 of 2, '(options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Object literal may only specify known properties, and 'payment_method_types' does not exist in type 'RequestOptions'.ts(2769)
============================================================
const setupIntent = await stripe.setupIntents.create({
payment_method_types: ["card"],
customer: stripeId,
usage: "off_session",
payment_method_data: {
allow_redisplay: 'always'
}
});
No overload matches this call.
Overload 1 of 2, '(params?: SetupIntentCreateParams | undefined, options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Object literal may only specify known properties, and 'allow_redisplay' does not exist in type 'PaymentMethodData'.
Overload 2 of 2, '(options?: RequestOptions | undefined): Promise<Response<SetupIntent>>', gave the following error.
Object literal may only specify known properties, and 'payment_method_types' does not exist in type 'RequestOptions'.ts(2769)
Yes this is not an official parameter. Unfortuantely I realized you can't set this parameter on SetupIntent like this
You can consider collecting the customer consent on frontend, and then call Update Payment Method API to update the Payment Method 's allow_redisplay directly
This allow_redisplay is mostly used for Checkout: https://support.stripe.com/questions/prefilling-saved-cards-in-checkout
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
https://docs.stripe.com/api/payment_methods/update?lang=node
I have tried something like below. But allow_redisplay is not a valid parameter still
const update = await stripe.paymentMethods.update(
'pm_1QGF9vKHA3BqBfGBvQkRdvpO',
{
billing_details:{
address:{
line1: "123 street",
country: "HK"
}
},
allow_redisplay: 'always'
}
)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
request id for that call please?
Pleast wait a moment
Sorry for the wait. I was testing the method.
At the end I found out that
import { NextApiRequest, NextApiResponse } from 'next'
import Stripe from'stripe'
import { getStripeSecretKey } from '../../../../../helper/getSecret'
const stripe = new Stripe(getStripeSecretKey(),
{
apiVersion: '2022-11-15',
})
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === 'POST') {
const paymentMethodId = req.body.paymentMethodId as string;
try {
const response = await stripe.paymentMethods.update(paymentMethodId, {
billing_details: {
name: 'updated',
},
allow_redisplay: 'always'
});
res.json(response);
} catch (error) {
res.status(500).json({ error: 'Error updating payment method' });
}
} else {
res.status(405).json({ error: 'Method not allowed' });
}
}
even the allow_redisplay: 'always' showing Error
Object literal may only specify known properties, and 'allow_redisplay' does not exist in type 'PaymentMethodUpdateParams'.ts(2353)
(property) allow_redisplay: string
No quick fixes available
I can still update the paymentmethod allow_redisaply value to always
Thank you so much for the help
======================
the id
req_3nKqnGMcrt4WCi
I never actually try to update the method since the code showing error. My bad