List payment subscriptions

List payment subscriptions

For this service the following endpoint must be consumed: 

  1. https://sandbox-merchant.greenpay.me/subscriptions/list/payments

Below is the step by step to list payment subscriptions in our API:


1. Create the JSON object to be sent


JSON structure example

  1. {
  2.     "subscriptionId": "f39a928e9c1f1fa32f30e1de1df35656",
  3.     "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
  4.     "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
  5.     "pageSize": 25,
  6.     "page": 1
  7. }
Parameters description

  1. subscriptionId: identifier generated in the list payment subscriptions response. 
  2. secret: provided by Greenpay.
  3. merchant: merchantId provided by Greenpay.
  4. pageSize: number of records that the service must return
  5. page: page that must return the service.

Recommendations
  1. The parameter “page” must be a number greater than zero
  1. 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 payment subscriptions endpoint, with the JSON containing the subscription data.

Once the list payment 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  payment subscriptions. The following code shows an example of the response received. 

  1. {
  2.     "status": "SUCCESS",
  3.     "code": 200,
  4.     "result": {
  5.         "entries": [
  6.             {
  7.                 "id": "7",
  8.                 "reference_number": "f88ae81b0d469f67d081b7f239c96305_1",
  9.                 "payment_date": "2018-12-27T22:22:32.868Z",
  10.                 "payment_result": null,
  11.                 "payment_retries": [
  12.                     {
  13.                         "attemp_date": "2018-12-27T22:32:32.837Z",
  14.                         "attemp_result": {
  15.                             "status": 500,
  16.                             "orderId": "f88ae81b0d469f67d081b7f239c96305_1",
  17.                             "authorization": null,
  18.                             "amount": 100,
  19.                             "currency": "CRC",
  20.                             "errors": [
  21.                                 "Error: Invalid card token"
  22.                             ],
  23.                             "_signature": "60d3dd83d1853ea1c697c0d338b5af9b87bd6398054076ebcbbcbf22dda6e36b5d38ea56aeb6a33db4ab27c6a56d750815b08a4fa813b1cc239ce59b5ae528eb52887bcab59dca06b7de80f726431b2bd973a1a4111b9d6e0fc7ab7bdd4408da0f9ba92031dfa3edabbf27b372a28cce6f587309c51848eb615c96cdba5c85b1"
  24.                         }
  25.                     }
  26.                 ]
  27.             }
  28.         ],
  29.         "page": 1,
  30.         "totalEntries": 1,
  31.         "totalPages": 1
  32.     },
  33.     "errors": []
  34. }
Below is a javascript example of the list subscriptions endpoint request. This function also obtains the JSON’s “body” that is received in response. 
  1. var unirest = require("unirest");

  2. var req = unirest("POST", "https://dev-merchant.greenpay.me/subscriptions/list/payments");

  3. req.headers({
  4.  "Postman-Token": "fead6d4d-70ea-405f-a134-c51458bbed15",
  5.  "cache-control": "no-cache",
  6.  "Content-Type": "application/json"
  7. });

  8. req.type("json");
  9. req.send({
  10.  "subscriptionId": "f39a928e9c1f1fa32f30e1de1df35656",
  11.  "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
  12.  "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
  13.  "pageSize": 100,
  14.  "page" : 1
  15. });

  16. req.end(function (res) {
  17.  if (res.error) throw new Error(res.error);

  18.  console.log(res.body);
  19. });
Possible errors
  • Merchant doesn't exist.

If you try to use the service with incorrect credentials, the returned response will be as the following

  1. {
  2.   "code": 500,
  3.   "status": "FAIL",
  4.   "result": [],
  5.   "errors": [
  6.       ""Merchant doesn't exist"."
  7.   ]
  8. }
  • Bad request, check params

If you try to use the service by sending unaccepted values in the pageSize and page parameters, the returned will be as the following.

  1. {
  2.    "status": "FAIL",
  3.    "code": 400,
  4.    "result": [],
  5.    "errors": [
  6.        "Bad request, check params"
  7.    ]
  8. }



    • Related Articles

    • List subscriptions

      For this service the following endpoint must be consumed: https://sandbox-merchant.greenpay.me/subscriptions/list Below is the step by step to list subscriptions in our API 1. Create the JSON object to be sent JSON object structure example {     ...
    • Manual payment

      For this service, the following endpoint must be consumed:  https://sandbox-merchant.greenpay.me/subscriptions/pay Step by step to process a successful manual payment in our API:  1.Create the JSON object to be sent. JSON structure example {   ...
    • Update payment method

      For this service, the following endpoint must be consumed:  https://sandbox-merchant.greenpay.me/subscriptions/update/card_token Step by step to update a payment method in our API: 1. Create the JSON object to be sent JSON structure example {   ...
    • Send bulk payment request

      To create a bulk payment request, a POST request must be made to the batch payment endpoint, with the structure of the JSON shown below: 1.{ "merchantId": "your_merchant_id", "secret": "your_secret", "terminal": "your_terminal", "currency": "USD || ...
    • Widget payment process

      To consider Para utilizar el widget de pago de Greenpay, se debe considerar los siguiente: You must have a sandbox or production account, to obtain a sandbox account visit About sandbox or test account. The payment widget is a web element that can be ...