PaymentAddress

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers .

PaymentAddress interface of the 支付请求 API is used to store shipping or payment address information.

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

特性

PaymentAddress.addressLine 只读
An array of DOMString objects 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.country 只读
A DOMString specifying the country in which the address is located, using the ISO-3166-1 alpha-2 standard. The string is always given in its canonical upper-case form. Some examples of valid country values: "US" , "GB" , "CN" ,或 "JP" .
PaymentAddress.city 只读
A DOMString which contains the city or town portion of the address.
PaymentAddress.dependentLocality 只读
A DOMString giving the dependent locality or sublocality within a city, for example, a neighborhood, borough, district, or UK dependent locality.
PaymentAddress.organization 只读
A DOMString specifying the name of the organization, firm, company, or institution at the payment address.
PaymentAddress.phone 只读
A DOMString specifying the telephone number of the recipient or contact person.
PaymentAddress.postalCode 只读
A DOMString 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.recipient 只读
A DOMString giving the name of the recipient, purchaser, or contact person at the payment address.
PaymentAddress.region 只读
A DOMString containing the top level administrative subdivision of the country, for example a state, province, oblast, or prefecture.
PaymentAddress.regionCode 只读
A DOMString specifying the region of the address, represented as a "code element" of an ISO3166-2 country subdivision name (e.g. "QLD" for Queensland, Australia, "CA" for California, and so on).
PaymentAddress.sortingCode 只读
A DOMString providing a postal sorting code such as is used in France.

注意: Properties for which values were not specified contain empty strings.

过时特性

The following properties are obsolete and should no longer be used, but may still be present in some browser versions.

PaymentAddress.languageCode 只读
A DOMString indicating the language code of the address. This identifies the language in which the address is given, and is intended to aid in localization of the display of the address.

方法

PaymentAddress.toJSON()
A standard serializer that returns a JSON representation of the PaymentAddress object's properties.

范例

In the following example, the 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 BasicCardRequest dictionary.

const supportedInstruments = [
  {
    supportedMethods: "basic-card",
  },
];
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 PaymentRequest.show() and the promise resolves successfully, the PaymentResponse object available inside the fulfilled promise ( instrumentResponse above) will have a PaymentResponse.details property that will contain response details. This has to conform to the structure defined by the BasicCardResponse dictionary, and may look something like this:

{
  "cardNumber' : '9999999999999999",
  "cardholderName' : 'Pat Straw",
  "cardSecurityCode" : "999",
  "expiryMonth" : "07",
  "expiryYear" : "2021",
  "billingAddress" : {
    "country" : "GB",
    // etc. billing address is a PaymentAddress object
  }
}
					

规范

规范 状态 Comment
支付请求 API
The definition of 'PaymentAddress' in that specification.
候选推荐 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PaymentAddress Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge ≤18 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) and the dom.payments.request.supportedRegions preference (needs to be set to A comma-delineated list of one or more 2-character ISO country codes indicating the countries in which to support payments (for example, US,CA . ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) and the dom.payments.request.supportedRegions preference (needs to be set to A comma-delineated list of one or more 2-character ISO country codes indicating the countries in which to support payments (for example, US,CA . ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
addressLine Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
city Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
country Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
dependentLocality Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
languageCode
弃用 非标
Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 不支持 56 — 63
注意事项 Disabled
56 — 63
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56 until version 63 (exclusive): this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 不支持 56 — 63
注意事项 Disabled
56 — 63
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56 until version 63 (exclusive): this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No
organization Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
phone Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
postalCode Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
recipient Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
region Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
regionCode
弃用 非标
Chrome 不支持 No Edge 不支持 No Firefox 64
注意事项 Disabled
64
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 64: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 64
注意事项 Disabled
64
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 64: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No
sortingCode Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 53
Disabled
53
Disabled
Disabled From version 53: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 56
注意事项 Disabled
56
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No
toJSON() Chrome 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 62
注意事项 Disabled
62
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 62: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari Yes WebView Android 不支持 No Chrome Android 61
Disabled
61
Disabled
Disabled From version 61: this feature is behind the #web-payments preference (needs to be set to Enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 62
注意事项 Disabled
62
注意事项 Disabled
Available only in nightly builds. Requires the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.
Disabled From version 62: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 不支持 No

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
用户必须明确启用此特征。