authscape 1.0.110 → 1.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc CHANGED
@@ -1,3 +1,3 @@
1
- {
2
- "presets": ["@babel/preset-react", "@babel/preset-env"]
1
+ {
2
+ "presets": ["@babel/preset-react", "@babel/preset-env"]
3
3
  }
package/index.js CHANGED
@@ -266,52 +266,647 @@ exports["default"] = void 0;
266
266
 
267
267
  var _react = _interopRequireWildcard(require("react"));
268
268
 
269
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
270
+
271
+ var _reactStripeJs = require("@stripe/react-stripe-js");
272
+
273
+ var _PaymentRounded = _interopRequireDefault(require("@mui/icons-material/PaymentRounded"));
274
+
275
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
276
+
269
277
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
270
278
 
271
279
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
272
280
 
273
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
281
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
274
282
 
275
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
283
+ 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); } }
276
284
 
277
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
285
+ 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); }); }; }
278
286
 
279
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
287
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
280
288
 
281
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
289
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
282
290
 
283
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
291
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
284
292
 
285
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
293
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
286
294
 
287
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
295
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
288
296
 
289
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
297
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
290
298
 
291
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
299
+ var checkoutForm = function checkoutForm(_ref) {
300
+ var payButtonText = _ref.payButtonText,
301
+ clientSecret = _ref.clientSecret,
302
+ onResponse = _ref.onResponse,
303
+ amount = _ref.amount;
292
304
 
293
- var DummyComponent = /*#__PURE__*/function (_Component) {
294
- _inherits(DummyComponent, _Component);
305
+ var _useState = (0, _react.useState)(false),
306
+ _useState2 = _slicedToArray(_useState, 2),
307
+ isPaymentProcessing = _useState2[0],
308
+ setIsPaymentProcessing = _useState2[1];
295
309
 
296
- var _super = _createSuper(DummyComponent);
310
+ var stripe = (0, _reactStripeJs.useStripe)();
311
+ var elements = (0, _reactStripeJs.useElements)();
297
312
 
298
- function DummyComponent() {
299
- _classCallCheck(this, DummyComponent);
313
+ var _useState3 = (0, _react.useState)(null),
314
+ _useState4 = _slicedToArray(_useState3, 2),
315
+ errorMessage = _useState4[0],
316
+ setErrorMessage = _useState4[1];
300
317
 
301
- return _super.apply(this, arguments);
302
- }
318
+ var handleSubmit = /*#__PURE__*/function () {
319
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
320
+ var _yield$stripe$confirm, error, response, setupIntent, _yield$stripe$confirm2, _error, _response, paymentIntent;
303
321
 
304
- _createClass(DummyComponent, [{
305
- key: "render",
306
- value: function render() {
307
- return /*#__PURE__*/_react["default"].createElement("div", null, "I am a dummy react npm module");
322
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
323
+ while (1) {
324
+ switch (_context.prev = _context.next) {
325
+ case 0:
326
+ setIsPaymentProcessing(true); // We don't want to let default form submission happen here,
327
+ // which would refresh the page.
328
+
329
+ event.preventDefault();
330
+
331
+ if (!(!stripe || !elements)) {
332
+ _context.next = 5;
333
+ break;
334
+ }
335
+
336
+ // Stripe.js has not yet loaded.
337
+ // Make sure to disable form submission until Stripe.js has loaded.
338
+ setIsPaymentProcessing(false);
339
+ return _context.abrupt("return");
340
+
341
+ case 5:
342
+ if (!(amount == null)) {
343
+ _context.next = 34;
344
+ break;
345
+ }
346
+
347
+ _context.next = 8;
348
+ return stripe.confirmSetup({
349
+ //`Elements` instance that was used to create the Payment Element
350
+ elements: elements,
351
+ redirect: "if_required" // confirmParams: {
352
+ // return_url: process.env.WebsiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
353
+ // },
354
+
355
+ });
356
+
357
+ case 8:
358
+ _yield$stripe$confirm = _context.sent;
359
+ error = _yield$stripe$confirm.error;
360
+
361
+ if (!error) {
362
+ _context.next = 15;
363
+ break;
364
+ }
365
+
366
+ // This point will only be reached if there is an immediate error when
367
+ // confirming the payment. Show error to your customer (for example, payment
368
+ // details incomplete)
369
+ setIsPaymentProcessing(false);
370
+ setErrorMessage(error.message);
371
+ _context.next = 32;
372
+ break;
373
+
374
+ case 15:
375
+ // Your customer will be redirected to your `return_url`. For some payment
376
+ // methods like iDEAL, your customer will be redirected to an intermediate
377
+ // site first to authorize the payment, then redirected to the `return_url`.
378
+ setIsPaymentProcessing(false);
379
+ response = null;
380
+ _context.next = 19;
381
+ return stripe.retrieveSetupIntent(clientSecret);
382
+
383
+ case 19:
384
+ response = _context.sent;
385
+ //
386
+ setupIntent = response.setupIntent;
387
+ _context.t0 = setupIntent.status;
388
+ _context.next = _context.t0 === 'succeeded' ? 24 : _context.t0 === 'processing' ? 26 : _context.t0 === 'requires_payment_method' ? 28 : 30;
389
+ break;
390
+
391
+ case 24:
392
+ // need to store the payment intent with the customer if they are logged in... currentUser
393
+ onResponse("succeeded", setupIntent.id, setupIntent.payment_method);
394
+ return _context.abrupt("break", 32);
395
+
396
+ case 26:
397
+ onResponse("processing", setupIntent.id, setupIntent.payment_method);
398
+ return _context.abrupt("break", 32);
399
+
400
+ case 28:
401
+ onResponse("requires_payment_method", null);
402
+ return _context.abrupt("break", 32);
403
+
404
+ case 30:
405
+ onResponse("failed", null);
406
+ return _context.abrupt("break", 32);
407
+
408
+ case 32:
409
+ _context.next = 66;
410
+ break;
411
+
412
+ case 34:
413
+ _context.next = 36;
414
+ return stripe.confirmPayment({
415
+ //`Elements` instance that was used to create the Payment Element
416
+ elements: elements,
417
+ redirect: "if_required",
418
+ confirmParams: {
419
+ return_url: process.env.WebsiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search)
420
+ }
421
+ });
422
+
423
+ case 36:
424
+ _yield$stripe$confirm2 = _context.sent;
425
+ _error = _yield$stripe$confirm2.error;
426
+
427
+ if (!_error) {
428
+ _context.next = 43;
429
+ break;
430
+ }
431
+
432
+ // This point will only be reached if there is an immediate error when
433
+ // confirming the payment. Show error to your customer (for example, payment
434
+ // details incomplete)
435
+ setIsPaymentProcessing(false);
436
+ setErrorMessage(_error.message);
437
+ _context.next = 66;
438
+ break;
439
+
440
+ case 43:
441
+ // Your customer will be redirected to your `return_url`. For some payment
442
+ // methods like iDEAL, your customer will be redirected to an intermediate
443
+ // site first to authorize the payment, then redirected to the `return_url`.
444
+ setIsPaymentProcessing(false);
445
+ _response = null;
446
+
447
+ if (!(amount == null)) {
448
+ _context.next = 51;
449
+ break;
450
+ }
451
+
452
+ _context.next = 48;
453
+ return stripe.retrieveSetupIntent(clientSecret);
454
+
455
+ case 48:
456
+ _response = _context.sent;
457
+ _context.next = 54;
458
+ break;
459
+
460
+ case 51:
461
+ _context.next = 53;
462
+ return stripe.retrievePaymentIntent(clientSecret);
463
+
464
+ case 53:
465
+ _response = _context.sent;
466
+
467
+ case 54:
468
+ paymentIntent = _response.paymentIntent;
469
+ _context.t1 = paymentIntent.status;
470
+ _context.next = _context.t1 === 'succeeded' ? 58 : _context.t1 === 'processing' ? 60 : _context.t1 === 'requires_payment_method' ? 62 : 64;
471
+ break;
472
+
473
+ case 58:
474
+ // need to store the payment intent with the customer if they are logged in... currentUser
475
+ onResponse("succeeded", paymentIntent.id);
476
+ return _context.abrupt("break", 66);
477
+
478
+ case 60:
479
+ onResponse("processing", paymentIntent.id);
480
+ return _context.abrupt("break", 66);
481
+
482
+ case 62:
483
+ onResponse("requires_payment_method", null);
484
+ return _context.abrupt("break", 66);
485
+
486
+ case 64:
487
+ onResponse("failed", null);
488
+ return _context.abrupt("break", 66);
489
+
490
+ case 66:
491
+ case "end":
492
+ return _context.stop();
493
+ }
494
+ }
495
+ }, _callee);
496
+ }));
497
+
498
+ return function handleSubmit(_x) {
499
+ return _ref2.apply(this, arguments);
500
+ };
501
+ }();
502
+
503
+ return /*#__PURE__*/_react["default"].createElement("form", {
504
+ onSubmit: handleSubmit
505
+ }, /*#__PURE__*/_react["default"].createElement(_reactStripeJs.PaymentElement, null), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
506
+ startIcon: /*#__PURE__*/_react["default"].createElement(_PaymentRounded["default"], null),
507
+ type: "submit",
508
+ fullWidth: true,
509
+ variant: "contained",
510
+ disabled: !stripe || isPaymentProcessing,
511
+ sx: {
512
+ marginTop: 2
308
513
  }
309
- }]);
514
+ }, payButtonText), errorMessage && /*#__PURE__*/_react["default"].createElement("div", null, errorMessage));
515
+ };
310
516
 
311
- return DummyComponent;
312
- }(_react.Component);
517
+ var _default = CheckoutForm;
518
+ exports["default"] = _default;
519
+ "use strict";
520
+
521
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
522
+
523
+ Object.defineProperty(exports, "__esModule", {
524
+ value: true
525
+ });
526
+ exports["default"] = stripePayment;
527
+
528
+ var _react = _interopRequireWildcard(require("react"));
529
+
530
+ var _reactStripeJs = require("@stripe/react-stripe-js");
531
+
532
+ var _stripeJs = require("@stripe/stripe-js");
533
+
534
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
535
+
536
+ var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
537
+
538
+ var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
539
+
540
+ var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));
541
+
542
+ var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
313
543
 
314
- exports["default"] = DummyComponent;
544
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
545
+
546
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
547
+
548
+ var _Tabs = _interopRequireDefault(require("@mui/material/Tabs"));
549
+
550
+ var _Tab = _interopRequireDefault(require("@mui/material/Tab"));
551
+
552
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
553
+
554
+ var _Select = _interopRequireDefault(require("@mui/material/Select"));
555
+
556
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
557
+
558
+ var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
559
+
560
+ var _excluded = ["children", "value", "index"];
561
+
562
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
563
+
564
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
565
+
566
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
567
+
568
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
569
+
570
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
571
+
572
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
573
+
574
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
575
+
576
+ 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); } }
577
+
578
+ 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); }); }; }
579
+
580
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
581
+
582
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
583
+
584
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
585
+
586
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
587
+
588
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
589
+
590
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
591
+
592
+ function stripePayment(_ref) {
593
+ var title = _ref.title,
594
+ description = _ref.description,
595
+ _ref$amount = _ref.amount,
596
+ amount = _ref$amount === void 0 ? null : _ref$amount,
597
+ _ref$priceId = _ref.priceId,
598
+ priceId = _ref$priceId === void 0 ? null : _ref$priceId,
599
+ _ref$stripeCustomerId = _ref.stripeCustomerId,
600
+ stripeCustomerId = _ref$stripeCustomerId === void 0 ? null : _ref$stripeCustomerId,
601
+ _ref$isModal = _ref.isModal,
602
+ isModal = _ref$isModal === void 0 ? true : _ref$isModal,
603
+ logOffUserName = _ref.logOffUserName,
604
+ logOffEmail = _ref.logOffEmail,
605
+ _ref$paymentRequestTy = _ref.paymentRequestType,
606
+ paymentRequestType = _ref$paymentRequestTy === void 0 ? 3 : _ref$paymentRequestTy,
607
+ currentUser = _ref.currentUser,
608
+ isOpen = _ref.isOpen,
609
+ onModalClose = _ref.onModalClose,
610
+ onResponse = _ref.onResponse,
611
+ _ref$payButtonText = _ref.payButtonText,
612
+ payButtonText = _ref$payButtonText === void 0 ? "PAY NOW" : _ref$payButtonText;
613
+ var stripePromise = (0, _stripeJs.loadStripe)(process.env.stripePublicKey);
614
+
615
+ var _useState = (0, _react.useState)(null),
616
+ _useState2 = _slicedToArray(_useState, 2),
617
+ options = _useState2[0],
618
+ setOptions = _useState2[1];
619
+
620
+ var _useState3 = (0, _react.useState)(0),
621
+ _useState4 = _slicedToArray(_useState3, 2),
622
+ value = _useState4[0],
623
+ setValue = _useState4[1];
624
+
625
+ var _useState5 = (0, _react.useState)([]),
626
+ _useState6 = _slicedToArray(_useState5, 2),
627
+ paymentMethods = _useState6[0],
628
+ setPaymentMethods = _useState6[1];
629
+
630
+ var _useState7 = (0, _react.useState)(null),
631
+ _useState8 = _slicedToArray(_useState7, 2),
632
+ paymentMethod = _useState8[0],
633
+ setPaymentMethod = _useState8[1];
634
+
635
+ var paymentMethodOpened = /*#__PURE__*/function () {
636
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
637
+ var response, responsePayments;
638
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
639
+ while (1) {
640
+ switch (_context.prev = _context.next) {
641
+ case 0:
642
+ response = null;
643
+
644
+ if (!(currentUser == null)) {
645
+ _context.next = 7;
646
+ break;
647
+ }
648
+
649
+ _context.next = 4;
650
+ return apiService().post("/Payment/ConnectCustomerNoAuth", {
651
+ paymentRequestType: paymentRequestType,
652
+ amount: amount,
653
+ priceId: priceId,
654
+ name: logOffUserName,
655
+ email: logOffEmail,
656
+ stripeCustomerId: stripeCustomerId
657
+ });
658
+
659
+ case 4:
660
+ response = _context.sent;
661
+ _context.next = 10;
662
+ break;
663
+
664
+ case 7:
665
+ _context.next = 9;
666
+ return apiService().post("/Payment/ConnectCustomer", {
667
+ paymentRequestType: paymentRequestType,
668
+ amount: amount,
669
+ priceId: priceId,
670
+ stripeCustomerId: stripeCustomerId
671
+ });
672
+
673
+ case 9:
674
+ response = _context.sent;
675
+
676
+ case 10:
677
+ if (!(response != null && response.status == 200)) {
678
+ _context.next = 16;
679
+ break;
680
+ }
681
+
682
+ setOptions({
683
+ clientSecret: response.data
684
+ });
685
+ _context.next = 14;
686
+ return apiService().get("/Payment/GetPaymentMethods");
687
+
688
+ case 14:
689
+ responsePayments = _context.sent;
690
+
691
+ if (responsePayments != null && responsePayments.status == 200) {
692
+ if (responsePayments.data.length > 0) {
693
+ setValue(1);
694
+ }
695
+
696
+ setPaymentMethods(responsePayments.data);
697
+ }
698
+
699
+ case 16:
700
+ case "end":
701
+ return _context.stop();
702
+ }
703
+ }
704
+ }, _callee);
705
+ }));
706
+
707
+ return function paymentMethodOpened() {
708
+ return _ref2.apply(this, arguments);
709
+ };
710
+ }();
711
+
712
+ (0, _react.useEffect)(function () {
713
+ if (isOpen) {
714
+ paymentMethodOpened();
715
+ }
716
+ }, [isOpen]);
717
+
718
+ var handleChange = function handleChange(event, newValue) {
719
+ setValue(newValue);
720
+ };
721
+
722
+ function a11yProps(index) {
723
+ return {
724
+ id: "simple-tab-".concat(index),
725
+ 'aria-controls': "simple-tabpanel-".concat(index)
726
+ };
727
+ }
728
+
729
+ var PaymentMethod = function PaymentMethod(_ref3) {
730
+ var paymentMethod = _ref3.paymentMethod,
731
+ clicked = _ref3.clicked;
732
+ return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
733
+ fullWidth: true,
734
+ sx: {
735
+ height: 160,
736
+ width: "100%",
737
+ marginTop: 2,
738
+ backgroundColor: "#2196F3",
739
+ position: "relative",
740
+ border: "1px solid #2196F3",
741
+ borderRadius: 1,
742
+ display: "flex",
743
+ flexDirection: "column",
744
+ justifyContent: "center",
745
+ textAlign: "center",
746
+ cursor: "pointer"
747
+ },
748
+ onClick: function onClick() {
749
+ clicked(paymentMethod.id);
750
+ }
751
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
752
+ gutterBottom: true,
753
+ variant: "body",
754
+ component: "div",
755
+ sx: {
756
+ fontSize: 14,
757
+ position: "absolute",
758
+ left: 15,
759
+ top: 10,
760
+ color: "white"
761
+ }
762
+ }, paymentMethod.brand), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
763
+ gutterBottom: true,
764
+ variant: "body",
765
+ component: "div",
766
+ sx: {
767
+ verticalAlign: "middle",
768
+ fontSize: 18,
769
+ color: "white"
770
+ }
771
+ }, "* * * * \xA0 * * * * \xA0 * * * * \xA0 ", paymentMethod.last4), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
772
+ container: true,
773
+ spacing: 1,
774
+ sx: {
775
+ position: "absolute",
776
+ bottom: 8,
777
+ marginLeft: 0,
778
+ width: "100%"
779
+ }
780
+ }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
781
+ item: true,
782
+ xs: 12,
783
+ sx: {
784
+ textAlign: "right",
785
+ paddingRight: 2
786
+ }
787
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
788
+ gutterBottom: true,
789
+ variant: "body",
790
+ component: "div",
791
+ sx: {
792
+ fontSize: 12,
793
+ marginLeft: 2,
794
+ marginTop: 1,
795
+ color: "#e9e9e9"
796
+ }
797
+ }, "EXPIRES"), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
798
+ gutterBottom: true,
799
+ variant: "body",
800
+ component: "div",
801
+ sx: {
802
+ fontSize: 12,
803
+ marginLeft: 2,
804
+ marginTop: "-9px",
805
+ color: "white"
806
+ }
807
+ }, paymentMethod.expMonth, "/", paymentMethod.expYear))));
808
+ };
809
+
810
+ function TabPanel(props) {
811
+ var children = props.children,
812
+ value = props.value,
813
+ index = props.index,
814
+ other = _objectWithoutProperties(props, _excluded);
815
+
816
+ return /*#__PURE__*/_react["default"].createElement("div", _extends({
817
+ role: "tabpanel",
818
+ hidden: value !== index,
819
+ id: "simple-tabpanel-".concat(index),
820
+ "aria-labelledby": "simple-tab-".concat(index)
821
+ }, other), value === index && /*#__PURE__*/_react["default"].createElement(_Box["default"], {
822
+ sx: {
823
+ p: 3
824
+ }
825
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, children)));
826
+ }
827
+
828
+ var PaymentContent = function PaymentContent() {
829
+ return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
830
+ sx: {
831
+ width: '100%'
832
+ }
833
+ }, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
834
+ sx: {
835
+ borderBottom: 1,
836
+ borderColor: 'divider'
837
+ }
838
+ }, /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
839
+ value: value,
840
+ onChange: handleChange,
841
+ "aria-label": "basic tabs example"
842
+ }, /*#__PURE__*/_react["default"].createElement(_Tab["default"], _extends({
843
+ label: "Add Payment Method"
844
+ }, a11yProps(0))), paymentMethods.length > 0 && /*#__PURE__*/_react["default"].createElement(_Tab["default"], _extends({
845
+ label: "Existing Payment Method"
846
+ }, a11yProps(1))))), paymentMethods.length > 0 && /*#__PURE__*/_react["default"].createElement(TabPanel, {
847
+ value: value,
848
+ index: 1
849
+ }, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
850
+ sx: {
851
+ marginTop: 4
852
+ },
853
+ fullWidth: true,
854
+ id: "demo-simple-select",
855
+ value: paymentMethod,
856
+ onChange: function onChange(val) {
857
+ setPaymentMethod(val.target.value);
858
+ }
859
+ }, paymentMethods != null && paymentMethods.map(function (paymentMethod, index) {
860
+ return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
861
+ key: index,
862
+ value: paymentMethod.id,
863
+ fullWidth: true,
864
+ sx: {
865
+ width: "100%"
866
+ }
867
+ }, /*#__PURE__*/_react["default"].createElement(PaymentMethod, {
868
+ paymentMethod: paymentMethod,
869
+ clicked: function clicked() {}
870
+ }));
871
+ }))), /*#__PURE__*/_react["default"].createElement(TabPanel, {
872
+ value: value,
873
+ index: 0
874
+ }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
875
+ mt: 4,
876
+ mb: 2
877
+ }, options != null && process.env.stripePublicKey != null && /*#__PURE__*/_react["default"].createElement(_reactStripeJs.Elements, {
878
+ stripe: stripePromise,
879
+ options: options
880
+ }, /*#__PURE__*/_react["default"].createElement("checkoutForm", {
881
+ payButtonText: payButtonText,
882
+ clientSecret: options != null ? options.clientSecret : null,
883
+ onResponse: onResponse,
884
+ amount: amount
885
+ }))))));
886
+ };
887
+
888
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isModal && /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
889
+ fullWidth: true,
890
+ maxWidth: "sm",
891
+ open: isOpen,
892
+ onClose: function onClose() {
893
+ return onModalClose();
894
+ }
895
+ }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
896
+ "aria-label": "close",
897
+ onClick: function onClick() {
898
+ onModalClose();
899
+ },
900
+ sx: {
901
+ position: 'absolute',
902
+ right: 8,
903
+ top: 8,
904
+ color: function color(theme) {
905
+ return theme.palette.grey[500];
906
+ }
907
+ }
908
+ }, /*#__PURE__*/_react["default"].createElement(_Close["default"], null))), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], null, description, /*#__PURE__*/_react["default"].createElement(PaymentContent, null)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null)), !isModal && /*#__PURE__*/_react["default"].createElement(PaymentContent, null));
909
+ }
315
910
  "use strict";
316
911
 
317
912
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.110",
3
+ "version": "1.0.112",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,9 @@
16
16
  "nookies": "^2.5.2",
17
17
  "react": "^17.0.2",
18
18
  "react-data-table-component": "^7.5.2",
19
- "react-dom": "^17.0.2"
19
+ "react-dom": "^17.0.2",
20
+ "@stripe/react-stripe-js": "^1.9.0",
21
+ "@stripe/stripe-js": "^1.32.0"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@babel/cli": "^7.1.5",
@@ -32,6 +34,8 @@
32
34
  "next": "^12.2.0",
33
35
  "nookies": "^2.5.2",
34
36
  "query-string": "^7.1.1",
35
- "react-data-table-component": "^7.5.2"
37
+ "react-data-table-component": "^7.5.2",
38
+ "@stripe/react-stripe-js": "^1.9.0",
39
+ "@stripe/stripe-js": "^1.32.0"
36
40
  }
37
41
  }
@@ -0,0 +1,157 @@
1
+ import React, {useState} from 'react';
2
+ import Button from '@mui/material/Button';
3
+ import {useStripe, useElements, PaymentElement} from '@stripe/react-stripe-js';
4
+ import PaymentRoundedIcon from '@mui/icons-material/PaymentRounded';
5
+
6
+ const checkoutForm = ({payButtonText, clientSecret, onResponse, amount}) => {
7
+
8
+ const [isPaymentProcessing, setIsPaymentProcessing] = useState(false);
9
+
10
+ const stripe = useStripe();
11
+ const elements = useElements();
12
+
13
+ const [errorMessage, setErrorMessage] = useState(null);
14
+
15
+ const handleSubmit = async (event) => {
16
+
17
+ setIsPaymentProcessing(true);
18
+
19
+ // We don't want to let default form submission happen here,
20
+ // which would refresh the page.
21
+ event.preventDefault();
22
+
23
+ if (!stripe || !elements) {
24
+ // Stripe.js has not yet loaded.
25
+ // Make sure to disable form submission until Stripe.js has loaded.
26
+
27
+ setIsPaymentProcessing(false);
28
+ return;
29
+ }
30
+
31
+
32
+ if (amount == null)
33
+ {
34
+ const {error} = await stripe.confirmSetup({
35
+ //`Elements` instance that was used to create the Payment Element
36
+ elements,
37
+ redirect:"if_required",
38
+ // confirmParams: {
39
+ // return_url: process.env.WebsiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
40
+ // },
41
+ });
42
+
43
+ if (error) {
44
+ // This point will only be reached if there is an immediate error when
45
+ // confirming the payment. Show error to your customer (for example, payment
46
+ // details incomplete)
47
+ setIsPaymentProcessing(false);
48
+ setErrorMessage(error.message);
49
+ } else {
50
+ // Your customer will be redirected to your `return_url`. For some payment
51
+ // methods like iDEAL, your customer will be redirected to an intermediate
52
+ // site first to authorize the payment, then redirected to the `return_url`.
53
+
54
+ setIsPaymentProcessing(false);
55
+
56
+ let response = null;
57
+
58
+ response = await stripe.retrieveSetupIntent(clientSecret);
59
+
60
+ //
61
+
62
+ let setupIntent = response.setupIntent;
63
+
64
+ switch (setupIntent.status) {
65
+ case 'succeeded':
66
+
67
+ // need to store the payment intent with the customer if they are logged in... currentUser
68
+ onResponse("succeeded", setupIntent.id, setupIntent.payment_method);
69
+ break;
70
+
71
+ case 'processing':
72
+ onResponse("processing", setupIntent.id, setupIntent.payment_method);
73
+ break;
74
+
75
+ case 'requires_payment_method':
76
+ onResponse("requires_payment_method", null);
77
+ break;
78
+
79
+ default:
80
+ onResponse("failed", null);
81
+ break;
82
+ }
83
+ }
84
+
85
+ }
86
+ else
87
+ {
88
+ const {error} = await stripe.confirmPayment({
89
+ //`Elements` instance that was used to create the Payment Element
90
+ elements,
91
+ redirect:"if_required",
92
+ confirmParams: {
93
+ return_url: process.env.WebsiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search),
94
+ },
95
+ });
96
+
97
+ if (error) {
98
+ // This point will only be reached if there is an immediate error when
99
+ // confirming the payment. Show error to your customer (for example, payment
100
+ // details incomplete)
101
+ setIsPaymentProcessing(false);
102
+ setErrorMessage(error.message);
103
+ } else {
104
+ // Your customer will be redirected to your `return_url`. For some payment
105
+ // methods like iDEAL, your customer will be redirected to an intermediate
106
+ // site first to authorize the payment, then redirected to the `return_url`.
107
+
108
+
109
+ setIsPaymentProcessing(false);
110
+
111
+ let response = null;
112
+
113
+ if (amount == null)
114
+ {
115
+ response = await stripe.retrieveSetupIntent(clientSecret);
116
+ }
117
+ else
118
+ {
119
+ response = await stripe.retrievePaymentIntent(clientSecret);
120
+ }
121
+
122
+ let paymentIntent = response.paymentIntent;
123
+
124
+ switch (paymentIntent.status) {
125
+ case 'succeeded':
126
+
127
+ // need to store the payment intent with the customer if they are logged in... currentUser
128
+ onResponse("succeeded", paymentIntent.id);
129
+ break;
130
+
131
+ case 'processing':
132
+ onResponse("processing", paymentIntent.id);
133
+ break;
134
+
135
+ case 'requires_payment_method':
136
+ onResponse("requires_payment_method", null);
137
+ break;
138
+
139
+ default:
140
+ onResponse("failed", null);
141
+ break;
142
+ }
143
+ }
144
+ }
145
+ };
146
+
147
+ return (
148
+ <form onSubmit={handleSubmit}>
149
+ <PaymentElement />
150
+ <Button startIcon={<PaymentRoundedIcon/>} type="submit" fullWidth={true} variant="contained" disabled={(!stripe || isPaymentProcessing)} sx={{marginTop:2}}>{payButtonText}</Button>
151
+ {/* Show error message to your customers */}
152
+ {errorMessage && <div>{errorMessage}</div>}
153
+ </form>
154
+ )
155
+ };
156
+
157
+ export default CheckoutForm;
@@ -0,0 +1,251 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ import {Elements} from '@stripe/react-stripe-js';
3
+ import {loadStripe} from '@stripe/stripe-js';
4
+ import Box from '@mui/material/Box';
5
+ import Dialog from '@mui/material/Dialog';
6
+ import DialogActions from '@mui/material/DialogActions';
7
+ import DialogContent from '@mui/material/DialogContent';
8
+ import DialogTitle from '@mui/material/DialogTitle';
9
+ //import CheckoutForm from './checkoutForm';
10
+ import IconButton from '@mui/material/IconButton';
11
+ import CloseIcon from '@mui/icons-material/Close';
12
+ import Tabs from '@mui/material/Tabs';
13
+ import Tab from '@mui/material/Tab';
14
+ import Typography from '@mui/material/Typography';
15
+ import Select from '@mui/material/Select';
16
+ import MenuItem from '@mui/material/MenuItem';
17
+ //import {apiService} from 'authscape';
18
+ import Grid from '@mui/material/Grid';
19
+
20
+ export default function stripePayment({title, description, amount = null, priceId = null, stripeCustomerId = null, isModal = true, logOffUserName, logOffEmail, paymentRequestType = 3, currentUser, isOpen, onModalClose, onResponse, payButtonText = "PAY NOW"}) {
21
+
22
+ const stripePromise = loadStripe(process.env.stripePublicKey);
23
+ const [options, setOptions] = useState(null);
24
+ const [value, setValue] = useState(0);
25
+ const [paymentMethods, setPaymentMethods] = useState([]);
26
+ const [paymentMethod, setPaymentMethod] = useState(null);
27
+
28
+ const paymentMethodOpened = async () => {
29
+
30
+ let response = null;
31
+ if (currentUser == null)
32
+ {
33
+ response = await apiService().post("/Payment/ConnectCustomerNoAuth", {
34
+ paymentRequestType: paymentRequestType,
35
+ amount: amount,
36
+ priceId: priceId,
37
+ name: logOffUserName,
38
+ email: logOffEmail,
39
+ stripeCustomerId: stripeCustomerId
40
+ });
41
+ }
42
+ else
43
+ {
44
+ response = await apiService().post("/Payment/ConnectCustomer", {
45
+ paymentRequestType: paymentRequestType,
46
+ amount: amount,
47
+ priceId: priceId,
48
+ stripeCustomerId: stripeCustomerId
49
+ });
50
+ }
51
+
52
+
53
+ if (response != null && response.status == 200)
54
+ {
55
+ setOptions({
56
+ clientSecret: response.data,
57
+ });
58
+
59
+ let responsePayments = await apiService().get("/Payment/GetPaymentMethods");
60
+ if (responsePayments != null && responsePayments.status == 200)
61
+ {
62
+ if (responsePayments.data.length > 0)
63
+ {
64
+ setValue(1);
65
+ }
66
+ setPaymentMethods(responsePayments.data);
67
+ }
68
+ }
69
+ }
70
+
71
+ useEffect(() => {
72
+
73
+ if (isOpen)
74
+ {
75
+ paymentMethodOpened();
76
+ }
77
+
78
+ }, [isOpen]);
79
+
80
+ const handleChange = (event, newValue) => {
81
+ setValue(newValue);
82
+ };
83
+
84
+ function a11yProps(index) {
85
+ return {
86
+ id: `simple-tab-${index}`,
87
+ 'aria-controls': `simple-tabpanel-${index}`,
88
+ };
89
+ }
90
+
91
+ const PaymentMethod = ({paymentMethod, clicked}) => {
92
+ return (
93
+ <Box fullWidth={true} sx={{height: 160, width:"100%", marginTop:2, backgroundColor:"#2196F3", position:"relative", border: "1px solid #2196F3", borderRadius: 1, display:"flex", flexDirection:"column", justifyContent:"center", textAlign:"center", cursor:"pointer"}}
94
+ onClick={() => {
95
+ clicked(paymentMethod.id);
96
+ }}>
97
+ <Typography gutterBottom variant="body" component="div" sx={{fontSize:14, position:"absolute", left:15, top:10, color:"white"}}>
98
+ {paymentMethod.brand}
99
+ </Typography>
100
+ <Typography gutterBottom variant="body" component="div" sx={{verticalAlign:"middle", fontSize:18, color:"white"}}>
101
+ * * * * &nbsp; * * * * &nbsp; * * * * &nbsp; {paymentMethod.last4}
102
+ </Typography>
103
+
104
+ <Grid container spacing={1} sx={{position:"absolute", bottom:8, marginLeft:0, width: "100%"}}>
105
+ <Grid item xs={12} sx={{textAlign:"right", paddingRight:2}}>
106
+ <Typography gutterBottom variant="body" component="div" sx={{fontSize:12, marginLeft:2, marginTop:1, color:"#e9e9e9"}}>
107
+ EXPIRES
108
+ </Typography>
109
+
110
+ <Typography gutterBottom variant="body" component="div" sx={{fontSize:12, marginLeft:2, marginTop:"-9px", color:"white"}}>
111
+ {paymentMethod.expMonth}/{paymentMethod.expYear}
112
+ </Typography>
113
+ </Grid>
114
+ </Grid>
115
+ </Box>
116
+ );
117
+ };
118
+
119
+ function TabPanel(props) {
120
+ const { children, value, index, ...other } = props;
121
+
122
+ return (
123
+ <div
124
+ role="tabpanel"
125
+ hidden={value !== index}
126
+ id={`simple-tabpanel-${index}`}
127
+ aria-labelledby={`simple-tab-${index}`}
128
+ {...other}
129
+ >
130
+ {value === index && (
131
+ <Box sx={{ p: 3 }}>
132
+ <Typography>{children}</Typography>
133
+ </Box>
134
+ )}
135
+ </div>
136
+ );
137
+ }
138
+
139
+ const PaymentContent = () => {
140
+ return (
141
+ <Box sx={{ width: '100%' }}>
142
+ <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
143
+ <Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
144
+ <Tab label="Add Payment Method" {...a11yProps(0)} />
145
+ {paymentMethods.length > 0 &&
146
+ <Tab label="Existing Payment Method" {...a11yProps(1)} />
147
+ }
148
+ </Tabs>
149
+ </Box>
150
+ {paymentMethods.length > 0 &&
151
+ <TabPanel value={value} index={1}>
152
+
153
+ <Select
154
+ sx={{marginTop:4}}
155
+ fullWidth={true}
156
+ id="demo-simple-select"
157
+ value={paymentMethod}
158
+ onChange={(val) => {
159
+ setPaymentMethod(val.target.value);
160
+ }}>
161
+ {paymentMethods != null && paymentMethods.map((paymentMethod, index) => {
162
+ return (
163
+ <MenuItem key={index} value={paymentMethod.id} fullWidth={true} sx={{width:"100%"}}>
164
+ <PaymentMethod paymentMethod={paymentMethod} clicked={() => {
165
+ }} />
166
+ </MenuItem>)
167
+ })}
168
+ </Select>
169
+
170
+ {/* <Button startIcon={<PaymentRoundedIcon/>} type="submit" variant="contained" disabled={paymentMethod == null} sx={{marginTop:2}} onClick={async () => {
171
+
172
+ if (invoiceId != null)
173
+ {
174
+ setIsLoading(true);
175
+ let response = await apiService().post("/Invoices/PayInvoice", {
176
+ InvoiceId: invoiceId,
177
+ WalletId: paymentMethod
178
+ });
179
+ setIsLoading(false);
180
+
181
+ if (response != null && response.status == 200)
182
+ {
183
+ window.location.reload();
184
+ }
185
+ else
186
+ {
187
+ alert("We had an issue with the payment method");
188
+ }
189
+ }
190
+
191
+ }}>{payButtonText}</Button> */}
192
+
193
+ </TabPanel>
194
+ }
195
+
196
+ <TabPanel value={value} index={0}>
197
+ <div>
198
+ <Box mt={4} mb={2}>
199
+ {(options != null && process.env.stripePublicKey != null) &&
200
+ <Elements stripe={stripePromise} options={options}>
201
+ <checkoutForm payButtonText={payButtonText} clientSecret={options != null ? options.clientSecret : null} onResponse={onResponse} amount={amount} />
202
+ </Elements>
203
+ }
204
+ </Box>
205
+ </div>
206
+ </TabPanel>
207
+ </Box>
208
+ )
209
+ }
210
+
211
+ return (
212
+ <>
213
+ {isModal &&
214
+ <Dialog
215
+ fullWidth={true}
216
+ maxWidth={"sm"}
217
+ open={isOpen}
218
+ onClose={() => onModalClose()}>
219
+ <DialogTitle>{title}
220
+
221
+ <IconButton
222
+ aria-label="close"
223
+ onClick={() => {
224
+
225
+ onModalClose();
226
+ }}
227
+ sx={{
228
+ position: 'absolute',
229
+ right: 8,
230
+ top: 8,
231
+ color: (theme) => theme.palette.grey[500],
232
+ }}>
233
+ <CloseIcon />
234
+ </IconButton>
235
+ </DialogTitle>
236
+ <DialogContent>
237
+ {description}
238
+ <PaymentContent />
239
+ </DialogContent>
240
+ <DialogActions>
241
+ </DialogActions>
242
+ </Dialog>
243
+ }
244
+
245
+ {!isModal &&
246
+ <PaymentContent />
247
+ }
248
+
249
+ </>
250
+ )
251
+ }
package/src/index.js DELETED
@@ -1,13 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- export default class DummyComponent extends Component {
4
-
5
- render () {
6
-
7
- return (
8
- <div>I am a dummy react npm module</div>
9
- )
10
-
11
- }
12
-
13
- }