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

Stripeでよかった

nof
December 15, 2018

 Stripeでよかった

JP_Stripes (Stripe ユーザーグループ)in 岡山 キックオフ
WebPayから乗り換えた話・仮売上の例

nof

December 15, 2018
Tweet

More Decks by nof

Other Decks in Technology

Transcript

  1. StripeͰΑ͔ͬͨ
    ࣮ྫΛަ͑ͯྑ͔ͬͨ͜ͱΛ঺հ
    SonicGarden ࡔ઒խढ़

    View full-size slide

  2. ୭Ͱ͔͢
    • ޿ౡ͔Βདྷ·ͨ͠
    • ࡔ઒խढ़ ʮ͔͞΃ʯ ͱݺ͹Ε͍ͯ·͢
    • Ԭࢁͷษڧձʹͨ·ʹདྷ·͢
    • גࣜձࣾιχοΫΨʔσϯ ϓϩάϥϚ
    • Rails࢖͍ͬͯ·͢

    View full-size slide

  3. ࿩͢͜ͱ
    • Webpay ͔Β ৐Γ׵͑ͨ࿩
    • Ծച্ͷྫ
    • ࠓ೔ͷ࿩ʹͰͨ Stripe API

    View full-size slide

  4. WebPay͔Β৐Γ׵͑ͨ࿩

    View full-size slide

  5. WebPayαʔϏεऴྃ (Stripeͱͷग़ձ͍)
    • 2016/10/31 Ξφ΢ϯε
    • 2017/04/30 ՝ۚػೳఀࢭ
    • ࢒͞Εͨ࣌ؒ 6ϲ݄
    WebPayͰ՝ۚॲཧΛ࣮૷͍ͯ͠Δ
    αʔϏε͕͋ͬͨͷͰҠߦ͕ඞཁ

    View full-size slide

  6. Ҡߦઌͷબఆɿ Stripe ʹܾΊͨཧ༝
    • ࠓճҠߦ͕ඞཁʹͳͬͨαʔϏεͰ΍͍ͬͯͨ͜ͱ
    • ձඅɿఆظ՝ۚ
    • د෇ۚɿ౎౓՝ۚ
    • ޓ׵ੑ͕ߴ͍
    • Charge, Customer ౳جຊతͳΦϒδΣΫτ͸Ͳ͏΍ΒҰॹͷߏ଄
    • Χʔυձࣾͷ࠶৹ࠪෆཁ
    • ళࢠػೳ (Stripe Connect) ʹڵຯ

    View full-size slide

  7. ΍ͬͨ͜ͱ
    • ϓϩάϥϜमਖ਼
    • ςετ
    • CustomerσʔλҠ؅ɾఆظ՝ۚҾ͖ܧ͗
    • WebPay͸ΞΧ΢ϯτ͕Ұͭͩͬͨؔ܎্ɺҠ؅ͷࡍʹ͓٬͞ΜΛ
    ަ͑ͨΩϟονϘʔϧΛ
    • Ҡ؅࡞ۀ଴ͪ
    10/31 12݄ 1݄ 3݄຤
    WebPayऴྃΞφ΢ϯε
    બఆ मਖ਼ ςετ
    2݄ 3݄
    Stripe՝ۚରԠϦϦʔε CustomerσʔλҠߦ
    ఆظ՝ۚҾ͖ܧ͗

    View full-size slide

  8. ϓϩάϥϜमਖ਼ (৽نͷ՝ۚॲཧΛStripeʹ޲͚Δ)
    • charge_key ౳ɺܾࡁΛҰҙʹ͢ΔΩʔΛσʔλϕʔεʹΧϥϜ௥Ճ
    • WebPay API ࢖͍ͬͯΔͱ͜ΖΛ Stripe API ࢖͏Α͏ʹΤϯυϙΠ
    ϯτมߋ
    • WebHook ॲཧ௥Ճ ఆظ՝ۚ༻ʹStripeͱWebPayΛಉ࣌ར༻
    • Stripeಛ༗ͷॲཧ௥Ճ ఆظ՝ۚ༻ʹPlanͱ͍͏֓೦ొ৔

    View full-size slide

  9. ςετ
    • stripe-ruby-mock gem
    • mockαʔόʔͰ͸ͳ͘ɺstripe-ruby ͷAPIίʔϧ෦෼Λmock

    View full-size slide

  10. σʔλҠ؅
    • ᶃ WebPay - Stripe ސ٬৘ใɾΧʔυ৘ใҠ؅
    • WebPay - Stripe ؒͰސ٬৘ใҠ؅ (PCI DSS४ڌ͍ͯ͠ΔͨΊՄೳ)
    • StripeଆͰ৽͘͠࡞ΒΕͨCustomer৘ใΛJSONͰఏڙ͍͖ͨͩɺγεςϜͷUser৘ใͱඥ෇͚
    • ᶄ ఆظ՝ۚ༻σʔλ࡞੒
    • Plan ࡞੒
    • WebPayͷRecursionΛఀࢭɺ৽͘͠StripeଆʹSubscriptionΛ࡞Δ (trial_end ʹ͍Εͯɺ͔ͦ͜Β։
    ࢝)

    View full-size slide

  11. ײ૝
    • Stripe αϙʔτ͞Μʹ૬ஊ͠ͳ͕Β࣮ࢪͰ͖ͨ
    • ಙӬ͞ΜʹΑΖ͓͘͠఻͑Լ͍͞
    • σʔλߏ଄͸΄΅ಉͩͬͨ͡ͷͰɺॿ͔ͬͨ
    • WebPay͸ΞΧ΢ϯτ͕ҰͭͳͷͰɺҠ؅ͷࡍʹ͓٬͞ΜΛަ͑ͨ
    ΩϟονϘʔϧΛ΍Δ͜ͱʹɻStripe͸ෳ਺ΞΧ΢ϯτΛඥ෇͚ΒΕ
    ΔͷͰྑ͍
    • StripeͰΑ͔ͬͨ

    View full-size slide

  12. Ծച্ͷྫ

    View full-size slide

  13. Ծച্
    • ·ܾͩࡁ͠ͳ͍͚Ͳ༩৴࿮͚ͩ֬อ
    • ͋ͱ͔ΒܾࡁͰ͖Δ
    • τϨʔχϯάͷ༧໿γεςϜͰ࢖͍·ͨ͠

    View full-size slide

  14. • capture: false Ͱ Charge ͢Δ͚ͩ
    • ޙ೔ɺCharge.capture Ͱܾࡁ׬ྃ

    View full-size slide

  15. ߟྀ࿙Ε
    • ༩৴࿮ͷ֬อظݶ͸7೔ؒ
    • 7೔ؒΑΓઌͷ༧໿Λͱͬͯ͠·ͬͨ
    • τϨʔχϯά౰೔ʹΤϥʔɻܾࡁͰ͖ͳ͍
    • ௚઀ྉۚΛ௖͔͘ɺޙ೔ৼࠐΈ͔ɻɻɻ
    • େৎ෉ͩͬͨʂ
    • Stripe࢖͔ͬͯͨΒେৎ෉ͩͬͨʂ

    View full-size slide

  16. ͔Β͘Γ
    • Stripe Ͱސ٬৘ใΛ؅ཧͯ͘͠ΕΔ Customer Λ࡞͍ͬͯͨ
    • Customer ʹ͸ΫϨδοτΧʔυ৘ใ΋ؚ·ΕΔ
    • ৽͘͠ Charge Λ࡞ܾͬͯࡁ੒ޭ
    • StripeͰΑ͔ͬͨ
    • ॿ͔ͬͨͱಉ࣌ʹɺCustomer৘ใ͸ݫॏʹѻΘͶ͹ͱ࠶ೝࣝ
    • ޷͖ͳ͚ܾͩࡁͰ͖ͪΌ͏ʁ

    View full-size slide

  17. ࠓ೔ͷ࿩ʹग़ͨ Stripe API

    View full-size slide

  18. Customer (͓٬͞Μ)
    • ౎౓՝ۚͰ͋Ε͹࡞Βͳͯ͘΋ྑ͍͚Ͳɺ࡞ͬͯ͋Δͱ Customer Λ࣠ʹ
    ߦಈΛัଊͰ͖ͯศར
    • γεςϜͷϢʔβʔͱඥ෇͚·͢
    • ΫϨδοτΧʔυͷ৘ใͱඥ෇͍͍ͯ·͢

    View full-size slide

  19. Charge (ܾࡁ)
    • ྉۚΛઃఆͯ͠create͢Ε͹՝ۚͰ͖·͢
    • Customerͱඥ෇͚Մೳ
    • ࡞Δͱ͖ʹ࣮ച্ɺԾച্Λ੍ޚͰ͖·͢ (capture = true/false)

    View full-size slide

  20. Refund (ฦۚ)
    • ฦۚ͠·͢
    • Ծച্ʹͨ͠ChargeͷऔΓফ͠΋͜ͷAPIͰ΍Γ·͢

    View full-size slide

  21. Plan (ఆظ՝ۚͷϓϥϯ)
    • ఆظ՝ۚͷϧʔϧͰ͢
    • ྉۚ΍ɺΠϯλʔόϧ(೔ɺिɺ݄ɺ೥)ΛܾΊ·͢

    View full-size slide

  22. Subscription (ఆظॲཧ)
    • Customer͝ͱͷఆظॲཧϧʔϧ
    • PlanʹैͬͯChargeΛ࡞ͬͯ͘Ε·͢
    • ։࢝ɾऴྃΛઃఆͨ͠Γ
    • τϥΠΞϧظؒޙɺఆظॲཧ։࢝ Έ͍ͨͳ͜ͱ΋Ͱ͖·͢

    View full-size slide

  23. ଞʹ΋
    • ֤ΦϒδΣΫτʹmetadataΛೖΕ͓͚ͯ͹ɺμογϡϘʔυͰݕࡧ
    Ͱ͖ͨΓ
    • ΤϯδχΞ޲͚ʹΘ͔Γ΍͍͢υΩϡϝϯτ΍αϯϓϧ
    • ૉ੖Β͍͠ Stripe ίϛϡχςΟ
    • StripeͰΑ͔ͬͨ

    View full-size slide