@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
71 lines • 3.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisplayNotificationEvent = exports.PredefinedContentHelper = void 0;
/**
* PredefinedContentHelper class to parse and manage predefined content reference IDs.
*/
class PredefinedContentHelper {
constructor(referenceId) {
this.params = new URLSearchParams(referenceId);
}
/**
* Extracts and validates the `event` value from the ReferenceID.
*
* @returns A valid `DisplayNotificationEvent`, otherwise `null`.
*
* @example
* const helper = new PredefinedContentHelper("...&event=PIN_ENTERED");
* const event = helper.getEvent(); // DisplayNotificationEvent.PIN_ENTERED or null
*/
getEvent() {
const event = this.params.get("event");
if (event && Object.values(DisplayNotificationEvent).includes(event)) {
return event;
}
return null;
}
getTransactionId() {
return this.params.get("TransactionID");
}
getTimeStamp() {
return this.params.get("TimeStamp");
}
get(key) {
return this.params.get(key);
}
toObject() {
return Object.fromEntries(this.params);
}
}
exports.PredefinedContentHelper = PredefinedContentHelper;
// Supported events for display notifications
var DisplayNotificationEvent;
(function (DisplayNotificationEvent) {
DisplayNotificationEvent["TENDER_CREATED"] = "TENDER_CREATED";
DisplayNotificationEvent["CARD_INSERTED"] = "CARD_INSERTED";
DisplayNotificationEvent["CARD_PRESENTED"] = "CARD_PRESENTED";
DisplayNotificationEvent["CARD_SWIPED"] = "CARD_SWIPED";
DisplayNotificationEvent["WAIT_FOR_APP_SELECTION"] = "WAIT_FOR_APP_SELECTION";
DisplayNotificationEvent["APPLICATION_SELECTED"] = "APPLICATION_SELECTED";
DisplayNotificationEvent["ASK_SIGNATURE"] = "ASK_SIGNATURE";
DisplayNotificationEvent["CHECK_SIGNATURE"] = "CHECK_SIGNATURE";
DisplayNotificationEvent["SIGNATURE_CHECKED"] = "SIGNATURE_CHECKED";
DisplayNotificationEvent["WAIT_FOR_PIN"] = "WAIT_FOR_PIN";
DisplayNotificationEvent["PIN_ENTERED"] = "PIN_ENTERED";
DisplayNotificationEvent["PRINT_RECEIPT"] = "PRINT_RECEIPT";
DisplayNotificationEvent["RECEIPT_PRINTED"] = "RECEIPT_PRINTED";
DisplayNotificationEvent["CARD_REMOVED"] = "CARD_REMOVED";
DisplayNotificationEvent["TENDER_FINAL"] = "TENDER_FINAL";
DisplayNotificationEvent["ASK_DCC"] = "ASK_DCC";
DisplayNotificationEvent["DCC_ACCEPTED"] = "DCC_ACCEPTED";
DisplayNotificationEvent["DCC_REJECTED"] = "DCC_REJECTED";
DisplayNotificationEvent["ASK_GRATUITY"] = "ASK_GRATUITY";
DisplayNotificationEvent["GRATUITY_ENTERED"] = "GRATUITY_ENTERED";
DisplayNotificationEvent["BALANCE_QUERY_STARTED"] = "BALANCE_QUERY_STARTED";
DisplayNotificationEvent["BALANCE_QUERY_COMPLETED"] = "BALANCE_QUERY_COMPLETED";
DisplayNotificationEvent["LOAD_STARTED"] = "LOAD_STARTED";
DisplayNotificationEvent["LOAD_COMPLETED"] = "LOAD_COMPLETED";
DisplayNotificationEvent["PROVIDE_CARD_DETAILS"] = "PROVIDE_CARD_DETAILS";
DisplayNotificationEvent["CARD_DETAILS_PROVIDED"] = "CARD_DETAILS_PROVIDED";
})(DisplayNotificationEvent = exports.DisplayNotificationEvent || (exports.DisplayNotificationEvent = {}));
//# sourceMappingURL=predefinedContentHelper.js.map