UNPKG

@fabrix/spool-cart

Version:

Spool - eCommerce Spool for Fabrix

29 lines (28 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const common_1 = require("@fabrix/fabrix/dist/common"); class GatewayController extends common_1.FabrixController { gateways(req, res) { const gateways = Object.keys(this.app.config.get('generics')) .map(key => { return this.app.config.get(`generics.${key}`); }).filter(generic => generic.type === 'payment_processor'); const hasKeyRegex = function (gateway) { const pub = Object.keys(gateway).find(function (key) { return /public/.test(key); }); if (pub) { return gateway[pub]; } return false; }; const opts = gateways.map(gate => { return { name: gate.name || 'Default', public: hasKeyRegex(gate.config) || null }; }); res.json(opts); } } exports.GatewayController = GatewayController;