Skip to content

Commit b1d3db5

Browse files
authored
feat: expose oneTime option to add the Point of Initiation Method tag to the EMV (#25)
1 parent 6279dd0 commit b1d3db5

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/types/pixCreate.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export type CreateDynamicPixParams = {
1414
merchantName: string;
1515
merchantCity: string;
1616
url: string;
17+
oneTime?: boolean;
1718
};

tests/creator.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest';
22
import { createDynamicPix, createStaticPix, hasError } from '../src';
33
import {
4+
DYNAMIC_ONE_TIME_TEST_EMV,
45
DYNAMIC_TEST_EMV,
56
DYNAMIC_TEST_NORMALIZED_NAME,
67
STATIC_TEST_EMV,
@@ -111,4 +112,18 @@ describe('EMV Code Creation', () => {
111112

112113
expect(dynamicPixFn.toBRCode()).toBe(DYNAMIC_TEST_NORMALIZED_NAME);
113114
});
115+
116+
it('should be able to create a dynamic pix with one time tag', () => {
117+
const dynamicPixFn = createDynamicPix({
118+
merchantName: 'Thales Ogliari',
119+
merchantCity: 'SÃO MIGUÉL DO O',
120+
url: 'payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e87',
121+
oneTime: true,
122+
});
123+
124+
expect(hasError(dynamicPixFn)).toBe(false);
125+
if (hasError(dynamicPixFn)) return;
126+
127+
expect(dynamicPixFn.toBRCode()).toBe(DYNAMIC_ONE_TIME_TEST_EMV);
128+
});
114129
});

tests/emvCodes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ export const DYNAMIC_TEST_EMV =
1717

1818
export const DYNAMIC_TEST_NORMALIZED_NAME =
1919
'00020126740014br.gov.bcb.pix2552payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e875204000053039865802BR5912BARBARA PELE6015SAO MIGUEL DO O62070503***63040433';
20+
21+
export const DYNAMIC_ONE_TIME_TEST_EMV =
22+
'00020101021226740014br.gov.bcb.pix2552payload.psp.com/3ec9d2f9-5f03-4e0e-820d-63a81e769e875204000053039865802BR5914THALES OGLIARI6015SAO MIGUEL DO O62070503***63042895';

0 commit comments

Comments
 (0)