UNPKG

sibs-payments

Version:

A payment system module for SIBS payments integration with card tokenization support

46 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MbWay = MbWay; const types_1 = require("./types"); async function MbWay(iam, data) { const now = new Date(); const auth = await (await fetch(types_1.API, { method: 'POST', headers: { "Content-Type": "application/json", "Authorization": `Bearer ${iam.bearerToken}`, "X-IBM-Client-Id": iam.clientId }, body: JSON.stringify({ "merchant": { "terminalId": iam.terminalId, "channel": "web", "merchantTransactionId": data.id || "" }, "transaction": { "transactionTimestamp": now.toISOString(), "description": data.description || "", "moto": false, "paymentType": "PURS", "amount": { "value": data.value, "currency": data.currency }, "paymentMethod": [ "MBWAY" ] } }) })).json(); const payment = await (await fetch(`${types_1.API}/${auth.transactionID}/mbway-id/purchase`, { method: 'POST', headers: { "Content-Type": "application/json", "Authorization": `Digest ${auth.transactionSignature}`, "X-IBM-Client-Id": iam.clientId }, body: JSON.stringify({ "customerPhone": data.phone }) })).json(); return { auth, payment }; } //# sourceMappingURL=purchase-mbway.js.map