Module: SolidusAfterpay::AfterpayHelper

Defined in:
app/helpers/solidus_afterpay/afterpay_helper.rb

Instance Method Summary collapse

Instance Method Details

#include_afterpay_js(test_mode: false, merchant_key: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/solidus_afterpay/afterpay_helper.rb', line 5

def include_afterpay_js(test_mode: false, merchant_key: nil)
  js_name = merchant_key ? "afterpay.js?merchant_key=#{merchant_key}" : 'afterpay-async.js'
  afterpay_js_url = if test_mode
                      "https://portal.sandbox.afterpay.com/#{js_name}"
                    else
                      "https://portal.afterpay.com/#{js_name}"
                    end

  javascript_include_tag afterpay_js_url, async: true, defer: true, onload: 'initAfterpay()'
end