The Buyer object includes details about the buyer such as name, email, unique Amazon Pay identifier, default shipping address postal and country code. You should only use this object if you’ve implemented Amazon Sign-in and only because you need to retrieve Buyer details before the buyer starts Amazon Pay checkout. Once checkout has started, you should use Get Checkout Session and Get Charge Permission instead.
Note: If your publicKeyId does not have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow these instructions instead.
Note: If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow these instructions instead.
List of buyer Prime memberships. This data is not available for general use
Type: address
Parameter
Description
name
Type: string
Address name
Max length: 50 characters/bytes
addressLine1
Type: string
The first line of the address
Max length: 180 characters/bytes
addressLine2
Type: string
The second line of the address
Max length: 60 characters/bytes
addressLine3
Type: string
The third line of the address
Max length: 60 characters/bytes
city
Type: string
City of the address
Max length: 50 characters/bytes
county
Type: string
County of the address
Max length: 50 characters/bytes
district
Type: string
District of the address
Max length: 50 characters/bytes
stateOrRegion
Type: string
The state or region:
US and CA addresses - Response will always be a 2-character code
All other countries - This element is free text and can be either a 2-character code, fully spelled out, or abbreviated
Max length: 50 characters/bytes
postalCode
Type: string
Postal code of the address
Max length: 20 characters/bytes
countryCode
Type: string
Country code of the address in ISO 3166 format
Max length: 3 characters/bytes
phoneNumber
Type: string
Phone number
Max length: 20 characters/bytes
Operations
Get Buyer
Get Buyer will only return buyerId by default. You must explicitly request access to additional buyer details using the button signInScopes parameter.
Amazon Pay will only provide the token required to retrieve buyer details after the buyer signs in. It will be appended to the signInReturnUrl as a query parameter and expires after 24 hours.
Request
curl "https://pay-api.amazon.com/:version/buyers/:buyerToken" \
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
curl "https://pay-api.amazon.com/:environment/:version/buyers/:buyerToken" \
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
Request parameters
Name
Location
Description
buyerToken (required)
Type: string
Path Parameter
Token used to retrieve buyer details. This value is appended as a query parameter to signInReturnUrl
using Amazon.Pay.API;
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Buyer;
using Microsoft.AspNetCore.Mvc.RazorPages;
public class Sample : PageModel
{
public BuyerResponse Buyer { get; private set; }
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 OnGet()
{
// the token as retrieved from the URL
string buyerToken = HttpContext.Request.Query["buyerToken"];
// get the buyer details
// NOTE: the BuyerResponse that is returned here contains properties for buyerId, name, email, shippingAddress, phoneNumber etc.
Buyer = client.GetBuyer(buyerToken);
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Address buyerAddress = result.ShippingAddress;
string buyerEmail = result.Email;
}
}
}
using Amazon.Pay.API;
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Buyer;
using Microsoft.AspNetCore.Mvc.RazorPages;
public class Sample : PageModel
{
public BuyerResponse Buyer { get; private set; }
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
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 OnGet()
{
// the token as retrieved from the URL
string buyerToken = HttpContext.Request.Query["buyerToken"];
// get the buyer details
// NOTE: the BuyerResponse that is returned here contains properties for buyerId, name, email, shippingAddress, phoneNumber etc.
Buyer = client.GetBuyer(buyerToken);
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Address buyerAddress = result.ShippingAddress;
string buyerEmail = result.Email;
}
}
}