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.
// {
// "payment_method": {
// "credit_card_cvv": "123",
// "token": "{{token}}",
// "type": "tokenized"
// }
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "payment_method.credit_card_cvv" "123" To iSuccess
Get ComUpdateString Of hoJson "payment_method.token" "{{token}}" To iSuccess
Get ComUpdateString Of hoJson "payment_method.type" "tokenized" 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}}/authorizations" "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 '{
"payment_method": {
"credit_card_cvv": "123",
"token": "{{token}}",
"type": "tokenized"
}
}'
https://api.paymentsos.com/payments/{{paymentid}}/authorizations
Postman Collection Item JSON
{
"name": "3. Create Authorization",
"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": "{\t\n\t\"payment_method\": {\n \"credit_card_cvv\": \"123\",\n \"token\": \"{{token}}\",\n \"type\": \"tokenized\"\n }\n}"
},
"url": {
"raw": "https://api.paymentsos.com/payments/{{paymentid}}/authorizations",
"protocol": "https",
"host": [
"api",
"paymentsos",
"com"
],
"path": [
"payments",
"{{paymentid}}",
"authorizations"
]
},
"description": "Create a new authorization"
},
"response": [
]
}