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);
     }
  })

Possible Consent Name:

JSAPI<consent_name>
getLocation(GoPay)location
getCamera(Javascript)camera
getProfile(GoPay)You can get this from the error response from getProfile

Sample Response:

Success Response:

type ConsentResponse = {
  data: {
      consent_name: string,
      has_consent: boolean,
  },
  success: boolean,
  error?: string
}
  • Data will be null in all cases of success.
  • Error will be null in case of success = true, and vice versa.

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