Chilkat Online Tools

Foxpro / GP-API Collection / TRA_7.3 APM PayPal Describe

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("X-GP-Version","{{version}}")
* Adds the "Authorization: Bearer {{token}}" header.
loHttp.AuthToken = "{{token}}"
loHttp.SetRequestHeader("idempotency-key","12345")
loHttp.SetRequestHeader("Accept","application/json")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://{{url}}/ucp/transactions/{{trn_id}}/describe",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

? "Response status code = " + STR(loHttp.LastStatus)
? loSbResponseBody.GetAsString()

RELEASE loHttp
RELEASE loSbResponseBody

Curl Command

curl -X GET
	-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/transactions/{{trn_id}}/describe

Postman Collection Item JSON

{
  "name": "TRA_7.3 APM  PayPal Describe",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var jsonData = JSON.parse(responseBody);\r",
          "postman.setEnvironmentVariable(\"trn_id\", jsonData.id);\r",
          "postman.setEnvironmentVariable(\"reference\", jsonData.reference);\r",
          "tests[\"Transaction ID \" + pm.environment.get(\"trn_id\")] = true;\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"
      }
    },
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          "var str = String(\"00000000\"+ Math.floor(Math.random()*100000000) + 1).slice(-8);",
          "",
          "pm.environment.set(\"reference\",str);"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{token}}"
      },
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "X-GP-Version",
        "type": "text",
        "value": "{{version}}"
      },
      {
        "key": "idempotency-key",
        "type": "text",
        "value": "12345",
        "disabled": true
      }
    ],
    "body": {
      "mode": "raw",
      "raw": ""
    },
    "url": {
      "raw": "https://{{url}}/ucp/transactions/{{trn_id}}/describe",
      "protocol": "https",
      "host": [
        "{{url}}"
      ],
      "path": [
        "ucp",
        "transactions",
        "{{trn_id}}",
        "describe"
      ]
    },
    "description": "If capture mode on initiate paypal request was set to 'Capture Later', you must complete capture by sending this request.\r\n\r\nFor more information on this request, please visit the following Dev Portal link: https://developer.globalpay.com/ecommerce/paypal#api"
  },
  "response": [
  ]
}