PayHere API

Demo page:


Please follow the below steps.

1. Create a Business App

  1. Sign in to your PayHere account & go to Settings > Business Apps section

  2. Click 'Create App' button & enter an app name & comma seperated domains to whilelist

  3. Tick the permission 'Subscription Management API'

  4. Click 'Add Business App' button to create the app

  5. Once the app is created click 'View Credential' button in front of the created app

  6. Copy the 'App ID' & 'App Secret' values

2. Generate an Authorization code

  1. Go to a Base64 encoding site such as

  2. Paste the App ID & App Secret you copied from Step 1 above, separated by a colon (:) mark. eg. 4OVx33RVOPg4DzdZUzq4A94D2:8n4VCj25MXp4JLDFyvsE9h4a8qgbPaZUI4JEWK4FCvop

  3. Click 'Encode' button & copy the base64 encoded value. This is your Authorization code. or if you are using OAuth library, you may use BASIC authorization technique by passing App ID & App Secret directly.

You can also generate the Authorization code by using the built-in workflow 'PayHere - Access Token: Server-Side. Ignore above steps from step 2 if you do so.

3. Retrieve an Access Token

If you don't already have a valid Access Token, you can retrieve one by consuming following API end point.

Request URL

Sandbox - sandbox.payhere
Live - payhere


"access_token": "cb5c47fd-741c-489a-b69e-fd73155ca34e",
"token_type": "bearer",
"expires_in": 599,
"scope": "SANDBOX"