From 869c65e4d376bd3b9e8afb39ca36b90d350f811b Mon Sep 17 00:00:00 2001 From: gilv93 Date: Wed, 9 Feb 2022 11:49:03 -0700 Subject: [PATCH 1/6] added sofort integration example --- public/bank-redirect/sofort/index.html | 69 ++++++++++++++++++++++++++ public/index.html | 1 + 2 files changed, 70 insertions(+) create mode 100644 public/bank-redirect/sofort/index.html diff --git a/public/bank-redirect/sofort/index.html b/public/bank-redirect/sofort/index.html new file mode 100644 index 0000000..a3f9669 --- /dev/null +++ b/public/bank-redirect/sofort/index.html @@ -0,0 +1,69 @@ + + + + + Bank Redirect Example + + + + + + + + +

Bank Redirect

+
+
+ Payment Method Type: + +
+ +
+ Invoice UUID: + +
+ +
+ Country: + +
+ + +
+ + + + + diff --git a/public/index.html b/public/index.html index 81101ce..e326a3d 100644 --- a/public/index.html +++ b/public/index.html @@ -29,6 +29,7 @@

Examples

  • Advanced bank account
  • Apple Pay
  • Bank Redirect
  • +
  • Sofort
  • PayPal
  • Fraud detection (Recurly and Kount direct integrations)
  • Fraud detection (Braintree integration)
  • From a28ae4adbcf3beef65a5ceab3ad0521139ad2822 Mon Sep 17 00:00:00 2001 From: gilv93 Date: Wed, 9 Feb 2022 13:15:11 -0700 Subject: [PATCH 2/6] undoing accidental change --- public/bank-redirect/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/bank-redirect/index.html b/public/bank-redirect/index.html index c303163..8480d8a 100644 --- a/public/bank-redirect/index.html +++ b/public/bank-redirect/index.html @@ -34,7 +34,7 @@

    Bank Redirect

    @@ -15,6 +16,8 @@

    Bank Redirect

    Payment Method Type:
    @@ -24,7 +27,12 @@

    Bank Redirect

    -
    + + + @@ -37,13 +45,40 @@

    Bank Redirect

    recurly.configure(window.recurlyConfig.publicKey); // Create BankRedirect instance - var bankRedirect = recurly.BankRedirect(); + const bankRedirect = recurly.BankRedirect(); + + const paymentMethod = document.getElementById('payment_method_type'); + + const country = document.getElementById('country_el'); + + const bank = document.getElementById('bank_el'); + + paymentMethod.addEventListener('change', () => { + if (event.target.value === 'sofort') { + country.style.display = 'block'; + bank.style.display = 'none'; + bankRedirect.loadCountries({ + payment_method_type: document.querySelector('#payment_method_type').value + }, '#country'); + } else if (event.target.value === 'ideal') { + country.style.display = 'none'; + bank.style.display = 'block'; + bankRedirect.loadBanks({ + payment_method_type: document.querySelector('#payment_method_type').value + }, '#bank'); + } + }) // If an error occurs, log it bankRedirect.on('error', function (error) { console.error('ERROR: ', error); }); + // Listen for successful countries response + bankRedirect.on('countries', function (countries) { + console.log('COUNTRIES: ', countries); + }); + // Listen for successful banks response bankRedirect.on('banks', function (banks) { console.log('BANKS: ', banks); @@ -54,17 +89,19 @@

    Bank Redirect

    console.error('Banks ERROR: ', error); }); - // load banks on the #bank selector - bankRedirect.loadBanks({ - payment_method_type: document.querySelector('#payment_method_type').value - }, '#bank') - // Start function start() { + let payment_type = document.querySelector('#payment_method_type').value; + + let isIdeal = payment_type === 'ideal'; + + let isSofort = payment_type === 'sofort'; + const iframe = bankRedirect.start({ payment_method_type: document.querySelector('#payment_method_type').value, invoice_uuid: document.querySelector('#invoice_uuid').value, - issuer_id: document.querySelector('#bank').value + ...(isIdeal && { issuer_id: document.querySelector('#bank').value }), + ...(isSofort && { country_code: document.querySelector('#country').value }) }); } diff --git a/public/bank-redirect/sofort/index.html b/public/bank-redirect/sofort/index.html deleted file mode 100644 index a3f9669..0000000 --- a/public/bank-redirect/sofort/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Bank Redirect Example - - - - - - - - -

    Bank Redirect

    -
    -
    - Payment Method Type: - -
    - -
    - Invoice UUID: - -
    - -
    - Country: - -
    - - -
    - - - - - From 79ecddae232c359f53774f7122558bfede3e1de3 Mon Sep 17 00:00:00 2001 From: gilv93 Date: Thu, 17 Feb 2022 10:43:22 -0700 Subject: [PATCH 5/6] changed syntax --- public/bank-redirect/index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/public/bank-redirect/index.html b/public/bank-redirect/index.html index 71a20de..0a5a61d 100644 --- a/public/bank-redirect/index.html +++ b/public/bank-redirect/index.html @@ -95,14 +95,16 @@

    Bank Redirect

    let isIdeal = payment_type === 'ideal'; - let isSofort = payment_type === 'sofort'; - - const iframe = bankRedirect.start({ + const payload = { payment_method_type: document.querySelector('#payment_method_type').value, invoice_uuid: document.querySelector('#invoice_uuid').value, - ...(isIdeal && { issuer_id: document.querySelector('#bank').value }), - ...(isSofort && { country_code: document.querySelector('#country').value }) - }); + } + + const addDetails = isIdeal ? + { issuer_id: document.querySelector('#bank').value } : + { country_code: document.querySelector('#country').value }; + + const iframe = bankRedirect.start(Object.assign(payload, addDetails)); } From aa6f996dc5577f4d2c63ed5518ac7f57c22463da Mon Sep 17 00:00:00 2001 From: gilv93 Date: Wed, 23 Feb 2022 09:52:30 -0700 Subject: [PATCH 6/6] cleaned up changes --- public/bank-redirect/index.html | 1 - public/index.html | 1 - 2 files changed, 2 deletions(-) diff --git a/public/bank-redirect/index.html b/public/bank-redirect/index.html index 0a5a61d..b3edb94 100644 --- a/public/bank-redirect/index.html +++ b/public/bank-redirect/index.html @@ -5,7 +5,6 @@ Bank Redirect Example - diff --git a/public/index.html b/public/index.html index e326a3d..81101ce 100644 --- a/public/index.html +++ b/public/index.html @@ -29,7 +29,6 @@

    Examples

  • Advanced bank account
  • Apple Pay
  • Bank Redirect
  • -
  • Sofort
  • PayPal
  • Fraud detection (Recurly and Kount direct integrations)
  • Fraud detection (Braintree integration)