UNPKG

xpresspayonline-react-native

Version:

xpresspayonline react native plugin

65 lines (53 loc) 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.verifyMerchant = verifyMerchant; var _config = require("./config/config"); function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function verifyMerchant(_x, _x2) { return _verifyMerchant.apply(this, arguments); } function _verifyMerchant() { _verifyMerchant = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(env, publicKey) { var headers, fetchOptions, url, response, responseData; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.prev = 0; headers = new Headers(); headers.append('Content-Type', 'application/json'); fetchOptions = { method: 'GET', headers: headers }; url = ''; if (env === 'LIVE') { url = _config.BASE_API_URL_LIVE; } else { url = _config.BASE_API_URL_TEST; } _context.next = 8; return fetch(url + '/external/merchants?publicKey=' + publicKey, fetchOptions); case 8: response = _context.sent; _context.next = 11; return response.json(); case 11: responseData = _context.sent; return _context.abrupt("return", Promise.resolve(responseData)); case 15: _context.prev = 15; _context.t0 = _context["catch"](0); Promise.reject(_context.t0); case 18: case "end": return _context.stop(); } } }, _callee, null, [[0, 15]]); })); return _verifyMerchant.apply(this, arguments); }