Preparing your App

How to securely connect to the Tap to Pay on Phone SDK

Android Package Name

To register your package name in Nearpay, follow these steps using the Nearpay dashboard:

  1. Login to the NearPay dashboard here
  2. Once logged in, navigate to the Apps page
  3. Add a new App
  4. Provide the package name and the name of the Android app

Setting Up Terminals

To set up a terminal for conducting transactions, please follow these steps:

  1. Login to the NearPay dashboard here
  2. Once logged in, navigate to the Terminals page.
  3. Create a new terminal.
  4. Generate a TRSM code consisting of six hexadecimal digits.
  5. Decide whether to assign the terminal to an existing merchant (if available) or create a new one.

By following these steps, you will be able to set up a terminal successfully.

Authentication

We have 4 method for login:

Login with JWT

AuthenticationData.Jwt("jwt here")

Login with existing mobile number

AuthenticationData.Mobile("+966500000000")

Login with existing email

AuthenticationData.Email("[email protected]")

Let the user enter the mobile number or email to Login

AuthenticationData.UserEnter.INSTANCE

Allowing your user to login using mobile, email and UserEnter

UserEnter, is a way to allow users to enter their mobile number or email to log in. To enable this feature in the Nearpay dashboard, there are a few steps that need to be followed. Once completed, users can log in from the App using their email or mobile number.

  1. Log in to the Nearpay Dashboard.
  2. Click on the "Terminals" tab.
  3. Select the terminal you want to invite the user to by clicking on its details.
  4. Under "Access", select "Invite user".
  5. Enter the user's details and send the invitation.

Once the user accepts the invitation, they can log in to the SDK and select the terminal to perform transactions.

Allowing Your User To Login Using JWT

To connect your user device to a terminal ID, use your backend to sign the JWT with the following data:

  1. Login to Nearpay Dashboard.
  2. Go to the credentials page.
  3. You will find the following:
    • Client UUID: you will use as client_uuid
    • JWT Key: Once you click generate, it will download a file which is the private key (pos_key.pem) that you will use to sign the JWT.
  4. for terminal_id, you can find all the terminals you have on the terminals page and select one
import * as fs from 'fs';
import * as jwt from 'jsonwebtoken';

function getToken() {
var privateKey: Buffer = fs.readFileSync('./pos_key.pem');

var terminal:any = {
  data:{
    ops: "auth",
    client_uuid: "212f66c6-bbfd-4fc7-9f50-31a749145cd1", // provided by nearpay
    terminal_id: "1000003000000006"// get this number from mada
  }
}

return jwt.sign(terminal, privateKey, { algorithm: "RS256"});
}

Ready to Get Started?

Congratulations! You're all set to embark on creating your app with our platform. Whether you're a seasoned developer or just getting started, we've got you covered to jump right into action.

Quick Start Guide

If you're excited to start building your app right away and don't want to waste any time, our Quick Start guide is perfect for you. It offers simple instructions to quickly set up your environment and start coding. You can access the Quick Start guide by clicking here.

SDK Page

If you want to gain a better understanding of our Tap to Pay on Phone Kits (SDKs) and access them, please visit our SDK page. On this page, you will find exhaustive documentation, sample codes, and resources that will help you get the most out of our platform's capabilities. We are here to support you every step of the way, so choose your preferred path and start turning your ideas into reality!