files/en-us/web/api/paymentaddress/index.md
{{APIRef("Payment Request API")}}{{SecureContext_Header}}{{Deprecated_Header}}{{Non-standard_Header}}
The PaymentAddress interface of the Payment Request API is used to store shipping or payment address information.
It may be useful to refer to the Universal Postal Union website's Addressing S42 standard materials, which provide information about international standards for postal addresses.
country values: "US", "GB", "CN", or "JP".[!NOTE] Properties for which values were not specified contain empty strings.
PaymentAddress object's properties.In the following example, the {{domxref("PaymentRequest.PaymentRequest","PaymentRequest()")}} constructor is used to create a new payment request, which takes three objects as parameters — one containing details of the payment methods that can be used for the payment, one containing details of the actual order (such as items bought and shipping options), and an optional object containing further options.
The first of these three (supportedInstruments in the example below) contains a data property that has to conform to the structure defined by the payment method.
const supportedInstruments = [
{
supportedMethods: "https://example.com/pay",
},
];
const details = {
total: { label: "Donation", amount: { currency: "USD", value: "65.00" } },
displayItems: [
{
label: "Original donation amount",
amount: { currency: "USD", value: "65.00" },
},
],
shippingOptions: [
{
id: "standard",
label: "Standard shipping",
amount: { currency: "USD", value: "0.00" },
selected: true,
},
],
};
const options = { requestShipping: true };
async function doPaymentRequest() {
const request = new PaymentRequest(supportedInstruments, details, options);
// Add event listeners here.
// Call show() to trigger the browser's payment flow.
const response = await request.show();
// Process payment.
const json = response.toJSON();
const httpResponse = await fetch("/pay/", { method: "POST", body: json });
const result = httpResponse.ok ? "success" : "failure";
await response.complete(result);
}
doPaymentRequest();
Once the payment flow has been triggered using {{domxref("PaymentRequest.show()")}} and the promise resolves successfully, the {{domxref("PaymentResponse")}} object available from the fulfilled promise (instrumentResponse above) will have a {{domxref("PaymentResponse.details")}} property containing response details. This has to conform to the structure defined by the payment method provider.
{{Compat}}