#fabian_api

1 messages ยท Page 1 of 1 (latest)

hearty heartBOT
#

๐Ÿ‘‹ 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/1268225819462078484

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

valid locust
#
    const subscriptionSchedule = await stripe.subscriptionSchedules.create({
      customer: customerId,
      end_behavior: 'release',
      phases: [
        {
          items: [
            {
              price: testProduct,
            },
          ],
          iterations: amountTestMonths ?? 1,
          currency: 'eur',
        },
        {
          items: [
            {
              price: mainProduct,
            },
          ],
          currency: 'eur',
        },
      ],
    });
digital relic
#

That looks like it should properly create a schedule that creates a subscription. What is happening instead?

valid locust
#

It seems like it doesnt have the same properties as a "real" subscription. eg:

      payment_settings: {save_default_payment_method: 'on_subscription'},
      expand: ['latest_invoice.payment_intent'],
#

Also I cant figure out how to get the clientSecret

#

With a normal subscription I could access it like the following:

clientSecret: (
        (subscription?.latest_invoice as Stripe.Invoice)
          .payment_intent as Stripe.PaymentIntent
      ).client_secret,
#

At the moment I need the client secret to complete the transaction on the client side

digital relic
#

Are those the payment behavior and settings that you do want or don't want?

valid locust
#

That I want

#

To be honest I am not completely sure

digital relic
#

Those setting should properly be reflected on the subscription. Once you do know the settings that you want, you can pass them to the phase settings

#

Can you tell me more about what you are trying to figure out with what you want these settings to be?

valid locust
#

I think my main focus at the moment is the client secret to complete the transaction

#

I just cant figure out the interaction between a subscription and a subscription schedule.

#

I need a way to achieve the following but with two phases:

    const subscription = await stripe.subscriptions.create({
      customer: customerId,
      currency: 'eur',
      items: [{price: mainProduct}],
      payment_behavior: 'default_incomplete',
      payment_settings: {save_default_payment_method: 'on_subscription'},
      expand: ['latest_invoice.payment_intent'],
    });
        return {
          status: 'success',
          message: 'Stripe Subscription created',
          subscriptionId: subscription.id,
          customerId,
          clientSecret: (
            (subscription?.latest_invoice as Stripe.Invoice)
              .payment_intent as Stripe.PaymentIntent
          ).client_secret,
        };
digital relic
#

The schedule create that you have now should work. Is there not a payment intent on the latest invoice when you create it?

valid locust
#

If I do the same with subscriptionSchedules

digital relic
#

You would need to do subscription?.subscription.latest_invoice

#

So basically Subscription Schedules are not subscriptions themselves. They manage a separate subscription object

#

The schedule doesn't have a latest invoice but the subscription does

valid locust
#

Ah got it. This makes sense

#

Thank you ๐Ÿ‘