#kevinx9999_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/1315906360776462336
📝 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.
- kevinx9999_webhooks, 12 minutes ago, 27 messages
Could you share what your question is? Stripe doesn't send email in test mode
Hi River, when creating the checkout sessions, I put the user log in email as client_reference_id which I can use it later in webhook to write database.
But, in the invoice.paid object, I didn't find client_reference_id or anything that I can use to identify the user, there is an email for checkout which can be different from the user log in email, so how to identiy invoice owner?
This is expected. Stripe doesn't copy the client_reference_id from Checkout Session object to Invoice object.
One way I'd recommend is to
- Create a Stripe Customer associated to your internal customer reference such as email or your own ID first: https://docs.stripe.com/api/customers/create, then save the Customer ID (cus_xxx) in your own database
- Set the Stripe Customer ID created in Step 1 to
customerof Checkout Session: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-customer
The customer ID (cus_xxx) will be present in invoice.* event in which you can then use it to find the customer information within your database
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, thanks, these are extra read and write to complete a transaction, if Stripe can link all these events with client_reference_id, that would be great, thanks there!
If you really want that id to be reflected on various related objects, you can use metadata instead. You can pass the metadata into subscription_data.metadata (this is for mode="subscription") when creating the Checkout Session. When a Subscription creates an Invoice, the metadata copies to the Invoice object’s subscription_details.metadata.
Really? thanks, let me test it
app.post("/createcheckout", async (req, res) => {
const { email } = req.body;
// Define your app's deep link prefix
const APP_SCHEME = "cmytip://";
const session = await stripe.checkout.sessions.create({
line_items: [
{
price: stripePrice,
quantity: 1,
},
],
mode: "subscription",
client_reference_id: email,
allow_promotion_codes: true,
subscription_data: { metadata: { email: email } },
automatic_tax: { enabled: true },
metadata: {
email: email,
},
success_url: `${API_BASE_URL}redirect?status=success&session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${API_BASE_URL}redirect?status=canceled`,
});
res.status(200).json({ url: session.url });
});
it doesn't work lol
metadata: {}, is empty in invoice.paid
what's the invoice.paid event id?
hold on a sec, you are right,
I missed it
Thanks Alex! you are a pro
Have a good holiday season there! thank you for your help!
cancel_at_period_end, where to config it
you'll need to update the subscription : https://docs.stripe.com/api/subscriptions/update#update_subscription-cancel_at_period_end
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so I can not just set it up in checkout session for subscription?
StripeInvalidRequestError: Received unknown parameter: cancel_at_period_end
it tells me an error
there's no such parameter cancel_at_period_at for Checkout Session, and pretty much yep, you can't set it up at the same time you create the Checkout Session
you can listen for the checkout.session.completed event, get the subscription id, then make a subsequent request to update the subscription
if the subscription is canceled in the middle of the sub period, do users get partial refund?
does stripe prorate it?
that's up to you to configure, so when you cancel the subscription, set prorate=true : https://docs.stripe.com/api/subscriptions/cancel#cancel_subscription-prorate. I'd like to point out that this credits any unused time / amount to the customer balance. If you want to actually refund the customer, you'll need to implement the logic to do so.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can I config cancel_at_period_end during the cancelation api call?
that's done only with the update subscription API. The cancel subscription API is to cancel it immediately
ok, so cancel_at_period_end is default to false, and prorate is default to false as well, so if I don't do anything, there won't be any refund, but, I can allow users to access the resource till the period end?
is this understanding correct?
even cancel_at_period_end is default to false, there won't be any prorate thus no refund etc
ok, so cancel_at_period_end is default to false, and prorate is default to false as well, so if I don't do anything, there won't be any refund, but, I can allow users to access the resource till the period end?
I'm not sure I understand, if you don't do anything, then the subscription won't cancel at period end
ok, to simplify it
do users get any refund if I don't do anything?
no, they won't get any refund. If the subscription is not cancelled, then it'll go on and on forever