Skip to content

feat: add funcionality for composite emv #32

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

Merged
merged 4 commits into from
May 22, 2025

Conversation

jonashger
Copy link
Collaborator

@jonashger jonashger commented May 22, 2025

What kind of change does this PR introduce?

This PR introduces a new feature: support for Composite PIX QR codes. This is a significant enhancement that adds support for a new type of PIX QR code that can handle both dynamic and recurring payment scenarios.

What is the current behavior?

Currently, the library only supports:

  • Static PIX QR codes (for one-time payments)
  • Dynamic PIX QR codes (for dynamic payment amounts)

What is the new behavior?

The library now supports:

  • Composite PIX QR codes that can handle:
    • Dynamic payments with recurring payment information
    • Static payments with recurring payment information
    • Recurring payment information only
  • New createCompositePix function to generate composite PIX QR codes
  • New fetchPayloadRec function to fetch recurring payment information
  • New type definitions and interfaces for composite PIX elements
  • Enhanced EMV code generation and parsing for composite PIX codes
  • New validation functions for composite PIX codes

Other information:

  • Added comprehensive test coverage for the new composite PIX functionality
  • Updated type definitions to support the new composite PIX structure
  • Added new EMV schema tags for handling recurring payment information
  • Enhanced the parser to handle the new composite PIX format
  • Added new test cases with example EMV codes for composite PIX scenarios

Summary by CodeRabbit

  • New Features

    • Added support for a new "composite" Pix type, allowing creation and parsing of Pix objects that combine features of static and dynamic types, including handling of multiple URLs.
    • Introduced new methods to fetch additional payloads for composite Pix types.
    • Expanded API with new functions and type guards for composite Pix handling.
  • Bug Fixes

    • Improved extraction and validation logic to correctly handle composite Pix elements and their associated fields.
  • Tests

    • Added comprehensive tests for composite Pix creation, parsing, and data extraction scenarios.
  • Documentation

    • Updated type definitions and exports to reflect new composite Pix capabilities.

@thalesog
Copy link
Owner

@coderabbitai full review

Copy link

coderabbitai bot commented May 22, 2025

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented May 22, 2025

Walkthrough

The changes introduce support for a new "COMPOSITE" Pix element type across the codebase, including type definitions, creation, parsing, validation, and EMV code generation. New methods and interfaces enable conditional payload fetching and error handling for composite Pix objects. Tests are expanded to cover composite Pix scenarios, and new exported constants and functions are added for public API and testing.

Changes

File(s) Change Summary
src/types/pixElements.ts, src/types/pixFunctions.ts, src/types/pixCreate.ts, src/types/pixDynamicPayload.ts, src/types/pixEmvSchema.ts Added "COMPOSITE" Pix type, new interfaces/types for composite Pix, updated mapped types, and extended enums and payload types.
src/create.ts, src/assembler.ts, src/emvHandler.ts, src/parser.ts, src/validate.ts Added support for composite Pix in creation, assembly, EMV generation, parsing, and validation. Introduced new methods and logic for handling composite-specific fields and control flow.
src/dynamicPayload.ts Refactored fetchPayload to a named export and added new fetchRecPayload function for composite Pix.
src/index.ts Added exports for createCompositePix and isCompositePix to the public API.
tests/creator.test.ts, tests/extractor.test.ts, tests/parser.test.ts Added and updated tests to cover composite Pix scenarios, including creation, parsing, and extraction.
tests/emvCodes.ts Added new exported constants representing composite EMV code samples for testing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant CompositePix
    participant PayloadService

    User->>API: createCompositePix(params)
    API->>CompositePix: Validate and assemble composite Pix object
    CompositePix-->>API: CompositePixObject
    User->>CompositePix: fetchPayload() or fetchRecPayload()
    CompositePix->>PayloadService: fetchPayload/fetchRecPayload (with URL)
    PayloadService-->>CompositePix: PIXFetchResults or PixError
    CompositePix-->>User: Payload data or error
Loading

Poem

🐇
A composite Pix hops in with glee,
With URLs and payloads for all to see.
Static, dynamic, and now combined,
New tests and types so well-aligned.
The code now fetches with double delight—
Rec and main, both day and night!
—Rabbit of the Repo

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10c751d and 6a29ca1.

📒 Files selected for processing (2)
  • src/dynamicPayload.ts (4 hunks)
  • src/types/pixCreate.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/types/pixCreate.ts
  • src/dynamicPayload.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/types/pixEmvSchema.ts (1)

11-12: Consider adding comments about tag purposes.

The new tags would benefit from comments explaining their purpose and relationship to composite PIX functionality, similar to how some other parts of the code have explanatory comments.

-  TAG_POSTAL_CODE = 61,
-  TAG_UNRESERVED_TEMPLATE = 80,
+  TAG_POSTAL_CODE = 61, // Postal code of the merchant
+  TAG_UNRESERVED_TEMPLATE = 80, // Contains reconciliation data for composite PIX
tests/creator.test.ts (1)

154-167: Test name doesn't match implementation.

The test name suggests it's testing composite Pix creation, but it's actually testing static Pix creation with a reconciliation URL.

Consider renaming this test to better reflect what it's testing:

-  it('should be able to create a composite pix from mandatory fields', () => {
+  it('should be able to create a static pix with reconciliation URL', () => {
src/types/pixDynamicPayload.ts (1)

79-106: Consider standardizing status handling across payload types

The PIXRecPayload type is well-structured and provides the necessary fields for recurring payment information. However, unlike PIXInstantPayload and PIXFuturePayload which have a status field of type PixDynamicStatus enum, the new type has status inside the atualizacao array as a plain string.

Consider creating an enum for the possible status values in atualizacao.status and aligning the status handling pattern with other payload types for consistency:

+export enum PixRecStatus {
+  ATIVO = 'ATIVO',
+  CONCLUIDO = 'CONCLUIDO',
+  REMOVIDO = 'REMOVIDO',
+  // Add other possible status values
+}

 export type PIXRecPayload = {
   // other fields...
   readonly atualizacao: {
-    readonly status: string;
+    readonly status: PixRecStatus;
     readonly data: string;
   }[];
 };
tests/extractor.test.ts (1)

57-57: Fix incorrect test description

The test description states it's for a dynamic PIX, but it's actually testing a composite PIX.

-  it('should be able to extract basic elements from a dynamic pix', () => {
+  it('should be able to extract basic elements from a composite pix', () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6785479 and 10c751d.

📒 Files selected for processing (16)
  • src/assembler.ts (2 hunks)
  • src/create.ts (2 hunks)
  • src/dynamicPayload.ts (3 hunks)
  • src/emvHandler.ts (3 hunks)
  • src/index.ts (1 hunks)
  • src/parser.ts (2 hunks)
  • src/types/pixCreate.ts (1 hunks)
  • src/types/pixDynamicPayload.ts (1 hunks)
  • src/types/pixElements.ts (4 hunks)
  • src/types/pixEmvSchema.ts (2 hunks)
  • src/types/pixFunctions.ts (3 hunks)
  • src/validate.ts (4 hunks)
  • tests/creator.test.ts (2 hunks)
  • tests/emvCodes.ts (1 hunks)
  • tests/extractor.test.ts (3 hunks)
  • tests/parser.test.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (8)
src/create.ts (6)
src/types/pixElements.ts (1)
  • CompositePixEmvElements (29-33)
src/assembler.ts (1)
  • generatePixObject (15-54)
src/index.ts (2)
  • createCompositePix (4-4)
  • PixError (13-13)
src/types/pixCreate.ts (1)
  • CreateCompositePixParams (22-28)
src/types/pixError.ts (1)
  • PixError (1-5)
src/utils/generateErrorObject.ts (1)
  • generateErrorObject (3-11)
tests/creator.test.ts (4)
src/index.ts (3)
  • createCompositePix (4-4)
  • hasError (8-8)
  • createStaticPix (3-3)
src/create.ts (2)
  • createCompositePix (77-96)
  • createStaticPix (31-53)
src/validate.ts (1)
  • hasError (48-52)
tests/emvCodes.ts (3)
  • COMPOSITE_DYNAMIC_UNRESERVED_EMV (30-31)
  • COMPOSITE_STATIC_UNRESERVED_EMV2 (27-28)
  • COMPOSITE_REC_ONLY (36-37)
src/assembler.ts (2)
src/utils/qrcodeGenerator.ts (1)
  • toBase64 (3-5)
src/dynamicPayload.ts (2)
  • fetchRecPayload (61-87)
  • fetchPayload (25-59)
src/validate.ts (2)
src/index.ts (1)
  • isCompositePix (11-11)
src/types/pixElements.ts (2)
  • PixObjects (68-68)
  • PixCompositeObject (74-74)
src/types/pixFunctions.ts (3)
src/dynamicPayload.ts (1)
  • PIXFetchResults (8-17)
src/types/pixError.ts (1)
  • PixError (1-5)
src/types/pixElements.ts (1)
  • PixCompositeObject (74-74)
src/dynamicPayload.ts (3)
src/types/pixError.ts (1)
  • PixError (1-5)
src/utils/generateErrorObject.ts (1)
  • generateErrorObject (3-11)
src/types/pixDynamicPayload.ts (1)
  • PIXRecPayload (79-106)
src/types/pixElements.ts (2)
src/types/helpers.ts (1)
  • ValueOf (1-1)
src/types/pixFunctions.ts (3)
  • PixStaticFn (14-17)
  • PixDynamicFn (24-29)
  • PixCompositeFn (31-37)
src/parser.ts (1)
src/validate.ts (1)
  • isPix (12-46)
🔇 Additional comments (50)
src/types/pixEmvSchema.ts (3)

11-12: Clear addition of new EMV tags.

New tags for postal code and unreserved template support the composite PIX functionality.


40-43: Good addition of TAG_UT to TagsWithSubTags.

The unreserved template tag is correctly added to the tags with subtags enum, allowing for nested structures within the unreserved template.


36-36:

❓ Verification inconclusive

Verify if making TAG_POSTAL_CODE mandatory is intentional.

Adding TAG_POSTAL_CODE to the EmvMandatory enum makes it a required field. Please confirm this is intentional, as it could potentially be a breaking change if existing code doesn't provide a postal code.


🏁 Script executed:

#!/bin/bash
# Check if there are any existing functions that create PIX codes without postal code
rg -n "createStaticPix|createDynamicPix" --type ts

Length of output: 1461


🏁 Script executed:

#!/bin/bash
# Locate the EmvMandatory enum declaration and its usages in create.ts
rg -n "enum EmvMandatory" --type ts
rg -n "EmvMandatory" -n src/create.ts

Length of output: 131


🏁 Script executed:

#!/bin/bash
# Search for references to EmvMandatory across entire repository
rg -n "EmvMandatory" -n .

# Display the beginning of src/create.ts to inspect how mandatory tags are handled
sed -n '1,200p' src/create.ts

Length of output: 4051


Confirm intentional addition of TAG_POSTAL_CODE to EmvMandatory

You’ve added
src/types/pixEmvSchema.ts:36

TAG_POSTAL_CODE = EmvSchema.TAG_POSTAL_CODE, // EL61

to the EmvMandatory enum, which now makes the postal code a required EMV field. However:

  • None of the createStaticPix, createDynamicPix, or createCompositePix functions in src/create.ts set a default postalCode.
  • Existing parser tests in tests/parser.test.ts weren’t updated to expect a postal code tag.

Please confirm this breaking change is intentional. If so, you’ll need to:

  • Populate postalCode (via defaults or required params) in all create*Pix functions.
  • Update parser and creation tests to include TAG_POSTAL_CODE.

If not, consider removing TAG_POSTAL_CODE from EmvMandatory or making it optional.

src/create.ts (2)

69-69: Good explicit initialization of urlRec field

Setting urlRec: undefined explicitly in the DynamicPixEmvElements ensures consistency with the new composite type handling and makes it clear that dynamic PIX codes don't have reconciliation URLs by default.


77-96: Implementation correctly follows established patterns

The createCompositePix function correctly follows the same structure and validation patterns as the existing PIX creation functions. It properly validates the merchant name and city with appropriate error messages and uses the same default fields as other PIX types.

The function effectively creates a composite PIX object with both the standard fields and the required urlRec parameter, which is essential for the recurring payment functionality.

src/emvHandler.ts (3)

28-31: Logical extension of conditional for composite PIX support

The updated condition correctly handles both DYNAMIC and COMPOSITE PIX types with the same MAI elements, which is appropriate since both types use the URL-based approach rather than the key-based approach of STATIC PIX.


45-51: Valid type check properly extended for composite PIX

The validation logic has been properly updated to include COMPOSITE as a valid PixElementType, ensuring that the createEmv function will process composite PIX codes correctly.


87-95: Correct implementation of unreserved template for recurring payments

The conditional block correctly adds an unreserved template with the urlRec value when present. This implementation follows the EMV QR code specification for adding custom data in unreserved templates.

The implementation uses the same pattern as the main MAI block, generating both GUI and URL tags within the unreserved template, which maintains consistency in the EMV structure.

src/parser.ts (5)

54-54: Effective detection of composite PIX codes

Using isPix(emvElements, 'composite') is a clean way to detect composite PIX elements without duplicating the detection logic, leveraging the existing validation function.


75-80: Correctly handles urlRec for static PIX types

The implementation properly extracts the urlRec from the unreserved template when dealing with static PIX types that are also composite, which enables support for static PIX codes with recurring payment information.


85-95: Proper handling of composite dynamic PIX codes

This block correctly handles the case where a dynamic PIX code also contains recurring payment information, returning a COMPOSITE type with both the url and urlRec fields.


101-101: Explicit initialization maintains consistency

Setting urlRec: undefined explicitly for dynamic PIX codes that aren't composite ensures consistent behavior and matches the initialization in the creation function.


105-114: Handles pure composite PIX type correctly

This new conditional properly handles PIX codes that only contain recurring payment information without being static or dynamic, returning a COMPOSITE type with just the urlRec field.

This covers the case where a PIX code is used solely for recurring payments without immediate transaction information.

tests/emvCodes.ts (1)

24-37: Comprehensive test cases for composite PIX functionality

The added test EMV codes provide excellent coverage for the new composite PIX functionality:

  1. Static PIX with recurring information (two variants)
  2. Dynamic PIX with recurring information
  3. Dynamic PIX specifically for recurring payments
  4. PIX with only recurring payment information

These test cases will ensure that all combinations of the composite PIX functionality can be properly tested, which is essential for maintaining reliability of the library.

src/types/pixFunctions.ts (3)

2-6: Added import for PixCompositeObject to support new composite PIX type

The import statement was expanded to include PixCompositeObject alongside the existing PixDynamicObject and PixStaticObject. This addition properly supports the new composite PIX type being introduced.


16-16: Added optional fetchRecPayload method to PixStaticFn

Adding an optional fetchRecPayload method to the PixStaticFn interface allows static PIX codes to handle reconciliation payloads when needed. This is a good extension of functionality.


31-37: New PixCompositeFn interface for composite PIX handling

The new PixCompositeFn interface properly extends PixFnDefault with appropriate methods for handling composite PIX elements. The interface correctly makes fetchPayload optional but fetchRecPayload required, reflecting that composite PIX elements always have reconciliation URLs but may not always have dynamic payment URLs.

src/validate.ts (6)

2-2: Added import for PixCompositeObject

The import statement correctly includes PixCompositeObject to support the new validation functions.


14-14: Extended test parameter to include 'composite'

The test parameter for the isPix function has been properly extended to include 'composite' as a valid option, consistent with the new PIX type being introduced.


27-30: Added detection for composite PIX elements

The code adds a check for composite PIX elements by looking for EmvMaiSchema.TAG_MAI_URL under EmvSchema.TAG_UNRESERVED_TEMPLATE. This correctly identifies composite PIX elements according to the EMV specification.


36-36: Updated 'valid' case to include composite PIX

The 'valid' case has been correctly updated to also check for composite PIX elements, ensuring that the validation logic is comprehensive.


41-42: Added 'composite' case to isPix function

The new 'composite' case correctly returns the result of the composite PIX check, maintaining consistency with the existing pattern for static and dynamic PIX elements.


72-76: Added isCompositePix type guard function

The new isCompositePix type guard function follows the same pattern as the existing isStaticPix and isDynamicPix functions, providing a consistent way to check if a PIX element is of the composite type.

src/types/pixCreate.ts (2)

11-11: Added optional urlRec to CreateStaticPixParams

Adding an optional urlRec property to CreateStaticPixParams allows static PIX codes to include reconciliation URLs when needed, which is a good extension of functionality.


22-28: Added CreateCompositePixParams type

The new CreateCompositePixParams type correctly defines the parameters needed for creating composite PIX elements. It requires the essential fields (merchantName, merchantCity, urlRec) and makes others optional (oneTime, url).

This aligns with the interface definition in pixFunctions.ts where fetchRecPayload is required but fetchPayload is optional for composite PIX elements.

src/dynamicPayload.ts (2)

3-3: Added import for PIXRecPayload

The import statement has been updated to include PIXRecPayload, which is necessary for the new fetchRecPayload function.


25-25: Changed default export to named export

The function has been changed from a default export to a named export, which is a good practice for consistency and makes imports more explicit.

src/assembler.ts (3)

1-1: Good addition of the fetchRecPayload import.

The import statement now includes the new fetchRecPayload function, which is used for retrieving reconciliation payloads. This aligns well with the new composite Pix functionality.


28-32: Well-structured extension for static Pix with reconciliation URL.

This conditional addition of the fetchRecPayload method for static Pix elements with a defined urlRec parameter is clean and follows the established pattern in the codebase.


39-47: Good implementation of composite Pix functionality.

The conditional logic for composite Pix elements is well-designed:

  • fetchPayload is conditionally added only when url exists
  • fetchRecPayload is always added as it's mandatory for composite Pix

This implementation correctly supports all three scenarios mentioned in the PR description: dynamic payments with recurring info, static payments with recurring info, and recurring-only payments.

tests/parser.test.ts (6)

2-7: Good import of the necessary components.

The imports have been properly updated to include PixCompositeObject, which is needed for the new tests.


16-23: Good import of composite test EMV constants.

The import of the composite EMV constants is appropriate for the new test cases.


38-54: Comprehensive test for parsing composite static EMV code.

This test effectively verifies that the parser can extract the expected fields from a composite static EMV code with unreserved template, including the reconciliation URL.


141-154: Good test coverage for static Pix with reconciliation URL.

This test properly validates parsing a static Pix with additional reconciliation data, checking for the correct type, fields, and urlRec value.


156-173: Good test coverage for composite dynamic Pix.

This test effectively validates that a composite Pix object with both url and urlRec is parsed correctly and has the proper COMPOSITE type.


175-190: Important edge case test for reconciliation-only Pix.

This test is crucial as it verifies the third scenario mentioned in the PR description: a composite Pix with only reconciliation data (no dynamic payment URL). It properly checks that url is undefined while urlRec is present.

tests/creator.test.ts (4)

2-7: Good import of createCompositePix function.

The imports have been properly updated to include the new createCompositePix function.


10-12: Good import of composite test EMV constants.

The import of the necessary composite EMV constants is appropriate for the new test cases.


138-152: Good test for composite Pix creation with both URLs.

This test properly validates the creation of a composite Pix with both dynamic payment URL and reconciliation URL.


169-180: Good test for reconciliation-only composite Pix.

This test properly validates the creation of a composite Pix with only a reconciliation URL, which is an important use case mentioned in the PR description.

src/types/pixElements.ts (6)

2-2: Good import of PixCompositeFn interface.

The import statement has been updated to include the PixCompositeFn interface, which is necessary for defining the PixCompositeObject type.


18-18: Good addition of COMPOSITE to PixElementType enum.

Adding the COMPOSITE type to the enum is necessary to support the new composite Pix functionality.


26-27: Explicit urlRec definition for dynamic elements.

Setting urlRec to undefined for dynamic elements makes it clear that dynamic Pix elements should not have a reconciliation URL. This is consistent with the design where composite elements should be used instead when both dynamic and reconciliation URLs are needed.


29-33: Well-designed composite element interface.

The CompositePixEmvElements interface properly defines:

  • url as optional to support reconciliation-only scenarios
  • urlRec as required, which is the defining characteristic of composite elements

This aligns with the three scenarios mentioned in the PR description.


42-42: Good addition of optional urlRec to static elements.

Making urlRec optional for static elements allows for static Pix with reconciliation information, which is one of the scenarios mentioned in the PR description.


54-54: Comprehensive type updates for composite support.

The updates to PixElement, PixElements, PixObject, and the addition of PixCompositeObject type are well-designed and consistent with the existing pattern. These changes ensure type safety throughout the application when working with composite Pix elements.

Also applies to: 56-59, 65-65, 74-74

src/index.ts (1)

1-5: Well-designed API extension for composite PIX support

The additions follow the established naming and structuring patterns of the library, making the new composite PIX functionality intuitively accessible to users familiar with the existing API. The grouped exports maintain good organization of related functionality.

Also applies to: 7-12

src/types/pixDynamicPayload.ts (1)

108-108: LGTM: Correctly updated payload union type

The PIXPayload union type has been properly extended to include the new PIXRecPayload type, making it available throughout the codebase.

tests/extractor.test.ts (2)

33-33: Good defensive testing for urlRec field

Adding explicit tests to verify that urlRec is undefined in static and dynamic PIX types helps ensure clear separation between the different PIX types and prevents potential confusion.

Also applies to: 54-54


58-77: Well-structured test for composite PIX functionality

The test case properly validates the composite PIX parsing functionality, checking both the standard fields and the new urlRec field specific to composite PIX codes. The test structure follows the established pattern in the codebase, making it easy to understand.

@thalesog thalesog merged commit 94d9587 into thalesog:master May 22, 2025
1 check passed
thalesog pushed a commit that referenced this pull request May 22, 2025
# [2.7.0](v2.6.0...v2.7.0) (2025-05-22)

### Bug Fixes

* **ci:** correct test workflow file extension ([#33](#33)) ([68bc907](68bc907))

### Features

* add funcionality for composite emv ([#32](#32)) ([94d9587](94d9587))
@thalesog
Copy link
Owner

🎉 This issue has been resolved in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants