
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@cardql/react-native-tap
Advanced tools
CardQL SDK for React Native tap-to-pay for secure in-person payments
CardQL SDK for React Native tap-to-pay for secure in-person payments.
npm install @cardql/react-native-tap
# or
yarn add @cardql/react-native-tap
This package requires the following peer dependencies:
npm install @cardql/react-native-tap react react-native
First, wrap your app with the payment terminal provider and implement a token provider:
import React from "react";
import { PaymentTerminalProvider } from "@cardql/react-native-tap";
function App() {
const fetchTokenProvider = async () => {
// Fetch connection token from your backend
const response = await fetch(`${API_URL}/connection_token`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
});
const { secret } = await response.json();
return secret;
};
return (
<PaymentTerminalProvider
logLevel="verbose"
tokenProvider={fetchTokenProvider}>
{/* Your app components */}
</PaymentTerminalProvider>
);
}
import React from "react";
import { TapToPayReader } from "@cardql/react-native-tap";
function PaymentScreen() {
const fetchTokenProvider = async () => {
// Your token provider implementation
const response = await fetch(`${API_URL}/connection_token`, {
method: "POST",
});
const { secret } = await response.json();
return secret;
};
const handleSuccess = (result) => {
console.log("Payment successful:", result);
// Handle successful payment
};
const handleError = (error) => {
console.error("Payment failed:", error);
// Handle payment error
};
return (
<TapToPayReader
amount="10.00"
currency="USD"
merchantID="your-merchant-id"
userID="user-123"
tokenProvider={fetchTokenProvider}
onSuccess={handleSuccess}
onError={handleError}
autoInit={true}
autoDiscoverReaders={true}
simulated={__DEV__} // Use simulated readers in development
/>
);
}
For more control, use the useTapToPay
hook:
import React, { useEffect } from "react";
import { useTapToPay } from "@cardql/react-native-tap";
function CustomPaymentFlow() {
const fetchTokenProvider = async () => {
const response = await fetch(`${API_URL}/connection_token`, {
method: "POST",
});
const { secret } = await response.json();
return secret;
};
const tapToPay = useTapToPay({
config: {
merchantID: "your-merchant-id",
currency: "USD",
paymentConfig: {
tokenProvider: fetchTokenProvider,
logLevel: "info",
simulated: __DEV__,
},
},
readerConfig: {
discoveryMethod: "localMobile",
simulated: __DEV__,
},
events: {
onReaderDiscovered: (readers) => {
console.log("Found readers:", readers.length);
},
onReaderConnected: (reader) => {
console.log("Connected to reader:", reader.id);
},
onPaymentMethodCollected: (paymentMethod) => {
console.log("Payment method collected:", paymentMethod.type);
},
onSuccess: (result) => {
console.log("Payment successful:", result);
},
onError: (error) => {
console.error("Payment error:", error);
},
},
autoInit: true,
autoDiscoverReaders: true,
});
const handlePayment = async () => {
try {
const result = await tapToPay.processPayment({
amount: "25.00",
currency: "USD",
merchantID: "your-merchant-id",
userID: "user-123",
description: "Coffee and pastry",
});
if (result.success) {
console.log("Payment completed:", result.payment);
} else {
console.error("Payment failed:", result.error);
}
} catch (error) {
console.error("Payment processing error:", error);
}
};
return (
<View>
<Text>
Status: {tapToPay.isInitialized ? "Ready" : "Initializing..."}
</Text>
<Text>Readers: {tapToPay.discoveredReaders.length}</Text>
<Text>Connected: {tapToPay.connectedReader?.id || "None"}</Text>
<Button
title="Start Payment"
onPress={handlePayment}
disabled={!tapToPay.connectedReader || tapToPay.isCollectingPayment}
/>
</View>
);
}
Use your device's built-in NFC for contactless payments:
const readerConfig = {
discoveryMethod: "localMobile",
simulated: false,
};
Connect to certified Bluetooth card readers:
const readerConfig = {
discoveryMethod: "bluetoothScan",
simulated: false,
};
Connect to internet-connected payment terminal readers:
const readerConfig = {
discoveryMethod: "internet",
locationId: "your-location-id",
};
interface TapToPayConfig {
merchantID: string;
currency?: string;
timeout?: number;
acceptedCardTypes?: CardType[];
paymentConfig: PaymentTerminalConfig;
captureMethod?: "automatic" | "manual";
customBranding?: {
primaryColor?: string;
logo?: string;
merchantName?: string;
};
}
interface PaymentTerminalConfig {
tokenProvider: () => Promise<string>;
logLevel?: "verbose" | "info" | "warn" | "error";
simulated?: boolean;
}
interface CardReaderConfig {
discoveryMethod: "bluetoothScan" | "localMobile" | "internet";
simulated?: boolean;
locationId?: string;
autoConnect?: boolean;
enableTipping?: boolean;
skipTipping?: boolean;
}
The SDK provides detailed error information:
interface TapToPayError {
code: TapToPayErrorCode;
message: string;
details?: any;
gatewayError?: any;
userFriendlyMessage?: string;
canRetry?: boolean;
suggestedAction?: string;
}
Common error codes:
TERMINAL_NOT_SUPPORTED
: Device doesn't support payment terminalREADER_CONNECTION_FAILED
: Could not connect to card readerPAYMENT_COLLECTION_FAILED
: Could not collect payment methodPAYMENT_CONFIRMATION_FAILED
: Could not confirm paymentTRANSACTION_DECLINED
: Payment was declined by issuerListen to payment flow events:
const events = {
onReaderDiscovered: (readers: Reader[]) => void;
onReaderConnected: (reader: Reader) => void;
onReaderDisconnected: (reason?: string) => void;
onPaymentMethodCollected: (paymentMethod: PaymentMethod) => void;
onPaymentIntentCreated: (paymentIntent: PaymentIntent) => void;
onDisplayMessage: (message: string) => void;
onError: (error: TapToPayError) => void;
onSuccess: (result: TapPaymentResult) => void;
onCancel: () => void;
};
Enable simulated mode for testing:
<TapToPayReader
simulated={true}
// ... other props
/>
In simulated mode, use these test card numbers:
4242424242424242
5555555555554444
378282246310005
For support with payment terminal integration:
MIT License - see LICENSE file for details.
FAQs
CardQL SDK for React Native tap-to-pay for secure in-person payments
The npm package @cardql/react-native-tap receives a total of 5 weekly downloads. As such, @cardql/react-native-tap popularity was classified as not popular.
We found that @cardql/react-native-tap 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.