diff --git a/src/types/pixCreate.ts b/src/types/pixCreate.ts index 53e1d1a..a63bfc5 100644 --- a/src/types/pixCreate.ts +++ b/src/types/pixCreate.ts @@ -14,4 +14,5 @@ export type CreateDynamicPixParams = { merchantName: string; merchantCity: string; url: string; + oneTime?: boolean; }; diff --git a/tests/creator.test.ts b/tests/creator.test.ts index ed7c283..fccf096 100644 --- a/tests/creator.test.ts +++ b/tests/creator.test.ts @@ -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, @@ -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); + }); }); diff --git a/tests/emvCodes.ts b/tests/emvCodes.ts index 4172dbf..02d5df0 100644 --- a/tests/emvCodes.ts +++ b/tests/emvCodes.ts @@ -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';