<commit_before>/* exported onBuyClicked */

/**
 * Initializes the payment request object.
 * @return {PaymentRequest} The payment request object.
 */
function buildPaymentRequest() {
  if (!window.PaymentRequest) {
    return null;
  }

  const supportedInstruments = [{
    supportedMethods: 'basic-card',
  }, {
    supportedMethods: 'https://google.com/pay',
    data: {
      allowedPaymentMethods: ['TOKENIZED_CARD', 'CARD'],
      apiVersion: 1,
      cardRequirements: {
        'allowedCardNetworks': ['VISA', 'MASTERCARD', 'AMEX'],
      },
      merchantName: '<NAME>',
      merchantId: '00184145120947117657',
      paymentMethodTokenizationParameters: {
        tokenizationType: 'GATEWAY_TOKEN',
        parameters: {
          'gateway': 'stripe',
          'stripe:publishableKey': '<KEY>',
          'stripe:version': '2016-07-06',
        },
      },
    },
  }];

  const details = {
    total: {
      label: 'Tots',
      amount: {
        currency: 'USD',
        value: '1.00',
      },
    },
  };

  let request = null;

  try {
    request = new PaymentRequest(supportedInstruments, details);
    if (request.canMakePayment) {
      request.canMakePayment().then(function(result) {
        info(result ? 'Can make payment' : 'Cannot make payment');
      }).catch(function(err) {
        error(err);
      });
    }

    if (request.onpaymentmethodchange) {
      info('Will print out payment method change event details here.');
      request.addEventListener('paymentmethodchange', (evt) => {
        info(JSON.stringify({'methodName': evt.methodName, 'methodDetails': evt.methodDetails}, undefined, 2);
      });
    }
  } catch (e) {
    error('Developer mistake: \'' + e + '\'');
  }

  return request;
}

let request = buildPaymentRequest();

/**
 * Launches payment request for Android Pay.
 */<commit_msg>Clarify meaning of the printed JSON<commit_after>/* exported onBuyClicked */

/**
 * Initializes the payment request object.
 * @return {PaymentRequest} The payment request object.
 */
function buildPaymentRequest() {
  if (!window.PaymentRequest) {
    return null;
  }

  const supportedInstruments = [{
    supportedMethods: 'basic-card',
  }, {
    supportedMethods: 'https://google.com/pay',
    data: {
      allowedPaymentMethods: ['TOKENIZED_CARD', 'CARD'],
      apiVersion: 1,
      cardRequirements: {
        'allowedCardNetworks': ['VISA', 'MASTERCARD', 'AMEX'],
      },
      merchantName: '<NAME>',
      merchantId: '00184145120947117657',
      paymentMethodTokenizationParameters: {
        tokenizationType: 'GATEWAY_TOKEN',
        parameters: {
          'gateway': 'stripe',
          'stripe:publishableKey': '<KEY>',
          'stripe:version': '2016-07-06',
        },
      },
    },
  }];

  const details = {
    total: {
      label: 'Tots',
      amount: {
        currency: 'USD',
        value: '1.00',
      },
    },
  };

  let request = null;

  try {
    request = new PaymentRequest(supportedInstruments, details);
    if (request.canMakePayment) {
      request.canMakePayment().then(function(result) {
        info(result ? 'Can make payment' : 'Cannot make payment');
      }).catch(function(err) {
        error(err);
      });
    }

    if (request.onpaymentmethodchange) {
      info('Will print out payment method change event details here.');
      request.addEventListener('paymentmethodchange', (evt) => {
        info('Payment method change event: ' + JSON.stringify({'methodName': evt.methodName, 'methodDetails': evt.methodDetails}, undefined, 2);
      });
    }
  } catch (e) {
    error('Developer mistake: \'' + e + '\'');
  }

  return request;
}

let request = buildPaymentRequest();

/**
 * Launches payment request for Android Pay.
 */
{'fraction_non_alphanumeric': 0.14721627408993576, 'fraction_numerical': 0.017665952890792293, 'mean_word_length': 2.737, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '562994', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1116, 'n_words': 243}