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 12, 2024
1 parent c90a8e5 commit 81489ee
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 26 deletions.
26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

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

on:
push:
branches:
- '**'

jobs:
build:
name: 'Run tests'
runs-on: ubuntu-latest
container: node:9.4.0
# defaults:
# run:
# working-directory: ./bancard-connectors/vpos/checkout/javascript

timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- run: yarn install --frozen-lockfile
- 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 81489ee

Please sign in to comment.