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W,aAC/B,KAAK,eAAe,EAAQ,UACrB,KAAK,MAAM,KAAK,YAAa,CAChC,YAAa,KAAK,UAClB,YACA,UAER,GACJ,CACA,OAAA,CAAQ,GACJ,OAAO,UAAU,UAAM,OAAQ,GAAQ,YAEnC,OADA,KAAK,eAAe,EAAW,aACxB,KAAK,MAAM,GAAG,KAAK,gCAAiC,CACvD,YAAa,KAAK,UAClB,aAER,GACJ,CACA,OAAA,CAAQ,GACJ,OAAO,UAAU,UAAM,OAAQ,GAAQ,YAEnC,OADA,KAAK,eAAe,EAAW,aACxB,KAAK,MAAM,GAAG,KAAK,gCAAiC,CACvD,YAAa,KAAK,UAClB,aAER,GACJ,CACA,UAAA,GACI,OAAO,UAAU,UAAM,OAAQ,GAAQ,YACnC,OAAO,KAAK,MAAM,GAAG,KAAK,mCAAoC,CAC1D,YAAa,KAAK,WAE1B,GACJ,EAEJ,OAAO,QAAU","file":"/npm/zarinpal-pay@3.0.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/zarinpal-pay@3.0.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst axios_1 = __importDefault(require(\"axios\"));\nclass ZarinpalPayment {\n    constructor(_merchant, options = {}) {\n        this._merchant = _merchant;\n        this._baseLinkPayment = \"https://payment.zarinpal.com/pg/v4/payment\";\n        this._sandboxBaseLink = \"https://sandbox.zarinpal.com/pg/v4/payment\";\n        this._gateway = \"https://payment.zarinpal.com/pg/StartPay\";\n        this._sandboxGateway = \"https://sandbox.zarinpal.com/pg/StartPay\";\n        this._currency = \"IRR\";\n        this._isSandbox = false;\n        this._setLinks = () => {\n            const base = this._isSandbox ? this._sandboxBaseLink : this._baseLinkPayment;\n            this._requestLink = `${base}/request.json`;\n            this._verifyLink = `${base}/verify.json`;\n        };\n        this._validateInput = (value, name) => {\n            if (value === undefined || value === null || value === \"\") {\n                throw new Error(`Zarinpal Pay --> The value *${name}* is invalid!`);\n            }\n        };\n        const { isToman = false, isSandbox = false } = options;\n        if (!_merchant || _merchant.length !== 36) {\n            throw new Error(\"Zarinpal Pay --> Merchant ID is invalid!\");\n        }\n        this._isSandbox = isSandbox;\n        this._currency = isToman ? \"IRT\" : \"IRR\";\n        this._setLinks();\n    }\n    _post(url, payload) {\n        return __awaiter(this, void 0, void 0, function* () {\n            var _a, _b, _c, _d;\n            try {\n                const { data } = yield axios_1.default.post(url, payload);\n                if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length) {\n                    throw new Error(JSON.stringify(data.errors));\n                }\n                return (_b = data.data) !== null && _b !== void 0 ? _b : data;\n            }\n            catch (err) {\n                throw (_d = (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.errors;\n                ;\n            }\n        });\n    }\n    create(_a) {\n        return __awaiter(this, arguments, void 0, function* ({ amount, callback_url, description = \"\", mobile, email, order_id, }) {\n            this._validateInput(amount, \"Amount\");\n            this._validateInput(callback_url, \"Callback URL\");\n            this._validateInput(description, \"Description\");\n            const transactionInfo = {\n                merchant_id: this._merchant,\n                amount,\n                currency: this._currency,\n                description,\n                callback_url,\n                metadata: [mobile, email, order_id],\n                order_id,\n            };\n            const data = yield this._post(this._requestLink, transactionInfo);\n            return Object.assign(Object.assign({}, data), { link: `${this._isSandbox ? this._sandboxGateway : this._gateway}/${data.authority}` });\n        });\n    }\n    verify(_a) {\n        return __awaiter(this, arguments, void 0, function* ({ authority, amount }) {\n            this._validateInput(authority, \"Authority\");\n            this._validateInput(amount, \"Amount\");\n            return this._post(this._verifyLink, {\n                merchant_id: this._merchant,\n                authority,\n                amount,\n            });\n        });\n    }\n    inquiry(authority) {\n        return __awaiter(this, void 0, void 0, function* () {\n            this._validateInput(authority, \"Authority\");\n            return this._post(`${this._baseLinkPayment}/inquiry.json`, {\n                merchant_id: this._merchant,\n                authority,\n            });\n        });\n    }\n    reverse(authority) {\n        return __awaiter(this, void 0, void 0, function* () {\n            this._validateInput(authority, \"Authority\");\n            return this._post(`${this._baseLinkPayment}/reverse.json`, {\n                merchant_id: this._merchant,\n                authority,\n            });\n        });\n    }\n    unverified() {\n        return __awaiter(this, void 0, void 0, function* () {\n            return this._post(`${this._baseLinkPayment}/unVerified.json`, {\n                merchant_id: this._merchant,\n            });\n        });\n    }\n}\nmodule.exports = ZarinpalPayment;\n"]}