Manual payment

Manual payment

For this service, the following endpoint must be consumed: 

  1. 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

  1. {
  2.   "subscriptionId": "id returned when subscription was created",
  3.   "merchantId": "your merchantid",
  4.   "secret": "your secret",
  5. }

Parameters description

  1. subscriptionIdIdentifier received in response when a subscription is created
  2. secret: secret provided by Greenpay.
  3. merchant: merchantId provided by Greenpay.
2. Send manual payment request
 

An HTTP POST request must be sent to the manual payment endpoint, with the JSON containing the subscription data.


Once the 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”. The following 

code shows an example of the response received. 

  1. {
  2.     "status": "SUCCESS",
  3.     "code": 200,
  4.     "result": {
  5.         "status": "approved",
  6.         "orderStatus": "ACTIVE",
  7.         "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
  8.         "order": {
  9.             "order_reference": "9541b344c3d45d421acd454d61251cde_2",
  10.             "subscriptionId": "9541b344c3d45d421acd454d61251cde",
  11.             "user": "UserBot",
  12.             "amount": 100,
  13.             "currency": "USD",
  14.             "date": "2018-12-11T06:00:00.000Z",
  15.             "authorization": "533735",
  16.             "details": "",
  17.             "errors": [],
  18.             "reason": "Manual payment"
  19.         }
  20.     }
  21. }
Below is a javascript example of the subscriptions manual payment endpoint request. This function also obtains the JSON’s “body” received in response. 

  1. var unirest = require("unirest");

  2. var req = unirest("POST", "
  3. https://sandbox-merchant.greenpay.me/subscriptions/pay");

  4. req.headers({
  5.  "cache-control": "no-cache",
  6.  "Content-Type": "application/json"
  7. });

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

  14. req.end(function (res) {
  15.  if (res.error) throw new Error(res.error);

  16.  console.log(res.body);
  17. });

  18. req.headers({
  19.  "cache-control": "no-cache",
  20.  "Content-Type": "application/json"
  21. });

  22. req.type("json");
  23. req.send({
  24.  "subscriptionId": "b69cd5773eac06bf25a702bac02e8079",
  25.  "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
  26.  "merchantId": "143b28c9-32ad-4635-8ed8-d6abfb6863a0"
  27. });

  28. req.end(function (res) {
  29.  if (res.error) throw new Error(res.error);

  30.  console.log(res.body);
  31. });
3. Possible errors 

  1. Merchant doesn't exist
When trying to update a subscription with invalid credentials, the response returned will be the following. 

Invalid credentials - response example

  1. {
  2.   "code": 500,
  3.   "status": "FAIL",
  4.   "result": [],
  5.   "errors": [
  6.       ""Merchant doesn't exist"."
  7.   ]
  8. }
    • Subscription not found. Impossible to manually pay.

    When trying to manually pay for an inactive subscription or in the On Hold state, the response returned will be the following



    Subscription not found response example
    1. {
    2.   "code": 500,
    3.   "status": "FAIL",
    4.   "result": [],
    5.   "errors": [
    6.       "Subscription not found. Impossible to manually pay."
    7.   ]
    8. }


      • Related Articles

      • 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 ...
      • Webform payment process

        To consider To use the card payment form, the following aspects should be considered: The form is available at: Sandbox: https://sandbox-checkoutform.greenpay.me/ Producción: https://checkout-form.greenpay.me/ Get a session and token of a valid ...
      • 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 ...
      • 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 {   ...