List payment subscriptions
For this service the following endpoint must be consumed:
- 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
- {
- "subscriptionId": "f39a928e9c1f1fa32f30e1de1df35656",
- "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
- "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
- "pageSize": 25,
- "page": 1
- }
Parameters description
- subscriptionId: identifier generated in the list payment subscriptions response.
- secret: provided by Greenpay.
- merchant: merchantId provided by Greenpay.
- pageSize: number of records that the service must return
- page: page that must return the service.
Recommendations
- The parameter “page” must be a number greater than zero
- 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.
- {
- "status": "SUCCESS",
- "code": 200,
- "result": {
- "entries": [
- {
- "id": "7",
- "reference_number": "f88ae81b0d469f67d081b7f239c96305_1",
- "payment_date": "2018-12-27T22:22:32.868Z",
- "payment_result": null,
- "payment_retries": [
- {
- "attemp_date": "2018-12-27T22:32:32.837Z",
- "attemp_result": {
- "status": 500,
- "orderId": "f88ae81b0d469f67d081b7f239c96305_1",
- "authorization": null,
- "amount": 100,
- "currency": "CRC",
- "errors": [
- "Error: Invalid card token"
- ],
- "_signature": "60d3dd83d1853ea1c697c0d338b5af9b87bd6398054076ebcbbcbf22dda6e36b5d38ea56aeb6a33db4ab27c6a56d750815b08a4fa813b1cc239ce59b5ae528eb52887bcab59dca06b7de80f726431b2bd973a1a4111b9d6e0fc7ab7bdd4408da0f9ba92031dfa3edabbf27b372a28cce6f587309c51848eb615c96cdba5c85b1"
- }
- }
- ]
- }
- ],
- "page": 1,
- "totalEntries": 1,
- "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/payments");
- req.headers({
- "Postman-Token": "fead6d4d-70ea-405f-a134-c51458bbed15",
- "cache-control": "no-cache",
- "Content-Type": "application/json"
- });
- req.type("json");
- req.send({
- "subscriptionId": "f39a928e9c1f1fa32f30e1de1df35656",
- "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);
- });
Possible errors
If you try to use the service with incorrect credentials, the returned response will be as the following
- {
- "code": 500,
- "status": "FAIL",
- "result": [],
- "errors": [
- ""Merchant doesn't exist"."
- ]
- }
- 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.
- {
- "status": "FAIL",
- "code": 400,
- "result": [],
- "errors": [
- "Bad request, check params"
- ]
- }
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 ...