Chilkat Online Tools

unicodeCpp / Razorpay APIs / Refunds

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    http.put_BasicAuth(true);
    http.put_Login(L"username");
    http.put_Password(L"password");

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "amount": 100,
    //   "reverse_all": 1
    // }

    CkJsonObjectW json;
    json.UpdateInt(L"amount",100);
    json.UpdateInt(L"reverse_all",1);

    http.SetRequestHeader(L"content-type",L"application/json");

    CkHttpResponseW *resp = http.PostJson3(L"https://api.razorpay.com/v1/payments/{pay_id}/refund",L"application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X POST
	-u 'username:password'
	-H "content-type: application/json"
	-d '{
    "amount": 100,
    "reverse_all": 1
}'
https://api.razorpay.com/v1/payments/{pay_id}/refund

Postman Collection Item JSON

{
  "name": "Refunds",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "content-type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"amount\": 100,\n    \"reverse_all\": 1\n}"
    },
    "url": {
      "raw": "https://api.razorpay.com/v1/payments/{pay_id}/refund",
      "protocol": "https",
      "host": [
        "api",
        "razorpay",
        "com"
      ],
      "path": [
        "v1",
        "payments",
        "{pay_id}",
        "refund"
      ]
    },
    "description": "Use this [API](https://razorpay.com/docs/api/route/#refund-payments-and-reverse-transfer-from-a-linked) to refund payments to customers and reverse transfers from linked accounts."
  },
  "response": [
  ]
}