# Subscription

# Subscription Request Api

You can use this API to subscribe.

# Endpoint

POST /api/v1.0/subscribe

# Parameters

Name Type Description Required
clientID string The merchant app ID provided by the Nagorik ✔️
requestID string Merchant subscription request ID ✔️
start date Subscription start date. Format: 2020-04-04 (after 11:30 PM of a day, you cannot put today as start date) ✔️
end date Subscription end date. Format: 2020-10-04 (cannot be after 730 days) ✔️
userReturnURL url After transaction completion user will be redirect to this URL with the value of invoiceID as an URL query parameter. ✔️
cycle string Payment cycle (one of the following):DAILY,WEEKLY,FIFTEEN_DAYS ✔️
amount string amount ✔️

# Response

Status: 200

{
    "url": "https://intent.recurring.pay.bka.sh/intent/web/intent/PMKWYBH9",
    "invoiceID": "nagorik2021-1195",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Subscription Request Status Api

You can use this API for subscription request status.

# Endpoint

POST /api/v1.0/subscribe/{$invoiceId}/status

# Query Parameters

Name Type Description Required
invoiceId string It is the invoiceID, that you received in response to the Subscription Request API. ✔️

# Response

Status: 200

{
    "invoiceId": "nagorik2021-1195",
    "status": "INITIALIZED",
    "subscriptionId": "578371",
    "createdAt": "2021-12-27 13:32:16",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Subscription Details

You can use this API for subscription details.

# Endpoint

POST /api/v1.0/subscription/{$subscriptionId}

# Query Parameters

Name Type Description Required
subscriptionId string It is the subscriotionID , that you received in response to the Subscription Request Status API. ✔️

# Response

Status: 200

{
    "id": "578371",
    "amount": 1,
    "cycle": "WEEKLY",
    "enabled": 0,
    "createdDate": "2021-12-27T07:32:16.000000Z",
    "startDate": "2022-01-01",
    "endDate": "2022-02-01",
    "nextPaymentDate": "2022-01-08 00:00:00",
    "requestID": "test012qe2123e",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Subscription Cancel

You can use this API for subscription cancel.

# Endpoint

POST api/v1.0/subscription/{subscriptionId}/cancel

# Query Parameters

Name Type Description Required
subscriptionId string It is the subscriotionID , that you received in response to the Subscription Request Status API. ✔️

# Response

Status: 200
{
    "id": 212,
    "subscriptionID": "598857",
    "requestID": 212,
    "status": "PROCESSED",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Subscription Cancel Details

You can use this API for subscription cancel details.

# Endpoint

POST api/v1.0/subscription/cancel/{subscriptionId}

# Query Parameters

Name Type Description Required
subscriptionId string It is the subscriptionID, that you received in response to the Subscription Request API. ✔️

# Response

Status: 200
{
    "id": 212,
    "subscriptionID": "598857",
    "requestID": 212,
    "status": "PROCESSED",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Payment List

You can use this API for payment list.

# Endpoint

POST api/v1.0/subscription/{subscriptionId}/payments

# Query Parameters

Name Type Description Required
subscriptionId string It is the subscriptionID, that you received in response to the Subscription Request API. ✔️

# Response

Status: 200
{
    "subscriptionPayments": [
        {
            "paymentId": 628342,
            "cycle": "WEEKLY",
            "dueDate": "2022-01-11",
            "reverseTransactionAmount": null,
            "reverseTransactionDate": null,
            "reverseTransactionId": null,
            "status": "SUCCEEDED_PAYMENT",
            "subscriptionId": "598857",
            "transactionDate": "2022-01-11 07:31:35",
            "transactionId": "9AB8WMM0IE",
            "nextPaymentDate": "2022-01-18"
        }
    ],
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'

# Payment Details

You can use this API for payment details.

# Endpoint

POST api/v1.0/subscription/payment/{paymentId}

# Query Parameters

Name Type Description Required
paymentId string paymentId ✔️

# Response

Status: 200
{
    "paymentId": 628342,
    "cycle": "WEEKLY",
    "dueDate": "2022-01-11",
    "reverseTransactionAmount": null,
    "reverseTransactionDate": null,
    "reverseTransactionId": null,
    "status": "SUCCEEDED_PAYMENT",
    "subscriptionId": "598857",
    "transactionDate": "2022-01-11 07:31:35",
    "transactionId": "9AB8WMM0IE",
    "nextPaymentDate": "2022-01-18",
    "errorCode": "00",
    "errorMessage": "Operation Success"
}
curl -X POST http://api.example.com/auth/login \
  --data '{
    "username": "my-username",
    "password": "my-password"
  }'