From 28dcf047eff3aa1d7e79a2d5bf43a874e393562c Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Wed, 23 Mar 2022 13:33:20 +0200 Subject: [PATCH] added encoder for billing request --- .gitignore | 2 +- app/services/eis_billing/base.rb | 21 ++++++++------------- config/credentials.yml.enc | 1 + 3 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 config/credentials.yml.enc diff --git a/.gitignore b/.gitignore index 1c4a85f46..08606ba47 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,6 @@ /config/deploy.rb /config/master.key /.idea - +/config/master.key # Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide. .rubocop.yml diff --git a/app/services/eis_billing/base.rb b/app/services/eis_billing/base.rb index 785dc87bb..87ac27b84 100644 --- a/app/services/eis_billing/base.rb +++ b/app/services/eis_billing/base.rb @@ -1,16 +1,7 @@ module EisBilling class Base - BASE_URL = '' - if Rails.env.staging? - BASE_URL = ENV['eis_billing_system_base_url_staging'] - else - BASE_URL = ENV['eis_billing_system_base_url_dev'] - end - - INITIATOR = 'registry' - - SECRET_WORD = ENV['secret_word'] - SECRET_ACCESS_WORD = ENV['secret_access_word'] + BASE_URL = ENV['eis_billing_system_base_url'] + INITIATOR = 'registry'.freeze def self.base_request(url:) uri = URI(url) @@ -25,11 +16,11 @@ module EisBilling end def self.generate_token - JWT.encode(payload, SECRET_WORD ) + JWT.encode(payload, billing_secret) end def self.payload - { data: SECRET_ACCESS_WORD } + { initiator: INITIATOR } end def self.headers @@ -38,5 +29,9 @@ module EisBilling 'Content-Type' => 'application/json' } end + + def self.billing_secret + Rails.application.credentials.config[:billing_secret] + end end end diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 000000000..919d8d9c1 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +bXY8qqnyzpMtyIDA74p4C1GiW+cLO7yeUXl5nwZB7yy1Lkv0XbF8juV07MCm7mBgh0BfjK9Ey2sx+QiXH/PimvhNDtgy6vSNbgb5AcQBJ6XwHlXei/DNF7Bt+r5V+ixrDU6FJZ8Y9EQyjZC9zcPiAaMhDMmA71bfiE2vO2TT1T6BZcjD5P4GKmYM7pMDgKATrwauzd6ejuYfTpSBHR51zuUEEBL1uZKSXW/i6vNAE+yuRxNOULWISA0zDPaCipnrMwjf8yWkp9L4qLIcggYpepZm6t+OyAD2XMTz/5skfQRtZ0PGDs7gzJLdAYD6ErUTU9N+n6SPhPpWu0zPFMR/A9t6AudgupmLeADGnkzUyRa4jCLzOnklV4rzAT1vM4zdVhGCgd3JXQL6zptrgHgRQN8i3BhBY2w3KXtFV1N61M6cMuuvTHMMFVI+V9sbRJ58Nok9EVbu5U/WRpuJElKq7xo1bgtY/0NOFq2K+TqZT6RBtSH5sWIdUGJJIbI6VngzfZpUNPiyg9eyShK2Wa2v1BlyLK3zYRD8F9/kNUvLCX7vgSjI/pwifokVAF51GhykhlmpfOyLmEEc011DwD+F4xjkYN1xHY8=--YBWnRjhG+BqNrfar--RcZCpjUq+MNhMOydjZWWTA== \ No newline at end of file