@talajs/wompi 0.0.0-stage → 0.6.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 ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,48 @@
1
- # Temporary Holding Version
1
+ # @talajs/wompi
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Wompi](https://wompi.sv) (El Salvador) for [Tala](../../README.md): card payments on a Wompi **payment link**. The register shows a QR code, the customer pays by card on Wompi's page, and Tala sees the payment through Wompi's webhook (and by asking Wompi while the register waits).
4
+
5
+ **How a payment works:**
6
+ 1. At the register, **Charge → Wompi → Show QR code**. Tala creates a payment link for exactly that amount, which can be paid once.
7
+ 2. The customer scans the QR code with their phone's camera and pays by card on Wompi's page.
8
+ 3. Wompi notifies Tala's webhook. Tala checks the signature, then **asks Wompi** for the link's transactions: only an approved payment for the exact amount settles the order. The webhook's own body is never trusted.
9
+ 4. The register also asks Wompi every few seconds while the QR code is up, so it doesn't depend on the webhook alone.
10
+
11
+ **What else it does:**
12
+ - **Expiry and cancel:** a link not paid within 15 minutes, or canceled at the register, is deactivated at Wompi. If Wompi says it was paid at the last moment, the payment counts instead.
13
+ - **Late payments:** if a customer somehow pays after Tala canceled the payment, it goes to the review queue for a manager to refund or take. It's never lost.
14
+ - **Confirming by hand:** if Wompi's confirmation never arrives but the business can see the payment in its Wompi panel, a manager can confirm it at the register with the reference. It's recorded as an external payment, and logged.
15
+ - **Refunds** are made in the Wompi panel; Wompi doesn't offer refunds through its API. Record them in Tala as usual, and the admin reminds you to make them at Wompi.
16
+
17
+ ```ts
18
+ import { createTalaApp, sweepCheckouts } from '@talajs/api'
19
+ import { wompi } from '@talajs/wompi'
20
+
21
+ const payments = (env: Env) => [
22
+ wompi({ webhookUrl: `${env.PUBLIC_ORIGIN}/tala/v1/webhooks/wompi` }),
23
+ ]
24
+
25
+ createTalaApp<Env>({
26
+ db,
27
+ auth,
28
+ payments,
29
+ encryptionKey: (env) => env.TALA_ENCRYPTION_KEY, // openssl rand -base64 32
30
+ })
31
+
32
+ // In the Cron Trigger: expire unpaid links, asking Wompi first.
33
+ await sweepCheckouts(db, { payments: payments(env), encryptionKey: env.TALA_ENCRYPTION_KEY })
34
+ ```
35
+
36
+ Each business connects its own Wompi account in the admin under **Payments → Wompi**: the **App ID** and **API Secret** from the Wompi panel (open the business, then its API details). The secret is stored encrypted and never shown again.
37
+
38
+ | Option | |
39
+ |---|---|
40
+ | `webhookUrl` | Required. Tala's webhook route, reachable from the internet: `<public origin>/<api mount>/v1/webhooks/wompi`. Set on every payment link, so nothing needs configuring in the Wompi panel. |
41
+ | `mock` | `true` to try it without a Wompi account: nothing is sent to Wompi, and the customer's page offers Approve and Decline. Never in production. |
42
+ | `apiUrl`, `tokenUrl`, `fetch` | For tests. Default `https://api.wompi.sv` and `https://id.wompi.sv/connect/token`. |
43
+
44
+ **Notes:**
45
+ - **US dollars only.** A store in another currency can't offer Wompi.
46
+ - **Test mode:** a business that's still in development at Wompi gets test payments: Wompi approves every card (CVV `111` declines) and no money moves. The admin says so; switch the business to production in the Wompi panel.
47
+ - **Card payments only** for now. Wompi's other options (Puntos Agrícola, instalments, Bitcoin, QuickPay) are off on the links Tala creates.
48
+ - If something sits in front of the Worker (a WAF, bot protection), let Wompi reach `POST /tala/v1/webhooks/wompi`. The signature is in the `wompi_hash` header.
@@ -0,0 +1,52 @@
1
+ /** A small client for Wompi El Salvador's API (https://docs.wompi.sv). */
2
+ export declare const WOMPI_API_URL = "https://api.wompi.sv";
3
+ export declare const WOMPI_TOKEN_URL = "https://id.wompi.sv/connect/token";
4
+ export interface WompiCredentials {
5
+ /** The business's App ID (the OAuth client id). */
6
+ appId: string;
7
+ /** Its API Secret: the OAuth client secret, and the key webhooks are signed with. */
8
+ apiSecret: string;
9
+ }
10
+ export interface WompiBusiness {
11
+ idAplicativo: string;
12
+ nombre: string;
13
+ /** False while the business is in development: every payment is a test. */
14
+ estaProductivo: boolean;
15
+ }
16
+ export interface WompiTransaction {
17
+ idTransaccion: string;
18
+ esAprobada: boolean;
19
+ /** False for test transactions. */
20
+ esReal: boolean;
21
+ codigoAutorizacion?: string | null;
22
+ monto: number;
23
+ }
24
+ export interface WompiLink {
25
+ idEnlace: number;
26
+ urlEnlace: string;
27
+ urlQrCodeEnlace?: string;
28
+ usable?: boolean;
29
+ transaccionCompra?: WompiTransaction | null;
30
+ transacciones?: WompiTransaction[] | null;
31
+ }
32
+ export declare class WompiError extends Error {
33
+ readonly status: number;
34
+ name: string;
35
+ constructor(message: string, status: number);
36
+ }
37
+ export interface WompiClientOptions {
38
+ apiUrl?: string;
39
+ tokenUrl?: string;
40
+ fetch?: typeof fetch;
41
+ }
42
+ export declare function wompiClient(credentials: WompiCredentials, options?: WompiClientOptions): {
43
+ business: () => Promise<WompiBusiness>;
44
+ createLink: (body: Record<string, unknown>) => Promise<WompiLink>;
45
+ link: (id: string) => Promise<WompiLink>;
46
+ deactivateLink: (id: string) => Promise<unknown>;
47
+ };
48
+ /** HMAC-SHA256 of the raw body with the API Secret, as hex: Wompi's `wompi_hash` header. */
49
+ export declare function wompiSignature(body: string, apiSecret: string): Promise<string>;
50
+ /** Constant-time comparison of two hex strings, ignoring case. */
51
+ export declare function sameHex(a: string, b: string): boolean;
52
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,eAAO,MAAM,aAAa,yBAAyB,CAAA;AACnD,eAAO,MAAM,eAAe,sCAAsC,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAA;CA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AAClE,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,WAO3C"}
package/dist/client.js ADDED
@@ -0,0 +1,87 @@
1
+ /** A small client for Wompi El Salvador's API (https://docs.wompi.sv). */
2
+ export const WOMPI_API_URL = 'https://api.wompi.sv';
3
+ export const WOMPI_TOKEN_URL = 'https://id.wompi.sv/connect/token';
4
+ export class WompiError extends Error {
5
+ status;
6
+ name = 'WompiError';
7
+ constructor(message, status) {
8
+ super(message);
9
+ this.status = status;
10
+ }
11
+ }
12
+ /** Tokens are reused until a minute before they expire (per isolate). */
13
+ const tokens = new Map();
14
+ export function wompiClient(credentials, options = {}) {
15
+ const apiUrl = (options.apiUrl ?? WOMPI_API_URL).replace(/\/$/, '');
16
+ const tokenUrl = options.tokenUrl ?? WOMPI_TOKEN_URL;
17
+ const fetcher = options.fetch ?? fetch;
18
+ const cacheKey = `${tokenUrl}|${credentials.appId}|${credentials.apiSecret.length}`;
19
+ async function token() {
20
+ const cached = tokens.get(cacheKey);
21
+ if (cached && cached.expiresAt > Date.now() + 60_000)
22
+ return cached.value;
23
+ const res = await fetcher(tokenUrl, {
24
+ method: 'POST',
25
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
26
+ body: new URLSearchParams({
27
+ grant_type: 'client_credentials',
28
+ audience: 'wompi_api',
29
+ client_id: credentials.appId,
30
+ client_secret: credentials.apiSecret,
31
+ }),
32
+ });
33
+ if (!res.ok) {
34
+ throw new WompiError(res.status === 400 || res.status === 401
35
+ ? "Wompi didn't accept the App ID and API Secret"
36
+ : `Wompi's sign-in failed (${res.status})`, res.status);
37
+ }
38
+ const body = (await res.json());
39
+ tokens.set(cacheKey, {
40
+ value: body.access_token,
41
+ expiresAt: Date.now() + body.expires_in * 1000,
42
+ });
43
+ return body.access_token;
44
+ }
45
+ async function call(method, path, body) {
46
+ const res = await fetcher(`${apiUrl}${path}`, {
47
+ method,
48
+ headers: {
49
+ authorization: `Bearer ${await token()}`,
50
+ ...(body === undefined ? {} : { 'content-type': 'application/json' }),
51
+ },
52
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
53
+ });
54
+ if (res.status === 401)
55
+ tokens.delete(cacheKey);
56
+ if (!res.ok) {
57
+ const text = await res.text().catch(() => '');
58
+ throw new WompiError(`Wompi ${method} ${path} failed (${res.status}) ${text.slice(0, 200)}`, res.status);
59
+ }
60
+ const text = await res.text();
61
+ return (text ? JSON.parse(text) : null);
62
+ }
63
+ return {
64
+ business: () => call('GET', '/Aplicativo'),
65
+ createLink: (body) => call('POST', '/EnlacePago', body),
66
+ link: (id) => call('GET', `/EnlacePago/${encodeURIComponent(id)}`),
67
+ deactivateLink: (id) => call('PUT', `/EnlacePago/${encodeURIComponent(id)}/desactivar`),
68
+ };
69
+ }
70
+ const hex = (bytes) => [...new Uint8Array(bytes)].map((b) => b.toString(16).padStart(2, '0')).join('');
71
+ /** HMAC-SHA256 of the raw body with the API Secret, as hex: Wompi's `wompi_hash` header. */
72
+ export async function wompiSignature(body, apiSecret) {
73
+ const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(apiSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
74
+ return hex(await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(body)));
75
+ }
76
+ /** Constant-time comparison of two hex strings, ignoring case. */
77
+ export function sameHex(a, b) {
78
+ const x = a.trim().toLowerCase();
79
+ const y = b.trim().toLowerCase();
80
+ if (x.length !== y.length)
81
+ return false;
82
+ let diff = 0;
83
+ for (let i = 0; i < x.length; i++)
84
+ diff |= x.charCodeAt(i) ^ y.charCodeAt(i);
85
+ return diff === 0;
86
+ }
87
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAA;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,mC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M,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EACnC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EACjC,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAA;IACD,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,CAAS;IAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAChC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAChC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACvC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC5E,OAAO,IAAI,KAAK,CAAC,CAAA;AACnB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type PaymentAdapter } from '@talajs/api';
2
+ import { type WompiClientOptions } from './client.js';
3
+ export { WOMPI_API_URL, WOMPI_TOKEN_URL, type WompiCredentials, WompiError, wompiClient, wompiSignature, } from './client.js';
4
+ export declare const WOMPI_PROVIDER = "wompi";
5
+ export interface WompiOptions extends WompiClientOptions {
6
+ /**
7
+ * Where Wompi reports payments: Tala's webhook route, e.g.
8
+ * `${PUBLIC_ORIGIN}/tala/v1/webhooks/wompi`. Must be reachable from the internet.
9
+ */
10
+ webhookUrl: string;
11
+ /**
12
+ * For trying Tala without a Wompi account: nothing is sent to Wompi, and the customer's page
13
+ * offers Approve and Decline buttons. Never in production.
14
+ */
15
+ mock?: boolean;
16
+ }
17
+ /**
18
+ * Wompi (El Salvador) as a Tala payment module: the register shows a QR code for a Wompi payment
19
+ * link; the customer pays by card on Wompi's page; Wompi's webhook (or the register's polling)
20
+ * settles it in Tala. Refunds are made in the Wompi panel and recorded in Tala.
21
+ *
22
+ * Each business enters its own App ID and API Secret under Payments; the secret is stored
23
+ * encrypted.
24
+ */
25
+ export declare function wompi(options: WompiOptions): PaymentAdapter;
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,KAAK,kBAAkB,EAKxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,gBAAgB,EACrB,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,cAAc,UAAU,CAAA;AAKrC,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAkCD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,cAAc,CA8J3D"}
package/dist/index.js ADDED
@@ -0,0 +1,176 @@
1
+ import { PaymentUnavailableError, } from '@talajs/api';
2
+ import { sameHex, wompiClient, wompiSignature, } from './client.js';
3
+ export { WOMPI_API_URL, WOMPI_TOKEN_URL, WompiError, wompiClient, wompiSignature, } from './client.js';
4
+ export const WOMPI_PROVIDER = 'wompi';
5
+ /** Minutes a payment link stays open at the register. */
6
+ const EXPIRES_IN_MINUTES = 15;
7
+ const config = (account) => account.config;
8
+ async function credentials(account) {
9
+ const appId = config(account).appId;
10
+ const apiSecret = await account.secret();
11
+ if (!appId || !apiSecret)
12
+ throw new PaymentUnavailableError('Set up Wompi first');
13
+ return { appId, apiSecret };
14
+ }
15
+ const dollars = (minor) => Math.round(minor) / 100;
16
+ /** An approved transaction for exactly this amount (and a real one, once in production). */
17
+ function approved(transactions, amountMinor, production) {
18
+ return transactions.find((t) => t.esAprobada &&
19
+ (production ? t.esReal : true) &&
20
+ Math.round(Number(t.monto) * 100) === amountMinor);
21
+ }
22
+ /**
23
+ * Wompi (El Salvador) as a Tala payment module: the register shows a QR code for a Wompi payment
24
+ * link; the customer pays by card on Wompi's page; Wompi's webhook (or the register's polling)
25
+ * settles it in Tala. Refunds are made in the Wompi panel and recorded in Tala.
26
+ *
27
+ * Each business enters its own App ID and API Secret under Payments; the secret is stored
28
+ * encrypted.
29
+ */
30
+ export function wompi(options) {
31
+ const client = (c) => wompiClient(c, options);
32
+ const mock = options.mock === true;
33
+ const adapter = {
34
+ id: WOMPI_PROVIDER,
35
+ label: mock ? 'Wompi (mock)' : 'Wompi',
36
+ checkoutHint: 'The customer scans this with their phone camera and pays by card on the Wompi page.',
37
+ methods: ['CARD'],
38
+ async setup(settings, current) {
39
+ const appId = typeof settings.appId === 'string' && settings.appId.trim()
40
+ ? settings.appId.trim()
41
+ : current
42
+ ? config(current).appId
43
+ : undefined;
44
+ const newSecret = typeof settings.apiSecret === 'string' && settings.apiSecret.trim()
45
+ ? settings.apiSecret.trim()
46
+ : undefined;
47
+ const apiSecret = newSecret ?? (current ? await current.secret() : null);
48
+ if (!appId || !apiSecret)
49
+ throw new Error('Enter the App ID and API Secret from the Wompi panel');
50
+ if (mock) {
51
+ return {
52
+ config: { appId, businessName: 'Mock business', production: false, mock: true },
53
+ ...(newSecret ? { secret: newSecret } : {}),
54
+ externalAccountId: `mock:${appId}`,
55
+ };
56
+ }
57
+ const business = await client({ appId, apiSecret }).business();
58
+ return {
59
+ config: { appId, businessName: business.nombre, production: business.estaProductivo },
60
+ ...(newSecret ? { secret: newSecret } : {}),
61
+ externalAccountId: business.idAplicativo,
62
+ };
63
+ },
64
+ async status(account) {
65
+ if (mock) {
66
+ return {
67
+ status: 'READY',
68
+ message: 'Mock mode: nothing reaches Wompi and no money moves.',
69
+ details: { appId: config(account).appId, mode: 'mock' },
70
+ };
71
+ }
72
+ const business = await client(await credentials(account)).business();
73
+ return {
74
+ status: 'READY',
75
+ ...(business.estaProductivo
76
+ ? {}
77
+ : {
78
+ message: 'Test mode: Wompi approves every payment and no money moves. Switch the business to production in the Wompi panel when you are ready.',
79
+ }),
80
+ details: {
81
+ business: business.nombre,
82
+ appId: config(account).appId,
83
+ mode: business.estaProductivo ? 'production' : 'test',
84
+ },
85
+ };
86
+ },
87
+ checkout: {
88
+ expiresInMinutes: EXPIRES_IN_MINUTES,
89
+ async start(request, account) {
90
+ if (request.currency !== 'USD') {
91
+ throw new PaymentUnavailableError('Wompi takes payments in US dollars only');
92
+ }
93
+ if (mock)
94
+ return { externalId: `mock-${request.paymentId}` };
95
+ const link = await client(await credentials(account)).createLink({
96
+ // Tala's payment id: it comes back in the webhook and the reports.
97
+ identificadorEnlaceComercio: request.paymentId,
98
+ monto: dollars(request.amountMinor + request.tipMinor),
99
+ nombreProducto: request.description,
100
+ formaPago: {
101
+ permitirTarjetaCreditoDebido: true,
102
+ permitirPagoConPuntoAgricola: false,
103
+ permitirPagoEnCuotasAgricola: false,
104
+ permitirPagoEnBitcoin: false,
105
+ permitePagoQuickPay: false,
106
+ },
107
+ configuracion: {
108
+ urlWebhook: options.webhookUrl,
109
+ notificarTransaccionCliente: false,
110
+ esMontoEditable: false,
111
+ esCantidadEditable: false,
112
+ cantidadPorDefecto: 1,
113
+ duracionInterfazIntentoMinutos: EXPIRES_IN_MINUTES,
114
+ },
115
+ limitesDeUso: { cantidadMaximaPagosExitosos: 1 },
116
+ });
117
+ return { externalId: String(link.idEnlace) };
118
+ },
119
+ async view(payment, account) {
120
+ if (mock || !payment.externalId)
121
+ return { mock: true };
122
+ const link = await client(await credentials(account)).link(payment.externalId);
123
+ return { redirectUrl: link.urlEnlace };
124
+ },
125
+ ...(mock
126
+ ? {
127
+ async submit(_payment, _account, data) {
128
+ return data.approve === true
129
+ ? { status: 'SUCCESS', reference: 'MOCK' }
130
+ : { status: 'FAILED', failureReason: 'Declined (mock)' };
131
+ },
132
+ }
133
+ : {}),
134
+ async check(payment, account) {
135
+ if (mock || !payment.externalId)
136
+ return null;
137
+ const link = await client(await credentials(account)).link(payment.externalId);
138
+ const all = [
139
+ ...(link.transaccionCompra ? [link.transaccionCompra] : []),
140
+ ...(link.transacciones ?? []),
141
+ ];
142
+ const paid = approved(all, payment.amountMinor + payment.tipMinor, config(account).production === true);
143
+ // Declined attempts aren't final: the customer can try another card on the same page.
144
+ if (!paid)
145
+ return null;
146
+ return { status: 'SUCCESS', reference: paid.codigoAutorizacion || paid.idTransaccion };
147
+ },
148
+ async cancel(payment, account) {
149
+ if (mock || !payment.externalId)
150
+ return;
151
+ await client(await credentials(account)).deactivateLink(payment.externalId);
152
+ },
153
+ },
154
+ webhook: {
155
+ paymentId(body) {
156
+ try {
157
+ const parsed = JSON.parse(body);
158
+ const id = parsed.EnlacePago?.IdentificadorEnlaceComercio;
159
+ return typeof id === 'string' ? id : null;
160
+ }
161
+ catch {
162
+ return null;
163
+ }
164
+ },
165
+ async verify(body, headers, account) {
166
+ const signature = headers.get('wompi_hash');
167
+ const secret = await account.secret();
168
+ if (!signature || !secret)
169
+ return false;
170
+ return sameHex(signature, await wompiSignature(body, secret));
171
+ },
172
+ },
173
+ };
174
+ return adapter;
175
+ }
176
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,uBAA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O,OAAO,CAAA;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@talajs/wompi",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.6.0",
4
+ "description": "Wompi (El Salvador) for Tala: customers scan a QR code at the register and pay by card on a Wompi payment link; webhooks settle it.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/NovaDovaDao/talajs/tree/main/packages/wompi#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/NovaDovaDao/talajs/issues"
9
+ },
10
+ "keywords": [
11
+ "wompi",
12
+ "el-salvador",
13
+ "payment-links",
14
+ "payments",
15
+ "pos",
16
+ "cloudflare-workers"
17
+ ],
18
+ "type": "module",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/NovaDovaDao/talajs.git",
22
+ "directory": "packages/wompi"
23
+ },
24
+ "sideEffects": false,
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "@talajs/api": "0.6.0"
36
+ },
37
+ "devDependencies": {
38
+ "@cloudflare/vitest-plugin": "1.8.2",
39
+ "@cloudflare/workers-types": "^5.20261118.1",
40
+ "wrangler": "4.162.0",
41
+ "@types/pg": "^8.23.1",
42
+ "pg": "^8.23.1",
43
+ "hono": "^4.13.18",
44
+ "@talajs/db": "0.6.0",
45
+ "@talajs/contracts": "0.6.0"
46
+ },
47
+ "engines": {
48
+ "node": ">=22"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc -p tsconfig.build.json",
55
+ "typecheck": "tsc --noEmit",
56
+ "test": "vitest run"
57
+ }
6
58
  }