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
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', '100100248'
EXEC sp_OASetProperty @http, 'Password', '117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b'
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, 'UpdateString', @success OUT, 'merchantReferences', 'merchant-order-number'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'ids', '{{id}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', '*/*'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.us-sandbox.afterpay.com/v2/payments', @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 "merchantReferences=merchant-order-number"
-d "ids=%7B%7Bid%7D%7D"
-u '100100248:117f3fe5a01a0e400f3e4782baf8ffa43a9d21e9217a15f50d545bc72480d081ecaecc1d6a42ac7a785b7437232bd4cf62dbee679b78a75a3892547059018f9b'
-H "Accept: */*"
-H "Content-Type: application/json"
https://api.us-sandbox.afterpay.com/v2/payments
Postman Collection Item JSON
{
"name": "List Payments",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "*/*"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "https://api.us-sandbox.afterpay.com/v2/payments?merchantReferences=merchant-order-number&ids={{id}}",
"protocol": "https",
"host": [
"api",
"us-sandbox",
"afterpay",
"com"
],
"path": [
"v2",
"payments"
],
"query": [
{
"key": "fromCreatedDate",
"value": "1970-01-01T00:00:00.000Z",
"disabled": true
},
{
"key": "toCreatedDate",
"value": "2019-11-11T00:00:00.000Z",
"disabled": true
},
{
"key": "tokens",
"value": "ro0ubumh557el6n6pqitjp4c11d9ui77p6mj5i1bgjlep8k8305m",
"disabled": true
},
{
"key": "merchantReferences",
"value": "merchant-order-number"
},
{
"key": "statuses",
"value": "APPROVED",
"disabled": true
},
{
"key": "offset",
"value": "1",
"disabled": true
},
{
"key": "limit",
"value": "250",
"disabled": true
},
{
"key": "orderBy",
"value": "createdAt",
"disabled": true
},
{
"key": "ascending",
"value": "false",
"disabled": true
},
{
"key": "ids",
"value": "{{id}}"
}
]
},
"description": "Get a list of payments for the merchant.\n\nTo retrieve a filtered list of payments, the following request parameters can be included:\n\ntokens\n*optional\n*string[]\n*A list of order tokens. Parameter can be used multiple times to search by multiple ids.\n\nids\n*optional\n*string[]\n*Search by Afterpay payment ID. Parameter can be used multiple times to search by multiple IDs.\n\nmerchantReferences\n*optional\n*string[]\n*Search by merchant references. Parameter can be used multiple times to search by multiple merchant references.\n\nMore documentation available at:\nhttps://docs.afterpay.com.au/online-api-v2-b857508478e7.html#list-payments"
},
"response": [
]
}