shoppe-stripe 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shoppe/stripe.rb CHANGED
@@ -7,19 +7,17 @@ module Shoppe
7
7
  class << self
8
8
 
9
9
  def api_key
10
- Shoppe.config['stripe']['api_key']
10
+ Shoppe.settings.stripe_api_key
11
11
  end
12
12
 
13
13
  def publishable_key
14
- Shoppe.config['stripe']['publishable_key']
14
+ Shoppe.settings.stripe_publishable_key
15
15
  end
16
16
 
17
17
  def setup
18
- # Validate the configuration file to ensure stripe has been configured.
19
- Shoppe.validate_live_config({'stripe' => ['api_key', 'publishable_key', 'currency']})
18
+ Shoppe.add_settings_group :stripe, [:stripe_api_key, :stripe_publishable_key, :stripe_currency]
20
19
 
21
20
  require 'stripe'
22
- ::Stripe.api_key = self.api_key
23
21
 
24
22
  require 'shoppe/stripe/order_extensions'
25
23
  Shoppe::Order.send :include, Shoppe::Stripe::OrderExtensions
@@ -28,7 +26,7 @@ module Shoppe
28
26
  Shoppe::Order.before_confirmation do
29
27
  if self.properties['stripe_customer_token']
30
28
  begin
31
- charge = ::Stripe::Charge.create(:customer => self.properties['stripe_customer_token'], :amount => self.total_in_pence, :currency => Shoppe.config['stripe']['currency'], :capture => false)
29
+ charge = ::Stripe::Charge.create({:customer => self.properties['stripe_customer_token'], :amount => self.total_in_pence, :currency => Shoppe.settings.stripe_currency, :capture => false}, Shoppe.settings.stripe_api_key)
32
30
  self.paid_at = Time.now
33
31
  self.payment_method = 'Stripe'
34
32
  self.payment_reference = charge.id
@@ -4,7 +4,7 @@ module Shoppe
4
4
 
5
5
  def accept_stripe_token(token)
6
6
  if token =~ /\Atok/
7
- customer = ::Stripe::Customer.create(:description => "Customer for order #{number}", :card => token)
7
+ customer = ::Stripe::Customer.create({:description => "Customer for order #{number}", :card => token}, Shoppe.settings.stripe_api_key)
8
8
  self.properties['stripe_customer_token'] = customer.id
9
9
  self.save
10
10
  elsif token =~ /\Acus/ && self.properties[:stripe_customer_token] != token
@@ -20,7 +20,7 @@ module Shoppe
20
20
  private
21
21
 
22
22
  def stripe_customer
23
- @stripe_customer ||= ::Stripe::Customer.retrieve(self.properties['stripe_customer_token'])
23
+ @stripe_customer ||= ::Stripe::Customer.retrieve(self.properties['stripe_customer_token'], Shoppe.settings.stripe_api_key)
24
24
  end
25
25
 
26
26
  def stripe_card
@@ -29,7 +29,7 @@ module Shoppe
29
29
 
30
30
  def stripe_charge
31
31
  return false unless self.paid? && self.payment_method == 'Stripe'
32
- @stripe_charge ||= ::Stripe::Charge.retrieve(self.payment_reference)
32
+ @stripe_charge ||= ::Stripe::Charge.retrieve(self.payment_reference, Shoppe.settings.stripe_api_key)
33
33
  end
34
34
 
35
35
  end
@@ -1,5 +1,5 @@
1
1
  module Shoppe
2
2
  module Stripe
3
- VERSION = '1.0.2'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoppe-stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-17 00:00:00.000000000 Z
12
+ date: 2013-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoppe