@sphoq/payments 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +67 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { SphoqPayments } from "./client.js";
|
|
2
2
|
export { SphoqApiError } from "./types.js";
|
|
3
|
-
export type { SphoqPaymentsOptions, ChargeItem, CreateChargeOptions, Charge, GetChargeOptions, CancelChargeOptions, CancelChargeResult, WebhookPayload, VerifyWebhookOptions, } from "./types.js";
|
|
3
|
+
export type { SphoqPaymentsOptions, ChargeItem, ChargeFee, CreateChargeOptions, Charge, GetChargeOptions, CancelChargeOptions, CancelChargeResult, WebhookPayload, VerifyWebhookOptions, } from "./types.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration options for the {@link SphoqPayments} client.
|
|
3
3
|
*
|
|
4
|
+
* The API key prefix determines the environment:
|
|
5
|
+
* - `spq_live_*` — Production (real PIX charges)
|
|
6
|
+
* - `spq_test_*` — Development/Sandbox (EfiBank sandbox, no real money)
|
|
7
|
+
*
|
|
4
8
|
* @example
|
|
5
9
|
* ```ts
|
|
6
10
|
* import { SphoqPayments } from "@sphoq/payments";
|
|
7
11
|
*
|
|
12
|
+
* // Production
|
|
8
13
|
* const sphoq = new SphoqPayments({
|
|
9
|
-
* apiKey: "
|
|
14
|
+
* apiKey: "spq_live_abc123...",
|
|
15
|
+
* baseUrl: "https://your-deployment.convex.site",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Sandbox / Testing
|
|
19
|
+
* const sphoqTest = new SphoqPayments({
|
|
20
|
+
* apiKey: "spq_test_abc123...",
|
|
10
21
|
* baseUrl: "https://your-deployment.convex.site",
|
|
11
22
|
* });
|
|
12
23
|
* ```
|
|
13
24
|
*/
|
|
14
25
|
export interface SphoqPaymentsOptions {
|
|
15
26
|
/**
|
|
16
|
-
* Your Sphoq API key.
|
|
17
|
-
*
|
|
27
|
+
* Your Sphoq API key.
|
|
28
|
+
* - `spq_live_*` keys target the **production** EfiBank environment (real charges).
|
|
29
|
+
* - `spq_test_*` keys target the **sandbox** EfiBank environment (test charges).
|
|
30
|
+
*
|
|
31
|
+
* Generate keys from the Plugin page in your Sphoq store dashboard.
|
|
18
32
|
*/
|
|
19
33
|
apiKey: string;
|
|
20
34
|
/**
|
|
@@ -157,6 +171,35 @@ export interface CreateChargeOptions {
|
|
|
157
171
|
*/
|
|
158
172
|
metadata?: Record<string, unknown>;
|
|
159
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* A fee applied to a charge.
|
|
176
|
+
*
|
|
177
|
+
* Fees are calculated at charge creation and included in every charge response
|
|
178
|
+
* and webhook payload.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const charge = await sphoq.charges.create({ amount: 100, description: "Test" });
|
|
183
|
+
* for (const fee of charge.fees) {
|
|
184
|
+
* console.log(`${fee.type} (${fee.provider}): ${fee.rate}% = R$ ${fee.amount}`);
|
|
185
|
+
* }
|
|
186
|
+
* console.log(`Net amount: R$ ${charge.netAmount}`);
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export interface ChargeFee {
|
|
190
|
+
/**
|
|
191
|
+
* The category of this fee.
|
|
192
|
+
* - `"platform"` — Sphoq platform fee
|
|
193
|
+
* - `"processor"` — Payment processor fee (e.g., EfiBank PIX)
|
|
194
|
+
*/
|
|
195
|
+
type: "platform" | "processor";
|
|
196
|
+
/** Who charges this fee (e.g., `"sphoq"`, `"efibank"`). */
|
|
197
|
+
provider: string;
|
|
198
|
+
/** Fee percentage (e.g., `5` for 5%). */
|
|
199
|
+
rate: number;
|
|
200
|
+
/** Calculated fee amount in BRL. */
|
|
201
|
+
amount: number;
|
|
202
|
+
}
|
|
160
203
|
/**
|
|
161
204
|
* A PIX charge object returned by the Sphoq API.
|
|
162
205
|
*
|
|
@@ -238,6 +281,27 @@ export interface Charge {
|
|
|
238
281
|
* Returned as-is from the API.
|
|
239
282
|
*/
|
|
240
283
|
metadata?: Record<string, unknown>;
|
|
284
|
+
/**
|
|
285
|
+
* Fees applied to this charge.
|
|
286
|
+
* Calculated at creation time based on the store's tax settings.
|
|
287
|
+
*/
|
|
288
|
+
fees: ChargeFee[];
|
|
289
|
+
/**
|
|
290
|
+
* Sum of all fee amounts in BRL.
|
|
291
|
+
* Equal to `fees.reduce((sum, f) => sum + f.amount, 0)`.
|
|
292
|
+
*/
|
|
293
|
+
totalFees: number;
|
|
294
|
+
/**
|
|
295
|
+
* Amount after fees in BRL.
|
|
296
|
+
* Equal to `amount - totalFees`.
|
|
297
|
+
*/
|
|
298
|
+
netAmount: number;
|
|
299
|
+
/**
|
|
300
|
+
* The environment this charge was created in.
|
|
301
|
+
* - `"production"` — Real PIX charge.
|
|
302
|
+
* - `"development"` — EfiBank sandbox charge (no real money).
|
|
303
|
+
*/
|
|
304
|
+
environment?: "production" | "development";
|
|
241
305
|
/** Unix timestamp (milliseconds) when the charge was created. */
|
|
242
306
|
createdAt: number;
|
|
243
307
|
/** Unix timestamp (milliseconds) when the PIX QR code expires. */
|