Chilkat Online Tools

SQL Server / GP-API Collection / AUT_1.0 3DS1 Not Enrolled

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.

    -- {
    --   "account_name": "{{acc_name}}",
    --   "reference": "abcdendfjknbkjfdns",
    --   "channel": "CNP",
    --   "amount": "5",
    --   "currency": "EUR",
    --   "country": "US",
    --   "source": "BROWSER",
    --   "payment_method": {
    --     "card": {
    --       "number": "4917000000000087",
    --       "expiry_month": "12",
    --       "expiry_year": "25"
    --     }
    --   },
    --   "notifications": {
    --     "challenge_return_url": "https://ensi808o85za.x.pipedream.net/",
    --     "three_ds_method_return_url": "https://ensi808o85za.x.pipedream.net/"
    --   }
    -- }

    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, 'account_name', '{{acc_name}}'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'reference', 'abcdendfjknbkjfdns'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'channel', 'CNP'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'amount', '5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'currency', 'EUR'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'country', 'US'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'source', 'BROWSER'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment_method.card.number', '4917000000000087'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment_method.card.expiry_month', '12'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment_method.card.expiry_year', '25'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'notifications.challenge_return_url', 'https://ensi808o85za.x.pipedream.net/'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'notifications.three_ds_method_return_url', 'https://ensi808o85za.x.pipedream.net/'

    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-GP-Version', '{{version}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://{{url}}/ucp/authentications', '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: Bearer <access_token>"
	-H "X-GP-Version: {{version}}"
	-d '{
    "account_name": "{{acc_name}}",
    "reference": "abcdendfjknbkjfdns",
    "channel": "CNP",
    "amount": "5",
    "currency": "EUR",
    "country": "US",
    "source": "BROWSER",
    "payment_method": {
        "card": {
            "number": "4917000000000087",
            "expiry_month": "12",
            "expiry_year": "25"
        }
    },
    "notifications": {
        "challenge_return_url": "https://ensi808o85za.x.pipedream.net/",
        "three_ds_method_return_url": "https://ensi808o85za.x.pipedream.net/"
    }
}'
https://{{url}}/ucp/authentications

Postman Collection Item JSON

{
  "name": "AUT_1.0 3DS1 Not Enrolled",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "//Json Parse",
          "//Json Parse",
          "pm.environment.unset(\"aut_id\");",
          "",
          "",
          "var jsonData = JSON.parse(responseBody);",
          "",
          "var pareq = jsonData.three_ds.challenge_value; ",
          "var redirect_url = jsonData.three_ds.redirect_url; ",
          "",
          "postman.setEnvironmentVariable(\"aut_id\", jsonData.id);",
          "postman.setEnvironmentVariable(\"reference\", jsonData.reference);",
          "postman.setEnvironmentVariable(\"act_id\", jsonData.action.id);",
          "",
          "",
          "console.log(pareq);",
          "pm.test(\"set  html\",function(){",
          "    var template='<!DOCTYPE html> <html> <head> <title>Sample 3DSecure Page</title> </head> <body><form action='+redirect_url+' method=\"POST\">  <input type=\"hidden\" name=\"challenge_value\" value= '+pareq+' /> <input type=\"submit\" value=\"Submit\"> </form> </body> </html>'     // save your html in the template and then     ",
          "    pm.visualizer.set(template);     // set that template to pm.visualizer",
          "})",
          "//https://test.portal.gpwebpay.com/pay-sim-gpi/sim/acs",
          "//https://apis-dev.globalpay.com/testing/acs"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "auth": {
      "type": "oauth2",
      "oauth2": [
        {
          "key": "accessToken",
          "value": "{{token}}",
          "type": "string"
        },
        {
          "key": "addTokenTo",
          "value": "header",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "X-GP-Version",
        "type": "text",
        "value": "{{version}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"account_name\": \"{{acc_name}}\",\n    \"reference\": \"abcdendfjknbkjfdns\",\n    \"channel\": \"CNP\",\n    \"amount\": \"5\",\n    \"currency\": \"EUR\",\n    \"country\": \"US\",\n    \"source\": \"BROWSER\",\n    \"payment_method\": {\n        \"card\": {\n            \"number\": \"4917000000000087\",\n            \"expiry_month\": \"12\",\n            \"expiry_year\": \"25\"\n        }\n    },\n    \"notifications\": {\n        \"challenge_return_url\": \"https://ensi808o85za.x.pipedream.net/\",\n        \"three_ds_method_return_url\": \"https://ensi808o85za.x.pipedream.net/\"\n    }\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://{{url}}/ucp/authentications",
      "protocol": "https",
      "host": [
        "{{url}}"
      ],
      "path": [
        "ucp",
        "authentications"
      ]
    },
    "description": "This request must be sent in order to verify what version of 3DS the payer is set up with i.e 3DS1 or 3DS2. In this specific request, the response comes back saying this customer has NOT been enrolled in 3DS. You can see in the response there is a liability shift along with an ECI value of 6 which means the cardholder is not 3DS enrolled.\r\n\r\nFor more information on this request, please visit the following Dev Portal link: https://developer.globalpay.com/api/authentications#/Check%20Availability/check3DSAvailability"
  },
  "response": [
  ]
}