#apolloengineer_api

1 messages ยท Page 1 of 1 (latest)

royal wagonBOT
#

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

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

twin comet
#

Hi ๐Ÿ‘‹

Have you considered using Subscription Schedules?
https://docs.stripe.com/api/subscription_schedules
This would allow you to specify the first month as free by creating your first phase with the trail property set to "true". You would use the same Price ID in the trail phase so it would have the same billing period.
https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-trial
You just specify iterations: 1 for the first phase and make a second phase this essentially the same but without the trail parameter.

tough rock
#

This sounds promising

twin comet
#

Subscription Schedules are another layer of complexity on top of Subscriptions so it can be easy to get into trouble. BUT, if you review the docs carefully and focus on your exact use case, they do allow for a higher degree of customization.

#

I strongly recommend building end-to-end testing scenarios so you can validate the behavior is what you expect.

tough rock
#

ok this is my pseudo code, I'll try it out

royal wagonBOT
tough rock
#
    items_parameter = items.reject { |item| item[:deleted] }.map do |item|
      {
        plan: item[:plan],
        quantity: ZpStripe::ConversionUtils.get_stripe_quantity(
          quantity: item[:quantity],
          product: PM.plan_with_id(item[:plan]).product
        ),
        metadata: item[:metadata] || {}
      }
    end

    Stripe::SubscriptionSchedule.create({
      customer: stripe_customer_id,
      phases: [{
        trial: true,
        iterations: 1,
        items: items_parameter
      }, {
        items: items_parameter
      }]
    }.merge(sub_options_temp))
twin comet
#

Have you run it? What happens?

sturdy stratus
#

๐Ÿ‘‹ taking over here and LMK if you have more questions

tough rock
#

it creates a trial invoice

#

curious if we know if the use customer is emailed this invoice

sturdy stratus
#

You mean a trial Subscription? You can paste the Subscription Id to your Stripe Dashboard search and inspect its Invoice

tough rock
#

ok

#

I would like the customer to not receive this invoice