List of JSAPIs (0.4.0)

This guide explains the technical specifications of JSAPIs that is available to be called from your application's frontend.

Integrate SDK

  1. You can use Mini AppSDK, which is a JavaScript library that provides a simple interface for interacting with GoPay Mini App features, such as retrieving location information and obtaining authorization codes.

    📝

    Notes

    You can download the JS SDK here: JS SDKhttps://www.npmjs.com/package/@gopay/miniapp-client (make sure you have version 0.3.19)

  2. Once installed, import Mini AppSDK and initialize the SDK in your JavaScript code:

    import MiniAppSDK from '@gopay/miniapp-client';
    
    const inProductionEnvironment = import.meta.env.PROD;
    
    const miniAppSdk = new MiniAppSDK({useDummyService: !inProductionEnvironment});
    
  3. You can view the readme files of the SDK for further clarification on what the SDK does.
    www.npmjs.com/@gopay/miniapp-client


Supported JSAPIs

MiniAppSDK

APIFunctionRequires Consent
getAuthCodeGet an auth code used to identify the current user sessionNo
getBankAccountTokenRequest and tokenize the user’s linked bank account informationYes
triggerPaymentAutomatically redirect users to the GoPay app to complete the payment, then return them to your Mini App.No
openDeeplinkRedirect users to particular deeplink/url(Gopay app deeplink)No
getConsentAsk user to retrieve user consent for accessing sensitive dataYes
getLocationObtain user's device locationNo
getSystemInfoGet device's system info such as OS, model, and app versionYes
getWifiInfoGet the device’s connected Wi-Fi details, such as SSID or signal strengthYes


Version History

VersionDescriptionGoPay App VersionDate
0.5Initial Release for V1

JSAPIs Specification (Deprecated)

📝

Note

  • Data will be null in case of success = false, and vice versa.
  • Error will be null in case of success = true, and vice versa.

Get Auth Code

Integration NeededDetails
Mini App FrontendAvailable since: GoPay App Version 1.36.0
Mini App npm SDK VersionAvailable since: 0.3.19

⚠️

Warning

The authCode is valid for 5 minutes. Please re-call the APIs again if exceed the authCode validity period.

Sample Request

miniAppSdk.getAuthCode() 
  .then((result) => { 
     if(result.success) {
         console.log('Authorization code:', result.data?.authCode);
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  });

Sample Response

type AuthCodeResponse = {
  success: true,
  data?: {
    authCode: "GBNURP5WyBIqXiGxKv2cO8Qj4CyS0qZrRK5O4e8ehdnHpowG6k5pkj2SsF7BqGIF"
  }
}
error = {
  success: false,
  error?: "Mini app is not found",
}

Open Deeplink

📝

Note

Merchant should request to whitelist deeplink to make this work. Please connect with our product/support for this.

Integration NeededDetails
Mini App FrontendAvailable since: GoPay 1.36.0
Mini App npm SDK VersionAvailable since: 0.3.19

Sample Request

const deeplink = 'gopay://...';

miniAppSdk
  .openGopayDeeplink(deeplink)
  .then((result) => {
    console.log('Success:', result.success);
  })
  .catch((err) => {
    console.log(err);
  });

Sample Response

 {
  success: true,
}
 {
  success: false,
  error: {
      code: 300,
      message: "Permission denied"
  },
}

Get Bank Account Token

Integration NeededDetails
Mini App FrontendAvailable since: TDB

Sample Request:

miniAppSdk.getBankAccountToken() 
  .then((result) => { 
     if(result.success) {
         console.log('Token code:', result.data?.token);
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  });

Sample Response

type BankAccountTokenResponse = {
  success: boolean,
  error?: string,
  data?: {
    token: string
  }
}

Trigger Payment

Integration NeededDetails
Mini App FrontendAvailable since: GoPay 1.45.0
Mini App npm SDK VersionAvailable since: 0.3.19

Sample Request:

// fetch the deeplink from your miniapp backend
const paymentDeeplink = 'gopay://...';

miniAppSdk.triggerPayment({ deeplink: paymentDeeplink }).then((result) => {
  console.log('Payment status:', result.data.status);
});

Sample Response:

 {
  success: true,
  data: {
      status: "success"
  }
}
 {
  success: false,
  error: {
      code: 300,
      message: "Permission denied"
  },
}

Get Consent

📝

Note

To protect user privacy, MiniApps must ask for user permission (consent) before using things like phone number, location, or camera.

1. Pre-Launch Consent (Handled by GoPay)

  • A popup showing all available consents appears automatically before the MiniApp opens.
  • This is shown every time the MiniApp opens if the user hasn’t granted all required permissions.
  • This works only if permission is granted by GoPay to the MiniApp. (docs)

2. Post-Launch Consent (Handled by Merchant)

  • A popup for specific consent appears only when the merchant calls the API or SDK listed below.
  • This is shown only if the user didn’t grant the consent during pre-launch.
  • You must call getConsent('consentName')from our SDK before calling the actual API.
  • This works only if step 1 is done

If the user declines Mandatory consent then user cannot proceed

Use the getConsent SDK only for permissions marked as optional and during post-launch.

API/SDKNeeds getConsent SDK
getProfile✅ Yes
getLocation✅ Yes
getDeviceInfo✅ Yes
getCamera✅ Yes
Integration NeededDetails
Mini App FrontendAvailable since: GoPay 1.52.0
Mini App npm SDK VersionComing soon

Sample Request:

miniAppSdk.getConsent(<consent_name>)
  .then((result) => {
     if(result.success) {
         console.log('Consent provided'); 
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  })

Sample Response:

type ConsentResponse = {
  data: {
      consent_name: string,
      has_consent: boolean,
  },
  success: boolean,
  error?: string
}

Possible Error Codes:

Error CodeDescription
100Method not supported error
200Incomplete parameter error
201Invalid type error
202Parameter data error
203Miniapp not registered
300No permission error
400Device not supported
401Network error
500Superapp error

Get Location

📝

Note

You must call getConsent before accessing the following SDKs.

Integration NeededDetails
Mini App FrontendAvailable since: GoPay 1.36.0
Mini App npm SDK VersionAvailable since: 0.3.19

Sample Request:

miniAppSdk.getLocation()
  .then((result) => {
     if(result.success) {
         console.log('Current location:', result.data); 
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  })

Sample Response:

type LocationResponse = {
  success: boolean,
  error?: string,
  data?: {
    latitude: number,
    longitude: number,
    time: number, // in milliseconds since epoch
  }
}

Get System Info

Integration NeededDetails
Mini App FrontendComing soon

Sample Request:

miniAppSdk.getSystemInfo()
  .then((result) => {
     if(result.success) {
         console.log('Device information:', result.data); 
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  })

Sample Response:

type DeviceInfoResponse = {
  success: boolean,
  error?: string,
  data?: {
    os_type: number,
    is_emulator: boolean, // tentative for now, key may change
    is_rooted: boolean, // tentative for now, key may change
    wifi_bssid: string,
    wifi_ssid: string,
    brand: string,
    model: string,
    product: string,
    uuid: string, // tentative for now, key may change
    idfa: string, // tentative for now, key may change
    idfv: string, // tentative for now, key may change
  }
}

Get Wifi Info

Sample Request

miniAppSdk.getWifiInfo()
  .then((result) => {
     if(result.success) {
         console.log('Wifi information:', result.data); 
     }
     else {
         console.log('Error fetching code:', result.error, result.error?.message);
     }
  })

Sample Response

type WifiInfoResponse = {
  success: boolean,
  error?: string,
  data?: {
    wifi_bssid: string,
    wifi_ssid: string,
  }
}