Chilkat Online Tools

C / GP-API Collection / TRA_4.4 Reversal for a prev refund

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkHttpResponse resp;

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

    http = CkHttp_Create();

    CkHttp_SetRequestHeader(http,"Content-Type","application/json");
    CkHttp_SetRequestHeader(http,"X-GP-Version","{{version}}");
    // Adds the "Authorization: Bearer {{token}}" header.
    CkHttp_putAuthToken(http,"{{token}}");
    CkHttp_SetRequestHeader(http,"Accept","application/json");

    resp = CkHttp_QuickRequest(http,"POST","https://{{url}}/ucp/transactions/{{refund_trn_id}}/reversal");
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        return;
    }

    printf("%d\n",CkHttpResponse_getStatusCode(resp));
    printf("%s\n",CkHttpResponse_bodyStr(resp));
    CkHttpResponse_Dispose(resp);


    CkHttp_Dispose(http);

    }

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Authorization: Bearer {{token}}"
	-H "Accept: application/json"
	-H "X-GP-Version: {{version}}"
https://{{url}}/ucp/transactions/{{refund_trn_id}}/reversal

Postman Collection Item JSON

{
  "name": "TRA_4.4 Reversal for a  prev refund",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "pm.test(\"Successful POST request\", function () {\r",
          "    pm.expect(pm.response.code).to.be.oneOf([400]);\r",
          "});\r",
          "\r",
          "pm.test(\"Status code name has string\", function () {\r",
          "    pm.response.to.have.status(\"Bad Request\");\r",
          "});\r",
          "\r",
          "\r",
          "tests[\"Response time is acceptable\"] = _.inRange(responseTime, 100, 1500); \r",
          "\r",
          "pm.test(\"Body matches string\", function () {\r",
          "    pm.expect(pm.response.text()).to.include(\"40010\");\r",
          "});"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "disabled": true
      },
      {
        "key": "Authorization",
        "value": "Bearer {{token}}"
      },
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "X-GP-Version",
        "type": "text",
        "value": "{{version}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": ""
    },
    "url": {
      "raw": "https://{{url}}/ucp/transactions/{{refund_trn_id}}/reversal",
      "protocol": "https",
      "host": [
        "{{url}}"
      ],
      "path": [
        "ucp",
        "transactions",
        "{{refund_trn_id}}",
        "reversal"
      ]
    },
    "description": "This request reverses a previous refund transaction. On success of reversal of refund, status will be \"REVERSED\"\r\n\r\n For more info on a reversed transaction request, visit: https://developer.globalpay.com/api/transactions#/Reverse/post_transactions__id__reversal"
  },
  "response": [
  ]
}