Class: KsStripe::Client
- Inherits:
-
Object
- Object
- KsStripe::Client
- Defined in:
- lib/koduc_stripe.rb
Overview
Set the Stripe API key
Class Method Summary collapse
-
.configure(&block) ⇒ Object
Set the Stripe API key to a class variable.
-
.get_key_header ⇒ Object
Gives Stripe Authorization Header for Stripe API request.
-
.stripe_key ⇒ Object
Gives the Stripe API Key.
Class Method Details
.configure(&block) ⇒ Object
Set the Stripe API key to a class variable
Parameter: A block of code having Stripe API Key
Returns: None
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/koduc_stripe.rb', line 26 def configure(&block) config = OpenStruct.new block.call config # if config[:stripe_api_key].blank? # raise "No Stripe API key provided." # elsif KsStripe::Empty.empty?(config[:stripe_api_key]) if KsStripe::Empty.empty?(config[:stripe_api_key]) raise "No Stripe API key provided. Please initialize the App with valid stripe API key." end @@stripe_token = config[:stripe_api_key] end |
.get_key_header ⇒ Object
Gives Stripe Authorization Header for Stripe API request
Parameter: None
Returns: If stripe key is provided then return Stripe Authorization Header
otherwise Raise exception.
53 54 55 56 57 58 |
# File 'lib/koduc_stripe.rb', line 53 def get_key_header if KsStripe::Empty.empty?(self.stripe_key) raise "No Stripe API key provided. Please initialize the App with valid stripe API key." end @@stripe_auth_key = "Bearer #{self.stripe_key}" end |
.stripe_key ⇒ Object
Gives the Stripe API Key
Parameter: None
Returns: Stripe API Key
44 45 46 |
# File 'lib/koduc_stripe.rb', line 44 def stripe_key return @@stripe_token end |