Skip to content

Pp 2324 support new qr code types#1182

Open
abolfazlimahdi wants to merge 17 commits into
release/qr-code-improvementsfrom
PP-2324-support-new-qr-code-types
Open

Pp 2324 support new qr code types#1182
abolfazlimahdi wants to merge 17 commits into
release/qr-code-improvementsfrom
PP-2324-support-new-qr-code-types

Conversation

@abolfazlimahdi

@abolfazlimahdi abolfazlimahdi commented Jun 22, 2026

Copy link
Copy Markdown

Pull Request Description

Adds support for five new QR/barcode payment formats — SPC, SPD, PayBySquare, UPNQR, and HUB3 — extending GiniCaptureSDK beyond the existing EPC, EPS, Bezahl, and GiniQR formats.

PP-2324

What changed and how:

  • New formats detected and parsed: QRCodesFormat enum extended with .spc, .spd, .payBySquare, .upnqr, and .hub3. Format detection in GiniQRCodeDocument uses prefix/first-line matching; parameter extraction in QRCodesExtractor implements format-specific field parsing for each.

  • PDF417 scanning enabled: Camera.swift now registers both .qr and .pdf417 metadata object types. HUB3 (Croatian payment slip) is distributed as a PDF417 barcode, not a QR code.

  • PayBySquare decoder: Slovak PayBySquare encodes payment data as base32hex + LZ77-compressed binary. A pure Swift LZMADecoder (LZMA1 stream, no Apple compression framework dependency) and a PayBySquareDecoder were added to handle the full decode pipeline.

  • Validation: GiniCaptureDocumentValidator updated with per-format validation rules. SPC, UPNQR, and HUB3 require a valid IBAN. SPD requires IBAN presence but skips strict validation (non-SEPA formats in the wild). PayBySquare validation is implied by a successful decode.

  • Unit tests: GiniQRCodeDocumentTests covers format detection, field extraction, and validation for all five new formats using fixture strings.

Notes for Reviewers

Tested on: iPhone 12 Pro, iOS 26.5

Manual checks:

  • Format detection confirmed via unit tests for SPC, SPD, PayBySquare, UPNQR, and HUB3 fixture strings
  • PayBySquare base32hex + LZMA1 decompression path tested against real-world encoded samples
  • PDF417 scanning path tested in Camera.swift — both .qr and .pdf417 are registered if the hardware supports them; no crash if .pdf417 is unavailable
  • Existing EPC, EPS, Bezahl, and GiniQR flows unaffected (only additive changes to the switch dispatch)

Unit tests added: GiniCaptureSDKTests/GiniQRCodeDocumentTests.swift — 262 lines covering all new formats

Known limitation: PayBySquare uses LZMA1 (not LZMA2); the pure Swift decoder handles the subset of LZMA1 streams produced by the PayBySquare spec. Apple's Compression framework only exposes LZMA2, which is why the custom decoder was necessary.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Capture SDK’s QR/payment-code support by recognizing and extracting parameters from additional payment code formats (including PDF417-based HUB3), and adds corresponding validation and tests.

Changes:

  • Added new supported code formats to GiniQRCodeDocument detection and QRCodesExtractor parameter extraction (SPC, SPD, Pay-by-Square, UPNQR, HUB3).
  • Updated the camera metadata output to scan both .qr and .pdf417 payloads.
  • Introduced a Pay-by-Square decoder (base32hex + LZMA) and added/extended tests for the new formats.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
CaptureSDK/GiniCaptureSDK/Tests/GiniCaptureSDKTests/GiniQRCodeDocumentTests.swift Adds Swift-Testing suites covering new formats and extraction behavior.
CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Camera/Camera.swift Enables scanning of QR + PDF417 metadata types and handles both in delegate callback.
CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Models/GiniQRCodeDocument.swift Extends QR/code format detection to include new formats and Pay-by-Square heuristic.
CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Helpers/QRCodesExtractor.swift Adds extraction logic for SPC/SPD/Pay-by-Square/UPNQR/HUB3 and extends format enum.
CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Helpers/PayBySquareDecoder.swift New decoder for Pay-by-Square payloads (base32hex + LZMA) and field parsing.
CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureDocumentValidator.swift Adds validation branches for newly supported formats.

@MozhganPeivandianSharbaf MozhganPeivandianSharbaf changed the base branch from main to release/qr-code-improvements June 23, 2026 13:03
- Add pure Swift LZMA1 decoder (LZMADecoder.swift) since
  Apple's Compression framework only supports XZ/LZMA2,
  not the raw LZMA1 format used by the bysquare spec
- Fix PayBySquare beneficiary index calculation to account
  for PaymentOptions extension fields (standing order/direct debit)
- Fix looksLikePayBySquare to avoid redundant uppercased() call
- Add official bysquare spec test vector with full decode coverage

PP-2324

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'iOS Capture SDK'

Failed conditions
2 New Critical Issues (required ≤ 0)
5 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants