Integration guide

1. Install library

Add to dependencies:

ninepay_sdk_flutter: ^1.0.5

2. Init SDK

Parameter
Explain

merchantCode

This is the code of the partner when integrating the SDK

secretKey

Key connect to API 9Pay

uId

User identifier using merchant's account, optional, can be null

flavorEnv

Using environment, there are 2 environments, sandbox (test code environment) and production (actual running environment), see the table below for configuration.

colorCode

The color code that the merchant wants to use on the buttons in the SDK, hex color code and not the # character, for example 15AE62

3. List of constants config SDK

Key
Explain

EnvironmentKey.SANDBOX

flavorEnv environment Sandbox

EnvironmentKey.PRODUCTION

flavorEnv environment Production

PaymentMethod.DEFAULT

Payment using all methods (used in the openPaymentOnSDK function).

PaymentMethod.WALLET

Payment using method 9Pay Ewallet (used in the openPaymentOnSDK function).

PaymentMethod.ATM_CARD

Payment using method inland card (used in the openPaymentOnSDK function).

PaymentMethod.CREDIT_CARD

Payment using method credit card (used in the openPaymentOnSDK function).

4. Technical Diagram

4.1 Example init SDK

late final NinepaySdkFlutter? ninepaySdkFlutter;

@override
  void initState() {
    ninepaySdkFlutter = NinepaySdkFlutter(
      merchantCode: 'merchant_code',
      secretKey: 'secret_key',
      uId: null,
      flavorEnv: NinepayEnv.STAGING,
      colorCode: '15AE62', // Color hex
    );
ninepaySdkFlutter.onEvent().listen((event) {
      // Get type event
      if (kDebugMode) {
        print('LISTEN SUCCESS ${event["name_event"]}');
      }
      String typeEvent = event['name_event'];

      switch (typeEvent) {
        case 'backToAppFrom':
          showToast(event.toString());
          break;
        case 'sdkDidComplete':
          showToast('sdkDidComplete');
          print(event);
          break;
        case 'getInfoSuccess':
          showToast('GET INFO SUCCESS ${event['data']}');
          break;
        case 'onError':
          showToast(event['message']);
          // map {"error_code": errorCode, "message": message}
          break;
        case 'onLogoutSuccessful':
          showToast('Đăng xuất thành công!');
          break;
        case 'onCloseSDK':
          showToast('onCloseSDK');
          break;
      }
    });

    super.initState();
  }
  
  @override
  void dispose() {
    // cancel listener
    ninepaySdkFlutter.cancel();
    super.dispose();
  }
// Json callback from getInfoSuccess:

{
  "balance": "1505549",
  "phone": "0971999999",
  "name": "NGUYEN VAN A",
  "statusKyc": "2"
}

4.2 Open fucntion SDK 9Pay

// Open SDK Action.
ninepaySdkFlutter.openSDKWithAction(action: NinepayActions.LOGIN);
Name action
Function

LOGIN

Login

HISTORY

Transaction history

TRANSFER

Money transfer and withdrawal functions

DEPOSIT

Deposit to 9Pay Ewallet

QR

Function scan QR code

BILLING

Billing (electric, water...)

TOPUP

Topup phone

PHONE_CARD

Buy phone card

DATA_CARD

Buy data card 4G

SERVICE_CARD

Buy service card

4.3 Function Payment order merchant

String urlPayment = "" // Url payment was created from backend
bool isShowResultScreen = true // show result screen when payment complete
// Method payment

// PaymentMethod.WALLET
// PaymentMethod.ATM_CARD
// PaymentMethod.CREDIT_CARD
// PaymentMethod.DEFAULT

ninepaySdkFlutter.openPaymentOnSDK(urlPayment, PaymentMethod.DEFAULT, isShowResultScreen);

4.4 Get user info

ninepaySdkFlutter.getUserInfo();

// Data will callback from getInfoSuccess listener
// Json data infomation:
// Phone number login, balance, eKYC status, full name of user.

4.5 Logout

ninepaySdkFlutter.logout(); // Logout user was logged

4.6 Close screen SDK

ninepaySdkFlutter.close();

5. Data test sandbox

Type
Details

Account Ewallet 9Pay SDK

0912365431

Password (Account Ewallet 9Pay SDK)

123123

OTP (Account Ewallet 9Pay SDK)

123456

Bank information used to link and deposit

Bank: Agribank

Number card: 9704 0000 0000 0018

Account holder: Nguyen Van A

Issuance date: 03/07

OTP: otp

International card

Account holder: NGUYEN VAN A

Number card:

  • 4005555555000009 (Visa)

  • 5200000000001005 (MasterCard)

Expiration: 05/25

CVV: 123

6. List error code SDK

Error will return callback from onError when init SDK.

Code
Type

403

Not login

2001

Error validate information order

2002

Error payment order merchant

2003

Error getting bank information and payment card SDK support

2004

Error decoding returned data

2005

Unknown error

Last updated