Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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": 3500
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateInt Of hoJson "amount" 3500 To iSuccess
Send ComSetRequestHeader To hoHttp "x-payments-os-env" "{{x-payments-os-env}}"
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
Send ComSetRequestHeader To hoHttp "app_id" "{{app_id}}"
Send ComSetRequestHeader To hoHttp "private_key" "{{private_key}}"
Send ComSetRequestHeader To hoHttp "idempotency_key" "{{$randomInt}}"
Send ComSetRequestHeader To hoHttp "api-version" "1.3.0"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://api.paymentsos.com/payments/{{paymentid}}/captures" "application/json" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
Curl Command
curl -X POST
-H "app_id: {{app_id}}"
-H "private_key: {{private_key}}"
-H "Content-Type: application/json"
-H "api-version: 1.3.0"
-H "x-payments-os-env: {{x-payments-os-env}}"
-H "idempotency_key: {{$randomInt}}"
-d '{
"amount": 3500
}'
https://api.paymentsos.com/payments/{{paymentid}}/captures
Postman Collection Item JSON
{
"name": "4. Create Capture",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"captureid\", jsonData.id);"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "app_id",
"value": "{{app_id}}"
},
{
"key": "private_key",
"value": "{{private_key}}"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "api-version",
"value": "1.3.0"
},
{
"key": "x-payments-os-env",
"value": "{{x-payments-os-env}}"
},
{
"key": "idempotency_key",
"value": "{{$randomInt}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"amount\": 3500\n}"
},
"url": {
"raw": "https://api.paymentsos.com/payments/{{paymentid}}/captures",
"protocol": "https",
"host": [
"api",
"paymentsos",
"com"
],
"path": [
"payments",
"{{paymentid}}",
"captures"
]
},
"description": "Create a new capture"
},
"response": [
]
}