Swift3 / GP-API Collection / DCC_1.3 ECOM Refund standalone
Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// 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}}",
// "type": "REFUND",
// "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}}"
// }
// }
let json = CkoJsonObject()!
json.update("merchant_id", value: "{{mer_id}}")
json.update("account_id", value: "{{tra_id}}")
json.update("type", value: "REFUND")
json.update("channel", value: "CNP")
json.update("amount", value: "10")
json.update("currency", value: "EUR")
json.update("country", value: "GB")
json.update("capture_mode", value: "AUTO")
json.update("reference", value: "TRANS-20180114123459948")
json.update("payment_method.first_name", value: "James")
json.update("payment_method.last_name", value: "Mason")
json.update("payment_method.entry_mode", value: "ECOM")
json.update("payment_method.card.number", value: "4006097467207025")
json.update("payment_method.card.expiry_month", value: "12")
json.update("payment_method.card.expiry_year", value: "30")
json.update("payment_method.card.cvv", value: "996")
json.update("currency_conversion.id", value: "{{ccs_id}}")
http.setRequestHeader("Content-Type", value: "application/json")
http.setRequestHeader("X-GP-Version", value: "{{version}}")
// Adds the "Authorization: Bearer {{token}}" header.
http.authToken = "{{token}}"
var resp: CkoHttpResponse? = http.postJson3("https://{{url}}/ucp/transactions", contentType: "application/json", json: json)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
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}}",
"type": "REFUND",
"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.3 ECOM Refund standalone",
"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 \"merchant_id\": \"{{mer_id}}\",\n \"account_id\": \"{{tra_id}}\",\n \"type\": \"REFUND\",\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": [
]
}