Add 'publishable_key' property to Stripe module (enables stubbing)

This commit is contained in:
Rob Harrington
2017-08-30 11:49:16 +10:00
parent 6690f2e9e7
commit 746c2ffef9
4 changed files with 14 additions and 3 deletions

View File

@@ -44,7 +44,7 @@
= @obfuscated_secret_key
.publishable_key
%strong= t('.instance_publishable_key') + ":"
= ENV["STRIPE_INSTANCE_PUBLISHABLE_KEY"]
= Stripe.publishable_key
- if !@stripe_account[:charges_enabled]
.alert-box.warning
= t(".charges_enabled_warning")

View File

@@ -1,6 +1,6 @@
%fieldset#payment
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{ENV['STRIPE_INSTANCE_PUBLISHABLE_KEY']}"))
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
%ng-form{"ng-controller" => "PaymentCtrl", name: "payment"}
%h5{"ng-class" => "{valid: payment.$valid, dirty: payment.$dirty || submitted}"}

View File

@@ -4,7 +4,7 @@
= inject_saved_credit_cards
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{ENV['STRIPE_INSTANCE_PUBLISHABLE_KEY']}"))
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
.row.pad-top
.small-12.columns.pad-top

View File

@@ -1,2 +1,13 @@
# Add the :publishable_key property, to allow us to access this
# property from the object, rather than calling from ENV directly.
# This is mostly useful for stubbing when testing, but also feels
# a bit cleaner than accessing keys in different ways.
module Stripe
class << self
attr_accessor :publishable_key
end
end
Stripe.api_key = ENV['STRIPE_INSTANCE_SECRET_KEY']
Stripe.publishable_key = ENV['STRIPE_INSTANCE_PUBLISHABLE_KEY']
Stripe.client_id = ENV['STRIPE_CLIENT_ID']