Chilkat Online Tools

SQL Server / Bond APIs / create a dispute

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

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "customer_id": "{{customer_id}}",
    --   "transaction_id": "{{transaction_id}}",
    --   "email": "no-reply@bond.tech",
    --   "phone": "1234567890",
    --   "dispute_reason": "FRAUD",
    --   "dispute_details": "card stolen",
    --   "file_attachments": [
    --     {
    --       "filename": "screenshot",
    --       "file": "ewogICJkaXNwdXRlX2lkIjogIjA2YzMzZTMxLTA4MTEtNDZhZC05NTg4LTljNWQwOTUzNzM3MiIsCiAgImRpc3B1dGVfc3RhdHVzIjogInN1Ym1pdHRlZCIKfQ=="
    --     }
    --   ]
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'customer_id', '{{customer_id}}'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'transaction_id', '{{transaction_id}}'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'email', 'no-reply@bond.tech'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'phone', '1234567890'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'dispute_reason', 'FRAUD'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'dispute_details', 'card stolen'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'file_attachments[0].filename', 'screenshot'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'file_attachments[0].file', 'ewogICJkaXNwdXRlX2lkIjogIjA2YzMzZTMxLTA4MTEtNDZhZC05NTg4LTljNWQwOTUzNzM3MiIsCiAgImRpc3B1dGVfc3RhdHVzIjogInN1Ym1pdHRlZCIKfQ=='

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Identity', '{{identity}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://{{environment}}.bond.tech/api/v0/disputes', 'application/json', @json
    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 @json
        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 @json


END
GO

Curl Command

curl -X POST
	-H "Authorization: {{authorization}}"
	-H "Identity: {{identity}}"
	-d '{
  "customer_id": "{{customer_id}}",
  "transaction_id": "{{transaction_id}}",
  "email": "no-reply@bond.tech",
  "phone": "1234567890",
  "dispute_reason": "FRAUD",
  "dispute_details": "card stolen",
  "file_attachments" :[
      {
      "filename": "screenshot",
      "file": "ewogICJkaXNwdXRlX2lkIjogIjA2YzMzZTMxLTA4MTEtNDZhZC05NTg4LTljNWQwOTUzNzM3MiIsCiAgImRpc3B1dGVfc3RhdHVzIjogInN1Ym1pdHRlZCIKfQ=="
        }
    ]
}'
https://{{environment}}.bond.tech/api/v0/disputes

Postman Collection Item JSON

{
  "name": "create a dispute",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "{{authorization}}",
        "type": "text"
      },
      {
        "key": "Identity",
        "value": "{{identity}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"customer_id\": \"{{customer_id}}\",\n  \"transaction_id\": \"{{transaction_id}}\",\n  \"email\": \"no-reply@bond.tech\",\n  \"phone\": \"1234567890\",\n  \"dispute_reason\": \"FRAUD\",\n  \"dispute_details\": \"card stolen\",\n  \"file_attachments\" :[\n      {\n      \"filename\": \"screenshot\",\n      \"file\": \"ewogICJkaXNwdXRlX2lkIjogIjA2YzMzZTMxLTA4MTEtNDZhZC05NTg4LTljNWQwOTUzNzM3MiIsCiAgImRpc3B1dGVfc3RhdHVzIjogInN1Ym1pdHRlZCIKfQ==\"\n        }\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://{{environment}}.bond.tech/api/v0/disputes",
      "protocol": "https",
      "host": [
        "{{environment}}",
        "bond",
        "tech"
      ],
      "path": [
        "api",
        "v0",
        "disputes"
      ],
      "query": [
        {
          "key": "page",
          "value": "2",
          "disabled": true
        },
        {
          "key": "per_page",
          "value": "5",
          "disabled": true
        }
      ]
    },
    "description": "Retrieve Card to Card Transfer"
  },
  "response": [
    {
      "name": "example",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "{{authorization}}",
            "type": "text"
          },
          {
            "key": "Identity",
            "value": "{{identity}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"customer_id\": \"{{customer_id}}\",\n  \"transaction_id\": \"{{transaction_id}}\",\n  \"email\": \"no-reply@bond.tech\",\n  \"phone\": \"1234567890\",\n  \"dispute_reason\": \"FRAUD\",\n  \"dispute_details\": \"card stolen\",\n  \"file_attachments\" :[\n      {\n      \"filename\": \"screenshot\",\n      \"file\": \"ewogICJkaXNwdXRlX2lkIjogIjA2YzMzZTMxLTA4MTEtNDZhZC05NTg4LTljNWQwOTUzNzM3MiIsCiAgImRpc3B1dGVfc3RhdHVzIjogInN1Ym1pdHRlZCIKfQ==\"\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://{{environment}}.bond.tech/api/v0/disputes\n",
          "protocol": "https",
          "host": [
            "{{environment}}",
            "bond",
            "tech"
          ],
          "path": [
            "api",
            "v0",
            "disputes\n"
          ],
          "query": [
            {
              "key": "card_account_id",
              "value": "b18f94bc-0d7c-456e-a2e7-19e68393b64f",
              "disabled": true
            }
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n  \"dispute_id\": \"06c33e31-0811-46ad-9588-9c5d09537372\",\n  \"dispute_status\": \"submitted\"\n}"
    }
  ]
}