Poko SDK for React Native

Parameters

Installation

npm install @pokopayment/react-native-sdk

The SDK needs 2 other packages to work correctly, follow these command to install them:

npm install react-native-webview

npm install react-native-permissions

Next, add the CAMERA permission to your application (See more here):

  • Android

Add this line to the AndroidManifest.xml

<uses-permission android:name="android.permission.CAMERA" />
  • iOS:

Install pod-install: npm install -D pod-install

Update your package.json

  "scripts": {
    ....
    "postinstall": "react-native setup-ios-permissions && pod-install"
  },
  "reactNativePermissionsIOS": [
    "Camera"
  ]

Then update your Info.plist with wanted permissions usage descriptions:json

  <key>NSCameraUsageDescription</key>
  <string>Some providers would need it for the KYC process</string>

Code Sample

// Root component
import {PokoWidgetProvider} from '@pokopayment/react-native-sdk';

function App(): JSX.Element {
  return (
    <PokoWidgetProvider apiKey="your API_KEY (optional)" environment="DEVELOPMENT (default) | STAGING | PRODUCTION">
      <HelloWorld />
    </PokoWidgetProvider>
  );
}

// HelloWorld component
import {usePokoWidget} from '@pokopayment/react-native-sdk';

const {launchWidget, setApiKey, setEnv, setUserId} =
    usePokoWidget();

setApiKey('YOUR API KEY'); // required, can ignore if already provided from the PokoWidgetProvider
setUserId('Your user ID'); // required
setEnv('PRODUCTION' | 'STAGING' | 'DEVELOPMENT'); // default DEVELOPMENT

const urlLaunched = launchWidget({
    fiat?: string; // VND, USD,..
    crypto?: string; // USDT-bsc, USDT-ethereum, BTC-bitcoin,...
    fiatAmount?: number; // 100.0
    cryptoAmount?: number; // 0.5
    strictMode?: boolean; // true | false (not allow users change fiat & crypto currency)
    fiatList?: string[]; // ['VND', 'USD']
    cryptoList?: string[]; // ['ETH-ethereum', 'BTC-bitcoin']
    excludeProviderIds?: string[]; // ['transak', 'payfura']
    signature?: string;
    providerId?: string;
    paymentMethodId?: string;
    receiveWalletAddress?: string;
});

Last updated