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 |
- Copyright:
- Transpayrent ApS 2026
- License:
- Common Transpayrent API license
- Source:
- See:
Example
Recommended merchant-owned Click-to-Pay checkout handoff
// session: the Create Payment Session response. The configuration of its Click to Pay payment method (205) has the
// acquirer data, MCC and country that Mastercard's 3-D Secure needs; give it to the helper unchanged.
var clickToPay = session.payment_methods.find(function(paymentMethod) { return Number(paymentMethod.id) === 205; });
var helper = sdk.getClickToPayHelper({ debugLogging: true, sessionData: clickToPay && clickToPay.configuration });
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> |
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.
authenticate(request) → {Promise}
Authenticates a Click-to-Pay consumer using device fingerprint or credentials.
Parameters:
| Name | Type | Description |
|---|---|---|
request |
Object | The authentication request object |
Returns:
Promise that resolves with authentication result
- Type
- Promise
checkoutWithCard(request) → {Promise.<ClickToPayCheckoutHandoff>}
Initiates checkout with a saved/recognized card.
Give the dpaTransactionOptions in init() or in the checkout. Mastercard replaces the options of init with the
options of the checkout, so the options of the checkout must be complete. The helper adds the acquirer data, MCC and
country from ClickToPayConfig.sessionData to the options that Mastercard uses:
- the checkout has
dpaTransactionOptions: the helper adds the data to them; - only init() had
dpaTransactionOptions: the helper added the data to them in init(); - no call has
dpaTransactionOptions: the helper sendsdpaTransactionOptionswith only this data in the checkout.
Parameters:
| Name | Type | Description |
|---|---|---|
request |
Object | The checkout request with selected card |
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. For |
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 ( |
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 |
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 |
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.
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 |
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.
When the request has dpaTransactionOptions, the helper adds the acquirer data, MCC and country from
ClickToPayConfig.sessionData to them. See TranspayrentClickToPayHelper#checkoutWithCard.
Parameters:
| Name | Type | Description |
|---|---|---|
request |
Object | The initialization request object (Mastercard UCS init schema) |
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 |
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.
isReady() → {Boolean}
Returns whether the Mastercard UCS browser SDK is available.
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 |
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 |
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 |
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 |
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 |
Throws:
-
Transpayrent-normalized error when
handoffis 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> |
Returns:
(static) getReadiness() → {ClickToPayReadiness}
Static readiness check for use before a helper instance is created.
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> |
Returns:
- Type
- String