#israel_link-checkout
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/1216789213023047700
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
Why would you expect the Checkout Session to show previously saved payment methods?
Because when a customer cancels a plan, my website blocks his access to the features and allows him to purchase a new plan from the price table, but in this case he would have to have the option of using the payment method he had already registered before cancel the plan.
Hi o/
Okay but this isn't a feature we list for the Checkout Session: https://docs.stripe.com/payments/checkout/how-checkout-works#features
Perhaps you may be thinking of Checkout with Link? https://docs.stripe.com/payments/link/checkout-link
Is it possible to do a checkout with a link through the stripe price table?
Link would be configured on your account settings. The Stripe pricing table is somewhat limited in what you can configure
I found a property within sessions.create() that might help, can you tell me if that would work?
My code is this
import { stripe } from 'lib/stripe';
import { NextRequest, NextResponse } from 'next/server';
const handleCreateCheckoutSession = async (
stripeId: string,
priceId: string
) => {
const stripeCheckoutSession = await stripe.checkout.sessions.create({
customer: stripeId,
payment_method_types: ['card', 'boleto'],
currency: 'brl',
payment_intent_data: {
setup_future_usage: 'on_session' // this prop
},
billing_address_collection: 'required',
line_items: [{ price: priceId, quantity: 1 }],
mode: 'subscription',
allow_promotion_codes: true,
cancel_url: process.env.STRIPE_CANCEL_URL,
success_url: process.env.STRIPE_SUCCESS_URL as string
});
return stripeCheckoutSession;
};
export async function POST(request: NextRequest) {
if (request.method === 'POST') {
const { stripeCustomerId, priceId } = await request.json();
const stripeCheckoutSession = await handleCreateCheckoutSession(
stripeCustomerId,
priceId
);
return new Response(
JSON.stringify({ sessionId: stripeCheckoutSession.id }),
{
status: 200,
statusText: 'Sucesso'
}
);
}
return NextResponse.json('Method not allowed', { status: 405 });
}
That would work for a Checkout Session. But I thought you were using a Pricing Table?
If it works, I can create my own price table just redirecting to the checkout session with this property
That would allow the Checkout Session to save payment methods for the customer, yes
Ok, I'll try that, I appreciate your patience, just one more question, is it possible to update a user's existing subscription through the checkout screen? or does it just create a new subscription for the user?
No, Checkout does not allow that. We do have a separate Stripe hosted interface to allow customers to manage their susbcriptions though. It's called the Customer Portal or sometimes the Billing Portal
Here is the doc for it: https://docs.stripe.com/customer-management
Perfect, thanks for the answers, sorry for any spelling mistakes, my English isn't that good. Anyway, thanks for your time, have a good week and good work.
No worries! Have a great day!