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AAI,GAAG,KAAK,OAAO,MAChC,IACf,CAAE,MAAO,GACL,OAAO,KAAK,UAAU,CAAE,QAAQ,EAAO,OAAO,EAAM,UAAW,EAAI,SAAS,KAAK,UAAW,QAAS,EAAI,SAAS,KAAK,SAC3H,CACJ,EAEJ,OAAO,QAAU,CAAE,UAAM","file":"/npm/dpay-payments@1.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dpay-payments@1.1.1/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","const axios = require('axios');\r\nconst sha256 = require('sha256');\r\nclass dpay {\r\n    constructor(service, hash, production = true) {\r\n        this.service = service;\r\n        this.hash = hash;\r\n        this.paymentUrl = production ? \"https://secure.dpay.pl/register/\":\"https://secure-test.dpay.pl/register/\";\r\n        this.paymentInfoUrl = production ? \"https://panel.dpay.pl/api/v1/pbl\":\"https://panel.digitalpayments.pl/api/v1/pbl\";\r\n    }\r\n\r\n    async createPayment(value, url_success, url_fail, url_ipn, installment, creditcard, paysafecard, paypal, nobanks, channel, email, client_name, client_surname, accept_tos, description, custom, style) {\r\n        const checksum = sha256(`${this.service}|${this.hash}|${value}|${url_success}|${url_fail}|${url_ipn}`);\r\n        const query = JSON.stringify({ service: this.service, value, url_success, url_fail, url_ipn, checksum, installment, creditcard, paysafecard, paypal, nobanks, channel, email, client_name, client_surname, accept_tos, description, custom, style });\r\n        try {\r\n            const res = await axios.post(this.paymentUrl, query);\r\n            return res.data;\r\n        } catch (err) {\r\n            return JSON.stringify({ status: false, error: true, msg: `${err.response.status} - ${err.response.statusText}` });\r\n        }\r\n    }\r\n\r\n    async getPaymentInfo(transaction_id) {\r\n        const checksum = sha256(`${this.service}|${transaction_id}|${this.hash}`);\r\n        const query = { service: this.service, transaction_id, checksum };\r\n        try {\r\n            const res = await axios.post(`${this.paymentInfoUrl}/details`, query);\r\n            return res.data;\r\n        } catch (err) {\r\n            console.log(err.response?.data.message);\r\n        }\r\n    }\r\n\r\n    // Maybe one day...\r\n    // async refundPayment(transaction_id) {\r\n    //     const checksum = sha256(`${this.service}|${transaction_id}|${this.hash}`);\r\n    //     const query = { service: this.service, transaction_id, checksum };\r\n    //     try {\r\n    //         const res = await axios.post(`${this.paymentInfoUrl}/refund`, query);\r\n    //         console.log(res);\r\n    //         return res.data;\r\n    //     } catch (err) {\r\n    //         console.log(err.response);\r\n    //         console.log(\"error\");\r\n    //         console.log(checksum);\r\n    //     }\r\n    // }\r\n}\r\n\r\nclass dpaySMS {\r\n    constructor(clientid, serviceid, production = true) {\r\n        this.url = production ? `https://panel.dpay.pl/api/v1/sms/verify/${clientid}/${serviceid}`:`https://panel.digitalpayments.pl/api/v1/sms/verify/${clientid}/${serviceid}`;\r\n    }\r\n\r\n    async paymentStatus(code) {\r\n        try {\r\n            const res = await axios.get(`${this.url}/${code}`);\r\n            return res.data;\r\n        } catch (err) {\r\n            return JSON.stringify({ status: false, error: true, errorcode: err.response.data.errorcode, message: err.response.data.message });\r\n        }\r\n    }\r\n}\r\nmodule.exports = { dpay, dpaySMS };"]}