Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' 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 = 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.
' {
' "merchant_id": "{{mer_id}}",
' "account_id": "{{tra_id}}",
' "model": "FROM_TRANSACTION_CURRENCY",
' "transaction_type": "SALE",
' "channel": "CNP",
' "amount": "10",
' "currency": "EUR",
' "country": "GB",
' "reference": "TRANS-20180114123459878",
' "payment_method": {
' "name": "Jane Doe",
' "entry_mode": "ECOM",
' "card": {
' "number": "4006097467207025",
' "expiry_month": "12",
' "expiry_year": "20",
' "cvv": "233"
' }
' }
' }
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = CreateObject("Chilkat.JsonObject")
success = json.UpdateString("merchant_id","{{mer_id}}")
success = json.UpdateString("account_id","{{tra_id}}")
success = json.UpdateString("model","FROM_TRANSACTION_CURRENCY")
success = json.UpdateString("transaction_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("reference","TRANS-20180114123459878")
success = json.UpdateString("payment_method.name","Jane Doe")
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","20")
success = json.UpdateString("payment_method.card.cvv","233")
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/currency-conversions","application/json",json)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)
outFile.Close
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "X-GP-Version: {{version}}"
-H "Authorization: Bearer {{token}}"
-d '{
"merchant_id": "{{mer_id}}",
"account_id": "{{tra_id}}",
"model": "FROM_TRANSACTION_CURRENCY",
"transaction_type": "SALE",
"channel": "CNP",
"amount": "10",
"currency": "EUR",
"country": "GB",
"reference": "TRANS-20180114123459878",
"payment_method": {
"name": "Jane Doe",
"entry_mode": "ECOM",
"card": {
"number": "4006097467207025",
"expiry_month": "12",
"expiry_year": "20",
"cvv": "233"
}
}
}'
https://{{url}}/ucp/currency-conversions
Postman Collection Item JSON
{
"name": "DCC_1.0 Rate Lookup",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);\r",
"\r",
"postman.setEnvironmentVariable(\"ccs_id\", jsonData.id);"
],
"type": "text/javascript"
}
}
],
"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": "{\r\n \"merchant_id\": \"{{mer_id}}\",\r\n \"account_id\": \"{{tra_id}}\",\r\n \"model\": \"FROM_TRANSACTION_CURRENCY\",\r\n \"transaction_type\": \"SALE\",\r\n \"channel\": \"CNP\",\r\n \"amount\": \"10\",\r\n \"currency\": \"EUR\",\r\n \"country\": \"GB\",\r\n \"reference\": \"TRANS-20180114123459878\",\r\n \"payment_method\": {\r\n \"name\": \"Jane Doe\",\r\n \"entry_mode\": \"ECOM\",\r\n \"card\": {\r\n \"number\": \"4006097467207025\",\r\n \"expiry_month\": \"12\",\r\n \"expiry_year\": \"20\",\r\n \"cvv\": \"233\"\r\n }\r\n }\r\n}"
},
"url": {
"raw": "https://{{url}}/ucp/currency-conversions",
"protocol": "https",
"host": [
"{{url}}"
],
"path": [
"ucp",
"currency-conversions"
]
}
},
"response": [
]
}