Class: TranspayrentClickToPayHelper

TranspayrentClickToPayHelper(environment, config, transactionopt)

The Transpayrent Helper SDK for Mastercard Click-to-Pay is a thin wrapper around the Mastercard Unified Checkout Solutions (UCS) JavaScript SDK.

This helper does not orchestrate the Click-to-Pay UI flow. Merchants remain responsible for recognition, OTP, card selection, fallback screens, and checkout popups. The helper provides:

  1. Button rendering via TranspayrentClickToPayHelper#displayPaymentButton
  2. Mastercard passthrough methods with identical names (init, getCards, idLookup, etc.)
  3. Transpayrent integration utilities that reduce boilerplate around readiness checks, checkout result normalization, gateway handoff context, and optional session storage

Click to Pay intentionally does not provide displayPaymentSheet orchestration.

Recommended merchant sequence:

  1. Load Transpayrent SDK + Mastercard UCS script
  2. helper.getReadiness() and show/hide Click to Pay UI accordingly
  3. helper.init(merchantOwnedInitRequest) then call Mastercard passthrough methods as needed
  4. Call checkoutWithCard / checkoutWithNewCard — they normalize the Mastercard result and store the checkout handoff automatically when checkoutActionCode is COMPLETE
  5. Apply the saved handoff when building gateway authenticate / authorize payloads via helper.applyCheckoutHandoff(paymentDetails) (or the static TranspayrentClickToPayHelper.applyCheckoutHandoff(paymentDetails, handoff))
  6. Continue with Transpayrent gateway authenticate / authorize or UI Helper completePayment

Constructor

new TranspayrentClickToPayHelper(environment, config, transactionopt)

Creates a new instance of the Transpayrent Click-to-Pay Helper, which uses the Mastercard Unified Checkout Solutions SDK internally to abstract the Click-to-Pay API.

Parameters:
Name Type Attributes Description
environment String

The Click-to-Pay environment, either PRODUCTION or TEST

config ClickToPayConfig

The base configuration for Click-to-Pay

transaction ClickToPayTransaction <optional>

Optional transaction details for Click-to-Pay

License:
  • Common Transpayrent API license
Source:
See:
Example

Recommended merchant-owned Click-to-Pay checkout handoff

 var helper = sdk.getClickToPayHelper({ debugLogging: true });
 var readiness = helper.getReadiness();
 if (!readiness.ready) {
     console.warn('Click to Pay unavailable:', readiness.issues);
     return;
 }

 helper.init(merchantOwnedInitRequest)
     .then(function() { return helper.checkoutWithCard(merchantOwnedCheckoutRequest); })
     .then(function(checkoutResult) {
         if (checkoutResult.checkoutActionCode !== 'COMPLETE') {
             return;
         }
         return uiHelper.completePayment(205, false);
     })
     .catch(function(error) {
         console.error(error.api, error.status, error.messages[0].code, error.messages[0].message);
     });

Methods

applyCheckoutHandoff(paymentDetails, handoffopt) → {Object}

Applies a saved checkout handoff to an authenticate/authorize payload. When handoff is omitted, uses the handoff stored by the last successful checkout call.

Parameters:
Name Type Attributes Description
paymentDetails Object
handoff ClickToPayCheckoutHandoffRef <optional>
Source:
Throws:

Transpayrent-normalized error when handoff is missing or incomplete

Type
Object
Returns:
Type
Object

assertReady()

Throws a normalized Click-to-Pay error when the Mastercard UCS SDK is not ready.

Source:

authenticate(request) → {Promise}

Authenticates a Click-to-Pay consumer using device fingerprint or credentials.

Parameters:
Name Type Description
request Object

The authentication request object

Source:
Returns:

Promise that resolves with authentication result

Type
Promise

checkoutWithCard(request) → {Promise.<ClickToPayCheckoutHandoff>}

Initiates checkout with a saved/recognized card.

Parameters:
Name Type Description
request Object

The checkout request with selected card

Source:
Returns:

Normalized checkout result; stores valid handoff on COMPLETE

Type
Promise.<ClickToPayCheckoutHandoff>

checkoutWithNewCard(request) → {Promise.<ClickToPayCheckoutHandoff>}

Initiates checkout with a newly encrypted card.

Parameters:
Name Type Description
request Object

The checkout request with encrypted card data

Source:
Returns:

Normalized checkout result; stores valid handoff on COMPLETE

Type
Promise.<ClickToPayCheckoutHandoff>

displayPaymentButton(container, paymentMethodIds, configopt)

Displays the Click-to-Pay button using the SRC UI Kit src-button web component when available. When <src-button> is unavailable, a plain HTML button is rendered as a visual/click target fallback only. That fallback does not indicate Mastercard Click-to-Pay runtime readiness; call TranspayrentClickToPayHelper#getReadiness before showing merchant-owned Click-to-Pay UI. It is strongly recommended to use Transpayrent#displayPaymentButton.

Parameters:
Name Type Attributes Description
container *

The container element for the button

paymentMethodIds Array.<PAYMENT_METHOD_ID>

List of payment method IDs from the gateway

config Object <optional>

Button-only configuration (buttonText, onClick)

Source:
See:

encryptCard(request) → {Promise}

Encrypts a new card for storage and use with Click-to-Pay.

Parameters:
Name Type Description
request Object

The encrypt card request with PAN and card details

Source:
Returns:

Promise that resolves with encrypted card data

Type
Promise

getCards(requestopt) → {Promise.<Array>}

Retrieves the list of recognized cards for the current consumer. Should be called after init() to determine if the consumer is recognized.

Parameters:
Name Type Attributes Description
request Object <optional>

Optional getCards request parameters

Source:
Returns:

Promise that resolves with the cards array (may be empty)

Type
Promise.<Array>
Example
helper.getCards().then(function(cards) {
     if (cards.length > 0) {
         console.log('Cards:', cards);
     }
 }).catch(function(error) {
     console.error('Get cards failed:', error.messages[0].message);
 });

getReadiness() → {ClickToPayReadiness}

Returns readiness diagnostics for the Mastercard UCS browser SDK.

Source:
Returns:
Type
ClickToPayReadiness
Example
var readiness = helper.getReadiness();
 if (!readiness.ready) {
     console.warn(readiness.issues);
 }

idLookup(request) → {Promise}

Performs an identity lookup for a consumer using email or phone number.

Parameters:
Name Type Description
request Object

The identity lookup request

Source:
Returns:

Promise that resolves with profile existence indicator

Type
Promise

init(request) → {Promise}

Initializes Click-to-Pay with a fresh service instance and optional configuration. This method must be called before any other Click-to-Pay operations.

Parameters:
Name Type Description
request Object

The initialization request object (Mastercard UCS init schema)

Source:
Returns:

Promise that resolves with the initialization result

Type
Promise
Example
helper.init({
     requestId: 'req-12345',
     consumerLanguage: 'en-US'
 }).then(function(result) {
     return helper.getCards();
 }).catch(function(error) {
     console.error('Init failed:', error.messages[0].message);
 });

initiateValidation(requestopt) → {Promise}

Initiates identity validation by sending an OTP to the consumer.

Parameters:
Name Type Attributes Description
request Object <optional>

The initiate validation request

Source:
Returns:

Promise that resolves with OTP delivery confirmation

Type
Promise

invalidateSession()

Clears init state and saved checkout handoff so the next session starts from a clean runtime.

Source:

isReady() → {Boolean}

Returns whether the Mastercard UCS browser SDK is available.

Source:
Returns:
Type
Boolean

setDebugLogging(enabled)

Enables or disables MC SDK request/response logging for debugging Click-to-Pay flows. Intended for development and integration troubleshooting only. The CVV/security code is always hidden from these logs regardless of this flag; every other field (including the PAN) is logged in full, so treat any captured output as sensitive when sharing it (email, tickets, etc.).

Parameters:
Name Type Description
enabled Boolean

When true, logs payloads to the browser console

Source:
Example
var helper = sdk.getClickToPayHelper({ debugLogging: true });
 // or at runtime:
 helper.setDebugLogging(true);

signOut(requestopt) → {Promise}

Signs out the consumer from their Click-to-Pay session.

Parameters:
Name Type Attributes Description
request Object <optional>

Optional sign out parameters

Source:
Returns:

Promise that resolves when sign out completes

Type
Promise

useRecognitionSessionStore(store)

Replaces the helper's recognition storage implementation. Use TranspayrentClickToPayHelper#recognitionStorage for normal read/write access.

Parameters:
Name Type Description
store ClickToPayRecognitionSessionStore
Source:

validate(request) → {Promise}

Completes identity validation by verifying the OTP entered by the consumer.

Parameters:
Name Type Description
request Object

The validate request with OTP value

Source:
Returns:

Promise that resolves with validation result and cards

Type
Promise

(static) applyCheckoutHandoff(paymentDetails, handoff) → {Object}

Applies a saved Click-to-Pay checkout handoff to an authenticate/authorize payload.

Parameters:
Name Type Description
paymentDetails Object
handoff ClickToPayCheckoutHandoffRef
Source:
Throws:

Transpayrent-normalized error when handoff is missing or incomplete

Type
Object
Returns:
Type
Object

(static) createRecognitionSessionStore(optionsopt) → {ClickToPayRecognitionSessionStore}

Creates an opt-in identity-scoped recognition token / remember-me store.

Parameters:
Name Type Attributes Description
options ClickToPayRecognitionSessionStoreOptions <optional>
Source:
Returns:
Type
ClickToPayRecognitionSessionStore

(static) getReadiness() → {ClickToPayReadiness}

Static readiness check for use before a helper instance is created.

Source:
Returns:
Type
ClickToPayReadiness

(static) normalizeIdentity(identity, identityNormalizeropt) → {String}

Normalizes an identity value for recognition/session storage keys.

Parameters:
Name Type Attributes Description
identity String
identityNormalizer function <optional>
Source:
Returns:
Type
String