@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/edge.d.ts +118 -1
- package/dist/edge.js +83 -0
- package/dist/fetch/index.cjs +50 -16
- package/dist/fetch/index.d.cts +31 -0
- package/dist/fetch/index.d.ts +31 -0
- package/dist/fetch/index.js +36 -0
- package/dist/index.cjs +99 -17
- package/dist/index.d.cts +118 -1
- package/dist/index.d.ts +118 -1
- package/dist/index.js +83 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -490,6 +490,31 @@ function createSolvaPayClient(opts) {
|
|
|
490
490
|
const result = await res.json();
|
|
491
491
|
return result;
|
|
492
492
|
},
|
|
493
|
+
// POST: /v1/sdk/payment-intents/{paymentIntentId}/business-details
|
|
494
|
+
async attachBusinessDetails(params) {
|
|
495
|
+
const url = `${base}/v1/sdk/payment-intents/${params.paymentIntentId}/business-details`;
|
|
496
|
+
const res = await fetch(url, {
|
|
497
|
+
method: "POST",
|
|
498
|
+
headers,
|
|
499
|
+
body: JSON.stringify({
|
|
500
|
+
isBusiness: params.isBusiness,
|
|
501
|
+
...params.businessName !== void 0 && { businessName: params.businessName },
|
|
502
|
+
...params.country !== void 0 && { country: params.country },
|
|
503
|
+
...params.taxId !== void 0 && { taxId: params.taxId },
|
|
504
|
+
...params.taxIdType !== void 0 && { taxIdType: params.taxIdType },
|
|
505
|
+
...params.customerRef !== void 0 && { customerRef: params.customerRef }
|
|
506
|
+
})
|
|
507
|
+
});
|
|
508
|
+
if (!res.ok) {
|
|
509
|
+
const error = await res.text();
|
|
510
|
+
log(`\u274C API Error: ${res.status} - ${error}`);
|
|
511
|
+
throw new SolvaPayError(
|
|
512
|
+
`Attach business details failed (${res.status}): ${error}`,
|
|
513
|
+
{ status: res.status }
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
return await res.json();
|
|
517
|
+
},
|
|
493
518
|
// POST: /v1/sdk/purchases/{purchaseRef}/cancel
|
|
494
519
|
async cancelPurchase(params) {
|
|
495
520
|
const url = `${base}/v1/sdk/purchases/${params.purchaseRef}/cancel`;
|
|
@@ -2013,6 +2038,14 @@ function createSolvaPay(config) {
|
|
|
2013
2038
|
}
|
|
2014
2039
|
return apiClient.processPaymentIntent(params);
|
|
2015
2040
|
},
|
|
2041
|
+
attachBusinessDetails(params) {
|
|
2042
|
+
if (!apiClient.attachBusinessDetails) {
|
|
2043
|
+
throw new SolvaPayError2(
|
|
2044
|
+
"attachBusinessDetails is not available on this API client"
|
|
2045
|
+
);
|
|
2046
|
+
}
|
|
2047
|
+
return apiClient.attachBusinessDetails(params);
|
|
2048
|
+
},
|
|
2016
2049
|
checkLimits(params) {
|
|
2017
2050
|
return apiClient.checkLimits(params);
|
|
2018
2051
|
},
|
|
@@ -2414,6 +2447,11 @@ async function getCustomerBalanceCore(request, options = {}) {
|
|
|
2414
2447
|
}
|
|
2415
2448
|
}
|
|
2416
2449
|
|
|
2450
|
+
// src/helpers/payment.ts
|
|
2451
|
+
import {
|
|
2452
|
+
validateBusinessDetails
|
|
2453
|
+
} from "@solvapay/core";
|
|
2454
|
+
|
|
2417
2455
|
// src/helpers/balance-poll.ts
|
|
2418
2456
|
var TOPUP_BALANCE_POLL_DELAYS_MS = [500, 1e3, 2e3, 4e3];
|
|
2419
2457
|
var BALANCE_RECONCILE_DELAYS_MS = [500, 1e3, 2e3, 4e3, 8e3, 16e3];
|
|
@@ -2546,6 +2584,50 @@ async function processPaymentIntentCore(request, body, options = {}) {
|
|
|
2546
2584
|
return handleRouteError(error, "Process payment intent", "Payment processing failed");
|
|
2547
2585
|
}
|
|
2548
2586
|
}
|
|
2587
|
+
async function attachBusinessDetailsCore(request, body, options = {}) {
|
|
2588
|
+
try {
|
|
2589
|
+
if (!body.paymentIntentId) {
|
|
2590
|
+
return {
|
|
2591
|
+
error: "paymentIntentId is required",
|
|
2592
|
+
status: 400
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
const validation = validateBusinessDetails({
|
|
2596
|
+
isBusiness: body.isBusiness,
|
|
2597
|
+
businessName: body.businessName,
|
|
2598
|
+
country: body.country,
|
|
2599
|
+
taxId: body.taxId,
|
|
2600
|
+
taxIdType: body.taxIdType
|
|
2601
|
+
});
|
|
2602
|
+
if (!validation.success) {
|
|
2603
|
+
const firstIssue = validation.error.issues[0];
|
|
2604
|
+
return {
|
|
2605
|
+
error: firstIssue?.message ?? "Invalid business details",
|
|
2606
|
+
status: 400
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
const solvaPay = options.solvaPay || createSolvaPay();
|
|
2610
|
+
if (typeof solvaPay.attachBusinessDetails !== "function") {
|
|
2611
|
+
return {
|
|
2612
|
+
error: "attachBusinessDetails is not available on this SolvaPay client",
|
|
2613
|
+
status: 501
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
const details = validation.data;
|
|
2617
|
+
const result = await solvaPay.attachBusinessDetails({
|
|
2618
|
+
paymentIntentId: body.paymentIntentId,
|
|
2619
|
+
...body.customerRef !== void 0 && { customerRef: body.customerRef },
|
|
2620
|
+
...details
|
|
2621
|
+
});
|
|
2622
|
+
return result;
|
|
2623
|
+
} catch (error) {
|
|
2624
|
+
return handleRouteError(
|
|
2625
|
+
error,
|
|
2626
|
+
"Attach business details",
|
|
2627
|
+
"Failed to attach business details"
|
|
2628
|
+
);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2549
2631
|
async function processTopupPaymentIntentCore(request, body, options = {}) {
|
|
2550
2632
|
try {
|
|
2551
2633
|
if (!body.paymentIntentId) {
|
|
@@ -3214,6 +3296,7 @@ export {
|
|
|
3214
3296
|
TOPUP_BALANCE_POLL_DELAYS_MS,
|
|
3215
3297
|
VIRTUAL_TOOL_DEFINITIONS,
|
|
3216
3298
|
activatePlanCore,
|
|
3299
|
+
attachBusinessDetailsCore,
|
|
3217
3300
|
buildGateMessage,
|
|
3218
3301
|
buildNudgeMessage,
|
|
3219
3302
|
buildPaywallGate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-preview-e2cd9bda9dee33e68f6bba7098f7d683e6f1b742",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@solvapay/core": "1.
|
|
45
|
+
"@solvapay/core": "1.2.0-preview-e2cd9bda9dee33e68f6bba7098f7d683e6f1b742"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^3.25.0 || ^4.0.0",
|