W3cubDocs

/DOM

BasicCardResponse.cardNumber

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

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The cardNumber property of the BasicCardResponse dictionary contains the number of the card used to make the payment.

Syntax

"cardNumber" : "number"

Value

A DOMString representing the credit card number.

Example

Let's look at a sample payment request:

var request = new PaymentRequest(supportedInstruments, details, options);

// Call show() to trigger the browser's payment flow.
request.show().then(function(instrumentResponse) {
  // Do something with the response from the UI.
  console.log(instrumentResponse.details);
})
.catch(function(err) {
  // Do something with the error from request.show().
});

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
  }
}

Specifications

Specification Status Comment
Basic Card Payment
The definition of 'cardNumber' in that specification.
Working Draft Initial definition.

Browser CompatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support No Yes 56
Disabled
56
Disabled
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.
No No ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support No 57 Yes 56
Disabled
56
Disabled
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.
No ? 7.0

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/BasicCardResponse/cardNumber