Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. PaymentAddress

PaymentAddress

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

ThePaymentAddress interface of thePayment Request API is used to store shipping or payment address information.

It may be useful to refer to the Universal Postal Union website'sAddressing S42 standard materials, which provide information about international standards for postal addresses.

Instance properties

PaymentAddress.addressLineRead onlyDeprecatedNon-standard

An array of strings providing each line of the address not included among the other properties. The exact size and content varies by country or location and can include, for example, a street name, house number, apartment number, rural delivery route, descriptive instructions, or post office box number.

PaymentAddress.countryRead onlyDeprecatedNon-standard

A string specifying the country in which the address is located, using theISO-3166-1 alpha-2 standard. The string is always given in its canonical upper-case form. Some examples of validcountry values:"US","GB","CN", or"JP".

PaymentAddress.cityRead onlyDeprecatedNon-standard

A string which contains the city or town portion of the address.

PaymentAddress.dependentLocalityRead onlyDeprecatedNon-standard

A string giving the dependent locality or sublocality within a city, for example, a neighborhood, borough, district, or UK dependent locality.

PaymentAddress.organizationRead onlyDeprecatedNon-standard

A string specifying the name of the organization, firm, company, or institution at the payment address.

PaymentAddress.phoneRead onlyDeprecatedNon-standard

A string specifying the telephone number of the recipient or contact person.

PaymentAddress.postalCodeRead onlyDeprecatedNon-standard

A string specifying a code used by a jurisdiction for mail routing, for example, the ZIP code in the United States or the PIN code in India.

PaymentAddress.recipientRead onlyDeprecatedNon-standard

A string giving the name of the recipient, purchaser, or contact person at the payment address.

PaymentAddress.regionRead onlyDeprecatedNon-standard

A string containing the top level administrative subdivision of the country, for example a state, province, oblast, or prefecture.

PaymentAddress.sortingCodeRead onlyDeprecatedNon-standard

A string providing a postal sorting code such as is used in France.

Instance methods

PaymentAddress.toJSON()DeprecatedNon-standard

A standard serializer that returns a JSON representation of thePaymentAddress object's properties.

Examples

In the following example, thePaymentRequest() 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 adata property that has to conform to the structure defined by the payment method.

js
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 usingPaymentRequest.show() and the promise resolves successfully, thePaymentResponse object available from the fulfilled promise (instrumentResponse above) will have aPaymentResponse.details property containing response details. This has to conform to the structure defined by the payment method provider.

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp