@goweekdays/core 1.1.2 → 1.1.4
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 +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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
|
|
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
|
|
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({
|
|
@@ -24980,15 +24977,15 @@ function useInvoiceService() {
|
|
|
24980
24977
|
}
|
|
24981
24978
|
if (subscription.status !== "active") {
|
|
24982
24979
|
await updateStatusById(subscription._id.toString(), "active", session);
|
|
24980
|
+
await processSuccessfulPayment(
|
|
24981
|
+
{
|
|
24982
|
+
_id: subscription._id,
|
|
24983
|
+
nextBillingDate: /* @__PURE__ */ new Date()
|
|
24984
|
+
},
|
|
24985
|
+
session
|
|
24986
|
+
);
|
|
24983
24987
|
}
|
|
24984
24988
|
await updateStatusByInvoiceNumber(invoice.invoiceNumber, "paid", session);
|
|
24985
|
-
await processSuccessfulPayment(
|
|
24986
|
-
{
|
|
24987
|
-
_id: subscription._id,
|
|
24988
|
-
nextBillingDate: subscription.nextBillingDate
|
|
24989
|
-
},
|
|
24990
|
-
session
|
|
24991
|
-
);
|
|
24992
24989
|
const paymentData = {
|
|
24993
24990
|
invoiceId: invoice.invoiceNumber,
|
|
24994
24991
|
amount: invoice.amount,
|
|
@@ -25130,8 +25127,7 @@ function useInvoiceController() {
|
|
|
25130
25127
|
const invoiceId = req.body.resource.id ?? "";
|
|
25131
25128
|
const status = req.body.resource.status ?? "";
|
|
25132
25129
|
const validation = import_joi28.default.object({
|
|
25133
|
-
invoiceId: import_joi28.default.string().required()
|
|
25134
|
-
status: import_joi28.default.string().valid("PAID").required()
|
|
25130
|
+
invoiceId: import_joi28.default.string().required()
|
|
25135
25131
|
});
|
|
25136
25132
|
const { error } = validation.validate({ invoiceId, status });
|
|
25137
25133
|
if (error) {
|
|
@@ -25139,7 +25135,7 @@ function useInvoiceController() {
|
|
|
25139
25135
|
return;
|
|
25140
25136
|
}
|
|
25141
25137
|
try {
|
|
25142
|
-
await paypalPaidInvoiceWebhookHandler(invoiceId
|
|
25138
|
+
await paypalPaidInvoiceWebhookHandler(invoiceId);
|
|
25143
25139
|
res.status(200).json({ message: "Webhook processed successfully." });
|
|
25144
25140
|
return;
|
|
25145
25141
|
} catch (error2) {
|