
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
card-react-native
Advanced tools
Tap Card React-Native Wrapper
Before diving into the development process, it's essential to establish the prerequisites and criteria necessary for a successful build. In this step, we'll outline the specific iOS requirements, including the minimum SDK version and other important details you need to consider. Let's ensure your project is set up for success from the very beginning.
React native 0.64
In order to be able to use card scanner functionality, please make sure you added the correct permission key-value in the iOS project info.plist.
<key>NSCameraUsageDescription</key>
<string>Card SDK needs it for scanner functionality</string>
in order to accept online payments on your application, you will need to add at least the Internet permission in the manifest file.
<uses-permission android:name="android.permission.INTERNET" /> //get internet access to complete online payments
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
While you can certainly use the sandbox keys available within our sample app which you can get by following the installation process, however, we highly recommend visiting our onboarding page, there you'll have the opportunity to register your package name and acquire your essential Tap Key for activating Card-iOS integration.
We got you covered, card-react-native can be installed with all possible technologies.
npm install card-react-native
yarn add card-react-native
Then run in your terminal
cd ios
pod install
pod update
import TapCardView from ‘card-react-native’;
This integration offers two distinct options: a simple integration designed for rapid development and streamlined merchant requirements, and an advanced integration that adds extra features for a more dynamic payment integration experience.
Here, you'll discover a comprehensive table featuring the parameters applicable to the simple integration. Additionally, you'll explore the various methods for integrating the SDK, either using storyboard to create the layout and then implementing the controllers functionalities by code, or directly using code. Furthermore, you'll gain insights into card tokenization after the initial payment and learn how to receive the callback notifications.
Each parameter is linked to the reference section, which provides a more in depth explanation of it.
| Configuration | Description | Required | Type | Sample |
|---|---|---|---|---|
| operator | This is the Key that you will get after registering you bundle id. | True | String | let operator {publicKey: 'pk_test_YhUjg9PNT8oDlKJ1aE2fMRz7'} |
| scope | Defines the intention of using the Card-React-native. | True | Scope | let scope = Scope.AuthenticatedToken |
| purpose | Defines the intention of using the Token after generation. | True | String | let purpose = "Transaction" |
| order | This is the order id that you created before or amount and currency to generate a new order. It will be linked this token. | True | Order | let order: = { amount: 1, currency: TapCurrencyCode.SAR, description: '', id: '', , reference : ''} |
function MinRequirement() {
const testRef =
React.useRef<ITapCardViewInputRef>() as MutableRefObject<ITapCardViewInputRef>;
return (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}
>
<TapCardView
onSuccess={(tokenValue) => {
console.log(
'🚀 ~ file: HomeScreen.tsx:136 ~ HomeScreen ~ tokenValue:',
tokenValue
);
}}
ref={cardSdkRef}
style={{ width: '100%' }}
config={{
merchant: {
id: '',
},
order: {
amount: 1,
currency: TapCurrencyCode.SAR,
},
operator: {
publicKey: 'pk_test_YhUjg9PNT8oDlKJ1aE2fMRz7'
},
scope: Scope.AuthenticatedToken,
customer: {
nameOnCard: 'Tap Payments',
editable: true,
name: [
{
first: 'Tap',
lang: Locale.en,
middle: 'Company',
last: 'Payments',
},
],
contact: {
phone: {
number: '88888888',
countryCode: '+965',
},
email: 'tappayments@tap.company',
},
},
}}
onInvalidInput={(invalidInput: boolean) => {
console.log(
'🚀 ~ file: HomeScreen.tsx:145 ~ HomeScreen ~ invalidInput:',
invalidInput
);
}}
/>
</View>
);
}
📘
A token is like a secret code that stands in for sensitive info, like credit card data. Instead of keeping the actual card info, we use this code. Tokens are hard for anyone to understand if they try to peek, making it a safer way to handle sensitive stuff.
const cardSdkRef =
React.useRef<ITapCardViewInputRef>() as MutableRefObject<ITapCardViewInputRef>;
cardSdkRef.current.generateToken();
The advanced configuration for the Card-iOS integration not only has all the features available in the simple integration but also introduces new capabilities, providing merchants with maximum flexibility. You can find a code below, where you'll discover comprehensive guidance on implementing the advanced flow as well as a complete description of each parameter.
Each parameter is linked to the reference section, which provides a more in depth explanation of it.
| Configuration | Description | Required | Type | Sample |
|---|---|---|---|---|
| operator | This is the Key that you will get after registering you bundle id. | True | String | let operator {publicKey: 'pk_test_YhUjg9PNT8oDlKJ1aE2fMRz7'} |
| scope | Defines the intention of using the Card-React-native. | True | Scope | let scope = Scope.AuthenticatedToken |
| purpose | Defines the intention of using the Token after generation. | True | String | let purpose = "Transaction" |
| order | This is the order id that you created before or amount and currency to generate a new order. It will be linked this token. | True | Order | let order: = { amount: 1, currency: TapCurrencyCode.SAR, description: '', id: '', , reference : ''} |
| invoice | This is the invoice id that you want to link this token to if any. | False | Invoice | let invoice = {"id":""} |
| merchant | This is the Merchant id that you will get after registering you bundle id. | True | Merchant | let merchant = {"id":""} |
| customer | The customer details you want to attach to this tokenization process. | True | Customer | let customer = {"id":"", "name":{{"lang":"en","first":"TAP","middle":"","last":"PAYMENTS"}}, "nameOnCard":"TAP PAYMENTS", "editble":true, "contact":{"email":"tap@tap.company", "phone":{"countryCode":"+965","number":"88888888"}}} |
| features | Some extra features that you can enable/disable based on the experience you want to provide.. | False | Features | let features = {"alternativeCardInputs":{ "cardScanner":true,"cardNFC":false}, "acceptanceBadge":true, "customerCards":{"saveCard":false, "autoSaveCard":false} |
| acceptance | The acceptance details for the transaction. Including, which card brands and types you want to allow for the customer to tokenize/save. | False | Acceptance | let acceptance = {"supportedSchemes":{ SupportedBrands.AMEX, SupportedBrands.MASTERCARD, SupportedBrands.VISA, SupportedBrands.MADA,}, "supportedFundSource":{"CREDIT","DEBIT"}, "supportedPaymentAuthentications":["3DS"]} |
| fields | Needed to define visibility of the optional fields in the card form. | False | fieldVisibility | let fieldVisibility ={ "card":{"cardHolder":true}} |
| interface | Needed to defines look and feel related configurations. | False | Interface | let interface = {locale: Locale.en, theme: Theme.dark, edges: Edges.curved, cardDirection: Direction.ltr, colorStyle: 'monochrome', powered: true, "loader": true} |
| post | This is the webhook for your server, if you want us to update you server to server. | False | Post | let post = {"url":""} |
const config = React.useMemo(() => {
return {
merchant: {
id: '',
},
order: {
reference: '',
amount: 1,
currency: TapCurrencyCode.SAR,
description: '',
id: '',
metadata: {},
},
invoice: {
id: 'Map to authenticate.reference.invoice',
},
post: {
url: 'Map to authenticate.reference.post',
},
purpose: Purpose.BillingTransaction,
operator: {
publicKey: 'pk_test_YhUjg9PNT8oDlKJ1aE2fMRz7'
},
scope: Scope.AuthenticatedToken,
customer: {
nameOnCard: 'Tap Payments',
editable: true,
id: '',
name: [
{
first: 'Tap',
lang: Locale.en,
middle: 'Company',
last: 'Payments',
},
],
contact: {
phone: {
number: '88888888',
countryCode: '+965',
},
email: 'tappayments@tap.company',
},
},
acceptance: {
supportedSchemes: [
SupportedSchemes.AMEX,
SupportedSchemes.MASTERCARD,
SupportedSchemes.VISA,
SupportedSchemes.MADA,
],
supportedFundSource: [
SupportedFundSource.Debit,
SupportedFundSource.Credit,
],
supportedPaymentAuthentications: [
SupportedPaymentAuthentications.secured,
],
},
fieldsVisibility: {
card: { cardHolder: true, cvv: true },
},
interface: {
loader: true,
locale: Locale.en,
theme: Theme.dark,
edges: Edges.curved,
cardDirection: Direction.ltr,
colorStyle: ColorStyle.colored,
powered: true,
},
features: {
alternativeCardInputs: {
cardNFC: true,
cardScanner: true,
},
customerCards: {
saveCard: true,
autoSaveCard: true,
},
acceptanceBadge: true,
},
};
}, []);
<View
// eslint-disable-next-line react-native/no-inline-styles
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}
>
<TapCardView
onSuccess={(tokenValue) => {}}
ref={cardSdkRef}
style={{ width: '100%' }}
config={config}
onHeightChange={() => {}}
onReady={() => {}}
onFocus={() => {}}
onBinIdentification={(binIdentification: Object) => {}}
onInvalidInput={(invalidInput: boolean) => {}}
onError={(error: object) => {}}
/>
</View>
callbacks that allows integrators to get notified from events fired from the TapCardView.
{
/// Will be fired whenever the card is rendered and loaded
onReady={() => {}}
/// Will be fired once the user focuses any of the card fields
onFocus={() => {}}
/// Will be fired once we detect the brand and related issuer data for the entered card data
/** - Parameter data: will include the data in JSON format. example :
*{
"bin": "424242",
"bank": "",
"card_brand": "VISA",
"card_type": "CREDIT",
"card_category": "",
"card_scheme": "VISA",
"country": "GB",
"address_required": false,
"api_version": "V2",
"issuer_id": "bnk_TS02A5720231337s3YN0809429",
"brand": "VISA"
}* */
onBinIdentification={(binIdentification: Object) => {}}
/// Will be fired whenever the validity of the card data changes.
/// - Parameter invalid: Will be true if the card data is invalid and false otherwise.
onInvalidInput={(invalidInput: boolean) => {}}
/**
Will be fired whenever the card sdk finishes successfully the task assigned to it. Whether `TapToken` or `AuthenticatedToken`
- Parameter data: will include the data in JSON format. For `TapToken`:
{
"id": "tok_MrL97231045SOom8cF8G939",
"created": 1694169907939,
"object": "token",
"live_mode": false,
"type": "CARD",
"source": "CARD-ENCRYPTED",
"used": false,
"card": {
"id": "card_d9Vj7231045akVT80B8n944",
"object": "card",
"address": {},
"funding": "CREDIT",
"fingerprint": "gRkNTnMrJPtVYkFDVU485Gc%2FQtEo%2BsV44sfBLiSPM1w%3D",
"brand": "VISA",
"scheme": "VISA",
"category": "",
"exp_month": 4,
"exp_year": 24,
"last_four": "4242",
"first_six": "424242",
"name": "AHMED",
"issuer": {
"bank": "",
"country": "GB",
"id": "bnk_TS07A0720231345Qx1e0809820"
}
},
"url": ""
}
*/
onSuccess={(tokenValue) => {}}
/// Will be fired whenever there is an error related to the card connectivity or apis
/// - Parameter data: includes a JSON format for the error description and error
onError={(error: object) => {}}
/// Will be fired whenever the card element changes its height for your convience
/// - Parameter height: The new needed height
onHeightChange={(height) => {}}
}
Below you will find more details about each parameter shared in the above tables that will help you easily integrate Card-iOS SDK.
let operator = {publicKey:"pk_test_YhUjg9PNT8oDlKJ1aE2fMRz7"}
Example: let scope:String = "Token"
AuthenticatedToken
Definition: This is a token created and authenticated by the customer. Which means that the customer entered the card information and also passed the Authentication step (3DS) and got the token after.
Example: let scope:String = "AuthenticatedToken"
SaveToken
Definition: This is used in case you want to have the card information saved in a token, however you want the customer to go through the authentication step (receive OTP or PIN) each time the card is used.
Example: let scope:String = "SaveToken"
SaveAuthenticatedToken
Definition: This means you will get an authenticated token to use in multiple times right away.
Example: let scope:String = "SaveAuthenticatedToken"
Transaction:
Definition: In case the token will be used only for a single charge request.
Example: const purpose:String = "Transaction"
Milestone Transaction:
Definition: Using the token for paying a part of a bigger order, when reaching a certain milestone.
Example:const purpose = "Milestone Transaction"
Instalment Transaction:
Definition: Using the token for a charge that is a part of an instalment plan.
Example:const purpose = "Instalment Transaction"
Billing Transaction:
Definition: Using the token for paying a bill.
Example:const purpose = "Billing Transaction"
Subscription Transaction:
Definition: Using the token for a recurring based transaction.
Example:const purpose = "Subscription Transaction"
Verify Cardholder:
Definition: Using the token to verify the ownership of the card, in other words, making sure of the identity of the cardholder.
Example:const purpose = "Verify Cardholder*"
Save Card:
Definition: Using the token to save this card and link it to the customer itself.
Example:const purpose = "Save Card"
Maintain Card:
Definition: Used to renew a saved card.
Example:const purpose = "Maintain Card"
let order = {
reference: '',
amount: 1,
currency: TapCurrencyCode.SAR,
description: '',
id: '',
metadata: {},
}
merchant
let merchant = {id:""}
let invoice = {id:""}
Definition: Here, you will collect the information of the customer that is paying using the token generate in the SDK.
Type: Dictionary (required)
Fields:
id
Definition: This is an optional field that you do not have before the token is generated. But, after the token is created once the card details are added, then you will receive the customer ID in the response which can be handled in the onSuccess callback function.
name
Definition: Full Name of the customer paying.
Fields:
editable
Definition: The customer's name on the card he is paying with, also known as cardholder name.
Note: It is of type Boolean, and indicated whether or not the customer can edit the cardholder name already entered when the token got created.
contact
Definition: The customer's contact information like email address and phone number.
Note: The contact information has to either have the email address or the phone details of the customers or both but it should not be empty.
Fields:
nameOnCard
Definition: Pre-fill the cardholder name already received once the payment form is submitted.
Example:
let customer = {
nameOnCard: 'Tap Payments',
editable: true,
id: '',
name: [
{
first: 'Tap',
lang: Locale.en,
middle: 'Company',
last: 'Payments',
},
],
contact: {
phone: {
number: '88888888',
countryCode: '+965',
},
email: 'tappayments@tap.company',
},
}
Definition: Additional functionalities to be added in order to make the payment gateway experience more customisable for your needs, like showing the accepted card brands on the payment form, save card toggle button...
Type: Dictionary (optional)
Fields:
acceptanceBadge
Definition: A boolean to indicate wether or not you want to display the list of supported card brands that appear beneath the card form itself.
customerCards
Definition: You will have the option to display either the toggle button that allows to save the card or the autosave card.
Fields:
alternativeCardInput
Definition: You can also, either add the card information by scanning the card or by using NFC.
Note: In order for that to work, you will need to add the Camera usage description to your info.plist file like so
Fields:
let features = {
alternativeCardInputs: {
cardNFC: true,
cardScanner: true,
},
customerCards: {
saveCard: true,
autoSaveCard: true,
},
acceptanceBadge: true,
}
supportedSchemes
Definition: A list to control which card schemes the customer can pay with, note that he can choose more than one card scheme.
Possible Values:
supportedFundSource
Definition: A list to control which card types are allowed by your customer.
Possible Values:
supportedPaymentAuthentications
Definition: A list of what authentication techniques you want to enforce like 3DS authentication
Possible Values:
let acceptance = acceptance: {
supportedSchemes: [
SupportedSchemes.AMEX,
SupportedSchemes.MASTERCARD,
SupportedSchemes.VISA,
SupportedSchemes.MADA,
],
supportedFundSource: [
SupportedFundSource.Debit,
SupportedFundSource.Credit,
],
supportedPaymentAuthentications: [
SupportedPaymentAuthentications.secured,
],
}
let fieldVisibility = {
card: {
cardHolder: true,
cvv: true
},
}
loader
Definition: A boolean to indicate wether or not you want to show a loading view on top of the card form while it is performing api requests.
locale
Definition: The language of the card form. Accepted values as of now are:
Possible Values:
theme
Definition: The display styling of the card form. Accepted values as of now are:
Options:
edges
Definition: Control the edges of the payment form.
Possible Values:
cardDirection
Definition: The layout of the fields (card logo, number, date & CVV) within the card element itself.
Possible Values:
powered
Definition: A boolean to indicate wether or not you want to show powered by tap.
Note, that you have to have the permission to hide it from the integration team. Otherwise, you will get an error if you pass it as false.
colorStyle
Definition: How do you want the icons rendered inside the card form.
Possible Values:
let interface = interface: {
loader: true,
locale: Locale.en,
theme: Theme.dark,
edges: Edges.curved,
cardDirection: Direction.ltr,
colorStyle: ColorStyle.colored,
powered: true,
},
Definition: Here you can pass the webhook URL you have, in order to receive notifications of the results of each Transaction happening on your application.
Type: Post (optional)
Fields:
let post:Post = {"url":""}
{
"bin": "557607",
"bank": "COMMERCIAL INTERNATIONAL BANK (EGYPT) S.A.E.",
"card_brand": "MASTERCARD",
"card_type": "DEBIT",
"card_category": "PLATINUM",
"card_scheme": "MASTERCARD",
"country": "EG",
"address_required": false,
"api_version": "V2",
"issuer_id": "bnk_TS02A1320232208a5O41810531",
"brand": "MASTERCARD"
}
The response here will differ based on the scope:
{
"id": "tok_4WUP3423199C4Vp18rY9y554",
"created": 1697656174554,
"object": "token",
"live_mode": false,
"type": "CARD",
"purpose": "Transaction",
"source": "CARD-ENCRYPTED",
"used": false,
"card": {
"id": "card_U8Wb34231992m7q185g9i558",
"object": "card",
"address": {},
"funding": "CREDIT",
"fingerprint": "gRkNTnMrJPtVYkFDVU485JtGPdhzQr%2FnmHGhlzLBvuc%3D",
"brand": "VISA",
"scheme": "VISA",
"category": "",
"exp_month": 2,
"exp_year": 44,
"last_four": "4242",
"first_six": "424242",
"first_eight": "42424242",
"name": "AHMED",
"issuer": {
"bank": "",
"country": "GB",
"id": "bnk_TS05A3420232209Kp2j1810445"
}
},
"save_card": false,
"url": ""
}
{
"id": "auth_payer_MhIp23231913vYjl18nx94755",
"object": "Authenticate",
"live_mode": false,
"api_version": "V2",
"status": "AUTHENTICATED",
"created": "1697656409282",
"amount": 1,
"currency": "KWD",
"save_card": false,
"provider": {
"name": "MPGS"
},
"transaction": {
"timezone": "UTCZ",
"created": "1697656409282"
},
"response": {
"code": "000",
"message": "Authentication Successful"
},
"reference": {
"transaction": "tck_LV02G1720231634Xj51824647",
"order": "ord_Tlh924231913OouS18vd9O487"
},
"customer": {
"id": "",
"name": [
{
"first_name": "test",
"middle_name": "test",
"last_name": "test",
"locale": "en"
}
],
"name_on_card": "Ahmed",
"email": "test@tap.com",
"phone": {
"country_code": "+20",
"number": "1099137777"
}
},
"source": {
"id": "tok_RCiU23231913dWqQ18WV9Q18"
},
"merchant": {
"id": "1124340"
},
"card": {
"first_six": "424242",
"scheme": "VISA",
"brand": "VISA",
"category": "",
"last_four": "4242",
"name": "AHMED",
"expiry": {
"month": "02",
"year": "44"
},
"funding": "CREDIT"
},
"authentication": {
"acsEci": "02",
"card_enrolled": "Y",
"authenticationToken": "jHyn+7YFi1EUAREAAAAvNUe6Hv8=",
"transactionId": "h3q0bQzZNyBueA//+57RcpfPo6s=",
"version": "3DS1",
"channel": "PAYER_BROWSER",
"purpose": "Transaction",
"url": "https://authenticate.alpha.tap.company/redirect/auth_payer_MhIp23231913vYjl18nx94755",
"transStatus": "Y",
"mode": "C"
},
"redirect": {
"url": ""
}
}
If the user didn't enable the save token switch, it will be as the previous scope. Otherwise it will be:
{
"id": "auth_payer_yhFr59231914mJvN18c79665",
"object": "Authenticate",
"live_mode": false,
"api_version": "V2",
"status": "AUTHENTICATED",
"created": "1697656504329",
"amount": 1,
"currency": "KWD",
"save_card": true,
"provider": {
"name": "MPGS"
},
"transaction": {
"timezone": "UTCZ",
"created": "1697656504329"
},
"response": {
"code": "000",
"message": "Authentication Successful"
},
"reference": {
"transaction": "tck_LV02G1720231634Xj60014708",
"order": "ord_Zu5d59231914gJa018lJ9b720"
},
"customer": {
"id": "cus_TS01A1520232215Nx3n1810085",
"name": [
{
"first_name": "test",
"middle_name": "test",
"last_name": "test",
"locale": "en"
}
],
"name_on_card": "Ahmed",
"email": "test@tap.com",
"phone": {
"country_code": "+20",
"number": "1099137777"
}
},
"source": {
"id": "tok_2AKI58231914GLWn18V69C147"
},
"merchant": {
"id": "1124340"
},
"card": {
"id": "card_rSWi582319149ys718hD9B151",
"first_six": "424242",
"scheme": "VISA",
"brand": "VISA",
"category": "",
"last_four": "4242",
"name": "AHMED",
"expiry": {
"month": "04",
"year": "44"
},
"funding": "CREDIT"
},
"authentication": {
"acsEci": "02",
"card_enrolled": "Y",
"authenticationToken": "jHyn+7YFi1EUAREAAAAvNUe6Hv8=",
"transactionId": "FOdR5lit6PaxiidyOxmjSS9z1ls=",
"version": "3DS1",
"channel": "PAYER_BROWSER",
"purpose": "Transaction",
"url": "https://authenticate.alpha.tap.company/redirect/auth_payer_yhFr59231914mJvN18c79665",
"transStatus": "Y",
"mode": "C"
},
"payment_agreement": {
"id": "payment_agreement_NDL3172319152Gck18109189",
"type": "UNSCHEDULED",
"contract": {
"id": "card_rSWi582319149ys718hD9B151",
"type": "SAVED_CARD"
}
},
"redirect": {
"url": ""
}
}
FAQs
Tap Card SDK Wrapper
The npm package card-react-native receives a total of 437 weekly downloads. As such, card-react-native popularity was classified as not popular.
We found that card-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.