安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
PaymentAddress
接口在
支付请求 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
只读
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
只读
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
值:
"US"
,
"GB"
,
"CN"
,或
"JP"
.
PaymentAddress.city
只读
DOMString
which contains the city or town portion of the address.
PaymentAddress.dependentLocality
只读
DOMString
giving the dependent locality or sublocality within a city, for example, a neighborhood, borough, district, or UK dependent locality.
PaymentAddress.organization
只读
DOMString
specifying the name of the organization, firm, company, or institution at the payment address.
PaymentAddress.phone
只读
DOMString
specifying the telephone number of the recipient or contact person.
PaymentAddress.postalCode
只读
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
只读
DOMString
giving the name of the recipient, purchaser, or contact person at the payment address.
PaymentAddress.region
只读
DOMString
containing the top level administrative subdivision of the country, for example a state, province, oblast, or prefecture.
PaymentAddress.regionCode
只读
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
只读
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
只读
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()
PaymentAddress
object's properties.
在以下范例中,
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
字典。
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
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
支付请求 API
The definition of 'PaymentAddress' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
PaymentAddress
|
Chrome
61
Disabled
|
Edge ≤18 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
addressLine
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
city
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
country
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
dependentLocality
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
languageCode
弃用
非标
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
不支持
56 — 63
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari ? | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
不支持
56 — 63
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS ? | Samsung Internet Android 不支持 No |
organization
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
phone
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
postalCode
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
recipient
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
region
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
regionCode
弃用
非标
|
Chrome 不支持 No | Edge 不支持 No |
Firefox
64
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari ? | WebView Android 不支持 No | Chrome Android 不支持 No |
Firefox Android
64
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS ? | Samsung Internet Android 不支持 No |
sortingCode
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
53
Disabled
|
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
toJSON()
|
Chrome
61
Disabled
|
Edge 15 |
Firefox
62
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No |
Chrome Android
61
Disabled
|
Firefox Android
62
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 不支持 No |
完整支持
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
PaymentAddress