UNPKG

@mft/moneyhub-api-client

Version:
32 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = ({ config, request }) => { const { identityServiceUrl } = config; const getPayment = ({ id }, options) => request(`${identityServiceUrl}/payments/${id}`, { cc: { scope: "payment:read", }, options, }); return { getPayment, getPayments: (params = {}, options) => request(`${identityServiceUrl}/payments`, { searchParams: params, cc: { scope: "payment:read", }, options, }), getPaymentFromIDToken: async ({ idToken }, options) => { try { const payload = JSON.parse(Buffer.from(idToken.split(".")[1], "base64").toString()); const paymentId = payload["mh:payment"]; return getPayment({ id: paymentId }, options); } catch (e) { throw new Error("Error retrieving payment from passed in ID Token: " + e.message); } }, }; }; //# sourceMappingURL=payments.js.map