Chilkat Online Tools

DataFlex / GP-API Collection / DIA_1.0 Get Disputes List

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vQueryParams
    Handle hoQueryParams
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1

    // 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

    Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
    If (Not(IsComObjectCreated(hoQueryParams))) Begin
        Send CreateComObject of hoQueryParams
    End
    Get ComUpdateInt Of hoQueryParams "page_size" 1000 To iSuccess
    Get ComUpdateString Of hoQueryParams "order" "ASC" To iSuccess
    Get ComUpdateString Of hoQueryParams "stage" "CHARGEBACK" To iSuccess
    Get ComUpdateString Of hoQueryParams "from_stage_time_created" "2020-06-09" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "X-GP-Version" "{{version}}"
    // Adds the "Authorization: Bearer {{token}}" header.
    Set ComAuthToken Of hoHttp To "{{token}}"
    Send ComSetRequestHeader To hoHttp "idempotency-key" "12345"
    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoQueryParams to vQueryParams
    Get pvComObject of hoResp to vResp
    Get ComHttpParams Of hoHttp "GET" "https://{{url}}/ucp/disputes" vQueryParams vResp To iSuccess
    If (iSuccess = 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


End_Procedure

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": [
  ]
}