安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

BasicCardRequest dictionary is a JavaScript object-structure that can be used in the 支付请求 API . The properties of BasicCardRequest are defined in the Basic Card Payment spec ).

特性

BasicCardRequest.supportedNetworks 可选 安全上下文
An optional array of DOMString s representing the card networks that the retailer supports (e.g. " amex" , " mastercard" ); see Card network identifiers for a complete list. If the property is missing, it implies that all networks are supported.

过时特性

These properties have been removed from the Payment Method: Basic Card specification and should no longer be used.

BasicCardRequest.supportedTypes 可选 安全上下文
This obsolete property was used to provide an optional array of DOMString s representing the card types that the retailer supports (e.g. credit , debit , prepaid ). If the property is missing, it implies that all the card types are supported. Instead of using this property, it is up to the server to check support for the card given the information coded into the account number.

Card network identifiers

The W3C maintains an official list of approved card network identifier strings , which may be used in the supportedNetworks list. Those are:

  • amex
  • cartebancaire
  • diners
  • discover
  • jcb
  • mastercard
  • mir
  • unionpay
  • visa

范例

在以下范例中, 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 that describes what data is needed to fullfil the payment (e.g., a shipping address).

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 字典。

var supportedInstruments = [{
  supportedMethods: 'basic-card',
  data: {
    supportedNetworks: ['visa', 'mastercard', 'amex', 'jcb',
                        'diners', 'discover', 'mir', 'unionpay']
  }
}];
var 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
    }
  ]
};
var options = {requestShipping: true};
try {
  var request = new PaymentRequest(supportedInstruments, details, options);
  // Add event listeners here.
  // Call show() to trigger the browser's payment flow.
  request.show().then(function(instrumentResponse) {
    // Do something with the response from the UI.
  })
  .catch(function(err) {
    // Do something with the error from request.show().
  });
} catch (e) {
  // Catch any other errors.
}
							

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' : 'Mr Dick Straw",
  "cardSecurityCode" : "999",
  "expiryMonth" : "07",
  "expiryYear" : "2021",
  "billingAddress" : {
    "country" : "GB",
    // etc. billing address is a PaymentAddress object
  }
}
							

规范

规范 状态 注释
Basic Card Payment
The definition of 'BasicCardRequest' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
BasicCardRequest Chrome 不支持 No Edge 不支持 ≤18 — 79 Firefox 56 注意事项 Disabled
56 注意事项 Disabled
Available only in nightly builds.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) 和 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 ? WebView Android 不支持 No Chrome Android 57 Firefox Android 56 注意事项 Disabled
56 注意事项 Disabled
Available only in nightly builds.
Disabled From version 56: this feature is behind the dom.payments.request.enabled preference (needs to be set to true ) 和 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 ? Samsung Internet Android 7.0
supportedNetworks Chrome 不支持 No Edge 不支持 ≤18 — 79 Firefox 56 注意事项 Disabled
56 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 57 Firefox Android 56 注意事项 Disabled
56 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 7.0
supportedTypes 弃用 Chrome 不支持 No Edge 不支持 ≤18 — 79 Firefox 不支持 56 — 65 注意事项 Disabled
56 — 65 注意事项 Disabled
It's now up to the payment processor to determine the type of card used, when necessary. Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android 57 Firefox Android 不支持 56 — 65 注意事项 Disabled
56 — 65 注意事项 Disabled
It's now up to the payment processor to determine the type of card used, when necessary. Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 7.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

元数据

  • 最后修改:
  1. 支付请求 API
  2. BasicCardRequest
  3. 特性
    1. supportedNetworks
    2. supportedTypes
  4. Related pages for Payment Request API
    1. HTMLIFrameElement.allowPaymentRequest
    2. MerchantValidationEvent
    3. PaymentAddress
    4. PaymentMethodChangeEvent
    5. PaymentRequest
    6. PaymentRequestUpdateEvent
    7. PaymentResponse

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1