@felloh-org/lambda-wrapper 1.3.6 → 1.3.8

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/.eslintrc.yml CHANGED
@@ -22,3 +22,5 @@ rules:
22
22
  camelcase: "off"
23
23
  import/no-dynamic-require: "off"
24
24
  global-require: "off"
25
+ import/no-named-as-default: "off"
26
+ import/no-named-as-default-member: "off"
@@ -15,6 +15,8 @@ var _http = _interopRequireDefault(require("../service/http"));
15
15
 
16
16
  var _logger = _interopRequireDefault(require("../service/logger"));
17
17
 
18
+ var _paymentInitiationObject = _interopRequireDefault(require("../service/payment-initiation-object"));
19
+
18
20
  var _request = _interopRequireDefault(require("../service/request"));
19
21
 
20
22
  var _user = _interopRequireDefault(require("../service/user"));
@@ -29,6 +31,7 @@ const DEFINITIONS = {
29
31
  EVENT_BRIDGE: 'EVENT_BRIDGE',
30
32
  HTTP: 'HTTP',
31
33
  LOGGER: 'LOGGER',
34
+ PAYMENT_INITIATION_OBJECT: 'PAYMENT_INITIATION_OBJECT',
32
35
  REQUEST: 'REQUEST',
33
36
  USER: 'USER',
34
37
  WAREHOUSE: 'WAREHOUSE'
@@ -39,6 +42,7 @@ const Dependencies = {
39
42
  [DEFINITIONS.EVENT_BRIDGE]: _eventBridge.default,
40
43
  [DEFINITIONS.HTTP]: _http.default,
41
44
  [DEFINITIONS.LOGGER]: _logger.default,
45
+ [DEFINITIONS.PAYMENT_INITIATION_OBJECT]: _paymentInitiationObject.default,
42
46
  [DEFINITIONS.REQUEST]: _request.default,
43
47
  [DEFINITIONS.WAREHOUSE]: _warehouse.default,
44
48
  [DEFINITIONS.AUTHENTICATION]: _authentication.default,
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ ECOMMERCE: 'ecommerce',
9
+ PAYMENT_LINK: 'payment-link'
10
+ };
11
+ exports.default = _default;
package/dist/index.js CHANGED
@@ -231,6 +231,12 @@ Object.defineProperty(exports, "OrganisationWebhookEntity", {
231
231
  return _organisationWebhook.default;
232
232
  }
233
233
  });
234
+ Object.defineProperty(exports, "PAYMENT_INITIATION_TYPES", {
235
+ enumerable: true,
236
+ get: function () {
237
+ return _paymentInitationTypes.default;
238
+ }
239
+ });
234
240
  Object.defineProperty(exports, "PaymentLinkEntity", {
235
241
  enumerable: true,
236
242
  get: function () {
@@ -636,6 +642,8 @@ var _organisationPayoutConfig = _interopRequireDefault(require("./entity/user/or
636
642
 
637
643
  var _transaction5 = _interopRequireDefault(require("./entity/nuvei/transaction"));
638
644
 
645
+ var _paymentInitationTypes = _interopRequireDefault(require("./enums/payment-initation-types"));
646
+
639
647
  var _registration = _interopRequireDefault(require("./event/user/registration"));
640
648
 
641
649
  var _changed = _interopRequireDefault(require("./event/user/password/changed"));
@@ -0,0 +1,15 @@
1
+ const { MigrationInterface, QueryRunner } = require("typeorm");
2
+
3
+ module.exports = class ecommerceTransaction1669040104944 {
4
+ name = 'ecommerceTransaction1669040104944'
5
+
6
+ async up(queryRunner) {
7
+ await queryRunner.query(`ALTER TABLE "payment"."transaction" ADD "ecommerce_id" character varying`);
8
+ await queryRunner.query(`ALTER TABLE "payment"."transaction" ADD CONSTRAINT "FK_9647a5fc7819bebf68c045b1f0c" FOREIGN KEY ("ecommerce_id") REFERENCES "payment"."ecommerce"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
9
+ }
10
+
11
+ async down(queryRunner) {
12
+ await queryRunner.query(`ALTER TABLE "payment"."transaction" DROP CONSTRAINT "FK_9647a5fc7819bebf68c045b1f0c"`);
13
+ await queryRunner.query(`ALTER TABLE "payment"."transaction" DROP COLUMN "ecommerce_id"`);
14
+ }
15
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _dependencies = require("../../config/dependencies");
9
+
10
+ var _dependencyAware = _interopRequireDefault(require("../../dependency-injection/dependency-aware"));
11
+
12
+ var _currency = _interopRequireDefault(require("../../entity/bank/currency"));
13
+
14
+ var _ecommerce = _interopRequireDefault(require("../../entity/payment/ecommerce"));
15
+
16
+ var _paymentLink = _interopRequireDefault(require("../../entity/payment/payment-link"));
17
+
18
+ var _paymentInitationTypes = _interopRequireDefault(require("../../enums/payment-initation-types"));
19
+
20
+ var _response = _interopRequireDefault(require("../../model/response"));
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ /**
25
+ * Payment Initiation Object Service
26
+ */
27
+ class PaymentInitiationObject extends _dependencyAware.default {
28
+ /**
29
+ * Payment Initiation Constructor
30
+ * @param di
31
+ */
32
+ constructor(di) {
33
+ super(di);
34
+ this.initialised = false;
35
+ const that = this;
36
+
37
+ this.initialise = async () => {
38
+ if (that.initialised === false) {
39
+ const warehouse = di.get(_dependencies.DEFINITIONS.WAREHOUSE);
40
+ that.connection = await warehouse.connect();
41
+ that.paymentLinkRepository = await this.connection.getRepository(_paymentLink.default);
42
+ that.ecommerceRepository = await this.connection.getRepository(_ecommerce.default);
43
+ this.initialised = true;
44
+ }
45
+ };
46
+ }
47
+
48
+ async get(initiationObjectID, initiationType) {
49
+ await this.initialise();
50
+ let result = null;
51
+
52
+ if (initiationType === _paymentInitationTypes.default.PAYMENT_LINK) {
53
+ result = await this.paymentLinkRepository.createQueryBuilder('payment_link').leftJoinAndSelect('payment_link.organisation', 'organisation').leftJoinAndSelect('payment_link.booking', 'booking').leftJoinAndMapOne('payment_link.currency', _currency.default, 'currency_join', 'currency_join.id = payment_link.currency').where('payment_link.id = :initiation_object_ID', {
54
+ initiation_object_ID: initiationObjectID
55
+ }).getOne(); // Throw an error response if the payment link does not exist
56
+
57
+ if (!result) {
58
+ const notFoundResponse = new _response.default(null, 404);
59
+ notFoundResponse.addError({
60
+ title: 'Payment link not found',
61
+ message: 'The payment link entity that you are attempting to access does not exist',
62
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
63
+ type: 'not_found',
64
+ code: 'payment_link.not_found'
65
+ });
66
+ throw notFoundResponse;
67
+ }
68
+ } else if (initiationType === _paymentInitationTypes.default.ECOMMERCE) {
69
+ result = await this.ecommerceRepository.createQueryBuilder('ecommerce').leftJoinAndSelect('ecommerce.organisation', 'organisation').leftJoinAndSelect('ecommerce.booking', 'booking').leftJoinAndMapOne('ecommerce.currency', _currency.default, 'currency_join', 'currency_join.id = ecommerce.currency').where('ecommerce.id = :initiation_object_ID', {
70
+ initiation_object_ID: initiationObjectID
71
+ }).getOne(); // Throw an error response if the payment link does not exist
72
+
73
+ if (!result) {
74
+ const notFoundResponse = new _response.default(null, 404);
75
+ notFoundResponse.addError({
76
+ title: 'Ecommerce entity not found',
77
+ message: 'The ecommerce entity that you are attempting to access does not exist',
78
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
79
+ type: 'not_found',
80
+ code: 'ecommerce.not_found'
81
+ });
82
+ throw notFoundResponse;
83
+ }
84
+ } else {
85
+ const notFoundResponse = new _response.default(null, 501);
86
+ notFoundResponse.addError({
87
+ title: 'Payment initiation type not supported',
88
+ message: 'The payment initiation type that you provided is not supported',
89
+ documentation_url: 'https://developers.felloh.com/errors#error-responses',
90
+ type: 'not_found',
91
+ code: 'initiation_type.not_supported'
92
+ });
93
+ throw notFoundResponse;
94
+ }
95
+
96
+ return result;
97
+ }
98
+
99
+ }
100
+
101
+ exports.default = PaymentInitiationObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felloh-org/lambda-wrapper",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Lambda wrapper for all Felloh Serverless Projects",
5
5
  "main": "dist/index.js",
6
6
  "engines": {