Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.58 KB

1_overview.md

File metadata and controls

56 lines (40 loc) · 1.58 KB

Using Pay with Stripe

Stripe has multiple options for payments

Prices & Plans

Stripe introduced Products & Prices to support more payment options. Previously, they had a concept called Plan that was for subscriptions. Pay supports both Price IDs and Plan IDs when subscribing.

@user.payment_processor.subscribe(plan: "price_1234")
@user.payment_processor.subscribe(plan: "plan_1234")

Multiple subscription items in a single subscription can be passed in as items:

@user.payment_processor.subscribe(
  items: [
    {price: "price_1234"},
    {price: "price_5678"}
  ]
)

See: https://stripe.com/docs/api/subscriptions/create

Promotion Codes

Promotion codes are customer-facing coupon codes that can be applied in several ways.

You can apply a promotion code on the Stripe::Customer to have it automatically apply to all Subscriptions.

@user.payment_processor.update_customer!(promotion_code: "promo_1234")

Promotion codes can also be applied directly to a subscription:

@user.payment_processor.subscribe(plan: "plan_1234", promotion_code: "promo_1234")

Stripe Checkout can also accept promotion codes by enabling the flag:

@checkout_session = current_user.payment_processor.checkout(
  mode: "payment",
  line_items: "price_1ILVZaKXBGcbgpbZQ26kgXWG",
  allow_promotion_codes: true
)

Next

See Credentials