founder-schema 0.30.0 → 0.31.0
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/dist/core/errors.d.ts +5 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +13 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/limits.d.ts +17 -0
- package/dist/core/limits.d.ts.map +1 -1
- package/dist/core/limits.js +17 -0
- package/dist/core/limits.js.map +1 -1
- package/dist/core/responses.d.ts +4 -0
- package/dist/core/responses.d.ts.map +1 -1
- package/dist/domains/billing/billing.d.ts +373 -11
- package/dist/domains/billing/billing.d.ts.map +1 -1
- package/dist/domains/billing/billing.js +168 -2
- package/dist/domains/billing/billing.js.map +1 -1
- package/dist/domains/billing/emails.d.ts +171 -0
- package/dist/domains/billing/emails.d.ts.map +1 -0
- package/dist/domains/billing/emails.js +121 -0
- package/dist/domains/billing/emails.js.map +1 -0
- package/dist/domains/billing/payment-method.d.ts +63 -0
- package/dist/domains/billing/payment-method.d.ts.map +1 -0
- package/dist/domains/billing/payment-method.js +57 -0
- package/dist/domains/billing/payment-method.js.map +1 -0
- package/dist/domains/membership/membership.d.ts +127 -0
- package/dist/domains/membership/membership.d.ts.map +1 -1
- package/dist/domains/membership/membership.js +87 -0
- package/dist/domains/membership/membership.js.map +1 -1
- package/dist/domains/notifications/notifications.d.ts +38 -1
- package/dist/domains/notifications/notifications.d.ts.map +1 -1
- package/dist/domains/notifications/notifications.js +33 -2
- package/dist/domains/notifications/notifications.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Founder Circle's payment emails (0.31.0, payments v2; founder-circle-backend
|
|
3
|
+
* docs/payments-v2-plan.md R13).
|
|
4
|
+
*
|
|
5
|
+
* THE CONTRACT BETWEEN TWO REPOS. The FC backend sends these through the central
|
|
6
|
+
* async-service, which renders a template of the SAME name with the SAME data
|
|
7
|
+
* keys. One list here, so the backend's sends (krish) and the templates (ram)
|
|
8
|
+
* cannot drift. They are FC's own: the shared `payment-success` and
|
|
9
|
+
* `refund-processed` carry another product's words and links (dating copy, a
|
|
10
|
+
* `/find-partner/me` button that is a 404 on Founder Circle), and Jansathi
|
|
11
|
+
* uses them in production, so they stay as they are.
|
|
12
|
+
*
|
|
13
|
+
* Every value is ready to print: the server formats the money ("Rs 999"), the
|
|
14
|
+
* dates (India's calendar, "27 Nov 2026") and the absolute links: every
|
|
15
|
+
* `paymentsUrl` is `${APP_BASE_URL}/me/payments`, every `plansUrl` is
|
|
16
|
+
* `${APP_BASE_URL}/me?tab=upgrade` (Me > Plans, where auto-renew is turned off
|
|
17
|
+
* and the payment method updated). `daysLeft` is a number and some keys may be
|
|
18
|
+
* null, as each schema says. A template
|
|
19
|
+
* computes nothing and holds no Founder Circle URL of its own. Transactional
|
|
20
|
+
* mail: no unsubscribe link, and nothing a member's settings could switch off.
|
|
21
|
+
*
|
|
22
|
+
* @module domains/billing/emails
|
|
23
|
+
*/
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
const text = z.string().trim().min(1);
|
|
26
|
+
const url = z.url();
|
|
27
|
+
/** The receipt, for a purchase or an auto-renewal's first charge. Links to the invoice. */
|
|
28
|
+
export const fcPaymentReceivedEmailSchema = z.object({
|
|
29
|
+
firstName: text,
|
|
30
|
+
/** The server's title: "Premium, 1 month", "Membership". */
|
|
31
|
+
title: text,
|
|
32
|
+
amountText: text,
|
|
33
|
+
/** Null for a TEST invoice (dev, test keys). */
|
|
34
|
+
invoiceNumber: text.nullable(),
|
|
35
|
+
paidOn: text,
|
|
36
|
+
/** The last day a refund may be asked for, the bare date ("3 Dec 2026"); the template words it. */
|
|
37
|
+
refundableUntil: text,
|
|
38
|
+
/** `${APP_BASE_URL}/me/payments`. */
|
|
39
|
+
paymentsUrl: url,
|
|
40
|
+
});
|
|
41
|
+
/** A refund went through. */
|
|
42
|
+
export const fcRefundProcessedEmailSchema = z.object({
|
|
43
|
+
firstName: text,
|
|
44
|
+
title: text,
|
|
45
|
+
amountText: text,
|
|
46
|
+
creditNoteNumber: text.nullable(),
|
|
47
|
+
paymentsUrl: url,
|
|
48
|
+
});
|
|
49
|
+
/** A PREPAID plan ends in 7 days, then in 1 day: renew with a tap. */
|
|
50
|
+
export const fcPlanEndsSoonEmailSchema = z.object({
|
|
51
|
+
firstName: text,
|
|
52
|
+
planName: text,
|
|
53
|
+
endsOn: text,
|
|
54
|
+
daysLeft: z.number().int().positive(),
|
|
55
|
+
plansUrl: url,
|
|
56
|
+
});
|
|
57
|
+
/** A YEARLY auto-renewal charges in 7 days; turn it off before then to stop it. */
|
|
58
|
+
export const fcPlanRenewsSoonEmailSchema = z.object({
|
|
59
|
+
firstName: text,
|
|
60
|
+
planName: text,
|
|
61
|
+
amountText: text,
|
|
62
|
+
renewsOn: text,
|
|
63
|
+
plansUrl: url,
|
|
64
|
+
});
|
|
65
|
+
/** An auto-renewal charged: the plan runs on. Links to the invoice. */
|
|
66
|
+
export const fcRenewalDoneEmailSchema = z.object({
|
|
67
|
+
firstName: text,
|
|
68
|
+
planName: text,
|
|
69
|
+
amountText: text,
|
|
70
|
+
invoiceNumber: text.nullable(),
|
|
71
|
+
/** When the plan's time now runs to. */
|
|
72
|
+
runsUntil: text,
|
|
73
|
+
/** The next charge; null when the auto-renewal has no more (its last cycle). */
|
|
74
|
+
nextChargeOn: text.nullable(),
|
|
75
|
+
paymentsUrl: url,
|
|
76
|
+
});
|
|
77
|
+
/** An auto-renewal's charge failed; the gateway retries for 3 days. Update the method. */
|
|
78
|
+
export const fcRenewalFailedEmailSchema = z.object({
|
|
79
|
+
firstName: text,
|
|
80
|
+
planName: text,
|
|
81
|
+
amountText: text,
|
|
82
|
+
/** When the time already paid runs out, if no retry succeeds. */
|
|
83
|
+
endsOn: text,
|
|
84
|
+
plansUrl: url,
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Why an auto-renewal stopped (the email's wording):
|
|
88
|
+
*
|
|
89
|
+
* payment_failed every retry failed
|
|
90
|
+
* refunded a refund of its charge ended it
|
|
91
|
+
* membership_ended the membership was refunded or withdrawn
|
|
92
|
+
* turned_off the member turned it off (a confirmation)
|
|
93
|
+
*/
|
|
94
|
+
export const AUTO_RENEW_STOP_REASON_VALUES = [
|
|
95
|
+
'payment_failed',
|
|
96
|
+
'refunded',
|
|
97
|
+
'membership_ended',
|
|
98
|
+
'turned_off',
|
|
99
|
+
];
|
|
100
|
+
export const autoRenewStopReasonSchema = z.enum(AUTO_RENEW_STOP_REASON_VALUES);
|
|
101
|
+
/** An auto-renewal stopped; the time already paid runs to `endsOn`. */
|
|
102
|
+
export const fcAutoRenewStoppedEmailSchema = z.object({
|
|
103
|
+
firstName: text,
|
|
104
|
+
planName: text,
|
|
105
|
+
/** Null when no paid time is left (a refund took it). */
|
|
106
|
+
endsOn: text.nullable(),
|
|
107
|
+
reason: autoRenewStopReasonSchema,
|
|
108
|
+
plansUrl: url,
|
|
109
|
+
});
|
|
110
|
+
/** Every FC payment email, by its async-service template name. Exhaustive by type. */
|
|
111
|
+
export const FC_EMAIL_DATA_SCHEMAS = {
|
|
112
|
+
'fc-payment-received': fcPaymentReceivedEmailSchema,
|
|
113
|
+
'fc-refund-processed': fcRefundProcessedEmailSchema,
|
|
114
|
+
'fc-plan-ends-soon': fcPlanEndsSoonEmailSchema,
|
|
115
|
+
'fc-plan-renews-soon': fcPlanRenewsSoonEmailSchema,
|
|
116
|
+
'fc-renewal-done': fcRenewalDoneEmailSchema,
|
|
117
|
+
'fc-renewal-failed': fcRenewalFailedEmailSchema,
|
|
118
|
+
'fc-auto-renew-stopped': fcAutoRenewStoppedEmailSchema,
|
|
119
|
+
};
|
|
120
|
+
export const FC_EMAIL_TEMPLATE_VALUES = Object.keys(FC_EMAIL_DATA_SCHEMAS);
|
|
121
|
+
//#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tF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qBAAqB,EAAE,4BAA4B;IACnD,qBAAqB,EAAE,4BAA4B;IACnD,mBAAmB,EAAE,yBAAyB;IAC9C,qBAAqB,EAAE,2BAA2B;IAClD,iBAAiB,EAAE,wBAAwB;IAC3C,mBAAmB,EAAE,0BAA0B;IAC/C,uBAAuB,EAAE,6BAA6B;CAC9C,CAAC;AAGX,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAsB,CAAC","sourcesContent":["/**\n * Founder Circle's payment emails (0.31.0, payments v2; founder-circle-backend\n * docs/payments-v2-plan.md R13).\n *\n * THE CONTRACT BETWEEN TWO REPOS. The FC backend sends these through the central\n * async-service, which renders a template of the SAME name with the SAME data\n * keys. One list here, so the backend's sends (krish) and the templates (ram)\n * cannot drift. They are FC's own: the shared `payment-success` and\n * `refund-processed` carry another product's words and links (dating copy, a\n * `/find-partner/me` button that is a 404 on Founder Circle), and Jansathi\n * uses them in production, so they stay as they are.\n *\n * Every value is ready to print: the server formats the money (\"Rs 999\"), the\n * dates (India's calendar, \"27 Nov 2026\") and the absolute links: every\n * `paymentsUrl` is `${APP_BASE_URL}/me/payments`, every `plansUrl` is\n * `${APP_BASE_URL}/me?tab=upgrade` (Me > Plans, where auto-renew is turned off\n * and the payment method updated). `daysLeft` is a number and some keys may be\n * null, as each schema says. A template\n * computes nothing and holds no Founder Circle URL of its own. Transactional\n * mail: no unsubscribe link, and nothing a member's settings could switch off.\n *\n * @module domains/billing/emails\n */\n\nimport { z } from 'zod';\n\nconst text = z.string().trim().min(1);\nconst url = z.url();\n\n/** The receipt, for a purchase or an auto-renewal's first charge. Links to the invoice. */\nexport const fcPaymentReceivedEmailSchema = z.object({\n firstName: text,\n /** The server's title: \"Premium, 1 month\", \"Membership\". */\n title: text,\n amountText: text,\n /** Null for a TEST invoice (dev, test keys). */\n invoiceNumber: text.nullable(),\n paidOn: text,\n /** The last day a refund may be asked for, the bare date (\"3 Dec 2026\"); the template words it. */\n refundableUntil: text,\n /** `${APP_BASE_URL}/me/payments`. */\n paymentsUrl: url,\n});\n\n/** A refund went through. */\nexport const fcRefundProcessedEmailSchema = z.object({\n firstName: text,\n title: text,\n amountText: text,\n creditNoteNumber: text.nullable(),\n paymentsUrl: url,\n});\n\n/** A PREPAID plan ends in 7 days, then in 1 day: renew with a tap. */\nexport const fcPlanEndsSoonEmailSchema = z.object({\n firstName: text,\n planName: text,\n endsOn: text,\n daysLeft: z.number().int().positive(),\n plansUrl: url,\n});\n\n/** A YEARLY auto-renewal charges in 7 days; turn it off before then to stop it. */\nexport const fcPlanRenewsSoonEmailSchema = z.object({\n firstName: text,\n planName: text,\n amountText: text,\n renewsOn: text,\n plansUrl: url,\n});\n\n/** An auto-renewal charged: the plan runs on. Links to the invoice. */\nexport const fcRenewalDoneEmailSchema = z.object({\n firstName: text,\n planName: text,\n amountText: text,\n invoiceNumber: text.nullable(),\n /** When the plan's time now runs to. */\n runsUntil: text,\n /** The next charge; null when the auto-renewal has no more (its last cycle). */\n nextChargeOn: text.nullable(),\n paymentsUrl: url,\n});\n\n/** An auto-renewal's charge failed; the gateway retries for 3 days. Update the method. */\nexport const fcRenewalFailedEmailSchema = z.object({\n firstName: text,\n planName: text,\n amountText: text,\n /** When the time already paid runs out, if no retry succeeds. */\n endsOn: text,\n plansUrl: url,\n});\n\n/**\n * Why an auto-renewal stopped (the email's wording):\n *\n * payment_failed every retry failed\n * refunded a refund of its charge ended it\n * membership_ended the membership was refunded or withdrawn\n * turned_off the member turned it off (a confirmation)\n */\nexport const AUTO_RENEW_STOP_REASON_VALUES = [\n 'payment_failed',\n 'refunded',\n 'membership_ended',\n 'turned_off',\n] as const;\nexport const autoRenewStopReasonSchema = z.enum(AUTO_RENEW_STOP_REASON_VALUES);\nexport type AutoRenewStopReason = z.infer<typeof autoRenewStopReasonSchema>;\n\n/** An auto-renewal stopped; the time already paid runs to `endsOn`. */\nexport const fcAutoRenewStoppedEmailSchema = z.object({\n firstName: text,\n planName: text,\n /** Null when no paid time is left (a refund took it). */\n endsOn: text.nullable(),\n reason: autoRenewStopReasonSchema,\n plansUrl: url,\n});\n\n/** Every FC payment email, by its async-service template name. Exhaustive by type. */\nexport const FC_EMAIL_DATA_SCHEMAS = {\n 'fc-payment-received': fcPaymentReceivedEmailSchema,\n 'fc-refund-processed': fcRefundProcessedEmailSchema,\n 'fc-plan-ends-soon': fcPlanEndsSoonEmailSchema,\n 'fc-plan-renews-soon': fcPlanRenewsSoonEmailSchema,\n 'fc-renewal-done': fcRenewalDoneEmailSchema,\n 'fc-renewal-failed': fcRenewalFailedEmailSchema,\n 'fc-auto-renew-stopped': fcAutoRenewStoppedEmailSchema,\n} as const;\n\nexport type FcEmailTemplate = keyof typeof FC_EMAIL_DATA_SCHEMAS;\nexport const FC_EMAIL_TEMPLATE_VALUES = Object.keys(FC_EMAIL_DATA_SCHEMAS) as FcEmailTemplate[];\n\n/** The data a template takes, by its name. */\nexport type FcEmailData<T extends FcEmailTemplate> = z.infer<(typeof FC_EMAIL_DATA_SCHEMAS)[T]>;\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a payment was made (payments v2, hary 2026-11-25; docs/payments-v2-plan.md R14 in
|
|
3
|
+
* founder-circle-backend).
|
|
4
|
+
*
|
|
5
|
+
* A SNAPSHOT taken from the gateway's payment when it is captured, for the member's payment
|
|
6
|
+
* history, their auto-renewal and the staff screen. DPDP: never a full card number, never a
|
|
7
|
+
* whole UPI id, never a phone or email. Of a UPI id only the part after `@` is kept (the
|
|
8
|
+
* app's handle, e.g. `okaxis`), never the person's part before it.
|
|
9
|
+
*
|
|
10
|
+
* A leaf module (zod only), so membership and billing both import it without a cycle.
|
|
11
|
+
*
|
|
12
|
+
* @module domains/billing/payment-method
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* Razorpay's `payment.method`, as it names them. ⚠ Stored: append only. Anything Razorpay
|
|
17
|
+
* adds later is stored as `other` until it is named here.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PAYMENT_METHOD_VALUES: readonly ["card", "upi", "netbanking", "wallet", "emi", "paylater", "emandate", "other"];
|
|
20
|
+
export declare const paymentMethodSchema: z.ZodEnum<{
|
|
21
|
+
other: "other";
|
|
22
|
+
card: "card";
|
|
23
|
+
upi: "upi";
|
|
24
|
+
netbanking: "netbanking";
|
|
25
|
+
wallet: "wallet";
|
|
26
|
+
emi: "emi";
|
|
27
|
+
paylater: "paylater";
|
|
28
|
+
emandate: "emandate";
|
|
29
|
+
}>;
|
|
30
|
+
export type PaymentMethod = z.infer<typeof paymentMethodSchema>;
|
|
31
|
+
/** The longest a snapshot's free-text part may be (a bank's or wallet's name). */
|
|
32
|
+
export declare const PAYMENT_METHOD_TEXT_MAX = 60;
|
|
33
|
+
/**
|
|
34
|
+
* One payment's method. Only the fields that belong to its `method` are set; the rest are
|
|
35
|
+
* null:
|
|
36
|
+
*
|
|
37
|
+
* card cardNetwork (Visa, Mastercard, RuPay...), cardType (credit, debit,
|
|
38
|
+
* prepaid), cardLast4, bank (the issuer, when the gateway says)
|
|
39
|
+
* upi upiHandle (after the @), bank (when the gateway says)
|
|
40
|
+
* netbanking bank
|
|
41
|
+
* wallet wallet
|
|
42
|
+
* emandate bank
|
|
43
|
+
*/
|
|
44
|
+
export declare const paymentMethodSnapshotSchema: z.ZodObject<{
|
|
45
|
+
method: z.ZodEnum<{
|
|
46
|
+
other: "other";
|
|
47
|
+
card: "card";
|
|
48
|
+
upi: "upi";
|
|
49
|
+
netbanking: "netbanking";
|
|
50
|
+
wallet: "wallet";
|
|
51
|
+
emi: "emi";
|
|
52
|
+
paylater: "paylater";
|
|
53
|
+
emandate: "emandate";
|
|
54
|
+
}>;
|
|
55
|
+
cardNetwork: z.ZodNullable<z.ZodString>;
|
|
56
|
+
cardType: z.ZodNullable<z.ZodString>;
|
|
57
|
+
cardLast4: z.ZodNullable<z.ZodString>;
|
|
58
|
+
bank: z.ZodNullable<z.ZodString>;
|
|
59
|
+
wallet: z.ZodNullable<z.ZodString>;
|
|
60
|
+
upiHandle: z.ZodNullable<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type PaymentMethodSnapshot = z.infer<typeof paymentMethodSnapshotSchema>;
|
|
63
|
+
//# sourceMappingURL=payment-method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-method.d.ts","sourceRoot":"","sources":["../../../src/domains/billing/payment-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,0FASxB,CAAC;AACX,eAAO,MAAM,mBAAmB;;;;;;;;;EAAgC,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAI1C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBAYtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a payment was made (payments v2, hary 2026-11-25; docs/payments-v2-plan.md R14 in
|
|
3
|
+
* founder-circle-backend).
|
|
4
|
+
*
|
|
5
|
+
* A SNAPSHOT taken from the gateway's payment when it is captured, for the member's payment
|
|
6
|
+
* history, their auto-renewal and the staff screen. DPDP: never a full card number, never a
|
|
7
|
+
* whole UPI id, never a phone or email. Of a UPI id only the part after `@` is kept (the
|
|
8
|
+
* app's handle, e.g. `okaxis`), never the person's part before it.
|
|
9
|
+
*
|
|
10
|
+
* A leaf module (zod only), so membership and billing both import it without a cycle.
|
|
11
|
+
*
|
|
12
|
+
* @module domains/billing/payment-method
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* Razorpay's `payment.method`, as it names them. ⚠ Stored: append only. Anything Razorpay
|
|
17
|
+
* adds later is stored as `other` until it is named here.
|
|
18
|
+
*/
|
|
19
|
+
export const PAYMENT_METHOD_VALUES = [
|
|
20
|
+
'card',
|
|
21
|
+
'upi',
|
|
22
|
+
'netbanking',
|
|
23
|
+
'wallet',
|
|
24
|
+
'emi',
|
|
25
|
+
'paylater',
|
|
26
|
+
'emandate',
|
|
27
|
+
'other',
|
|
28
|
+
];
|
|
29
|
+
export const paymentMethodSchema = z.enum(PAYMENT_METHOD_VALUES);
|
|
30
|
+
/** The longest a snapshot's free-text part may be (a bank's or wallet's name). */
|
|
31
|
+
export const PAYMENT_METHOD_TEXT_MAX = 60;
|
|
32
|
+
const shortText = z.string().trim().min(1).max(PAYMENT_METHOD_TEXT_MAX);
|
|
33
|
+
/**
|
|
34
|
+
* One payment's method. Only the fields that belong to its `method` are set; the rest are
|
|
35
|
+
* null:
|
|
36
|
+
*
|
|
37
|
+
* card cardNetwork (Visa, Mastercard, RuPay...), cardType (credit, debit,
|
|
38
|
+
* prepaid), cardLast4, bank (the issuer, when the gateway says)
|
|
39
|
+
* upi upiHandle (after the @), bank (when the gateway says)
|
|
40
|
+
* netbanking bank
|
|
41
|
+
* wallet wallet
|
|
42
|
+
* emandate bank
|
|
43
|
+
*/
|
|
44
|
+
export const paymentMethodSnapshotSchema = z.object({
|
|
45
|
+
method: paymentMethodSchema,
|
|
46
|
+
cardNetwork: shortText.nullable(),
|
|
47
|
+
cardType: shortText.nullable(),
|
|
48
|
+
cardLast4: z
|
|
49
|
+
.string()
|
|
50
|
+
.regex(/^\d{4}$/)
|
|
51
|
+
.nullable(),
|
|
52
|
+
bank: shortText.nullable(),
|
|
53
|
+
wallet: shortText.nullable(),
|
|
54
|
+
/** The UPI app's handle, the part of the UPI id after `@`; never the part before it. */
|
|
55
|
+
upiHandle: shortText.nullable(),
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=payment-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-method.js","sourceRoot":"","sources":["../../../src/domains/billing/payment-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM;IACN,KAAK;IACL,YAAY;IACZ,QAAQ;IACR,KAAK;IACL,UAAU;IACV,UAAU;IACV,OAAO;CACC,CAAC;AACX,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAGjE,kFAAkF;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,mBAAmB;IAC3B,WAAW,EAAE,SAAS,CAAC,QAAQ,EAAE;IACjC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE;IAC9B,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,KAAK,CAAC,SAAS,CAAC;SAChB,QAAQ,EAAE;IACb,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE;IAC1B,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE;IAC5B,wFAAwF;IACxF,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC","sourcesContent":["/**\n * How a payment was made (payments v2, hary 2026-11-25; docs/payments-v2-plan.md R14 in\n * founder-circle-backend).\n *\n * A SNAPSHOT taken from the gateway's payment when it is captured, for the member's payment\n * history, their auto-renewal and the staff screen. DPDP: never a full card number, never a\n * whole UPI id, never a phone or email. Of a UPI id only the part after `@` is kept (the\n * app's handle, e.g. `okaxis`), never the person's part before it.\n *\n * A leaf module (zod only), so membership and billing both import it without a cycle.\n *\n * @module domains/billing/payment-method\n */\n\nimport { z } from 'zod';\n\n/**\n * Razorpay's `payment.method`, as it names them. ⚠ Stored: append only. Anything Razorpay\n * adds later is stored as `other` until it is named here.\n */\nexport const PAYMENT_METHOD_VALUES = [\n 'card',\n 'upi',\n 'netbanking',\n 'wallet',\n 'emi',\n 'paylater',\n 'emandate',\n 'other',\n] as const;\nexport const paymentMethodSchema = z.enum(PAYMENT_METHOD_VALUES);\nexport type PaymentMethod = z.infer<typeof paymentMethodSchema>;\n\n/** The longest a snapshot's free-text part may be (a bank's or wallet's name). */\nexport const PAYMENT_METHOD_TEXT_MAX = 60;\n\nconst shortText = z.string().trim().min(1).max(PAYMENT_METHOD_TEXT_MAX);\n\n/**\n * One payment's method. Only the fields that belong to its `method` are set; the rest are\n * null:\n *\n * card cardNetwork (Visa, Mastercard, RuPay...), cardType (credit, debit,\n * prepaid), cardLast4, bank (the issuer, when the gateway says)\n * upi upiHandle (after the @), bank (when the gateway says)\n * netbanking bank\n * wallet wallet\n * emandate bank\n */\nexport const paymentMethodSnapshotSchema = z.object({\n method: paymentMethodSchema,\n cardNetwork: shortText.nullable(),\n cardType: shortText.nullable(),\n cardLast4: z\n .string()\n .regex(/^\\d{4}$/)\n .nullable(),\n bank: shortText.nullable(),\n wallet: shortText.nullable(),\n /** The UPI app's handle, the part of the UPI id after `@`; never the part before it. */\n upiHandle: shortText.nullable(),\n});\nexport type PaymentMethodSnapshot = z.infer<typeof paymentMethodSnapshotSchema>;\n"]}
|
|
@@ -202,8 +202,90 @@ export declare const planCatalogSchema: z.ZodObject<{
|
|
|
202
202
|
refundWindowDays: z.ZodNumber;
|
|
203
203
|
paymentsEnabled: z.ZodBoolean;
|
|
204
204
|
paymentsLiveAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
205
|
+
autoRenewEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
205
206
|
}, z.core.$strip>;
|
|
206
207
|
export type PlanCatalog = z.infer<typeof planCatalogSchema>;
|
|
208
|
+
/**
|
|
209
|
+
* Where an auto-renewal stands: Razorpay's subscription states, as it names
|
|
210
|
+
* them. ⚠ Stored: append only.
|
|
211
|
+
*
|
|
212
|
+
* created made, waiting for the member to authorise it at Checkout
|
|
213
|
+
* authenticated authorised; its first charge is on a later date (it starts
|
|
214
|
+
* when the time already held ends)
|
|
215
|
+
* active charging each period
|
|
216
|
+
* pending a charge failed; Razorpay is retrying (T+1 to T+3 days)
|
|
217
|
+
* halted every retry failed: no more charges (auto-renew is off)
|
|
218
|
+
* cancelled turned off (at the end of the period, or at once after a
|
|
219
|
+
* refund), or replaced
|
|
220
|
+
* completed its cycles ran out
|
|
221
|
+
* expired never authorised in time
|
|
222
|
+
* paused paused at the gateway (Founder Circle never pauses one)
|
|
223
|
+
*/
|
|
224
|
+
export declare const AUTO_RENEWAL_STATUS_VALUES: readonly ["created", "authenticated", "active", "pending", "halted", "cancelled", "completed", "expired", "paused"];
|
|
225
|
+
export declare const autoRenewalStatusSchema: z.ZodEnum<{
|
|
226
|
+
active: "active";
|
|
227
|
+
created: "created";
|
|
228
|
+
authenticated: "authenticated";
|
|
229
|
+
pending: "pending";
|
|
230
|
+
halted: "halted";
|
|
231
|
+
cancelled: "cancelled";
|
|
232
|
+
completed: "completed";
|
|
233
|
+
expired: "expired";
|
|
234
|
+
paused: "paused";
|
|
235
|
+
}>;
|
|
236
|
+
export type AutoRenewalStatus = z.infer<typeof autoRenewalStatusSchema>;
|
|
237
|
+
/** The statuses in which an auto-renewal will still charge (or is about to). */
|
|
238
|
+
export declare const AUTO_RENEWAL_RUNNING_VALUES: readonly ["authenticated", "active", "pending"];
|
|
239
|
+
/**
|
|
240
|
+
* A member's auto-renewal, as `GET /me/membership` shows it: at most one, the
|
|
241
|
+
* running one (null when none runs).
|
|
242
|
+
*/
|
|
243
|
+
export declare const autoRenewalSchema: z.ZodObject<{
|
|
244
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
245
|
+
status: z.ZodEnum<{
|
|
246
|
+
active: "active";
|
|
247
|
+
created: "created";
|
|
248
|
+
authenticated: "authenticated";
|
|
249
|
+
pending: "pending";
|
|
250
|
+
halted: "halted";
|
|
251
|
+
cancelled: "cancelled";
|
|
252
|
+
completed: "completed";
|
|
253
|
+
expired: "expired";
|
|
254
|
+
paused: "paused";
|
|
255
|
+
}>;
|
|
256
|
+
tier: z.ZodEnum<{
|
|
257
|
+
premium: "premium";
|
|
258
|
+
business: "business";
|
|
259
|
+
}>;
|
|
260
|
+
period: z.ZodEnum<{
|
|
261
|
+
month: "month";
|
|
262
|
+
year: "year";
|
|
263
|
+
}>;
|
|
264
|
+
amount: z.ZodNumber;
|
|
265
|
+
nextChargeAt: z.ZodNullable<z.ZodISODateTime>;
|
|
266
|
+
cancelAtCycleEnd: z.ZodBoolean;
|
|
267
|
+
method: z.ZodNullable<z.ZodObject<{
|
|
268
|
+
method: z.ZodEnum<{
|
|
269
|
+
other: "other";
|
|
270
|
+
card: "card";
|
|
271
|
+
upi: "upi";
|
|
272
|
+
netbanking: "netbanking";
|
|
273
|
+
wallet: "wallet";
|
|
274
|
+
emi: "emi";
|
|
275
|
+
paylater: "paylater";
|
|
276
|
+
emandate: "emandate";
|
|
277
|
+
}>;
|
|
278
|
+
cardNetwork: z.ZodNullable<z.ZodString>;
|
|
279
|
+
cardType: z.ZodNullable<z.ZodString>;
|
|
280
|
+
cardLast4: z.ZodNullable<z.ZodString>;
|
|
281
|
+
bank: z.ZodNullable<z.ZodString>;
|
|
282
|
+
wallet: z.ZodNullable<z.ZodString>;
|
|
283
|
+
upiHandle: z.ZodNullable<z.ZodString>;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
canUpdateMethod: z.ZodBoolean;
|
|
286
|
+
graceUntil: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
287
|
+
}, z.core.$strip>;
|
|
288
|
+
export type AutoRenewal = z.infer<typeof autoRenewalSchema>;
|
|
207
289
|
export declare const membershipSchema: z.ZodObject<{
|
|
208
290
|
kind: z.ZodEnum<{
|
|
209
291
|
founding: "founding";
|
|
@@ -319,6 +401,51 @@ export declare const meMembershipSchema: z.ZodObject<{
|
|
|
319
401
|
legalName: z.ZodOptional<z.ZodString>;
|
|
320
402
|
address: z.ZodOptional<z.ZodString>;
|
|
321
403
|
}, z.core.$strip>>;
|
|
404
|
+
autoRenewal: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
405
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
406
|
+
status: z.ZodEnum<{
|
|
407
|
+
active: "active";
|
|
408
|
+
created: "created";
|
|
409
|
+
authenticated: "authenticated";
|
|
410
|
+
pending: "pending";
|
|
411
|
+
halted: "halted";
|
|
412
|
+
cancelled: "cancelled";
|
|
413
|
+
completed: "completed";
|
|
414
|
+
expired: "expired";
|
|
415
|
+
paused: "paused";
|
|
416
|
+
}>;
|
|
417
|
+
tier: z.ZodEnum<{
|
|
418
|
+
premium: "premium";
|
|
419
|
+
business: "business";
|
|
420
|
+
}>;
|
|
421
|
+
period: z.ZodEnum<{
|
|
422
|
+
month: "month";
|
|
423
|
+
year: "year";
|
|
424
|
+
}>;
|
|
425
|
+
amount: z.ZodNumber;
|
|
426
|
+
nextChargeAt: z.ZodNullable<z.ZodISODateTime>;
|
|
427
|
+
cancelAtCycleEnd: z.ZodBoolean;
|
|
428
|
+
method: z.ZodNullable<z.ZodObject<{
|
|
429
|
+
method: z.ZodEnum<{
|
|
430
|
+
other: "other";
|
|
431
|
+
card: "card";
|
|
432
|
+
upi: "upi";
|
|
433
|
+
netbanking: "netbanking";
|
|
434
|
+
wallet: "wallet";
|
|
435
|
+
emi: "emi";
|
|
436
|
+
paylater: "paylater";
|
|
437
|
+
emandate: "emandate";
|
|
438
|
+
}>;
|
|
439
|
+
cardNetwork: z.ZodNullable<z.ZodString>;
|
|
440
|
+
cardType: z.ZodNullable<z.ZodString>;
|
|
441
|
+
cardLast4: z.ZodNullable<z.ZodString>;
|
|
442
|
+
bank: z.ZodNullable<z.ZodString>;
|
|
443
|
+
wallet: z.ZodNullable<z.ZodString>;
|
|
444
|
+
upiHandle: z.ZodNullable<z.ZodString>;
|
|
445
|
+
}, z.core.$strip>>;
|
|
446
|
+
canUpdateMethod: z.ZodBoolean;
|
|
447
|
+
graceUntil: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
448
|
+
}, z.core.$strip>>>;
|
|
322
449
|
}, z.core.$strip>;
|
|
323
450
|
export type MeMembership = z.infer<typeof meMembershipSchema>;
|
|
324
451
|
//# sourceMappingURL=membership.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../../../src/domains/membership/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../../../src/domains/membership/membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,kEAMzB,CAAC;AACX,eAAO,MAAM,oBAAoB;;;;;;EAAiC,CAAC;AACnE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,8B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
|
|
25
|
+
import { objectIdSchema } from '../../core/common.js';
|
|
25
26
|
import { DAY_MS, INDIA_UTC_OFFSET_MS } from '../../core/limits.js';
|
|
26
27
|
import { billingDetailsSchema } from '../billing/gst.js';
|
|
28
|
+
import { paymentMethodSnapshotSchema } from '../billing/payment-method.js';
|
|
27
29
|
/**
|
|
28
30
|
* How someone came to hold a membership. ⚠ Stored: append only.
|
|
29
31
|
*
|
|
@@ -226,6 +228,85 @@ export const planCatalogSchema = z.object({
|
|
|
226
228
|
* null when an older server leaves it out, so a client can ship first.
|
|
227
229
|
*/
|
|
228
230
|
paymentsLiveAt: z.iso.datetime().nullable().default(null),
|
|
231
|
+
/**
|
|
232
|
+
* Whether a plan may renew AUTOMATICALLY here (0.31.0, payments v2). The
|
|
233
|
+
* server's two keys: its `SUBSCRIPTIONS_ENABLED` is set AND its gateway plans
|
|
234
|
+
* resolve, and payments are live. While false a client offers no
|
|
235
|
+
* "Renew automatically" switch: every plan is prepaid. Defaults to false
|
|
236
|
+
* when an older server leaves it out.
|
|
237
|
+
*/
|
|
238
|
+
autoRenewEnabled: z.boolean().default(false),
|
|
239
|
+
});
|
|
240
|
+
// ─── Auto-renewal (0.31.0, payments v2) ──────────────────────────────────────
|
|
241
|
+
//
|
|
242
|
+
// The user, 2026-11-25: plans RENEW AUTOMATICALLY BY DEFAULT, and the member can
|
|
243
|
+
// turn it off (founder-circle-backend docs/payments-v2-plan.md, section 3a). An
|
|
244
|
+
// auto-renewal is a Razorpay subscription for one tier and period: each charge
|
|
245
|
+
// it makes is an ORDER that buys one period, appended to the blocks exactly as
|
|
246
|
+
// a manual purchase is (same invoice, same 7-day refund). It adds time only
|
|
247
|
+
// when a charge lands, so a failed charge takes nothing away: the plan ends
|
|
248
|
+
// when its time runs out, as a prepaid one does.
|
|
249
|
+
/**
|
|
250
|
+
* Where an auto-renewal stands: Razorpay's subscription states, as it names
|
|
251
|
+
* them. ⚠ Stored: append only.
|
|
252
|
+
*
|
|
253
|
+
* created made, waiting for the member to authorise it at Checkout
|
|
254
|
+
* authenticated authorised; its first charge is on a later date (it starts
|
|
255
|
+
* when the time already held ends)
|
|
256
|
+
* active charging each period
|
|
257
|
+
* pending a charge failed; Razorpay is retrying (T+1 to T+3 days)
|
|
258
|
+
* halted every retry failed: no more charges (auto-renew is off)
|
|
259
|
+
* cancelled turned off (at the end of the period, or at once after a
|
|
260
|
+
* refund), or replaced
|
|
261
|
+
* completed its cycles ran out
|
|
262
|
+
* expired never authorised in time
|
|
263
|
+
* paused paused at the gateway (Founder Circle never pauses one)
|
|
264
|
+
*/
|
|
265
|
+
export const AUTO_RENEWAL_STATUS_VALUES = [
|
|
266
|
+
'created',
|
|
267
|
+
'authenticated',
|
|
268
|
+
'active',
|
|
269
|
+
'pending',
|
|
270
|
+
'halted',
|
|
271
|
+
'cancelled',
|
|
272
|
+
'completed',
|
|
273
|
+
'expired',
|
|
274
|
+
'paused',
|
|
275
|
+
];
|
|
276
|
+
export const autoRenewalStatusSchema = z.enum(AUTO_RENEWAL_STATUS_VALUES);
|
|
277
|
+
/** The statuses in which an auto-renewal will still charge (or is about to). */
|
|
278
|
+
export const AUTO_RENEWAL_RUNNING_VALUES = [
|
|
279
|
+
'authenticated',
|
|
280
|
+
'active',
|
|
281
|
+
'pending',
|
|
282
|
+
];
|
|
283
|
+
/**
|
|
284
|
+
* A member's auto-renewal, as `GET /me/membership` shows it: at most one, the
|
|
285
|
+
* running one (null when none runs).
|
|
286
|
+
*/
|
|
287
|
+
export const autoRenewalSchema = z.object({
|
|
288
|
+
id: objectIdSchema,
|
|
289
|
+
status: autoRenewalStatusSchema,
|
|
290
|
+
tier: planTierSchema,
|
|
291
|
+
period: planPeriodSchema,
|
|
292
|
+
/** What each charge takes, GST included: the price it was started at, kept. */
|
|
293
|
+
amount: paiseSchema,
|
|
294
|
+
/** When the next charge is due; null when none will come (turned off, halted). */
|
|
295
|
+
nextChargeAt: z.iso.datetime().nullable(),
|
|
296
|
+
/** Turned off: no more charges; the time already paid stays until it ends. */
|
|
297
|
+
cancelAtCycleEnd: z.boolean(),
|
|
298
|
+
/** How it pays, as last charged or authorised; null before the gateway says. */
|
|
299
|
+
method: paymentMethodSnapshotSchema.nullable(),
|
|
300
|
+
/** A failed charge (`pending`) can be fixed by updating the method. */
|
|
301
|
+
canUpdateMethod: z.boolean(),
|
|
302
|
+
/**
|
|
303
|
+
* In the renewal grace (`RENEWAL_GRACE_DAYS`): the time held has ended and
|
|
304
|
+
* the charge is awaited, so the tier stays in force until this instant.
|
|
305
|
+
* Null outside it. A client says "your renewal is being processed; your
|
|
306
|
+
* plan stays active until <date>" (or, with `status: 'pending'`, that the
|
|
307
|
+
* charge failed and is being retried).
|
|
308
|
+
*/
|
|
309
|
+
graceUntil: z.iso.datetime().nullable().default(null),
|
|
229
310
|
});
|
|
230
311
|
// ─── GET /me/membership ──────────────────────────────────────────────────────
|
|
231
312
|
export const membershipSchema = z.object({
|
|
@@ -275,5 +356,11 @@ export const meMembershipSchema = z.object({
|
|
|
275
356
|
}),
|
|
276
357
|
/** The billing details they last used, to prefill the next checkout; null before the first. */
|
|
277
358
|
billing: billingDetailsSchema.nullable(),
|
|
359
|
+
/**
|
|
360
|
+
* The auto-renewal that runs (0.31.0): authorised, charging, or retrying a
|
|
361
|
+
* failed charge. Null when none does. Defaults to null when an older server
|
|
362
|
+
* leaves it out.
|
|
363
|
+
*/
|
|
364
|
+
autoRenewal: autoRenewalSchema.nullable().default(null),
|
|
278
365
|
});
|
|
279
366
|
//# sourceMappingURL=membership.js.map
|