@goweekdays/core 0.0.5 → 0.0.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @goweekdays/core
2
2
 
3
+ ## 0.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - b303ac8: clean up
8
+
9
+ ## 0.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - 30d52f6: update dependencies
14
+
3
15
  ## 0.0.5
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1012,7 +1012,8 @@ declare function usePaymentMethodService(): {
1012
1012
  };
1013
1013
 
1014
1014
  declare function usePaymentMethodController(): {
1015
- linkEWalletController: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1015
+ linkEWallet: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1016
+ linkCard: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1016
1017
  getByUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1017
1018
  };
1018
1019
 
package/dist/index.js CHANGED
@@ -13431,7 +13431,8 @@ function useFileService() {
13431
13431
  secretAccessKey: SPACES_SECRET_KEY,
13432
13432
  endpoint: SPACES_ENDPOINT,
13433
13433
  region: SPACES_REGION,
13434
- bucket: SPACES_BUCKET
13434
+ bucket: SPACES_BUCKET,
13435
+ forcePathStyle: true
13435
13436
  });
13436
13437
  async function createFile(value) {
13437
13438
  const session = import_utils14.useAtlas.getClient()?.startSession();
@@ -18838,7 +18839,8 @@ function useXenditService() {
18838
18839
  });
18839
18840
  return res.data;
18840
18841
  } catch (error) {
18841
- throw new import_utils54.BadRequestError("Failed to initiate card linking..");
18842
+ import_utils54.logger.error(error.response.data.message);
18843
+ throw new import_utils54.BadRequestError(error.response.data.message);
18842
18844
  }
18843
18845
  }
18844
18846
  async function eWalletSubsequentPayment({
@@ -19071,7 +19073,6 @@ function usePaymentMethodRepo() {
19071
19073
  try {
19072
19074
  return collection.aggregate([
19073
19075
  { $match: { user } },
19074
- { $sort: { createdAt: -1 } },
19075
19076
  {
19076
19077
  $project: {
19077
19078
  _id: 1,
@@ -19442,7 +19443,6 @@ function useSubscriptionService() {
19442
19443
  payment.user = "";
19443
19444
  payment.org = org;
19444
19445
  delete payment._id;
19445
- console.log(payment);
19446
19446
  await addPaymentMethod(payment, session);
19447
19447
  value.billingAddress.org = org;
19448
19448
  await addAddress(value.billingAddress, session);
@@ -19866,8 +19866,8 @@ function usePaymentMethodService() {
19866
19866
  var import_joi12 = __toESM(require("joi"));
19867
19867
  var import_utils64 = require("@goweekdays/utils");
19868
19868
  function usePaymentMethodController() {
19869
- const { linkEWallet } = usePaymentMethodService();
19870
- async function linkEWalletController(req, res, next) {
19869
+ const { linkEWallet: _linkEWallet, linkCard: _linkCard } = usePaymentMethodService();
19870
+ async function linkEWallet(req, res, next) {
19871
19871
  const mobile_number = req.body.mobile_number ?? "";
19872
19872
  const type = req.body.type ?? "";
19873
19873
  const user = req.headers["user"] ?? "";
@@ -19894,7 +19894,7 @@ function usePaymentMethodController() {
19894
19894
  next(new import_utils64.BadRequestError(error.message));
19895
19895
  }
19896
19896
  try {
19897
- const result = await linkEWallet({
19897
+ const result = await _linkEWallet({
19898
19898
  user,
19899
19899
  mobile_number,
19900
19900
  type,
@@ -19908,6 +19908,63 @@ function usePaymentMethodController() {
19908
19908
  next(error2);
19909
19909
  }
19910
19910
  }
19911
+ async function linkCard(req, res, next) {
19912
+ const cardNumber = req.body.cardNumber ?? "";
19913
+ const expiryMonth = req.body.expiryMonth ?? "";
19914
+ const expiryYear = req.body.expiryYear ?? "";
19915
+ const cvv = req.body.cvv ?? "";
19916
+ const cardholderName = req.body.cardholderName ?? "";
19917
+ const currency = req.body.currency ?? "";
19918
+ const success_return_url = req.body.success_return_url ?? "";
19919
+ const failure_return_url = req.body.failure_return_url ?? "";
19920
+ const cardType = req.body.cardType ?? "";
19921
+ const user = req.headers["user"] ?? "";
19922
+ const validation = import_joi12.default.object({
19923
+ cardNumber: import_joi12.default.string().required(),
19924
+ expiryMonth: import_joi12.default.string().required(),
19925
+ expiryYear: import_joi12.default.string().required(),
19926
+ cvv: import_joi12.default.string().required(),
19927
+ cardholderName: import_joi12.default.string().required(),
19928
+ currency: import_joi12.default.string().optional().allow("", null),
19929
+ success_return_url: import_joi12.default.string().uri().required(),
19930
+ failure_return_url: import_joi12.default.string().uri().required(),
19931
+ cardType: import_joi12.default.string().required(),
19932
+ user: import_joi12.default.string().hex().required()
19933
+ });
19934
+ const { error } = validation.validate({
19935
+ user,
19936
+ cardType,
19937
+ cardNumber,
19938
+ expiryMonth,
19939
+ expiryYear,
19940
+ cvv,
19941
+ cardholderName,
19942
+ currency,
19943
+ success_return_url,
19944
+ failure_return_url
19945
+ });
19946
+ if (error) {
19947
+ next(new import_utils64.BadRequestError(error.message));
19948
+ }
19949
+ try {
19950
+ const result = await _linkCard({
19951
+ type: cardType,
19952
+ user,
19953
+ card_number: cardNumber,
19954
+ expiry_month: expiryMonth,
19955
+ expiry_year: expiryYear,
19956
+ cvv,
19957
+ cardholder_name: cardholderName,
19958
+ currency,
19959
+ success_return_url,
19960
+ failure_return_url
19961
+ });
19962
+ res.json(result);
19963
+ return;
19964
+ } catch (error2) {
19965
+ next(error2);
19966
+ }
19967
+ }
19911
19968
  const { getByUser: _getByUser } = usePaymentMethodRepo();
19912
19969
  async function getByUser(req, res, next) {
19913
19970
  const user = req.headers["user"] ?? "";
@@ -19919,7 +19976,8 @@ function usePaymentMethodController() {
19919
19976
  }
19920
19977
  }
19921
19978
  return {
19922
- linkEWalletController,
19979
+ linkEWallet,
19980
+ linkCard,
19923
19981
  getByUser
19924
19982
  };
19925
19983
  }