@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,106 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { action } from "./_generated/server.js";
|
|
3
|
+
import { internal } from "./_generated/api.js";
|
|
4
|
+
import { epaycoCredentialsValidator, chargeInfoValidator, } from "./validators.js";
|
|
5
|
+
import { getEpaycoClient, unwrap, dataOf, pick } from "./epaycoClient.js";
|
|
6
|
+
import { buildSplitPayload, storedReceivers } from "./payloads.js";
|
|
7
|
+
import { statusFromEstado } from "./status.js";
|
|
8
|
+
import { rateLimiter } from "./rateLimits.js";
|
|
9
|
+
/** Charge a tokenized credit card. */
|
|
10
|
+
export const createCharge = action({
|
|
11
|
+
args: {
|
|
12
|
+
credentials: epaycoCredentialsValidator,
|
|
13
|
+
userId: v.string(),
|
|
14
|
+
chargeInfo: chargeInfoValidator,
|
|
15
|
+
},
|
|
16
|
+
returns: v.any(),
|
|
17
|
+
handler: async (ctx, args) => {
|
|
18
|
+
await rateLimiter.limit(ctx, "createCharge", {
|
|
19
|
+
key: args.userId,
|
|
20
|
+
throws: true,
|
|
21
|
+
});
|
|
22
|
+
const info = args.chargeInfo;
|
|
23
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
24
|
+
const result = unwrap(await epayco.charge.create({
|
|
25
|
+
token_card: info.tokenCard,
|
|
26
|
+
customer_id: info.customerId,
|
|
27
|
+
doc_type: info.docType,
|
|
28
|
+
doc_number: info.docNumber,
|
|
29
|
+
name: info.name,
|
|
30
|
+
last_name: info.lastName,
|
|
31
|
+
email: info.email,
|
|
32
|
+
...(info.city ? { city: info.city } : {}),
|
|
33
|
+
...(info.address ? { address: info.address } : {}),
|
|
34
|
+
...(info.phone ? { phone: info.phone } : {}),
|
|
35
|
+
...(info.cellPhone ? { cell_phone: info.cellPhone } : {}),
|
|
36
|
+
bill: info.bill,
|
|
37
|
+
description: info.description,
|
|
38
|
+
value: String(info.value),
|
|
39
|
+
tax: String(info.tax),
|
|
40
|
+
tax_base: String(info.taxBase),
|
|
41
|
+
currency: info.currency ?? "COP",
|
|
42
|
+
dues: String(info.dues ?? 1),
|
|
43
|
+
...(info.ip ? { ip: info.ip } : {}),
|
|
44
|
+
...(info.urlResponse ? { url_response: info.urlResponse } : {}),
|
|
45
|
+
...(info.urlConfirmation
|
|
46
|
+
? { url_confirmation: info.urlConfirmation }
|
|
47
|
+
: {}),
|
|
48
|
+
...(info.methodConfirmation
|
|
49
|
+
? { method_confirmation: info.methodConfirmation }
|
|
50
|
+
: {}),
|
|
51
|
+
...(info.useDefaultCardCustomer !== undefined
|
|
52
|
+
? { use_default_card_customer: info.useDefaultCardCustomer }
|
|
53
|
+
: {}),
|
|
54
|
+
extras: {
|
|
55
|
+
extra1: info.extra1 ?? "",
|
|
56
|
+
extra2: info.extra2 ?? "",
|
|
57
|
+
extra3: info.extra3 ?? "",
|
|
58
|
+
},
|
|
59
|
+
...buildSplitPayload(info.split, false),
|
|
60
|
+
}));
|
|
61
|
+
const data = dataOf(result);
|
|
62
|
+
const refPayco = pick(data, ["ref_payco", "refPayco"]);
|
|
63
|
+
if (refPayco) {
|
|
64
|
+
await ctx.runMutation(internal.transactions.upsertTransaction, {
|
|
65
|
+
userId: args.userId,
|
|
66
|
+
epaycoRef: refPayco,
|
|
67
|
+
epaycoTransactionId: pick(data, [
|
|
68
|
+
"transactionId",
|
|
69
|
+
"transaction_id",
|
|
70
|
+
"x_transaction_id",
|
|
71
|
+
]),
|
|
72
|
+
paymentMethod: "credit_card",
|
|
73
|
+
status: statusFromEstado(pick(data, ["estado", "x_response", "respuesta"])),
|
|
74
|
+
amount: info.value,
|
|
75
|
+
currency: info.currency ?? "COP",
|
|
76
|
+
description: info.description,
|
|
77
|
+
customerEmail: info.email,
|
|
78
|
+
franchise: pick(data, ["franchise", "franquicia", "x_franchise"]),
|
|
79
|
+
responseCode: pick(data, ["cod_respuesta", "x_cod_response"]),
|
|
80
|
+
responseMessage: pick(data, [
|
|
81
|
+
"respuesta",
|
|
82
|
+
"x_response_reason_text",
|
|
83
|
+
"response_reason_text",
|
|
84
|
+
]),
|
|
85
|
+
splitPayment: info.split !== undefined ? true : undefined,
|
|
86
|
+
splitReceivers: storedReceivers(info.split),
|
|
87
|
+
rawResponse: data,
|
|
88
|
+
lastSyncedAt: Date.now(),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
/** Look up a transaction by ref_payco directly from ePayco. */
|
|
95
|
+
export const getCharge = action({
|
|
96
|
+
args: {
|
|
97
|
+
credentials: epaycoCredentialsValidator,
|
|
98
|
+
epaycoRef: v.string(),
|
|
99
|
+
},
|
|
100
|
+
returns: v.any(),
|
|
101
|
+
handler: async (_ctx, args) => {
|
|
102
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
103
|
+
return unwrap(await epayco.charge.get(args.epaycoRef));
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=chargesApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargesApi.js","sourceRoot":"","sources":["../../src/component/chargesApi.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,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,sCAAsC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;IACjC,IAAI,EAAE;QACJ,WAAW,EAAE,0BAA0B;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,UAAU,EAAE,mBAAmB;KAChC;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,cAAc,EAAE;YAC3C,GAAG,EAAE,IAAI,CAAC,MAAM;YAChB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,CAAC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G,EAAE;IAChB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS,kDAA4B,CAAC;AAG5C,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,WAAW,MAAM,2CAA2C,CAAC;AAEpE,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC5C,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAE3B,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local persistence for ePayco customers. The outbound SDK calls live in
|
|
3
|
+
* `customersApi.ts` (Node runtime); these queries/mutations run in the fast
|
|
4
|
+
* V8 runtime and are the source of truth for the host app's reactive reads.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getLocalCustomer: import("convex/server").RegisteredQuery<"public", {
|
|
7
|
+
userId: string;
|
|
8
|
+
}, Promise<{
|
|
9
|
+
_id: import("convex/values").GenericId<"customers">;
|
|
10
|
+
_creationTime: number;
|
|
11
|
+
phone?: string | undefined;
|
|
12
|
+
docNumber?: string | undefined;
|
|
13
|
+
docType?: string | undefined;
|
|
14
|
+
defaultCard?: string | undefined;
|
|
15
|
+
userId: string;
|
|
16
|
+
epaycoCustomerId: string;
|
|
17
|
+
email: string;
|
|
18
|
+
name: string;
|
|
19
|
+
lastSyncedAt: number;
|
|
20
|
+
} | null>>;
|
|
21
|
+
export declare const getLocalCustomerByEpaycoId: import("convex/server").RegisteredQuery<"public", {
|
|
22
|
+
epaycoCustomerId: string;
|
|
23
|
+
}, Promise<{
|
|
24
|
+
_id: import("convex/values").GenericId<"customers">;
|
|
25
|
+
_creationTime: number;
|
|
26
|
+
phone?: string | undefined;
|
|
27
|
+
docNumber?: string | undefined;
|
|
28
|
+
docType?: string | undefined;
|
|
29
|
+
defaultCard?: string | undefined;
|
|
30
|
+
userId: string;
|
|
31
|
+
epaycoCustomerId: string;
|
|
32
|
+
email: string;
|
|
33
|
+
name: string;
|
|
34
|
+
lastSyncedAt: number;
|
|
35
|
+
} | null>>;
|
|
36
|
+
export declare const listLocalCustomers: import("convex/server").RegisteredQuery<"public", {
|
|
37
|
+
limit?: number | undefined;
|
|
38
|
+
}, Promise<{
|
|
39
|
+
_id: import("convex/values").GenericId<"customers">;
|
|
40
|
+
_creationTime: number;
|
|
41
|
+
phone?: string | undefined;
|
|
42
|
+
docNumber?: string | undefined;
|
|
43
|
+
docType?: string | undefined;
|
|
44
|
+
defaultCard?: string | undefined;
|
|
45
|
+
userId: string;
|
|
46
|
+
epaycoCustomerId: string;
|
|
47
|
+
email: string;
|
|
48
|
+
name: string;
|
|
49
|
+
lastSyncedAt: number;
|
|
50
|
+
}[]>>;
|
|
51
|
+
export declare const upsertCustomer: import("convex/server").RegisteredMutation<"internal", {
|
|
52
|
+
email?: string | undefined;
|
|
53
|
+
name?: string | undefined;
|
|
54
|
+
phone?: string | undefined;
|
|
55
|
+
docNumber?: string | undefined;
|
|
56
|
+
docType?: string | undefined;
|
|
57
|
+
defaultCard?: string | undefined;
|
|
58
|
+
userId: string;
|
|
59
|
+
epaycoCustomerId: string;
|
|
60
|
+
lastSyncedAt: number;
|
|
61
|
+
}, Promise<import("convex/values").GenericId<"customers">>>;
|
|
62
|
+
export declare const setDefaultCard: import("convex/server").RegisteredMutation<"internal", {
|
|
63
|
+
epaycoCustomerId: string;
|
|
64
|
+
defaultCard: string;
|
|
65
|
+
lastSyncedAt: number;
|
|
66
|
+
}, Promise<null>>;
|
|
67
|
+
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/component/customers.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;UAS3B,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;UAWrC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;KAM7B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;2DAkDzB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;iBAsBzB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { internalMutation, query } from "./_generated/server.js";
|
|
3
|
+
/**
|
|
4
|
+
* Local persistence for ePayco customers. The outbound SDK calls live in
|
|
5
|
+
* `customersApi.ts` (Node runtime); these queries/mutations run in the fast
|
|
6
|
+
* V8 runtime and are the source of truth for the host app's reactive reads.
|
|
7
|
+
*/
|
|
8
|
+
export const getLocalCustomer = query({
|
|
9
|
+
args: { userId: v.string() },
|
|
10
|
+
returns: v.any(),
|
|
11
|
+
handler: async (ctx, args) => {
|
|
12
|
+
return await ctx.db
|
|
13
|
+
.query("customers")
|
|
14
|
+
.withIndex("by_userId", (q) => q.eq("userId", args.userId))
|
|
15
|
+
.first();
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const getLocalCustomerByEpaycoId = query({
|
|
19
|
+
args: { epaycoCustomerId: v.string() },
|
|
20
|
+
returns: v.any(),
|
|
21
|
+
handler: async (ctx, args) => {
|
|
22
|
+
return await ctx.db
|
|
23
|
+
.query("customers")
|
|
24
|
+
.withIndex("by_epaycoCustomerId", (q) => q.eq("epaycoCustomerId", args.epaycoCustomerId))
|
|
25
|
+
.first();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
export const listLocalCustomers = query({
|
|
29
|
+
args: { limit: v.optional(v.number()) },
|
|
30
|
+
returns: v.any(),
|
|
31
|
+
handler: async (ctx, args) => {
|
|
32
|
+
return await ctx.db.query("customers").take(args.limit ?? 100);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const upsertCustomer = internalMutation({
|
|
36
|
+
args: {
|
|
37
|
+
userId: v.string(),
|
|
38
|
+
epaycoCustomerId: v.string(),
|
|
39
|
+
name: v.optional(v.string()),
|
|
40
|
+
email: v.optional(v.string()),
|
|
41
|
+
phone: v.optional(v.string()),
|
|
42
|
+
docType: v.optional(v.string()),
|
|
43
|
+
docNumber: v.optional(v.string()),
|
|
44
|
+
defaultCard: v.optional(v.string()),
|
|
45
|
+
lastSyncedAt: v.number(),
|
|
46
|
+
},
|
|
47
|
+
returns: v.id("customers"),
|
|
48
|
+
handler: async (ctx, args) => {
|
|
49
|
+
const existing = await ctx.db
|
|
50
|
+
.query("customers")
|
|
51
|
+
.withIndex("by_epaycoCustomerId", (q) => q.eq("epaycoCustomerId", args.epaycoCustomerId))
|
|
52
|
+
.first();
|
|
53
|
+
if (existing) {
|
|
54
|
+
if (existing.lastSyncedAt >= args.lastSyncedAt)
|
|
55
|
+
return existing._id;
|
|
56
|
+
await ctx.db.patch(existing._id, {
|
|
57
|
+
...(args.name !== undefined ? { name: args.name } : {}),
|
|
58
|
+
...(args.email !== undefined ? { email: args.email } : {}),
|
|
59
|
+
...(args.phone !== undefined ? { phone: args.phone } : {}),
|
|
60
|
+
...(args.docType !== undefined ? { docType: args.docType } : {}),
|
|
61
|
+
...(args.docNumber !== undefined ? { docNumber: args.docNumber } : {}),
|
|
62
|
+
...(args.defaultCard !== undefined
|
|
63
|
+
? { defaultCard: args.defaultCard }
|
|
64
|
+
: {}),
|
|
65
|
+
lastSyncedAt: args.lastSyncedAt,
|
|
66
|
+
});
|
|
67
|
+
return existing._id;
|
|
68
|
+
}
|
|
69
|
+
return await ctx.db.insert("customers", {
|
|
70
|
+
userId: args.userId,
|
|
71
|
+
epaycoCustomerId: args.epaycoCustomerId,
|
|
72
|
+
name: args.name ?? "",
|
|
73
|
+
email: args.email ?? "",
|
|
74
|
+
phone: args.phone,
|
|
75
|
+
docType: args.docType,
|
|
76
|
+
docNumber: args.docNumber,
|
|
77
|
+
defaultCard: args.defaultCard,
|
|
78
|
+
lastSyncedAt: args.lastSyncedAt,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
export const setDefaultCard = internalMutation({
|
|
83
|
+
args: {
|
|
84
|
+
epaycoCustomerId: v.string(),
|
|
85
|
+
defaultCard: v.string(),
|
|
86
|
+
lastSyncedAt: v.number(),
|
|
87
|
+
},
|
|
88
|
+
returns: v.null(),
|
|
89
|
+
handler: async (ctx, args) => {
|
|
90
|
+
const existing = await ctx.db
|
|
91
|
+
.query("customers")
|
|
92
|
+
.withIndex("by_epaycoCustomerId", (q) => q.eq("epaycoCustomerId", args.epaycoCustomerId))
|
|
93
|
+
.first();
|
|
94
|
+
if (existing) {
|
|
95
|
+
await ctx.db.patch(existing._id, {
|
|
96
|
+
defaultCard: args.defaultCard,
|
|
97
|
+
lastSyncedAt: args.lastSyncedAt,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=customers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/component/customers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;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ACrB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;IAC7C,IAAI,EAAE;QACJ,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;KACzB;IACD,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE;IACjB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE;aAC1B,KAAK,CAAC,WAAW,CAAC;aAClB,SAAS,CAAC,qBAAqB,EAAE,CAAC,CAAC,EAAE,EAAE,CACtC,CAAC,CAAC,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAChD;aACA,KAAK,EAAE,CAAC;QACX,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAC/B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;aAChC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Create an ePayco customer (links a tokenized card to a profile). */
|
|
2
|
+
export declare const createCustomer: 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
|
+
customerInfo: {
|
|
11
|
+
address?: string | undefined;
|
|
12
|
+
cellPhone?: string | undefined;
|
|
13
|
+
city?: string | undefined;
|
|
14
|
+
lastName?: string | undefined;
|
|
15
|
+
phone?: string | undefined;
|
|
16
|
+
docNumber?: string | undefined;
|
|
17
|
+
docType?: string | undefined;
|
|
18
|
+
isDefault?: boolean | undefined;
|
|
19
|
+
tokenCard: string;
|
|
20
|
+
email: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
24
|
+
/** Fetch a customer from ePayco by its ePayco id. */
|
|
25
|
+
export declare const getCustomer: import("convex/server").RegisteredAction<"public", {
|
|
26
|
+
credentials: {
|
|
27
|
+
testMode?: boolean | undefined;
|
|
28
|
+
lang?: string | undefined;
|
|
29
|
+
apiKey: string;
|
|
30
|
+
privateKey: string;
|
|
31
|
+
};
|
|
32
|
+
epaycoCustomerId: string;
|
|
33
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
34
|
+
/** List customers from ePayco (paginated). */
|
|
35
|
+
export declare const listCustomers: import("convex/server").RegisteredAction<"public", {
|
|
36
|
+
page?: number | undefined;
|
|
37
|
+
perPage?: number | undefined;
|
|
38
|
+
credentials: {
|
|
39
|
+
testMode?: boolean | undefined;
|
|
40
|
+
lang?: string | undefined;
|
|
41
|
+
apiKey: string;
|
|
42
|
+
privateKey: string;
|
|
43
|
+
};
|
|
44
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
45
|
+
/** Update a customer's mutable fields on ePayco and locally. */
|
|
46
|
+
export declare const updateCustomer: import("convex/server").RegisteredAction<"public", {
|
|
47
|
+
address?: string | undefined;
|
|
48
|
+
cellPhone?: string | undefined;
|
|
49
|
+
city?: string | undefined;
|
|
50
|
+
email?: string | undefined;
|
|
51
|
+
lastName?: string | undefined;
|
|
52
|
+
name?: string | undefined;
|
|
53
|
+
phone?: string | undefined;
|
|
54
|
+
credentials: {
|
|
55
|
+
testMode?: boolean | undefined;
|
|
56
|
+
lang?: string | undefined;
|
|
57
|
+
apiKey: string;
|
|
58
|
+
privateKey: string;
|
|
59
|
+
};
|
|
60
|
+
userId: string;
|
|
61
|
+
epaycoCustomerId: string;
|
|
62
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
63
|
+
/** Remove a card (token) from a customer on ePayco. */
|
|
64
|
+
export declare const deleteCustomerCard: import("convex/server").RegisteredAction<"public", {
|
|
65
|
+
credentials: {
|
|
66
|
+
testMode?: boolean | undefined;
|
|
67
|
+
lang?: string | undefined;
|
|
68
|
+
apiKey: string;
|
|
69
|
+
privateKey: string;
|
|
70
|
+
};
|
|
71
|
+
customerId: string;
|
|
72
|
+
franchise: string;
|
|
73
|
+
mask: string;
|
|
74
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
75
|
+
/** Set an existing token as the customer's default card. */
|
|
76
|
+
export declare const addDefaultCard: import("convex/server").RegisteredAction<"public", {
|
|
77
|
+
credentials: {
|
|
78
|
+
testMode?: boolean | undefined;
|
|
79
|
+
lang?: string | undefined;
|
|
80
|
+
apiKey: string;
|
|
81
|
+
privateKey: string;
|
|
82
|
+
};
|
|
83
|
+
customerId: string;
|
|
84
|
+
franchise: string;
|
|
85
|
+
mask: string;
|
|
86
|
+
token: string;
|
|
87
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
88
|
+
/** Attach an additional token to an existing customer. */
|
|
89
|
+
export declare const addNewToken: import("convex/server").RegisteredAction<"public", {
|
|
90
|
+
credentials: {
|
|
91
|
+
testMode?: boolean | undefined;
|
|
92
|
+
lang?: string | undefined;
|
|
93
|
+
apiKey: string;
|
|
94
|
+
privateKey: string;
|
|
95
|
+
};
|
|
96
|
+
customerId: string;
|
|
97
|
+
tokenCard: string;
|
|
98
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
99
|
+
//# sourceMappingURL=customersApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customersApi.d.ts","sourceRoot":"","sources":["../../src/component/customersApi.ts"],"names":[],"mappings":"AAUA,uEAAuE;AACvE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;uDAiDzB,CAAC;AAEH,qDAAqD;AACrD,eAAO,MAAM,WAAW;;;;;;;;uDAUtB,CAAC;AAEH,8CAA8C;AAC9C,eAAO,MAAM,aAAa;;;;;;;;;uDAgBxB,CAAC;AAEH,gEAAgE;AAChE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;uDAuCzB,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,kBAAkB;;;;;;;;;;uDAkB7B,CAAC;AAEH,4DAA4D;AAC5D,eAAO,MAAM,cAAc;;;;;;;;;;;uDA4BzB,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,WAAW;;;;;;;;;uDAgBtB,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { action } from "./_generated/server.js";
|
|
3
|
+
import { internal } from "./_generated/api.js";
|
|
4
|
+
import { epaycoCredentialsValidator, customerInfoValidator, } from "./validators.js";
|
|
5
|
+
import { getEpaycoClient, unwrap, dataOf, pick } from "./epaycoClient.js";
|
|
6
|
+
import { rateLimiter } from "./rateLimits.js";
|
|
7
|
+
/** Create an ePayco customer (links a tokenized card to a profile). */
|
|
8
|
+
export const createCustomer = action({
|
|
9
|
+
args: {
|
|
10
|
+
credentials: epaycoCredentialsValidator,
|
|
11
|
+
userId: v.string(),
|
|
12
|
+
customerInfo: customerInfoValidator,
|
|
13
|
+
},
|
|
14
|
+
returns: v.any(),
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
await rateLimiter.limit(ctx, "createCustomer", {
|
|
17
|
+
key: args.userId,
|
|
18
|
+
throws: true,
|
|
19
|
+
});
|
|
20
|
+
const info = args.customerInfo;
|
|
21
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
22
|
+
const result = unwrap(await epayco.customers.create({
|
|
23
|
+
token_card: info.tokenCard,
|
|
24
|
+
name: info.name,
|
|
25
|
+
last_name: info.lastName ?? "",
|
|
26
|
+
email: info.email,
|
|
27
|
+
default: info.isDefault ?? true,
|
|
28
|
+
...(info.phone ? { phone: info.phone } : {}),
|
|
29
|
+
...(info.cellPhone ? { cell_phone: info.cellPhone } : {}),
|
|
30
|
+
...(info.city ? { city: info.city } : {}),
|
|
31
|
+
...(info.address ? { address: info.address } : {}),
|
|
32
|
+
}));
|
|
33
|
+
const data = dataOf(result);
|
|
34
|
+
const epaycoCustomerId = pick(data, ["customerId", "id_customer", "id", "uid"]) ??
|
|
35
|
+
pick(result, ["customerId", "id_customer", "id", "uid"]);
|
|
36
|
+
if (epaycoCustomerId) {
|
|
37
|
+
await ctx.runMutation(internal.customers.upsertCustomer, {
|
|
38
|
+
userId: args.userId,
|
|
39
|
+
epaycoCustomerId,
|
|
40
|
+
name: info.name,
|
|
41
|
+
email: info.email,
|
|
42
|
+
phone: info.phone ?? info.cellPhone,
|
|
43
|
+
docType: info.docType,
|
|
44
|
+
docNumber: info.docNumber,
|
|
45
|
+
lastSyncedAt: Date.now(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
/** Fetch a customer from ePayco by its ePayco id. */
|
|
52
|
+
export const getCustomer = action({
|
|
53
|
+
args: {
|
|
54
|
+
credentials: epaycoCredentialsValidator,
|
|
55
|
+
epaycoCustomerId: v.string(),
|
|
56
|
+
},
|
|
57
|
+
returns: v.any(),
|
|
58
|
+
handler: async (_ctx, args) => {
|
|
59
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
60
|
+
return unwrap(await epayco.customers.get(args.epaycoCustomerId));
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
/** List customers from ePayco (paginated). */
|
|
64
|
+
export const listCustomers = action({
|
|
65
|
+
args: {
|
|
66
|
+
credentials: epaycoCredentialsValidator,
|
|
67
|
+
page: v.optional(v.number()),
|
|
68
|
+
perPage: v.optional(v.number()),
|
|
69
|
+
},
|
|
70
|
+
returns: v.any(),
|
|
71
|
+
handler: async (_ctx, args) => {
|
|
72
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
73
|
+
return unwrap(await epayco.customers.list({
|
|
74
|
+
page: args.page ?? 1,
|
|
75
|
+
perPage: args.perPage ?? 20,
|
|
76
|
+
}));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
/** Update a customer's mutable fields on ePayco and locally. */
|
|
80
|
+
export const updateCustomer = action({
|
|
81
|
+
args: {
|
|
82
|
+
credentials: epaycoCredentialsValidator,
|
|
83
|
+
userId: v.string(),
|
|
84
|
+
epaycoCustomerId: v.string(),
|
|
85
|
+
name: v.optional(v.string()),
|
|
86
|
+
lastName: v.optional(v.string()),
|
|
87
|
+
email: v.optional(v.string()),
|
|
88
|
+
phone: v.optional(v.string()),
|
|
89
|
+
cellPhone: v.optional(v.string()),
|
|
90
|
+
city: v.optional(v.string()),
|
|
91
|
+
address: v.optional(v.string()),
|
|
92
|
+
},
|
|
93
|
+
returns: v.any(),
|
|
94
|
+
handler: async (ctx, args) => {
|
|
95
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
96
|
+
const result = unwrap(await epayco.customers.update(args.epaycoCustomerId, {
|
|
97
|
+
...(args.name ? { name: args.name } : {}),
|
|
98
|
+
...(args.lastName ? { last_name: args.lastName } : {}),
|
|
99
|
+
...(args.email ? { email: args.email } : {}),
|
|
100
|
+
...(args.phone ? { phone: args.phone } : {}),
|
|
101
|
+
...(args.cellPhone ? { cell_phone: args.cellPhone } : {}),
|
|
102
|
+
...(args.city ? { city: args.city } : {}),
|
|
103
|
+
...(args.address ? { address: args.address } : {}),
|
|
104
|
+
}));
|
|
105
|
+
await ctx.runMutation(internal.customers.upsertCustomer, {
|
|
106
|
+
userId: args.userId,
|
|
107
|
+
epaycoCustomerId: args.epaycoCustomerId,
|
|
108
|
+
...(args.name !== undefined ? { name: args.name } : {}),
|
|
109
|
+
...(args.email !== undefined ? { email: args.email } : {}),
|
|
110
|
+
...(args.phone !== undefined ? { phone: args.phone } : {}),
|
|
111
|
+
lastSyncedAt: Date.now(),
|
|
112
|
+
});
|
|
113
|
+
return result;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
/** Remove a card (token) from a customer on ePayco. */
|
|
117
|
+
export const deleteCustomerCard = action({
|
|
118
|
+
args: {
|
|
119
|
+
credentials: epaycoCredentialsValidator,
|
|
120
|
+
franchise: v.string(),
|
|
121
|
+
mask: v.string(),
|
|
122
|
+
customerId: v.string(),
|
|
123
|
+
},
|
|
124
|
+
returns: v.any(),
|
|
125
|
+
handler: async (_ctx, args) => {
|
|
126
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
127
|
+
return unwrap(await epayco.customers.delete({
|
|
128
|
+
franchise: args.franchise,
|
|
129
|
+
mask: args.mask,
|
|
130
|
+
customer_id: args.customerId,
|
|
131
|
+
}));
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
/** Set an existing token as the customer's default card. */
|
|
135
|
+
export const addDefaultCard = action({
|
|
136
|
+
args: {
|
|
137
|
+
credentials: epaycoCredentialsValidator,
|
|
138
|
+
customerId: v.string(),
|
|
139
|
+
token: v.string(),
|
|
140
|
+
franchise: v.string(),
|
|
141
|
+
mask: v.string(),
|
|
142
|
+
},
|
|
143
|
+
returns: v.any(),
|
|
144
|
+
handler: async (ctx, args) => {
|
|
145
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
146
|
+
const result = unwrap(await epayco.customers.addDefaultCard({
|
|
147
|
+
franchise: args.franchise,
|
|
148
|
+
token: args.token,
|
|
149
|
+
mask: args.mask,
|
|
150
|
+
customer_id: args.customerId,
|
|
151
|
+
}));
|
|
152
|
+
await ctx.runMutation(internal.customers.setDefaultCard, {
|
|
153
|
+
epaycoCustomerId: args.customerId,
|
|
154
|
+
defaultCard: args.token,
|
|
155
|
+
lastSyncedAt: Date.now(),
|
|
156
|
+
});
|
|
157
|
+
return result;
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
/** Attach an additional token to an existing customer. */
|
|
161
|
+
export const addNewToken = action({
|
|
162
|
+
args: {
|
|
163
|
+
credentials: epaycoCredentialsValidator,
|
|
164
|
+
customerId: v.string(),
|
|
165
|
+
tokenCard: v.string(),
|
|
166
|
+
},
|
|
167
|
+
returns: v.any(),
|
|
168
|
+
handler: async (_ctx, args) => {
|
|
169
|
+
const epayco = getEpaycoClient(args.credentials);
|
|
170
|
+
return unwrap(await epayco.customers.addNewToken({
|
|
171
|
+
token_card: args.tokenCard,
|
|
172
|
+
customer_id: args.customerId,
|
|
173
|
+
}));
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
//# sourceMappingURL=customersApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customersApi.js","sourceRoot":"","sources":["../../src/component/customersApi.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,qBAAqB,GACtB,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,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;IACnC,IAAI,EAAE;QACJ,WAAW,EAAE,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AW,EAAE,0BAA0B;QACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB;IACD,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE;IAChB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,OAAO,MAAM,CACX,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;YACjC,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,WAAW,EAAE,IAAI,CAAC,UAAU;SAC7B,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Start a Daviplata payment. Returns a ref_payco + id_session_token used for OTP confirmation. */
|
|
2
|
+
export declare const createDaviplataPayment: 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
|
+
daviplataInfo: {
|
|
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
|
+
indCountry?: string | undefined;
|
|
19
|
+
email: string;
|
|
20
|
+
lastName: string;
|
|
21
|
+
name: string;
|
|
22
|
+
phone: string;
|
|
23
|
+
description: string;
|
|
24
|
+
docNumber: string;
|
|
25
|
+
docType: string;
|
|
26
|
+
value: number;
|
|
27
|
+
tax: number;
|
|
28
|
+
taxBase: number;
|
|
29
|
+
};
|
|
30
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
31
|
+
/** Confirm a Daviplata payment with the customer's OTP. */
|
|
32
|
+
export declare const confirmDaviplataPayment: import("convex/server").RegisteredAction<"public", {
|
|
33
|
+
credentials: {
|
|
34
|
+
testMode?: boolean | undefined;
|
|
35
|
+
lang?: string | undefined;
|
|
36
|
+
apiKey: string;
|
|
37
|
+
privateKey: string;
|
|
38
|
+
};
|
|
39
|
+
idSessionToken: string;
|
|
40
|
+
otp: string;
|
|
41
|
+
refPayco: string;
|
|
42
|
+
}, Promise<import("./epaycoClient.js").EpaycoResponse>>;
|
|
43
|
+
//# sourceMappingURL=daviplataApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daviplataApi.d.ts","sourceRoot":"","sources":["../../src/component/daviplataApi.ts"],"names":[],"mappings":"AAWA,mGAAmG;AACnG,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAmEjC,CAAC;AAEH,2DAA2D;AAC3D,eAAO,MAAM,uBAAuB;;;;;;;;;;uDAoClC,CAAC"}
|