Back to Collection Items
var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;
begin
// 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.
// {
// "token": "{{token}}",
// "merchantReference": "merchant-order-number"
// }
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'token','{{token}}');
CkJsonObject_UpdateString(json,'merchantReference','merchant-order-number');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');
CkHttp_SetRequestHeader(http,'Accept','application/json');
resp := CkHttp_PostJson3(http,'https://api.us-sandbox.afterpay.com/v2/payments/auth','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
Curl Command
curl -X POST
-u '100100248:117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b'
-H "Accept: application/json"
-H "Content-Type: application/json"
-d '{
"token": "{{token}}",
"merchantReference": "merchant-order-number"
}'
https://api.us-sandbox.afterpay.com/v2/payments/auth
Postman Collection Item JSON
{
"name": "Auth",
"event": [
{
"listen": "test",
"script": {
"id": "ce54d0ec-48f7-43ed-af8e-165c898c6d39",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"id\", jsonData.id);",
"postman.setEnvironmentVariable(\"merchantReference\", jsonData.merchantReference);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"token\": \"{{token}}\",\n\t\"merchantReference\": \"merchant-order-number\"\n}"
},
"url": {
"raw": "https://api.us-sandbox.afterpay.com/v2/payments/auth",
"protocol": "https",
"host": [
"api",
"us-sandbox",
"afterpay",
"com"
],
"path": [
"v2",
"payments",
"auth"
]
},
"description": "This resource creates a payment authorisation, to be captured at a later date. The authorisation has an expiration date and time. This is returned in the events list for the AUTHED payment event type.\n\nThe authorisation resource is idempotent based on the token. The idempotent nature of the payment resources allows for the safe retry of requests, guaranteeing the operation is only performed once."
},
"response": [
]
}