@pulgueta/epayco-convex 0.1.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/LICENSE +201 -0
- package/README.md +945 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/index.d.ts +222 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +355 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +78 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +580 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/banks.d.ts +14 -0
- package/dist/component/banks.d.ts.map +1 -0
- package/dist/component/banks.js +37 -0
- package/dist/component/banks.js.map +1 -0
- package/dist/component/cashApi.d.ts +59 -0
- package/dist/component/cashApi.d.ts.map +1 -0
- package/dist/component/cashApi.js +88 -0
- package/dist/component/cashApi.js.map +1 -0
- package/dist/component/chargesApi.d.ts +64 -0
- package/dist/component/chargesApi.d.ts.map +1 -0
- package/dist/component/chargesApi.js +106 -0
- package/dist/component/chargesApi.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +6 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/customers.d.ts +67 -0
- package/dist/component/customers.d.ts.map +1 -0
- package/dist/component/customers.js +103 -0
- package/dist/component/customers.js.map +1 -0
- package/dist/component/customersApi.d.ts +99 -0
- package/dist/component/customersApi.d.ts.map +1 -0
- package/dist/component/customersApi.js +176 -0
- package/dist/component/customersApi.js.map +1 -0
- package/dist/component/daviplataApi.d.ts +43 -0
- package/dist/component/daviplataApi.d.ts.map +1 -0
- package/dist/component/daviplataApi.js +103 -0
- package/dist/component/daviplataApi.js.map +1 -0
- package/dist/component/epaycoClient.d.ts +84 -0
- package/dist/component/epaycoClient.d.ts.map +1 -0
- package/dist/component/epaycoClient.js +422 -0
- package/dist/component/epaycoClient.js.map +1 -0
- package/dist/component/payloads.d.ts +34 -0
- package/dist/component/payloads.d.ts.map +1 -0
- package/dist/component/payloads.js +45 -0
- package/dist/component/payloads.js.map +1 -0
- package/dist/component/plans.d.ts +47 -0
- package/dist/component/plans.d.ts.map +1 -0
- package/dist/component/plans.js +83 -0
- package/dist/component/plans.js.map +1 -0
- package/dist/component/plansApi.d.ts +64 -0
- package/dist/component/plansApi.d.ts.map +1 -0
- package/dist/component/plansApi.js +121 -0
- package/dist/component/plansApi.js.map +1 -0
- package/dist/component/pseApi.d.ts +68 -0
- package/dist/component/pseApi.d.ts.map +1 -0
- package/dist/component/pseApi.js +113 -0
- package/dist/component/pseApi.js.map +1 -0
- package/dist/component/rateLimits.d.ts +69 -0
- package/dist/component/rateLimits.d.ts.map +1 -0
- package/dist/component/rateLimits.js +67 -0
- package/dist/component/rateLimits.js.map +1 -0
- package/dist/component/safetypayApi.d.ts +35 -0
- package/dist/component/safetypayApi.d.ts.map +1 -0
- package/dist/component/safetypayApi.js +68 -0
- package/dist/component/safetypayApi.js.map +1 -0
- package/dist/component/schema.d.ts +200 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +104 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/signature.d.ts +11 -0
- package/dist/component/signature.d.ts.map +1 -0
- package/dist/component/signature.js +28 -0
- package/dist/component/signature.js.map +1 -0
- package/dist/component/status.d.ts +12 -0
- package/dist/component/status.d.ts.map +1 -0
- package/dist/component/status.js +55 -0
- package/dist/component/status.js.map +1 -0
- package/dist/component/subscriptions.d.ts +69 -0
- package/dist/component/subscriptions.d.ts.map +1 -0
- package/dist/component/subscriptions.js +114 -0
- package/dist/component/subscriptions.js.map +1 -0
- package/dist/component/subscriptionsApi.d.ts +62 -0
- package/dist/component/subscriptionsApi.d.ts.map +1 -0
- package/dist/component/subscriptionsApi.js +147 -0
- package/dist/component/subscriptionsApi.js.map +1 -0
- package/dist/component/tokens.d.ts +31 -0
- package/dist/component/tokens.d.ts.map +1 -0
- package/dist/component/tokens.js +79 -0
- package/dist/component/tokens.js.map +1 -0
- package/dist/component/tokensApi.d.ts +18 -0
- package/dist/component/tokensApi.d.ts.map +1 -0
- package/dist/component/tokensApi.js +53 -0
- package/dist/component/tokensApi.js.map +1 -0
- package/dist/component/transactions.d.ts +103 -0
- package/dist/component/transactions.d.ts.map +1 -0
- package/dist/component/transactions.js +177 -0
- package/dist/component/transactions.js.map +1 -0
- package/dist/component/validators.d.ts +571 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +203 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/component/webhooks.d.ts +55 -0
- package/dist/component/webhooks.d.ts.map +1 -0
- package/dist/component/webhooks.js +172 -0
- package/dist/component/webhooks.js.map +1 -0
- package/dist/react/index.d.ts +16 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +43 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +106 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/index.test.ts +66 -0
- package/src/client/index.ts +633 -0
- package/src/client/setup.test.ts +26 -0
- package/src/component/_generated/api.ts +94 -0
- package/src/component/_generated/component.ts +809 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/banks.ts +41 -0
- package/src/component/cashApi.ts +100 -0
- package/src/component/chargesApi.ts +119 -0
- package/src/component/convex.config.ts +7 -0
- package/src/component/customers.test.ts +122 -0
- package/src/component/customers.ts +116 -0
- package/src/component/customersApi.ts +206 -0
- package/src/component/daviplataApi.ts +119 -0
- package/src/component/epaycoApi.test.ts +110 -0
- package/src/component/epaycoClient.ts +578 -0
- package/src/component/payloads.ts +67 -0
- package/src/component/plans.test.ts +129 -0
- package/src/component/plans.ts +86 -0
- package/src/component/plansApi.ts +135 -0
- package/src/component/pseApi.ts +125 -0
- package/src/component/rateLimits.ts +67 -0
- package/src/component/safetypayApi.ts +78 -0
- package/src/component/schema.ts +124 -0
- package/src/component/setup.test.helper.ts +10 -0
- package/src/component/setup.test.ts +22 -0
- package/src/component/signature.ts +38 -0
- package/src/component/status.ts +71 -0
- package/src/component/subscriptions.test.ts +117 -0
- package/src/component/subscriptions.ts +128 -0
- package/src/component/subscriptionsApi.ts +172 -0
- package/src/component/tokens.ts +89 -0
- package/src/component/tokensApi.ts +63 -0
- package/src/component/transactions.test.ts +227 -0
- package/src/component/transactions.ts +200 -0
- package/src/component/validators.ts +245 -0
- package/src/component/webhooks.test.ts +137 -0
- package/src/component/webhooks.ts +229 -0
- package/src/react/index.ts +71 -0
- package/src/test.ts +13 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { RateLimiter } from "@convex-dev/rate-limiter";
|
|
2
|
+
export declare const rateLimiter: RateLimiter<{
|
|
3
|
+
createCustomer: {
|
|
4
|
+
kind: "token bucket";
|
|
5
|
+
rate: number;
|
|
6
|
+
period: number;
|
|
7
|
+
capacity: number;
|
|
8
|
+
};
|
|
9
|
+
createToken: {
|
|
10
|
+
kind: "token bucket";
|
|
11
|
+
rate: number;
|
|
12
|
+
period: number;
|
|
13
|
+
capacity: number;
|
|
14
|
+
};
|
|
15
|
+
createCharge: {
|
|
16
|
+
kind: "token bucket";
|
|
17
|
+
rate: number;
|
|
18
|
+
period: number;
|
|
19
|
+
capacity: number;
|
|
20
|
+
};
|
|
21
|
+
createSubscription: {
|
|
22
|
+
kind: "token bucket";
|
|
23
|
+
rate: number;
|
|
24
|
+
period: number;
|
|
25
|
+
capacity: number;
|
|
26
|
+
};
|
|
27
|
+
createPseTransaction: {
|
|
28
|
+
kind: "token bucket";
|
|
29
|
+
rate: number;
|
|
30
|
+
period: number;
|
|
31
|
+
capacity: number;
|
|
32
|
+
};
|
|
33
|
+
createCashPayment: {
|
|
34
|
+
kind: "token bucket";
|
|
35
|
+
rate: number;
|
|
36
|
+
period: number;
|
|
37
|
+
capacity: number;
|
|
38
|
+
};
|
|
39
|
+
createDaviplataPayment: {
|
|
40
|
+
kind: "token bucket";
|
|
41
|
+
rate: number;
|
|
42
|
+
period: number;
|
|
43
|
+
capacity: number;
|
|
44
|
+
};
|
|
45
|
+
confirmDaviplataPayment: {
|
|
46
|
+
kind: "token bucket";
|
|
47
|
+
rate: number;
|
|
48
|
+
period: number;
|
|
49
|
+
capacity: number;
|
|
50
|
+
};
|
|
51
|
+
createSafetyPayPayment: {
|
|
52
|
+
kind: "token bucket";
|
|
53
|
+
rate: number;
|
|
54
|
+
period: number;
|
|
55
|
+
capacity: number;
|
|
56
|
+
};
|
|
57
|
+
chargeSubscription: {
|
|
58
|
+
kind: "token bucket";
|
|
59
|
+
rate: number;
|
|
60
|
+
period: number;
|
|
61
|
+
capacity: number;
|
|
62
|
+
};
|
|
63
|
+
webhookProcessing: {
|
|
64
|
+
kind: "fixed window";
|
|
65
|
+
rate: number;
|
|
66
|
+
period: number;
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
//# sourceMappingURL=rateLimits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimits.d.ts","sourceRoot":"","sources":["../../src/component/rateLimits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAU,MAAM,0BAA0B,CAAC;AAG/D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DtB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { RateLimiter, MINUTE } from "@convex-dev/rate-limiter";
|
|
2
|
+
import { components } from "./_generated/api.js";
|
|
3
|
+
export const rateLimiter = new RateLimiter(components.rateLimiter, {
|
|
4
|
+
createCustomer: {
|
|
5
|
+
kind: "token bucket",
|
|
6
|
+
rate: 5,
|
|
7
|
+
period: MINUTE,
|
|
8
|
+
capacity: 3,
|
|
9
|
+
},
|
|
10
|
+
createToken: {
|
|
11
|
+
kind: "token bucket",
|
|
12
|
+
rate: 10,
|
|
13
|
+
period: MINUTE,
|
|
14
|
+
capacity: 5,
|
|
15
|
+
},
|
|
16
|
+
createCharge: {
|
|
17
|
+
kind: "token bucket",
|
|
18
|
+
rate: 10,
|
|
19
|
+
period: MINUTE,
|
|
20
|
+
capacity: 5,
|
|
21
|
+
},
|
|
22
|
+
createSubscription: {
|
|
23
|
+
kind: "token bucket",
|
|
24
|
+
rate: 5,
|
|
25
|
+
period: MINUTE,
|
|
26
|
+
capacity: 3,
|
|
27
|
+
},
|
|
28
|
+
createPseTransaction: {
|
|
29
|
+
kind: "token bucket",
|
|
30
|
+
rate: 10,
|
|
31
|
+
period: MINUTE,
|
|
32
|
+
capacity: 5,
|
|
33
|
+
},
|
|
34
|
+
createCashPayment: {
|
|
35
|
+
kind: "token bucket",
|
|
36
|
+
rate: 10,
|
|
37
|
+
period: MINUTE,
|
|
38
|
+
capacity: 5,
|
|
39
|
+
},
|
|
40
|
+
createDaviplataPayment: {
|
|
41
|
+
kind: "token bucket",
|
|
42
|
+
rate: 10,
|
|
43
|
+
period: MINUTE,
|
|
44
|
+
capacity: 5,
|
|
45
|
+
},
|
|
46
|
+
// Keyed per ref_payco: caps OTP brute-force attempts on a single payment.
|
|
47
|
+
confirmDaviplataPayment: {
|
|
48
|
+
kind: "token bucket",
|
|
49
|
+
rate: 5,
|
|
50
|
+
period: MINUTE,
|
|
51
|
+
capacity: 5,
|
|
52
|
+
},
|
|
53
|
+
createSafetyPayPayment: {
|
|
54
|
+
kind: "token bucket",
|
|
55
|
+
rate: 10,
|
|
56
|
+
period: MINUTE,
|
|
57
|
+
capacity: 5,
|
|
58
|
+
},
|
|
59
|
+
chargeSubscription: {
|
|
60
|
+
kind: "token bucket",
|
|
61
|
+
rate: 5,
|
|
62
|
+
period: MINUTE,
|
|
63
|
+
capacity: 3,
|
|
64
|
+
},
|
|
65
|
+
webhookProcessing: { kind: "fixed window", rate: 200, period: MINUTE },
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=rateLimits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimits.js","sourceRoot":"","sources":["../../src/component/rateLimits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE;IACjE,cAAc,EAAE;QACd,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,WAAW,EAAE;QACX,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,oBAAoB,EAAE;QACpB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,sBAAsB,EAAE;QACtB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,0EAA0E;IAC1E,uBAAuB,EAAE;QACvB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,sBAAsB,EAAE;QACtB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,CAAC;KACZ;IACD,iBAAiB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;CACvE,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Create a SafetyPay transaction (cash or online bank). */
|
|
2
|
+
export declare const createSafetyPayPayment: import("convex/server").RegisteredAction<"public", {
|
|
3
|
+
credentials: {
|
|
4
|
+
testMode?: boolean | undefined;
|
|
5
|
+
lang?: string | undefined;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
privateKey: string;
|
|
8
|
+
};
|
|
9
|
+
userId: string;
|
|
10
|
+
safetypayInfo: {
|
|
11
|
+
address?: string | undefined;
|
|
12
|
+
city?: string | undefined;
|
|
13
|
+
currency?: string | undefined;
|
|
14
|
+
ip?: string | undefined;
|
|
15
|
+
urlConfirmation?: string | undefined;
|
|
16
|
+
methodConfirmation?: string | undefined;
|
|
17
|
+
country?: string | undefined;
|
|
18
|
+
endDate?: string | undefined;
|
|
19
|
+
indCountry?: string | undefined;
|
|
20
|
+
invoice?: string | undefined;
|
|
21
|
+
ico?: number | undefined;
|
|
22
|
+
email: string;
|
|
23
|
+
lastName: string;
|
|
24
|
+
name: string;
|
|
25
|
+
phone: string;
|
|
26
|
+
description: string;
|
|
27
|
+
docNumber: string;
|
|
28
|
+
docType: string;
|
|
29
|
+
cash: "1" | "2";
|
|
30
|
+
value: number;
|
|
31
|
+
tax: number;
|
|
32
|
+
taxBase: number;
|
|
33
|
+
};
|
|
34
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
35
|
+
//# sourceMappingURL=safetypayApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safetypayApi.d.ts","sourceRoot":"","sources":["../../src/component/safetypayApi.ts"],"names":[],"mappings":"AAUA,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAkEjC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { action } from "./_generated/server.js";
|
|
3
|
+
import { internal } from "./_generated/api.js";
|
|
4
|
+
import { epaycoCredentialsValidator, safetypayInfoValidator, } from "./validators.js";
|
|
5
|
+
import { getEpaycoClient, unwrap, dataOf, pick } from "./epaycoClient.js";
|
|
6
|
+
import { rateLimiter } from "./rateLimits.js";
|
|
7
|
+
/** Create a SafetyPay transaction (cash or online bank). */
|
|
8
|
+
export const createSafetyPayPayment = action({
|
|
9
|
+
args: {
|
|
10
|
+
credentials: epaycoCredentialsValidator,
|
|
11
|
+
userId: v.string(),
|
|
12
|
+
safetypayInfo: safetypayInfoValidator,
|
|
13
|
+
},
|
|
14
|
+
returns: v.any(),
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
await rateLimiter.limit(ctx, "createSafetyPayPayment", {
|
|
17
|
+
key: args.userId,
|
|
18
|
+
throws: true,
|
|
19
|
+
});
|
|
20
|
+
const info = args.safetypayInfo;
|
|
21
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
22
|
+
const result = unwrap(await epayco.safetypay.create({
|
|
23
|
+
cash: info.cash,
|
|
24
|
+
...(info.endDate ? { end_date: info.endDate } : {}),
|
|
25
|
+
doc_type: info.docType,
|
|
26
|
+
doc_number: info.docNumber,
|
|
27
|
+
name: info.name,
|
|
28
|
+
last_name: info.lastName,
|
|
29
|
+
email: info.email,
|
|
30
|
+
ind_country: info.indCountry ?? "57",
|
|
31
|
+
phone: info.phone,
|
|
32
|
+
country: info.country ?? "CO",
|
|
33
|
+
...(info.invoice ? { invoice: info.invoice } : {}),
|
|
34
|
+
...(info.city ? { city: info.city } : {}),
|
|
35
|
+
...(info.address ? { address: info.address } : {}),
|
|
36
|
+
...(info.ip ? { ip: info.ip } : {}),
|
|
37
|
+
currency: info.currency ?? "COP",
|
|
38
|
+
description: info.description,
|
|
39
|
+
value: info.value,
|
|
40
|
+
tax: info.tax,
|
|
41
|
+
ico: info.ico ?? 0,
|
|
42
|
+
tax_base: info.taxBase,
|
|
43
|
+
method_confirmation: info.methodConfirmation ?? "",
|
|
44
|
+
...(info.urlConfirmation
|
|
45
|
+
? { url_confirmation: info.urlConfirmation }
|
|
46
|
+
: {}),
|
|
47
|
+
}));
|
|
48
|
+
const data = dataOf(result);
|
|
49
|
+
const refPayco = pick(data, ["ref_payco", "refPayco"]);
|
|
50
|
+
if (refPayco) {
|
|
51
|
+
await ctx.runMutation(internal.transactions.upsertTransaction, {
|
|
52
|
+
userId: args.userId,
|
|
53
|
+
epaycoRef: refPayco,
|
|
54
|
+
epaycoTransactionId: pick(data, ["transactionId", "transaction_id"]),
|
|
55
|
+
paymentMethod: "safetypay",
|
|
56
|
+
status: "pending",
|
|
57
|
+
amount: info.value,
|
|
58
|
+
currency: info.currency ?? "COP",
|
|
59
|
+
description: info.description,
|
|
60
|
+
customerEmail: info.email,
|
|
61
|
+
rawResponse: data,
|
|
62
|
+
lastSyncedAt: Date.now(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=safetypayApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safetypayApi.js","sourceRoot":"","sources":["../../src/component/safetypayApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,IAAI,EAAE;QACJ,WAAW,EAAE,0BAA0B;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,aAAa,EAAE,sBAAsB;KACtC;IACD,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE;IAChB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,wBAAwB,EAAE;YACrD,GAAG,EAAE,IAAI,CAAC,MAAM;YAChB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;QAChC,MAAM,MAAM,GAAG,eAAe,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AAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;YAClB,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,mBAAmB,EAAE,IAAI,CAAC,kBAAkB,IAAI,EAAE;YAClD,GAAG,CAAC,IAAI,CAAC,eAAe;gBACtB,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,eAAe,EAAE;gBAC5C,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CACH,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QAEvD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,iBAAiB,EAAE;gBAC7D,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,SAAS,EAAE,QAAQ;gBACnB,mBAAmB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;gBACpE,aAAa,EAAE,WAAW;gBAC1B,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,IAAI,CAAC,KAAK;gBAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;gBAChC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,aAAa,EAAE,IAAI,CAAC,KAAK;gBACzB,WAAW,EAAE,IAAI;gBACjB,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;aACzB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
|
+
customers: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
+
phone?: string | undefined;
|
|
4
|
+
docNumber?: string | undefined;
|
|
5
|
+
docType?: string | undefined;
|
|
6
|
+
defaultCard?: string | undefined;
|
|
7
|
+
userId: string;
|
|
8
|
+
epaycoCustomerId: string;
|
|
9
|
+
email: string;
|
|
10
|
+
name: string;
|
|
11
|
+
lastSyncedAt: number;
|
|
12
|
+
}, {
|
|
13
|
+
userId: import("convex/values").VString<string, "required">;
|
|
14
|
+
epaycoCustomerId: import("convex/values").VString<string, "required">;
|
|
15
|
+
name: import("convex/values").VString<string, "required">;
|
|
16
|
+
email: import("convex/values").VString<string, "required">;
|
|
17
|
+
phone: import("convex/values").VString<string | undefined, "optional">;
|
|
18
|
+
docType: import("convex/values").VString<string | undefined, "optional">;
|
|
19
|
+
docNumber: import("convex/values").VString<string | undefined, "optional">;
|
|
20
|
+
defaultCard: import("convex/values").VString<string | undefined, "optional">;
|
|
21
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
22
|
+
}, "required", "userId" | "epaycoCustomerId" | "email" | "name" | "phone" | "docNumber" | "docType" | "defaultCard" | "lastSyncedAt">, {
|
|
23
|
+
by_userId: ["userId", "_creationTime"];
|
|
24
|
+
by_epaycoCustomerId: ["epaycoCustomerId", "_creationTime"];
|
|
25
|
+
by_email: ["email", "_creationTime"];
|
|
26
|
+
}, {}, {}>;
|
|
27
|
+
tokens: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
28
|
+
userId: string;
|
|
29
|
+
epaycoCustomerId: string;
|
|
30
|
+
franchise: string;
|
|
31
|
+
mask: string;
|
|
32
|
+
lastSyncedAt: number;
|
|
33
|
+
epaycoTokenId: string;
|
|
34
|
+
isActive: boolean;
|
|
35
|
+
}, {
|
|
36
|
+
userId: import("convex/values").VString<string, "required">;
|
|
37
|
+
epaycoTokenId: import("convex/values").VString<string, "required">;
|
|
38
|
+
epaycoCustomerId: import("convex/values").VString<string, "required">;
|
|
39
|
+
mask: import("convex/values").VString<string, "required">;
|
|
40
|
+
franchise: import("convex/values").VString<string, "required">;
|
|
41
|
+
isActive: import("convex/values").VBoolean<boolean, "required">;
|
|
42
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
43
|
+
}, "required", "userId" | "epaycoCustomerId" | "franchise" | "mask" | "lastSyncedAt" | "epaycoTokenId" | "isActive">, {
|
|
44
|
+
by_userId: ["userId", "_creationTime"];
|
|
45
|
+
by_epaycoTokenId: ["epaycoTokenId", "_creationTime"];
|
|
46
|
+
}, {}, {}>;
|
|
47
|
+
transactions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
48
|
+
franchise?: string | undefined;
|
|
49
|
+
splitReceivers?: {
|
|
50
|
+
fee?: number | undefined;
|
|
51
|
+
id: string;
|
|
52
|
+
total: number;
|
|
53
|
+
iva: number;
|
|
54
|
+
base_iva: number;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
epaycoTransactionId?: string | undefined;
|
|
57
|
+
customerEmail?: string | undefined;
|
|
58
|
+
bankName?: string | undefined;
|
|
59
|
+
cashProvider?: string | undefined;
|
|
60
|
+
responseCode?: string | undefined;
|
|
61
|
+
responseMessage?: string | undefined;
|
|
62
|
+
splitPayment?: boolean | undefined;
|
|
63
|
+
rawResponse?: any;
|
|
64
|
+
userId: string;
|
|
65
|
+
epaycoRef: string;
|
|
66
|
+
status: string;
|
|
67
|
+
amount: number;
|
|
68
|
+
currency: string;
|
|
69
|
+
description: string;
|
|
70
|
+
paymentMethod: "credit_card" | "pse" | "cash" | "daviplata" | "safetypay";
|
|
71
|
+
lastSyncedAt: number;
|
|
72
|
+
}, {
|
|
73
|
+
userId: import("convex/values").VString<string, "required">;
|
|
74
|
+
epaycoRef: import("convex/values").VString<string, "required">;
|
|
75
|
+
epaycoTransactionId: import("convex/values").VString<string | undefined, "optional">;
|
|
76
|
+
paymentMethod: import("convex/values").VUnion<"credit_card" | "pse" | "cash" | "daviplata" | "safetypay", [import("convex/values").VLiteral<"credit_card", "required">, import("convex/values").VLiteral<"pse", "required">, import("convex/values").VLiteral<"cash", "required">, import("convex/values").VLiteral<"daviplata", "required">, import("convex/values").VLiteral<"safetypay", "required">], "required", never>;
|
|
77
|
+
status: import("convex/values").VString<string, "required">;
|
|
78
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
79
|
+
currency: import("convex/values").VString<string, "required">;
|
|
80
|
+
description: import("convex/values").VString<string, "required">;
|
|
81
|
+
customerEmail: import("convex/values").VString<string | undefined, "optional">;
|
|
82
|
+
bankName: import("convex/values").VString<string | undefined, "optional">;
|
|
83
|
+
cashProvider: import("convex/values").VString<string | undefined, "optional">;
|
|
84
|
+
responseCode: import("convex/values").VString<string | undefined, "optional">;
|
|
85
|
+
responseMessage: import("convex/values").VString<string | undefined, "optional">;
|
|
86
|
+
franchise: import("convex/values").VString<string | undefined, "optional">;
|
|
87
|
+
splitPayment: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
88
|
+
splitReceivers: import("convex/values").VArray<{
|
|
89
|
+
fee?: number | undefined;
|
|
90
|
+
id: string;
|
|
91
|
+
total: number;
|
|
92
|
+
iva: number;
|
|
93
|
+
base_iva: number;
|
|
94
|
+
}[] | undefined, import("convex/values").VObject<{
|
|
95
|
+
fee?: number | undefined;
|
|
96
|
+
id: string;
|
|
97
|
+
total: number;
|
|
98
|
+
iva: number;
|
|
99
|
+
base_iva: number;
|
|
100
|
+
}, {
|
|
101
|
+
id: import("convex/values").VString<string, "required">;
|
|
102
|
+
total: import("convex/values").VFloat64<number, "required">;
|
|
103
|
+
iva: import("convex/values").VFloat64<number, "required">;
|
|
104
|
+
base_iva: import("convex/values").VFloat64<number, "required">;
|
|
105
|
+
fee: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
106
|
+
}, "required", "id" | "total" | "iva" | "base_iva" | "fee">, "optional">;
|
|
107
|
+
rawResponse: import("convex/values").VAny<any, "optional", string>;
|
|
108
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
109
|
+
}, "required", "userId" | "epaycoRef" | "franchise" | "status" | "amount" | "currency" | "description" | "paymentMethod" | "splitReceivers" | "lastSyncedAt" | "epaycoTransactionId" | "customerEmail" | "bankName" | "cashProvider" | "responseCode" | "responseMessage" | "splitPayment" | "rawResponse" | `rawResponse.${string}`>, {
|
|
110
|
+
by_userId: ["userId", "_creationTime"];
|
|
111
|
+
by_epaycoRef: ["epaycoRef", "_creationTime"];
|
|
112
|
+
by_userId_and_status: ["userId", "status", "_creationTime"];
|
|
113
|
+
}, {}, {}>;
|
|
114
|
+
plans: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
115
|
+
name: string;
|
|
116
|
+
epaycoPlanId: string;
|
|
117
|
+
status: string;
|
|
118
|
+
amount: number;
|
|
119
|
+
currency: string;
|
|
120
|
+
description: string;
|
|
121
|
+
interval: string;
|
|
122
|
+
intervalCount: number;
|
|
123
|
+
trialDays: number;
|
|
124
|
+
lastSyncedAt: number;
|
|
125
|
+
}, {
|
|
126
|
+
epaycoPlanId: import("convex/values").VString<string, "required">;
|
|
127
|
+
name: import("convex/values").VString<string, "required">;
|
|
128
|
+
description: import("convex/values").VString<string, "required">;
|
|
129
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
130
|
+
currency: import("convex/values").VString<string, "required">;
|
|
131
|
+
interval: import("convex/values").VString<string, "required">;
|
|
132
|
+
intervalCount: import("convex/values").VFloat64<number, "required">;
|
|
133
|
+
trialDays: import("convex/values").VFloat64<number, "required">;
|
|
134
|
+
status: import("convex/values").VString<string, "required">;
|
|
135
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
136
|
+
}, "required", "name" | "epaycoPlanId" | "status" | "amount" | "currency" | "description" | "interval" | "intervalCount" | "trialDays" | "lastSyncedAt">, {
|
|
137
|
+
by_epaycoPlanId: ["epaycoPlanId", "_creationTime"];
|
|
138
|
+
by_status: ["status", "_creationTime"];
|
|
139
|
+
}, {}, {}>;
|
|
140
|
+
subscriptions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
141
|
+
epaycoTokenId?: string | undefined;
|
|
142
|
+
currentPeriodStart?: number | undefined;
|
|
143
|
+
currentPeriodEnd?: number | undefined;
|
|
144
|
+
userId: string;
|
|
145
|
+
epaycoCustomerId: string;
|
|
146
|
+
epaycoPlanId: string;
|
|
147
|
+
status: string;
|
|
148
|
+
epaycoSubscriptionId: string;
|
|
149
|
+
lastSyncedAt: number;
|
|
150
|
+
}, {
|
|
151
|
+
userId: import("convex/values").VString<string, "required">;
|
|
152
|
+
epaycoSubscriptionId: import("convex/values").VString<string, "required">;
|
|
153
|
+
epaycoCustomerId: import("convex/values").VString<string, "required">;
|
|
154
|
+
epaycoPlanId: import("convex/values").VString<string, "required">;
|
|
155
|
+
epaycoTokenId: import("convex/values").VString<string | undefined, "optional">;
|
|
156
|
+
status: import("convex/values").VString<string, "required">;
|
|
157
|
+
currentPeriodStart: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
158
|
+
currentPeriodEnd: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
159
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
160
|
+
}, "required", "userId" | "epaycoCustomerId" | "epaycoPlanId" | "status" | "epaycoSubscriptionId" | "lastSyncedAt" | "epaycoTokenId" | "currentPeriodStart" | "currentPeriodEnd">, {
|
|
161
|
+
by_userId: ["userId", "_creationTime"];
|
|
162
|
+
by_epaycoSubscriptionId: ["epaycoSubscriptionId", "_creationTime"];
|
|
163
|
+
by_customerId_and_status: ["epaycoCustomerId", "status", "_creationTime"];
|
|
164
|
+
}, {}, {}>;
|
|
165
|
+
banks: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
166
|
+
lastSyncedAt: number;
|
|
167
|
+
bankName: string;
|
|
168
|
+
bankCode: string;
|
|
169
|
+
}, {
|
|
170
|
+
bankCode: import("convex/values").VString<string, "required">;
|
|
171
|
+
bankName: import("convex/values").VString<string, "required">;
|
|
172
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
173
|
+
}, "required", "lastSyncedAt" | "bankName" | "bankCode">, {
|
|
174
|
+
by_bankCode: ["bankCode", "_creationTime"];
|
|
175
|
+
}, {}, {}>;
|
|
176
|
+
webhookEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
177
|
+
epaycoTransactionId?: string | undefined;
|
|
178
|
+
errorMessage?: string | undefined;
|
|
179
|
+
processedAt?: number | undefined;
|
|
180
|
+
epaycoRef: string;
|
|
181
|
+
status: "pending" | "failed" | "processed";
|
|
182
|
+
lastSyncedAt: number;
|
|
183
|
+
eventType: string;
|
|
184
|
+
rawPayload: any;
|
|
185
|
+
}, {
|
|
186
|
+
epaycoRef: import("convex/values").VString<string, "required">;
|
|
187
|
+
epaycoTransactionId: import("convex/values").VString<string | undefined, "optional">;
|
|
188
|
+
eventType: import("convex/values").VString<string, "required">;
|
|
189
|
+
status: import("convex/values").VUnion<"pending" | "failed" | "processed", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"processed", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
|
|
190
|
+
rawPayload: import("convex/values").VAny<any, "required", string>;
|
|
191
|
+
errorMessage: import("convex/values").VString<string | undefined, "optional">;
|
|
192
|
+
processedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
193
|
+
lastSyncedAt: import("convex/values").VFloat64<number, "required">;
|
|
194
|
+
}, "required", "epaycoRef" | "status" | "lastSyncedAt" | "epaycoTransactionId" | "eventType" | "rawPayload" | "errorMessage" | "processedAt" | `rawPayload.${string}`>, {
|
|
195
|
+
by_epaycoRef: ["epaycoRef", "_creationTime"];
|
|
196
|
+
by_status: ["status", "_creationTime"];
|
|
197
|
+
}, {}, {}>;
|
|
198
|
+
}, true>;
|
|
199
|
+
export default _default;
|
|
200
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBAwHG"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
export default defineSchema({
|
|
4
|
+
customers: defineTable({
|
|
5
|
+
userId: v.string(),
|
|
6
|
+
epaycoCustomerId: v.string(),
|
|
7
|
+
name: v.string(),
|
|
8
|
+
email: v.string(),
|
|
9
|
+
phone: v.optional(v.string()),
|
|
10
|
+
docType: v.optional(v.string()),
|
|
11
|
+
docNumber: v.optional(v.string()),
|
|
12
|
+
defaultCard: v.optional(v.string()),
|
|
13
|
+
lastSyncedAt: v.number(),
|
|
14
|
+
})
|
|
15
|
+
.index("by_userId", ["userId"])
|
|
16
|
+
.index("by_epaycoCustomerId", ["epaycoCustomerId"])
|
|
17
|
+
.index("by_email", ["email"]),
|
|
18
|
+
tokens: defineTable({
|
|
19
|
+
userId: v.string(),
|
|
20
|
+
epaycoTokenId: v.string(),
|
|
21
|
+
epaycoCustomerId: v.string(),
|
|
22
|
+
mask: v.string(),
|
|
23
|
+
franchise: v.string(),
|
|
24
|
+
isActive: v.boolean(),
|
|
25
|
+
lastSyncedAt: v.number(),
|
|
26
|
+
})
|
|
27
|
+
.index("by_userId", ["userId"])
|
|
28
|
+
.index("by_epaycoTokenId", ["epaycoTokenId"]),
|
|
29
|
+
transactions: defineTable({
|
|
30
|
+
userId: v.string(),
|
|
31
|
+
epaycoRef: v.string(),
|
|
32
|
+
epaycoTransactionId: v.optional(v.string()),
|
|
33
|
+
paymentMethod: v.union(v.literal("credit_card"), v.literal("pse"), v.literal("cash"), v.literal("daviplata"), v.literal("safetypay")),
|
|
34
|
+
status: v.string(),
|
|
35
|
+
amount: v.number(),
|
|
36
|
+
currency: v.string(),
|
|
37
|
+
description: v.string(),
|
|
38
|
+
customerEmail: v.optional(v.string()),
|
|
39
|
+
bankName: v.optional(v.string()),
|
|
40
|
+
cashProvider: v.optional(v.string()),
|
|
41
|
+
responseCode: v.optional(v.string()),
|
|
42
|
+
responseMessage: v.optional(v.string()),
|
|
43
|
+
franchise: v.optional(v.string()),
|
|
44
|
+
splitPayment: v.optional(v.boolean()),
|
|
45
|
+
splitReceivers: v.optional(v.array(v.object({
|
|
46
|
+
id: v.string(),
|
|
47
|
+
total: v.number(),
|
|
48
|
+
iva: v.number(),
|
|
49
|
+
base_iva: v.number(),
|
|
50
|
+
fee: v.optional(v.number()),
|
|
51
|
+
}))),
|
|
52
|
+
rawResponse: v.optional(v.any()),
|
|
53
|
+
lastSyncedAt: v.number(),
|
|
54
|
+
})
|
|
55
|
+
.index("by_userId", ["userId"])
|
|
56
|
+
.index("by_epaycoRef", ["epaycoRef"])
|
|
57
|
+
.index("by_userId_and_status", ["userId", "status"]),
|
|
58
|
+
plans: defineTable({
|
|
59
|
+
epaycoPlanId: v.string(),
|
|
60
|
+
name: v.string(),
|
|
61
|
+
description: v.string(),
|
|
62
|
+
amount: v.number(),
|
|
63
|
+
currency: v.string(),
|
|
64
|
+
interval: v.string(),
|
|
65
|
+
intervalCount: v.number(),
|
|
66
|
+
trialDays: v.number(),
|
|
67
|
+
status: v.string(),
|
|
68
|
+
lastSyncedAt: v.number(),
|
|
69
|
+
})
|
|
70
|
+
.index("by_epaycoPlanId", ["epaycoPlanId"])
|
|
71
|
+
.index("by_status", ["status"]),
|
|
72
|
+
subscriptions: defineTable({
|
|
73
|
+
userId: v.string(),
|
|
74
|
+
epaycoSubscriptionId: v.string(),
|
|
75
|
+
epaycoCustomerId: v.string(),
|
|
76
|
+
epaycoPlanId: v.string(),
|
|
77
|
+
epaycoTokenId: v.optional(v.string()),
|
|
78
|
+
status: v.string(),
|
|
79
|
+
currentPeriodStart: v.optional(v.number()),
|
|
80
|
+
currentPeriodEnd: v.optional(v.number()),
|
|
81
|
+
lastSyncedAt: v.number(),
|
|
82
|
+
})
|
|
83
|
+
.index("by_userId", ["userId"])
|
|
84
|
+
.index("by_epaycoSubscriptionId", ["epaycoSubscriptionId"])
|
|
85
|
+
.index("by_customerId_and_status", ["epaycoCustomerId", "status"]),
|
|
86
|
+
banks: defineTable({
|
|
87
|
+
bankCode: v.string(),
|
|
88
|
+
bankName: v.string(),
|
|
89
|
+
lastSyncedAt: v.number(),
|
|
90
|
+
}).index("by_bankCode", ["bankCode"]),
|
|
91
|
+
webhookEvents: defineTable({
|
|
92
|
+
epaycoRef: v.string(),
|
|
93
|
+
epaycoTransactionId: v.optional(v.string()),
|
|
94
|
+
eventType: v.string(),
|
|
95
|
+
status: v.union(v.literal("pending"), v.literal("processed"), v.literal("failed")),
|
|
96
|
+
rawPayload: v.any(),
|
|
97
|
+
errorMessage: v.optional(v.string()),
|
|
98
|
+
processedAt: v.optional(v.number()),
|
|
99
|
+
lastSyncedAt: v.number(),
|
|
100
|
+
})
|
|
101
|
+
.index("by_epaycoRef", ["epaycoRef"])
|
|
102
|
+
.index("by_status", ["status"]),
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,eAAe,YAAY,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;QACrB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,KAAK,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C,cAAc,EAAE,CAAC,WAAW,CAAC,CAAC;SACpC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ePayco webhook (confirmation) signature verification.
|
|
3
|
+
*
|
|
4
|
+
* ePayco signs each confirmation with:
|
|
5
|
+
* SHA256( p_cust_id_cliente ^ p_key ^ x_ref_payco ^ x_transaction_id ^ x_amount ^ x_currency_code )
|
|
6
|
+
*
|
|
7
|
+
* This runs in the default Convex (V8) runtime using Web Crypto — no Node
|
|
8
|
+
* built-ins required — so it is safe to import from queries/mutations/actions.
|
|
9
|
+
*/
|
|
10
|
+
export declare function verifyWebhookSignature(custIdCliente: string, pKey: string, xRefPayco: string, xTransactionId: string, xAmount: string, xCurrencyCode: string, receivedSignature: string): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/component/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC,CAUlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ePayco webhook (confirmation) signature verification.
|
|
3
|
+
*
|
|
4
|
+
* ePayco signs each confirmation with:
|
|
5
|
+
* SHA256( p_cust_id_cliente ^ p_key ^ x_ref_payco ^ x_transaction_id ^ x_amount ^ x_currency_code )
|
|
6
|
+
*
|
|
7
|
+
* This runs in the default Convex (V8) runtime using Web Crypto — no Node
|
|
8
|
+
* built-ins required — so it is safe to import from queries/mutations/actions.
|
|
9
|
+
*/
|
|
10
|
+
export async function verifyWebhookSignature(custIdCliente, pKey, xRefPayco, xTransactionId, xAmount, xCurrencyCode, receivedSignature) {
|
|
11
|
+
const data = `${custIdCliente}^${pKey}^${xRefPayco}^${xTransactionId}^${xAmount}^${xCurrencyCode}`;
|
|
12
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(data));
|
|
13
|
+
const computedSignature = Array.from(new Uint8Array(hashBuffer))
|
|
14
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
15
|
+
.join("");
|
|
16
|
+
return timingSafeEqual(computedSignature, receivedSignature);
|
|
17
|
+
}
|
|
18
|
+
/** Constant-time string comparison to avoid leaking timing information. */
|
|
19
|
+
function timingSafeEqual(a, b) {
|
|
20
|
+
if (a.length !== b.length)
|
|
21
|
+
return false;
|
|
22
|
+
let mismatch = 0;
|
|
23
|
+
for (let i = 0; i < a.length; i++) {
|
|
24
|
+
mismatch |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
25
|
+
}
|
|
26
|
+
return mismatch === 0;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/component/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,aAAqB,EACrB,IAAY,EACZ,SAAiB,EACjB,cAAsB,EACtB,OAAe,EACf,aAAqB,EACrB,iBAAyB;IAEzB,MAAM,IAAI,GAAG,GAAG,aAAa,IAAI,IAAI,IAAI,SAAS,IAAI,cAAc,IAAI,OAAO,IAAI,aAAa,EAAE,CAAC;IACnG,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAC3C,SAAS,EACT,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAC/B,CAAC;IACF,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;SAC7D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,eAAe,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;AAC/D,CAAC;AAED,2EAA2E;AAC3E,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS;IAC3C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,QAAQ,KAAK,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalization of ePayco transaction states into the component's canonical
|
|
3
|
+
* status vocabulary: pending | approved | rejected | failed | expired | reversed.
|
|
4
|
+
*
|
|
5
|
+
* Pure functions, safe in any runtime.
|
|
6
|
+
*/
|
|
7
|
+
export type TransactionStatus = "pending" | "approved" | "rejected" | "failed" | "expired" | "reversed";
|
|
8
|
+
/** Map ePayco's `x_cod_response` (webhook) numeric code to a canonical status. */
|
|
9
|
+
export declare function statusFromCodResponse(cod: string | number): TransactionStatus;
|
|
10
|
+
/** Map ePayco's textual `estado` / `x_response` to a canonical status. */
|
|
11
|
+
export declare function statusFromEstado(estado: string | undefined | null): TransactionStatus;
|
|
12
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/component/status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,UAAU,GACV,QAAQ,GACR,SAAS,GACT,UAAU,CAAC;AAEf,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAwB7E;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAChC,iBAAiB,CA0BnB"}
|