tansengming / stripe-rails

A Rails Engine for integrating with Stripe
MIT License
755 stars 123 forks source link

add support for Plan to use a constant name different from plan id #143

Closed alexagranov closed 5 years ago

alexagranov commented 5 years ago

As per new addition to Readme this allows:

" If you have to support an existing plan with a Stripe plan id that can not be used as a Ruby constant, provide the plan id as a symbol when defining the plan, but provide the name for the constant to define with constant_name:

Stripe.plan "Silver-Plan".to_sym do |plan|
  plan.constant_name = 'SILVER_PLAN'
end

Stripe::Plans::SILVER_PLAN # => will be defined
# Will map to plan :id => "Silver-Plan" on Stripe

Note - If you're planning on running rake stripe:prepare to create your subscription plans, Stripe will restrict plan ids to match this regexp (/\A[a-zA-Z0-9_\-]+\z/) when created via API but still allows creation of plan ids that don't follow this restriction when manually created on stripe.com. "

Notes:

alexagranov commented 5 years ago

@tansengming ping

tansengming commented 5 years ago

Hi @alexagranov thanks for the PR! I'll be busy for a few more days and will have a look at this later this week. Cheers.

alexagranov commented 5 years ago

hi @tansengming updated!

tansengming commented 5 years ago

Looks good, thanks again!