Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
CkHttp_putBasicAuth(http,TRUE);
CkHttp_putLogin(http,"100100248");
CkHttp_putPassword(http,"117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b");
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "requestId": "merchant-generated-request-guid",
// "amount": {
// "amount": "37.00",
// "currency": "USD"
// },
// "merchantReference": "merchant-order-number"
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"requestId","merchant-generated-request-guid");
CkJsonObject_UpdateString(json,"amount.amount","37.00");
CkJsonObject_UpdateString(json,"amount.currency","USD");
CkJsonObject_UpdateString(json,"merchantReference","merchant-order-number");
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
resp = CkHttp_PostJson3(http,"https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/refund","application/json",json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
}
Curl Command
curl -X POST
-u '100100248:117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b'
-H "Content-Type: application/json"
-d '{
"requestId": "merchant-generated-request-guid",
"amount" : {
"amount" : "37.00",
"currency" : "USD"
},
"merchantReference" : "merchant-order-number"
}'
https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/refund
Postman Collection Item JSON
{
"name": "Create Refund",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"requestId\": \"merchant-generated-request-guid\",\n\t\"amount\" : {\n\t\t\"amount\" : \"37.00\",\n\t\t\"currency\" : \"USD\"\n\t\t},\n\t\"merchantReference\" : \"merchant-order-number\"\n}"
},
"url": {
"raw": "https://api.us-sandbox.afterpay.com/v2/payments/{{id}}/refund",
"protocol": "https",
"host": [
"api",
"us-sandbox",
"afterpay",
"com"
],
"path": [
"v2",
"payments",
"{{id}}",
"refund"
]
},
"description": "This resource performs a full or partial refund.\n\nThe resource is idempotent if a unique requestId is provided."
},
"response": [
]
}