Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAF-26] - Add alias token Charge3DS iframe #66

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

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

on:
push:
branches:
- '**'

jobs:
build:
name: 'Run tests'
runs-on: ubuntu-latest
container: node:9.4.0
defaults:
run:
working-directory: ./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.Charge3DS.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