@solvapay/server 1.3.0 → 1.4.0-preview-e2cd9bda9dee33e68f6bba7098f7d683e6f1b742

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.cjs CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  TOPUP_BALANCE_POLL_DELAYS_MS: () => TOPUP_BALANCE_POLL_DELAYS_MS,
36
36
  VIRTUAL_TOOL_DEFINITIONS: () => VIRTUAL_TOOL_DEFINITIONS,
37
37
  activatePlanCore: () => activatePlanCore,
38
+ attachBusinessDetailsCore: () => attachBusinessDetailsCore,
38
39
  buildGateMessage: () => buildGateMessage,
39
40
  buildNudgeMessage: () => buildNudgeMessage,
40
41
  buildPaywallGate: () => buildPaywallGate,
@@ -76,7 +77,7 @@ __export(index_exports, {
76
77
  });
77
78
  module.exports = __toCommonJS(index_exports);
78
79
  var import_node_crypto = __toESM(require("crypto"), 1);
79
- var import_core8 = require("@solvapay/core");
80
+ var import_core9 = require("@solvapay/core");
80
81
 
81
82
  // src/client.ts
82
83
  var import_core = require("@solvapay/core");
@@ -566,6 +567,31 @@ function createSolvaPayClient(opts) {
566
567
  const result = await res.json();
567
568
  return result;
568
569
  },
570
+ // POST: /v1/sdk/payment-intents/{paymentIntentId}/business-details
571
+ async attachBusinessDetails(params) {
572
+ const url = `${base}/v1/sdk/payment-intents/${params.paymentIntentId}/business-details`;
573
+ const res = await fetch(url, {
574
+ method: "POST",
575
+ headers,
576
+ body: JSON.stringify({
577
+ isBusiness: params.isBusiness,
578
+ ...params.businessName !== void 0 && { businessName: params.businessName },
579
+ ...params.country !== void 0 && { country: params.country },
580
+ ...params.taxId !== void 0 && { taxId: params.taxId },
581
+ ...params.taxIdType !== void 0 && { taxIdType: params.taxIdType },
582
+ ...params.customerRef !== void 0 && { customerRef: params.customerRef }
583
+ })
584
+ });
585
+ if (!res.ok) {
586
+ const error = await res.text();
587
+ log(`\u274C API Error: ${res.status} - ${error}`);
588
+ throw new import_core.SolvaPayError(
589
+ `Attach business details failed (${res.status}): ${error}`,
590
+ { status: res.status }
591
+ );
592
+ }
593
+ return await res.json();
594
+ },
569
595
  // POST: /v1/sdk/purchases/{purchaseRef}/cancel
570
596
  async cancelPurchase(params) {
571
597
  const url = `${base}/v1/sdk/purchases/${params.purchaseRef}/cancel`;
@@ -2089,6 +2115,14 @@ function createSolvaPay(config) {
2089
2115
  }
2090
2116
  return apiClient.processPaymentIntent(params);
2091
2117
  },
2118
+ attachBusinessDetails(params) {
2119
+ if (!apiClient.attachBusinessDetails) {
2120
+ throw new import_core2.SolvaPayError(
2121
+ "attachBusinessDetails is not available on this API client"
2122
+ );
2123
+ }
2124
+ return apiClient.attachBusinessDetails(params);
2125
+ },
2092
2126
  checkLimits(params) {
2093
2127
  return apiClient.checkLimits(params);
2094
2128
  },
@@ -2490,6 +2524,9 @@ async function getCustomerBalanceCore(request, options = {}) {
2490
2524
  }
2491
2525
  }
2492
2526
 
2527
+ // src/helpers/payment.ts
2528
+ var import_core4 = require("@solvapay/core");
2529
+
2493
2530
  // src/helpers/balance-poll.ts
2494
2531
  var TOPUP_BALANCE_POLL_DELAYS_MS = [500, 1e3, 2e3, 4e3];
2495
2532
  var BALANCE_RECONCILE_DELAYS_MS = [500, 1e3, 2e3, 4e3, 8e3, 16e3];
@@ -2622,6 +2659,50 @@ async function processPaymentIntentCore(request, body, options = {}) {
2622
2659
  return handleRouteError(error, "Process payment intent", "Payment processing failed");
2623
2660
  }
2624
2661
  }
2662
+ async function attachBusinessDetailsCore(request, body, options = {}) {
2663
+ try {
2664
+ if (!body.paymentIntentId) {
2665
+ return {
2666
+ error: "paymentIntentId is required",
2667
+ status: 400
2668
+ };
2669
+ }
2670
+ const validation = (0, import_core4.validateBusinessDetails)({
2671
+ isBusiness: body.isBusiness,
2672
+ businessName: body.businessName,
2673
+ country: body.country,
2674
+ taxId: body.taxId,
2675
+ taxIdType: body.taxIdType
2676
+ });
2677
+ if (!validation.success) {
2678
+ const firstIssue = validation.error.issues[0];
2679
+ return {
2680
+ error: firstIssue?.message ?? "Invalid business details",
2681
+ status: 400
2682
+ };
2683
+ }
2684
+ const solvaPay = options.solvaPay || createSolvaPay();
2685
+ if (typeof solvaPay.attachBusinessDetails !== "function") {
2686
+ return {
2687
+ error: "attachBusinessDetails is not available on this SolvaPay client",
2688
+ status: 501
2689
+ };
2690
+ }
2691
+ const details = validation.data;
2692
+ const result = await solvaPay.attachBusinessDetails({
2693
+ paymentIntentId: body.paymentIntentId,
2694
+ ...body.customerRef !== void 0 && { customerRef: body.customerRef },
2695
+ ...details
2696
+ });
2697
+ return result;
2698
+ } catch (error) {
2699
+ return handleRouteError(
2700
+ error,
2701
+ "Attach business details",
2702
+ "Failed to attach business details"
2703
+ );
2704
+ }
2705
+ }
2625
2706
  async function processTopupPaymentIntentCore(request, body, options = {}) {
2626
2707
  try {
2627
2708
  if (!body.paymentIntentId) {
@@ -2745,7 +2826,7 @@ async function createCustomerSessionCore(request, options = {}) {
2745
2826
  }
2746
2827
 
2747
2828
  // src/helpers/renewal.ts
2748
- var import_core4 = require("@solvapay/core");
2829
+ var import_core5 = require("@solvapay/core");
2749
2830
  async function cancelPurchaseCore(request, body, options = {}) {
2750
2831
  try {
2751
2832
  if (!body.purchaseRef) {
@@ -2791,7 +2872,7 @@ async function cancelPurchaseCore(request, body, options = {}) {
2791
2872
  await new Promise((resolve) => setTimeout(resolve, 500));
2792
2873
  return cancelledPurchase;
2793
2874
  } catch (error) {
2794
- if (error instanceof import_core4.SolvaPayError) {
2875
+ if (error instanceof import_core5.SolvaPayError) {
2795
2876
  const errorMessage = error.message;
2796
2877
  if (errorMessage.includes("not found")) {
2797
2878
  return {
@@ -2859,7 +2940,7 @@ async function reactivatePurchaseCore(request, body, options = {}) {
2859
2940
  await new Promise((resolve) => setTimeout(resolve, 500));
2860
2941
  return reactivatedPurchase;
2861
2942
  } catch (error) {
2862
- if (error instanceof import_core4.SolvaPayError) {
2943
+ if (error instanceof import_core5.SolvaPayError) {
2863
2944
  const errorMessage = error.message;
2864
2945
  if (errorMessage.includes("not found")) {
2865
2946
  return {
@@ -2988,7 +3069,7 @@ async function disableAutoRechargeCore(request, options = {}) {
2988
3069
  }
2989
3070
 
2990
3071
  // src/helpers/plans.ts
2991
- var import_core5 = require("@solvapay/core");
3072
+ var import_core6 = require("@solvapay/core");
2992
3073
  async function listPlansCore(request, options = {}) {
2993
3074
  try {
2994
3075
  const url = new URL(request.url);
@@ -3000,7 +3081,7 @@ async function listPlansCore(request, options = {}) {
3000
3081
  };
3001
3082
  }
3002
3083
  const apiClient = options.solvaPay?.apiClient ?? (() => {
3003
- const config = (0, import_core5.getSolvaPayConfig)();
3084
+ const config = (0, import_core6.getSolvaPayConfig)();
3004
3085
  if (!config.apiKey) return null;
3005
3086
  return createSolvaPayClient({
3006
3087
  apiKey: config.apiKey,
@@ -3063,11 +3144,11 @@ async function checkLimitsCore(request, options = {}) {
3063
3144
  }
3064
3145
 
3065
3146
  // src/helpers/merchant.ts
3066
- var import_core6 = require("@solvapay/core");
3147
+ var import_core7 = require("@solvapay/core");
3067
3148
  async function getMerchantCore(_request, options = {}) {
3068
3149
  try {
3069
3150
  const apiClient = options.solvaPay?.apiClient ?? (() => {
3070
- const config = (0, import_core6.getSolvaPayConfig)();
3151
+ const config = (0, import_core7.getSolvaPayConfig)();
3071
3152
  if (!config.apiKey) return null;
3072
3153
  return createSolvaPayClient({
3073
3154
  apiKey: config.apiKey,
@@ -3094,7 +3175,7 @@ async function getMerchantCore(_request, options = {}) {
3094
3175
  }
3095
3176
 
3096
3177
  // src/helpers/product.ts
3097
- var import_core7 = require("@solvapay/core");
3178
+ var import_core8 = require("@solvapay/core");
3098
3179
  async function getProductCore(request, options = {}) {
3099
3180
  try {
3100
3181
  const url = new URL(request.url);
@@ -3106,7 +3187,7 @@ async function getProductCore(request, options = {}) {
3106
3187
  };
3107
3188
  }
3108
3189
  const apiClient = options.solvaPay?.apiClient ?? (() => {
3109
- const config = (0, import_core7.getSolvaPayConfig)();
3190
+ const config = (0, import_core8.getSolvaPayConfig)();
3110
3191
  if (!config.apiKey) return null;
3111
3192
  return createSolvaPayClient({
3112
3193
  apiKey: config.apiKey,
@@ -3254,34 +3335,34 @@ function verifyWebhook({
3254
3335
  secret
3255
3336
  }) {
3256
3337
  const toleranceSec = 300;
3257
- if (!signature) throw new import_core8.SolvaPayError("Missing webhook signature");
3338
+ if (!signature) throw new import_core9.SolvaPayError("Missing webhook signature");
3258
3339
  const parts = signature.split(",");
3259
3340
  const tPart = parts.find((p) => p.startsWith("t="));
3260
3341
  const v1Part = parts.find((p) => p.startsWith("v1="));
3261
3342
  if (!tPart || !v1Part) {
3262
- throw new import_core8.SolvaPayError("Malformed webhook signature");
3343
+ throw new import_core9.SolvaPayError("Malformed webhook signature");
3263
3344
  }
3264
3345
  const timestamp = parseInt(tPart.slice(2), 10);
3265
3346
  const receivedHmac = v1Part.slice(3);
3266
3347
  if (Number.isNaN(timestamp) || !receivedHmac) {
3267
- throw new import_core8.SolvaPayError("Malformed webhook signature");
3348
+ throw new import_core9.SolvaPayError("Malformed webhook signature");
3268
3349
  }
3269
3350
  if (toleranceSec > 0) {
3270
3351
  const age = Math.abs(Math.floor(Date.now() / 1e3) - timestamp);
3271
3352
  if (age > toleranceSec) {
3272
- throw new import_core8.SolvaPayError("Webhook signature timestamp too old");
3353
+ throw new import_core9.SolvaPayError("Webhook signature timestamp too old");
3273
3354
  }
3274
3355
  }
3275
3356
  const expectedHmac = import_node_crypto.default.createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
3276
3357
  if (receivedHmac.length !== expectedHmac.length) {
3277
- throw new import_core8.SolvaPayError("Invalid webhook signature");
3358
+ throw new import_core9.SolvaPayError("Invalid webhook signature");
3278
3359
  }
3279
3360
  const ok = import_node_crypto.default.timingSafeEqual(Buffer.from(expectedHmac), Buffer.from(receivedHmac));
3280
- if (!ok) throw new import_core8.SolvaPayError("Invalid webhook signature");
3361
+ if (!ok) throw new import_core9.SolvaPayError("Invalid webhook signature");
3281
3362
  try {
3282
3363
  return JSON.parse(body);
3283
3364
  } catch {
3284
- throw new import_core8.SolvaPayError("Invalid webhook payload: body is not valid JSON");
3365
+ throw new import_core9.SolvaPayError("Invalid webhook payload: body is not valid JSON");
3285
3366
  }
3286
3367
  }
3287
3368
  // Annotate the CommonJS export names for ESM import in node:
@@ -3291,6 +3372,7 @@ function verifyWebhook({
3291
3372
  TOPUP_BALANCE_POLL_DELAYS_MS,
3292
3373
  VIRTUAL_TOOL_DEFINITIONS,
3293
3374
  activatePlanCore,
3375
+ attachBusinessDetailsCore,
3294
3376
  buildGateMessage,
3295
3377
  buildNudgeMessage,
3296
3378
  buildPaywallGate,
package/dist/index.d.cts CHANGED
@@ -1,3 +1,6 @@
1
+ import * as _solvapay_core from '@solvapay/core';
2
+ import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
3
+
1
4
  interface components {
2
5
  schemas: {
3
6
  SdkMerchantResponseDto: {
@@ -243,6 +246,28 @@ interface components {
243
246
  customerRef: string;
244
247
  planRef?: string;
245
248
  };
249
+ BusinessDetailsDto: {
250
+ /** Whether the purchase is on behalf of a business */
251
+ isBusiness: boolean;
252
+ /** Legal business name */
253
+ businessName?: string;
254
+ /** ISO 3166-1 alpha-2 country code */
255
+ country?: string;
256
+ /** Tax / VAT identification number */
257
+ taxId?: string;
258
+ };
259
+ TaxBreakdownResponse: {
260
+ subtotal: number;
261
+ taxAmount: number;
262
+ taxRate: number;
263
+ treatment: "reverse_charge" | "standard" | "none" | "not_collecting";
264
+ total: number;
265
+ currency: string;
266
+ inclusive: boolean;
267
+ };
268
+ AttachBusinessDetailsResponse: {
269
+ taxBreakdown: components["schemas"]["TaxBreakdownResponse"];
270
+ };
246
271
  CreateCheckoutSessionResponse: {
247
272
  /**
248
273
  * Checkout session ID/token
@@ -403,6 +428,11 @@ interface components {
403
428
  createdAt: string;
404
429
  /** @description Last update timestamp */
405
430
  updatedAt: string;
431
+ /**
432
+ * Tax inclusion behavior for business checkout
433
+ * @enum {string}
434
+ */
435
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
406
436
  };
407
437
  CreatePlanRequest: {
408
438
  name: string;
@@ -450,6 +480,8 @@ interface components {
450
480
  maxActiveUsers?: number;
451
481
  accessExpiryDays?: number;
452
482
  default?: boolean;
483
+ /** @enum {string} */
484
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
453
485
  };
454
486
  UpdatePlanRequest: {
455
487
  name?: string;
@@ -484,6 +516,8 @@ interface components {
484
516
  [key: string]: unknown;
485
517
  };
486
518
  default?: boolean;
519
+ /** @enum {string} */
520
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
487
521
  };
488
522
  CreateProductRequest: {
489
523
  name: string;
@@ -1673,6 +1707,51 @@ interface operations {
1673
1707
  };
1674
1708
  };
1675
1709
  };
1710
+ PaymentIntentSdkController_attachBusinessDetails: {
1711
+ parameters: {
1712
+ query?: never;
1713
+ header?: never;
1714
+ path: {
1715
+ /** @description Stripe payment intent ID */
1716
+ processorPaymentId: string;
1717
+ };
1718
+ cookie?: never;
1719
+ };
1720
+ requestBody: {
1721
+ content: {
1722
+ "application/json": components["schemas"]["BusinessDetailsDto"];
1723
+ };
1724
+ };
1725
+ responses: {
1726
+ /** @description Tax breakdown after applying business details */
1727
+ 200: {
1728
+ headers: {
1729
+ [name: string]: unknown;
1730
+ };
1731
+ content: {
1732
+ "application/json": components["schemas"]["AttachBusinessDetailsResponse"];
1733
+ };
1734
+ };
1735
+ /** @description Invalid business details or payment intent state */
1736
+ 400: {
1737
+ headers: {
1738
+ [name: string]: unknown;
1739
+ };
1740
+ content: {
1741
+ "application/json": unknown;
1742
+ };
1743
+ };
1744
+ /** @description Payment intent not found */
1745
+ 404: {
1746
+ headers: {
1747
+ [name: string]: unknown;
1748
+ };
1749
+ content: {
1750
+ "application/json": unknown;
1751
+ };
1752
+ };
1753
+ };
1754
+ };
1676
1755
  CheckoutSessionSdkController_createCheckoutSession: {
1677
1756
  parameters: {
1678
1757
  query?: never;
@@ -2999,6 +3078,13 @@ type WebhookEvent = {
2999
3078
  * Types related to the SolvaPay API client and backend communication.
3000
3079
  */
3001
3080
 
3081
+ type AttachBusinessDetailsParams = {
3082
+ paymentIntentId: string;
3083
+ customerRef?: string;
3084
+ } & BusinessDetailsInput;
3085
+ type AttachBusinessDetailsResult = {
3086
+ taxBreakdown: TaxBreakdown;
3087
+ };
3002
3088
  type CheckLimitsRequest = components['schemas']['CheckLimitRequest'] & {
3003
3089
  /**
3004
3090
  * When `true`, the backend mints a checkout session (or customer
@@ -3383,6 +3469,7 @@ interface SolvaPayClient {
3383
3469
  customerRef: string;
3384
3470
  planRef?: string;
3385
3471
  }): Promise<ProcessPaymentResult>;
3472
+ attachBusinessDetails?(params: AttachBusinessDetailsParams): Promise<AttachBusinessDetailsResult>;
3386
3473
  getUserInfo?(params: {
3387
3474
  customerRef: string;
3388
3475
  productRef: string;
@@ -4137,6 +4224,21 @@ interface SolvaPay {
4137
4224
  customerRef: string;
4138
4225
  planRef?: string;
4139
4226
  }): Promise<ProcessPaymentResult>;
4227
+ /**
4228
+ * Attach business purchase details to a payment intent
4229
+ * and retrieve the computed tax breakdown.
4230
+ */
4231
+ attachBusinessDetails(params: {
4232
+ paymentIntentId: string;
4233
+ customerRef?: string;
4234
+ isBusiness: boolean;
4235
+ businessName?: string;
4236
+ country?: string;
4237
+ taxId?: string;
4238
+ taxIdType?: _solvapay_core.TaxIdType;
4239
+ }): Promise<{
4240
+ taxBreakdown: _solvapay_core.TaxBreakdown;
4241
+ }>;
4140
4242
  /**
4141
4243
  * Check if customer is within usage limits for a product.
4142
4244
  *
@@ -5152,6 +5254,21 @@ declare function processPaymentIntentCore(request: Request, body: {
5152
5254
  * }
5153
5255
  * ```
5154
5256
  */
5257
+ /**
5258
+ * Attach business purchase details to a credit-topup payment intent and
5259
+ * retrieve the computed tax breakdown.
5260
+ *
5261
+ * Validates business fields client-side via `@solvapay/core` before
5262
+ * forwarding to the SolvaPay backend.
5263
+ */
5264
+ declare function attachBusinessDetailsCore(request: Request, body: {
5265
+ paymentIntentId: string;
5266
+ customerRef?: string;
5267
+ } & BusinessDetailsInput, options?: {
5268
+ solvaPay?: SolvaPay;
5269
+ }): Promise<{
5270
+ taxBreakdown: TaxBreakdown;
5271
+ } | ErrorResult>;
5155
5272
  declare function processTopupPaymentIntentCore(request: Request, body: {
5156
5273
  paymentIntentId: string;
5157
5274
  }, options?: {
@@ -5484,4 +5601,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
5484
5601
  secret: string;
5485
5602
  }): WebhookEvent;
5486
5603
 
5487
- export { type ActivatePlanResult, type AssignCreditsRequest, type AssignCreditsResponse, type AuthenticatedUser, type AutoRechargeConfig, type AutoRechargeDisplayBlock, type AutoRechargeInput, type AutoRechargeResponse, BALANCE_RECONCILE_DELAYS_MS, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CreditDebitResult, type CreditDebitSkipReason, type CreditDisplayBlock, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpServerLike, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, type ProcessPaymentResult, type ProtectHandlerContext, type PurchaseCheckResult, type RegisterVirtualToolsMcpOptions, type RetryOptions, type SaveAutoRechargeInput, type SaveAutoRechargeResponse, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, TOPUP_BALANCE_POLL_DELAYS_MS, type ToolPlanMappingInput, type TopupProcessResult, type TrackUsageBulkRequest, type TrackUsageBulkResponse, type TrackUsageRequest, type TrackUsageResponse, VIRTUAL_TOOL_DEFINITIONS, type VirtualToolDefinition, type VirtualToolsOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, createVirtualTools, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, jsonSchemaToZodRawShape, listPlansCore, paywallErrorToClientPayload, pollBalanceUntilIncreased, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, registerVirtualToolsMcpImpl, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyWebhook, withRetry };
5604
+ export { type ActivatePlanResult, type AssignCreditsRequest, type AssignCreditsResponse, type AuthenticatedUser, type AutoRechargeConfig, type AutoRechargeDisplayBlock, type AutoRechargeInput, type AutoRechargeResponse, BALANCE_RECONCILE_DELAYS_MS, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CreditDebitResult, type CreditDebitSkipReason, type CreditDisplayBlock, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpServerLike, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, type ProcessPaymentResult, type ProtectHandlerContext, type PurchaseCheckResult, type RegisterVirtualToolsMcpOptions, type RetryOptions, type SaveAutoRechargeInput, type SaveAutoRechargeResponse, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, TOPUP_BALANCE_POLL_DELAYS_MS, type ToolPlanMappingInput, type TopupProcessResult, type TrackUsageBulkRequest, type TrackUsageBulkResponse, type TrackUsageRequest, type TrackUsageResponse, VIRTUAL_TOOL_DEFINITIONS, type VirtualToolDefinition, type VirtualToolsOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, attachBusinessDetailsCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, createVirtualTools, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, jsonSchemaToZodRawShape, listPlansCore, paywallErrorToClientPayload, pollBalanceUntilIncreased, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, registerVirtualToolsMcpImpl, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyWebhook, withRetry };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import * as _solvapay_core from '@solvapay/core';
2
+ import { BusinessDetailsInput, TaxBreakdown } from '@solvapay/core';
3
+
1
4
  interface components {
2
5
  schemas: {
3
6
  SdkMerchantResponseDto: {
@@ -243,6 +246,28 @@ interface components {
243
246
  customerRef: string;
244
247
  planRef?: string;
245
248
  };
249
+ BusinessDetailsDto: {
250
+ /** Whether the purchase is on behalf of a business */
251
+ isBusiness: boolean;
252
+ /** Legal business name */
253
+ businessName?: string;
254
+ /** ISO 3166-1 alpha-2 country code */
255
+ country?: string;
256
+ /** Tax / VAT identification number */
257
+ taxId?: string;
258
+ };
259
+ TaxBreakdownResponse: {
260
+ subtotal: number;
261
+ taxAmount: number;
262
+ taxRate: number;
263
+ treatment: "reverse_charge" | "standard" | "none" | "not_collecting";
264
+ total: number;
265
+ currency: string;
266
+ inclusive: boolean;
267
+ };
268
+ AttachBusinessDetailsResponse: {
269
+ taxBreakdown: components["schemas"]["TaxBreakdownResponse"];
270
+ };
246
271
  CreateCheckoutSessionResponse: {
247
272
  /**
248
273
  * Checkout session ID/token
@@ -403,6 +428,11 @@ interface components {
403
428
  createdAt: string;
404
429
  /** @description Last update timestamp */
405
430
  updatedAt: string;
431
+ /**
432
+ * Tax inclusion behavior for business checkout
433
+ * @enum {string}
434
+ */
435
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
406
436
  };
407
437
  CreatePlanRequest: {
408
438
  name: string;
@@ -450,6 +480,8 @@ interface components {
450
480
  maxActiveUsers?: number;
451
481
  accessExpiryDays?: number;
452
482
  default?: boolean;
483
+ /** @enum {string} */
484
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
453
485
  };
454
486
  UpdatePlanRequest: {
455
487
  name?: string;
@@ -484,6 +516,8 @@ interface components {
484
516
  [key: string]: unknown;
485
517
  };
486
518
  default?: boolean;
519
+ /** @enum {string} */
520
+ taxBehavior?: "auto" | "inclusive" | "exclusive";
487
521
  };
488
522
  CreateProductRequest: {
489
523
  name: string;
@@ -1673,6 +1707,51 @@ interface operations {
1673
1707
  };
1674
1708
  };
1675
1709
  };
1710
+ PaymentIntentSdkController_attachBusinessDetails: {
1711
+ parameters: {
1712
+ query?: never;
1713
+ header?: never;
1714
+ path: {
1715
+ /** @description Stripe payment intent ID */
1716
+ processorPaymentId: string;
1717
+ };
1718
+ cookie?: never;
1719
+ };
1720
+ requestBody: {
1721
+ content: {
1722
+ "application/json": components["schemas"]["BusinessDetailsDto"];
1723
+ };
1724
+ };
1725
+ responses: {
1726
+ /** @description Tax breakdown after applying business details */
1727
+ 200: {
1728
+ headers: {
1729
+ [name: string]: unknown;
1730
+ };
1731
+ content: {
1732
+ "application/json": components["schemas"]["AttachBusinessDetailsResponse"];
1733
+ };
1734
+ };
1735
+ /** @description Invalid business details or payment intent state */
1736
+ 400: {
1737
+ headers: {
1738
+ [name: string]: unknown;
1739
+ };
1740
+ content: {
1741
+ "application/json": unknown;
1742
+ };
1743
+ };
1744
+ /** @description Payment intent not found */
1745
+ 404: {
1746
+ headers: {
1747
+ [name: string]: unknown;
1748
+ };
1749
+ content: {
1750
+ "application/json": unknown;
1751
+ };
1752
+ };
1753
+ };
1754
+ };
1676
1755
  CheckoutSessionSdkController_createCheckoutSession: {
1677
1756
  parameters: {
1678
1757
  query?: never;
@@ -2999,6 +3078,13 @@ type WebhookEvent = {
2999
3078
  * Types related to the SolvaPay API client and backend communication.
3000
3079
  */
3001
3080
 
3081
+ type AttachBusinessDetailsParams = {
3082
+ paymentIntentId: string;
3083
+ customerRef?: string;
3084
+ } & BusinessDetailsInput;
3085
+ type AttachBusinessDetailsResult = {
3086
+ taxBreakdown: TaxBreakdown;
3087
+ };
3002
3088
  type CheckLimitsRequest = components['schemas']['CheckLimitRequest'] & {
3003
3089
  /**
3004
3090
  * When `true`, the backend mints a checkout session (or customer
@@ -3383,6 +3469,7 @@ interface SolvaPayClient {
3383
3469
  customerRef: string;
3384
3470
  planRef?: string;
3385
3471
  }): Promise<ProcessPaymentResult>;
3472
+ attachBusinessDetails?(params: AttachBusinessDetailsParams): Promise<AttachBusinessDetailsResult>;
3386
3473
  getUserInfo?(params: {
3387
3474
  customerRef: string;
3388
3475
  productRef: string;
@@ -4137,6 +4224,21 @@ interface SolvaPay {
4137
4224
  customerRef: string;
4138
4225
  planRef?: string;
4139
4226
  }): Promise<ProcessPaymentResult>;
4227
+ /**
4228
+ * Attach business purchase details to a payment intent
4229
+ * and retrieve the computed tax breakdown.
4230
+ */
4231
+ attachBusinessDetails(params: {
4232
+ paymentIntentId: string;
4233
+ customerRef?: string;
4234
+ isBusiness: boolean;
4235
+ businessName?: string;
4236
+ country?: string;
4237
+ taxId?: string;
4238
+ taxIdType?: _solvapay_core.TaxIdType;
4239
+ }): Promise<{
4240
+ taxBreakdown: _solvapay_core.TaxBreakdown;
4241
+ }>;
4140
4242
  /**
4141
4243
  * Check if customer is within usage limits for a product.
4142
4244
  *
@@ -5152,6 +5254,21 @@ declare function processPaymentIntentCore(request: Request, body: {
5152
5254
  * }
5153
5255
  * ```
5154
5256
  */
5257
+ /**
5258
+ * Attach business purchase details to a credit-topup payment intent and
5259
+ * retrieve the computed tax breakdown.
5260
+ *
5261
+ * Validates business fields client-side via `@solvapay/core` before
5262
+ * forwarding to the SolvaPay backend.
5263
+ */
5264
+ declare function attachBusinessDetailsCore(request: Request, body: {
5265
+ paymentIntentId: string;
5266
+ customerRef?: string;
5267
+ } & BusinessDetailsInput, options?: {
5268
+ solvaPay?: SolvaPay;
5269
+ }): Promise<{
5270
+ taxBreakdown: TaxBreakdown;
5271
+ } | ErrorResult>;
5155
5272
  declare function processTopupPaymentIntentCore(request: Request, body: {
5156
5273
  paymentIntentId: string;
5157
5274
  }, options?: {
@@ -5484,4 +5601,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
5484
5601
  secret: string;
5485
5602
  }): WebhookEvent;
5486
5603
 
5487
- export { type ActivatePlanResult, type AssignCreditsRequest, type AssignCreditsResponse, type AuthenticatedUser, type AutoRechargeConfig, type AutoRechargeDisplayBlock, type AutoRechargeInput, type AutoRechargeResponse, BALANCE_RECONCILE_DELAYS_MS, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CreditDebitResult, type CreditDebitSkipReason, type CreditDisplayBlock, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpServerLike, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, type ProcessPaymentResult, type ProtectHandlerContext, type PurchaseCheckResult, type RegisterVirtualToolsMcpOptions, type RetryOptions, type SaveAutoRechargeInput, type SaveAutoRechargeResponse, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, TOPUP_BALANCE_POLL_DELAYS_MS, type ToolPlanMappingInput, type TopupProcessResult, type TrackUsageBulkRequest, type TrackUsageBulkResponse, type TrackUsageRequest, type TrackUsageResponse, VIRTUAL_TOOL_DEFINITIONS, type VirtualToolDefinition, type VirtualToolsOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, createVirtualTools, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, jsonSchemaToZodRawShape, listPlansCore, paywallErrorToClientPayload, pollBalanceUntilIncreased, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, registerVirtualToolsMcpImpl, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyWebhook, withRetry };
5604
+ export { type ActivatePlanResult, type AssignCreditsRequest, type AssignCreditsResponse, type AuthenticatedUser, type AutoRechargeConfig, type AutoRechargeDisplayBlock, type AutoRechargeInput, type AutoRechargeResponse, BALANCE_RECONCILE_DELAYS_MS, type ConfigureMcpPlansRequest, type ConfigureMcpPlansResponse, type CreateSolvaPayConfig, type CreditDebitResult, type CreditDebitSkipReason, type CreditDisplayBlock, type CustomerBalanceResult, type CustomerResponseMapped, type CustomerWebhookObject, type ErrorResult, type GetUsageResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type LimitResponseWithPlan, type McpBootstrapPlanInput, type McpBootstrapRequest, type McpBootstrapResponse, type McpServerLike, type McpToolPlanMappingInput, type NextAdapterOptions, type OneTimePurchaseInfo, type PayableAllowResult, type PayableFunction, type PayableGateOptions, type PayableGateResult, type PayableOptions, type PayablePaywallResult, type PaymentMethodInfo, type PaywallArgs, type PaywallDecision, PaywallError, type PaywallMetadata, type PaywallState, type PaywallStructuredContent, type ProcessPaymentResult, type ProtectHandlerContext, type PurchaseCheckResult, type RegisterVirtualToolsMcpOptions, type RetryOptions, type SaveAutoRechargeInput, type SaveAutoRechargeResponse, type SdkMerchantResponse, type SdkProductResponse, type ServerClientOptions, type SolvaPay, type SolvaPayClient, TOPUP_BALANCE_POLL_DELAYS_MS, type ToolPlanMappingInput, type TopupProcessResult, type TrackUsageBulkRequest, type TrackUsageBulkResponse, type TrackUsageRequest, type TrackUsageResponse, VIRTUAL_TOOL_DEFINITIONS, type VirtualToolDefinition, type VirtualToolsOptions, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, attachBusinessDetailsCore, buildGateMessage, buildNudgeMessage, buildPaywallGate, cancelPurchaseCore, checkLimitsCore, checkPurchaseCore, classifyPaywallState, type components, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, createVirtualTools, disableAutoRechargeCore, getAuthenticatedUserCore, getAutoRechargeCore, getCustomerBalanceCore, getMerchantCore, getPaymentMethodCore, getProductCore, getUsageCore, handleRouteError, isErrorResult, isPaywallStructuredContent, jsonSchemaToZodRawShape, listPlansCore, paywallErrorToClientPayload, pollBalanceUntilIncreased, processPaymentIntentCore, processTopupPaymentIntentCore, reactivatePurchaseCore, registerVirtualToolsMcpImpl, saveAutoRechargeCore, syncCustomerCore, trackUsageCore, verifyWebhook, withRetry };