react-native-sumup-sdk
v1.0.6
Published
Accept Card Payment from our React Native apps using using SumUp card reader device.
Readme
react-native-sumup-sdk
Getting started
$ npm install react-native-sumup-sdk --save$ react-native link react-native-sumup-sdk
Installation
iOS
Please stay tuned iOS support coming soon. Sorry for that.
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactnativesumupsdk.ReactSumUpModule;to the imports at the top of the file - In the
onCreate()method, addReactSumUpModule.initSumUp(this);to the end
- Append the following lines to
android/settings.gradle:include ':react-native-sumup-sdk' project(':react-native-sumup-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sumup-sdk/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:implementation project(':react-native-sumup-sdk')
Implementing using SumUp Android SDk - version 5.0.3
Prerequisites
- Registered for a merchant account via SumUp's country websites (or received a test account).
- Generate an Affiliate (Access) Key via SumUp Developers portal.
- Generate an API Key via SumUp Developers portal.
Usage
import SumUpSDK, {CurrencyCodes} from 'react-native-sumup-sdk';
SumUpSDK.init("YOUR_Affiliate_KEY");
const App = () => {
const sumUpSdk = new SumUpSDK();
useEffect(() => {
try{
await sumUpSdk.authenticateWithToken('YOUR_API_KEY');
}catch(error){
console.log(error)
}
}, []);
return (
<View>
<Text>SumUp SDK</Text>
</View>
);
};
export default App;To authenticate with a token (see https://developer.sumup.com/rest-api/#section/Authentication)...
await sumUpSdk.authenticateWithToken('YOUR_API_KEY');To authenticate with SumUp credentials...
await sumUpSdk.authenticate();To wake up the device...
await sumUpSdk.prepareForCheckout();To wake up the device...
await sumUpSdk.prepareForCheckout();To begin the checkout process...
import { CurrencyCodes } from 'react-native-sumup-sdk';
await sumUpSdk.checkout(
'ABC' /* the transaction title */,
1.23 /* the transaction amount */
);
// OPTIONAL FIELDS:
// currencyCode = CurrencyCodes.GBP (defaulted to GBP)
// foreignTransactionId = '' (foreign transaction ID, must be unique)
// token = null (authentication token. Only required if authentication hasn't already been done)💬 Buy me a coffee ☕️ if you like my work!
https://buymeacoffee.com/atifgulzar
