@netappsng/react-native-pay 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @netappsng/react-native-pay
|
|
2
2
|
|
|
3
|
-
NetAppsPay React Native SDK — accept card, bank transfer, USSD, and
|
|
3
|
+
NetAppsPay React Native SDK — accept card, bank transfer, USSD, PayAttitude and Tap to Pay (NFC) payments in your React Native app. Supports **iOS** and **Android**.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -168,6 +168,9 @@ export default function CheckoutScreen() {
|
|
|
168
168
|
| `'ussd'` | USSD payment |
|
|
169
169
|
| `'payattitude'` | PayAttitude (USSD push) |
|
|
170
170
|
| `'moniflow'` | MoniFlow marketplace |
|
|
171
|
+
| `'tap_to_pay'` | NFC Tap to Pay (Android only — requires setup, see below) |
|
|
172
|
+
|
|
173
|
+
> **Note:** `tap_to_pay` is only available on Android. On iOS, this channel is silently ignored.
|
|
171
174
|
|
|
172
175
|
### Callbacks
|
|
173
176
|
|
|
@@ -178,6 +181,141 @@ export default function CheckoutScreen() {
|
|
|
178
181
|
| `onCancel` | — | User dismissed the payment sheet |
|
|
179
182
|
| `onReady` | — | Payment sheet is fully loaded |
|
|
180
183
|
|
|
184
|
+
## Tap to Pay (NFC) — Android Only
|
|
185
|
+
|
|
186
|
+
Tap to Pay lets customers pay by tapping their contactless card on the Android device. It requires an additional native `taptopay` module that is **not** included by default. Your app will compile and work normally without it — devices without NFC are unaffected.
|
|
187
|
+
|
|
188
|
+
> **Not supported on iOS.** If you include `'tap_to_pay'` in `paymentChannels` on iOS, it is silently ignored.
|
|
189
|
+
|
|
190
|
+
### Step 1 — Add the taptopay module dependency
|
|
191
|
+
|
|
192
|
+
In your React Native project's **Android** build files, add the `taptopay` module alongside the payment SDK:
|
|
193
|
+
|
|
194
|
+
```kotlin
|
|
195
|
+
// android/app/build.gradle.kts (or build.gradle)
|
|
196
|
+
|
|
197
|
+
dependencies {
|
|
198
|
+
// The core payment SDK (already added by the RN package)
|
|
199
|
+
implementation("ng.netapps:netappspay:1.0.0")
|
|
200
|
+
|
|
201
|
+
// Tap to Pay NFC plugin — add this line
|
|
202
|
+
implementation("ng.netapps:taptopay:1.0.0")
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Then sync your Gradle project (Android Studio will prompt you, or run `cd android && ./gradlew sync`).
|
|
207
|
+
|
|
208
|
+
### Step 2 — Register the NFC provider in your Android app
|
|
209
|
+
|
|
210
|
+
Open your `MainApplication.kt` (or `MainApplication.java`) file — this is usually at:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
android/app/src/main/java/com/yourapp/MainApplication.kt
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Add the import and registration call inside `onCreate`:
|
|
217
|
+
|
|
218
|
+
```kotlin
|
|
219
|
+
// MainApplication.kt
|
|
220
|
+
|
|
221
|
+
import com.netappspay.sdk.taptopay.TapToPayRegistry
|
|
222
|
+
import com.netappspay.taptopay.NfcTapToPayProvider
|
|
223
|
+
|
|
224
|
+
class MainApplication : Application(), ReactApplication {
|
|
225
|
+
|
|
226
|
+
override fun onCreate() {
|
|
227
|
+
super.onCreate()
|
|
228
|
+
|
|
229
|
+
// Register NFC Tap to Pay provider — do this once on app start
|
|
230
|
+
TapToPayRegistry.register(NfcTapToPayProvider())
|
|
231
|
+
|
|
232
|
+
// ... rest of your onCreate
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Java version:**
|
|
238
|
+
|
|
239
|
+
```java
|
|
240
|
+
// MainApplication.java
|
|
241
|
+
|
|
242
|
+
import com.netappspay.sdk.taptopay.TapToPayRegistry;
|
|
243
|
+
import com.netappspay.taptopay.NfcTapToPayProvider;
|
|
244
|
+
|
|
245
|
+
public class MainApplication extends Application implements ReactApplication {
|
|
246
|
+
|
|
247
|
+
@Override
|
|
248
|
+
public void onCreate() {
|
|
249
|
+
super.onCreate();
|
|
250
|
+
|
|
251
|
+
// Register NFC Tap to Pay provider
|
|
252
|
+
TapToPayRegistry.INSTANCE.register(new NfcTapToPayProvider());
|
|
253
|
+
|
|
254
|
+
// ... rest of your onCreate
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
That's all the native code you need. The `taptopay` module's `AndroidManifest.xml` automatically adds the NFC permission with `android:required="false"`, so your app still installs on devices without NFC.
|
|
260
|
+
|
|
261
|
+
### Step 3 — Include `'tap_to_pay'` in your payment channels
|
|
262
|
+
|
|
263
|
+
Now in your React Native / TypeScript code, add `'tap_to_pay'` to the `paymentChannels` array:
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import { presentPayment } from '@netappsng/react-native-pay';
|
|
267
|
+
import type { PaymentConfig } from '@netappsng/react-native-pay';
|
|
268
|
+
|
|
269
|
+
const config: PaymentConfig = {
|
|
270
|
+
publicKey: 'pk_live_xxxxxxxxxxxxxxxxxxxx',
|
|
271
|
+
amount: 10000,
|
|
272
|
+
currency: 'NGN',
|
|
273
|
+
email: 'john@example.com',
|
|
274
|
+
fullName: 'John Doe',
|
|
275
|
+
phoneNumber: '08106720418',
|
|
276
|
+
narration: 'POS Payment',
|
|
277
|
+
paymentChannels: ['card', 'transfer', 'tap_to_pay'],
|
|
278
|
+
defaultChannel: 'card',
|
|
279
|
+
businessName: 'Demo Store',
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
presentPayment(config, {
|
|
283
|
+
onSuccess: (payload) => {
|
|
284
|
+
console.log('Tap to Pay successful!', payload.transactionRef);
|
|
285
|
+
},
|
|
286
|
+
onFailed: (payload) => {
|
|
287
|
+
console.log('Payment failed:', payload.message);
|
|
288
|
+
},
|
|
289
|
+
onCancel: () => {
|
|
290
|
+
console.log('Cancelled');
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### How it works
|
|
296
|
+
|
|
297
|
+
1. When the payment sheet opens, the SDK checks if a Tap to Pay provider is registered via `TapToPayRegistry`
|
|
298
|
+
2. If registered **and** the device has NFC hardware enabled, the "Tap to Pay" tab appears
|
|
299
|
+
3. If no provider is registered or the device lacks NFC, the tab is automatically hidden — no errors, no crashes
|
|
300
|
+
4. The customer taps their contactless card on the device to complete payment
|
|
301
|
+
|
|
302
|
+
### Requirements
|
|
303
|
+
|
|
304
|
+
| Requirement | Value |
|
|
305
|
+
|---|---|
|
|
306
|
+
| Min Android SDK | **24** (Android 7.0) |
|
|
307
|
+
| NFC hardware | Required on the device |
|
|
308
|
+
| `taptopay` module | Must be added as a dependency |
|
|
309
|
+
| Provider registration | Must call `TapToPayRegistry.register()` before payment |
|
|
310
|
+
|
|
311
|
+
### Unregister (optional)
|
|
312
|
+
|
|
313
|
+
If you need to disable Tap to Pay at runtime:
|
|
314
|
+
|
|
315
|
+
```kotlin
|
|
316
|
+
TapToPayRegistry.unregister()
|
|
317
|
+
```
|
|
318
|
+
|
|
181
319
|
## Native SDKs
|
|
182
320
|
|
|
183
321
|
This package bridges the native NetAppsPay SDKs:
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","Platform","NativeNetappspay","emitter","validateConfig","config","publicKey","trim","email","fullName","narration","amount","currency","paymentChannels","length","defaultChannel","presentPayment","callbacks","OS","console","warn","error","onFailed","status","message","timestamp","Date","toISOString","sanitizedConfig","address1","city","phoneNumber","subscriptions","addListener","payload","onSuccess","onCancel","onReady","setTimeout","present","forEach","s","remove"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,OAAOC,gBAAgB,MAAM,uBAAoB;;AAEjD;;
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","NativeNetappspay","emitter","validateConfig","config","publicKey","trim","email","fullName","narration","amount","currency","paymentChannels","length","defaultChannel","presentPayment","callbacks","OS","console","warn","error","onFailed","status","message","timestamp","Date","toISOString","sanitizedConfig","address1","city","phoneNumber","subscriptions","addListener","payload","onSuccess","onCancel","onReady","setTimeout","present","forEach","s","remove"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,OAAOC,gBAAgB,MAAM,uBAAoB;;AAEjD;;AAqGA;;AAEA,MAAMC,OAAO,GAAG,IAAIH,kBAAkB,CAACE,gBAAuB,CAAC;;AAE/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,cAAcA,CAACC,MAAqB,EAAiB;EAC5D,IAAI,CAACA,MAAM,CAACC,SAAS,EAAEC,IAAI,CAAC,CAAC,EAAE,OAAO,uBAAuB;EAC7D,IAAI,CAACF,MAAM,CAACG,KAAK,EAAED,IAAI,CAAC,CAAC,EAAE,OAAO,mBAAmB;EACrD,IAAI,CAACF,MAAM,CAACI,QAAQ,EAAEF,IAAI,CAAC,CAAC,EAAE,OAAO,sBAAsB;EAC3D,IAAI,CAACF,MAAM,CAACK,SAAS,EAAEH,IAAI,CAAC,CAAC,EAAE,OAAO,uBAAuB;EAC7D,IAAI,OAAOF,MAAM,CAACM,MAAM,KAAK,QAAQ,IAAIN,MAAM,CAACM,MAAM,IAAI,CAAC,EAAE,OAAO,kCAAkC;EACtG,IAAI,CAACN,MAAM,CAACO,QAAQ,EAAE,OAAO,sBAAsB;EACnD,IAAI,CAACP,M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,EACF/B,OAAO,CAAC8B,WAAW,CAAC,iBAAiB,EAAGC,OAAO,IAAK;IAClDjB,SAAS,EAAEK,QAAQ,GAAGY,OAA+B,CAAC;EACxD,CAAC,CAAC,EACF/B,OAAO,CAAC8B,WAAW,CAAC,iBAAiB,EAAE,MAAM;IAC3ChB,SAAS,EAAEmB,QAAQ,GAAG,CAAC;EACzB,CAAC,CAAC,EACFjC,OAAO,CAAC8B,WAAW,CAAC,gBAAgB,EAAE,MAAM;IAC1ChB,SAAS,EAAEoB,OAAO,GAAG,CAAC;EACxB,CAAC,CAAC,CACH;;EAED;EACAC,UAAU,CAAC,MAAMpC,gBAAgB,CAACqC,OAAO,CAACX,eAAsB,CAAC,EAAE,CAAC,CAAC;EAErE,OAAO,MAAM;IACXI,aAAa,CAACQ,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC;EAC1C,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Currency = 'NGN' | 'USD';
|
|
2
|
-
export type PaymentChannel = 'card' | 'transfer' | 'ussd' | 'payattitude' | 'moniflow';
|
|
2
|
+
export type PaymentChannel = 'card' | 'transfer' | 'ussd' | 'payattitude' | 'moniflow' | 'tap_to_pay';
|
|
3
3
|
export type ChargeAllocation = 'CUSTOMER' | 'MERCHANT';
|
|
4
4
|
export interface PaymentConfig {
|
|
5
5
|
/** Your NetAppsPay public key */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;AAErC,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM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