@sphoq/payments 0.3.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 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
@@ -171,6 +171,35 @@ export interface CreateChargeOptions {
171
171
  */
172
172
  metadata?: Record<string, unknown>;
173
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
+ }
174
203
  /**
175
204
  * A PIX charge object returned by the Sphoq API.
176
205
  *
@@ -252,6 +281,21 @@ export interface Charge {
252
281
  * Returned as-is from the API.
253
282
  */
254
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;
255
299
  /**
256
300
  * The environment this charge was created in.
257
301
  * - `"production"` — Real PIX charge.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphoq/payments",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Sphoq Payments SDK — integrate PIX payment processing into your app",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",