UNPKG

sibs-payments

Version:

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

66 lines 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Card = Card; const types_1 = require("./types"); async function Card(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": [ "CARD" ] }, "customer": { "customerInfo": { "customerName": data.customerName, "customerEmail": data.customerEmail, "shippingAddress": data.billingAddress, "billingAddress": data.billingAddress } }, "tokenisation": { "paymentTokens": [{ "tokenType": "Card", "value": data.token }] } }) })).json(); const payment = await (await fetch(`${types_1.API}/${auth.transactionID}/token/purchase`, { method: 'POST', headers: { "Content-Type": "application/json", "Authorization": `Digest ${auth.transactionSignature}`, "X-IBM-Client-Id": iam.clientId }, body: JSON.stringify({ "tokenInfo": { "value": data.token, "secureCode": data.secureCode, "tokenType": "Card", }, }) })).json(); return { auth, payment }; } //# sourceMappingURL=purchase-card.js.map