Sha256: 7bca195cfabd4707620f37b0ef573751c18259ebee42411f81d0f3d1368374ae

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module SolidusNexio
  module CheckoutHelper
    def setup_nexio_own_form(payment_method, user:, order:)
      # include js script only once per request
      unless @__nexio_checkout_script
        content_for(:head) { javascript_include_tag('solidus_nexio/checkout.js') }
        @__nexio_checkout_script = true
      end

      config = {
        publicKey: payment_method.preferred_public_key,
        paths: {
          oneTimeToken: solidus_nexio.payment_method_one_time_tokens_path(payment_method),
          creditCard: solidus_nexio.payment_method_credit_cards_path(payment_method)
        },
        data: NexioData.one_time_token(user: user, order: order)
      }
      javascript_tag("window.addNexioOwnForm(#{payment_method.id}, #{config.to_json});")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_nexio-0.1.1 app/helpers/solidus_nexio/checkout_helper.rb
solidus_nexio-0.1.0 app/helpers/solidus_nexio/checkout_helper.rb