React Native Stone SDK Implementation (Support for both Mobile and POS versions)

Overview

react-native-stone-pos

Stone Android POS Native Module

Installation

Stone has a private packageCloud repository, so we need to have your token before hand in order to communicate with package cloud.

So you have two options:

Environment variable / Project properties

We support both options, as adding the variables to your gradle.properties in your android folder, or setting it as a global environment variable. (This is useful when you are building it from CI)

The most important variable you need is: StonePos_packageCloudToken. This variable is used to authenticate with Stone private package Cloud repo, so we can download our dependencies.

Other variables you might want:

Name Default Value Description
StonePos_posMode pos Set this to anything other than pos to remove the HAL dependencies all together, this is useful if you are building an app to mobile devices other than the POS
StonePos_includeIngenico true Set this to anything other than true to remove the Ingenico hal dependencies
StonePos_includeSunmi true Set this to anything other than true to remove the Sunmi hal dependencies
StonePos_includeGertec true Set this to anything other than true to remove the Gertec hal dependencies

Install Steps:

npm install react-native-stone-pos

Android

YOU NEED TO DO THIS

Edit android/app/build.gradle ( NOT android/build.gradle ) and add the following:

apply from: "../../node_modules/react-native-stone-pos/android/stone-repo.gradle"

If you are building with the POS in mind, you will also need to apply this here:

apply from: "../../node_modules/react-native-stone-pos/android/dynamic-hal.gradle"

This will enable the HAL modules of your choosing, or all of them as long as you are in POS mode, or the StonePos_include* variables are true

Troubleshooting

Manifest merger failed : Attribute application@allowBackup value=(false)

You might get an error when you are using the default React Native Manifest, which is:

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:12:7-34
  	is also present at [br.com.stone:stone-sdk:4.1.1] AndroidManifest.xml:20:9-35 value=(true).
  	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-12:19 to override.

So, as per the suggestion, you can add tools:replace="android:allowBackup" to your <application> element at your android/app/src/main/AndroidManifest.xml file, like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.yourapp.here">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="true"
      tools:replace="android:allowBackup"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>
More than one file was found with OS independent path 'META-INF/client_release.kotlin_module'

If you get this error:

More than one file was found with OS independent path 'META-INF/client_release.kotlin_module'

Try modifying android/app/build.gradle and add this inside the android section:

packagingOptions {
  exclude 'META-INF/api_release.kotlin_module'
  exclude 'META-INF/client_release.kotlin_module'
}

Usage

import * as StonePOS from 'react-native-stone-pos';

// ...

const isRunningInPOS = StonePOS.IS_RUNNING_IN_POS;
const activationResult = await StonePOS.initSDK('My Awesome App');

if (!isRunningInPos) {
  //Ask user to select the bluetooth pinpad (use any library you like), and then you can connect using:
  const pinpadConnectResult = await StonePOS.connectToPinPad(
    'My beauty pinpad',
    '00:11:22:33:44'
  );
}

Example

Checkout the example project, which was made with the intention of running all the required homologation tests. There you will see how to void, execute a charge, print, and so on.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

You might also like...
馃殌 React Native Segmented Control, Pure Javascript for iOS and Android
馃殌 React Native Segmented Control, Pure Javascript for iOS and Android

Installation Add the dependency: npm i react-native-segmented-control-2 Peer Dependencies Zero Dependency 馃コ Usage Import import SegmentedControl from

Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.

Uncompress React Native Simple library to decompress files .zip, .rar, .cbz and .cbr in React Native. Installation yarn add uncompress-react-native o

A react native interface for integrating payments using PayPal

react-native-paypal Getting started Installation npm install react-native-paypal Android Specific Add this to your build.gradle maven { url "https:

A framework for building native applications using React

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started 路 Learn the Basics 路 Showcase 路 Contribute 路 Community 路 Suppor

Library to read incoming SMS in Android for Expo (React Native)

react-native-expo-read-sms Maintainers maniac-tech Active maintainer Installation Install this in your managed Expo project by running this command: $

 A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Implementation of useful hooks inspired by React for Compose
Implementation of useful hooks inspired by React for Compose

useCompose React inspired hooks for Compose Installation Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the

An android application where you can manage and install all versions of the spotify app.

An android application where you can manage and install all versions of the spotify app.

Be notified of new AndroidX (Jetpack) library versions and their changelog by GitHub notifications
Be notified of new AndroidX (Jetpack) library versions and their changelog by GitHub notifications

Image credits: Android Developers This repository publishes release notes of And

Releases(v0.1.13)
Owner
8Sistemas
Solu莽玫es infinitas ao seu dispor
8Sistemas
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Ahmed Eid 0 Jan 11, 2022
An Animated Scrolling View for React Native applications, supported on both iOS and Android

react-native-focused-scroll An Animated Scrolling View for React Native applications, supported on both iOS and Android Preview react-native-focus-scr

Fatemeh Marzoughi (Saba) 3 Aug 12, 2022
Make SIP calls from react-native using Linphone SDK

react-native-sip Make SIP calls from react-native using Linphone SDK Installation npm install react-native-sip Usage import { multiply } from "react-n

Woonivers 2 Jun 30, 2022
Wrapper for Kustomer SDK v2.0 for react native

This is a wrapper for Kustomer v2 Sdk for react native. This implements the kust

Shivam Rawat 2 Dec 30, 2021
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
A demo for Android font typeface support in React Native!

A Step-by-step Guide to a Consistent Multi-Platform Font Typeface Experience in React Native Goal Be able to use font typeface modifiers such as fontW

Jules Sam. Randolph 53 Dec 23, 2022
GeckoView implementation on android for React Native.

react-native-geckoview A fully functional implementation of GeckoView on android for react native. The component supports two-way messaging similar to

Ammar Ahmed 7 Nov 24, 2022
Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

null 7 Sep 7, 2022
A 2020s compatible React Native keyboard avoiding view for Android and iOS that just works.

react-native-keyboard-shift Example Snack coming soon Until then: Clone this repo: git clone https://github.com/FullStackCraft/react-native-keyboard-s

Full Stack Craft 66 Aug 16, 2022
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

NativeScript 22k Dec 31, 2022