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

Expose oneTime option to add the Point of Initiation Method tag to the EMV #25

Merged
merged 3 commits into from
Aug 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/types/pixCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export type CreateDynamicPixParams = {
merchantName: string;
merchantCity: string;
url: string;
oneTime?: boolean;
};
15 changes: 15 additions & 0 deletions tests/creator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { createDynamicPix, createStaticPix, hasError } from '../src';
import {
DYNAMIC_ONE_TIME_TEST_EMV,
DYNAMIC_TEST_EMV,
DYNAMIC_TEST_NORMALIZED_NAME,
STATIC_TEST_EMV,
Expand Down Expand Up @@ -111,4 +112,18 @@ describe('EMV Code Creation', () => {

expect(dynamicPixFn.toBRCode()).toBe(DYNAMIC_TEST_NORMALIZED_NAME);
});

it('should be able to create a dynamic pix with one time tag', () => {
const dynamicPixFn = createDynamicPix({
merchantName: 'Thales Ogliari',
merchantCity: 'SÃO MIGUÉL DO O',
url: 'payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e87',
oneTime: true,
});

expect(hasError(dynamicPixFn)).toBe(false);
if (hasError(dynamicPixFn)) return;

expect(dynamicPixFn.toBRCode()).toBe(DYNAMIC_ONE_TIME_TEST_EMV);
});
});
3 changes: 3 additions & 0 deletions tests/emvCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ export const DYNAMIC_TEST_EMV =

export const DYNAMIC_TEST_NORMALIZED_NAME =
'00020126740014br.gov.bcb.pix2552payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e875204000053039865802BR5912BARBARA PELE6015SAO MIGUEL DO O62070503***63040433';

export const DYNAMIC_ONE_TIME_TEST_EMV =
'00020101021226740014br.gov.bcb.pix2552payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e875204000053039865802BR5914THALES OGLIARI6015SAO MIGUEL DO O62070503***63042895';