Manually requesting reports
Settlement reports are automatically generated per settlement. Transaction reports and Sandbox Settlement reports might be created by a schedule (see managing report schedules section).
Multicurrency reports (reportType _GET_CSV_CUSTOM_OFFAMAZONPAYMENTS_MULTI_CURRENCY_PAYMENTS_DATA_
) do not support schedule creation.
It is als possible to manually request individual transaction, Sandbox Settlement reports and Multicurrency reports via the Create Report
API.
Create Report
Submits a request to generate a report based on the reportType
and date range specified.
Request
curl "https://pay-api.amazon.com/live/:version/reports"
-X POST
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"
-d @request_body
curl "https://pay-api.amazon.com/live/:version/reports"
-X POST
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"
-d @request_body
Request body
{
"reportType": "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
"startTime": "2022-08-04T00-00-00Z",
"endTime": "2022-08-04T23-59-59Z"
}
Sample Code
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$requestPayload = array(
'reportType' => '_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_',
'startTime' => '20220804T000000Z',
'endTime' => '20220804T235959Z'
);
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->createReport($requestPayload);
if ($result['status'] === 200) {
// success
$response = $result['response'];
echo $response;
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (\Exception $e) {
// handle the exception
echo $e . "\n";
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Reports;
using Amazon.Pay.API.WebStore.Types;
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 CreateReport()
{
// 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
CreateReportRequest requestPayload = new CreateReportRequest(
reportType: ReportTypes._GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_,
startTime: "20220804T000000Z", // Can also use DateTime.Now or any DateTime object value
endTime: "20220804T235959Z" // Can also use DateTime.Now or any DateTime object value
);
// send the request
CreateReportResponse report = client.CreateReport(requestPayload, 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);
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY")
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = null;
JSONObject requestPayload = new JSONObject();
requestPayload.put("reportType", "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_");
requestPayload.put("startTime", "20220804T000000Z");
requestPayload.put("endTime", "20220804T235959Z");
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
response = webstoreClient.createReport(requestPayload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const requestPayload = {
reportType: "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
startTime: "20220804T000000Z",
endTime: "20220804T235959Z"
}
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.createReport(requestPayload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'sandbox' => false,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$requestPayload = array(
'reportType' => '_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_',
'startTime' => '20220804T000000Z',
'endTime' => '20220804T235959Z'
);
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->createReport($requestPayload);
if ($result['status'] === 200) {
// success
$response = $result['response'];
echo $response;
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (\Exception $e) {
// handle the exception
echo $e . "\n";
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Reports;
using Amazon.Pay.API.WebStore.Types;
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 CreateReport()
{
// 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
CreateReportRequest requestPayload = new CreateReportRequest(
reportType: ReportTypes._GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_,
startTime: "20220804T000000Z", // Can also use DateTime.Now or any DateTime object value
endTime: "20220804T235959Z" // Can also use DateTime.Now or any DateTime object value
);
// send the request
CreateReportResponse report = client.CreateReport(requestPayload, 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);
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY")
.setEnvironment(Environment.LIVE)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = null;
JSONObject requestPayload = new JSONObject();
requestPayload.put("reportType", "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_");
requestPayload.put("startTime", "20220804T000000Z");
requestPayload.put("endTime", "20220804T235959Z");
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
response = webstoreClient.createReport(requestPayload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: false,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const requestPayload = {
reportType: "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
startTime: "20220804T000000Z",
endTime: "20220804T235959Z"
}
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.createReport(requestPayload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
Response
Returns HTTP 201 status response code if the operation was successful.
{
"reportId": "A08439021T39K6DTX4JS8",
}
Use the reportId
returned in the Get Report
API to retrieve report status and the report document url to get the report content.