Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Stripe subscription for SaaS service

Stripe subscription for SaaS service

JP_Stripes@Kyoto 2018/04

Hidetaka Okamoto

April 24, 2018
Tweet

More Decks by Hidetaka Okamoto

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • Digitalcube Co. Ltd. • WordCamp Kyoto 2017࣮ߦҕ һ௕

    • ྲྀ͠ͷJAWS-UGӡӦϝϯόʔ H i d e t a k a O k a m o t o
  2. ঎඼৘ใ͸ɺstripe.products.list stripe.products.list({ limit: 3 }) .then(products => console.log(products)); { object:

    'list', data: [ { id: 'prod_Cd7vkU3EO1ZidK', object: 'product', attributes: [], description: null, images: [], metadata: {}, name: 'Hello Billing', shippable: null, skus: [Object], statement_descriptor: 'Create new page', type: 'service', unit_label: ‘ϖʔδ',
  3. ঎඼ʹରԠ͢Δྉۚϓϥϯ͸ɺstripe.plans.list stripe.plans.list({ product: 'prod_Cd7vkU3EO1ZidK' }) .then(products => console.log(products)); { object:

    'list', data: [ { id: 'sample-plan-usd', object: 'plan', amount: 3000, billing_scheme: 'per_unit', created: 1523010941, currency: 'usd', interval: 'month', interval_count: 1, livemode: false, metadata: {}, nickname: 'Sample plan',
  4. “name -> nickname” & “statement_descriptor"ͷഇࢭ stripe.plans.list({ product: 'prod_Cd7vkU3EO1ZidK' }) .then(products

    => console.log(products)); { object: 'list', data: [ { id: 'sample-plan-usd', object: 'plan', amount: 3000, billing_scheme: 'per_unit', created: 1523010941, currency: 'usd', interval: 'month', interval_count: 1, livemode: false, metadata: {}, nickname: 'Sample plan',
  5. – h t t p s : / / s

    t r i p e . c o m / d o c s / s u b s c r i p t i o n s / u p g r a d i n g - d o w n g r a d i n g “If you want the customer to immediately pay the price difference when switching to a more expensive plan on the same billing cycle, you need to generate an invoice after making the switch.”
  6. – h t t p s : / / s

    t r i p e . c o m / d o c s / s u b s c r i p t i o n s / u p g r a d i n g - d o w n g r a d i n g w i t h G o o g l e ຋ ༁ “ಉ͡੥ٻαΠΫϧͰΑΓߴՁͳϓϥϯʹ੾Γସ͑Δ ͱ͖ʹɺސ٬͕͙͢ʹՁֹ֨ࠩΛࢧ෷͏Α͏ʹ͢Δʹ ͸ɺ੾Γସ͑ޙʹ੥ٻॻΛੜ੒͢Δඞཁ͕͋Γ· ͢ɻ”
  7. ଈܾ࣌ࡁͷ৔߹ͷྲྀΕ const params = { items: [{ id: subscriptionId, plan:

    planId, }] } stripe.subscriptions.update(subscriptionId, params) .then(() => { return stripe.invoices.create({ customer: customerId, subscription: subscriptionId, tax_percent: 8 }) })
  8. ଈܾ࣌ࡁͷ৔߹ͷྲྀΕ const params = { items: [{ id: subscriptionId, plan:

    planId, }] } stripe.subscriptions.update(subscriptionId, params) .then(() => { return stripe.invoices.create({ customer: customerId, subscription: subscriptionId, tax_percent: 8 }) })