Skip to content

fix: cap card number and CVV lengths by detected brand (v1.0.1) - #25

Merged
RZEROSTERN merged 2 commits into
developfrom
bugfix/card-brand-input-lengths
Nov 10, 2026
Merged

RZEROSTERN merged 2 commits into
developfrom
bugfix/card-brand-input-lengths

Conversation

@RZEROSTERN

Copy link
Copy Markdown
Contributor

Summary

Fixes two input bugs in the SDK card form (visible in the sample app's AddCardScreen) and bumps the library to 1.0.1 so the fix can be released.

Card number length

  • The form accepted up to 19 digits for every brand.
  • It now stops at 15 digits when American Express is detected (prefixes 34/37) and at 16 digits for every other brand.
  • CardBrand gains a cardNumberLength property next to securityCodeLength, and OpenpayCardFormState.updateCardNumber caps the input with it. Editing a 16-digit number so that it becomes Amex re-caps it to 15.

Security code (CVV) length

  • Typing was already capped at 4 digits for Amex and 3 otherwise, but a 4-digit code typed for an Amex card survived when the card number was changed to another brand.
  • updateCardNumber now cuts the security code to the length of the newly detected brand.
  • Validation is unchanged: Amex requires exactly 4 digits, every other brand exactly 3.

Version bump

  • VERSION_NAME (gradle.properties) and OpenpaySdk.VERSION → 1.0.1.
  • Dependency snippets in README.md and the EN/ES/FR/PT getting started guides → 1.0.1.
  • docs/*/ui-components.md (EN/ES/FR/PT) describe the new card number cap.

Not changed

  • CardValidator.isValidCardNumber still accepts 12–19 digit numbers that pass Luhn. Only the form input is capped; hosts calling the validator directly see no behavior change.
  • CardNumberVisualTransformation keeps its 19-digit grouping for hosts that use it outside the form state.

Release path

CD runs on a v* tag and checks that the tag equals VERSION_NAME:

  1. Merge this PR into develop.
  2. Open and merge the release PR develop → master.
  3. Push the tag v1.0.1 on master → CD runs tests, uploads the signed artifacts, promotes the staging repository and creates the GitHub release.
  4. Press Publish at central.sonatype.com → Publish → Deployments.

Test plan

  • ./gradlew testDebugUnitTest jacocoTestReport :openpay-sdk:jacocoCoverageVerification passes locally (80% coverage gate included)
  • New unit tests in OpenpayCardFormStateTest and CardBrandTest for the 15/16 digit caps and the CVV trim on brand change
  • New Robolectric Compose tests in OpenpayCardFormComposeTest typing over-long Visa and Amex numbers and switching brand after typing the CVV
  • CI instrumented tests on the API 34 emulator (not run locally, no device attached)

🤖 Generated with Claude Code

RZEROSTERN and others added 2 commits November 10, 2026 00:47
The card form accepted up to 19 digits for every brand. The card number is
now capped at 15 digits when American Express is detected and at 16 for
every other brand. A security code typed for a previous brand is also cut
to the new brand length (4 digits for American Express, 3 otherwise) when
the card number changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Aligns VERSION_NAME, OpenpaySdk.VERSION and the dependency snippets in the
README and the four-language getting started guides, so the v1.0.1 tag
passes the CD version guard.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Unit test coverage

Overall Project 83.54% 🍏
Files changed 100% 🍏

Module Coverage
openpay-sdk 82.51% 🍏
Files
Module File Coverage
openpay-sdk CardBrand.kt 100% 🍏
OpenpaySdk.kt 100% 🍏
OpenpayCardFormState.kt 99.16% 🍏

@RZEROSTERN
RZEROSTERN merged commit 388e8e3 into develop Nov 10, 2026
2 checks passed
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.

1 participant