@fire-spark/core 0.12.2 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +16 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -462,6 +462,15 @@ type CreateOrderOptions = {
|
|
|
462
462
|
customer?: OrderCustomerSource;
|
|
463
463
|
fromOrderId?: string;
|
|
464
464
|
isAnonymous?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* ISO 4217 code for a new cart's totals — pass the merchant's
|
|
467
|
+
* `preferences.currency.code`. Ignored when an OPEN order is reused or
|
|
468
|
+
* with `fromOrderId` (the source keeps its currency). The API stamps the
|
|
469
|
+
* merchant currency on every write, so the cart adopts it after the
|
|
470
|
+
* first sync either way; this keeps the local draft right before that.
|
|
471
|
+
* Default `"USD"`.
|
|
472
|
+
*/
|
|
473
|
+
currency?: string;
|
|
465
474
|
/** When false, skips the OPEN-order lookup and starts a local draft. */
|
|
466
475
|
reuseOpen?: boolean;
|
|
467
476
|
orderId?: string;
|
package/dist/index.js
CHANGED
|
@@ -3934,11 +3934,20 @@ const redemptionTenderInputs = (redeem, providers = /* @__PURE__ */ new Map()) =
|
|
|
3934
3934
|
};
|
|
3935
3935
|
});
|
|
3936
3936
|
};
|
|
3937
|
+
/**
|
|
3938
|
+
* `collect_at` when the caller omits it, same rule as the API place
|
|
3939
|
+
* default (D23): cash and the Fire Spark card terminal are collected in
|
|
3940
|
+
* person (`DOOR`); every other method is charged by the SDK (`DEVICE`).
|
|
3941
|
+
*/
|
|
3942
|
+
const defaultTenderCollectAt = (provider, method) => {
|
|
3943
|
+
return isManualPayment(provider, method) ? "DOOR" : "DEVICE";
|
|
3944
|
+
};
|
|
3937
3945
|
/** The one real tender of the simple flow (`allocation: null`). */
|
|
3938
3946
|
const simpleTenderInput = (payment) => {
|
|
3939
3947
|
if (!payment.type || !payment.provider) return null;
|
|
3940
3948
|
if (!isRealPaymentMethod(payment.type)) return null;
|
|
3941
|
-
const
|
|
3949
|
+
const fallback = defaultTenderCollectAt(payment.provider, payment.type);
|
|
3950
|
+
const collect_at = payment.collect_at ?? fallback;
|
|
3942
3951
|
const t1 = {
|
|
3943
3952
|
method: payment.type,
|
|
3944
3953
|
provider: payment.provider
|
|
@@ -5447,6 +5456,11 @@ const optionalBrandId = (value) => {
|
|
|
5447
5456
|
if (!trimmed) return void 0;
|
|
5448
5457
|
return trimmed;
|
|
5449
5458
|
};
|
|
5459
|
+
/** ISO 4217 code, upper-cased; anything else → undefined (USD default). */
|
|
5460
|
+
const optionalCurrency = (value) => {
|
|
5461
|
+
const code = value?.trim().toUpperCase() ?? "";
|
|
5462
|
+
return /^[A-Z]{3}$/.test(code) ? code : void 0;
|
|
5463
|
+
};
|
|
5450
5464
|
const buildInsertFromOptions = (options) => {
|
|
5451
5465
|
if (!options.scope) throw new Error("Order requires scope when fromOrderId is omitted");
|
|
5452
5466
|
if (!options.customer) throw new Error("Order requires customer when fromOrderId is omitted");
|
|
@@ -5470,7 +5484,7 @@ const buildInsertFromOptions = (options) => {
|
|
|
5470
5484
|
redeem: []
|
|
5471
5485
|
};
|
|
5472
5486
|
const b5 = {
|
|
5473
|
-
totals: emptyTotals(),
|
|
5487
|
+
totals: emptyTotals(optionalCurrency(options.currency)),
|
|
5474
5488
|
metadata: {},
|
|
5475
5489
|
redemption_steps: []
|
|
5476
5490
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "Fire Spark headless SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"big.js": "6.2.1",
|
|
21
21
|
"dayjs": "1.11.9",
|
|
22
22
|
"@types/big.js": "6.2.2",
|
|
23
|
-
"@fire-spark/payments": "^0.12.
|
|
24
|
-
"@fire-spark/types": "^0.12.
|
|
23
|
+
"@fire-spark/payments": "^0.12.4",
|
|
24
|
+
"@fire-spark/types": "^0.12.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|