Class: Payola::PaymentGateways::StripePaymentGateway
- Inherits:
-
Object
- Object
- Payola::PaymentGateways::StripePaymentGateway
- Defined in:
- lib/payola/payment_gateways/stripe_payment_gateway.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#interval_count ⇒ Object
Returns the value of attribute interval_count.
-
#payment_token ⇒ Object
Returns the value of attribute payment_token.
-
#plan_id ⇒ Object
Returns the value of attribute plan_id.
-
#plan_name ⇒ Object
Returns the value of attribute plan_name.
-
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
Class Method Summary collapse
Instance Method Summary collapse
- #apply_subscription ⇒ Object
-
#initialize(**args) ⇒ StripePaymentGateway
constructor
A new instance of StripePaymentGateway.
Constructor Details
#initialize(**args) ⇒ StripePaymentGateway
Returns a new instance of StripePaymentGateway.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 17 def initialize(**args) args.each do |name, value| public_send("#{name}=", value) end Stripe.api_key = api_key || Payola.config.payment_gateway_api_key combined_id = subscription_id || '' self.customer_id = combined_id[/\A(cus_[A-Za-z0-9]{14})\:/, 1] || 'no_customer' self.subscription_id = combined_id[/\:(sub_[A-Za-z0-9]{14})\z/, 1] || 'no_subscription' end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def amount @amount end |
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def api_key @api_key end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def customer_id @customer_id end |
#interval ⇒ Object
Returns the value of attribute interval.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def interval @interval end |
#interval_count ⇒ Object
Returns the value of attribute interval_count.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def interval_count @interval_count end |
#payment_token ⇒ Object
Returns the value of attribute payment_token.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def payment_token @payment_token end |
#plan_id ⇒ Object
Returns the value of attribute plan_id.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def plan_id @plan_id end |
#plan_name ⇒ Object
Returns the value of attribute plan_name.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def plan_name @plan_name end |
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
7 8 9 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 7 def subscription_id @subscription_id end |
Class Method Details
.apply_subscription(**args) ⇒ Object
41 42 43 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 41 def self.apply_subscription(**args) new(**args).apply_subscription end |
Instance Method Details
#apply_subscription ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/payola/payment_gateways/stripe_payment_gateway.rb', line 29 def apply_subscription update_subscription_plan update_subscription_payment_token { status: subscription.status, plan: subscription.plan[:id], subscription_id: "#{subscription.customer}:#{subscription.id}", last_four_of_credit_card: last_four_of_credit_card, } end |