https://github.com/bitfancy/nfc-payment
https://github.com/bitfancy/nfc-payment
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bitfancy/nfc-payment
- Owner: BitFancy
- License: mit
- Created: 2024-05-08T18:54:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-08T19:01:36.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T21:16:52.324Z (11 months ago)
- Language: Java
- Size: 413 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-nfc-payment
A React Native module that allows you to receive payments with nfc.
This package will only work on Android and isn't available for iOS as of 2020 because Apple do not allow 3rd party iPhone apps to use the Core NFC framework.
## Installation
```sh
npm install react-native-nfc-payment
```
### Android
Simple add `uses-permission` into your `AndroidManifest.xml`:
```xml
```
### Methods
| Method | Description |
| -------------------- | ------------------------------- |
| `registerTagEvent` | `Start the nfc reading process` |
| `unregisterTagEvent` | `Close the nfc reading process` |
### Options
| Method | Description | Default |
| ---------------------- | -------------------------------------------------- | ------- |
| `contactLess` | `Enable contact less reading` | `true` |
| `readAllAids` | `Read all aids in card` | `true` |
| `readTransactions` | `Read all transactions` | `true` |
| `removeDefaultParsers` | `Remove default parsers for GeldKarte and EmvCard` | `false` |
| `readAt` | `Read and extract ATR/ATS and description` | `true` |
## Usage / Example
```javascript
import { useEffect, useState } from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import {
registerTagEvent,
unregisterTagEvent,
type INfcModuleConfig,
type INfcCardInfo,
} from "react-native-nfc-payment";
export default function App() {
const [cardInfos, setCardInfos] = useState(null);
useEffect(() => {
onRegisterTagEvent();
return () => {
onUnregisterTagEvent();
};
}, []);
const onRegisterTagEvent = async () => {
try {
var options: INfcModuleConfig = {
contactLess: true,
readAllAids: true,
readTransactions: true,
removeDefaultParsers: false,
readAt: true,
};
const result = await registerTagEvent(options);
console.log("unregisterTagEvent::result", JSON.parse(result));
} catch (error) {
console.log("error", error);
}
};
const onUnregisterTagEvent = async () => {
try {
const result = await unregisterTagEvent();
console.log("unregisterTagEvent::result", result);
} catch (error) {
console.log("error", error);
}
};
return (
Register Tag Event
Unregister Tag Event
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
paddingHorizontal: 30,
},
buttonStyle: {
padding: 10,
backgroundColor: "#ddd",
borderRadius: 40,
alignItems: "center",
marginBottom: 20,
},
});
```
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## Acknowledgements
Thanks to the authors of these libraries for inspiration:
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
- [EMV-NFC-Paycard-Enrollment](https://github.com/devnied/EMV-NFC-Paycard-Enrollment)
## License
MIT
---