Update helper messages in Stripe Connect config UI

This commit is contained in:
Rob Harrington
2017-10-16 10:34:50 +11:00
parent 9e40502876
commit 0d483882de
4 changed files with 8 additions and 11 deletions

View File

@@ -7,12 +7,12 @@ module Admin
before_filter :load_settings, only: [:edit]
def edit
return @stripe_account = { status: :empty_api_key } if Stripe.api_key.blank?
return @stripe_account = { status: :empty_api_key_error_html } if Stripe.api_key.blank?
attrs = %i[id business_name charges_enabled]
@obfuscated_secret_key = obfuscated_secret_key
@stripe_account = Stripe::Account.retrieve.to_hash.slice(*attrs).merge(status: :ok)
rescue Stripe::AuthenticationError
@stripe_account = { status: :auth_fail }
@stripe_account = { status: :auth_fail_error }
end
def update

View File

@@ -6,8 +6,6 @@
%fieldset.no-border-bottom
%legend
= t('.settings')
.alert-box.warning
= t(".stripe_beta_warning")
= form_for @settings, as: :settings, url: main_app.admin_stripe_connect_settings_path, :method => :put do |f|
.row
.twelve.columns.alpha.omega
@@ -50,4 +48,4 @@
= t(".charges_enabled_warning")
- else
.alert-box.error
= t(".#{@stripe_account[:status]}_error")
= t(".#{@stripe_account[:status]}")

View File

@@ -748,7 +748,6 @@ en:
edit:
title: "Stripe Connect"
settings: "Settings"
stripe_beta_warning: "Warning: The Stripe Connect integration is currently in beta and should not be enabled in production yet"
stripe_connect_enabled: Enable shops to accept payments using Stripe Connect?
no_api_key_msg: No Stripe account exists for this enterprise.
configuration_explanation_html: For detailed instructions on configuring the Stripe Connect integration, please <a href='https://github.com/openfoodfoundation/openfoodnetwork/wiki/Setting-up-Stripe-on-an-OFN-instance' target='_blank'>consult this guide</a>.
@@ -760,7 +759,7 @@ en:
charges_enabled: Charges Enabled
charges_enabled_warning: "Warning: Charges are not enabled for your account"
auth_fail_error: The API key you provided is invalid
empty_api_key_error: No Stripe API key has been provided. To set your API key, please follow the instructions at
empty_api_key_error_html: No Stripe API key has been provided. To set your API key, please follow <a href="https://github.com/openfoodfoundation/openfoodnetwork/wiki/Setting-up-Stripe-on-an-OFN-instance" target="_blank">these instructions</a>
# Admin controllers
controllers:

View File

@@ -26,9 +26,9 @@ describe Admin::StripeConnectSettingsController, type: :controller do
allow(Stripe).to receive(:api_key) { nil }
end
it "sets the account status to :empty_api_key" do
it "sets the account status to :empty_api_key_error_html" do
spree_get :edit
expect(assigns(:stripe_account)[:status]).to eq :empty_api_key
expect(assigns(:stripe_account)[:status]).to eq :empty_api_key_error_html
expect(assigns(:settings).stripe_connect_enabled).to be true
end
end
@@ -44,9 +44,9 @@ describe Admin::StripeConnectSettingsController, type: :controller do
to_return(:status => 401, :body => "{\"error\": {\"message\": \"Invalid API Key provided: sk_test_****xxxx\"}}")
end
it "sets the account status to :auth_fail" do
it "sets the account status to :auth_fail_error" do
spree_get :edit
expect(assigns(:stripe_account)[:status]).to eq :auth_fail
expect(assigns(:stripe_account)[:status]).to eq :auth_fail_error
expect(assigns(:settings).stripe_connect_enabled).to be true
end
end