@solvapay/server 1.0.7 → 1.0.8-preview.10
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/edge.d.ts +156 -5
- package/dist/edge.js +432 -24
- package/dist/index.cjs +328 -33
- package/dist/index.d.cts +112 -5
- package/dist/index.d.ts +112 -5
- package/dist/index.js +316 -25
- package/package.json +6 -6
package/dist/edge.d.ts
CHANGED
|
@@ -2488,6 +2488,26 @@ interface ProcessPaymentResult {
|
|
|
2488
2488
|
status: 'completed';
|
|
2489
2489
|
}
|
|
2490
2490
|
type ActivatePlanResult = components['schemas']['ActivatePlanResponseDto'];
|
|
2491
|
+
/**
|
|
2492
|
+
* SDK-facing merchant identity (source: GET /v1/sdk/merchant).
|
|
2493
|
+
*
|
|
2494
|
+
* Hand-typed here until the OpenAPI generator picks up the new endpoint.
|
|
2495
|
+
* Fields match `SdkMerchantResponseDto` on the backend.
|
|
2496
|
+
*/
|
|
2497
|
+
type SdkMerchantResponse = {
|
|
2498
|
+
displayName: string;
|
|
2499
|
+
legalName: string;
|
|
2500
|
+
supportEmail?: string;
|
|
2501
|
+
supportUrl?: string;
|
|
2502
|
+
termsUrl?: string;
|
|
2503
|
+
privacyUrl?: string;
|
|
2504
|
+
country?: string;
|
|
2505
|
+
defaultCurrency?: string;
|
|
2506
|
+
statementDescriptor?: string;
|
|
2507
|
+
logoUrl?: string;
|
|
2508
|
+
};
|
|
2509
|
+
/** SDK-facing product projection. Sourced from the existing OpenAPI spec. */
|
|
2510
|
+
type SdkProductResponse = components['schemas']['SdkProductResponse'];
|
|
2491
2511
|
type McpBootstrapRequest = components['schemas']['McpBootstrapDto'];
|
|
2492
2512
|
interface McpBootstrapResponse {
|
|
2493
2513
|
product: components['schemas']['SdkProductResponse'];
|
|
@@ -2553,6 +2573,13 @@ interface SolvaPayClient {
|
|
|
2553
2573
|
externalRef?: string;
|
|
2554
2574
|
email?: string;
|
|
2555
2575
|
}): Promise<CustomerResponseMapped>;
|
|
2576
|
+
/**
|
|
2577
|
+
* SDK-facing merchant identity (GET /v1/sdk/merchant).
|
|
2578
|
+
* Returns the subset of provider fields safe for browser consumption —
|
|
2579
|
+
* used by `<MandateText>`, `<CheckoutSummary>`, and trust signals.
|
|
2580
|
+
*/
|
|
2581
|
+
getMerchant?(): Promise<SdkMerchantResponse>;
|
|
2582
|
+
getProduct?(productRef: string): Promise<SdkProductResponse>;
|
|
2556
2583
|
listProducts?(): Promise<Array<{
|
|
2557
2584
|
reference: string;
|
|
2558
2585
|
name: string;
|
|
@@ -3693,8 +3720,16 @@ declare function handleRouteError(error: unknown, operationName: string, default
|
|
|
3693
3720
|
* and name from authenticated requests. Works with any framework that uses
|
|
3694
3721
|
* the standard Web API Request (Express, Fastify, Next.js, Edge Functions, etc.).
|
|
3695
3722
|
*
|
|
3696
|
-
*
|
|
3697
|
-
*
|
|
3723
|
+
* Resolution order:
|
|
3724
|
+
* 1. `x-user-id` header — set by Next.js-style middleware (unchanged).
|
|
3725
|
+
* 2. `Authorization: Bearer <jwt>` — verified via HS256 when a secret is
|
|
3726
|
+
* configured (`SOLVAPAY_JWT_SECRET` or `SUPABASE_JWT_SECRET`), or
|
|
3727
|
+
* unverified-decoded when no secret is configured. The unverified path
|
|
3728
|
+
* covers platforms that verify JWTs at the gateway (e.g. Supabase Edge
|
|
3729
|
+
* with `verify_jwt = true`, which is the default) and asymmetric signing
|
|
3730
|
+
* keys (ES256/RS256) that the SDK does not have keys for.
|
|
3731
|
+
* 3. Set `SOLVAPAY_AUTH_STRICT=true` to require cryptographic verification
|
|
3732
|
+
* inside the handler (the unverified-decode fallback is then disabled).
|
|
3698
3733
|
*
|
|
3699
3734
|
* @param request - Standard Web API Request object
|
|
3700
3735
|
* @param options - Configuration options
|
|
@@ -3733,6 +3768,13 @@ declare function getAuthenticatedUserCore(request: Request, options?: {
|
|
|
3733
3768
|
* Works with standard Web API Request (works everywhere).
|
|
3734
3769
|
*/
|
|
3735
3770
|
|
|
3771
|
+
type CustomerBalanceResult = {
|
|
3772
|
+
customerRef: string;
|
|
3773
|
+
credits: number;
|
|
3774
|
+
displayCurrency: string;
|
|
3775
|
+
creditsPerMinorUnit: number;
|
|
3776
|
+
displayExchangeRate: number;
|
|
3777
|
+
};
|
|
3736
3778
|
/**
|
|
3737
3779
|
* Sync customer with SolvaPay backend (ensure customer exists).
|
|
3738
3780
|
*
|
|
@@ -3775,6 +3817,18 @@ declare function syncCustomerCore(request: Request, options?: {
|
|
|
3775
3817
|
includeEmail?: boolean;
|
|
3776
3818
|
includeName?: boolean;
|
|
3777
3819
|
}): Promise<string | ErrorResult>;
|
|
3820
|
+
/**
|
|
3821
|
+
* Get credits for the authenticated customer.
|
|
3822
|
+
*
|
|
3823
|
+
* Authenticates the request, syncs the customer, then fetches credits.
|
|
3824
|
+
*
|
|
3825
|
+
* @param request - Standard Web API Request object
|
|
3826
|
+
* @param options - Configuration options
|
|
3827
|
+
* @returns Customer credits result or error result
|
|
3828
|
+
*/
|
|
3829
|
+
declare function getCustomerBalanceCore(request: Request, options?: {
|
|
3830
|
+
solvaPay?: SolvaPay;
|
|
3831
|
+
}): Promise<CustomerBalanceResult | ErrorResult>;
|
|
3778
3832
|
|
|
3779
3833
|
/**
|
|
3780
3834
|
* Create a payment intent for a customer to purchase a plan.
|
|
@@ -3969,6 +4023,31 @@ declare function cancelPurchaseCore(request: Request, body: {
|
|
|
3969
4023
|
}, options?: {
|
|
3970
4024
|
solvaPay?: SolvaPay;
|
|
3971
4025
|
}): Promise<Record<string, unknown> | ErrorResult>;
|
|
4026
|
+
/**
|
|
4027
|
+
* Reactivate purchase - core implementation
|
|
4028
|
+
*
|
|
4029
|
+
* Undoes a pending cancellation, restoring auto-renewal and clearing cancellation fields.
|
|
4030
|
+
* Only works while the purchase is still active and the end date hasn't passed.
|
|
4031
|
+
*
|
|
4032
|
+
* @param request - Standard Web API Request
|
|
4033
|
+
* @param body - Reactivation parameters
|
|
4034
|
+
* @param options - Configuration options
|
|
4035
|
+
* @returns Reactivated purchase response or error result
|
|
4036
|
+
*/
|
|
4037
|
+
declare function reactivatePurchaseCore(request: Request, body: {
|
|
4038
|
+
purchaseRef: string;
|
|
4039
|
+
}, options?: {
|
|
4040
|
+
solvaPay?: SolvaPay;
|
|
4041
|
+
}): Promise<Record<string, unknown> | ErrorResult>;
|
|
4042
|
+
|
|
4043
|
+
declare function activatePlanCore(request: Request, body: {
|
|
4044
|
+
productRef: string;
|
|
4045
|
+
planRef: string;
|
|
4046
|
+
}, options?: {
|
|
4047
|
+
solvaPay?: SolvaPay;
|
|
4048
|
+
includeEmail?: boolean;
|
|
4049
|
+
includeName?: boolean;
|
|
4050
|
+
}): Promise<ActivatePlanResult | ErrorResult>;
|
|
3972
4051
|
|
|
3973
4052
|
/**
|
|
3974
4053
|
* Plans Helper (Core)
|
|
@@ -3980,13 +4059,85 @@ declare function cancelPurchaseCore(request: Request, body: {
|
|
|
3980
4059
|
|
|
3981
4060
|
type Plan = components['schemas']['Plan'];
|
|
3982
4061
|
/**
|
|
3983
|
-
* List plans - core implementation
|
|
4062
|
+
* List plans - core implementation.
|
|
4063
|
+
*
|
|
4064
|
+
* Pass `options.solvaPay` to route through a pre-configured SolvaPay instance
|
|
4065
|
+
* (e.g. stub-backed in examples). When omitted, the helper reads
|
|
4066
|
+
* `SOLVAPAY_SECRET_KEY` from environment and constructs a real API client.
|
|
3984
4067
|
*/
|
|
3985
|
-
declare function listPlansCore(request: Request
|
|
4068
|
+
declare function listPlansCore(request: Request, options?: {
|
|
4069
|
+
solvaPay?: SolvaPay;
|
|
4070
|
+
}): Promise<{
|
|
3986
4071
|
plans: Plan[];
|
|
3987
4072
|
productRef: string;
|
|
3988
4073
|
} | ErrorResult>;
|
|
3989
4074
|
|
|
4075
|
+
/**
|
|
4076
|
+
* Merchant Helper (Core)
|
|
4077
|
+
*
|
|
4078
|
+
* Generic helper for GET /api/merchant — returns the SDK-facing merchant
|
|
4079
|
+
* identity used by `<MandateText>`, `<CheckoutSummary>`, and trust signals.
|
|
4080
|
+
* Works with standard Web API Request (Express, Fastify, Next.js, Edge).
|
|
4081
|
+
*/
|
|
4082
|
+
|
|
4083
|
+
declare function getMerchantCore(_request: Request, options?: {
|
|
4084
|
+
solvaPay?: SolvaPay;
|
|
4085
|
+
}): Promise<SdkMerchantResponse | ErrorResult>;
|
|
4086
|
+
|
|
4087
|
+
/**
|
|
4088
|
+
* Product Helper (Core)
|
|
4089
|
+
*
|
|
4090
|
+
* Generic helper for GET /api/get-product?productRef=...
|
|
4091
|
+
* Returns a single product by reference, used by the `useProduct` React hook.
|
|
4092
|
+
*/
|
|
4093
|
+
|
|
4094
|
+
declare function getProductCore(request: Request, options?: {
|
|
4095
|
+
solvaPay?: SolvaPay;
|
|
4096
|
+
}): Promise<SdkProductResponse | ErrorResult>;
|
|
4097
|
+
|
|
4098
|
+
interface PurchaseCheckResult {
|
|
4099
|
+
customerRef: string;
|
|
4100
|
+
email?: string;
|
|
4101
|
+
name?: string;
|
|
4102
|
+
purchases: Array<{
|
|
4103
|
+
reference: string;
|
|
4104
|
+
productName?: string;
|
|
4105
|
+
productRef?: string;
|
|
4106
|
+
status?: string;
|
|
4107
|
+
startDate?: string;
|
|
4108
|
+
planSnapshot?: {
|
|
4109
|
+
meterId?: string;
|
|
4110
|
+
limit?: number;
|
|
4111
|
+
freeUnits?: number;
|
|
4112
|
+
};
|
|
4113
|
+
usage?: {
|
|
4114
|
+
used?: number;
|
|
4115
|
+
overageUnits?: number;
|
|
4116
|
+
overageCost?: number;
|
|
4117
|
+
periodStart?: string;
|
|
4118
|
+
periodEnd?: string;
|
|
4119
|
+
};
|
|
4120
|
+
[key: string]: unknown;
|
|
4121
|
+
}>;
|
|
4122
|
+
}
|
|
4123
|
+
declare function checkPurchaseCore(request: Request, options?: {
|
|
4124
|
+
solvaPay?: SolvaPay;
|
|
4125
|
+
includeEmail?: boolean;
|
|
4126
|
+
includeName?: boolean;
|
|
4127
|
+
}): Promise<PurchaseCheckResult | ErrorResult>;
|
|
4128
|
+
|
|
4129
|
+
declare function trackUsageCore(request: Request, body: {
|
|
4130
|
+
actionType?: 'transaction' | 'api_call' | 'hour' | 'email' | 'storage' | 'custom';
|
|
4131
|
+
units?: number;
|
|
4132
|
+
productRef?: string;
|
|
4133
|
+
description?: string;
|
|
4134
|
+
metadata?: Record<string, unknown>;
|
|
4135
|
+
}, options?: {
|
|
4136
|
+
solvaPay?: SolvaPay;
|
|
4137
|
+
}): Promise<{
|
|
4138
|
+
success: true;
|
|
4139
|
+
} | ErrorResult>;
|
|
4140
|
+
|
|
3990
4141
|
/**
|
|
3991
4142
|
* SolvaPay Server SDK - Edge Runtime Entry Point
|
|
3992
4143
|
*
|
|
@@ -4000,4 +4151,4 @@ declare function verifyWebhook({ body, signature, secret, }: {
|
|
|
4000
4151
|
secret: string;
|
|
4001
4152
|
}): Promise<WebhookEvent>;
|
|
4002
4153
|
|
|
4003
|
-
export { type AuthenticatedUser, type CreateSolvaPayConfig, type CustomerWebhookObject, type ErrorResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, cancelPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, getAuthenticatedUserCore, handleRouteError, isErrorResult, listPlansCore, paywallErrorToClientPayload, processPaymentIntentCore, syncCustomerCore, verifyWebhook, withRetry };
|
|
4154
|
+
export { type AuthenticatedUser, type CreateSolvaPayConfig, type CustomerBalanceResult, type CustomerWebhookObject, type ErrorResult, type HttpAdapterOptions, type LimitActivationBalance, type LimitActivationProduct, type LimitPlanSummary, type McpAdapterOptions, type NextAdapterOptions, type PayableFunction, type PayableOptions, type PaywallArgs, PaywallError, type PaywallMetadata, type PaywallStructuredContent, type PaywallToolResult, type PurchaseCheckResult, type RetryOptions, type ServerClientOptions, type SolvaPay, type SolvaPayClient, type WebhookEvent, type WebhookEventForType, type WebhookEventObjectMap, type WebhookEventType, type WebhookProduct, activatePlanCore, cancelPurchaseCore, checkPurchaseCore, createCheckoutSessionCore, createCustomerSessionCore, createPaymentIntentCore, createSolvaPay, createSolvaPayClient, createTopupPaymentIntentCore, getAuthenticatedUserCore, getCustomerBalanceCore, getMerchantCore, getProductCore, handleRouteError, isErrorResult, listPlansCore, paywallErrorToClientPayload, processPaymentIntentCore, reactivatePurchaseCore, syncCustomerCore, trackUsageCore, verifyWebhook, withRetry };
|