Skip to main content

Web SDK handler

Success Handler

Description

This callback function is used to trigger any logic to be executed upon the payment and user journey having been completed (successfully and unsuccessfully). When payment data has been submitted and process by payment provider, user journey is completed and callback triggered.

void successHandler ( data );

Parameters

ParameterDetailsType
dataObject
kindDefines type of success handler. Can take one of the following values:string
CALLBACK: It is returned in case of payment process.
ADD_METHOD_CALLBACK: It is returned in case of payment option registration process.
transactionIdCheckout token associated with payment.guid
transactionReferenceTransaction identifier, that must be used by the end-customer while initiating transaction with 'Pre-payment' and 'Pay upon invoice' payment options.string
transactionStatusDefines current status of the initial transaction.string
messageDefines result of the submitted payment.string

Error Handler

Description

This callback function is used to trigger any logic to be executed upon the payment and user journey having not been able to start / initiated. When the SmartPay SDK can not be initiated correctly, this callback is triggered.

void errorHandler ( errorCode, message );

Parameters

Error codeDescriptionConsumer to select another payment method and retry
ERROR_INIT_PAYMENTError on payment initialization, consumer need to choose a different payment option.Yes
ERR_CONFIGError while loading payment methods configuration or widget.No
ERROR_INVALID_INPUTInvalid configuration passed to renderWidget method.No
ERR_PAYMENT_CALLBACKPayment failed during Authorization or Capturing. This is a hard failure, recreation of transaction is required.No
ERROR_INIT_STORE_PAYMENT_OPTIONError while storing payment option, consumer need to choose a different payment option.Yes
ERRORAny other unhandled error.No
ERROR_CHECKOUT_TIMEOUTcheckoutToken or transactionId is expired. Refer here for more details.No

Before Submit Handler

Description

Callback is being triggered, when a payment method has been selected by the end-customer in the SmartPay widget and he/she clicks on 'Confirm' button.

Promise<boolean> | boolean  onBeforeSubmit ( data );

Parameters

SmartPay widget must provide 'data' object into the callback function as an argument. Depending on the selection which end-user made in selector area, the 'data' object can have two sets of data described in tables below.

Stored payment option selected

ParameterDetails
data
transactionIdCheckout Token associated with payment.
nameDisplay name of the payment option which has been stored.
codeCode of the payment option which has been stored.
carrierNumberMasked carrier number of the payment instrument which has been stored. E.g.: 401288****1881
isDefaultFlag showing whether the stored payment option was chosen by the consumer to be the default one.
referenceStored payment option reference, to be used as input for MIT authorize API method.
isExpiredIn case of CC, shows whether the card is expired or not.
expiryDateWhen stored payment option belong to 'CC' group, this value provides the expiration date of the card. For non-CC payment methods value is empty string. Format: MM/YYYY
storedPaymentOptionDataContains payment method specific information used for storing the payment option. Currently used for SEPA only.
mandateReferenceSEPA mandate reference.
mandateSignedDateMandate signature date, format: YYYY-MM-DD
mandateSignedTimeMandate signature time, format: HHmmss

Guest payment option selected

ParameterDetails
data
transactionIdCheckout Token associated with payment.
nameDisplay name of the payment option which has been selected.
codeCode of the payment option which has been selected.

Return value

Return value typeReturn value description
Promise<boolean>boolean If callback function returns true, the the payment need to be continued. If callback function returns false or non-boolean value or undefined, the the payment need to be prevented.

Before Delete Stored Option Handler

Description

When 'enableDeleteSpo' parameter was provided into the 'renderWidget' method with value 'true', the deletion of the consumer's stored payment options gets available in the stored options list on the main screen. Once 'Delete' button clicked, SmartPay Widget will check if the selected stored payment option is in use by consumer's subscriptions. Regardless of the usage check result, widget will trigger the 'onBeforeDeleteSpo' callback function and provide Subscriptions information which use the selected stored option along with stored option reference.

Promise<boolean> | boolean  onBeforeDeleteSpo ( data );

Parameters

SmartPay widget provides 'data' object into the callback function as an argument.

ParameterDetailsType
dataObject
storedPaymentOptionReferenceStored payment option reference issued by the KontoCloud.string
usedForRecurringPaymentsFlag shows if the payment option is used in subscriptions.boolean
recurringPaymentsAn array of objects, providing the merchant with information about where the storedPaymentOptionReference is used.array
objectTypeDescribes the object (e.g. subscription, payment serie) that uses the storedPaymentOptionReferencestring
objectIdProvides the ID of the objectstring

Return value

Return value typeReturn value description
Promise<boolean>boolean If callback function returns true, then deletion of the stored payment option must be continued. If callback function returns false or non-boolean value or undefined, then deletion of the stored payment option must be prevented.

Payment Method Selection Changed Handler

Description

This callback will be triggered, when the a payment method has been selected by the end-customer in SmartPay widget.

void onSelectionChanged ( data );

Parameters

SmartPay widget provides a 'data' object into the callback function as an argument.

Depending on the selection which your consumer made in selector area, the 'data' object can have two sets of data described in tables below.

Stored payment option selected

ParameterDetails
data-
transactionIdCheckout Token associated with payment.
nameDisplay name of the payment option which has been stored.
codeCode of the payment option which has been stored.
carrierNumberMasked carrier number of the payment instrument which has been stored. E.g.: 401288****1881
isDefaultFlag showing whether the stored payment option was chosen by the consumer to be the default one.
referenceStored payment option reference.
isExpiredIn case of CC, shows whether the card is expired or not.
expiryDateWhen stored payment option belong to 'CC' group, this value provides the expiration date of the card. For non-CC payment methods value is empty string. Format: MM/YYYY
storedPaymentOptionDataContains payment method specific information used for storing the payment option. Currently used for SEPA only.
mandateReferenceSEPA mandate reference
mandateSignedDateMandate signature date, format: YYYY-MM-DD
mandateSignedTimeMandate signature time, format: HHmmss

Guest payment option selected

ParameterDetails
data-
transactionIdCheckout Token associated with payment.
nameDisplay name of the payment option which has been stored.
codeCode of the payment option which has been stored.

Widget Rendered Handler

Description

This callback function will be triggered to execute any logic both during the loading of the SmartPay widget and upon its successful rendering. This handler plays a critical role in managing and responding to different stages of the widget's lifecycle, ensuring that any required actions, such as updating the UI, logging events, or handling errors, are performed at the appropriate time. By leveraging this function, you can ensure a smoother user experience, particularly in scenarios where the loading process may take longer due to network conditions or other factors.

void onWidgetRendered ( data );

Parameters

ParameterDetailsType
dataObject
transactionId (for payment transaction context)
OR
subscriptionId (for subscriptions context)
Unique transaction identifier.guid