This guide explains the technical specifications of JSAPIs that is available to be called from your application's frontend.
Integrate SDK
-
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)
-
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});
-
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
API | Function | Requires Consent |
---|---|---|
getAuthCode | Get an auth code used to identify the current user session | No |
getBankAccountToken | Request and tokenize the user’s linked bank account information | Yes |
triggerPayment | Automatically redirect users to the GoPay app to complete the payment, then return them to your Mini App. | No |
openDeeplink | Redirect users to particular deeplink/url(Gopay app deeplink) | No |
getConsent | Ask user to retrieve user consent for accessing sensitive data | Yes |
getLocation | Obtain user's device location | No |
getSystemInfo | Get device's system info such as OS, model, and app version | Yes |
getWifiInfo | Get the device’s connected Wi-Fi details, such as SSID or signal strength | Yes |
Version History
Version | Description | GoPay App Version | Date |
---|---|---|---|
0.5 | Initial 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 Needed | Details |
---|---|
Mini App Frontend | Available since: GoPay App Version 1.36.0 |
Mini App npm SDK Version | Available 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 Needed | Details |
---|---|
Mini App Frontend | Available since: GoPay 1.36.0 |
Mini App npm SDK Version | Available 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 Needed | Details |
---|---|
Mini App Frontend | Available 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 Needed | Details |
---|---|
Mini App Frontend | Available since: GoPay 1.45.0 |
Mini App npm SDK Version | Available 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/SDK | Needs getConsent SDK |
---|---|
getProfile | ✅ Yes |
getLocation | ✅ Yes |
getDeviceInfo | ✅ Yes |
getCamera | ✅ Yes |
Integration Needed | Details |
---|---|
Mini App Frontend | Available since: GoPay 1.52.0 |
Mini App npm SDK Version | Coming 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 Code | Description |
---|---|
100 | Method not supported error |
200 | Incomplete parameter error |
201 | Invalid type error |
202 | Parameter data error |
203 | Miniapp not registered |
300 | No permission error |
400 | Device not supported |
401 | Network error |
500 | Superapp error |
Get Location
Note
You must call
getConsent
before accessing the following SDKs.
Integration Needed | Details |
---|---|
Mini App Frontend | Available since: GoPay 1.36.0 |
Mini App npm SDK Version | Available 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 Needed | Details |
---|---|
Mini App Frontend | Coming 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,
}
}