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);
    } 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 when the event is triggered.

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