Skip to content

Commit

Permalink
[PAF-26] - Add alias token Charge3DS iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
jperezinv committed Apr 10, 2024
1 parent c90a8e5 commit 74d1d8b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 26 deletions.
26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
push:
branches:
- '**'

jobs:
run-tests:
name: 'Run tests'
runs-on: ubuntu-22.04x
container: circleci/node:9.4.0

timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: v1-dependencies-{{ checksum "package.json" }}
restore-keys: v1-dependencies-

- name: Install yarn
run: yarn install

- name: Run tests
run: yarn test

12 changes: 12 additions & 0 deletions vpos/checkout/javascript/src/bancard-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const ZIMPLE_IFRAME_URL = `${constants.BANCARD_URL}/checkout/zimple/new`;
const ALLOWED_STYLES_URL = `${constants.BANCARD_URL}/checkout/allowed_styles`;
const CONFIRMATION_IFRAME_URL = `${constants.BANCARD_URL}/alias_token/confirmation/new`;
const PREAUTHORIZATION_IFRAME_URL = `${constants.BANCARD_URL}/checkout/preauthorization/new`;
const CHARGE3DS_IFRAME_URL = `${constants.BANCARD_URL}/checkout/charge_3ds/new`;

const Settings = {
handler: 'default',
Expand Down Expand Up @@ -233,6 +234,17 @@ class Bancard {
};
}

get Charge3DS() {
return {
createForm: (divId, processId, options) => {
this.divId = divId;
internalMethods.createForm({
divId, processId, options, url: CHARGE3DS_IFRAME_URL,
});
},
};
}

destroy() {
const iframeContainer = window.document.getElementById(this.divId);

Expand Down
18 changes: 18 additions & 0 deletions vpos/checkout/javascript/src/specs/bancard-checkout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ describe('Bancard', () => {
.toBe('https://desa.infonet.com.py:8085/checkout/preauthorization/new?process_id=1234');
});
});

describe('Charge3DS', () => {
beforeEach(() => {
instance.Preauthorization.createForm('targetDiv', '1234');
window.location.replace = jest.fn();
});

afterEach(() => { instance.destroy(); });

test('It creates the iframe', () => {
expect(document.querySelectorAll('iframe').length).toBe(1);
});

test('Iframe points to correct URL', () => {
expect(document.querySelectorAll('iframe')[0].getAttribute('src'))
.toBe('https://desa.infonet.com.py:8085/checkout/charge_3ds/new?process_id=1234');
});
});
});

describe('When the div does not exist', () => {
Expand Down

0 comments on commit 74d1d8b

Please sign in to comment.