Public API Reference

If you have any questions regarding the API, you can ask in the #dev channel in our Discord Server

login POST

Login and start a session with the server.

Endpoint: https://mypayindia.com/api/v1/login

Request body:

{
    "username": "username",
    "password": "password"
}


Response: 200 OK

{
    "success": true,
    "message": "Logged in!"
}

Errors

Invalid credentials: 401 Unauthorized

{
    "success": false,
    "message": "Invalid credentials"
}

Missing required fields: 400 Bad Request

{
    "success": false,
    "message": "Username or password is missing"
}

info GET

Get information about the logged in account.

Endpoint: https://mypayindia.com/api/v1/info


Response: 200 OK

{
    "success": true,
    "username": "username",
    "first_name": "first_name",
    "last_name": "last_name",
    "email": "[email protected]",
    "date_of_birth": "1970-01-01",
    "created": "1970-01-01 00:00:00",
    "balance": "123456.78"
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

leaderboard GET

Get global leaderboard

Endpoint: https://mypayindia.com/api/v1/leaderboard


Response: 200 OK

{
  "success": true,
  "data": [
    {
      "username": "username",
      "balance": "123456.78",
      "created": "1970-01-01 00:00:00"
    },
    ...
  ]
}

transaction_history GET

Get transaction history for logged in account.

Endpoint: https://mypayindia.com/api/v1/transaction_history


Response: 200 OK

{
  "success": true,
  "data": [
    {
      "id": 123,
      "transaction_id": "TXN-1234567890-09af",
      "sender_id": 9,
      "target_id": 41,
      "amount": "123.45",
      "created": "1970-01-01 00:00:00",
      "status": "status",
      "sender_name": "sender_username",
      "target_name": "recipient_username"
    },
    ...
  ]
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

transaction POST

Get information about a transaction.

Endpoint: https://mypayindia.com/api/v1/transaction

Request body:

{
    "id": 123
}

// Or:

{
    "transaction_id": "TXN-1234567890-09af"
}


Response: 200 OK

{
    "success": true,
    "id": 123,
    "transaction_id": "TXN-1234567890-09af",
    "sender_id": 9,
    "target_id": 41,
    "amount": "123.45",
    "created": "1970-01-01 00:00:00",
    "status": "status",
    "sender_name": "sender_username",
    "target_name": "recipient_username",
    "note": "My Note India"
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Transaction id not provided: 400 Bad Request

{
    "success": false,
    "message": "Missing id"
}

transfer POST

Transfer money to recipient.

Endpoint: https://mypayindia.com/api/v1/transfer

Request body:

{
    "amount": "123.45",
    "recipient": 41,
    "note": "My Note India"
}


Response: 200 OK

{
    "success": true,
    "transaction_id": 123,
    "status": "status",
    "sender_id": 9,
    "recipient_id": 41,
    "amount": "123.45",
    "new_balance": "123345.99"
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Amount not provided: 400 Bad Request

{
    "success": false,
    "message": "Missing amount"
}

Recipient not provided: 400 Bad Request

{
    "success": false,
    "message": "Missing recipient"
}

Create a payment link to share money with anyone who has a MyPayIndia account.

Endpoint: https://mypayindia.com/api/v1/create_payment_link

Request body:

{
    "amount": 123.45,
    "note": "My Note India"
}


Response: 200 OK

{
    "success": true,
    "id": 123,
    "token": "0123456789abcdef",
    "amount": 123.45,
    "note": "My Note India",
    "new_balance": 123345.67,
    "link_url": "URL_HERE"
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Amount not provided: 400 Bad Request

{
    "success": false, 
    "message": "Missing amount"
}

Insufficient balance: 200 OK

{
    "success": false,
    "message": "Insufficient balance. You need X.XX INR but only have Y.YY INR."
}

Get information about a payment link by its token. If the user is logged in, also returns their balance and whether they can accept the link.

Endpoint: https://mypayindia.com/api/v1/get_payment_link?token=TOKEN


Response: 200 OK

{
    "success": true,
    "amount": 123.45,
    "author_username": "sender_username",
    "author_name": "Sender Name",
    "note": "My Note India",
    "created": "1970-01-01 00:00:00",
    "current_user_balance": 500.00,
    "can_accept": true
}

Errors

Missing token: 400 Bad Request

{
    "success": false,
    "error": "missing_token",
    "message": "Missing token parameter"
}

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Payment link not found: 404 Not Found

{
    "success": false,
    "error": "not_found",
    "message": "Payment link not found."
}

Payment link already claimed: 410 Gone

{
    "success": false,
    "error": "already_claimed",
    "message": "This payment link has already been claimed."
}

Payment link cancelled: 410 Gone

{
    "success": false,
    "error": "cancelled",
    "message": "This payment link has been cancelled by the sender."
}

List payment links for logged in account

Endpoint: https://mypayindia.com/api/v1/list_payment_links


Response: 200 OK

{
  "success": true,
  "data": [
    "links": [
        {
        "id": 123,
        "token": "0123456789abcdef",
        "amount": 123,
        "note": "Hi",
        "created": "1970-01-01 00:00:00",
        "status": "status"
        },
        ...
    ]
  ]
}

Errors

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Claim a payment link

Endpoint: https://mypayindia.com/api/v1/claim_payment_link?token=TOKEN


Response: 200 OK

{
    "success": true,
    "data": {
        "transaction_id": "TXN-0123456789-abcd",
        "amount": 123,
        "new_balance": 12345,
        "from_user": "defaultuser0"
    }
}

Errors

Missing token: 400 Bad Request

{
    "success": false,
    "error": "missing_token",
    "message": "Missing token parameter"
}

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

Cancel a payment link

Endpoint: https://mypayindia.com/api/v1/cancel_payment_link?token=TOKEN


Response: 200 OK

{
    "success": true,
    "data": {
        "amount": 123,
        "refunded_to": "mypayindia"
    }
}

Errors

Missing token: 400 Bad Request

{
    "success": false,
    "error": "missing_token",
    "message": "Missing token parameter"
}

Not logged in: 401 Unauthorized

{
    "success": false,
    "message": "Unauthorized"
}

pay/create_transaction POST

Create a payment transaction.

Endpoint: https://mypayindia.com/api/v1/pay/create_transaction

Request body:

{
    "merchant_key": "0123456789abcdef",
    "amount": 123.45,
    "order_id": "my_order_india_1234567890"
}


Response: 200 OK

{
    "success": true,
    "data": {
        "payment_url": "<?php echo BASE_URL; ?>/pay?txn=PAY-0123456789ABCDEF"
    }
}

Errors

Missing merchant key: 401 Unauthorized

{
    "success": false,
    "message": "Missing merchant_key"
}

Amount not provided: 400 Bad Request

{
    "success": false, 
    "message": "Missing amount"
}