@soledgic/sdk 0.2.2 → 0.3.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/README.md +69 -85
- package/dist/index.d.mts +173 -24
- package/dist/index.d.ts +173 -24
- package/dist/index.js +112 -28
- package/dist/index.mjs +111 -28
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Soledgic TypeScript SDK
|
|
2
2
|
|
|
3
|
-
TypeScript client for Soledgic's
|
|
3
|
+
TypeScript client for Soledgic's wallet-first payment infrastructure API for marketplaces, creator platforms, and closed-loop app economies.
|
|
4
4
|
|
|
5
5
|
This package targets the supported API-key surface:
|
|
6
6
|
|
|
@@ -11,18 +11,20 @@ This package targets the supported API-key surface:
|
|
|
11
11
|
- `checkout-sessions`
|
|
12
12
|
- `payouts`
|
|
13
13
|
- `refunds`
|
|
14
|
-
- `
|
|
15
|
-
- `
|
|
16
|
-
- `compliance`
|
|
17
|
-
- `tax`
|
|
14
|
+
- `receipts`
|
|
15
|
+
- `activity`
|
|
18
16
|
- webhook endpoint management and signature verification
|
|
19
17
|
|
|
20
18
|
It does not wrap the dashboard/operator control-plane routes such as `/api/identity/*` or `/api/ecosystems/*`.
|
|
21
19
|
|
|
20
|
+
New integrations should use the namespaced contract shown below. Existing SDK
|
|
21
|
+
integrations remain supported through compatibility shims so current installs do
|
|
22
|
+
not break during the transition.
|
|
23
|
+
|
|
22
24
|
## Installation
|
|
23
25
|
|
|
24
26
|
```bash
|
|
25
|
-
npm install @soledgic/sdk@0.
|
|
27
|
+
npm install @soledgic/sdk@0.3.0
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
## Quick Start
|
|
@@ -32,43 +34,41 @@ import SoledgicClient from '@soledgic/sdk'
|
|
|
32
34
|
|
|
33
35
|
const soledgic = new SoledgicClient({
|
|
34
36
|
apiKey: process.env.SOLEDGIC_API_KEY!,
|
|
37
|
+
baseUrl: process.env.SOLEDGIC_BASE_URL || 'https://api.soledgic.com',
|
|
35
38
|
apiVersion: '2026-03-01',
|
|
36
39
|
})
|
|
37
40
|
|
|
38
|
-
const
|
|
39
|
-
|
|
41
|
+
const userWallet = await soledgic.users.upsertWallet({
|
|
42
|
+
externalUserId: 'user_123',
|
|
43
|
+
name: 'User 123 wallet',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const creator = await soledgic.creators.upsert({
|
|
47
|
+
externalCreatorId: 'creator_456',
|
|
40
48
|
userId: '9f9b62d2-2f32-4b20-bc24-1f86b16cb9eb',
|
|
41
49
|
displayName: 'Jane Creator',
|
|
42
50
|
email: 'jane@example.com',
|
|
43
51
|
defaultSplitPercent: 80,
|
|
44
52
|
})
|
|
45
53
|
|
|
46
|
-
const checkout = await soledgic.
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
const checkout = await soledgic.orders.createCheckout({
|
|
55
|
+
creatorId: creator.participant.id,
|
|
56
|
+
externalUserId: 'user_123',
|
|
57
|
+
externalProductId: 'chapter_001',
|
|
58
|
+
externalOrderId: 'order_1001',
|
|
59
|
+
amount: 999,
|
|
49
60
|
currency: 'USD',
|
|
50
|
-
productName: '
|
|
61
|
+
productName: 'Chapter 1',
|
|
51
62
|
successUrl: 'https://example.com/success',
|
|
52
63
|
cancelUrl: 'https://example.com/cancel',
|
|
53
64
|
})
|
|
54
65
|
|
|
55
|
-
const
|
|
56
|
-
ownerId: participant.participant.id,
|
|
57
|
-
walletType: 'creator_earnings',
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
const payout = await soledgic.createPayout({
|
|
61
|
-
participantId: participant.participant.id,
|
|
62
|
-
referenceId: 'payout_2026_03_13_001',
|
|
63
|
-
amount: 1500,
|
|
64
|
-
payoutMethod: 'bank',
|
|
65
|
-
})
|
|
66
|
+
const activity = await soledgic.activity.listWallet(userWallet.wallet.id, { limit: 10 })
|
|
66
67
|
|
|
67
68
|
console.log({
|
|
68
69
|
checkoutUrl: checkout.checkoutSession.checkoutUrl,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
payoutTransactionId: payout.payout.transactionId,
|
|
70
|
+
walletBalance: userWallet.wallet.availableBalance,
|
|
71
|
+
activityItems: activity.entries.length,
|
|
72
72
|
})
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -76,91 +76,70 @@ The wallet API is uniform across integrations, but balances remain scoped.
|
|
|
76
76
|
Every wallet object belongs to one ledger, one owner, and one wallet type.
|
|
77
77
|
Soledgic does not expose a shared universal wallet balance.
|
|
78
78
|
|
|
79
|
-
## Public Treasury
|
|
79
|
+
## Public Treasury Namespaces
|
|
80
80
|
|
|
81
|
-
###
|
|
81
|
+
### Platform and Creators
|
|
82
82
|
|
|
83
83
|
| Method | Description |
|
|
84
84
|
| --- | --- |
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
85
|
+
| `platform.getStatus()` | Read current API and treasury health |
|
|
86
|
+
| `creators.upsert(req)` | Create or update a creator-backed treasury account |
|
|
87
|
+
| `creators.get(creatorId)` | Get one creator with active hold detail |
|
|
88
|
+
| `creators.getPayoutEligibility(creatorId)` | Check payout readiness |
|
|
89
|
+
| `creators.createWallet(req)` | Create a creator earnings wallet when the integration manages wallets directly |
|
|
89
90
|
|
|
90
|
-
`
|
|
91
|
+
`creators.upsert` accepts an optional `userId` so a public creator can be linked to a shared identity record without exposing the operator APIs directly.
|
|
91
92
|
|
|
92
93
|
### Wallets, Transfers, and Holds
|
|
93
94
|
|
|
94
95
|
| Method | Description |
|
|
95
96
|
| --- | --- |
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
97
|
+
| `users.upsertWallet(req)` | Create or update a user wallet |
|
|
98
|
+
| `wallets.list(filters?)` | List wallet objects by owner or wallet type |
|
|
99
|
+
| `wallets.create(req)` | Create a scoped wallet object |
|
|
100
|
+
| `wallets.get(walletId)` | Fetch a wallet object by wallet id |
|
|
101
|
+
| `wallets.listActivity(walletId, opts?)` | List entries for a wallet object |
|
|
102
|
+
| `wallets.topUp(req)` | Top up a wallet object |
|
|
103
|
+
| `wallets.withdraw(req)` | Withdraw from a wallet object |
|
|
104
|
+
| `wallets.transfer(req)` | Move funds between wallets when transfer is permitted |
|
|
105
|
+
| `holds.list(opts?)` | List held funds |
|
|
106
|
+
| `holds.release(req)` | Release a hold and optionally execute the transfer |
|
|
106
107
|
|
|
107
108
|
Supported wallet types:
|
|
108
109
|
|
|
109
110
|
- `consumer_credit`: closed-loop platform credits
|
|
110
111
|
- `creator_earnings`: payout-eligible seller or creator proceeds
|
|
111
112
|
|
|
112
|
-
`
|
|
113
|
+
`wallets.create` currently provisions scoped consumer-credit wallets. Creator
|
|
113
114
|
earnings wallets are provisioned through participant and treasury flows.
|
|
114
115
|
|
|
115
116
|
### Checkout, Payouts, and Refunds
|
|
116
117
|
|
|
117
118
|
| Method | Description |
|
|
118
119
|
| --- | --- |
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
| `
|
|
129
|
-
| `matchTransaction(req)` | Create a reconciliation match |
|
|
130
|
-
| `unmatchTransaction(transactionId)` | Remove a reconciliation match |
|
|
131
|
-
| `createReconciliationSnapshot(req)` | Freeze a reconciliation snapshot for a period or as-of date |
|
|
132
|
-
| `getReconciliationSnapshot(periodId)` | Read the latest snapshot for a period |
|
|
133
|
-
| `autoMatchBankTransaction(bankAggregatorTransactionId)` | Attempt an automatic bank-to-ledger match |
|
|
134
|
-
|
|
135
|
-
### Fraud, Compliance, and Tax
|
|
136
|
-
|
|
137
|
-
| Method | Description |
|
|
138
|
-
| --- | --- |
|
|
139
|
-
| `evaluateFraud(req)` | Create a fraud evaluation for a proposed transaction |
|
|
140
|
-
| `listFraudPolicies()` | List active fraud policies |
|
|
141
|
-
| `createFraudPolicy(req)` | Create a fraud policy |
|
|
142
|
-
| `deleteFraudPolicy(policyId)` | Delete a fraud policy |
|
|
143
|
-
| `getComplianceOverview(opts?)` | Summarize ledger-scoped compliance signals |
|
|
144
|
-
| `listComplianceAccessPatterns(opts?)` | Inspect suspicious or high-volume access patterns |
|
|
145
|
-
| `listComplianceFinancialActivity(opts?)` | Summarize payout, sale, refund, and dispute activity |
|
|
146
|
-
| `listComplianceSecuritySummary(opts?)` | Summarize risk-scored security and audit events |
|
|
147
|
-
| `calculateTaxForParticipant(participantId, taxYear?)` | Calculate participant tax totals and shared-profile status |
|
|
148
|
-
| `generateAllTaxDocuments(taxYear?)` | Generate tax documents for the year |
|
|
149
|
-
| `listTaxDocuments(taxYear?)` | List generated tax documents |
|
|
150
|
-
| `getTaxDocument(documentId)` | Read one tax document |
|
|
151
|
-
| `exportTaxDocuments(taxYear?, format?)` | Export tax documents as CSV or JSON |
|
|
152
|
-
| `markTaxDocumentFiled(documentId)` | Mark a document as filed |
|
|
153
|
-
| `generateTaxSummary(taxYear, participantId?)` | Generate tax summary totals for the year |
|
|
120
|
+
| `orders.createCheckout(req)` | Create hosted or direct checkout flows for an order |
|
|
121
|
+
| `purchases.create(req)` | Create a purchase checkout flow |
|
|
122
|
+
| `payouts.request(req)` | Create a payout request |
|
|
123
|
+
| `payouts.getEligibility(creatorId)` | Check creator payout readiness |
|
|
124
|
+
| `refunds.request(req)` | Request a refund through Soledgic |
|
|
125
|
+
| `refunds.list(req?)` | Query refunds, including by `saleReference` |
|
|
126
|
+
| `reversals.create(req)` | Create an accounting reversal |
|
|
127
|
+
| `receipts.upload(req)` | Attach a receipt to a transaction |
|
|
128
|
+
| `activity.listWallet(walletId, opts?)` | List wallet activity for a user-facing activity feed |
|
|
129
|
+
| `activity.listRefunds(req?)` | List refund activity |
|
|
154
130
|
|
|
155
131
|
### Webhooks
|
|
156
132
|
|
|
157
133
|
| Method | Description |
|
|
158
134
|
| --- | --- |
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
135
|
+
| `webhooks.listEndpoints()` | List configured webhook endpoints |
|
|
136
|
+
| `webhooks.createEndpoint(config)` | Create a webhook endpoint |
|
|
137
|
+
| `webhooks.updateEndpoint(endpointId, updates)` | Update a webhook endpoint |
|
|
138
|
+
| `webhooks.deleteEndpoint(endpointId)` | Delete a webhook endpoint |
|
|
139
|
+
| `webhooks.listDeliveries(endpointId?, limit?)` | Inspect recent deliveries |
|
|
140
|
+
| `webhooks.rotateSecret(endpointId)` | Rotate an endpoint secret |
|
|
141
|
+
| `webhooks.verifySignature(...)` | Verify `X-Soledgic-Signature` |
|
|
142
|
+
| `webhooks.parseEvent(payload)` | Parse a webhook payload into an event object |
|
|
164
143
|
|
|
165
144
|
## Replay Safety
|
|
166
145
|
|
|
@@ -178,7 +157,7 @@ If your integration retries requests or replays processor events, treat `referen
|
|
|
178
157
|
import { SoledgicError } from '@soledgic/sdk'
|
|
179
158
|
|
|
180
159
|
try {
|
|
181
|
-
await soledgic.
|
|
160
|
+
await soledgic.payouts.request({
|
|
182
161
|
participantId: 'creator_456',
|
|
183
162
|
referenceId: 'payout_retry_safe_001',
|
|
184
163
|
amount: 999999,
|
|
@@ -195,6 +174,10 @@ try {
|
|
|
195
174
|
|
|
196
175
|
The SDK surfaces structured `error_code` values from the API when they are present. Use those codes for client logic instead of matching on human-readable messages.
|
|
197
176
|
|
|
177
|
+
## Release Notes
|
|
178
|
+
|
|
179
|
+
- `0.3.0` adds the namespaced SDK contract while keeping top-level compatibility shims for existing integrations.
|
|
180
|
+
|
|
198
181
|
## Security Boundary
|
|
199
182
|
|
|
200
183
|
This SDK is intentionally limited to the public integration contract:
|
|
@@ -207,6 +190,7 @@ It does not authenticate end-user dashboard sessions, and it does not expose the
|
|
|
207
190
|
- shared identity profiles
|
|
208
191
|
- participant identity linking and unlinking
|
|
209
192
|
- ecosystem management
|
|
193
|
+
- risk, compliance, reconciliation, and tax operations
|
|
210
194
|
- internal fixture cleanup
|
|
211
195
|
|
|
212
196
|
Those flows are documented in [docs/OPERATOR_CONTROL_PLANE.md](../../docs/OPERATOR_CONTROL_PLANE.md).
|
package/dist/index.d.mts
CHANGED
|
@@ -511,17 +511,64 @@ interface CreateRefundRequest {
|
|
|
511
511
|
idempotencyKey?: string;
|
|
512
512
|
metadata?: Record<string, unknown>;
|
|
513
513
|
}
|
|
514
|
-
interface
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
externalRef?: string;
|
|
522
|
-
projectionsCreated?: number;
|
|
523
|
-
channel?: 'slack' | 'email' | 'webhook';
|
|
514
|
+
interface UpsertUserWalletRequest {
|
|
515
|
+
/** Your app's stable user/customer id. */
|
|
516
|
+
externalUserId: string;
|
|
517
|
+
/** Optional label for the wallet owner type. Defaults to "user". */
|
|
518
|
+
ownerType?: string;
|
|
519
|
+
name?: string;
|
|
520
|
+
metadata?: Record<string, unknown>;
|
|
524
521
|
}
|
|
522
|
+
interface UpsertCreatorRequest {
|
|
523
|
+
/** Your app's stable creator/seller id. */
|
|
524
|
+
externalCreatorId: string;
|
|
525
|
+
userId?: string;
|
|
526
|
+
displayName?: string;
|
|
527
|
+
email?: string;
|
|
528
|
+
defaultSplitPercent?: number;
|
|
529
|
+
taxInfo?: ParticipantTaxInfo;
|
|
530
|
+
payoutPreferences?: ParticipantPayoutPreferences;
|
|
531
|
+
metadata?: Record<string, unknown>;
|
|
532
|
+
}
|
|
533
|
+
interface CreateCreatorWalletRequest {
|
|
534
|
+
/** Your app's stable creator/seller id, mapped to a Soledgic participant. */
|
|
535
|
+
creatorId: string;
|
|
536
|
+
name?: string;
|
|
537
|
+
metadata?: Record<string, unknown>;
|
|
538
|
+
}
|
|
539
|
+
type UniversalCheckoutRequest = {
|
|
540
|
+
/** Your app's stable creator/seller id, mapped to participant_id. */
|
|
541
|
+
creatorId: string;
|
|
542
|
+
amount: number;
|
|
543
|
+
currency?: string;
|
|
544
|
+
/** Your app's stable product/session id, mapped to product_id. */
|
|
545
|
+
externalProductId?: string;
|
|
546
|
+
productName?: string;
|
|
547
|
+
/** Your app's stable buyer/user id, mapped to customer_id. */
|
|
548
|
+
externalUserId?: string;
|
|
549
|
+
customerEmail?: string;
|
|
550
|
+
/** Your app's stable order/purchase id. Used as idempotency_key when no explicit idempotencyKey is provided. */
|
|
551
|
+
externalOrderId?: string;
|
|
552
|
+
metadata?: Record<string, string>;
|
|
553
|
+
} & ({
|
|
554
|
+
paymentMethodId: string;
|
|
555
|
+
sourceId?: string;
|
|
556
|
+
idempotencyKey: string;
|
|
557
|
+
successUrl?: string;
|
|
558
|
+
cancelUrl?: string;
|
|
559
|
+
} | {
|
|
560
|
+
paymentMethodId?: string;
|
|
561
|
+
sourceId: string;
|
|
562
|
+
idempotencyKey: string;
|
|
563
|
+
successUrl?: string;
|
|
564
|
+
cancelUrl?: string;
|
|
565
|
+
} | {
|
|
566
|
+
paymentMethodId?: undefined;
|
|
567
|
+
sourceId?: undefined;
|
|
568
|
+
successUrl: string;
|
|
569
|
+
cancelUrl?: string;
|
|
570
|
+
idempotencyKey?: string;
|
|
571
|
+
});
|
|
525
572
|
interface InvoiceLineItem {
|
|
526
573
|
description: string;
|
|
527
574
|
quantity: number;
|
|
@@ -975,18 +1022,6 @@ interface ReceivePaymentResponse {
|
|
|
975
1022
|
transactionId: string;
|
|
976
1023
|
amount: number;
|
|
977
1024
|
}
|
|
978
|
-
interface SendBreachAlertResponse {
|
|
979
|
-
success: boolean;
|
|
980
|
-
message?: string;
|
|
981
|
-
alertsSent: number;
|
|
982
|
-
alertsFailed?: number;
|
|
983
|
-
alertsSkipped?: number;
|
|
984
|
-
results?: Array<{
|
|
985
|
-
channel: string;
|
|
986
|
-
success: boolean;
|
|
987
|
-
error?: string;
|
|
988
|
-
}>;
|
|
989
|
-
}
|
|
990
1025
|
interface WalletObject {
|
|
991
1026
|
id: string;
|
|
992
1027
|
object: 'wallet';
|
|
@@ -1239,6 +1274,7 @@ declare function mapWebhookDelivery(delivery: any): WebhookDelivery;
|
|
|
1239
1274
|
|
|
1240
1275
|
declare const DEFAULT_API_VERSION = "2026-03-01";
|
|
1241
1276
|
declare const DEFAULT_BASE_URL = "https://api.soledgic.com/v1";
|
|
1277
|
+
declare function normalizeBaseUrl(input?: string): string;
|
|
1242
1278
|
declare class Soledgic {
|
|
1243
1279
|
private _getKey;
|
|
1244
1280
|
private baseUrl;
|
|
@@ -1250,11 +1286,125 @@ declare class Soledgic {
|
|
|
1250
1286
|
readonly webhooks: {
|
|
1251
1287
|
verifySignature: (payload: WebhookPayloadInput, signatureHeader: string, secret: string, options?: VerifyWebhookSignatureOptions) => Promise<boolean>;
|
|
1252
1288
|
parseEvent: <T = Record<string, unknown>>(payload: WebhookPayloadInput) => ParsedWebhookEvent<T>;
|
|
1289
|
+
listEndpoints: () => Promise<{
|
|
1290
|
+
success: any;
|
|
1291
|
+
data: any;
|
|
1292
|
+
}>;
|
|
1293
|
+
createEndpoint: (config: {
|
|
1294
|
+
url: string;
|
|
1295
|
+
description?: string;
|
|
1296
|
+
events?: string[];
|
|
1297
|
+
}) => Promise<{
|
|
1298
|
+
success: any;
|
|
1299
|
+
data: {
|
|
1300
|
+
secret: any;
|
|
1301
|
+
id: string;
|
|
1302
|
+
url: string;
|
|
1303
|
+
description: string | null;
|
|
1304
|
+
events: string[];
|
|
1305
|
+
isActive: boolean;
|
|
1306
|
+
createdAt: string;
|
|
1307
|
+
secretRotatedAt: string | null;
|
|
1308
|
+
};
|
|
1309
|
+
message: any;
|
|
1310
|
+
}>;
|
|
1311
|
+
updateEndpoint: (endpointId: string, updates: {
|
|
1312
|
+
url?: string;
|
|
1313
|
+
description?: string;
|
|
1314
|
+
events?: string[];
|
|
1315
|
+
isActive?: boolean;
|
|
1316
|
+
}) => Promise<{
|
|
1317
|
+
success: any;
|
|
1318
|
+
data: WebhookEndpoint;
|
|
1319
|
+
}>;
|
|
1320
|
+
deleteEndpoint: (endpointId: string) => Promise<{
|
|
1321
|
+
success: any;
|
|
1322
|
+
message: any;
|
|
1323
|
+
}>;
|
|
1324
|
+
testEndpoint: (endpointId: string) => Promise<{
|
|
1325
|
+
success: any;
|
|
1326
|
+
error: any;
|
|
1327
|
+
data: {
|
|
1328
|
+
delivered: boolean;
|
|
1329
|
+
status: any;
|
|
1330
|
+
responseTimeMs: any;
|
|
1331
|
+
};
|
|
1332
|
+
}>;
|
|
1333
|
+
listDeliveries: (endpointId?: string, limit?: number) => Promise<{
|
|
1334
|
+
success: any;
|
|
1335
|
+
data: any;
|
|
1336
|
+
}>;
|
|
1337
|
+
rotateSecret: (endpointId: string) => Promise<{
|
|
1338
|
+
success: any;
|
|
1339
|
+
data: {
|
|
1340
|
+
secret: any;
|
|
1341
|
+
};
|
|
1342
|
+
message: any;
|
|
1343
|
+
}>;
|
|
1344
|
+
};
|
|
1345
|
+
readonly platform: {
|
|
1346
|
+
getStatus: () => Promise<unknown>;
|
|
1347
|
+
};
|
|
1348
|
+
readonly users: {
|
|
1349
|
+
upsertWallet: (req: UpsertUserWalletRequest) => Promise<CreateWalletResponse>;
|
|
1350
|
+
};
|
|
1351
|
+
readonly creators: {
|
|
1352
|
+
upsert: (req: UpsertCreatorRequest) => Promise<CreateParticipantResponse>;
|
|
1353
|
+
get: (creatorId: string) => Promise<{
|
|
1354
|
+
success: boolean;
|
|
1355
|
+
participant: ParticipantDetail;
|
|
1356
|
+
}>;
|
|
1357
|
+
getPayoutEligibility: (creatorId: string) => Promise<ParticipantPayoutEligibilityResponse>;
|
|
1358
|
+
createWallet: (req: CreateCreatorWalletRequest) => Promise<CreateWalletResponse>;
|
|
1359
|
+
};
|
|
1360
|
+
readonly orders: {
|
|
1361
|
+
createCheckout: (req: UniversalCheckoutRequest) => Promise<CheckoutSessionResourceResponse>;
|
|
1362
|
+
};
|
|
1363
|
+
readonly purchases: {
|
|
1364
|
+
create: (req: UniversalCheckoutRequest) => Promise<CheckoutSessionResourceResponse>;
|
|
1365
|
+
};
|
|
1366
|
+
readonly wallets: {
|
|
1367
|
+
list: (filters?: ListWalletsRequest) => Promise<ListWalletsResponse>;
|
|
1368
|
+
create: (req: CreateWalletRequest) => Promise<CreateWalletResponse>;
|
|
1369
|
+
get: (walletId: string) => Promise<GetWalletResponse>;
|
|
1370
|
+
listActivity: (walletId: string, options?: {
|
|
1371
|
+
limit?: number;
|
|
1372
|
+
offset?: number;
|
|
1373
|
+
}) => Promise<WalletEntriesResponse>;
|
|
1374
|
+
topUp: (req: WalletTopupRequest) => Promise<WalletTopupResponse>;
|
|
1375
|
+
withdraw: (req: WalletWithdrawRequest) => Promise<WalletWithdrawalResponse>;
|
|
1376
|
+
transfer: (req: ParticipantTransferRequest) => Promise<ParticipantTransferResponse>;
|
|
1377
|
+
};
|
|
1378
|
+
readonly payouts: {
|
|
1379
|
+
request: (req: CreatePayoutRequest) => Promise<PayoutResourceResponse>;
|
|
1380
|
+
getEligibility: (creatorId: string) => Promise<ParticipantPayoutEligibilityResponse>;
|
|
1381
|
+
};
|
|
1382
|
+
readonly refunds: {
|
|
1383
|
+
request: (req: CreateRefundRequest) => Promise<RefundResourceResponse>;
|
|
1384
|
+
list: (req?: ListRefundsRequest) => Promise<ListRefundsResponse>;
|
|
1385
|
+
};
|
|
1386
|
+
readonly holds: {
|
|
1387
|
+
list: (options?: HoldQueryOptions) => Promise<HeldFundsResponse>;
|
|
1388
|
+
release: (req: ReleaseHoldRequest) => Promise<ReleaseHoldResponse>;
|
|
1389
|
+
};
|
|
1390
|
+
readonly reversals: {
|
|
1391
|
+
create: (req: ReverseTransactionRequest) => Promise<ReverseResponse>;
|
|
1392
|
+
};
|
|
1393
|
+
readonly receipts: {
|
|
1394
|
+
upload: (req: UploadReceiptRequest) => Promise<UploadReceiptResponse>;
|
|
1395
|
+
};
|
|
1396
|
+
readonly activity: {
|
|
1397
|
+
listWallet: (walletId: string, options?: {
|
|
1398
|
+
limit?: number;
|
|
1399
|
+
offset?: number;
|
|
1400
|
+
}) => Promise<WalletEntriesResponse>;
|
|
1401
|
+
listRefunds: (req?: ListRefundsRequest) => Promise<ListRefundsResponse>;
|
|
1253
1402
|
};
|
|
1254
1403
|
private throwTypedError;
|
|
1255
1404
|
private request;
|
|
1256
1405
|
private requestGet;
|
|
1257
1406
|
private requestRaw;
|
|
1407
|
+
private createUniversalCheckout;
|
|
1258
1408
|
private requestGetRaw;
|
|
1259
1409
|
private requestDelete;
|
|
1260
1410
|
recordIncome(req: RecordIncomeRequest): Promise<unknown>;
|
|
@@ -1586,7 +1736,6 @@ declare class Soledgic {
|
|
|
1586
1736
|
exportReport(req: ExportReportRequest): Promise<ExportReportJsonResponse | ExportReportCsvResponse>;
|
|
1587
1737
|
uploadReceipt(req: UploadReceiptRequest): Promise<UploadReceiptResponse>;
|
|
1588
1738
|
receivePayment(req: ReceivePaymentRequest): Promise<ReceivePaymentResponse>;
|
|
1589
|
-
sendBreachAlert(req: SendBreachAlertRequest): Promise<SendBreachAlertResponse>;
|
|
1590
1739
|
private mapWalletObject;
|
|
1591
1740
|
listWallets(filters?: ListWalletsRequest): Promise<ListWalletsResponse>;
|
|
1592
1741
|
createWallet(req: CreateWalletRequest): Promise<CreateWalletResponse>;
|
|
@@ -1633,4 +1782,4 @@ declare class Soledgic {
|
|
|
1633
1782
|
importBankStatement(req: ImportBankStatementRequest): Promise<any>;
|
|
1634
1783
|
}
|
|
1635
1784
|
|
|
1636
|
-
export { type AlertChannel, type AlertConfiguration, type AlertTestResult, type AlertThresholds, type AlertType, AuthenticationError, type AuthorizationDecisionType, type AuthorizationPolicy, type AuthorizationResult, type AutoMatchReconciliationResponse, type BackdatePolicyRequest, type BreachRisk, type CheckoutBreakdown, type CheckoutSessionResourceResponse, type ComplianceAccessPatternsResponse, type ComplianceFinancialActivityResponse, type ComplianceOverviewResponse, type ComplianceSecuritySummaryResponse, ConflictError, type CreateAlertRequest, type CreateBankAccountRequest, type CreateBudgetRequest, type CreateCheckoutSessionRequest, type CreateContractorRequest, type CreateInvoiceRequest, type CreateLedgerRequest, type CreateLedgerResponse, type CreateParticipantRequest, type CreateParticipantResponse, type CreatePayoutRequest, type CreatePeriodRequest, type CreatePolicyRequest, type CreateRecurringRequest, type CreateRefundRequest, type CreateSnapshotRequest, type CreateWalletRequest, type CreateWalletResponse, DEFAULT_API_VERSION, DEFAULT_BASE_URL, type EmailAlertConfig, type ExportReportCsvResponse, type ExportReportJsonResponse, type ExportReportRequest, type ExtractedTerms, type FraudPolicyDeleteResponse, type FraudPolicyListResponse, type FraudPolicyResource, type FraudPolicyResponse, type FrozenStatement, type GetWalletResponse, type HeldFund, type HeldFundsResponse, type HeldFundsSummaryResponse, type HoldQueryOptions, type ImportBankStatementLine, type ImportBankStatementRequest, type InvoiceLineItem, type ListRefundsRequest, type ListRefundsResponse, type ListWalletsRequest, type ListWalletsResponse, NotFoundError, type ObligationItem, type Obligations, type ParsedWebhookEvent, type ParticipantDetail, type ParticipantPayoutEligibilityResponse, type ParticipantPayoutPreferences, type ParticipantSummary, type ParticipantTaxInfo, type ParticipantTransferRequest, type ParticipantTransferResponse, type ParticipantWalletMutationRequest, type PayBillRequest, type PayoutResourceResponse, type Period, type PolicySeverity, type PolicyType, type PolicyViolation, type PreflightAuthorizationRequest, type PreflightAuthorizationResponse, type PreflightResult, type ProjectIntentRequest, type ProjectIntentResponse, type ProjectionMatch, type ReceivePaymentRequest, type ReceivePaymentResponse, type ReconcileMatchRequest, type ReconciliationMatchResponse, type ReconciliationSnapshot, type ReconciliationUnmatchResponse, type RecordAdjustmentRequest, type RecordBillRequest, type RecordContractorPaymentRequest, type RecordExpenseRequest, type RecordIncomeRequest, type RecordInvoicePaymentRequest, type RecordOpeningBalanceRequest, type RecordRefundResponse, type RecordTransferRequest, type RefundResourceResponse, type RefundSummary, type RegisterInstrumentRequest, type RegisterInstrumentResponse, type ReleaseHoldRequest, type ReleaseHoldResponse, type ReverseResponse, type ReverseTransactionRequest, type RiskEvaluationRequest, type RiskEvaluationResponse, type
|
|
1785
|
+
export { type AlertChannel, type AlertConfiguration, type AlertTestResult, type AlertThresholds, type AlertType, AuthenticationError, type AuthorizationDecisionType, type AuthorizationPolicy, type AuthorizationResult, type AutoMatchReconciliationResponse, type BackdatePolicyRequest, type BreachRisk, type CheckoutBreakdown, type CheckoutSessionResourceResponse, type ComplianceAccessPatternsResponse, type ComplianceFinancialActivityResponse, type ComplianceOverviewResponse, type ComplianceSecuritySummaryResponse, ConflictError, type CreateAlertRequest, type CreateBankAccountRequest, type CreateBudgetRequest, type CreateCheckoutSessionRequest, type CreateContractorRequest, type CreateCreatorWalletRequest, type CreateInvoiceRequest, type CreateLedgerRequest, type CreateLedgerResponse, type CreateParticipantRequest, type CreateParticipantResponse, type CreatePayoutRequest, type CreatePeriodRequest, type CreatePolicyRequest, type CreateRecurringRequest, type CreateRefundRequest, type CreateSnapshotRequest, type CreateWalletRequest, type CreateWalletResponse, DEFAULT_API_VERSION, DEFAULT_BASE_URL, type EmailAlertConfig, type ExportReportCsvResponse, type ExportReportJsonResponse, type ExportReportRequest, type ExtractedTerms, type FraudPolicyDeleteResponse, type FraudPolicyListResponse, type FraudPolicyResource, type FraudPolicyResponse, type FrozenStatement, type GetWalletResponse, type HeldFund, type HeldFundsResponse, type HeldFundsSummaryResponse, type HoldQueryOptions, type ImportBankStatementLine, type ImportBankStatementRequest, type InvoiceLineItem, type ListRefundsRequest, type ListRefundsResponse, type ListWalletsRequest, type ListWalletsResponse, NotFoundError, type ObligationItem, type Obligations, type ParsedWebhookEvent, type ParticipantDetail, type ParticipantPayoutEligibilityResponse, type ParticipantPayoutPreferences, type ParticipantSummary, type ParticipantTaxInfo, type ParticipantTransferRequest, type ParticipantTransferResponse, type ParticipantWalletMutationRequest, type PayBillRequest, type PayoutResourceResponse, type Period, type PolicySeverity, type PolicyType, type PolicyViolation, type PreflightAuthorizationRequest, type PreflightAuthorizationResponse, type PreflightResult, type ProjectIntentRequest, type ProjectIntentResponse, type ProjectionMatch, type ReceivePaymentRequest, type ReceivePaymentResponse, type ReconcileMatchRequest, type ReconciliationMatchResponse, type ReconciliationSnapshot, type ReconciliationUnmatchResponse, type RecordAdjustmentRequest, type RecordBillRequest, type RecordContractorPaymentRequest, type RecordExpenseRequest, type RecordIncomeRequest, type RecordInvoicePaymentRequest, type RecordOpeningBalanceRequest, type RecordRefundResponse, type RecordTransferRequest, type RefundResourceResponse, type RefundSummary, type RegisterInstrumentRequest, type RegisterInstrumentResponse, type ReleaseHoldRequest, type ReleaseHoldResponse, type ReverseResponse, type ReverseTransactionRequest, type RiskEvaluationRequest, type RiskEvaluationResponse, type SlackAlertConfig, Soledgic, type SoledgicConfig, SoledgicError, type SubmitTaxInfoRequest, type TaxCalculationResponse, type TaxDocumentGenerationResponse, type TaxDocumentResponse, type TaxDocumentsResponse, type TaxSummaryResponse, type UniversalCheckoutRequest, type UnmatchedTransactionsResponse, type UpdateAlertRequest, type UploadReceiptRequest, type UploadReceiptResponse, type UpsertCreatorRequest, type UpsertUserWalletRequest, ValidationError, type VerifyWebhookSignatureOptions, type WalletEntriesResponse, type WalletHistoryEntry, type WalletObject, type WalletTopupRequest, type WalletTopupResponse, type WalletWithdrawRequest, type WalletWithdrawalResponse, type WebhookDelivery, type WebhookEndpoint, type WebhookEndpointSecretResult, type WebhookPayloadInput, Soledgic as default, hmacHex, isArrayBufferView, mapWebhookDelivery, mapWebhookEndpoint, normalizeBaseUrl, parseWebhookEvent, parseWebhookSignatureHeader, resolveWebhookEndpointUrl, timingSafeEqual, verifyWebhookSignature, webhookPayloadToString };
|
package/dist/index.d.ts
CHANGED
|
@@ -511,17 +511,64 @@ interface CreateRefundRequest {
|
|
|
511
511
|
idempotencyKey?: string;
|
|
512
512
|
metadata?: Record<string, unknown>;
|
|
513
513
|
}
|
|
514
|
-
interface
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
externalRef?: string;
|
|
522
|
-
projectionsCreated?: number;
|
|
523
|
-
channel?: 'slack' | 'email' | 'webhook';
|
|
514
|
+
interface UpsertUserWalletRequest {
|
|
515
|
+
/** Your app's stable user/customer id. */
|
|
516
|
+
externalUserId: string;
|
|
517
|
+
/** Optional label for the wallet owner type. Defaults to "user". */
|
|
518
|
+
ownerType?: string;
|
|
519
|
+
name?: string;
|
|
520
|
+
metadata?: Record<string, unknown>;
|
|
524
521
|
}
|
|
522
|
+
interface UpsertCreatorRequest {
|
|
523
|
+
/** Your app's stable creator/seller id. */
|
|
524
|
+
externalCreatorId: string;
|
|
525
|
+
userId?: string;
|
|
526
|
+
displayName?: string;
|
|
527
|
+
email?: string;
|
|
528
|
+
defaultSplitPercent?: number;
|
|
529
|
+
taxInfo?: ParticipantTaxInfo;
|
|
530
|
+
payoutPreferences?: ParticipantPayoutPreferences;
|
|
531
|
+
metadata?: Record<string, unknown>;
|
|
532
|
+
}
|
|
533
|
+
interface CreateCreatorWalletRequest {
|
|
534
|
+
/** Your app's stable creator/seller id, mapped to a Soledgic participant. */
|
|
535
|
+
creatorId: string;
|
|
536
|
+
name?: string;
|
|
537
|
+
metadata?: Record<string, unknown>;
|
|
538
|
+
}
|
|
539
|
+
type UniversalCheckoutRequest = {
|
|
540
|
+
/** Your app's stable creator/seller id, mapped to participant_id. */
|
|
541
|
+
creatorId: string;
|
|
542
|
+
amount: number;
|
|
543
|
+
currency?: string;
|
|
544
|
+
/** Your app's stable product/session id, mapped to product_id. */
|
|
545
|
+
externalProductId?: string;
|
|
546
|
+
productName?: string;
|
|
547
|
+
/** Your app's stable buyer/user id, mapped to customer_id. */
|
|
548
|
+
externalUserId?: string;
|
|
549
|
+
customerEmail?: string;
|
|
550
|
+
/** Your app's stable order/purchase id. Used as idempotency_key when no explicit idempotencyKey is provided. */
|
|
551
|
+
externalOrderId?: string;
|
|
552
|
+
metadata?: Record<string, string>;
|
|
553
|
+
} & ({
|
|
554
|
+
paymentMethodId: string;
|
|
555
|
+
sourceId?: string;
|
|
556
|
+
idempotencyKey: string;
|
|
557
|
+
successUrl?: string;
|
|
558
|
+
cancelUrl?: string;
|
|
559
|
+
} | {
|
|
560
|
+
paymentMethodId?: string;
|
|
561
|
+
sourceId: string;
|
|
562
|
+
idempotencyKey: string;
|
|
563
|
+
successUrl?: string;
|
|
564
|
+
cancelUrl?: string;
|
|
565
|
+
} | {
|
|
566
|
+
paymentMethodId?: undefined;
|
|
567
|
+
sourceId?: undefined;
|
|
568
|
+
successUrl: string;
|
|
569
|
+
cancelUrl?: string;
|
|
570
|
+
idempotencyKey?: string;
|
|
571
|
+
});
|
|
525
572
|
interface InvoiceLineItem {
|
|
526
573
|
description: string;
|
|
527
574
|
quantity: number;
|
|
@@ -975,18 +1022,6 @@ interface ReceivePaymentResponse {
|
|
|
975
1022
|
transactionId: string;
|
|
976
1023
|
amount: number;
|
|
977
1024
|
}
|
|
978
|
-
interface SendBreachAlertResponse {
|
|
979
|
-
success: boolean;
|
|
980
|
-
message?: string;
|
|
981
|
-
alertsSent: number;
|
|
982
|
-
alertsFailed?: number;
|
|
983
|
-
alertsSkipped?: number;
|
|
984
|
-
results?: Array<{
|
|
985
|
-
channel: string;
|
|
986
|
-
success: boolean;
|
|
987
|
-
error?: string;
|
|
988
|
-
}>;
|
|
989
|
-
}
|
|
990
1025
|
interface WalletObject {
|
|
991
1026
|
id: string;
|
|
992
1027
|
object: 'wallet';
|
|
@@ -1239,6 +1274,7 @@ declare function mapWebhookDelivery(delivery: any): WebhookDelivery;
|
|
|
1239
1274
|
|
|
1240
1275
|
declare const DEFAULT_API_VERSION = "2026-03-01";
|
|
1241
1276
|
declare const DEFAULT_BASE_URL = "https://api.soledgic.com/v1";
|
|
1277
|
+
declare function normalizeBaseUrl(input?: string): string;
|
|
1242
1278
|
declare class Soledgic {
|
|
1243
1279
|
private _getKey;
|
|
1244
1280
|
private baseUrl;
|
|
@@ -1250,11 +1286,125 @@ declare class Soledgic {
|
|
|
1250
1286
|
readonly webhooks: {
|
|
1251
1287
|
verifySignature: (payload: WebhookPayloadInput, signatureHeader: string, secret: string, options?: VerifyWebhookSignatureOptions) => Promise<boolean>;
|
|
1252
1288
|
parseEvent: <T = Record<string, unknown>>(payload: WebhookPayloadInput) => ParsedWebhookEvent<T>;
|
|
1289
|
+
listEndpoints: () => Promise<{
|
|
1290
|
+
success: any;
|
|
1291
|
+
data: any;
|
|
1292
|
+
}>;
|
|
1293
|
+
createEndpoint: (config: {
|
|
1294
|
+
url: string;
|
|
1295
|
+
description?: string;
|
|
1296
|
+
events?: string[];
|
|
1297
|
+
}) => Promise<{
|
|
1298
|
+
success: any;
|
|
1299
|
+
data: {
|
|
1300
|
+
secret: any;
|
|
1301
|
+
id: string;
|
|
1302
|
+
url: string;
|
|
1303
|
+
description: string | null;
|
|
1304
|
+
events: string[];
|
|
1305
|
+
isActive: boolean;
|
|
1306
|
+
createdAt: string;
|
|
1307
|
+
secretRotatedAt: string | null;
|
|
1308
|
+
};
|
|
1309
|
+
message: any;
|
|
1310
|
+
}>;
|
|
1311
|
+
updateEndpoint: (endpointId: string, updates: {
|
|
1312
|
+
url?: string;
|
|
1313
|
+
description?: string;
|
|
1314
|
+
events?: string[];
|
|
1315
|
+
isActive?: boolean;
|
|
1316
|
+
}) => Promise<{
|
|
1317
|
+
success: any;
|
|
1318
|
+
data: WebhookEndpoint;
|
|
1319
|
+
}>;
|
|
1320
|
+
deleteEndpoint: (endpointId: string) => Promise<{
|
|
1321
|
+
success: any;
|
|
1322
|
+
message: any;
|
|
1323
|
+
}>;
|
|
1324
|
+
testEndpoint: (endpointId: string) => Promise<{
|
|
1325
|
+
success: any;
|
|
1326
|
+
error: any;
|
|
1327
|
+
data: {
|
|
1328
|
+
delivered: boolean;
|
|
1329
|
+
status: any;
|
|
1330
|
+
responseTimeMs: any;
|
|
1331
|
+
};
|
|
1332
|
+
}>;
|
|
1333
|
+
listDeliveries: (endpointId?: string, limit?: number) => Promise<{
|
|
1334
|
+
success: any;
|
|
1335
|
+
data: any;
|
|
1336
|
+
}>;
|
|
1337
|
+
rotateSecret: (endpointId: string) => Promise<{
|
|
1338
|
+
success: any;
|
|
1339
|
+
data: {
|
|
1340
|
+
secret: any;
|
|
1341
|
+
};
|
|
1342
|
+
message: any;
|
|
1343
|
+
}>;
|
|
1344
|
+
};
|
|
1345
|
+
readonly platform: {
|
|
1346
|
+
getStatus: () => Promise<unknown>;
|
|
1347
|
+
};
|
|
1348
|
+
readonly users: {
|
|
1349
|
+
upsertWallet: (req: UpsertUserWalletRequest) => Promise<CreateWalletResponse>;
|
|
1350
|
+
};
|
|
1351
|
+
readonly creators: {
|
|
1352
|
+
upsert: (req: UpsertCreatorRequest) => Promise<CreateParticipantResponse>;
|
|
1353
|
+
get: (creatorId: string) => Promise<{
|
|
1354
|
+
success: boolean;
|
|
1355
|
+
participant: ParticipantDetail;
|
|
1356
|
+
}>;
|
|
1357
|
+
getPayoutEligibility: (creatorId: string) => Promise<ParticipantPayoutEligibilityResponse>;
|
|
1358
|
+
createWallet: (req: CreateCreatorWalletRequest) => Promise<CreateWalletResponse>;
|
|
1359
|
+
};
|
|
1360
|
+
readonly orders: {
|
|
1361
|
+
createCheckout: (req: UniversalCheckoutRequest) => Promise<CheckoutSessionResourceResponse>;
|
|
1362
|
+
};
|
|
1363
|
+
readonly purchases: {
|
|
1364
|
+
create: (req: UniversalCheckoutRequest) => Promise<CheckoutSessionResourceResponse>;
|
|
1365
|
+
};
|
|
1366
|
+
readonly wallets: {
|
|
1367
|
+
list: (filters?: ListWalletsRequest) => Promise<ListWalletsResponse>;
|
|
1368
|
+
create: (req: CreateWalletRequest) => Promise<CreateWalletResponse>;
|
|
1369
|
+
get: (walletId: string) => Promise<GetWalletResponse>;
|
|
1370
|
+
listActivity: (walletId: string, options?: {
|
|
1371
|
+
limit?: number;
|
|
1372
|
+
offset?: number;
|
|
1373
|
+
}) => Promise<WalletEntriesResponse>;
|
|
1374
|
+
topUp: (req: WalletTopupRequest) => Promise<WalletTopupResponse>;
|
|
1375
|
+
withdraw: (req: WalletWithdrawRequest) => Promise<WalletWithdrawalResponse>;
|
|
1376
|
+
transfer: (req: ParticipantTransferRequest) => Promise<ParticipantTransferResponse>;
|
|
1377
|
+
};
|
|
1378
|
+
readonly payouts: {
|
|
1379
|
+
request: (req: CreatePayoutRequest) => Promise<PayoutResourceResponse>;
|
|
1380
|
+
getEligibility: (creatorId: string) => Promise<ParticipantPayoutEligibilityResponse>;
|
|
1381
|
+
};
|
|
1382
|
+
readonly refunds: {
|
|
1383
|
+
request: (req: CreateRefundRequest) => Promise<RefundResourceResponse>;
|
|
1384
|
+
list: (req?: ListRefundsRequest) => Promise<ListRefundsResponse>;
|
|
1385
|
+
};
|
|
1386
|
+
readonly holds: {
|
|
1387
|
+
list: (options?: HoldQueryOptions) => Promise<HeldFundsResponse>;
|
|
1388
|
+
release: (req: ReleaseHoldRequest) => Promise<ReleaseHoldResponse>;
|
|
1389
|
+
};
|
|
1390
|
+
readonly reversals: {
|
|
1391
|
+
create: (req: ReverseTransactionRequest) => Promise<ReverseResponse>;
|
|
1392
|
+
};
|
|
1393
|
+
readonly receipts: {
|
|
1394
|
+
upload: (req: UploadReceiptRequest) => Promise<UploadReceiptResponse>;
|
|
1395
|
+
};
|
|
1396
|
+
readonly activity: {
|
|
1397
|
+
listWallet: (walletId: string, options?: {
|
|
1398
|
+
limit?: number;
|
|
1399
|
+
offset?: number;
|
|
1400
|
+
}) => Promise<WalletEntriesResponse>;
|
|
1401
|
+
listRefunds: (req?: ListRefundsRequest) => Promise<ListRefundsResponse>;
|
|
1253
1402
|
};
|
|
1254
1403
|
private throwTypedError;
|
|
1255
1404
|
private request;
|
|
1256
1405
|
private requestGet;
|
|
1257
1406
|
private requestRaw;
|
|
1407
|
+
private createUniversalCheckout;
|
|
1258
1408
|
private requestGetRaw;
|
|
1259
1409
|
private requestDelete;
|
|
1260
1410
|
recordIncome(req: RecordIncomeRequest): Promise<unknown>;
|
|
@@ -1586,7 +1736,6 @@ declare class Soledgic {
|
|
|
1586
1736
|
exportReport(req: ExportReportRequest): Promise<ExportReportJsonResponse | ExportReportCsvResponse>;
|
|
1587
1737
|
uploadReceipt(req: UploadReceiptRequest): Promise<UploadReceiptResponse>;
|
|
1588
1738
|
receivePayment(req: ReceivePaymentRequest): Promise<ReceivePaymentResponse>;
|
|
1589
|
-
sendBreachAlert(req: SendBreachAlertRequest): Promise<SendBreachAlertResponse>;
|
|
1590
1739
|
private mapWalletObject;
|
|
1591
1740
|
listWallets(filters?: ListWalletsRequest): Promise<ListWalletsResponse>;
|
|
1592
1741
|
createWallet(req: CreateWalletRequest): Promise<CreateWalletResponse>;
|
|
@@ -1633,4 +1782,4 @@ declare class Soledgic {
|
|
|
1633
1782
|
importBankStatement(req: ImportBankStatementRequest): Promise<any>;
|
|
1634
1783
|
}
|
|
1635
1784
|
|
|
1636
|
-
export { type AlertChannel, type AlertConfiguration, type AlertTestResult, type AlertThresholds, type AlertType, AuthenticationError, type AuthorizationDecisionType, type AuthorizationPolicy, type AuthorizationResult, type AutoMatchReconciliationResponse, type BackdatePolicyRequest, type BreachRisk, type CheckoutBreakdown, type CheckoutSessionResourceResponse, type ComplianceAccessPatternsResponse, type ComplianceFinancialActivityResponse, type ComplianceOverviewResponse, type ComplianceSecuritySummaryResponse, ConflictError, type CreateAlertRequest, type CreateBankAccountRequest, type CreateBudgetRequest, type CreateCheckoutSessionRequest, type CreateContractorRequest, type CreateInvoiceRequest, type CreateLedgerRequest, type CreateLedgerResponse, type CreateParticipantRequest, type CreateParticipantResponse, type CreatePayoutRequest, type CreatePeriodRequest, type CreatePolicyRequest, type CreateRecurringRequest, type CreateRefundRequest, type CreateSnapshotRequest, type CreateWalletRequest, type CreateWalletResponse, DEFAULT_API_VERSION, DEFAULT_BASE_URL, type EmailAlertConfig, type ExportReportCsvResponse, type ExportReportJsonResponse, type ExportReportRequest, type ExtractedTerms, type FraudPolicyDeleteResponse, type FraudPolicyListResponse, type FraudPolicyResource, type FraudPolicyResponse, type FrozenStatement, type GetWalletResponse, type HeldFund, type HeldFundsResponse, type HeldFundsSummaryResponse, type HoldQueryOptions, type ImportBankStatementLine, type ImportBankStatementRequest, type InvoiceLineItem, type ListRefundsRequest, type ListRefundsResponse, type ListWalletsRequest, type ListWalletsResponse, NotFoundError, type ObligationItem, type Obligations, type ParsedWebhookEvent, type ParticipantDetail, type ParticipantPayoutEligibilityResponse, type ParticipantPayoutPreferences, type ParticipantSummary, type ParticipantTaxInfo, type ParticipantTransferRequest, type ParticipantTransferResponse, type ParticipantWalletMutationRequest, type PayBillRequest, type PayoutResourceResponse, type Period, type PolicySeverity, type PolicyType, type PolicyViolation, type PreflightAuthorizationRequest, type PreflightAuthorizationResponse, type PreflightResult, type ProjectIntentRequest, type ProjectIntentResponse, type ProjectionMatch, type ReceivePaymentRequest, type ReceivePaymentResponse, type ReconcileMatchRequest, type ReconciliationMatchResponse, type ReconciliationSnapshot, type ReconciliationUnmatchResponse, type RecordAdjustmentRequest, type RecordBillRequest, type RecordContractorPaymentRequest, type RecordExpenseRequest, type RecordIncomeRequest, type RecordInvoicePaymentRequest, type RecordOpeningBalanceRequest, type RecordRefundResponse, type RecordTransferRequest, type RefundResourceResponse, type RefundSummary, type RegisterInstrumentRequest, type RegisterInstrumentResponse, type ReleaseHoldRequest, type ReleaseHoldResponse, type ReverseResponse, type ReverseTransactionRequest, type RiskEvaluationRequest, type RiskEvaluationResponse, type
|
|
1785
|
+
export { type AlertChannel, type AlertConfiguration, type AlertTestResult, type AlertThresholds, type AlertType, AuthenticationError, type AuthorizationDecisionType, type AuthorizationPolicy, type AuthorizationResult, type AutoMatchReconciliationResponse, type BackdatePolicyRequest, type BreachRisk, type CheckoutBreakdown, type CheckoutSessionResourceResponse, type ComplianceAccessPatternsResponse, type ComplianceFinancialActivityResponse, type ComplianceOverviewResponse, type ComplianceSecuritySummaryResponse, ConflictError, type CreateAlertRequest, type CreateBankAccountRequest, type CreateBudgetRequest, type CreateCheckoutSessionRequest, type CreateContractorRequest, type CreateCreatorWalletRequest, type CreateInvoiceRequest, type CreateLedgerRequest, type CreateLedgerResponse, type CreateParticipantRequest, type CreateParticipantResponse, type CreatePayoutRequest, type CreatePeriodRequest, type CreatePolicyRequest, type CreateRecurringRequest, type CreateRefundRequest, type CreateSnapshotRequest, type CreateWalletRequest, type CreateWalletResponse, DEFAULT_API_VERSION, DEFAULT_BASE_URL, type EmailAlertConfig, type ExportReportCsvResponse, type ExportReportJsonResponse, type ExportReportRequest, type ExtractedTerms, type FraudPolicyDeleteResponse, type FraudPolicyListResponse, type FraudPolicyResource, type FraudPolicyResponse, type FrozenStatement, type GetWalletResponse, type HeldFund, type HeldFundsResponse, type HeldFundsSummaryResponse, type HoldQueryOptions, type ImportBankStatementLine, type ImportBankStatementRequest, type InvoiceLineItem, type ListRefundsRequest, type ListRefundsResponse, type ListWalletsRequest, type ListWalletsResponse, NotFoundError, type ObligationItem, type Obligations, type ParsedWebhookEvent, type ParticipantDetail, type ParticipantPayoutEligibilityResponse, type ParticipantPayoutPreferences, type ParticipantSummary, type ParticipantTaxInfo, type ParticipantTransferRequest, type ParticipantTransferResponse, type ParticipantWalletMutationRequest, type PayBillRequest, type PayoutResourceResponse, type Period, type PolicySeverity, type PolicyType, type PolicyViolation, type PreflightAuthorizationRequest, type PreflightAuthorizationResponse, type PreflightResult, type ProjectIntentRequest, type ProjectIntentResponse, type ProjectionMatch, type ReceivePaymentRequest, type ReceivePaymentResponse, type ReconcileMatchRequest, type ReconciliationMatchResponse, type ReconciliationSnapshot, type ReconciliationUnmatchResponse, type RecordAdjustmentRequest, type RecordBillRequest, type RecordContractorPaymentRequest, type RecordExpenseRequest, type RecordIncomeRequest, type RecordInvoicePaymentRequest, type RecordOpeningBalanceRequest, type RecordRefundResponse, type RecordTransferRequest, type RefundResourceResponse, type RefundSummary, type RegisterInstrumentRequest, type RegisterInstrumentResponse, type ReleaseHoldRequest, type ReleaseHoldResponse, type ReverseResponse, type ReverseTransactionRequest, type RiskEvaluationRequest, type RiskEvaluationResponse, type SlackAlertConfig, Soledgic, type SoledgicConfig, SoledgicError, type SubmitTaxInfoRequest, type TaxCalculationResponse, type TaxDocumentGenerationResponse, type TaxDocumentResponse, type TaxDocumentsResponse, type TaxSummaryResponse, type UniversalCheckoutRequest, type UnmatchedTransactionsResponse, type UpdateAlertRequest, type UploadReceiptRequest, type UploadReceiptResponse, type UpsertCreatorRequest, type UpsertUserWalletRequest, ValidationError, type VerifyWebhookSignatureOptions, type WalletEntriesResponse, type WalletHistoryEntry, type WalletObject, type WalletTopupRequest, type WalletTopupResponse, type WalletWithdrawRequest, type WalletWithdrawalResponse, type WebhookDelivery, type WebhookEndpoint, type WebhookEndpointSecretResult, type WebhookPayloadInput, Soledgic as default, hmacHex, isArrayBufferView, mapWebhookDelivery, mapWebhookEndpoint, normalizeBaseUrl, parseWebhookEvent, parseWebhookSignatureHeader, resolveWebhookEndpointUrl, timingSafeEqual, verifyWebhookSignature, webhookPayloadToString };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
isArrayBufferView: () => isArrayBufferView,
|
|
34
34
|
mapWebhookDelivery: () => mapWebhookDelivery,
|
|
35
35
|
mapWebhookEndpoint: () => mapWebhookEndpoint,
|
|
36
|
+
normalizeBaseUrl: () => normalizeBaseUrl,
|
|
36
37
|
parseWebhookEvent: () => parseWebhookEvent,
|
|
37
38
|
parseWebhookSignatureHeader: () => parseWebhookSignatureHeader,
|
|
38
39
|
resolveWebhookEndpointUrl: () => resolveWebhookEndpointUrl,
|
|
@@ -223,11 +224,102 @@ function mapWebhookDelivery(delivery) {
|
|
|
223
224
|
// src/client.ts
|
|
224
225
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
225
226
|
var DEFAULT_BASE_URL = "https://api.soledgic.com/v1";
|
|
227
|
+
function normalizeBaseUrl(input) {
|
|
228
|
+
const raw = (input?.trim() || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
229
|
+
const deduped = raw.replace(/(?:\/v1)+$/, "/v1");
|
|
230
|
+
if (deduped.endsWith("/v1")) return deduped;
|
|
231
|
+
return `${deduped}/v1`;
|
|
232
|
+
}
|
|
226
233
|
var Soledgic = class {
|
|
227
234
|
constructor(config) {
|
|
228
235
|
this.webhooks = {
|
|
229
236
|
verifySignature: (payload, signatureHeader, secret, options) => verifyWebhookSignature(payload, signatureHeader, secret, options),
|
|
230
|
-
parseEvent: (payload) => parseWebhookEvent(payload)
|
|
237
|
+
parseEvent: (payload) => parseWebhookEvent(payload),
|
|
238
|
+
listEndpoints: () => this.listWebhookEndpoints(),
|
|
239
|
+
createEndpoint: (config) => this.createWebhookEndpoint(config),
|
|
240
|
+
updateEndpoint: (endpointId, updates) => this.updateWebhookEndpoint(endpointId, updates),
|
|
241
|
+
deleteEndpoint: (endpointId) => this.deleteWebhookEndpoint(endpointId),
|
|
242
|
+
testEndpoint: (endpointId) => this.testWebhookEndpoint(endpointId),
|
|
243
|
+
listDeliveries: (endpointId, limit) => this.getWebhookDeliveries(endpointId, limit),
|
|
244
|
+
rotateSecret: (endpointId) => this.rotateWebhookSecret(endpointId)
|
|
245
|
+
};
|
|
246
|
+
this.platform = {
|
|
247
|
+
getStatus: () => this.getHealthStatus()
|
|
248
|
+
};
|
|
249
|
+
this.users = {
|
|
250
|
+
upsertWallet: (req) => this.createWallet({
|
|
251
|
+
ownerId: req.externalUserId,
|
|
252
|
+
ownerType: req.ownerType || "user",
|
|
253
|
+
walletType: "consumer_credit",
|
|
254
|
+
name: req.name,
|
|
255
|
+
metadata: {
|
|
256
|
+
...req.metadata,
|
|
257
|
+
external_user_id: req.externalUserId
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
};
|
|
261
|
+
this.creators = {
|
|
262
|
+
upsert: (req) => this.createParticipant({
|
|
263
|
+
participantId: req.externalCreatorId,
|
|
264
|
+
userId: req.userId,
|
|
265
|
+
displayName: req.displayName,
|
|
266
|
+
email: req.email,
|
|
267
|
+
defaultSplitPercent: req.defaultSplitPercent,
|
|
268
|
+
taxInfo: req.taxInfo,
|
|
269
|
+
payoutPreferences: req.payoutPreferences,
|
|
270
|
+
metadata: {
|
|
271
|
+
...req.metadata,
|
|
272
|
+
external_creator_id: req.externalCreatorId
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
get: (creatorId) => this.getParticipant(creatorId),
|
|
276
|
+
getPayoutEligibility: (creatorId) => this.getParticipantPayoutEligibility(creatorId),
|
|
277
|
+
createWallet: (req) => this.createWallet({
|
|
278
|
+
participantId: req.creatorId,
|
|
279
|
+
walletType: "creator_earnings",
|
|
280
|
+
name: req.name,
|
|
281
|
+
metadata: {
|
|
282
|
+
...req.metadata,
|
|
283
|
+
external_creator_id: req.creatorId
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
};
|
|
287
|
+
this.orders = {
|
|
288
|
+
createCheckout: (req) => this.createUniversalCheckout(req)
|
|
289
|
+
};
|
|
290
|
+
this.purchases = {
|
|
291
|
+
create: (req) => this.createUniversalCheckout(req)
|
|
292
|
+
};
|
|
293
|
+
this.wallets = {
|
|
294
|
+
list: (filters) => this.listWallets(filters),
|
|
295
|
+
create: (req) => this.createWallet(req),
|
|
296
|
+
get: (walletId) => this.getWallet(walletId),
|
|
297
|
+
listActivity: (walletId, options) => this.getWalletEntries(walletId, options),
|
|
298
|
+
topUp: (req) => this.topUpWallet(req),
|
|
299
|
+
withdraw: (req) => this.withdrawFromWallet(req),
|
|
300
|
+
transfer: (req) => this.createTransfer(req)
|
|
301
|
+
};
|
|
302
|
+
this.payouts = {
|
|
303
|
+
request: (req) => this.createPayout(req),
|
|
304
|
+
getEligibility: (creatorId) => this.getParticipantPayoutEligibility(creatorId)
|
|
305
|
+
};
|
|
306
|
+
this.refunds = {
|
|
307
|
+
request: (req) => this.createRefund(req),
|
|
308
|
+
list: (req) => this.listRefunds(req)
|
|
309
|
+
};
|
|
310
|
+
this.holds = {
|
|
311
|
+
list: (options) => this.listHolds(options),
|
|
312
|
+
release: (req) => this.releaseHold(req)
|
|
313
|
+
};
|
|
314
|
+
this.reversals = {
|
|
315
|
+
create: (req) => this.reverseTransaction(req)
|
|
316
|
+
};
|
|
317
|
+
this.receipts = {
|
|
318
|
+
upload: (req) => this.uploadReceipt(req)
|
|
319
|
+
};
|
|
320
|
+
this.activity = {
|
|
321
|
+
listWallet: (walletId, options) => this.getWalletEntries(walletId, options),
|
|
322
|
+
listRefunds: (req) => this.listRefunds(req)
|
|
231
323
|
};
|
|
232
324
|
if (!config.apiKey) {
|
|
233
325
|
throw new Error("apiKey is required");
|
|
@@ -240,7 +332,7 @@ var Soledgic = class {
|
|
|
240
332
|
this._destroyKey = () => {
|
|
241
333
|
key = null;
|
|
242
334
|
};
|
|
243
|
-
this.baseUrl = (config.baseUrl
|
|
335
|
+
this.baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
244
336
|
this.timeoutMs = config.timeout ?? 3e4;
|
|
245
337
|
this.apiVersion = (config.apiVersion || "").trim() || DEFAULT_API_VERSION;
|
|
246
338
|
}
|
|
@@ -354,6 +446,23 @@ var Soledgic = class {
|
|
|
354
446
|
clearTimeout(timer);
|
|
355
447
|
}
|
|
356
448
|
}
|
|
449
|
+
createUniversalCheckout(req) {
|
|
450
|
+
const metadata = {
|
|
451
|
+
...req.metadata,
|
|
452
|
+
...req.externalOrderId ? { external_order_id: req.externalOrderId } : {},
|
|
453
|
+
...req.externalProductId ? { external_product_id: req.externalProductId } : {},
|
|
454
|
+
...req.externalUserId ? { external_user_id: req.externalUserId } : {}
|
|
455
|
+
};
|
|
456
|
+
const checkoutReq = {
|
|
457
|
+
...req,
|
|
458
|
+
participantId: req.creatorId,
|
|
459
|
+
productId: req.externalProductId,
|
|
460
|
+
customerId: req.externalUserId,
|
|
461
|
+
idempotencyKey: "idempotencyKey" in req ? req.idempotencyKey || req.externalOrderId : req.externalOrderId,
|
|
462
|
+
metadata
|
|
463
|
+
};
|
|
464
|
+
return this.createCheckoutSession(checkoutReq);
|
|
465
|
+
}
|
|
357
466
|
async requestGetRaw(endpoint, params) {
|
|
358
467
|
const url = new URL(`${this.baseUrl}/${endpoint}`);
|
|
359
468
|
if (params) {
|
|
@@ -1669,32 +1778,6 @@ var Soledgic = class {
|
|
|
1669
1778
|
metadata: req.metadata
|
|
1670
1779
|
});
|
|
1671
1780
|
}
|
|
1672
|
-
// === BREACH ALERTS ===
|
|
1673
|
-
async sendBreachAlert(req) {
|
|
1674
|
-
const response = await this.request("send-breach-alert", {
|
|
1675
|
-
cash_balance: req.cashBalance,
|
|
1676
|
-
pending_total: req.pendingTotal,
|
|
1677
|
-
shortfall: req.shortfall,
|
|
1678
|
-
coverage_ratio: req.coverageRatio,
|
|
1679
|
-
triggered_by: req.triggeredBy,
|
|
1680
|
-
instrument_id: req.instrumentId,
|
|
1681
|
-
external_ref: req.externalRef,
|
|
1682
|
-
projections_created: req.projectionsCreated,
|
|
1683
|
-
channel: req.channel
|
|
1684
|
-
});
|
|
1685
|
-
return {
|
|
1686
|
-
success: response.success,
|
|
1687
|
-
message: response.message,
|
|
1688
|
-
alertsSent: response.alerts_sent ?? 0,
|
|
1689
|
-
alertsFailed: response.alerts_failed,
|
|
1690
|
-
alertsSkipped: response.alerts_skipped,
|
|
1691
|
-
results: response.results ? response.results.map((r) => ({
|
|
1692
|
-
channel: r.channel,
|
|
1693
|
-
success: r.success,
|
|
1694
|
-
error: r.error
|
|
1695
|
-
})) : void 0
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
1781
|
// === WALLETS ===
|
|
1699
1782
|
mapWalletObject(wallet) {
|
|
1700
1783
|
return {
|
|
@@ -2218,6 +2301,7 @@ var client_default = Soledgic;
|
|
|
2218
2301
|
isArrayBufferView,
|
|
2219
2302
|
mapWebhookDelivery,
|
|
2220
2303
|
mapWebhookEndpoint,
|
|
2304
|
+
normalizeBaseUrl,
|
|
2221
2305
|
parseWebhookEvent,
|
|
2222
2306
|
parseWebhookSignatureHeader,
|
|
2223
2307
|
resolveWebhookEndpointUrl,
|
package/dist/index.mjs
CHANGED
|
@@ -179,11 +179,102 @@ function mapWebhookDelivery(delivery) {
|
|
|
179
179
|
// src/client.ts
|
|
180
180
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
181
181
|
var DEFAULT_BASE_URL = "https://api.soledgic.com/v1";
|
|
182
|
+
function normalizeBaseUrl(input) {
|
|
183
|
+
const raw = (input?.trim() || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
184
|
+
const deduped = raw.replace(/(?:\/v1)+$/, "/v1");
|
|
185
|
+
if (deduped.endsWith("/v1")) return deduped;
|
|
186
|
+
return `${deduped}/v1`;
|
|
187
|
+
}
|
|
182
188
|
var Soledgic = class {
|
|
183
189
|
constructor(config) {
|
|
184
190
|
this.webhooks = {
|
|
185
191
|
verifySignature: (payload, signatureHeader, secret, options) => verifyWebhookSignature(payload, signatureHeader, secret, options),
|
|
186
|
-
parseEvent: (payload) => parseWebhookEvent(payload)
|
|
192
|
+
parseEvent: (payload) => parseWebhookEvent(payload),
|
|
193
|
+
listEndpoints: () => this.listWebhookEndpoints(),
|
|
194
|
+
createEndpoint: (config) => this.createWebhookEndpoint(config),
|
|
195
|
+
updateEndpoint: (endpointId, updates) => this.updateWebhookEndpoint(endpointId, updates),
|
|
196
|
+
deleteEndpoint: (endpointId) => this.deleteWebhookEndpoint(endpointId),
|
|
197
|
+
testEndpoint: (endpointId) => this.testWebhookEndpoint(endpointId),
|
|
198
|
+
listDeliveries: (endpointId, limit) => this.getWebhookDeliveries(endpointId, limit),
|
|
199
|
+
rotateSecret: (endpointId) => this.rotateWebhookSecret(endpointId)
|
|
200
|
+
};
|
|
201
|
+
this.platform = {
|
|
202
|
+
getStatus: () => this.getHealthStatus()
|
|
203
|
+
};
|
|
204
|
+
this.users = {
|
|
205
|
+
upsertWallet: (req) => this.createWallet({
|
|
206
|
+
ownerId: req.externalUserId,
|
|
207
|
+
ownerType: req.ownerType || "user",
|
|
208
|
+
walletType: "consumer_credit",
|
|
209
|
+
name: req.name,
|
|
210
|
+
metadata: {
|
|
211
|
+
...req.metadata,
|
|
212
|
+
external_user_id: req.externalUserId
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
};
|
|
216
|
+
this.creators = {
|
|
217
|
+
upsert: (req) => this.createParticipant({
|
|
218
|
+
participantId: req.externalCreatorId,
|
|
219
|
+
userId: req.userId,
|
|
220
|
+
displayName: req.displayName,
|
|
221
|
+
email: req.email,
|
|
222
|
+
defaultSplitPercent: req.defaultSplitPercent,
|
|
223
|
+
taxInfo: req.taxInfo,
|
|
224
|
+
payoutPreferences: req.payoutPreferences,
|
|
225
|
+
metadata: {
|
|
226
|
+
...req.metadata,
|
|
227
|
+
external_creator_id: req.externalCreatorId
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
get: (creatorId) => this.getParticipant(creatorId),
|
|
231
|
+
getPayoutEligibility: (creatorId) => this.getParticipantPayoutEligibility(creatorId),
|
|
232
|
+
createWallet: (req) => this.createWallet({
|
|
233
|
+
participantId: req.creatorId,
|
|
234
|
+
walletType: "creator_earnings",
|
|
235
|
+
name: req.name,
|
|
236
|
+
metadata: {
|
|
237
|
+
...req.metadata,
|
|
238
|
+
external_creator_id: req.creatorId
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
};
|
|
242
|
+
this.orders = {
|
|
243
|
+
createCheckout: (req) => this.createUniversalCheckout(req)
|
|
244
|
+
};
|
|
245
|
+
this.purchases = {
|
|
246
|
+
create: (req) => this.createUniversalCheckout(req)
|
|
247
|
+
};
|
|
248
|
+
this.wallets = {
|
|
249
|
+
list: (filters) => this.listWallets(filters),
|
|
250
|
+
create: (req) => this.createWallet(req),
|
|
251
|
+
get: (walletId) => this.getWallet(walletId),
|
|
252
|
+
listActivity: (walletId, options) => this.getWalletEntries(walletId, options),
|
|
253
|
+
topUp: (req) => this.topUpWallet(req),
|
|
254
|
+
withdraw: (req) => this.withdrawFromWallet(req),
|
|
255
|
+
transfer: (req) => this.createTransfer(req)
|
|
256
|
+
};
|
|
257
|
+
this.payouts = {
|
|
258
|
+
request: (req) => this.createPayout(req),
|
|
259
|
+
getEligibility: (creatorId) => this.getParticipantPayoutEligibility(creatorId)
|
|
260
|
+
};
|
|
261
|
+
this.refunds = {
|
|
262
|
+
request: (req) => this.createRefund(req),
|
|
263
|
+
list: (req) => this.listRefunds(req)
|
|
264
|
+
};
|
|
265
|
+
this.holds = {
|
|
266
|
+
list: (options) => this.listHolds(options),
|
|
267
|
+
release: (req) => this.releaseHold(req)
|
|
268
|
+
};
|
|
269
|
+
this.reversals = {
|
|
270
|
+
create: (req) => this.reverseTransaction(req)
|
|
271
|
+
};
|
|
272
|
+
this.receipts = {
|
|
273
|
+
upload: (req) => this.uploadReceipt(req)
|
|
274
|
+
};
|
|
275
|
+
this.activity = {
|
|
276
|
+
listWallet: (walletId, options) => this.getWalletEntries(walletId, options),
|
|
277
|
+
listRefunds: (req) => this.listRefunds(req)
|
|
187
278
|
};
|
|
188
279
|
if (!config.apiKey) {
|
|
189
280
|
throw new Error("apiKey is required");
|
|
@@ -196,7 +287,7 @@ var Soledgic = class {
|
|
|
196
287
|
this._destroyKey = () => {
|
|
197
288
|
key = null;
|
|
198
289
|
};
|
|
199
|
-
this.baseUrl = (config.baseUrl
|
|
290
|
+
this.baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
200
291
|
this.timeoutMs = config.timeout ?? 3e4;
|
|
201
292
|
this.apiVersion = (config.apiVersion || "").trim() || DEFAULT_API_VERSION;
|
|
202
293
|
}
|
|
@@ -310,6 +401,23 @@ var Soledgic = class {
|
|
|
310
401
|
clearTimeout(timer);
|
|
311
402
|
}
|
|
312
403
|
}
|
|
404
|
+
createUniversalCheckout(req) {
|
|
405
|
+
const metadata = {
|
|
406
|
+
...req.metadata,
|
|
407
|
+
...req.externalOrderId ? { external_order_id: req.externalOrderId } : {},
|
|
408
|
+
...req.externalProductId ? { external_product_id: req.externalProductId } : {},
|
|
409
|
+
...req.externalUserId ? { external_user_id: req.externalUserId } : {}
|
|
410
|
+
};
|
|
411
|
+
const checkoutReq = {
|
|
412
|
+
...req,
|
|
413
|
+
participantId: req.creatorId,
|
|
414
|
+
productId: req.externalProductId,
|
|
415
|
+
customerId: req.externalUserId,
|
|
416
|
+
idempotencyKey: "idempotencyKey" in req ? req.idempotencyKey || req.externalOrderId : req.externalOrderId,
|
|
417
|
+
metadata
|
|
418
|
+
};
|
|
419
|
+
return this.createCheckoutSession(checkoutReq);
|
|
420
|
+
}
|
|
313
421
|
async requestGetRaw(endpoint, params) {
|
|
314
422
|
const url = new URL(`${this.baseUrl}/${endpoint}`);
|
|
315
423
|
if (params) {
|
|
@@ -1625,32 +1733,6 @@ var Soledgic = class {
|
|
|
1625
1733
|
metadata: req.metadata
|
|
1626
1734
|
});
|
|
1627
1735
|
}
|
|
1628
|
-
// === BREACH ALERTS ===
|
|
1629
|
-
async sendBreachAlert(req) {
|
|
1630
|
-
const response = await this.request("send-breach-alert", {
|
|
1631
|
-
cash_balance: req.cashBalance,
|
|
1632
|
-
pending_total: req.pendingTotal,
|
|
1633
|
-
shortfall: req.shortfall,
|
|
1634
|
-
coverage_ratio: req.coverageRatio,
|
|
1635
|
-
triggered_by: req.triggeredBy,
|
|
1636
|
-
instrument_id: req.instrumentId,
|
|
1637
|
-
external_ref: req.externalRef,
|
|
1638
|
-
projections_created: req.projectionsCreated,
|
|
1639
|
-
channel: req.channel
|
|
1640
|
-
});
|
|
1641
|
-
return {
|
|
1642
|
-
success: response.success,
|
|
1643
|
-
message: response.message,
|
|
1644
|
-
alertsSent: response.alerts_sent ?? 0,
|
|
1645
|
-
alertsFailed: response.alerts_failed,
|
|
1646
|
-
alertsSkipped: response.alerts_skipped,
|
|
1647
|
-
results: response.results ? response.results.map((r) => ({
|
|
1648
|
-
channel: r.channel,
|
|
1649
|
-
success: r.success,
|
|
1650
|
-
error: r.error
|
|
1651
|
-
})) : void 0
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
1736
|
// === WALLETS ===
|
|
1655
1737
|
mapWalletObject(wallet) {
|
|
1656
1738
|
return {
|
|
@@ -2174,6 +2256,7 @@ export {
|
|
|
2174
2256
|
isArrayBufferView,
|
|
2175
2257
|
mapWebhookDelivery,
|
|
2176
2258
|
mapWebhookEndpoint,
|
|
2259
|
+
normalizeBaseUrl,
|
|
2177
2260
|
parseWebhookEvent,
|
|
2178
2261
|
parseWebhookSignatureHeader,
|
|
2179
2262
|
resolveWebhookEndpointUrl,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soledgic/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Wallet-first payment infrastructure API for marketplaces, creator platforms, and closed-loop app economies",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
34
34
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
35
35
|
"test": "vitest run",
|
|
36
|
-
"
|
|
36
|
+
"audit:package": "node ../../scripts/audit-sdk-package.mjs",
|
|
37
|
+
"prepublishOnly": "npm run build && npm run audit:package"
|
|
37
38
|
},
|
|
38
39
|
"keywords": [
|
|
39
40
|
"accounting",
|