@goweekdays/core 1.1.1 → 1.1.3

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
+ ## 1.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 0f25524: Revise invoice webhook handler
8
+
9
+ ## 1.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 39a9527: Paypal invoice webhook handler patch
14
+
3
15
  ## 1.1.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2025,7 +2025,7 @@ declare function useInvoiceRepo(): {
2025
2025
 
2026
2026
  declare function useInvoiceService(): {
2027
2027
  processOverDueInvoices: (BATCH_SIZE?: number, MAX_RETRIES?: number) => Promise<void>;
2028
- paypalPaidInvoiceWebhookHandler: (invoiceId: string, status: string) => Promise<"Payment processed successfully." | undefined>;
2028
+ paypalPaidInvoiceWebhookHandler: (invoiceId: string) => Promise<"Payment processed successfully." | undefined>;
2029
2029
  };
2030
2030
 
2031
2031
  declare function useInvoiceController(): {
package/dist/index.js CHANGED
@@ -24945,13 +24945,10 @@ function useInvoiceService() {
24945
24945
  });
24946
24946
  }
24947
24947
  }
24948
- async function paypalPaidInvoiceWebhookHandler(invoiceId, status) {
24948
+ async function paypalPaidInvoiceWebhookHandler(invoiceId) {
24949
24949
  if (!invoiceId) {
24950
24950
  throw new import_utils84.BadRequestError("Invoice ID is required.");
24951
24951
  }
24952
- if (!status) {
24953
- throw new import_utils84.BadRequestError("Status is required.");
24954
- }
24955
24952
  const session = import_utils84.useAtlas.getClient()?.startSession();
24956
24953
  if (!session) {
24957
24954
  import_utils84.logger.log({
@@ -24960,6 +24957,7 @@ function useInvoiceService() {
24960
24957
  });
24961
24958
  return;
24962
24959
  }
24960
+ session.startTransaction();
24963
24961
  try {
24964
24962
  const invoice = await getByTransactionId(invoiceId);
24965
24963
  if (!invoice) {
@@ -24970,7 +24968,6 @@ function useInvoiceService() {
24970
24968
  "Subscription ID is missing in invoice metadata."
24971
24969
  );
24972
24970
  }
24973
- session?.startTransaction();
24974
24971
  const subscription = await getById(invoice.metadata.subscriptionId);
24975
24972
  if (!subscription) {
24976
24973
  throw new import_utils84.NotFoundError("Subscription not found.");
@@ -25022,13 +25019,14 @@ function useInvoiceService() {
25022
25019
  await session.commitTransaction();
25023
25020
  return "Payment processed successfully.";
25024
25021
  } catch (error) {
25025
- session?.abortTransaction();
25022
+ session.abortTransaction();
25026
25023
  import_utils84.logger.log({
25027
25024
  level: "error",
25028
25025
  message: String(error)
25029
25026
  });
25027
+ throw error;
25030
25028
  } finally {
25031
- session?.endSession();
25029
+ session.endSession();
25032
25030
  }
25033
25031
  }
25034
25032
  return {
@@ -25129,8 +25127,7 @@ function useInvoiceController() {
25129
25127
  const invoiceId = req.body.resource.id ?? "";
25130
25128
  const status = req.body.resource.status ?? "";
25131
25129
  const validation = import_joi28.default.object({
25132
- invoiceId: import_joi28.default.string().required(),
25133
- status: import_joi28.default.string().valid("PAID").required()
25130
+ invoiceId: import_joi28.default.string().required()
25134
25131
  });
25135
25132
  const { error } = validation.validate({ invoiceId, status });
25136
25133
  if (error) {
@@ -25138,7 +25135,7 @@ function useInvoiceController() {
25138
25135
  return;
25139
25136
  }
25140
25137
  try {
25141
- await paypalPaidInvoiceWebhookHandler(invoiceId, status);
25138
+ await paypalPaidInvoiceWebhookHandler(invoiceId);
25142
25139
  res.status(200).json({ message: "Webhook processed successfully." });
25143
25140
  return;
25144
25141
  } catch (error2) {