UNPKG

@playmoweb/payline-typescript-sdk

Version:
40 lines 1.13 kB
import moment from "moment-timezone"; /** * Payline helpers */ class PaylineUtils { static timezone = "Europe/Paris"; /** * Return the payline date format for this date */ static getPaylineDateFormat(value) { return value.format("DD/MM/YYYY HH:mm"); } /** * Return the payline date format for this date */ static getPaylineNowDateFormat() { return this.getPaylineDateFormat(moment.tz(PaylineUtils.timezone)); } /** * Check result for success */ static isSuccessful(response) { return response.result && ["02500", "00000"].indexOf(response.result.code) !== -1; } /** * Check errors */ static parseErrors(error) { if (!error.response) { return Promise.reject(error); } const response = error.response; if (response.statusCode === 401) { return Promise.reject({ shortMessage: "Payline: Not authorized" }); } return Promise.reject({ shortMessage: "Payline: Unknown error" }); } } export { PaylineUtils }; //# sourceMappingURL=payline-utils.js.map