v1

Authentication

To access the MyPay API, you must first authenticate your requests using an Access Token.

Required Credentials

Obtain the following from the Merchant Dashboard before you start:

Credential Description
Client ID Unique identifier for your application
Client Secret Secret key for the client (keep confidential)
Base URL API URL for the environment you are using (see Introduction)

Getting an Access Token

Use this endpoint to obtain a valid bearer token for a specific period.

Endpoint: POST /authentication/token

Headers:

Content-Type: application/json

Request Body:

{
    "client_id": "your_client_id_here",
    "secret_id": "your_client_secret_here"
}

Success Response (200 OK)

{
    "message": {
        "code": 200,
        "success": ["SUCCESS"]
    },
    "data": {
        "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
        "expire_time": 600
    },
    "type": "success"
}

[!NOTE] Each access_token is tied to one payment session (one call to POST /payment/create). It is valid for 10 minutes (600 seconds). For a new order, request a new token via POST /authentication/token. Do not reuse a token across different orders.

Recommended Flow

  1. Call POST /authentication/token to obtain an access_token.
  2. Call POST /payment/create once with that token.
  3. Redirect the customer to the payment_url from the response.
  4. For the next order, start again from step 1 with a new token.

Error Response (400 Bad Request)

{
    "message": {
        "code": 400,
        "error": ["Invalid client ID"]
    },
    "data": {},
    "type": "error"
}

Using the Token

After obtaining the Token, you must send it in the Authorization header with every subsequent API request:

Authorization: Bearer <your_access_token>