Skip to content

Commit

Permalink
feat: expose oneTime option to add the Point of Initiation Method
Browse files Browse the repository at this point in the history
… tag to the EMV (#25)
  • Loading branch information
ghobolds authored Aug 19, 2024
1 parent 6279dd0 commit b1d3db5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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';

0 comments on commit b1d3db5

Please sign in to comment.