<commit_before>// Type definitions for Braintree-web v3.6.1
// Project: https://github.com/braintree/braintree-web
// Definitions by: <NAME> <https://github.com/chlela>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1

/**
 * @module braintree-web/american-express
 * @description This module is for use with Amex Express Checkout. To accept American Express cards, use Hosted Fields.
 */
declare namespace braintree {
  export interface AmericanExpress {
    /**
     * @static
     * @function create
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {callback} callback The second argument, `data`, is the {@link AmericanExpress} instance.
     * @returns {void}
     */
    create: (options: { client: Client }, callback: callback) => void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Gets the rewards balance associated with a Braintree nonce.
     * @public
     * @param {object} options Request options
     * @param {string} options.nonce An existing Braintree nonce.
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @returns {void}
     * @example
     * var americanExpress = require('braintree-web/american-express');
     *
     * americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) {
     *   var options = {nonce: existingBraintreeNonce};
     *   americanExpressInstance.getRewardsBalance(options, function (getErr, payload) {
     *     if (getErr || payload.error) {
     *       // Handle error
     *       return;
     *     }
     *
     *     console.log('Rewards amount: ' + payload.rewardsAmount);
     *   });
     * });
     */
    getRewardsBalance(options: { nonce: string }, callback: callback): void;

    /**
     * Gets the Express Checkout nonce profile given a nonce from American Express.
     * @public
     * @param {object} options Request options
     * @param {string} options.nonce An existing nonce from American Express (note that this is <em>not</em> a nonce from Braintree).
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @returns {void}
     * @example
     * var americanExpress = require('braintree-web/american-express');
     *
     * americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) {
     *   var options = {nonce: existingAmericanExpressNonce};
     *   americanExpressInstance.getExpressCheckoutProfile(options, function (getErr, payload) {
     *     if (getErr) {
     *       // Handle error
     *       return;
     *     }
     *
     *     console.log('Number of cards: ' + payload.amexExpressCheckoutCards.length);
     *   });
     * });
     */
    getExpressCheckoutProfile(options: { nonce: string }, callback: callback): void;
  }
}


declare namespace braintree {
  // more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest

  //  billingContact
  //  Billing contact information for the user.
  //    countryCode
  //Required.The merchant’s two- letter ISO 3166 country code.
  //    currencyCode
  //  Required.The three- letter ISO 4217 currency code for the payment.
  //    lineItems
  //A set of line items that explain recurring payments and additional charges.
  //    merchantCapabilities
  //  Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
  //    requiredBillingContactFields
  //  The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
  //    requiredShippingContactFields
  //  The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
  //    shippingContact
  //  Shipping contact information for the user.
  //    shippingMethods
  //A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
  //    shippingType
  //  How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
  //    supportedNetworks
  //  Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
  //    total
  //  Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
  interface ApplePayPaymentRequest {
    total: {
      label: string;
      amount: string;
    };
    countryCode: string;
    currencyCode: string;
    supportedNetworks: string[];
    merchantCapabilities: string[];

    billingContact?: any;
    shippingContact?: any;
    shippingMethods?: any;
    shippingType?: any;
    requiredBillingContactFields?: any;
    requiredShippingContactFields?: any;
  }

  export enum ApplePayStatusCodes {
    // The requested action succeeded.
    STATUS_SUCCESS = 1,
    // The requested action failed.
    STATUS_FAILURE,
    // The billing address is not valid.
    STATUS_INVALID_BILLING_POSTAL_ADDRESS,
    // The shipping address is not valid.
    STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
    // The shipping contact information is not valid.
    STATUS_INVALID_SHIPPING_CONTACT,
    // The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
    STATUS_PIN_REQUIRED,
    // The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
    STATUS_PIN_INCORRECT,
    // The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
    STATUS_PIN_LOCKOUT,
  }

  interface ApplePayPayload {
    merchantIdentifier: string;
    domainName: string;
    displayName: string;
  }

  export class ApplePaySession {
    constructor(version: number, request: ApplePayPaymentRequest);

    canMakePayments(): boolean;

    canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;

    completeMerchantValidation(merchantSession: any): void;

    abort(): void;

    begin(): void;

    completePayment(status: ApplePayStatusCodes): void;

    completePaymentMethodSelection(newTotal: any, newLineItems: any): void;

    completeShippingContactSelection(status: ApplePayStatusCodes, newShippingMethods: any, newTotal: any, newLineItems: any): void;

    completeShippingMethodSelection(status: ApplePayStatusCodes, newTotal: any, newLineItems: any): void;

    supportsVersion(version: number): boolean;

    oncancel: (event: any) => void;

    onpaymentauthorized: (event: any) => void;

    onpaymentmethodselected: (event: any) => void;

    onshippingcontactselected: (event: any) => void;

    onshippingmethodselected: (event: any) => void;

    onvalidatemerchant: (event: any) => void;
  }
}

/**
 * @module braintree-web/apple-pay
 * @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.*
 */
declare namespace braintree {
  export interface ApplePay {
    /**
     * @static
     * @function create
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {callback} callback The second argument, `data`, is the {@link ApplePay} instance.
     * @returns {void}
     */
    create: (options: { client: Client }, callback: callback) => void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Merges a payment request with Braintree defaults
     * The following properties are assigned to `paymentRequest` if not already defined
     * - countryCode
     * - currencyCode
     * - merchantCapabilities
     * - supportedNetworks
     * @public
     * @param {external:ApplePayPaymentRequest} paymentRequest The payment request details to apply on top of those from Braintree.
     * @returns {external:ApplePayPaymentRequest} The decorated `paymentRequest`.
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   // ...
     *   var paymentRequest = applePay.createPaymentRequest({
     *    total: {
     *      label: 'My Company',
     *      amount: '19.99'
     *   });
     *
     *   console.log(paymentRequest);
     *   // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
     *
     */
    createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest

    /**
     * Validates the merchant website, as required by ApplePaySession before payment can be authorized.
     * @public
     * @param {object} options Options
     * @param {string} options.validationURL The validationURL fram an ApplePayValidateMerchantEvent.
     * @param {string} [options.displayName]
     * - The canonical name for your store.
     * - The system may display this name to the user.
     * - Use a 128-character or less, UTF-8 string.
     * - Do not localize the name.
     * @param {string} [options.merchantIdentifier]
     * Your Apple merchant identifier. This is the Apple Merchant ID created on the Apple Developer Portal.
     * Defaults to the merchant identifier specified in the Braintree Control Panel.
     * You can use this field to override the merchant identifier for this transaction.
     * @param {callback} callback The second argument, <code>data</code>, is the Apple Pay merchant session object.
     * Pass the merchant session to your Apple Pay session's completeMerchantValidation method.
     * @returns {void}
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   var session = new ApplePaySession(1, {
     *     // This should be the payment request object that
     *     // contains the information needed to display the payment sheet.
     *   });
     *
     *   session.onvalidatemerchant = function (event) {
     *     applePay.performValidation({
     *       validationURL: event.validationURL
     *     }, function(err, validationData) {
     *       if (err) {
     *         console.error(err);
     *         session.abort();
     *         return;
     *       }
     *       session.completeMerchantValidation(validationData);
     *     });
     *   };
     * });
     */
    performValidation(options: { validationURL: string, displayName?: string, merchantIdentifier?: string }, callback: callback): void;

    /**
     * Tokenizes an Apple Pay payment.
     * @public
     * @param {object} options Options
     * @param {object} options.token The `payment.token` property of an {@link external:ApplePayPaymentAuthorizedEvent}
     * @param {callback} callback The second argument, <code>data</code>, is the tokenized payload.
     * @returns {void}
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   var session = new ApplePaySession(1, { });
     *
     *   session.onpaymentauthorized = function (event) {
     *     applePay.tokenize({
     *       token: event.payment.token
     *     }, function (err, tokenizedPayload) {
     *       if (err) {
     *         session.completePayment(ApplePaySession.STATUS_FAILURE);
     *         return;
     *       }
     *       session.completePayment(ApplePaySession.STATUS_SUCCESS);
     *
     *       // Send the tokenizedPayload to your server.
     *     });
     *  };
     * });
     */
    tokenize(options: { token: any }, callback: callback): void;
  }
}

/** @module braintree-web/client */
declare namespace braintree {
  /**
 * This object is returned by {@link Client#getConfiguration|getConfiguration}. This information is used extensively by other Braintree modules to properly configure themselves.
 * @property {object} client The braintree-web/client parameters.
 * @property {string} client.authorization A tokenizationKey or clientToken.
 * @property {object} gatewayConfiguration Gateway-supplied configuration.
 * @property {object} analyticsMetadata Analytics-specific data.
 * @property {string} analyticsMetadata.sessionId Uniquely identifies a browsing session.
 * @property {string} analyticsMetadata.sdkVersion The braintree.js version.
 * @property {string} analyticsMetadata.merchantAppId Identifies the merchant's web app.
 */
  interface ClientAnalyticsMetadata {
    sessionId: string;
    sdkVersion: string;
    merchantAppId: string;
  }

  interface Configuration {
    client: Client;
    gatewayConfiguration: any;
    analyticsMetadata: ClientAnalyticsMetadata;
  }

  interface CreditCardInfo {
    number: string;
    cvv: string;
    expirationDate: string;
    billingAddress: {
      postalCode?: string;
    }
  }

  export interface Client {
    authorization: string;

    /**
     * @function
     * @description This function is the entry point for the <code>braintree.client</code> module. It is used for creating {@link Client} instances that service communication to Braintree servers.
     * @param {object} options Object containing all {@link Client} options:
     * @param {string} options.authorization A tokenizationKey or clientToken.
     * @param {callback} callback The second argument, <code>data</code>, is the {@link Client} instance.
     * @returns {void}
     * @example
     * var createClient = require('braintree-web/client').create;
     *
     * createClient({
     *   authorization: CLIENT_AUTHORIZATION
     * }, function (createErr, clientInstance) {
     *   ...
     * });
     * @static
     */
    create(options: { authorization: string }): Promise<Client>;
    create(options: { authorization: string }, callback: callback): void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Returns a copy of the configuration values.
     * @public
     * @returns {Client~configuration} configuration
     */
    getConfiguration(): Configuration;

    /**
     * Used by other modules to formulate all network requests to the Braintree gateway. It is also capable of being used directly from your own form to tokenize credit card information. However, be sure to satisfy PCI compliance if you use direct card tokenization.
     * @public
     * @param {object} options Request options:
     * @param {string} options.method HTTP method, e.g. "get" or "post"
     * @param {string} options.endpoint Endpoint path. e.g. "payment_methods"
     * @param {object} options.data Data to send with the request
     * @param {number} [options.timeout=60000] Set a timeout (in milliseconds) for the request.
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @example
     * <caption>Direct Credit Card Tokenization</caption>
     * var createClient = require('braintree-web/client').create;
     *
     * createClient({
     *   authorization: CLIENT_AUTHORIZATION
     * }, function (createErr, clientInstance) {
     *   var form = document.getElementById('my-form-id');
     *   var data = {
     *     creditCard: {
     *       number: form['cc-number'].value,
     *       cvv: form['cc-cvv'].value,
     *       expirationDate: form['cc-date'].value,
     *       billingAddress: {
     *         postalCode: form['cc-postal'].value
     *       },
     *       options: {
     *         validate: false
     *       }
     *     }
     *   };
     *
     *   // Warning: For a merchant to be eligible for the easiest level of PCI compliance (SAQ A),
     *   // payment fields cannot be hosted on your checkout page.
     *   // For an alternative to the following, use Hosted Fields.
     *   clientInstance.request({
     *     endpoint: 'payment_methods/credit_cards',
     *     method: 'post',
     *     data: data
     *   }, function (requestErr, response) {
     *  // More detailed example of handling API errors: https://codepen.io/braintree/pen/MbwjdM
     *     if (requestErr) { throw new Error(requestErr); }
     *
     *     console.log('Got nonce:', response.creditCards[0].nonce);
     *   });
     * });
     * @returns {void}
     */
    request(options: { method: string, endpoint: string, data: any, timeout?: number }, callback: callback): void;
  }
}

/** @module braintree-web/data-collector */
declare namespace braintree {
  export interface DataCollector {
    /**
     * @static
     * @function create
     * @description Creates a DataCollector instance. Requires advanced fraud protection to be enabled in the Braintree gateway. Contact our [support team](mailto:<EMAIL>) to configure your Kount ID.
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {boolean} [options.kount] If true, Kount fraud data collection is enabled.
     * @param {boolean} [options.paypal] If true, PayPal fraud data collection is enabled.
     * @param {callback} callback The second argument, `data`, is the {@link DataCollector} instance.
     * @returns {void}
     */
    create(options: { client: Client, kount: boolean, paypal: boolean }): Promise<DataCollector>;
    create(options: { client: Client, kount: boolean, paypal: boolean }, callback: callback): void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * @memberof DataCollector
     * @name deviceData
     * @type string
     * @description JSON string to pass with server transactions.
     * @instance
     */
    deviceData: string;

    /**
     * @memberof DataCollector
     * @name teardown
     * @function
     * @description Cleanly remove all event handlers and DOM nodes that were added.
     * @param {callback} [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
     * @instance
     * @returns {void}
     */
    teardown(callback?: callback): void;
  }
}

/** @module braintree-web/hosted-fields */
declare namespace braintree {
  /**
   * Fields used in {@link module:braintree-web/hosted-fields~fieldOptions fields options}
   * @typedef {object} field
   * @property {string} selector A CSS selector to find the container where the hosted field will be inserted.
   * @property {string} [placeholder] Will be used as the `placeholder` attribute of the input. If `placeholder` is not natively supported by the browser, it will be polyfilled.
   * @property {string} [type] Will be used as the `type` attribute of the input. To mask `cvv` input, for instance, `type: "password"` can be used.
   * @property {boolean} [formatInput=true] - Enable or disable automatic formatting on this field.
   * @property {object|boolean} [select] If truthy, this field becomes a `<select>` dropdown list. This can only be used for `expirationMonth` and `expirationYear` fields.
   * @property {string[]} [select.options] An array of 12 strings, one per month. This can only be used for the `expirationMonth` field. For example, the array can look like `['01 - January', '02 - February', ...]`.
   */
  interface HostedFieldsField {
    selector: string;
    placeholder?: string;
    type?: string;
    formatInput?: boolean;
    select?: boolean | { options: string[] };
  }

  /**
 * An object that has {@link module:braintree-web/hosted-fields~field field objects} for each field. Used in {@link module:braintree-web/hosted-fields~create create}.
 * @typedef {object} fieldOptions
 * @property {field} [number] A field for card number.
 * @property {field} [expirationDate] A field for expiration date in `MM/YYYY` format. This should not be used with the `expirationMonth` and `expirationYear` properties.
 * @property {field} [expirationMonth] A field for expiration month in `MM` format. This should be used with the `expirationYear` property.
 * @property {field} [expirationYear] A field for expiration year in `YYYY` format. This should be used with the `expirationMonth` property.
 * @property {field} [cvv] A field for 3 or 4 digit CVV or CID.
 * @property {field} [postalCode] A field for postal or region code.
 */
  interface HostedFieldFieldOptions {
    number: HostedFieldsField;
    expirationDate?: HostedFieldsField;
    expirationMonth?: HostedFieldsField;
    expirationYear?: HostedFieldsField;
    cvv: HostedFieldsField;<commit_msg>update HostedFieldsField for braintree-web (#35638)<commit_after>// Type definitions for Braintree-web v3.6.1
// Project: https://github.com/braintree/braintree-web
// Definitions by: <NAME> <https://github.com/chlela>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1

/**
 * @module braintree-web/american-express
 * @description This module is for use with Amex Express Checkout. To accept American Express cards, use Hosted Fields.
 */
declare namespace braintree {
  export interface AmericanExpress {
    /**
     * @static
     * @function create
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {callback} callback The second argument, `data`, is the {@link AmericanExpress} instance.
     * @returns {void}
     */
    create: (options: { client: Client }, callback: callback) => void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Gets the rewards balance associated with a Braintree nonce.
     * @public
     * @param {object} options Request options
     * @param {string} options.nonce An existing Braintree nonce.
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @returns {void}
     * @example
     * var americanExpress = require('braintree-web/american-express');
     *
     * americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) {
     *   var options = {nonce: existingBraintreeNonce};
     *   americanExpressInstance.getRewardsBalance(options, function (getErr, payload) {
     *     if (getErr || payload.error) {
     *       // Handle error
     *       return;
     *     }
     *
     *     console.log('Rewards amount: ' + payload.rewardsAmount);
     *   });
     * });
     */
    getRewardsBalance(options: { nonce: string }, callback: callback): void;

    /**
     * Gets the Express Checkout nonce profile given a nonce from American Express.
     * @public
     * @param {object} options Request options
     * @param {string} options.nonce An existing nonce from American Express (note that this is <em>not</em> a nonce from Braintree).
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @returns {void}
     * @example
     * var americanExpress = require('braintree-web/american-express');
     *
     * americanExpress.create({client: clientInstance}, function (createErr, americanExpressInstance) {
     *   var options = {nonce: existingAmericanExpressNonce};
     *   americanExpressInstance.getExpressCheckoutProfile(options, function (getErr, payload) {
     *     if (getErr) {
     *       // Handle error
     *       return;
     *     }
     *
     *     console.log('Number of cards: ' + payload.amexExpressCheckoutCards.length);
     *   });
     * });
     */
    getExpressCheckoutProfile(options: { nonce: string }, callback: callback): void;
  }
}


declare namespace braintree {
  // more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest

  //  billingContact
  //  Billing contact information for the user.
  //    countryCode
  //Required.The merchant’s two- letter ISO 3166 country code.
  //    currencyCode
  //  Required.The three- letter ISO 4217 currency code for the payment.
  //    lineItems
  //A set of line items that explain recurring payments and additional charges.
  //    merchantCapabilities
  //  Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
  //    requiredBillingContactFields
  //  The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
  //    requiredShippingContactFields
  //  The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
  //    shippingContact
  //  Shipping contact information for the user.
  //    shippingMethods
  //A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
  //    shippingType
  //  How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
  //    supportedNetworks
  //  Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
  //    total
  //  Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
  interface ApplePayPaymentRequest {
    total: {
      label: string;
      amount: string;
    };
    countryCode: string;
    currencyCode: string;
    supportedNetworks: string[];
    merchantCapabilities: string[];

    billingContact?: any;
    shippingContact?: any;
    shippingMethods?: any;
    shippingType?: any;
    requiredBillingContactFields?: any;
    requiredShippingContactFields?: any;
  }

  export enum ApplePayStatusCodes {
    // The requested action succeeded.
    STATUS_SUCCESS = 1,
    // The requested action failed.
    STATUS_FAILURE,
    // The billing address is not valid.
    STATUS_INVALID_BILLING_POSTAL_ADDRESS,
    // The shipping address is not valid.
    STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
    // The shipping contact information is not valid.
    STATUS_INVALID_SHIPPING_CONTACT,
    // The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
    STATUS_PIN_REQUIRED,
    // The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
    STATUS_PIN_INCORRECT,
    // The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
    STATUS_PIN_LOCKOUT,
  }

  interface ApplePayPayload {
    merchantIdentifier: string;
    domainName: string;
    displayName: string;
  }

  export class ApplePaySession {
    constructor(version: number, request: ApplePayPaymentRequest);

    canMakePayments(): boolean;

    canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;

    completeMerchantValidation(merchantSession: any): void;

    abort(): void;

    begin(): void;

    completePayment(status: ApplePayStatusCodes): void;

    completePaymentMethodSelection(newTotal: any, newLineItems: any): void;

    completeShippingContactSelection(status: ApplePayStatusCodes, newShippingMethods: any, newTotal: any, newLineItems: any): void;

    completeShippingMethodSelection(status: ApplePayStatusCodes, newTotal: any, newLineItems: any): void;

    supportsVersion(version: number): boolean;

    oncancel: (event: any) => void;

    onpaymentauthorized: (event: any) => void;

    onpaymentmethodselected: (event: any) => void;

    onshippingcontactselected: (event: any) => void;

    onshippingmethodselected: (event: any) => void;

    onvalidatemerchant: (event: any) => void;
  }
}

/**
 * @module braintree-web/apple-pay
 * @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.*
 */
declare namespace braintree {
  export interface ApplePay {
    /**
     * @static
     * @function create
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {callback} callback The second argument, `data`, is the {@link ApplePay} instance.
     * @returns {void}
     */
    create: (options: { client: Client }, callback: callback) => void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Merges a payment request with Braintree defaults
     * The following properties are assigned to `paymentRequest` if not already defined
     * - countryCode
     * - currencyCode
     * - merchantCapabilities
     * - supportedNetworks
     * @public
     * @param {external:ApplePayPaymentRequest} paymentRequest The payment request details to apply on top of those from Braintree.
     * @returns {external:ApplePayPaymentRequest} The decorated `paymentRequest`.
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   // ...
     *   var paymentRequest = applePay.createPaymentRequest({
     *    total: {
     *      label: 'My Company',
     *      amount: '19.99'
     *   });
     *
     *   console.log(paymentRequest);
     *   // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
     *
     */
    createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest

    /**
     * Validates the merchant website, as required by ApplePaySession before payment can be authorized.
     * @public
     * @param {object} options Options
     * @param {string} options.validationURL The validationURL fram an ApplePayValidateMerchantEvent.
     * @param {string} [options.displayName]
     * - The canonical name for your store.
     * - The system may display this name to the user.
     * - Use a 128-character or less, UTF-8 string.
     * - Do not localize the name.
     * @param {string} [options.merchantIdentifier]
     * Your Apple merchant identifier. This is the Apple Merchant ID created on the Apple Developer Portal.
     * Defaults to the merchant identifier specified in the Braintree Control Panel.
     * You can use this field to override the merchant identifier for this transaction.
     * @param {callback} callback The second argument, <code>data</code>, is the Apple Pay merchant session object.
     * Pass the merchant session to your Apple Pay session's completeMerchantValidation method.
     * @returns {void}
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   var session = new ApplePaySession(1, {
     *     // This should be the payment request object that
     *     // contains the information needed to display the payment sheet.
     *   });
     *
     *   session.onvalidatemerchant = function (event) {
     *     applePay.performValidation({
     *       validationURL: event.validationURL
     *     }, function(err, validationData) {
     *       if (err) {
     *         console.error(err);
     *         session.abort();
     *         return;
     *       }
     *       session.completeMerchantValidation(validationData);
     *     });
     *   };
     * });
     */
    performValidation(options: { validationURL: string, displayName?: string, merchantIdentifier?: string }, callback: callback): void;

    /**
     * Tokenizes an Apple Pay payment.
     * @public
     * @param {object} options Options
     * @param {object} options.token The `payment.token` property of an {@link external:ApplePayPaymentAuthorizedEvent}
     * @param {callback} callback The second argument, <code>data</code>, is the tokenized payload.
     * @returns {void}
     * @example
     * var applePay = require('braintree-web/apple-pay');
     *
     * applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
     *   var session = new ApplePaySession(1, { });
     *
     *   session.onpaymentauthorized = function (event) {
     *     applePay.tokenize({
     *       token: event.payment.token
     *     }, function (err, tokenizedPayload) {
     *       if (err) {
     *         session.completePayment(ApplePaySession.STATUS_FAILURE);
     *         return;
     *       }
     *       session.completePayment(ApplePaySession.STATUS_SUCCESS);
     *
     *       // Send the tokenizedPayload to your server.
     *     });
     *  };
     * });
     */
    tokenize(options: { token: any }, callback: callback): void;
  }
}

/** @module braintree-web/client */
declare namespace braintree {
  /**
 * This object is returned by {@link Client#getConfiguration|getConfiguration}. This information is used extensively by other Braintree modules to properly configure themselves.
 * @property {object} client The braintree-web/client parameters.
 * @property {string} client.authorization A tokenizationKey or clientToken.
 * @property {object} gatewayConfiguration Gateway-supplied configuration.
 * @property {object} analyticsMetadata Analytics-specific data.
 * @property {string} analyticsMetadata.sessionId Uniquely identifies a browsing session.
 * @property {string} analyticsMetadata.sdkVersion The braintree.js version.
 * @property {string} analyticsMetadata.merchantAppId Identifies the merchant's web app.
 */
  interface ClientAnalyticsMetadata {
    sessionId: string;
    sdkVersion: string;
    merchantAppId: string;
  }

  interface Configuration {
    client: Client;
    gatewayConfiguration: any;
    analyticsMetadata: ClientAnalyticsMetadata;
  }

  interface CreditCardInfo {
    number: string;
    cvv: string;
    expirationDate: string;
    billingAddress: {
      postalCode?: string;
    }
  }

  export interface Client {
    authorization: string;

    /**
     * @function
     * @description This function is the entry point for the <code>braintree.client</code> module. It is used for creating {@link Client} instances that service communication to Braintree servers.
     * @param {object} options Object containing all {@link Client} options:
     * @param {string} options.authorization A tokenizationKey or clientToken.
     * @param {callback} callback The second argument, <code>data</code>, is the {@link Client} instance.
     * @returns {void}
     * @example
     * var createClient = require('braintree-web/client').create;
     *
     * createClient({
     *   authorization: CLIENT_AUTHORIZATION
     * }, function (createErr, clientInstance) {
     *   ...
     * });
     * @static
     */
    create(options: { authorization: string }): Promise<Client>;
    create(options: { authorization: string }, callback: callback): void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * Returns a copy of the configuration values.
     * @public
     * @returns {Client~configuration} configuration
     */
    getConfiguration(): Configuration;

    /**
     * Used by other modules to formulate all network requests to the Braintree gateway. It is also capable of being used directly from your own form to tokenize credit card information. However, be sure to satisfy PCI compliance if you use direct card tokenization.
     * @public
     * @param {object} options Request options:
     * @param {string} options.method HTTP method, e.g. "get" or "post"
     * @param {string} options.endpoint Endpoint path. e.g. "payment_methods"
     * @param {object} options.data Data to send with the request
     * @param {number} [options.timeout=60000] Set a timeout (in milliseconds) for the request.
     * @param {callback} callback The second argument, <code>data</code>, is the returned server data.
     * @example
     * <caption>Direct Credit Card Tokenization</caption>
     * var createClient = require('braintree-web/client').create;
     *
     * createClient({
     *   authorization: CLIENT_AUTHORIZATION
     * }, function (createErr, clientInstance) {
     *   var form = document.getElementById('my-form-id');
     *   var data = {
     *     creditCard: {
     *       number: form['cc-number'].value,
     *       cvv: form['cc-cvv'].value,
     *       expirationDate: form['cc-date'].value,
     *       billingAddress: {
     *         postalCode: form['cc-postal'].value
     *       },
     *       options: {
     *         validate: false
     *       }
     *     }
     *   };
     *
     *   // Warning: For a merchant to be eligible for the easiest level of PCI compliance (SAQ A),
     *   // payment fields cannot be hosted on your checkout page.
     *   // For an alternative to the following, use Hosted Fields.
     *   clientInstance.request({
     *     endpoint: 'payment_methods/credit_cards',
     *     method: 'post',
     *     data: data
     *   }, function (requestErr, response) {
     *  // More detailed example of handling API errors: https://codepen.io/braintree/pen/MbwjdM
     *     if (requestErr) { throw new Error(requestErr); }
     *
     *     console.log('Got nonce:', response.creditCards[0].nonce);
     *   });
     * });
     * @returns {void}
     */
    request(options: { method: string, endpoint: string, data: any, timeout?: number }, callback: callback): void;
  }
}

/** @module braintree-web/data-collector */
declare namespace braintree {
  export interface DataCollector {
    /**
     * @static
     * @function create
     * @description Creates a DataCollector instance. Requires advanced fraud protection to be enabled in the Braintree gateway. Contact our [support team](mailto:<EMAIL>) to configure your Kount ID.
     * @param {object} options Creation options:
     * @param {Client} options.client A {@link Client} instance.
     * @param {boolean} [options.kount] If true, Kount fraud data collection is enabled.
     * @param {boolean} [options.paypal] If true, PayPal fraud data collection is enabled.
     * @param {callback} callback The second argument, `data`, is the {@link DataCollector} instance.
     * @returns {void}
     */
    create(options: { client: Client, kount: boolean, paypal: boolean }): Promise<DataCollector>;
    create(options: { client: Client, kount: boolean, paypal: boolean }, callback: callback): void;

    /**
     * @description The current version of the SDK, i.e. `3.0.2`.
     * @type {string}
     */
    VERSION: string;

    /**
     * @memberof DataCollector
     * @name deviceData
     * @type string
     * @description JSON string to pass with server transactions.
     * @instance
     */
    deviceData: string;

    /**
     * @memberof DataCollector
     * @name teardown
     * @function
     * @description Cleanly remove all event handlers and DOM nodes that were added.
     * @param {callback} [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
     * @instance
     * @returns {void}
     */
    teardown(callback?: callback): void;
  }
}

interface HostedFieldsFieldMaskInput {
    /**
     * The character to use when masking the input.
     * @default '•'
     */
    character?: string;
    /**
     * Only applicable for the credit card field. Whether or not to show the last 4 digits of the card when masking.
     */
    showLastFour?: boolean;
}

/** @module braintree-web/hosted-fields */
declare namespace braintree {
  /**
   * Fields used in {@link module:braintree-web/hosted-fields~fieldOptions fields options}
   * @typedef {object} field
   * @property {string} selector A CSS selector to find the container where the hosted field will be inserted.
   * @property {string} [placeholder] Will be used as the `placeholder` attribute of the input. If `placeholder` is not natively supported by the browser, it will be polyfilled.
   * @property {string} [type] Will be used as the `type` attribute of the input. To mask `cvv` input, for instance, `type: "password"` can be used.
   * @property {boolean} [formatInput=true] - Enable or disable automatic formatting on this field.
   * @property {object|boolean} [select] If truthy, this field becomes a `<select>` dropdown list. This can only be used for `expirationMonth` and `expirationYear` fields.
   * @property {string[]} [select.options] An array of 12 strings, one per month. This can only be used for the `expirationMonth` field. For example, the array can look like `['01 - January', '02 - February', ...]`.
   * @property {boolean | HostedFieldsFieldMaskInput} [maskInput] Enable or disable input masking when input is not focused. If set to `true` instead of an object, the defaults for the `maskInput` parameters will be used.
   */
  interface HostedFieldsField {
    selector: string;
    placeholder?: string;
    type?: string;
    formatInput?: boolean;
    maskInput?: boolean | HostedFieldsFieldMaskInput;
    select?: boolean | { options: string[] };
    maxCardLength?: number;
    maxlength?: number;
    minlength?: number;
    prefill?: string;
    rejectUnsupportedCards?: boolean;
  }

  /**
 * An object that has {@link module:braintree-web/hosted-fields~field field objects} for each field. Used in {@link module:braintree-web/hosted-fields~create create}.
 * @typedef {object} fieldOptions
 * @property {field} [number] A field for card number.
 * @property {field} [expirationDate] A field for expiration date in `MM/YYYY` format. This should not be used with the `expirationMonth` and `expirationYear` properties.
 * @property {field} [expirationMonth] A field for expiration month in `MM` format. This should be used with the `expirationYear` property.
 * @property {field} [expirationYear] A field for expiration year in `YYYY` format. This should be used with the `expirationMonth` property.
 * @property {field} [cvv] A field for 3 or 4 digit CVV or CID.
 * @property {field} [postalCode] A field for postal or region code.
 */
  interface HostedFieldFieldOptions {
    number: HostedFieldsField;
    expirationDate?: HostedFieldsField;
    expirationMonth?: HostedFieldsField;
    expirationYear?: HostedFieldsField;
    cvv: HostedFieldsField;
{'fraction_non_alphanumeric': 0.102777062910886, 'fraction_numerical': 0.002854268535198746, 'mean_word_length': 3.0496447181430604, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 67, 'https://': 10, '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': '4715141', 'n_tokens_mistral': 11882, 'n_tokens_neox': 11622, 'n_words': 3924}