onCardTypeChange Callback

The onCardTypeChange( ) method invokes the callback function when the card type is first detected or changed.

Usage

PaymentSession.onCardTypeChange(function(selector, result), [scope])

Example

PaymentSession.onCardTypeChange(function(selector, result) {
    //handle change event
    if (result.status === 'SUPPORTED') {
        // use card details like brand, fundingMethod, issuer and scheme
        console.log(result.brand);
        console.log(result.fundingMethod);
        console.log(result.issuer);
        console.log(result.scheme);
        console.log(result.order.amount);
        console.log(result.order.netAmount);
        console.log(result.order.merchantCharge.type);
        console.log(result.order.merchantCharge.amount);
        console.log(result.capabilities);
        console.log(result.interactionConstraints);
        console.log(result.paymentPlans);
        console.log(result.localBrand);
        console.log(result.currencyConversion.offerText);
        console.log(result.currencyConversion.payerAmount);
        console.log(result.currencyConversion.payerCurrency);
        console.log(result.currencyConversion.requestId);
    } else if (result.status === 'INSUFFICIENT_LENGTH') {
        // selector for invalid field is provided
        console.log('Minimum of 10 digits required to determine card type.');
    } else if (result.status === 'NOT_SUPPORTED') {
        console.log('The card type you entered is not supported.');
    }
});

Arguments

<callbackFunction> Function COMPULSORY

The callback function invoked with selector and the result when an event is triggered.

  1. selector String COMPULSORY

    Identifier of the HTML element which is card-number.

  2. result Object COMPULSORY

    Result object which sent as an argument to the function.

    1. result.brand String COMPULSORY

      The brand name used to describe the card that is recognized and accepted globally.

    2. result.fundingMethod String COMPULSORY

      The method used by the payer to provide the funds for the payment.

    3. result.issuer String COMPULSORY

      The issuer of the card, if known.

    4. result.scheme String COMPULSORY

      The organization that owns a card brand and defines operating regulations for its use.

    5. result.order.amount Decimal COMPULSORY

      The total amount for the order.

    6. result.order.netAmount Decimal COMPULSORY

      The amount payable for the order before surcharging is applied.

    7. result.order.merchantCharge Object CONDITIONAL

      Information about additional fees that you are charging the payer for processing the payment for this order, for example, a surcharge, convenience or service fee.

    8. result.order.merchantCharge.type String CONDITIONAL

      The type of the additional fee that you are charging the payer.

      • Existence : CONDITIONAL
      Validation Rules
      • JSON Type : String
      Value must be a member of the following list. The values are case sensitive.
      CONVENIENCE_FEE
      A fee that covers the cost of accepting a payment using a non-standard payment channel for your business, for example, a payment made over the phone rather than using your website.
      SERVICE_FEE
      A type of convenience fee with specific rules and restricted to education and government merchants with specific merchant category codes (MCC).
      SURCHARGE
      A fee that covers your cost of accepting a payment method.
    9. result.order.merchantCharge.amount Decimal CONDITIONAL

      The amount of the additional fee that you are charging the payer.

      • Existence : CONDITIONAL
      Validation Rules
      • JSON Type : Decimal
      Data is a string that consists of the characters 0-9 and '.' and represents a valid decimal number.
      minimum length
      1
      maximum length
      14
    10. result.capabilities String COMPULSORY

      Indicates capabilities available to you for card payments.

      • Existence : ALWAYS PROVIDED
      Validation Rules
      • JSON Type : String
      Value must be a member of the following list. The values are case sensitive.
      ADDRESS_VERIFICATION
      Indicates if you are allowed to use the Address Verification Service (AVS) to verify address details supplied by the cardholder.
      CARD_SECURITY_CODE
      Indicates if you are allowed to use the Card Security Check to verify the Card Security Code (CSC) supplied by the cardholder
      NO_CARD_SECURITY_CODE_PRINTED_ON_CARD
      Indicates if you are allowed to accept payments from credit cards without a Card Security Code (CSC) printed on the card.
    11. result.interactionConstraints String COMPULSORY

      Indicates if the cardholder is required to provide additional information when using a card to pay for the order.

      • Existence : CONDITIONAL
      Validation Rules
      • JSON Type : String
      Value must be one or more comma separated members of the following list. The values are case sensitive.
      CREDIT_DEBIT_SELECTION
      Indicates if the cardholder must be forced to select between using a credit card or a debit card, before entering their card details.
      CARD_TYPE_SELECTION
      Indicates if the cardholder must be forced to select the card type.This is required when the card is identified as a co-branded card and regulation stipulates that the payer must select the card type.The card type selected by the payer must subsequently be provided in field sourceOfFunds.provided.card.cardType on financial transaction requests.
      CARD_SECURITY_CODE_ENTRY
      Indicates if the cardholder must be forced to enter the Card Security Code (CSC) when using a credit card to pay for the order.
    12. result.paymentPlans String COMPULSORY

      Information on valid payment plans for this order based on the values supplied in the request parameters.

    13. result.localBrand String COMPULSORY

      The brand name used to describe a card that is recognized and accepted within its country/region of origin.

    14. result.currencyConversion.offerText String COMPULSORY

      This is a piece of HTML markup that can be included as part of your website to offer the payer the currency conversion quote.

      It contains information necessary to comply with scheme requirements.

      • Existence : CONDITIONAL
      Validation Rules
      Data can consist of any characters
      JSON type
      String
      minimum length
      1
      maximum length
      4096
    15. result.currencyConversion.payerAmount Decimal COMPULSORY

      The total amount of the transaction in the payer's currency.

      You must include this field if the payer accepted the DCC offer you presented to them.

      • Existence : CONDITIONAL
      Validation Rules
      Data is a decimal number.
      JSON type
      Number
      maximum value
      1000000000000
      minimum value
      0
      maximum post-decimal digits
      3
    16. result.currencyConversion.payerCurrency Upper case alphabetic text COMPULSORY

      The currency of the DCC rate quote provided by your DCC Service Provider.

      The currency must be expressed as an ISO 4217 alpha code, e.g. USD and must be different to that provided for transaction currency. You must include this field if the payer accepted the DCC offer you presented to them.

      • Existence : CONDITIONAL
      Validation Rules
      Data must consist of the characters A-Z
      JSON type
      String
      minimum length
      3
      maximum length
      3
    17. result.currencyConversion.requestId String COMPULSORY

      fThe unique identifier for your DCC quote request as returned in the PAYMENT_OPTIONS_INQUIRY response.

      • Existence : CONDITIONAL
      Validation Rules
      Data can consist of any characters
      JSON type
      String
      minimum length
      1
      maximum length
      100
scope String OPTIONAL

The optional named instance of a card payment data set within a session. See Multiple Hosted Sessions for more information.

Return Value

None

Copyright © 2023 MasterCard