This specification defines a Payment Method used by the PaymentRequest API [[!payment-request]] to support tokenized card payments.
The working group maintains a list of all bug reports that the group has not yet addressed. Pull requests with proposed specification text for outstanding issues are strongly encouraged.
This specification addresses data security in credit or debit card payments on the Web.
When making a card payment, the cardholder shares data with a merchant. The sahred data has traditionally included the number embossed on the card (the primary account number or PAN), the card expiry date, cardholder name, and billing address.
There are a variety of ways to share this data: imprinting the card (physically making use of the embossed numbers on the card), swiping the card through magnetic stripe reader, providing the data through a chip or contactless connection, typing it into a Web form, or reading it aloud over the phone. These approaches differ in their convenience and security.
Most notably, if the PAN is intercepted by a malicious actor (in a merchant store or through a compromised Web site, for example), this can lead to fraudulent reuse. The card payment ecosystem has chosen to combat this risk by reducing the circulation of PANs, and instead reducing attack vectors through more opaque and controlled data. By accepting (and possibly storing) tokens instead of the PAN, merchants can reduce the risk of fraud due to data compromise. This can lower their costs to receive card payments and their liability for some types of fraud.
EMVCo has published [[!EMVCO-TOKENIZATION]] and related documents that replace the traditional PAN with a "network token" (as well as additional data to help limit misuse of each network token). These are called "network" tokens because card payment networks (e.g., American Express, China Union Pay, Discover, JCB, Mastercard, and Visa) and issuing banks offer relevant services. The current document describes how to connect these service providers to the Payment Request [[payment-request]] ecosystem so that merchants can request network and issuer tokens, and users can use payment handlers that request these tokens from service providers.
The network tokenization approach has gained some traction in "card present" transactions, that is through physical terminals. Indeed, in regions where merchants have migrated to terminals that accept network tokens, fraud has tended to move online. This trend is an important reason why the Web Payments Working Group seeks to increase the security of card payments on the Web.
Network tokenization offers several security benefits:
In addition, the current specification includes mechanisms to further enhance security through encryption of potentially sensitive data.
In [[!EMVCO-TOKENIZATION]] EMVCo describes the different roles in the tokenization ecosystem as well as the data requirements that are related through the current specification. Please consult that document for authoriative definitions. For the purposes of this introduction, here are brief descriptions of key roles:
Network tokens offer additional benefits as well beyond security:
const methodData = [{
  supportedMethods: ['tokenized-card'],
  data: {
    supportedNetworks: ['mastercard','visa', 'amex', 'discover', 'jcb','unionpay'],
    supportedTypes: ['credit','debit'],
    usageType: 'one-time',
    payeeID: '234987',
    keyProviderURL: 'https://pspKeyProvider.example/tokenizedCardPublicKey',
  }
}];
const details = {
  displayItems: [
    {
      label: "Sub-total",
      amount: { currency: "USD", value: "55.00" },
    },
    {
      label: "Sales Tax",
      amount: { currency: "USD", value: "5.00" },
    },
  ],
  total: {
    label: "Total due",
    // The total is USD$65.00 here because we need to
    // add shipping (below). The selected shipping
    // costs USD$5.00.  
    amount: { currency: "USD", value: "65.00" },
  },
};
new PaymentRequest(methodData, details);
        
      This example shows some fictitious Mastercard-specific response data.
          {
          displayLast4: "***6789",
          displayExpiryMonth: "02",
          displayExpiryYear: "22",
          displayNetwork: "mastercard",
          encryptedDetails: "QWxobHZ4bU4yWkt1QUFFU05GWjRHb0FCRkE9PQ==", 
          }
        
          
            When decrypted, the encryptedDetails data would be:
          
          {
          cardNumber: "5413339000001513",
          expiryMonth: "12",
          expiryYear: "20",
          cryptogram: "AlhlvxmN2ZKuAAESNFZ4GoABFA==",
          typeOfCryptogram: "UCAF", // "Universal Card Authentication Field"
          trid: "59812345678",
          eci: "242", // Authorization and final transaction request with UCAF data
          }
        
        This specification is designed to address these primary use cases:
See the TokenUsageType for more information.
For these use cases, the individual payment methods support different flows:
tokenized-card but relies on the payee (or their payment
          service provider) having a backend integration to reach a Token
          Service Provider. The payee expects to retrieve token,
          cryptogram, and other information through backend APIs and therefore
          only needs a reference via Payment Request API. In other words, the
          existence of the backend integration means the payee requires less
          data than with tokenized-card.
        not have a backend integration
          that enables them to reach a Token Service Provider for the
          cryptogram. Through this payment method, the payee leverages Payment
          Request API and the user's Payment Handler to reach the original
          Token Service Provider.
        
        The payment method identifier string for the Tokenized Card
        Payment method is tokenized-card.
      
          This section describes payment method specific data that is supplied
          as part of the data argument to the PaymentRequest
          constructor.
        
        dictionary TokenizedCardRequest{
          sequence<DOMString>       supportedNetworks;
          sequence<BasicCardType>   supportedTypes;
          required DOMString              keyProviderURL;
                   TokenUsageType         usageType;
                   DOMString              payeeID;
        };
      
        
          The TokenizedCardRequest dictionary contains the
          following members:
        
See What public key formats are acceptable, and any constraints? #1 .
For more information about handling of supportedNetworks and supportedTypes see the steps to check if an instrument is supported.
          enum TokenUsageType { "one-time", "card-on-file", "recurring" };
        
        
        dictionary TokenizedCardResponse {
                       DOMString       cardholderName;
                       DOMString       displayMaskedCard;
                       DOMString       displayLast4;
           required    DOMString       displayExpiryMonth;
           required    DOMString       displayExpiryYear; 
           required    DOMString       displayNetwork;
                       DOMString       par;
                       DOMString       tokenReferenceID;
                       DOMString       eci;
                       PaymentAddress? billingAddress;
           required    DOMString       encryptedDetails;
         };
      
        This dictionary defines the sensitive data that is to be encrypted. Note that the fields of this dictionary do not themselves influence the encryption.
          dictionary EncryptedTokenizedCard {
           required DOMString       cardNumber;
           required DOMString       expiryMonth;
           required DOMString       expiryYear;
           required DOMString       cryptogram;
           required DOMString       typeOfCryptogram;
           required DOMString       trid;
                    DOMString       tokenRequestorKey;
          };
        
          token-cryptogram payment method for card-on-file use
              cases.
            
        The payment method identifier string for the Token Reference
        Payment method is token-reference.
      
          This section describes payment method specific data that is supplied
          as part of the data argument to the PaymentRequest
          constructor.
        
        dictionary TokenReferenceRequest{
          sequence<DOMString>       supportedNetworks;
          sequence<BasicCardType>   supportedTypes;
                   TokenUsageType         usageType;
                   DOMString              payeeID;
        };
        
        
        dictionary TokenReferenceResponse {
                  required DOMString       tokenReferenceID;
                  required DOMString       trid;
                  };
              
        
        The payment method identifier string for the Token Cryptogram
        Payment method is token-cryptogram.
      
          This section describes payment method specific data that is supplied
          as part of the data argument to the PaymentRequest
          constructor.
        
        dictionary TokenCryptogramRequest{
           required DOMString   tokenRequestorID;
                    DOMString   tokenReferenceID;
                    DOMString   encryptedCardNumber;
        };
      
        
          The TokenCryptogramRequest dictionary contains the
          following members:
        
tokenized-card payment
            response.
            Need more details on encryption.
          dictionary TokenCryptogramResponse{
               required DOMString cryptogram;
               required DOMString typeOfCryptogram;
                        DOMString eci;
          };
      
        
        Currently these sections are for the tokenized-card
        payment method; we will need similar algorithms for other payment
        methods.
      
The steps to check if a payment can be made by a Payment Handler that handles "tokenized-card" takes TokenizedCardRequest request as input. It returns either true or false:
DOMString sequence.
          DOMString sequence.
          The steps to check if an instrument is supported takes as input a card card, a list of type types, a list of network networks, and a usageType usage. It returns true if the card is supported, false otherwise.
The steps to respond to a payment request are given by the following algorithm. If the end user inputs or selects a card that meets the constraints of TokenizedCardRequest data, the algorithm returns a card as a TokenizedCardResponse.
01" to "12", or the
          empty string if the user chooses not to provide it or the type
          doesn't require an expiry month.
          0000" to "9999", or
          the empty string if the user chooses not to provide it or the
          type doesn't require an expiry year.
          PaymentAddress from user-provided input with
              redactList.
              01" to "12", or the empty string if the
          user chooses not to provide it or the type doesn't require an
          expiry month.
          0000" to "9999", or the empty string if
          the user chooses not to provide it or the type doesn't require
          an expiry year.
          Until such time as we learn of intention by browsers/mediators to implement this specification, we have eliminated discussion of validation in this algorithm.
There is only one class of product that can claim conformance to this specification: a payment handler.
A conforming payment handler MUST:
This specification relies on several other underlying specifications.
The following Token Service Provider considerations are explicitly out of scope for this specification.
This diagram illustrates one flow where a payee requests a token (or token reference id) for one-time use, recurring, or card-on-file.
This diagram illustrates a request for a subsequent cryptogram based on a previously stored token.
Thanks to Manash Bhattacharjee for his early work on this specification.