🖥
#Stripe API で定期支払いのスケジュールを登録して、すぐに請求し、支払い成功させる ( with #Ruby )
Code
# Docs
# https://stripe.com/docs/api/subscription_schedules/create
#
# Invoicing workflow | Stripe Billing
# https://stripe.com/docs/billing/invoices/workflow
#
# https://stripe.com/docs/api/invoices/
# Code
require 'stripe'
Stripe::api_key = ENV['STRIPE_SECRET_KEY']
product = Stripe::Product.create(name: "Gold plan #{rand(9999999999)}")
plan = Stripe::Plan.create(interval: 'month', currency: 'jpy', amount: 1000, product: product.id)
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)
# Subscription create case
# subscription = Stripe::Subscription::create( customer: customer.id, default_payment_method: customer_payment_method.id, items: [{ plan: plan.id }], default_tax_rates: [tax_rate] )
# Set start_date to immediately start schedule
subscription_schedule = Stripe::SubscriptionSchedule.create(
{
customer: customer.id,
start_date: Time.now.to_i + 3,
end_behavior: 'release',
phases: [
{
plans:
[
{plan: plan.id, quantity: 1},
],
iterations: 12,
default_payment_method: customer_payment_method.id,
default_tax_rates: [tax_rate],
},
],
}
)
puts '-' * 100
puts "Subscription Schedule created"
puts "https://dashboard.stripe.com/test/subscription_schedules/#{subscription_schedule.id}"
puts '-' * 100
puts subscription_schedule
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
subscription = Stripe::Subscription.retrieve(id: subscription_schedule.subscription, expand: ['schedule', 'latest_invoice'])
puts subscription
puts '-' * 100
puts "Subscription created"
puts "https://dashboard.stripe.com/test/subscriptions/#{subscription.id}"
puts '-' * 100
latest_invoice = subscription.latest_invoice
puts latest_invoice
puts '-' * 100
puts "Invoice created"
puts "https://dashboard.stripe.com/test/invoices/#{latest_invoice.id}"
puts '-' * 100
paid_invoice = Stripe::Invoice.pay(latest_invoice.id)
puts paid_invoice
puts '-' * 100
puts "Invoice payment probably succeeded"
puts '-' * 100
retrieve_invoice = Stripe::Invoice.retrieve(id: latest_invoice.id, expand: ['subscription','subscription.schedule'])
puts '-' * 100
puts "Retrieve subscription from invoice"
puts '-' * 100
puts retrieve_invoice.subscription
puts '-' * 100
puts "Retrieve subscription schedule from invoice"
puts '-' * 100
puts retrieve_invoice.subscription.schedule
Run example
$ STRIPE_SECRET_KEY=sk_test_xxxxxxx ruby ~/tmp/stripe-subscription-schedule.rb
----------------------------------------------------------------------------------------------------
Subscription Schedule created
https://dashboard.stripe.com/test/subscription_schedules/sub_sched_1Ftk11Cmti5jpytUFlkdOKDt
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1Ftk11Cmti5jpytUFlkdOKDt",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577319347,
"current_phase": null,
"customer": "cus_GQbDdYLUXLHE9m",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": null,
"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": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1608941750,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GQbDoFK42Sxy6z",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577319350,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1Ftk11Cmti5jpytUEuhpqnPt",
"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
active
{
"id": "sub_GQbEXMXD1ciXk9",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577319350,
"billing_thresholds": null,
"cancel_at": 1608941750,
"cancel_at_period_end": false,
"canceled_at": 1577319350,
"collection_method": "charge_automatically",
"created": 1577319350,
"current_period_end": 1579997750,
"current_period_start": 1577319350,
"customer": "cus_GQbDdYLUXLHE9m",
"days_until_due": null,
"default_payment_method": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"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_GQbEkVikV3ZthN",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577319381,
"metadata": {
},
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_GQbEXMXD1ciXk9",
"tax_rates": [
]
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/subscription_items?subscription=sub_GQbEXMXD1ciXk9"
},
"latest_invoice": {
"id": "in_1Ftk1YCmti5jpytUQsbtoUFn",
"object": "invoice",
"account_country": "JP",
"account_name": "yumainaura",
"amount_due": 1100,
"amount_paid": 0,
"amount_remaining": 1100,
"application_fee_amount": null,
"attempt_count": 0,
"attempted": false,
"auto_advance": true,
"billing_reason": "subscription_create",
"charge": null,
"collection_method": "charge_automatically",
"created": 1577319380,
"currency": "jpy",
"custom_fields": null,
"customer": "cus_GQbDdYLUXLHE9m",
"customer_address": null,
"customer_email": null,
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
"customer_tax_exempt": "none",
"customer_tax_ids": [
],
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"description": null,
"discount": null,
"due_date": null,
"ending_balance": null,
"footer": null,
"hosted_invoice_url": null,
"invoice_pdf": null,
"lines": {
"object": "list",
"data": [
{
"id": "sli_38474efa3a6d4d",
"object": "line_item",
"amount": 1000,
"currency": "jpy",
"description": "1 × Gold plan 2633593089 (at ¥1,000 / month)",
"discountable": true,
"livemode": false,
"metadata": {
},
"period": {
"end": 1579997750,
"start": 1577319350
},
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"proration": false,
"quantity": 1,
"subscription": "sub_GQbEXMXD1ciXk9",
"subscription_item": "si_GQbEkVikV3ZthN",
"tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"tax_rates": [
],
"type": "subscription",
"unique_id": "il_1Ftk1YCmti5jpytUmX52GECS"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_1Ftk1YCmti5jpytUQsbtoUFn/lines"
},
"livemode": false,
"metadata": {
},
"next_payment_attempt": 1577322980,
"number": "FF7403DD-0001",
"paid": false,
"payment_intent": null,
"period_end": 1577319350,
"period_start": 1577319350,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "draft",
"status_transitions": {
"finalized_at": null,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subscription": "sub_GQbEXMXD1ciXk9",
"subtotal": 1000,
"tax": 100,
"tax_percent": 10.0,
"total": 1100,
"total_tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"webhooks_delivered_at": 1577319382
},
"livemode": false,
"metadata": {
},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"schedule": {
"id": "sub_sched_1Ftk11Cmti5jpytUFlkdOKDt",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577319347,
"current_phase": {
"end_date": 1608941750,
"start_date": 1577319350
},
"customer": "cus_GQbDdYLUXLHE9m",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": null,
"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": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1608941750,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GQbDoFK42Sxy6z",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577319350,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1Ftk11Cmti5jpytUEuhpqnPt",
"status": "active",
"subscription": "sub_GQbEXMXD1ciXk9"
},
"start_date": 1577319350,
"status": "active",
"tax_percent": 10.0,
"trial_end": null,
"trial_start": null
}
----------------------------------------------------------------------------------------------------
Subscription created
https://dashboard.stripe.com/test/subscriptions/sub_GQbEXMXD1ciXk9
----------------------------------------------------------------------------------------------------
{
"id": "in_1Ftk1YCmti5jpytUQsbtoUFn",
"object": "invoice",
"account_country": "JP",
"account_name": "yumainaura",
"amount_due": 1100,
"amount_paid": 0,
"amount_remaining": 1100,
"application_fee_amount": null,
"attempt_count": 0,
"attempted": false,
"auto_advance": true,
"billing_reason": "subscription_create",
"charge": null,
"collection_method": "charge_automatically",
"created": 1577319380,
"currency": "jpy",
"custom_fields": null,
"customer": "cus_GQbDdYLUXLHE9m",
"customer_address": null,
"customer_email": null,
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
"customer_tax_exempt": "none",
"customer_tax_ids": [
],
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"description": null,
"discount": null,
"due_date": null,
"ending_balance": null,
"footer": null,
"hosted_invoice_url": null,
"invoice_pdf": null,
"lines": {
"object": "list",
"data": [
{
"id": "sli_38474efa3a6d4d",
"object": "line_item",
"amount": 1000,
"currency": "jpy",
"description": "1 × Gold plan 2633593089 (at ¥1,000 / month)",
"discountable": true,
"livemode": false,
"metadata": {
},
"period": {
"end": 1579997750,
"start": 1577319350
},
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"proration": false,
"quantity": 1,
"subscription": "sub_GQbEXMXD1ciXk9",
"subscription_item": "si_GQbEkVikV3ZthN",
"tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"tax_rates": [
],
"type": "subscription",
"unique_id": "il_1Ftk1YCmti5jpytUmX52GECS"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_1Ftk1YCmti5jpytUQsbtoUFn/lines"
},
"livemode": false,
"metadata": {
},
"next_payment_attempt": 1577322980,
"number": "FF7403DD-0001",
"paid": false,
"payment_intent": null,
"period_end": 1577319350,
"period_start": 1577319350,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "draft",
"status_transitions": {
"finalized_at": null,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subscription": "sub_GQbEXMXD1ciXk9",
"subtotal": 1000,
"tax": 100,
"tax_percent": 10.0,
"total": 1100,
"total_tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"webhooks_delivered_at": 1577319382
}
----------------------------------------------------------------------------------------------------
Invoice created
https://dashboard.stripe.com/test/invoices/in_1Ftk1YCmti5jpytUQsbtoUFn
----------------------------------------------------------------------------------------------------
{
"id": "in_1Ftk1YCmti5jpytUQsbtoUFn",
"object": "invoice",
"account_country": "JP",
"account_name": "yumainaura",
"amount_due": 1100,
"amount_paid": 1100,
"amount_remaining": 0,
"application_fee_amount": null,
"attempt_count": 1,
"attempted": true,
"auto_advance": false,
"billing_reason": "subscription_create",
"charge": "ch_1Ftk1eCmti5jpytUa9N5N0cf",
"collection_method": "charge_automatically",
"created": 1577319380,
"currency": "jpy",
"custom_fields": null,
"customer": "cus_GQbDdYLUXLHE9m",
"customer_address": null,
"customer_email": null,
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
"customer_tax_exempt": "none",
"customer_tax_ids": [
],
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"description": null,
"discount": null,
"due_date": null,
"ending_balance": 0,
"footer": null,
"hosted_invoice_url": "https://pay.stripe.com/invoice/invst_7ln6i62uKeaBMkqZ1BdedfM6Rv",
"invoice_pdf": "https://pay.stripe.com/invoice/invst_7ln6i62uKeaBMkqZ1BdedfM6Rv/pdf",
"lines": {
"object": "list",
"data": [
{
"id": "sli_38474efa3a6d4d",
"object": "line_item",
"amount": 1000,
"currency": "jpy",
"description": "1 × Gold plan 2633593089 (at ¥1,000 / month)",
"discountable": true,
"livemode": false,
"metadata": {
},
"period": {
"end": 1579997750,
"start": 1577319350
},
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"proration": false,
"quantity": 1,
"subscription": "sub_GQbEXMXD1ciXk9",
"subscription_item": "si_GQbEkVikV3ZthN",
"tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"tax_rates": [
],
"type": "subscription",
"unique_id": "il_1Ftk1YCmti5jpytUmX52GECS"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_1Ftk1YCmti5jpytUQsbtoUFn/lines"
},
"livemode": false,
"metadata": {
},
"next_payment_attempt": null,
"number": "FF7403DD-0001",
"paid": true,
"payment_intent": "pi_1Ftk1dCmti5jpytU0dsPSu4w",
"period_end": 1577319350,
"period_start": 1577319350,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "paid",
"status_transitions": {
"finalized_at": 1577319385,
"marked_uncollectible_at": null,
"paid_at": 1577319386,
"voided_at": null
},
"subscription": "sub_GQbEXMXD1ciXk9",
"subtotal": 1000,
"tax": 100,
"tax_percent": 10.0,
"total": 1100,
"total_tax_amounts": [
{
"amount": 100,
"inclusive": false,
"tax_rate": "txr_1Ftk0zCmti5jpytUkYy6UaYf"
}
],
"webhooks_delivered_at": 1577319382
}
----------------------------------------------------------------------------------------------------
Invoice payment probably succeeded
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Retrieve subscription from invoice
----------------------------------------------------------------------------------------------------
{
"id": "sub_GQbEXMXD1ciXk9",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577319350,
"billing_thresholds": null,
"cancel_at": 1608941750,
"cancel_at_period_end": false,
"canceled_at": 1577319350,
"collection_method": "charge_automatically",
"created": 1577319350,
"current_period_end": 1579997750,
"current_period_start": 1577319350,
"customer": "cus_GQbDdYLUXLHE9m",
"days_until_due": null,
"default_payment_method": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_source": null,
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"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_GQbEkVikV3ZthN",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1577319381,
"metadata": {
},
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_GQbEXMXD1ciXk9",
"tax_rates": [
]
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/subscription_items?subscription=sub_GQbEXMXD1ciXk9"
},
"latest_invoice": "in_1Ftk1YCmti5jpytUQsbtoUFn",
"livemode": false,
"metadata": {
},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": {
"id": "plan_GQbDoFK42Sxy6z",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1000,
"amount_decimal": "1000",
"billing_scheme": "per_unit",
"created": 1577319345,
"currency": "jpy",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": null,
"product": "prod_GQbDxyDwvoUaxC",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"schedule": {
"id": "sub_sched_1Ftk11Cmti5jpytUFlkdOKDt",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577319347,
"current_phase": {
"end_date": 1608941750,
"start_date": 1577319350
},
"customer": "cus_GQbDdYLUXLHE9m",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": null,
"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": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1608941750,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GQbDoFK42Sxy6z",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577319350,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1Ftk11Cmti5jpytUEuhpqnPt",
"status": "active",
"subscription": "sub_GQbEXMXD1ciXk9"
},
"start_date": 1577319350,
"status": "active",
"tax_percent": 10.0,
"trial_end": null,
"trial_start": null
}
----------------------------------------------------------------------------------------------------
Retrieve subscription schedule from invoice
----------------------------------------------------------------------------------------------------
{
"id": "sub_sched_1Ftk11Cmti5jpytUFlkdOKDt",
"object": "subscription_schedule",
"canceled_at": null,
"completed_at": null,
"created": 1577319347,
"current_phase": {
"end_date": 1608941750,
"start_date": 1577319350
},
"customer": "cus_GQbDdYLUXLHE9m",
"default_settings": {
"billing_thresholds": null,
"collection_method": "charge_automatically",
"default_payment_method": null,
"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": "pm_1Ftk10Cmti5jpytU7XgurtXJ",
"default_tax_rates": [
{
"id": "txr_1Ftk0zCmti5jpytUkYy6UaYf",
"object": "tax_rate",
"active": true,
"created": 1577319345,
"description": null,
"display_name": "Tax Rate",
"inclusive": false,
"jurisdiction": null,
"livemode": false,
"metadata": {
},
"percentage": 10.0
}
],
"end_date": 1608941750,
"invoice_settings": null,
"plans": [
{
"billing_thresholds": null,
"plan": "plan_GQbDoFK42Sxy6z",
"quantity": 1,
"tax_rates": [
]
}
],
"prorate": true,
"start_date": 1577319350,
"tax_percent": 10.0,
"trial_end": null
}
],
"released_at": null,
"released_subscription": null,
"renewal_interval": null,
"revision": "sub_sched_rev_1Ftk11Cmti5jpytUEuhpqnPt",
"status": "active",
"subscription": "sub_GQbEXMXD1ciXk9"
}
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-12-27
Discussion