Feature(SDK-106): Add unionpay as a supported network#42
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds UnionPay as a supported card network across the React Native credit card flow and the native Apple Pay / Samsung Pay network mappings.
Changes:
- Introduces
unionpaytoCreditCardNetwork, adds UnionPay prefix detection, and surfaces a UnionPay logo in the credit card UI. - Updates card-number formatting/validation to allow up to 19 digits (UnionPay) and expands defaults/config fixtures to include
unionpay. - Extends iOS (Apple Pay) and Android (Samsung Pay) network mapping to recognize
unionpay, plus adds/updates tests.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/views/credit_card.tsx | Updates card-number input handling, max length, and renders UnionPay logo. |
| src/services/validators/credit_card_number_validator.ts | Adjusts card-number validation to account for UnionPay candidates and 19-digit ranges. |
| src/models/payment_config.ts | Adds unionpay to default supportedNetworks and updates docs. |
| src/models/credit_card_network.ts | Adds unionpay enum member. |
| src/helpers/formatters.ts | Extends formatting regex to support up to 19 digits. |
| src/helpers/credit_card_utils.ts | Adds UnionPay prefix regex + network detection; extends network-string mapping aliases. |
| src/assets/unionpay.tsx | Adds UnionPay SVG asset. |
| src/assets/index.ts | Introduces barrel exports for assets (including UnionPay). |
| src/tests/services/validators/credit_card_number_validator.test.ts | Adds UnionPay validation and supported-networks tests. |
| src/tests/services/validators/credit_card_cvc_validator.test.ts | Adds CVC validation expectations for UnionPay. |
| src/tests/services/credit_card_payment_service.test.ts | Adds UnionPay to “all networks” and validates UnionPay field set. |
| src/tests/models/payment_request.test.ts | Verifies company: 'unionpay' serialization for credit card requests. |
| src/tests/models/payment_config.test.ts | Updates default supported networks expectation to include UnionPay. |
| src/tests/helpers/formatters.test.ts | Adds formatting tests for 19-digit UnionPay numbers. |
| src/tests/helpers/credit_card_utils.test.ts | Adds UnionPay Luhn + network detection + alias mapping tests. |
| src/tests/fixtures/payment_config_fixture.ts | Adds UnionPay to supportedNetworks fixtures. |
| ios/ReactNativeApplePay/ReactNativePayments.m | Maps unionpay to PKPaymentNetworkChinaUnionPay and skips unknown mappings safely. |
| example/src/App.tsx | Updates example config to include unionpay. |
| android/src/main/java/com/moyasarsdk/samsungpay/SamsungPayButtonViewModel.kt | Maps unionpay to Samsung Pay’s ChinaUnionPay brand and lowercases inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
135
| const cardNetwork = getCreditCardNetworkFromNumber(number); | ||
| const cardNumberMaxLength = cardNetwork === CreditCardNetwork.amex ? 17 : 23; | ||
|
|
Comment on lines
189
to
+193
| onChangeText={(value) => { | ||
| const cleanNumber = value | ||
| .replace(/\s/g, '') | ||
| .replace(/[^\d٠-٩]/gi, '') | ||
| .slice(0, 16); | ||
| .slice(0, 19); |
Comment on lines
+26
to
+30
| if (isUnionPayCandidate) { | ||
| return value.length < 16 || value.length > 19 || !isValidLuhn(value); | ||
| } | ||
|
|
||
| return value.length < 15 || value.length > 19 || !isValidLuhn(value); |
Contributor
sultan-algarbi
left a comment
There was a problem hiding this comment.
Good work overall. Please address the Copilot comments, then proceed with merging and release.
sultan-algarbi
requested changes
May 20, 2026
sultan-algarbi
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://moyasar-team.atlassian.net/browse/SDK-106