#stan_api

1 messages · Page 1 of 1 (latest)

supple meadowBOT
#

👋 Welcome to your new thread!

⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!

🔗 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/1212672421266591744

📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.

⏲️ 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. Thank you for your patience!

forest ridgeBOT
#

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.

ember crescent
#

Can you share the request ID (req_xxx) which you retrieve the Subscription with expanding those two fields and its response returned from Stripe? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request

lime mango
#

subscriptionId: sub_1Op4ozGogiQBpoccUCxP2crW
reqId: req_jlN0tZgTlq4N6c

#

this is how I create the schedule

#

{
customer: customerId,
start_date: 'now',
end_behavior: 'release',
phases: [
{
items: [
{
price: price?.id,
quantity,
},
],
trial: true,
end_date: subscriptionStartPeriod.utc().unix(),
},
{
items: [
{
price: price?.id,
quantity,
},
],
end_date: subscriptionStartPeriod.add(1, 'month').startOf('month').add(12, 'hours').utc().unix(),
},
{
items: [
{
price: price?.id,
quantity,
},
],
iterations: 100,
},
],
expand: ['subscription.pending_setup_intent', 'subscription', 'subscription.latest_invoice'],
}

ember crescent
lime mango
#

I tried to get it from latest_invoice

#

but again it is null

ember crescent
lime mango
#

so how do I verify the payment using schedule

ember crescent
#

You should finalise the latest_invoice to get the Payment Intent: https://docs.stripe.com/api/invoices/finalize

Alternatively, I'd recommend following:

  1. Create a subscription directly with the guide here: https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=elements
  2. Only when the payment is made successfully, then you create a subscription schedule: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#changing-subscriptions

Create and manage subscriptions to accept recurring payments.

Learn how to use subscription schedules.

lime mango
#

when I finalize it, payment_intent is again null on the invoice itself

ember crescent
lime mango
#

const invoice = await this.stripeClient.invoices.finalizeInvoice(
(subscription.latest_invoice as Stripe.Invoice).id,
);
const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});

ember crescent
#

Can you share the request ID (req_xxx) which you finalise the invoice? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request

I don't see in_1Op4ozGogiQBpoccUSpmZJ6p being finalised

lime mango
#

req_FuzCoGuuHCZEeX

#

after finilizing, do I need to retrieve the subscription again with expand: ['latest_invoice']

#

and look for the intent there ?

ember crescent
#

This is a zero dollar invoice. It's expected that Payment Intent will not be present even after you finalise it

lime mango
#

yeah my first item is trial

ember crescent
#

When you retrieve the Subscription again for zero dollar in first invoice, pending_setup_intent should be present

lime mango
#

but it is null

#

await this.stripeClient.invoices.finalizeInvoice((subscription.latest_invoice as Stripe.Invoice).id);
const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});
console.log(s.pending_setup_intent);

ember crescent
#

Can you share the request ID (req_xxx) of your subscription retrieval and the full response from Stripe?

lime mango
#

req_4fj2A4L1oCQ8Ph

#

this is finilize

#

then I do GET of the subscription, there is no log for the get

ember crescent
#

Stripe doesn't store the GET response. Sharing the GET response from your request will help us to understand the problem

lime mango
#

ok

#

for request: req_mQ1p6En7Q0OYGR

#

and this is how I get this response after finalizeInvoice

#

const s = await this.stripeClient.subscriptions.retrieve(subscription.id, {
expand: ['pending_setup_intent', 'latest_invoice'],
});

quasi grove
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

lime mango
#

ok

quasi grove
#

We just checked and it seems to be a known bug. What you can do instead is create a Subscription with trial normally, and when the trial ends/customer adds a Payment Method, turn it into a Subscription Schedule.

lime mango
#

this means that I have to create subscription and after 14 days to cancel it with crone and create a new one ?

#

what I need to achieve is to create a subscription with 14 days free trial and the billing of the subscription should happen on 1st of each month

#

you college pointed me to go to schedules

#

now you are saying that I have to build the subscription on my self with crone ?

quasi grove
#

You can turn any regular Stripe Subscription into a Subscription Schedule. You should create one regular Subscription with trial, and then turn it into a Subscription Schedule (as you do now), with from_subscription parameter.

lime mango
#

so what you mean is to create subscription and then create schedule with that subscription

#

when I create it from subscription, I can't set phases ?

#

as I said I need it to start now, to have 14 days trial and then to start normal billing from 1st of the month

#

if the user subscribe today it should have trial till 14 of march

quasi grove
lime mango
#

on 14 it should bill for 14-31 march

#

and then full billing on 1st of aprial

#

it is for 14 days

quasi grove
lime mango
#

this is what I am trying to build

lime mango
#

exactly

quasi grove
lime mango
#

but then I am missing payment_intent

#

I can't get it when I create schedule

#
  1. create subscription with 14 days trial
  2. create schedule from that subscription
  3. update it some how and add more items ?
quasi grove
#
  1. You will get the pending_setup_intent when you create a regular Subscription with a trial.
  2. Then you listen to setup_intent.succeeded (meaning customer added a Payment Method) and turn Subscription into a Subscription Schedule.
  3. Immediately after add more phases to your S.Schedule.
lime mango
#

ok, can you give me example of how to turn it to schedule

#

first I create schedule from the subscription and then how to add items ?

quasi grove
lime mango
#

yes this is how to create schedule from subscription

#

but then I need to add more items

#

is there example for it

quasi grove
lime mango
#

do I need again to add trial phase ?

quasi grove
#

Yes, I think so. You need to specify the currently running phase too.

lime mango
#

ok

#

I will try