react-native-tinkoff-pay
v0.1.0
Published
A React Native module for T-Bank Acquiring SDK payments
Readme
react-native-tinkoff-pay
A React Native module for integrating T-Bank (Tinkoff) Acquiring SDK into mobile applications on iOS and Android platforms. This library enables seamless payment processing using T-Bank's payment forms, supporting various payment methods like bank cards, T-Pay, SBP, and Mir Pay (Android only).
Features
- Unified payment initiation across iOS and Android.
- Synchronous payment result delivery via
Promise. - Support for custom
terminalKeyandpublicKeyper payment. - Built with Kotlin (Android) and Swift + Objective-C (iOS) for native performance.
Requirements
- iOS: iOS 13.0 or higher, Xcode 15.1+, Swift 5.9.2+
- Android: Android 7.0 (API level 24) or higher
- React Native: 0.60.0 or higher
Installation
Install the Package
npm install react-native-tinkoff-pay
# or
yarn add react-native-tinkoff-payiOS Setup
Update Podfile
Add the following to yourios/Podfile:pod 'TASDKCore' pod 'TASDKUI'Then run:
cd ios && pod installConfigure
Info.plist
Add the following toios/YourApp/Info.plistto support T-Pay and SBP:<key>LSApplicationQueriesSchemes</key> <array> <string>bank100000000004</string> <!-- T-Pay --> <string>bank100000000111</string> <!-- Sberbank SBP --> <string>bank110000000005</string> <!-- VTB SBP --> <!-- Add more SBP schemes as needed, up to 50 --> </array> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoadsInWebContent</key> <true/> <key>NSAllowsArbitraryLoads</key> <false/> <key>NSExceptionDomains</key> <dict> <key>securepay.tinkoff.ru</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>qr.nspk.ru</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> </dict> </dict> </dict>
Android Setup
Configure
network_security_config.xml
Create thenetwork_security_config.xmland Add the following to:<network-security-config> <base-config> <trust-anchors> <certificates src="system" /> <certificates src="@raw/acq_tinkoff_root_cert" /> <certificates src="@raw/acq_ministry_of_digital_development_root_cert" /> </trust-anchors> </base-config> </network-security-config>Then add this line to
AndroidManifest.xml<application ... android:networkSecurityConfig="@xml/network_security_config" //<-Add this line >Sync Project
cd android && ./gradlew clean build
Usage
Example
import TinkoffPay from 'react-native-tinkoff-pay';
// Initiate a payment
async function makePayment() {
try {
const result = await TinkoffPay.startPayment({
orderId: 'ORDER_123',
amount: 100000, // 1000 RUB in kopecks
description: 'Test payment',
customerKey: 'CUSTOMER_KEY',
terminalKey: 'your_terminal_key',
publicKey:
'your_public_key',
password: 'your_password',
});
console.log('Payment result:', result);
} catch (error) {
console.error(error);
}
}
makePayment();API
startPayment(paymentFlow: PaymentFlow): Promise<PaymentResult>
Initiates a payment using T-Bank's payment form.
Parameters:
paymentFlow: PaymentFlow:orderId: string- Unique order identifier in the merchant's system.amount: number- Payment amount in kopecks (e.g., 100000 for 1000 RUB).description: string- Brief description of the order.customerKey: string- Unique customer identifier for card saving.terminalKey: string- Terminal identifier from T-Bank personal account.publicKey: string- Public key for data encryption from T-Bank personal account.password: string- Password for token generation (should be handled server-side in production).
Returns:
Promise<PaymentResult>status: 'succeeded' | 'cancelled'- Payment outcome.paymentId?: string- Payment identifier (if succeeded).cardId?: string- Card identifier (if succeeded and card was saved).
Throws:
Error- If payment fails or SDK initialization fails.
Configuration
Prerequisites
To use this library, you need:
TerminalKey,PublicKey, andPasswordfrom your T-Bank personal account after enabling Internet Acquiring.- See Personal Account Settings for details.
Security Notes
- Token Generation: The
passwordis used client-side for token generation in this implementation. Make shure you dont store password in application source. - SSL/TLS Certificates: Configure your app to support MinTsifra certificates for reliability:
- iOS: Update
Info.plistas per iOS SDK docs. - Android: Add
network-security-configas per Android SDK docs.
- iOS: Update
Troubleshooting
- "ActivityNotFoundException": Ensure
TinkoffPaymentActivityis registered in your Android manifest (see Android Setup). - "SDK not initialized": Verify that
terminalKey,publicKey, andpasswordare valid. The library initializes the SDK on the firststartPaymentcall. - Payment Fails: Enable debug logging with
AcquiringSdk.isDebug = trueand check Logcat (Android) or Xcode logs (iOS) for details.
Development
Building the Library
yarn clean
yarn prepareTesting
yarn test
yarn typecheck
yarn lintContributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -am 'Add your feature' - Push to the branch:
git push origin feature/your-feature - Open a Pull Request.
Report bugs or request features at GitHub Issues.
License
MIT License. See LICENSE for details.
Acknowledgments
- Built using T-Bank Acquiring SDK for iOS and Android.
- Authors: MobilityTop LTD [email protected] (MobilityTop), Igor Orekhov [email protected] (arahisman).
