sibs-payments
Version:
A payment system module for SIBS payments integration with card tokenization support
58 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MbRef = MbRef;
const types_1 = require("./types");
async function MbRef(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": [
"REFERENCE"
],
"paymentReference": {
"initialDatetime": now.toISOString(),
"finalDatetime": new Date(now.getTime() + 10 * 60 * 1000).toISOString(),
"maxAmount": {
"value": data.value,
"currency": data.currency
},
"minAmount": {
"value": data.value,
"currency": data.currency
},
"entity": data.entity
}
}
})
})).json();
const payment = await (await fetch(`${types_1.API}/${auth.transactionID}/service-reference/generate`, {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Authorization": `Digest ${auth.transactionSignature}`,
"X-IBM-Client-Id": iam.clientId
}
})).json();
return { auth, payment };
}
//# sourceMappingURL=purchase-mbref.js.map