- The parameter “pageSize” must be a number between one and one hundred.
2. Send request
An HTTP POST request must be sent to the list subscriptions endpoint, with the JSON containing the subscription data.
Once the list subscriptions request has been sent and successfully made, a JSON object is obtained in response.
When receiving this response, the expected parameter from the JSON object is the “body”, since it contains the result of the list subscriptions. The following code shows an example of the response received.
- {
- "status": "SUCCESS",
- "code": 200,
- "result": {
- "entries": [
- {
- "id": "5625d026579f64b63f250631220f8836",
- "status": "NOT_PAID",
- "user_id": "Aaron",
- "description": "subscription description",
- "currency": "CRC",
- "amount": "10",
- "startdate": "1536991200000",
- "enddate": "1544853600000",
- "cadence": "EVERY 1 MONTH",
- "next_payment_date": "2019-01-15T00:00:00.000Z"
- },
- {
- "id": "2d374b16dfc4937a7429cbd73636f7ba",
- "status": "NOT_PAID",
- "user_id": "Aaron",
- "description": "subscription description",
- "currency": "CRC",
- "amount": "10",
- "startdate": "1536991200000",
- "enddate": "1544853600000",
- "cadence": "EVERY 15 DAY",
- "next_payment_date": "2019-01-27T00:00:00.000Z"
- }
- ],
- "page": 1,
- "totalEntries": 15,
- "totalPages": 1
- },
- "errors": []
- }
Below is a javascript example of the list subscriptions endpoint request. This function also obtains the JSON’s “body” that is received in response.
- var unirest = require("unirest");
- var req = unirest("POST", "https://dev-merchant.greenpay.me/subscriptions/list");
- req.headers({
- "Postman-Token": "93d00f6a-5af4-4dd1-b540-5b705107b615",
- "cache-control": "no-cache",
- "Content-Type": "application/json"
- });
- req.type("json");
- req.send({
- "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
- "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
- "pageSize": 100,
- "page": 1
- });
- req.end(function (res) {
- if (res.error) throw new Error(res.error);
- console.log(res.body);
- });