#Stripe + Ruby - Test subscription with immediately finished by specified trial period end : and start billing
8722 단어 스트라이프
코드
require 'stripe'
Stripe.api_key = 'sk_test_xxxxxxxxxxx'
product = Stripe::Product.create(name: 'Gold plan')
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 = Stripe::Subscription::create( customer: customer.id, default_payment_method: customer_payment_method.id, items: [{ plan: plan.id }], default_tax_rates: [tax_rate], trial_end: (Time.now.to_i + 5) )
Result e.g
=> #<Stripe::Subscription:0x3fcd2c9f3128 id=sub_GQKh4eG0ZMm7JQ> JSON: {
"id": "sub_GQKh4eG0ZMm7JQ",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577257942,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"collection_method": "charge_automatically",
"created": 1577257937,
"current_period_end": 1577257942,
"current_period_start": 1577257937,
"customer": "cus_GQKbTifs2Duhwe",
"days_until_due": null,
"default_payment_method": "pm_1FtTwUCmti5jpytUxyBlAksI",
"default_source": null,
"default_tax_rates": [
{"id":"txr_1FtTwTCmti5jpytUnwwi2w3L","object":"tax_rate","active":true,"created":1577257561,"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_GQKhUmcJsQVkTh","object":"subscription_item","billing_thresholds":null,"created":1577257937,"metadata":{},"plan":{"id":"plan_GQKbfgYG7NGBrH","object":"plan","active":true,"aggregate_usage":null,"amount":1000,"amount_decimal":"1000","billing_scheme":"per_unit","created":1577257561,"currency":"jpy","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":null,"product":"prod_GQKbZMaRTjX4Wa","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":1,"subscription":"sub_GQKh4eG0ZMm7JQ","tax_rates":[]}],"has_more":false,"total_count":1,"url":"/v1/subscription_items?subscription=sub_GQKh4eG0ZMm7JQ"},
"latest_invoice": "in_1FtU2XCmti5jpytUzWEhiZLq",
"livemode": false,
"metadata": {},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": {"id":"plan_GQKbfgYG7NGBrH","object":"plan","active":true,"aggregate_usage":null,"amount":1000,"amount_decimal":"1000","billing_scheme":"per_unit","created":1577257561,"currency":"jpy","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":null,"product":"prod_GQKbZMaRTjX4Wa","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},
"quantity": 1,
"schedule": null,
"start_date": 1577257937,
"status": "trialing",
"tax_percent": 10.0,
"trial_end": 1577257942,
"trial_start": 1577257937
}
대시보드
Ref
Using trial periods on subscriptions | Stripe Billing
htps : // st 리페. 코 m / 드 cs / 병 g / su bsc p chion s / thia ls
Original by Github issue
Reference
이 문제에 관하여(#Stripe + Ruby - Test subscription with immediately finished by specified trial period end : and start billing), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/d95d28231a0f788fa6d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
require 'stripe'
Stripe.api_key = 'sk_test_xxxxxxxxxxx'
product = Stripe::Product.create(name: 'Gold plan')
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 = Stripe::Subscription::create( customer: customer.id, default_payment_method: customer_payment_method.id, items: [{ plan: plan.id }], default_tax_rates: [tax_rate], trial_end: (Time.now.to_i + 5) )
=> #<Stripe::Subscription:0x3fcd2c9f3128 id=sub_GQKh4eG0ZMm7JQ> JSON: {
"id": "sub_GQKh4eG0ZMm7JQ",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1577257942,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"collection_method": "charge_automatically",
"created": 1577257937,
"current_period_end": 1577257942,
"current_period_start": 1577257937,
"customer": "cus_GQKbTifs2Duhwe",
"days_until_due": null,
"default_payment_method": "pm_1FtTwUCmti5jpytUxyBlAksI",
"default_source": null,
"default_tax_rates": [
{"id":"txr_1FtTwTCmti5jpytUnwwi2w3L","object":"tax_rate","active":true,"created":1577257561,"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_GQKhUmcJsQVkTh","object":"subscription_item","billing_thresholds":null,"created":1577257937,"metadata":{},"plan":{"id":"plan_GQKbfgYG7NGBrH","object":"plan","active":true,"aggregate_usage":null,"amount":1000,"amount_decimal":"1000","billing_scheme":"per_unit","created":1577257561,"currency":"jpy","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":null,"product":"prod_GQKbZMaRTjX4Wa","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":1,"subscription":"sub_GQKh4eG0ZMm7JQ","tax_rates":[]}],"has_more":false,"total_count":1,"url":"/v1/subscription_items?subscription=sub_GQKh4eG0ZMm7JQ"},
"latest_invoice": "in_1FtU2XCmti5jpytUzWEhiZLq",
"livemode": false,
"metadata": {},
"next_pending_invoice_item_invoice": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"plan": {"id":"plan_GQKbfgYG7NGBrH","object":"plan","active":true,"aggregate_usage":null,"amount":1000,"amount_decimal":"1000","billing_scheme":"per_unit","created":1577257561,"currency":"jpy","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":null,"product":"prod_GQKbZMaRTjX4Wa","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},
"quantity": 1,
"schedule": null,
"start_date": 1577257937,
"status": "trialing",
"tax_percent": 10.0,
"trial_end": 1577257942,
"trial_start": 1577257937
}
대시보드
Ref
Using trial periods on subscriptions | Stripe Billing
htps : // st 리페. 코 m / 드 cs / 병 g / su bsc p chion s / thia ls
Original by Github issue
Reference
이 문제에 관하여(#Stripe + Ruby - Test subscription with immediately finished by specified trial period end : and start billing), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/d95d28231a0f788fa6d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Using trial periods on subscriptions | Stripe Billing
htps : // st 리페. 코 m / 드 cs / 병 g / su bsc p chion s / thia ls
Original by Github issue
Reference
이 문제에 관하여(#Stripe + Ruby - Test subscription with immediately finished by specified trial period end : and start billing), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/d95d28231a0f788fa6d1
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(#Stripe + Ruby - Test subscription with immediately finished by specified trial period end : and start billing), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/YumaInaura/items/d95d28231a0f788fa6d1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)