🖥
#Stripe API / Create Subscription schedule and Update current phases a
Points
- You may build phases structure of update.
- You maybe not able to update only one phase in multiple phases.
- You probably must give "start_date" same as current phase start date. in first phase in new update phases. with already started Subscription Schedule.
Docs
Docs
Code
# Code
require 'stripe'
Stripe::api_key = ENV['STRIPE_SECRET_KEY']
product1 = Stripe::Product.create(name: "Gold plan #{rand(9999999999)}")
plan1 = Stripe::Plan.create(interval: 'month', currency: 'jpy', amount: 5000, product: product1.id, usage_type: 'licensed')
product2 = Stripe::Product.create(name: "Silver plan #{rand(9999999999)}")
plan2 = Stripe::Plan.create(interval: 'month', currency: 'jpy', amount: 3000, product: product2.id, usage_type: 'licensed')
product3 = Stripe::Product.create(name: "Bronse plan #{rand(9999999999)}")
plan3 = Stripe::Plan.create(interval: 'month', currency: 'jpy', amount: 1000, product: product3.id, usage_type: 'licensed')
tax_rate = Stripe::TaxRate.create(display_name: 'Tax Rate', percentage: 10.0, inclusive: false)
customer = Stripe::Customer.create
payment_method = Stripe::PaymentMethod.create(type: 'card', card: { number: '4242424242424242', exp_year: 2030, exp_month: 01})
customer_payment_method = Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
def put_subscription_schedule(subscription_schedule, message)
puts '-' * 100
puts "Subscription Schedule"
puts message
puts '-' * 100
puts subscription_schedule
end
# https://stripe.com/docs/api/subscription_schedules/create
subscription_schedule = Stripe::SubscriptionSchedule.create(
{
customer: customer.id,
start_date: Time.now.to_i + 5,
default_settings: {
default_payment_method: customer_payment_method.id,
},
phases: [
{
plans:
[
{ plan: plan1.id, quantity: 1 },
{ plan: plan2.id, quantity: 4 },
],
default_tax_rates: [tax_rate],
iterations: 3,
},
{
plans:
[
{ plan: plan2.id, quantity: 1 },
{ plan: plan3.id, quantity: 1 },
],
default_tax_rates: [tax_rate],
iterations: 5,
},
{
plans:
[
{ plan: plan3.id, quantity: 3 },
{ plan: plan1.id, quantity: 2 },
],
default_tax_rates: [tax_rate],
iterations: 7,
}
],
}
)
put_subscription_schedule(subscription_schedule, 'CREATED')
puts '-' * 100
puts "Wait until subscription schedule starts"
puts '-' * 100
until subscription_schedule.status == 'active' do
subscription_schedule = Stripe::SubscriptionSchedule.retrieve(subscription_schedule.id)
puts subscription_schedule.status
sleep 2
end
started_subscription_schedule = Stripe::SubscriptionSchedule.retrieve(id: subscription_schedule.id, expand: ['subscription'])
put_subscription_schedule(started_subscription_schedule, 'STARTED')
puts '-' * 100
puts "Subscription created"
puts "https://dashboard.stripe.com/test/subscriptions/#{started_subscription_schedule.subscription.id}"
puts '-' * 100
puts started_subscription_schedule.subscription
# Build update phases structure from first created subscription schedule
#
# SubscriptionSchedule has no "iterations" property in it self
# Because it handles iterations by start_date / end_date and cycle of plans
update_subscription_schedule_phases = subscription_schedule.phases.map do |phase|
plans = phase.plans.map do |plan|
{ plan: plan.plan, quantity: plan.quantity }
end;
{
plans: plans,
default_payment_method: phase.default_payment_method,
start_date: phase.start_date,
end_date: phase.end_date,
}
end
# Example
# Keep current phase but remove next come phases
updated_subscription_schedule = Stripe::SubscriptionSchedule.update(
subscription_schedule.id,
{
phases: [
update_subscription_schedule_phases[0]
]
}
)
put_subscription_schedule(updated_subscription_schedule, 'UPDATED')
# Example
# Update and reset to same phases on subscription shcedule created
updated_subscription_schedule = Stripe::SubscriptionSchedule.update(
subscription_schedule.id,
{
phases: update_subscription_schedule_phases
}
)
put_subscription_schedule(updated_subscription_schedule, 'UPDATED')
# Stripe::InvalidRequestError: You can only adjust the end date to a future date for the current phase.
#
# updated_subscription_schedule = Stripe::SubscriptionSchedule.update(
# subscription_schedule.id,
# {
# phases: [update_subscription_schedule_phases[1]]
# }
# )
# https://stripe.com/docs/api/subscription_schedules/update
#
# no customer id because already knows customer
# no start_date because already set start_date when created
#
# If
# no phases has start_date
# Then
# Stripe::InvalidRequestError: The subscription schedule update is missing at least one phase with a `start_date` to anchor end dates to.
#
# If
# not equal subscription_schedule.current_phase.start_date
# e.g
# update_start_date_set_on_first_phase = subscription_schedule.current_phase.start_date + 1
# update_start_date_set_on_first_phase = subscription_schedule.current_phase.start_date - 1
# Then
# Stripe::InvalidRequestError: You can only adjust the end date to a future date for the current phase.
# This message seems strange for me
update_start_date_set_on_first_phase = subscription_schedule.current_phase.start_date
# Example
# Update and shuffle phases and subscriptions
updated_subscription_schedule = Stripe::SubscriptionSchedule.update(
subscription_schedule.id,
{
phases: [
{
plans:
[
{ plan: plan1.id, quantity: [*1..10].sample },
{ plan: plan2.id, quantity: [*1..10].sample },
],
default_payment_method: customer_payment_method.id,
default_tax_rates: [tax_rate],
iterations: [*1..10].sample,
start_date: update_start_date_set_on_first_phase,
},
{
plans:
[
{ plan: plan2.id, quantity: [*1..10].sample },
{ plan: plan3.id, quantity: [*1..10].sample },
],
default_payment_method: customer_payment_method.id,
default_tax_rates: [tax_rate],
iterations: [*1..10].sample,
}
]
}
)
put_subscription_schedule(updated_subscription_schedule, 'UPDATED')
In Dashboard - Created
In Dashboard - Started
In Dashboard - Updated
In Dashboard - Updated
In Dashboard - Updated
Run
$ STRIPE_SECRET_KEY=sk_test_xxxx ruby ~/tmp/stripe-subscription.rb
----------------------------------------------------------------------------------------------------
Subscription Schedule
CREATED
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577854767,
"current_phase": null,
"customer": "cus_GSv9dlPfWQnUzM",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"invoice_settings": null
},
"end_behavior": "release",
"livemode": false,
"metadata": {
},
"phases": [
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1585717172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 4,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577854772,
"tax_percent": 10.0,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1598936372,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1585717172,
"tax_percent": 10.0,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1617253172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 3,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 2,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1598936372,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1FvzIpCmti5jpytUnnlu1fqt",
"status": "not_started",
"subscription": null
}
----------------------------------------------------------------------------------------------------
Wait until subscription schedule starts
----------------------------------------------------------------------------------------------------
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
not_started
active
----------------------------------------------------------------------------------------------------
Subscription Schedule
STARTED
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577854767,
"current_phase": {
"end_date": 1585717172,
"start_date": 1577854772
},
"customer": "cus_GSv9dlPfWQnUzM",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"invoice_settings": null
},
"end_behavior": "release",
"livemode": false,
"metadata": {
},
"phases": [
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1585717172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 4,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577854772,
"tax_percent": 10.0,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1598936372,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1585717172,
"tax_percent": 10.0,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1617253172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 3,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 2,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1598936372,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1FvzIpCmti5jpytUnnlu1fqt",
"status": "active",
"subscription": {
"id": "sub_GSvAZCbL0Ya2Dz",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577854772,
"billing_thresholds": null,
"cancel_at": 1585717172,
"cancel_at_period_end": false,
"canceled_at": 1577854772,
"collection_method": "charge_automatically",
"created": 1577854772,
"current_period_end": 1580533172,
"current_period_start": 1577854772,
"customer": "cus_GSv9dlPfWQnUzM",
"days_until_due": null,
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"discount": null,
"ended_at": null,
"invoice_customer_balance_settings": {
"consume_applied_balance_on_void": true
},
"items": {
"object": "list",
"data": [
{
"id": "si_GSvAdhvFrqOTic",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577854834,
"metadata": {
},
"plan": {
"id": "plan_GSv96AVCPo5AnI",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 5000,
"amount_decimal": "5000",
"billing_scheme": "per_unit",
"created": 1577854764,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GSv9N2AIVdvrAr",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_GSvAZCbL0Ya2Dz",
"tax_rates": [
]
},
{
"id": "si_GSvAgKooNc96qR",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577854834,
"metadata": {
},
"plan": {
"id": "plan_GSv9Ppg630rR1B",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 3000,
"amount_decimal": "3000",
"billing_scheme": "per_unit",
"created": 1577854765,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GSv9wehfuUCd9Z",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 4,
"subscription": "sub_GSvAZCbL0Ya2Dz",
"tax_rates": [
]
}
],
"has_more": false,
"total_count": 2,
"url": "/v1/subscription_items?subscription=sub_GSvAZCbL0Ya2Dz"
},
"latest_invoice": "in_1FvzJtCmti5jpytURRXRx3j8",
"livemode": false,
"metadata": {
},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": null,
"quantity": null,
"schedule": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"start_date": 1577854772,
"status": "active",
"tax_percent": 10.0,
"trial_end": null,
"trial_start": null
}
}
----------------------------------------------------------------------------------------------------
Subscription created
https://dashboard.stripe.com/test/subscriptions/sub_GSvAZCbL0Ya2Dz
----------------------------------------------------------------------------------------------------
{
"id": "sub_GSvAZCbL0Ya2Dz",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577854772,
"billing_thresholds": null,
"cancel_at": 1585717172,
"cancel_at_period_end": false,
"canceled_at": 1577854772,
"collection_method": "charge_automatically",
"created": 1577854772,
"current_period_end": 1580533172,
"current_period_start": 1577854772,
"customer": "cus_GSv9dlPfWQnUzM",
"days_until_due": null,
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"discount": null,
"ended_at": null,
"invoice_customer_balance_settings": {
"consume_applied_balance_on_void": true
},
"items": {
"object": "list",
"data": [
{
"id": "si_GSvAdhvFrqOTic",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577854834,
"metadata": {
},
"plan": {
"id": "plan_GSv96AVCPo5AnI",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 5000,
"amount_decimal": "5000",
"billing_scheme": "per_unit",
"created": 1577854764,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GSv9N2AIVdvrAr",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_GSvAZCbL0Ya2Dz",
"tax_rates": [
]
},
{
"id": "si_GSvAgKooNc96qR",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577854834,
"metadata": {
},
"plan": {
"id": "plan_GSv9Ppg630rR1B",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 3000,
"amount_decimal": "3000",
"billing_scheme": "per_unit",
"created": 1577854765,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GSv9wehfuUCd9Z",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 4,
"subscription": "sub_GSvAZCbL0Ya2Dz",
"tax_rates": [
]
}
],
"has_more": false,
"total_count": 2,
"url": "/v1/subscription_items?subscription=sub_GSvAZCbL0Ya2Dz"
},
"latest_invoice": "in_1FvzJtCmti5jpytURRXRx3j8",
"livemode": false,
"metadata": {
},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": null,
"quantity": null,
"schedule": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"start_date": 1577854772,
"status": "active",
"tax_percent": 10.0,
"trial_end": null,
"trial_start": null
}
----------------------------------------------------------------------------------------------------
Subscription Schedule
UPDATED
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577854767,
"current_phase": {
"end_date": 1585717172,
"start_date": 1577854772
},
"customer": "cus_GSv9dlPfWQnUzM",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"invoice_settings": {
"days_until_due": null
}
},
"end_behavior": "release",
"livemode": false,
"metadata": {
},
"phases": [
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
],
"end_date": 1585717172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 4,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577854772,
"tax_percent": null,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1FvzJzCmti5jpytUKNbp8VYS",
"status": "active",
"subscription": "sub_GSvAZCbL0Ya2Dz"
}
----------------------------------------------------------------------------------------------------
Subscription Schedule
UPDATED
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577854767,
"current_phase": {
"end_date": 1585717172,
"start_date": 1577854772
},
"customer": "cus_GSv9dlPfWQnUzM",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"invoice_settings": {
"days_until_due": null
}
},
"end_behavior": "release",
"livemode": false,
"metadata": {
},
"phases": [
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
],
"end_date": 1585717172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 4,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577854772,
"tax_percent": null,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
],
"end_date": 1598936372,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 1,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1585717172,
"tax_percent": null,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": null,
"default_tax_rates": [
],
"end_date": 1617253172,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 3,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 2,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1598936372,
"tax_percent": null,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1FvzJzCmti5jpytUr8Kbu64A",
"status": "active",
"subscription": "sub_GSvAZCbL0Ya2Dz"
}
----------------------------------------------------------------------------------------------------
Subscription Schedule
UPDATED
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1FvzIpCmti5jpytUmHomKTmD",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577854767,
"current_phase": {
"end_date": 1598936372,
"start_date": 1577854772
},
"customer": "cus_GSv9dlPfWQnUzM",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_source": null,
"invoice_settings": {
"days_until_due": null
}
},
"end_behavior": "release",
"livemode": false,
"metadata": {
},
"phases": [
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1598936372,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv96AVCPo5AnI",
"quantity": 8,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 5,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577854772,
"tax_percent": 10.0,
"trial_end": null
},
{
"application_fee_percent": null,
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"default_payment_method": "pm_1FvzIoCmti5jpytUfcf56qXP",
"default_tax_rates": [
{
"id": "txr_1FvzInCmti5jpytUipQ6xVGU",
"object": "tax_rate",
"active": true,
"created": 1577854765,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1601528372,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GSv9Ppg630rR1B",
"quantity": 5,
"tax_rates": [
]
},
{
"billing_thresholds": null,
"plan": "plan_GSv99o5yLatFvT",
"quantity": 2,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1598936372,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1FvzK0Cmti5jpytUwEbq4ePj",
"status": "active",
"subscription": "sub_GSvAZCbL0Ya2Dz"
}
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2020-01-02
Discussion