From 5eae1c74a8eb9af8aca91b7061f2f0c9136c9e9b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 1 Jul 2020 11:48:00 +0200 Subject: [PATCH] [bug] Unable to access the invoices section if the stripe key was not set or incorrect --- CHANGELOG.md | 1 + app/controllers/api/payments_controller.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf63a0218..0874ae740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog Fab-manager - Ability to run the upgrade without interactions +- Fix a bug: Unable to access the invoices section if no stripe key was set or incorrect ## v4.5.0 2020 June 30 diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 3c5353efe..0dcdef361 100644 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -60,10 +60,12 @@ class API::PaymentsController < API::ApiController authorize :payment key = Setting.get('stripe_secret_key') - render json: { status: false } and return unless key + render json: { status: false } and return unless key&.present? charges = Stripe::Charge.list({ limit: 1 }, { api_key: key }) render json: { status: charges.data.length.positive? } + rescue Stripe::AuthenticationError + render json: { status: false } end private