solidus_bolt 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/bolt_callback_urls_controller.rb +39 -0
- data/app/models/solidus_bolt/bolt_configuration.rb +2 -2
- data/app/services/solidus_bolt/merchant_configuration/get_callback_urls_service.rb +36 -0
- data/app/services/solidus_bolt/merchant_configuration/set_callback_urls_service.rb +55 -0
- data/app/views/spree/admin/bolt_callback_urls/new.html.erb +24 -0
- data/app/views/spree/admin/bolts/show.html.erb +3 -0
- data/config/routes.rb +5 -0
- data/lib/solidus_bolt/version.rb +1 -1
- data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +1 -1
- data/spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_GetCallbackUrlsService/_call/receives_the_correct_response.yml +54 -0
- data/spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_SetCallbackUrlsService/_call/receives_the_correct_response.yml +54 -0
- data/spec/models/solidus_bolt/bolt_configuration_spec.rb +10 -0
- data/spec/services/solidus_bolt/merchant_configuration/get_callback_urls_service_spec.rb +15 -0
- data/spec/services/solidus_bolt/merchant_configuration/set_callback_urls_service_spec.rb +20 -0
- data/spec/support/bolt_configuration.rb +1 -1
- data/spec/support/vcr.rb +1 -0
- metadata +14 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 85a81224dbf00b809093c50581fa790f56f6389a85753a002eff55ed149ddbff
         | 
| 4 | 
            +
              data.tar.gz: 84ee9afd0a6dd580df9d3ffcbe2550a3e957d5c43fafc209e42cd79965caf9c2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ed702363808663ef10223d943f670c2bc90b248be1f4953b9288b631b36ec9a40908d1c7d3b295bb6f5cbf27b92820845dbe49e8f51a3336a1da68372c247f18
         | 
| 7 | 
            +
              data.tar.gz: 2398a99717a2d8f76b1b20c790062b5543d0f7323d90dc55637814bbeadac6d55c3078008a0213f2c6461630dd51362316d5d1b2a2c987fe37acac41cd4e34e8
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Spree
         | 
| 4 | 
            +
              module Admin
         | 
| 5 | 
            +
                class BoltCallbackUrlsController < Spree::Admin::BaseController
         | 
| 6 | 
            +
                  def new
         | 
| 7 | 
            +
                    callback_urls = SolidusBolt::MerchantConfiguration::GetCallbackUrlsService.call
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    @oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }['url']
         | 
| 10 | 
            +
                    @oauth_redirect = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_redirect' }['url']
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def update
         | 
| 14 | 
            +
                    SolidusBolt::MerchantConfiguration::SetCallbackUrlsService.call(
         | 
| 15 | 
            +
                      oauth_logout: params[:bolt_callback_urls][:oauth_logout],
         | 
| 16 | 
            +
                      oauth_redirect: params[:bolt_callback_urls][:oauth_redirect]
         | 
| 17 | 
            +
                    )
         | 
| 18 | 
            +
                    flash[:success] = "Successfully updated callback urls."
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    redirect_to new_admin_bolt_callback_urls_path
         | 
| 21 | 
            +
                  rescue SolidusBolt::ServerError => e
         | 
| 22 | 
            +
                    flash[:error] = e.message
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    render :new
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  private
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def bolt_webhook_params
         | 
| 30 | 
            +
                    params
         | 
| 31 | 
            +
                      .require(:bolt_webhook)
         | 
| 32 | 
            +
                      .permit(
         | 
| 33 | 
            +
                        :event,
         | 
| 34 | 
            +
                        :webhook_url,
         | 
| 35 | 
            +
                      )
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -16,11 +16,11 @@ module SolidusBolt | |
| 16 16 | 
             
                validate :config_can_be_created, on: :create
         | 
| 17 17 |  | 
| 18 18 | 
             
                def merchant_public_id
         | 
| 19 | 
            -
                  publishable_key | 
| 19 | 
            +
                  publishable_key&.split('.')&.first
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 22 | 
             
                def division_public_id
         | 
| 23 | 
            -
                  publishable_key | 
| 23 | 
            +
                  publishable_key&.split('.')&.second
         | 
| 24 24 | 
             
                end
         | 
| 25 25 |  | 
| 26 26 | 
             
                def self.fetch
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module SolidusBolt
         | 
| 4 | 
            +
              module MerchantConfiguration
         | 
| 5 | 
            +
                class GetCallbackUrlsService < SolidusBolt::BaseService
         | 
| 6 | 
            +
                  attr_reader :oauth_redirect, :oauth_logout, :get_account
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def call
         | 
| 9 | 
            +
                    get_callbacks
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  private
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def get_callbacks # rubocop:disable Naming/AccessorMethodName
         | 
| 15 | 
            +
                    url = "#{api_base_url}/#{api_version}/merchant/callbacks"
         | 
| 16 | 
            +
                    handle_result(
         | 
| 17 | 
            +
                      HTTParty.get(
         | 
| 18 | 
            +
                        url, headers: headers, query: query
         | 
| 19 | 
            +
                      )
         | 
| 20 | 
            +
                    )
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def query
         | 
| 24 | 
            +
                    {
         | 
| 25 | 
            +
                      division_id: @config.division_public_id
         | 
| 26 | 
            +
                    }
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def headers
         | 
| 30 | 
            +
                    {
         | 
| 31 | 
            +
                      'Content-Type' => 'application/json',
         | 
| 32 | 
            +
                    }.merge(authentication_header)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module SolidusBolt
         | 
| 4 | 
            +
              module MerchantConfiguration
         | 
| 5 | 
            +
                class SetCallbackUrlsService < SolidusBolt::BaseService
         | 
| 6 | 
            +
                  attr_reader :oauth_redirect, :oauth_logout, :get_account
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def initialize(oauth_redirect: nil, oauth_logout: nil, get_account: nil)
         | 
| 9 | 
            +
                    @oauth_redirect = oauth_redirect
         | 
| 10 | 
            +
                    @oauth_logout = oauth_logout
         | 
| 11 | 
            +
                    @get_account = get_account
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    super
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def call
         | 
| 17 | 
            +
                    set_callbacks
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  private
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def set_callbacks
         | 
| 23 | 
            +
                    url = "#{api_base_url}/#{api_version}/merchant/callbacks"
         | 
| 24 | 
            +
                    handle_result(
         | 
| 25 | 
            +
                      HTTParty.post(
         | 
| 26 | 
            +
                        url, headers: headers, body: body.to_json
         | 
| 27 | 
            +
                      )
         | 
| 28 | 
            +
                    )
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def body
         | 
| 32 | 
            +
                    {
         | 
| 33 | 
            +
                      division_id: @config.division_public_id,
         | 
| 34 | 
            +
                      callback_urls: callback_urls
         | 
| 35 | 
            +
                    }
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def callback_urls
         | 
| 39 | 
            +
                    callback_urls = []
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                    callback_urls <<  { type: 'oauth_redirect', url: oauth_redirect } if oauth_redirect.present?
         | 
| 42 | 
            +
                    callback_urls <<  { type: 'oauth_logout', url: oauth_logout } if oauth_logout.present?
         | 
| 43 | 
            +
                    callback_urls <<  { type: 'get_account', url: get_account } if get_account.present?
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                    callback_urls
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def headers
         | 
| 49 | 
            +
                    {
         | 
| 50 | 
            +
                      'Content-Type' => 'application/json',
         | 
| 51 | 
            +
                    }.merge(authentication_header)
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            <% admin_breadcrumb(plural_resource_name(SolidusBolt::BoltConfiguration)) %>
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            <%= form_for :bolt_callback_urls, url: admin_bolt_callback_urls_path, method: :patch do |f| %>
         | 
| 4 | 
            +
              <fieldset class="form-group no-border-bottom no-border-top">
         | 
| 5 | 
            +
                <div class="row">
         | 
| 6 | 
            +
                  <div id="general_fields" class="col-9">
         | 
| 7 | 
            +
                    <div class="row">
         | 
| 8 | 
            +
                      <div class="col-12">
         | 
| 9 | 
            +
                        <%= f.label :oauth_redirect %>
         | 
| 10 | 
            +
                        <%= f.text_field :oauth_redirect, class: 'fullwidth', value: @oauth_redirect || 'https://domain.com/webhooks/bolt' %>
         | 
| 11 | 
            +
                      </div>
         | 
| 12 | 
            +
                      <div class="col-12">
         | 
| 13 | 
            +
                        <%= f.label :oauth_logout %>
         | 
| 14 | 
            +
                        <%= f.text_field :oauth_logout, class: 'fullwidth', value: @oauth_logout || 'https://domain.com/webhooks/bolt' %>
         | 
| 15 | 
            +
                      </div>
         | 
| 16 | 
            +
                    </div>
         | 
| 17 | 
            +
                    <div class="row p-2 justify-content-center">
         | 
| 18 | 
            +
                      <%= f.submit 'Update', class: 'btn btn-primary', data: { disable_with: 'Creating..' } %>
         | 
| 19 | 
            +
                      <%= link_to 'Cancel', admin_bolt_path, class: 'button' %>
         | 
| 20 | 
            +
                    </div>
         | 
| 21 | 
            +
                  </div>
         | 
| 22 | 
            +
                </div>
         | 
| 23 | 
            +
              </fieldset>
         | 
| 24 | 
            +
            <% end %>
         | 
| @@ -11,6 +11,9 @@ | |
| 11 11 | 
             
                    ) %>
         | 
| 12 12 | 
             
                </li>
         | 
| 13 13 | 
             
              <% else %>
         | 
| 14 | 
            +
                <li>
         | 
| 15 | 
            +
                  <%= link_to 'Configure Callbacks URLs', new_admin_bolt_callback_urls_path, class: 'btn btn-primary' %>
         | 
| 16 | 
            +
                </li>
         | 
| 14 17 | 
             
                <li>
         | 
| 15 18 | 
             
                  <%= link_to 'Configure Webhooks', new_admin_bolt_webhook_path, class: 'btn btn-primary' %>
         | 
| 16 19 | 
             
                </li>
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -4,8 +4,13 @@ Spree::Core::Engine.routes.draw do | |
| 4 4 | 
             
              namespace :admin do
         | 
| 5 5 | 
             
                resource :bolt, only: [:show, :edit, :update]
         | 
| 6 6 | 
             
                resource :bolt_webhook, only: [:new, :create]
         | 
| 7 | 
            +
                resource :bolt_callback_urls, only: [:new, :update]
         | 
| 7 8 | 
             
              end
         | 
| 8 9 |  | 
| 9 10 | 
             
              post '/webhooks/bolt', to: '/solidus_bolt/webhooks#update'
         | 
| 10 11 | 
             
              post '/api/accounts/bolt', to: '/solidus_bolt/accounts#create'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              devise_scope :spree_user do
         | 
| 14 | 
            +
                get '/bolt_logout', to: '/spree/user_sessions#destroy', as: 'bolt_logout'
         | 
| 15 | 
            +
              end
         | 
| 11 16 | 
             
            end
         | 
    
        data/lib/solidus_bolt/version.rb
    CHANGED
    
    
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            <% if spree_current_user %>
         | 
| 2 2 | 
             
              <li><%= link_to t('spree.my_account'), spree.account_path %></li>
         | 
| 3 | 
            -
              <li | 
| 3 | 
            +
              <li><div class="bolt-account-sso" data-logged-in="true"></div></li>
         | 
| 4 4 | 
             
            <% else %>
         | 
| 5 5 | 
             
              <li>
         | 
| 6 6 | 
             
                <div class="bolt-account-sso"></div>
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: https://api-sandbox.bolt.com/v1/merchant/callbacks?division_id=<DIVISION_PUBLIC_ID>
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: US-ASCII
         | 
| 8 | 
            +
                  string: ''
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  Content-Type:
         | 
| 11 | 
            +
                  - application/json
         | 
| 12 | 
            +
                  X-Api-Key:
         | 
| 13 | 
            +
                  - "<API_KEY>"
         | 
| 14 | 
            +
                  Accept-Encoding:
         | 
| 15 | 
            +
                  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
         | 
| 16 | 
            +
                  Accept:
         | 
| 17 | 
            +
                  - "*/*"
         | 
| 18 | 
            +
                  User-Agent:
         | 
| 19 | 
            +
                  - Ruby
         | 
| 20 | 
            +
              response:
         | 
| 21 | 
            +
                status:
         | 
| 22 | 
            +
                  code: 200
         | 
| 23 | 
            +
                  message: OK
         | 
| 24 | 
            +
                headers:
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Wed, 27 Jul 2022 18:10:11 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json; charset=UTF-8
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '157'
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  Public-Key-Pins-Report-Only:
         | 
| 34 | 
            +
                  - max-age=2592000;pin-sha256="OGAVOYhLZd3ADKYGFZOED1c5m1ObMlRv9PyIWrO4Nd0=";pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";pin-sha256="IXHYSIdST+XY22J5ivybYkntMIfjA5P6pMKX2hWG1BE=";report-uri="https://77aa1bd121ef22d50247a23390ce6cff.report-uri.io/r/default/hpkp/reportOnly"
         | 
| 35 | 
            +
                  Set-Cookie:
         | 
| 36 | 
            +
                  - trk=f47ec1df-c6f5-460c-baf3-2ff506846dd2; Path=/; Max-Age=31536000; HttpOnly;
         | 
| 37 | 
            +
                    Secure; SameSite=None
         | 
| 38 | 
            +
                  Strict-Transport-Security:
         | 
| 39 | 
            +
                  - max-age=31536000; includeSubDomains; preload
         | 
| 40 | 
            +
                  X-Bolt-Api-Version:
         | 
| 41 | 
            +
                  - '2022-01-01'
         | 
| 42 | 
            +
                  X-Bolt-Trace-Id:
         | 
| 43 | 
            +
                  - Root=1-62e17f83-46d90f8f25fd210e0420dbdb
         | 
| 44 | 
            +
                  X-Device-Id:
         | 
| 45 | 
            +
                  - cc0e49b483c9bdb9dce4a6f35b9fcfb75194e19da94e18882fac74a192a8fc71
         | 
| 46 | 
            +
                  X-Envoy-Upstream-Service-Time:
         | 
| 47 | 
            +
                  - '29'
         | 
| 48 | 
            +
                  Server:
         | 
| 49 | 
            +
                  - envoy
         | 
| 50 | 
            +
                body:
         | 
| 51 | 
            +
                  encoding: UTF-8
         | 
| 52 | 
            +
                  string: '{"callback_urls":[{"url":"http://localhost:3000/bolt_logout","type":"oauth_logout"},{"url":"http://localhost:3000/users/auth/bolt","type":"oauth_redirect"}]}'
         | 
| 53 | 
            +
              recorded_at: Wed, 27 Jul 2022 18:10:11 GMT
         | 
| 54 | 
            +
            recorded_with: VCR 6.1.0
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: post
         | 
| 5 | 
            +
                uri: https://api-sandbox.bolt.com/v1/merchant/callbacks
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: UTF-8
         | 
| 8 | 
            +
                  string: '{"division_id":"Rq4qB1QajYLn","callback_urls":[{"type":"oauth_redirect","url":"http://localhost:3000/users/auth/bolt"},{"type":"oauth_logout","url":"http://localhost:3000//user/spree_user/logout"}]}'
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  Content-Type:
         | 
| 11 | 
            +
                  - application/json
         | 
| 12 | 
            +
                  X-Api-Key:
         | 
| 13 | 
            +
                  - "<API_KEY>"
         | 
| 14 | 
            +
                  Accept-Encoding:
         | 
| 15 | 
            +
                  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
         | 
| 16 | 
            +
                  Accept:
         | 
| 17 | 
            +
                  - "*/*"
         | 
| 18 | 
            +
                  User-Agent:
         | 
| 19 | 
            +
                  - Ruby
         | 
| 20 | 
            +
              response:
         | 
| 21 | 
            +
                status:
         | 
| 22 | 
            +
                  code: 200
         | 
| 23 | 
            +
                  message: OK
         | 
| 24 | 
            +
                headers:
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Tue, 26 Jul 2022 21:17:15 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json; charset=UTF-8
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '4'
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  Public-Key-Pins-Report-Only:
         | 
| 34 | 
            +
                  - max-age=2592000;pin-sha256="OGAVOYhLZd3ADKYGFZOED1c5m1ObMlRv9PyIWrO4Nd0=";pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";pin-sha256="IXHYSIdST+XY22J5ivybYkntMIfjA5P6pMKX2hWG1BE=";report-uri="https://77aa1bd121ef22d50247a23390ce6cff.report-uri.io/r/default/hpkp/reportOnly"
         | 
| 35 | 
            +
                  Set-Cookie:
         | 
| 36 | 
            +
                  - trk=ea8f518e-f41d-4b8c-9615-161bff916a0f; Path=/; Max-Age=31536000; HttpOnly;
         | 
| 37 | 
            +
                    Secure; SameSite=None
         | 
| 38 | 
            +
                  Strict-Transport-Security:
         | 
| 39 | 
            +
                  - max-age=31536000; includeSubDomains; preload
         | 
| 40 | 
            +
                  X-Bolt-Api-Version:
         | 
| 41 | 
            +
                  - '2022-01-01'
         | 
| 42 | 
            +
                  X-Bolt-Trace-Id:
         | 
| 43 | 
            +
                  - Root=1-62e059db-307d2def557ae7d63cda1f93
         | 
| 44 | 
            +
                  X-Device-Id:
         | 
| 45 | 
            +
                  - 65fb9d676354668c7128f58217c94230e32303007b66559078fee6aefb88e8a4
         | 
| 46 | 
            +
                  X-Envoy-Upstream-Service-Time:
         | 
| 47 | 
            +
                  - '37'
         | 
| 48 | 
            +
                  Server:
         | 
| 49 | 
            +
                  - envoy
         | 
| 50 | 
            +
                body:
         | 
| 51 | 
            +
                  encoding: UTF-8
         | 
| 52 | 
            +
                  string: 'null'
         | 
| 53 | 
            +
              recorded_at: Tue, 26 Jul 2022 21:17:15 GMT
         | 
| 54 | 
            +
            recorded_with: VCR 6.1.0
         | 
| @@ -62,6 +62,11 @@ RSpec.describe SolidusBolt::BoltConfiguration, type: :model do | |
| 62 62 | 
             
                  bolt_configuration = create(:bolt_configuration, publishable_key: 'abc.def.ghi')
         | 
| 63 63 | 
             
                  expect(bolt_configuration.merchant_public_id).to eq('abc')
         | 
| 64 64 | 
             
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                it 'returns nil if publishable_key is nil' do
         | 
| 67 | 
            +
                  bolt_configuration = create(:bolt_configuration, publishable_key: nil)
         | 
| 68 | 
            +
                  expect(bolt_configuration.division_public_id).to be_nil
         | 
| 69 | 
            +
                end
         | 
| 65 70 | 
             
              end
         | 
| 66 71 |  | 
| 67 72 | 
             
              describe '#division_public_id' do
         | 
| @@ -69,6 +74,11 @@ RSpec.describe SolidusBolt::BoltConfiguration, type: :model do | |
| 69 74 | 
             
                  bolt_configuration = create(:bolt_configuration, publishable_key: 'abc.def.ghi')
         | 
| 70 75 | 
             
                  expect(bolt_configuration.division_public_id).to eq('def')
         | 
| 71 76 | 
             
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                it 'returns nil if publishable_key is nil' do
         | 
| 79 | 
            +
                  bolt_configuration = create(:bolt_configuration, publishable_key: nil)
         | 
| 80 | 
            +
                  expect(bolt_configuration.division_public_id).to be_nil
         | 
| 81 | 
            +
                end
         | 
| 72 82 | 
             
              end
         | 
| 73 83 |  | 
| 74 84 | 
             
              describe '#environment_url' do
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            RSpec.describe SolidusBolt::MerchantConfiguration::GetCallbackUrlsService, :vcr, :bolt_configuration do
         | 
| 6 | 
            +
              subject(:api) { described_class.new }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              describe '#call', vcr: true do
         | 
| 9 | 
            +
                it 'receives the correct response' do
         | 
| 10 | 
            +
                  expect(api.call).to match hash_including(
         | 
| 11 | 
            +
                    'callback_urls' => array_including(hash_including('type', 'url'))
         | 
| 12 | 
            +
                  )
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            RSpec.describe SolidusBolt::MerchantConfiguration::SetCallbackUrlsService, :vcr, :bolt_configuration do
         | 
| 6 | 
            +
              subject(:api) { described_class.new(params) }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              let(:params) {
         | 
| 9 | 
            +
                {
         | 
| 10 | 
            +
                  oauth_redirect: 'http://localhost:3000/users/auth/bolt',
         | 
| 11 | 
            +
                  oauth_logout: 'http://localhost:3000//user/spree_user/logout'
         | 
| 12 | 
            +
                }
         | 
| 13 | 
            +
              }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              describe '#call', vcr: true do
         | 
| 16 | 
            +
                it 'receives the correct response' do
         | 
| 17 | 
            +
                  expect(api.call).to be_nil
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -7,7 +7,7 @@ RSpec.configure do |config| | |
| 7 7 | 
             
                solidus_bolt_configuration.environment = 'sandbox'
         | 
| 8 8 | 
             
                solidus_bolt_configuration.api_key = ENV['BOLT_API_KEY']
         | 
| 9 9 | 
             
                solidus_bolt_configuration.signing_secret = ENV['BOLT_SIGNING_SECRET']
         | 
| 10 | 
            -
                solidus_bolt_configuration.publishable_key = ENV['BOLT_PUBLISHABLE_KEY']
         | 
| 10 | 
            +
                solidus_bolt_configuration.publishable_key = ENV['BOLT_PUBLISHABLE_KEY'] || 'abc.def.ghi'
         | 
| 11 11 |  | 
| 12 12 | 
             
                solidus_bolt_configuration.save!
         | 
| 13 13 |  | 
    
        data/spec/support/vcr.rb
    CHANGED
    
    | @@ -19,6 +19,7 @@ VCR.configure do |config| | |
| 19 19 | 
             
              end
         | 
| 20 20 |  | 
| 21 21 | 
             
              config.filter_sensitive_data('<PUBLISHABLE_KEY>') { SolidusBolt::BoltConfiguration.fetch.publishable_key }
         | 
| 22 | 
            +
              config.filter_sensitive_data('<DIVISION_PUBLIC_ID>') { SolidusBolt::BoltConfiguration.fetch.division_public_id }
         | 
| 22 23 | 
             
              config.filter_sensitive_data('<API_KEY>') { SolidusBolt::BoltConfiguration.fetch.api_key }
         | 
| 23 24 |  | 
| 24 25 | 
             
              # Let's you set default VCR record mode with VCR_RECORDE_MODE=all for re-recording
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: solidus_bolt
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - piyushswain
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire:
         | 
| 11 11 | 
             
            bindir: exe
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2022-07- | 
| 13 | 
            +
            date: 2022-07-28 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: coffee-rails
         | 
| @@ -242,6 +242,7 @@ files: | |
| 242 242 | 
             
            - app/controllers/solidus_bolt/accounts_controller.rb
         | 
| 243 243 | 
             
            - app/controllers/solidus_bolt/base_controller.rb
         | 
| 244 244 | 
             
            - app/controllers/solidus_bolt/webhooks_controller.rb
         | 
| 245 | 
            +
            - app/controllers/spree/admin/bolt_callback_urls_controller.rb
         | 
| 245 246 | 
             
            - app/controllers/spree/admin/bolt_webhooks_controller.rb
         | 
| 246 247 | 
             
            - app/controllers/spree/admin/bolts_controller.rb
         | 
| 247 248 | 
             
            - app/decorators/controllers/solidus_bolt/spree_checkout_controller/add_addresses_to_bolt.rb
         | 
| @@ -265,6 +266,8 @@ files: | |
| 265 266 | 
             
            - app/services/solidus_bolt/accounts/detail_service.rb
         | 
| 266 267 | 
             
            - app/services/solidus_bolt/accounts/detect_account_service.rb
         | 
| 267 268 | 
             
            - app/services/solidus_bolt/base_service.rb
         | 
| 269 | 
            +
            - app/services/solidus_bolt/merchant_configuration/get_callback_urls_service.rb
         | 
| 270 | 
            +
            - app/services/solidus_bolt/merchant_configuration/set_callback_urls_service.rb
         | 
| 268 271 | 
             
            - app/services/solidus_bolt/oauth/token_service.rb
         | 
| 269 272 | 
             
            - app/services/solidus_bolt/payments/capture_sync_service.rb
         | 
| 270 273 | 
             
            - app/services/solidus_bolt/payments/credit_sync_service.rb
         | 
| @@ -280,6 +283,7 @@ files: | |
| 280 283 | 
             
            - app/services/solidus_bolt/users/sync_addresses_service.rb
         | 
| 281 284 | 
             
            - app/services/solidus_bolt/users/sync_payment_sources_service.rb
         | 
| 282 285 | 
             
            - app/services/solidus_bolt/webhooks/create_service.rb
         | 
| 286 | 
            +
            - app/views/spree/admin/bolt_callback_urls/new.html.erb
         | 
| 283 287 | 
             
            - app/views/spree/admin/bolt_webhooks/new.html.erb
         | 
| 284 288 | 
             
            - app/views/spree/admin/bolts/_configuration.html.erb
         | 
| 285 289 | 
             
            - app/views/spree/admin/bolts/_form.html.erb
         | 
| @@ -341,6 +345,8 @@ files: | |
| 341 345 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetailService/_call/with_wrong_access_token/gives_an_error.yml
         | 
| 342 346 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetectAccountService/_call/receives_the_correct_response.yml
         | 
| 343 347 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetectAccountService/_call/returns_status_200.yml
         | 
| 348 | 
            +
            - spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_GetCallbackUrlsService/_call/receives_the_correct_response.yml
         | 
| 349 | 
            +
            - spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_SetCallbackUrlsService/_call/receives_the_correct_response.yml
         | 
| 344 350 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Oauth_TokenService/_call/makes_the_API_call.yml
         | 
| 345 351 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Transactions_AuthorizeService/when_repeat_payment/_call/makes_the_API_call.yml
         | 
| 346 352 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Transactions_AuthorizeService/with_auto_capture/_call/makes_the_API_call.yml
         | 
| @@ -372,6 +378,8 @@ files: | |
| 372 378 | 
             
            - spec/services/solidus_bolt/accounts/detail_service_spec.rb
         | 
| 373 379 | 
             
            - spec/services/solidus_bolt/accounts/detect_account_service_spec.rb
         | 
| 374 380 | 
             
            - spec/services/solidus_bolt/base_service_spec.rb
         | 
| 381 | 
            +
            - spec/services/solidus_bolt/merchant_configuration/get_callback_urls_service_spec.rb
         | 
| 382 | 
            +
            - spec/services/solidus_bolt/merchant_configuration/set_callback_urls_service_spec.rb
         | 
| 375 383 | 
             
            - spec/services/solidus_bolt/oauth/token_service_spec.rb
         | 
| 376 384 | 
             
            - spec/services/solidus_bolt/payments/capture_sync_service_spec.rb
         | 
| 377 385 | 
             
            - spec/services/solidus_bolt/payments/credit_sync_service_spec.rb
         | 
| @@ -435,6 +443,8 @@ test_files: | |
| 435 443 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetailService/_call/with_wrong_access_token/gives_an_error.yml
         | 
| 436 444 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetectAccountService/_call/receives_the_correct_response.yml
         | 
| 437 445 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_DetectAccountService/_call/returns_status_200.yml
         | 
| 446 | 
            +
            - spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_GetCallbackUrlsService/_call/receives_the_correct_response.yml
         | 
| 447 | 
            +
            - spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_SetCallbackUrlsService/_call/receives_the_correct_response.yml
         | 
| 438 448 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Oauth_TokenService/_call/makes_the_API_call.yml
         | 
| 439 449 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Transactions_AuthorizeService/when_repeat_payment/_call/makes_the_API_call.yml
         | 
| 440 450 | 
             
            - spec/fixtures/vcr_cassettes/SolidusBolt_Transactions_AuthorizeService/with_auto_capture/_call/makes_the_API_call.yml
         | 
| @@ -466,6 +476,8 @@ test_files: | |
| 466 476 | 
             
            - spec/services/solidus_bolt/accounts/detail_service_spec.rb
         | 
| 467 477 | 
             
            - spec/services/solidus_bolt/accounts/detect_account_service_spec.rb
         | 
| 468 478 | 
             
            - spec/services/solidus_bolt/base_service_spec.rb
         | 
| 479 | 
            +
            - spec/services/solidus_bolt/merchant_configuration/get_callback_urls_service_spec.rb
         | 
| 480 | 
            +
            - spec/services/solidus_bolt/merchant_configuration/set_callback_urls_service_spec.rb
         | 
| 469 481 | 
             
            - spec/services/solidus_bolt/oauth/token_service_spec.rb
         | 
| 470 482 | 
             
            - spec/services/solidus_bolt/payments/capture_sync_service_spec.rb
         | 
| 471 483 | 
             
            - spec/services/solidus_bolt/payments/credit_sync_service_spec.rb
         |