If you are using one of the Amazon Pay CV2 API SDKs, your SDK handle authentication for you, using the same keys and credentials as for your payment integration.
In case you have to - or are preferring to - manually sign requests, please start by Getting your Public Key ID. Requests need to be singed with your keys for authentication. Please follow the guide to Signing Requests. The Amazon Pay Scratchpad (US, EU, JP) is also a great resource for this.
Note:For partners: Please reach out to your Amazon Pay Partner Manager or Solution Architect to understand which options are available for the merchants you support.
Step 2: Get a list of generated reports
The Get Reports API will return a list of reports including their metadata. The metadata includes the reportDocumentId. This identifier is required to retrieve the actual report document.
Operation: Get Reports
Request
curl "https://pay-api.amazon.com/live/:version/reports"
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"
curl "https://pay-api.amazon.com/live/:version/reports"
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"
Request parameters
Name
Location
Description
reportTypes (optional)
Type: string (comma-separated list of ReportTypes)
A list of processing statuses used to filter reports.
createdSince (optional)
Type: string (date-time ISO 8601)
Query Parameter
The earliest report creation date and time for reports to include in the response, in ISO 8601 date time format. Reports are retained for a maximum of 90 days.
Default: 90 days
createdUntil (optional)
Type: string (date-time ISO 8601)
Query Parameter
The latest report creation date and time for reports to include in the response, in ISO 8601 date time format. Reports are retained for a maximum of 90 days.
Default: now
pageSize (optional)
Type: number
Query Parameter
The number of reports per page to return. Minimum: 1 Maximum: 100
Default: 10
nextToken (optional)
Type: string
Query Parameter
A string token returned in the response to your previous request. nextToken is returned when the number of results exceeds the specified pageSize value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail.
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetReportsAPI()
{
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// init Request Payload
GetReportsRequest reportRequest = new GetReportsRequest();
// send the request
GetReportsResponse report = client.GetReports(reportRequest, headers);
// check if API call was successful
if (!report.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
Console.WriteLine(report.RawResponse);
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Live,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetReportsAPI()
{
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// init Request Payload
GetReportsRequest reportRequest = new GetReportsRequest();
// send the request
GetReportsResponse report = client.GetReports(reportRequest, headers);
// check if API call was successful
if (!report.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
Console.WriteLine(report.RawResponse);
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetReportDocument()
{
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// init Request Payload
string reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";
// send the request
GetReportDocumentResponse report = client.GetReportDocument(reportDocumentId, headers);
// check if API call was successful
if (!report.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
Console.WriteLine(report.RawResponse);
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Live,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetReportDocument()
{
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// init Request Payload
string reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";
// send the request
GetReportDocumentResponse report = client.GetReportDocument(reportDocumentId, headers);
// check if API call was successful
if (!report.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
Console.WriteLine(report.RawResponse);
}
}
The Get Report Document API will return an url with the link to the report in zip format.
All details for this API are available here. If you are using a SDK, please check the matching SDK documentation.
Step 4: Download the report document file
You must download the report using the information returned in Step 3. The url is valid for 30 seconds only. At this time, all files will be uncompressed.
The following sample code demonstrates how to download a plain text report document. You can also use the principles demonstrated in the sample code to guide you in building applications in other programming languages.
Use the following as inputs for the sample code:
The url and optional compressionAlgorithm values from the previous step are arguments for the url, and compressionAlgorithm parameters of the download method of the DownloadExample class.