---
title: Buyer
url: amazon-pay-api-v2/buyer.html
---

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  <a href="../amazon-pay-api-v2/checkout-session.md#get-checkout-session" target="_blank" rel="noopener noreferrer">Get Checkout Session</a> and  <a href="../amazon-pay-api-v2/charge-permission.md#get-charge-permission" target="_blank" rel="noopener noreferrer">Get Charge Permission</a> instead.

<script>
  function keySpecifics(){
    const keyQuery = "?environmentSpecificKeys=";
    const currentSetting = window.location.search?.split("?environmentSpecificKeys=")[1] ?? 'false';
    const newSetting = currentSetting === 'false' ? 'true' : 'false';
    window.location = window.location.origin + window.location.pathname + keyQuery + newSetting // +  window.location.hash (not included as it feels weird to jump down)
  }
</script>
<div style="display:none" class="environmentSpecificKeys">
  <div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> If your publicKeyId <b>_does not_</b> have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow <a href='#' onclick='keySpecifics()' rel='noopener noreferrer'>these instructions</a> instead.</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
  <div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow <a href='#' onclick='keySpecifics()' rel='noopener noreferrer'>these instructions</a> instead.</div>
</div>


Supported operations:

<div style="display:none" class="environmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#ustab" data-toggle="tab">US</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#eutab" data-toggle="tab">EU / UK</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#jptab" data-toggle="tab">JP</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="ustab" markdown="block">   
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.com/:version/buyers/:buyerToken
</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="eutab" markdown="block">
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.eu/:version/buyers/:buyerToken
</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="jptab" markdown="block">
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.jp/:version/buyers/:buyerToken
</div>
  </div>
</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#ustabNESK" data-toggle="tab">US</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#eutabNESK" data-toggle="tab">EU / UK</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#jptabNESK" data-toggle="tab">JP</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="ustabNESK" markdown="block">   
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.com/:environment/:version/buyers/:buyerToken
</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="eutabNESK" markdown="block">
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.eu/:environment/:version/buyers/:buyerToken
</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="jptabNESK" markdown="block">
<div markdown="block">
* **Get Buyer** - GET https://pay-api.amazon.jp/:environment/:version/buyers/:buyerToken
</div>
  </div>
</div>
</div>



***

* TOC
{:toc}
{::options toc_levels="3" /}

### Buyer object

<table width="100%" border="1">
    <tbody>
        <tr id='cJS9CA15m1O'>
            <td id='s:cJS9CA15m1O;cJS9CADTmKU' style='vertical-align: top; font-weight: bold; width: 30%;' class='bold'>Parameter
                <br /></td>
            <td id='s:cJS9CA15m1O;cJS9CACuV6g' style='vertical-align: top; font-weight: bold; width: 70%;' class='bold'>Description
                <br /></td>
        </tr>
        <tr id='eVX9CAekLu0'>
            <td id='s:eVX9CAekLu0;eVX9CAgCtkV' style='vertical-align: top;'>buyer<br><br>Type: <a href="#type-buyer">buyer</a>
                <br /></td>
            <td id='s:eVX9CAekLu0;eVX9CAZWNK6' style='vertical-align: top;'>Details about the buyer, such as their unique identifier, name, and email
                <br /></td>
        </tr>
    </tbody>
</table>

#### Type: buyer

<table width="100%" border="1">
    <tbody>
        <tr id='cJS9CA15m1O'>
            <td id='s:cJS9CA15m1O;cJS9CADTmKU' style='vertical-align: top; font-weight: bold; width: 30%;' class='bold'>Parameter
                <br /></td>
            <td id='s:cJS9CA15m1O;cJS9CACuV6g' style='vertical-align: top; font-weight: bold; width: 70%;' class='bold'>Description
                <br /></td>
        </tr>
        <tr id='eVX9CA8MgFZ'>
            <td id='s:eVX9CA8MgFZ;eVX9CAkIKgm' style='vertical-align: top;'>buyerId<br><br>Type: string
                <br /></td>
            <td id='s:eVX9CA8MgFZ;eVX9CA0qHyb' style='vertical-align: top;'>Unique Amazon Pay buyer identifier
                <br /></td>
        </tr>
        <tr id='eVX9CAxAa6i'>
            <td id='s:eVX9CAxAa6i;eVX9CAkIKgm' style='vertical-align: top;'>countryCode<br><br>Type: string
                <br /></td>
            <td id='s:eVX9CAxAa6i;eVX9CA0qHyb' style='vertical-align: top;'>Buyer default shipping address country
                <br /></td>
        </tr>
        <tr id='eVX9CA3luwf'>
            <td id='s:eVX9CA3luwf;eVX9CAkIKgm' style='vertical-align: top;'>email<br><br>Type: string
                <br /></td>
            <td id='s:eVX9CA3luwf;eVX9CA0qHyb' style='vertical-align: top;'>Buyer email address
                <br /></td>
        </tr>
        <tr id='eVX9CADjRYi'>
            <td id='s:eVX9CADjRYi;eVX9CAkIKgm' style='vertical-align: top;'>name<br><br>Type: string
                <br /></td>
            <td id='s:eVX9CADjRYi;eVX9CA0qHyb' style='vertical-align: top;'>Buyer name
                <br /></td>
        </tr>
        <tr id='eVX9CA2CiDk'>
            <td id='s:eVX9CA2CiDk;eVX9CAkIKgm' style='vertical-align: top;'>postalCode<br><br>Type: string
                <br /></td>
            <td id='s:eVX9CA2CiDk;eVX9CA0qHyb' style='vertical-align: top;'>Buyer default shipping address postal code
                <br /></td>
        </tr>
        <tr id='eVX9CA2CiDk'>
            <td id='' style='vertical-align: top;'>shippingAddress<br><br>Type: <a href="#type-address">address</a>
                <br /></td>
            <td id='' style='vertical-align: top;'>Buyer default shipping address
                <br /></td>
        </tr>
        <tr id='eVX9CA2CiDk'>
            <td id='' style='vertical-align: top;'>billingAddress<br><br>Type: <a href="#type-address">address</a>
                <br /></td>
            <td id='' style='vertical-align: top;'>Buyer default billing address
                <br /></td>
        </tr>
         <tr id='eVX9CA2CiDk'>
            <td id='' style='vertical-align: top;'>phoneNumber<br><br>Type: string
                <br /></td>
            <td id='' style='vertical-align: top;'>Buyer default billing address phone number
                <br /></td>
        </tr>
        <tr id=''>
            <td id='' style='vertical-align: top;'>primeMembershipTypes<br><br>Type: list&lt;primeMembershipType&gt;
                <br /></td>
            <td id='' style='vertical-align: top;'>List of buyer Prime memberships. This data is not available for general use
            </td>
        </tr>
    </tbody>
</table>

#### Type: address

<table width="100%" border="1">
    <tbody>
        <tr id='cJS9CA15m1O'>
            <td id='s:cJS9CA15m1O;cJS9CADTmKU' style='vertical-align: top; font-weight: bold; width: 30%;' class='bold'>Parameter
                <br /></td>
            <td id='s:cJS9CA15m1O;cJS9CACuV6g' style='vertical-align: top; font-weight: bold; width: 70%;' class='bold'>Description
                <br /></td>
        </tr>
        <tr id='cJS9CAhKQ2T'>
            <td id='s:cJS9CAhKQ2T;cJS9CADTmKU' style='vertical-align: top;'>name<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAhKQ2T;cJS9CACuV6g' style='vertical-align: top;'>Address name<br><br>Max length: 50 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAqXCyh'>
            <td id='s:cJS9CAqXCyh;cJS9CADTmKU' style='vertical-align: top;'>addressLine1<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAqXCyh;cJS9CACuV6g' style='vertical-align: top;'>The first line of the address<br><br>Max length: 180 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAwiBgM'>
            <td id='s:cJS9CAwiBgM;cJS9CADTmKU' style='vertical-align: top;'>addressLine2<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAwiBgM;cJS9CACuV6g' style='vertical-align: top;'>The second line of the address<br><br>Max length: 60 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAcRMHh'>
            <td id='s:cJS9CAcRMHh;cJS9CADTmKU' style='vertical-align: top;'>addressLine3<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAcRMHh;cJS9CACuV6g' style='vertical-align: top;'>The third line of the address<br><br>Max length: 60 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAMadQS'>
            <td id='s:cJS9CAMadQS;cJS9CADTmKU' style='vertical-align: top;'>city<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAMadQS;cJS9CACuV6g' style='vertical-align: top;'>City of the address<br><br>Max length: 50 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAElYRX'>
            <td id='s:cJS9CAElYRX;cJS9CADTmKU' style='vertical-align: top;'>county<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAElYRX;cJS9CACuV6g' style='vertical-align: top;'>County of the address<br><br>Max length: 50 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAuqxtJ'>
            <td id='s:cJS9CAuqxtJ;cJS9CADTmKU' style='vertical-align: top;'>district<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAuqxtJ;cJS9CACuV6g' style='vertical-align: top;'>District of the address<br><br>Max length: 50 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAJhCV2'>
            <td id='s:cJS9CAJhCV2;cJS9CADTmKU' style='vertical-align: top;'>stateOrRegion<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAJhCV2;cJS9CACuV6g' style='vertical-align: top;'>The state or region:
            <ul>
                <li>US and CA addresses - Response will always be a 2-character code</li>
                <li>All other countries - This element is free text and can be either a 2-character code, fully spelled out, or abbreviated</li>
              </ul> 
                Max length: 50 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAaTUA6'>
            <td id='s:cJS9CAaTUA6;cJS9CADTmKU' style='vertical-align: top;'>postalCode<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAaTUA6;cJS9CACuV6g' style='vertical-align: top;'>Postal code of the address<br><br>Max length: 20 characters/bytes
                <br /></td>
        </tr>
        <tr id='cJS9CAm6V7w'>
            <td id='s:cJS9CAm6V7w;cJS9CADTmKU' style='vertical-align: top;'>countryCode<br><br>Type: string
                <br /></td>
            <td id='s:cJS9CAm6V7w;cJS9CACuV6g' style='vertical-align: top;'>Country code of the address in ISO 3166 format<br><br>Max length: 3 characters/bytes
                <br /></td>
        </tr>
        <tr id=''>
          <td id='' style='vertical-align: top;'>phoneNumber<br><br>Type: string
              <br /></td>
          <td id='' style='vertical-align: top;'>Phone number<br><br>Max length: 20 characters/bytes
              <br /></td>
      </tr>
    </tbody>
</table>


## Operations

### Get Buyer

Get Buyer will only return `buyerId` by default. You must explicitly request access to additional buyer details using the button <a href="../amazon-pay-checkout/amazon-sign-in.md#type-signinscope" target="_blank" rel="noopener noreferrer">`signInScopes`</a> 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

<div style="display:none" class="environmentSpecificKeys">
    <code style="color:black">
curl "https://pay-api.amazon.com/:version/buyers/:buyerToken" \<br />
-X GET<br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
</code>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
    <code style="color:black">
curl "https://pay-api.amazon.com/:environment/:version/buyers/:buyerToken" \<br />
-X GET<br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
</code>
</div>

#### Request parameters

<table width="100%" border="1">
    <tbody>
        <tr id=''>
            <td id='' style='vertical-align: top; font-weight: bold; width: 30%;' class='bold'>Name
                <br /></td>
            <td id='' style='vertical-align: top; font-weight: bold; width: 20%;' class='bold'>Location
                <br /></td>
            <td id='' style='vertical-align: top; font-weight: bold; width: 50%;' class='bold'>Description
                <br /></td>
        </tr>
        <tr id=''>
            <td id='' style='vertical-align: top;'>buyerToken<br><b>(required)</b><br><br>Type: string
                <br /></td>
            <td id='' style='vertical-align: top;'>Path Parameter
                <br /></td>
            <td id='' style='vertical-align: top;'>Token used to retrieve buyer details. This value is appended as a query parameter to <code>signInReturnUrl</code><br><br>Max length: 1000 characters/bytes
                <br /></td>
        </tr>
    </tbody>
</table>

#### Sample Code

<div style="display:none" class="environmentSpecificKeys">
    <ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getBuyer" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getBuyer" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getBuyer" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getBuyer" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getBuyer">   
<div markdown="block">
```
<?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'
    );
            
    try {
        $buyerToken = 'eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw';
        
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getBuyer($buyerToken);
            
        if ($result['status'] === 200) {
            $response = json_decode($result['response'], true);

        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'];
        }
    } catch (Exception $e) {
        // handle the exception
        echo $e;
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getBuyer">
<div markdown="block">
```
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;
        }
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getBuyer">
<div markdown="block">
```
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;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {

        String buyerToken = "eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw";

        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        
        AmazonPayResponse response = webstoreClient.getBuyer(buyerToken);
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}

```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getBuyer">
<div markdown="block">
```html
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 buyerToken = "eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw";
             
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getBuyer(buyerToken);

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
    <ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getBuyer-NESK" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getBuyer-NESK" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getBuyer-NESK" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getBuyer-NESK" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getBuyer-NESK">   
<div markdown="block">
```
<?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'       => true,
        'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2'
    );
            
    try {
        $buyerToken = 'eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw';
        
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getBuyer($buyerToken);
            
        if ($result['status'] === 200) {
            $response = json_decode($result['response'], true);

        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'];
        }
    } catch (Exception $e) {
        // handle the exception
        echo $e;
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getBuyer-NESK">
<div markdown="block">
```
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;
        }
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getBuyer-NESK">
<div markdown="block">
```
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;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {

        String buyerToken = "eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw";

        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
            .setEnvironment(Environment.SANDBOX)
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        
        AmazonPayResponse response = webstoreClient.getBuyer(buyerToken);
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}

```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getBuyer-NESK">
<div markdown="block">
```html
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: true,
    algorithm: 'AMZN-PAY-RSASSA-PSS-V2' 
};

const buyerToken = "eyL7YthG12BvRUYiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiNXQ3NmhOTVhKN0tidkpSbHR0WmggBn12JmnY6yI6IkExMjhHQ01LVyIsIml2IjoidXFUeWl5NzUtMlU1RVk0RyJ9.iy6tY93sESc2fHVj49ynJO3e45ZiGkpDbmVYjgAimiM.K4nVJFzrHV-Pbotw.CumBT12hN5Bih_V0UI635PuIZ_IAD-HcH42hy5NuliOhFoAoFf4uNnVpjjDbPWnkYcdgtettavJlKGPG5wG2zaHJc2AFODXuuHklYGUbOwX1Z9JBXJExXfcLyvM_d5Zh4eaXkJWB3BUCfrP4afG9llHmwOHRvORu4vyGzG4JuBrZVeZ69EK0yqDMOYgbR44Bospf9XCDeV_NQfkmZWerjHaWe_ltYgCEcbUQu4-Snb76NbVT8Uf85KNocQfi4SYJn5tUKTjh2uR9XHeQhQY.f7UR3zVnUDe_WfqsvrPMNw";
             
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getBuyer(buyerToken);

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>


#### Response

Returns <a href="https://restfulapi.net/http-status-200-ok" target="_blank" rel="noopener noreferrer">HTTP 200 status response code</a> if the operation was successful.

```
{
	"name": "John Example",
	"email": "johnexample@amazon.com",
	"postalCode": "12345",
	"countryCode": "US",
	"buyerId": "DIRECTEDBUYERID",
	"phoneNumber": "1234567811" // default billing address phone number
	"shippingAddress": {
		"name": "John",
		"addressLine1": "15th Street",
		"addressLine2": "",
		"addressLine3": "",
		"city": "Seattle", 
		"county": "",
		"district": "",
		"stateOrRegion": "WA",
		"country": "USA",
		"postalCode": "98121",
		"phoneNumber": "1234567899"
	},
	"billingAddress": null,
	"primeMembershipTypes": null
}
```

#### Error codes

<table width="100%" border="1">
    <tbody>
        <tr id=''>
            <td id='' style='vertical-align: top; font-weight: bold; width: 30%;' class='bold'>HTTP status code
                <br /></td>
            <td id='' style='vertical-align: top; font-weight: bold; width: 20%;' class='bold'>Reason code
                <br /></td>
            <td id='' style='vertical-align: top; font-weight: bold; width: 50%;' class='bold'>Description
                <br /></td>
        </tr>
        <tr id=''>
            <td id='' style='vertical-align: top;'>400 BAD_REQUEST
                <br /></td>
            <td id='' style='vertical-align: top;'>InvalidBuyerToken
                <br /></td>
            <td id='' style='vertical-align: top;'>The token provided is expired, revoked, malformed, or invalid for some other reason
                <br /></td>
        </tr>
    </tbody>
</table>

Generic errors can be found <a href="../amazon-pay-api-v2/error-handling.md" target="_blank" rel="noopener noreferrer">here</a>. 






