Back to Collection Items
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = Server.CreateObject("Chilkat.Http")
' Use this online tool to generate code from sample JSON: Generate Code to Create JSON
' The following JSON is sent in the request body.
' {
' "account_name": "dcc",
' "type": "SALE",
' "channel": "CNP",
' "amount": "10",
' "currency": "EUR",
' "country": "GB",
' "capture_mode": "AUTO",
' "reference": "TRANS-20180114123459948",
' "payment_method": {
' "first_name": "James",
' "last_name": "Mason",
' "entry_mode": "ECOM",
' "card": {
' "number": "4006097467207025",
' "expiry_month": "12",
' "expiry_year": "30",
' "cvv": "996"
' }
' },
' "currency-conversion": {
' "id": "{{ccs_id}}"
' }
' }
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("account_name","dcc")
success = json.UpdateString("type","SALE")
success = json.UpdateString("channel","CNP")
success = json.UpdateString("amount","10")
success = json.UpdateString("currency","EUR")
success = json.UpdateString("country","GB")
success = json.UpdateString("capture_mode","AUTO")
success = json.UpdateString("reference","TRANS-20180114123459948")
success = json.UpdateString("payment_method.first_name","James")
success = json.UpdateString("payment_method.last_name","Mason")
success = json.UpdateString("payment_method.entry_mode","ECOM")
success = json.UpdateString("payment_method.card.number","4006097467207025")
success = json.UpdateString("payment_method.card.expiry_month","12")
success = json.UpdateString("payment_method.card.expiry_year","30")
success = json.UpdateString("payment_method.card.cvv","996")
success = json.UpdateString("currency-conversion.id","{{ccs_id}}")
http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "X-GP-Version","{{version}}"
' Adds the "Authorization: Bearer {{token}}" header.
http.AuthToken = "{{token}}"
' resp is a Chilkat.HttpResponse
Set resp = http.PostJson3("https://{{url}}/ucp/transactions","application/json",json)
If (http.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( resp.StatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
%>
</body>
</html>
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "X-GP-Version: {{version}}"
-H "Authorization: Bearer {{token}}"
-d '{
"account_name": "dcc",
"type": "SALE",
"channel": "CNP",
"amount": "10",
"currency": "EUR",
"country": "GB",
"capture_mode": "AUTO",
"reference": "TRANS-20180114123459948",
"payment_method": {
"first_name": "James",
"last_name": "Mason",
"entry_mode": "ECOM",
"card": {
"number": "4006097467207025",
"expiry_month": "12",
"expiry_year": "30",
"cvv": "996"
}
},
"currency-conversion": {
"id": "{{ccs_id}}"
}
}'
https://{{url}}/ucp/transactions
Postman Collection Item JSON
{
"name": "DCC_1.2 ECOM Sale",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-GP-Version",
"value": "{{version}}",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"account_name\": \"dcc\",\n \"type\": \"SALE\",\n \"channel\": \"CNP\",\n \"amount\": \"10\",\n \"currency\": \"EUR\",\n \"country\": \"GB\",\n \"capture_mode\": \"AUTO\",\n \"reference\": \"TRANS-20180114123459948\",\n \"payment_method\": {\n \"first_name\": \"James\",\n \"last_name\": \"Mason\",\n \"entry_mode\": \"ECOM\",\n \"card\": {\n \"number\": \"4006097467207025\",\n \"expiry_month\": \"12\",\n \"expiry_year\": \"30\",\n \"cvv\": \"996\"\n }\n },\n \"currency-conversion\": {\n \"id\": \"{{ccs_id}}\"\n }\n}"
},
"url": {
"raw": "https://{{url}}/ucp/transactions",
"protocol": "https",
"host": [
"{{url}}"
],
"path": [
"ucp",
"transactions"
]
}
},
"response": [
]
}