@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
101 lines • 4.27 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(); // "PIN_ENTERED" or null
*/
getEvent() {
const event = this.params.get("event");
switch (event) {
case "TENDER_CREATED":
case "CARD_INSERTED":
case "CARD_PRESENTED":
case "CARD_SWIPED":
case "WAIT_FOR_APP_SELECTION":
case "APPLICATION_SELECTED":
case "ASK_SIGNATURE":
case "CHECK_SIGNATURE":
case "SIGNATURE_CHECKED":
case "WAIT_FOR_PIN":
case "PIN_ENTERED":
case "PRINT_RECEIPT":
case "RECEIPT_PRINTED":
case "CARD_REMOVED":
case "TENDER_FINAL":
case "ASK_DCC":
case "DCC_ACCEPTED":
case "DCC_REJECTED":
case "ASK_GRATUITY":
case "GRATUITY_ENTERED":
case "BALANCE_QUERY_STARTED":
case "BALANCE_QUERY_COMPLETED":
case "LOAD_STARTED":
case "LOAD_COMPLETED":
case "PROVIDE_CARD_DETAILS":
case "CARD_DETAILS_PROVIDED":
return event;
default:
return null;
}
}
getTransactionId() {
return this.params.get("TransactionID");
}
getTimeStamp() {
return this.params.get("TimeStamp");
}
get(key) {
return this.params.get(key);
}
toObject() {
const result = {};
for (const [key, value] of this.params.entries()) {
result[key] = value;
}
return result;
}
}
exports.PredefinedContentHelper = PredefinedContentHelper;
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