SQL Server / GP-API Collection / DIA_1.0 Get Disputes List
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_size', 1000
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'order', 'ASC'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'stage', 'CHARGEBACK'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'from_stage_time_created', '2020-06-09'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-GP-Version', '{{version}}'
-- Adds the "Authorization: Bearer {{token}}" header.
EXEC sp_OASetProperty @http, 'AuthToken', '{{token}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'idempotency-key', '12345'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://{{url}}/ucp/disputes', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
END
GO
Curl Command
curl -G -d "page_size=1000"
-d "order=ASC"
-d "stage=CHARGEBACK"
-d "from_stage_time_created=2020-06-09"
-H "Content-Type: application/json"
-H "Authorization: Bearer {{token}}"
-H "Accept: application/json"
-H "X-GP-Version: {{version}}"
-H "idempotency-key: 12345"
https://{{url}}/ucp/disputes
Postman Collection Item JSON
{
"name": "DIA_1.0 Get Disputes List",
"event": [
{
"listen": "test",
"script": {
"exec": [
"\r",
"var totalAdjDebitAmount=0;\r",
"var totalAdjCreditAmount=0;\r",
"var totalAdjEvenAmount=0;\r",
"var totalAdjDebitCount=0;\r",
"var totalAdjCreditCount=0;\r",
"var totalAdjEvenCount=0;\r",
"var totalRecordCount=0;\r",
"var i=0;\r",
"\r",
"var jsonData = JSON.parse(responseBody);\r",
"\r",
"\r",
"for(i = 0; i < jsonData.disputes.length; i++) {\r",
"\r",
" var obj = jsonData.disputes[i];\r",
" fundingType = String(obj.last_adjustment_funding);\r",
" \r",
" if (fundingType == \"DEBIT\"){\r",
" totalAdjDebitAmount += parseInt(obj.last_adjustment_amount);\r",
" totalAdjDebitCount++;\r",
" }else if(fundingType == \"CREDIT\") {\r",
" totalAdjCreditAmount += parseInt(obj.last_adjustment_amount);\r",
" totalAdjCreditCount++;\r",
" \r",
" }else {\r",
" totalAdjEvenAmount += parseInt(obj.last_adjustment_amount);\r",
" totalAdjEvenCount++;\r",
" \r",
" }\r",
" totalRecordCount++;\r",
"}\r",
"\r",
"totalAdjCreditAmount = 0 - totalAdjCreditAmount;\r",
"\r",
"console.log(\"dr amt: \" + totalAdjDebitAmount);\r",
"console.log(\"dr cnt: \" + totalAdjDebitCount);\r",
"\r",
"console.log(\"cr amt: \" + totalAdjCreditAmount);\r",
"console.log(\"cr cnt: \" + totalAdjCreditCount);\r",
"\r",
"console.log(\"ev amt: \" + totalAdjEvenAmount);\r",
"console.log(\"ev cnt: \" + totalAdjEvenCount);\r",
"\r",
"console.log(\"ttl cnt: \" + totalRecordCount);\r",
"console.log(\"ttl amt (sum): \" + (totalAdjDebitAmount + totalAdjCreditAmount + totalAdjEvenAmount));\r",
"\r",
"console.log(\"ttl cnt (sum): \" + (totalAdjDebitCount + totalAdjCreditCount + totalAdjEvenCount));\r",
"\r",
"console.log(\"ttl cnt: \" + totalRecordCount);\r",
"console.log(\"ttl amt (sum): \" + (totalAdjDebitAmount + totalAdjCreditAmount));\r",
"\r",
"console.log(\"ttl cnt (sum): \" + (totalAdjDebitCount + totalAdjCreditCount));\r",
"\r",
"console.log(\" ********** \");\r",
"\r",
"\r",
"tests[\"Response time is acceptable\"] = _.inRange(responseTime, 100, 1500); \r",
"\r",
"\r",
"pm.test(\"Successful POST request\", function () {\r",
" pm.expect(pm.response.code).to.be.oneOf([200,201,202]);\r",
"});\r",
"\r",
"pm.test(\"Status code name has string\", function () {\r",
" pm.response.to.have.status(\"OK\");\r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text",
"disabled": true
},
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
},
{
"key": "Accept",
"value": "application/json",
"type": "text"
},
{
"key": "X-GP-Version",
"value": "{{version}}",
"type": "text"
},
{
"key": "idempotency-key",
"value": "12345",
"type": "text"
}
],
"url": {
"raw": "https://{{url}}/ucp/disputes?page_size=1000&order=ASC&stage=CHARGEBACK&from_stage_time_created=2020-06-09",
"protocol": "https",
"host": [
"{{url}}"
],
"path": [
"ucp",
"disputes"
],
"query": [
{
"key": "page_size",
"value": "1000"
},
{
"key": "to_stage_time_created",
"value": "2020-01-29",
"disabled": true
},
{
"key": "from_adjustment_time_created",
"value": "2020-01-01",
"disabled": true
},
{
"key": "to_adjustment_time_created",
"value": "2020-03-31",
"disabled": true
},
{
"key": "order_by",
"value": "id",
"disabled": true
},
{
"key": "order",
"value": "ASC"
},
{
"key": "last_adjustment_funding",
"value": "CREDIT",
"disabled": true
},
{
"key": "result",
"value": "WON",
"disabled": true
},
{
"key": "stage",
"value": "CHARGEBACK"
},
{
"key": "stage",
"value": "REVERSAL",
"disabled": true
},
{
"key": "stage",
"value": "SECOND_CHARGEBACK",
"disabled": true
},
{
"key": "id",
"value": "",
"disabled": true
},
{
"key": "system.mid",
"value": "",
"disabled": true
},
{
"key": "to_stage_time_created",
"value": "2020-03-31",
"disabled": true
},
{
"key": "system.hierarchy",
"value": "",
"disabled": true
},
{
"key": "from_stage_time_created",
"value": "2020-06-09"
},
{
"key": "from_status_time_created",
"value": "2020-07-25",
"disabled": true
},
{
"key": "order_by",
"value": "arn",
"disabled": true
}
]
},
"description": "This request retrieves all disputes from GP that have been made by a Payer or a Payer's Bank. User can pass in certain criteria in the query string in order to return specific types of disputes such as:\r\n- Chargebacks\r\n- Retrieval\r\n- Reversal\r\n- Arbitration\r\n- & more\r\n\r\nTo see further criteria, visit https://developer.globalpay.com/api/disputes#/Disputes/get_disputes\r\n\r\nAdditionally, the user can change page size, how the response is ordered and change the date from when the disputes date back too.\r\n\r\n\r\nIn the response received back, you will see the merchant_id along with the disputes and their reason code/description for the dispute."
},
"response": [
]
}