@fire-spark/payments 0.17.1 → 0.17.3
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 +10 -1
- package/dist/index.js +7 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -571,7 +571,16 @@ type RedeemLike = {
|
|
|
571
571
|
payment_id?: string | null;
|
|
572
572
|
amount?: number;
|
|
573
573
|
before_taxes?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Omitted on older rows, which cover money (points or a discount).
|
|
576
|
+
* `PRODUCT` links a cart line and covers no money.
|
|
577
|
+
*/
|
|
578
|
+
type?: "POINTS" | "DISCOUNT" | "PRODUCT" | null;
|
|
574
579
|
};
|
|
580
|
+
/** A product reward links a line. It is not a discount. */
|
|
581
|
+
declare const isProductReward: (redeem: {
|
|
582
|
+
type?: string | null;
|
|
583
|
+
}) => boolean;
|
|
575
584
|
/** Redeems of one `payment_id`, ready to seed its tender. */
|
|
576
585
|
type RedemptionGroup = {
|
|
577
586
|
payment_id: string;
|
|
@@ -791,4 +800,4 @@ declare const scopedPaymentStorage: (storage: PaymentStorage, paymentId: string)
|
|
|
791
800
|
/** For tests and web previews; apps provide AsyncStorage or localStorage. */
|
|
792
801
|
declare const memoryPaymentStorage: () => PaymentStorage;
|
|
793
802
|
//#endregion
|
|
794
|
-
export { ACTIVE_INTENT_STATUSES, AllocateTenderInput, AllocateTendersInput, AllocateTendersResult, AllocatedTender, AllocationError, CURRENCY_DECIMALS, ChargeConversion, DEFAULT_PAYMENT_POLICY, DELIVERY_FEE_BASED_ON, DIGITAL_COLLECT_AT, type DeviceField, MANUAL_PAYMENT_METHODS, MergePaymentTenderOutcome, MergePaymentTenderResult, Money, NEXT_STATUSES, PARTIAL_APPROVAL_ERROR, PAYMENT_CHALLENGE_MESSAGE, PAYMENT_ERROR_CODES, PAYMENT_ERROR_DEFAULTS, type PaymentAction, type PaymentAdapter, type PaymentAdapterCapabilities, type PaymentAmount, type PaymentCardType, PaymentChallenge, PaymentChallengeInput, PaymentChallengeMessage, PaymentChallengeResult, type PaymentCollectAt, type PaymentContext, type PaymentCustomer, type PaymentEntryMode, type PaymentEnvironment, PaymentError, PaymentErrorCode, PaymentErrorDictionary, PaymentErrorEntry, PaymentErrorReason, type PaymentIntentStatus, type PaymentMetadata, type PaymentMetadataPayment, type PaymentOperation, type PaymentPolicy, type PaymentResult, type PaymentReversal, type PaymentServer, type PaymentStorage, PaymentTenderUpdate, type PaymentUI, REDEMPTION_METHOD, RawPaymentError, RedeemLike, RedeemSource, RedemptionDetails, RedemptionGroup, RedemptionReward, RulesTender, StandardPaymentError, TERMINAL_TENDER_STATUSES, TIP_FEE_BASED_ON, type TaxBreakdown, TaxLine, type TerminalContext, type TerminalOperation, type TerminalOperations, type TerminalResult, ValidateTendersResult, activeIntent, allocateTenders, batchCloseDay, countTenderItems, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, definePaymentErrors, derivePaymentStatus, formatPaymentError, groupRedeems, hasRedeemPayment, isBatchCloseDue, isDeliveryFee, isIntentCovered, isManualPayment, isMixedTenders, isPaymentError, isRealPaymentMethod, isRedemptionReserved, isScopePaid, isTenderSettled, isTerminalLocked, isTipFee, liveRealTenders, liveTenders, memoryPaymentStorage, mergePaymentTender, missingDeviceFields, money, moneyMax, moneyMin, moneyNumber, moneyNumbers, moneySum, moneyZero, nextIntentStatus, orderRedeems, parsePaymentChallengeMessage, paymentChallengeDocument, primaryTender, primaryTenderOf, prorateMinor, realTenders, redeemsCoverTotal, redemptionDetailsOf, redemptionRewardsOf, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, splitMoney, taxBreakdown, tendersCoverage, tendersInScope, toChargeAmount, toPaymentAmount, toPaymentError, validateTendersAgainstRules, withTerminalLock };
|
|
803
|
+
export { ACTIVE_INTENT_STATUSES, AllocateTenderInput, AllocateTendersInput, AllocateTendersResult, AllocatedTender, AllocationError, CURRENCY_DECIMALS, ChargeConversion, DEFAULT_PAYMENT_POLICY, DELIVERY_FEE_BASED_ON, DIGITAL_COLLECT_AT, type DeviceField, MANUAL_PAYMENT_METHODS, MergePaymentTenderOutcome, MergePaymentTenderResult, Money, NEXT_STATUSES, PARTIAL_APPROVAL_ERROR, PAYMENT_CHALLENGE_MESSAGE, PAYMENT_ERROR_CODES, PAYMENT_ERROR_DEFAULTS, type PaymentAction, type PaymentAdapter, type PaymentAdapterCapabilities, type PaymentAmount, type PaymentCardType, PaymentChallenge, PaymentChallengeInput, PaymentChallengeMessage, PaymentChallengeResult, type PaymentCollectAt, type PaymentContext, type PaymentCustomer, type PaymentEntryMode, type PaymentEnvironment, PaymentError, PaymentErrorCode, PaymentErrorDictionary, PaymentErrorEntry, PaymentErrorReason, type PaymentIntentStatus, type PaymentMetadata, type PaymentMetadataPayment, type PaymentOperation, type PaymentPolicy, type PaymentResult, type PaymentReversal, type PaymentServer, type PaymentStorage, PaymentTenderUpdate, type PaymentUI, REDEMPTION_METHOD, RawPaymentError, RedeemLike, RedeemSource, RedemptionDetails, RedemptionGroup, RedemptionReward, RulesTender, StandardPaymentError, TERMINAL_TENDER_STATUSES, TIP_FEE_BASED_ON, type TaxBreakdown, TaxLine, type TerminalContext, type TerminalOperation, type TerminalOperations, type TerminalResult, ValidateTendersResult, activeIntent, allocateTenders, batchCloseDay, countTenderItems, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, definePaymentErrors, derivePaymentStatus, formatPaymentError, groupRedeems, hasRedeemPayment, isBatchCloseDue, isDeliveryFee, isIntentCovered, isManualPayment, isMixedTenders, isPaymentError, isProductReward, isRealPaymentMethod, isRedemptionReserved, isScopePaid, isTenderSettled, isTerminalLocked, isTipFee, liveRealTenders, liveTenders, memoryPaymentStorage, mergePaymentTender, missingDeviceFields, money, moneyMax, moneyMin, moneyNumber, moneyNumbers, moneySum, moneyZero, nextIntentStatus, orderRedeems, parsePaymentChallengeMessage, paymentChallengeDocument, primaryTender, primaryTenderOf, prorateMinor, realTenders, redeemsCoverTotal, redemptionDetailsOf, redemptionRewardsOf, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, splitMoney, taxBreakdown, tendersCoverage, tendersInScope, toChargeAmount, toPaymentAmount, toPaymentError, validateTendersAgainstRules, withTerminalLock };
|
package/dist/index.js
CHANGED
|
@@ -1269,6 +1269,10 @@ const isBatchCloseDue = (input) => {
|
|
|
1269
1269
|
const batchCloseDay = (now) => localDay(now);
|
|
1270
1270
|
//#endregion
|
|
1271
1271
|
//#region src/redemptions.ts
|
|
1272
|
+
/** A product reward links a line. It is not a discount. */
|
|
1273
|
+
const isProductReward = (redeem) => {
|
|
1274
|
+
return redeem.type === "PRODUCT";
|
|
1275
|
+
};
|
|
1272
1276
|
const add = (left, right) => {
|
|
1273
1277
|
return moneyNumber(money(left).plus(right));
|
|
1274
1278
|
};
|
|
@@ -1294,7 +1298,7 @@ const orderRedeems = (order) => {
|
|
|
1294
1298
|
*/
|
|
1295
1299
|
const redeemsCoverTotal = (redeem, totals) => {
|
|
1296
1300
|
const paid = redeem.reduce((sum, item) => {
|
|
1297
|
-
if (!hasRedeemPayment(item)) return sum;
|
|
1301
|
+
if (!hasRedeemPayment(item) || isProductReward(item)) return sum;
|
|
1298
1302
|
return sum.plus(item.amount ?? 0);
|
|
1299
1303
|
}, moneyZero());
|
|
1300
1304
|
if (paid.lte(0)) return false;
|
|
@@ -1326,7 +1330,7 @@ const detailsOf = (rewards, loyalty_transaction_id) => {
|
|
|
1326
1330
|
const groupRedeems = (redeem) => {
|
|
1327
1331
|
const groups = /* @__PURE__ */ new Map();
|
|
1328
1332
|
for (const item of redeem) {
|
|
1329
|
-
if (!hasRedeemPayment(item)) continue;
|
|
1333
|
+
if (!hasRedeemPayment(item) || isProductReward(item)) continue;
|
|
1330
1334
|
const payment_id = item.payment_id;
|
|
1331
1335
|
const list = groups.get(payment_id) ?? [];
|
|
1332
1336
|
list.push(item);
|
|
@@ -1482,4 +1486,4 @@ const memoryPaymentStorage = () => {
|
|
|
1482
1486
|
};
|
|
1483
1487
|
};
|
|
1484
1488
|
//#endregion
|
|
1485
|
-
export { ACTIVE_INTENT_STATUSES, CURRENCY_DECIMALS, DEFAULT_PAYMENT_POLICY, DELIVERY_FEE_BASED_ON, DIGITAL_COLLECT_AT, MANUAL_PAYMENT_METHODS, NEXT_STATUSES, PARTIAL_APPROVAL_ERROR, PAYMENT_CHALLENGE_MESSAGE, PAYMENT_ERROR_CODES, PAYMENT_ERROR_DEFAULTS, PaymentError, REDEMPTION_METHOD, TERMINAL_TENDER_STATUSES, TIP_FEE_BASED_ON, activeIntent, allocateTenders, batchCloseDay, countTenderItems, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, definePaymentErrors, derivePaymentStatus, formatPaymentError, groupRedeems, hasRedeemPayment, isBatchCloseDue, isDeliveryFee, isIntentCovered, isManualPayment, isMixedTenders, isPaymentError, isRealPaymentMethod, isRedemptionReserved, isScopePaid, isTenderSettled, isTerminalLocked, isTipFee, liveRealTenders, liveTenders, memoryPaymentStorage, mergePaymentTender, missingDeviceFields, money, moneyMax, moneyMin, moneyNumber, moneyNumbers, moneySum, moneyZero, nextIntentStatus, orderRedeems, parsePaymentChallengeMessage, paymentChallengeDocument, primaryTender, primaryTenderOf, prorateMinor, realTenders, redeemsCoverTotal, redemptionDetailsOf, redemptionRewardsOf, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, splitMoney, taxBreakdown, tendersCoverage, tendersInScope, toChargeAmount, toPaymentAmount, toPaymentError, validateTendersAgainstRules, withTerminalLock };
|
|
1489
|
+
export { ACTIVE_INTENT_STATUSES, CURRENCY_DECIMALS, DEFAULT_PAYMENT_POLICY, DELIVERY_FEE_BASED_ON, DIGITAL_COLLECT_AT, MANUAL_PAYMENT_METHODS, NEXT_STATUSES, PARTIAL_APPROVAL_ERROR, PAYMENT_CHALLENGE_MESSAGE, PAYMENT_ERROR_CODES, PAYMENT_ERROR_DEFAULTS, PaymentError, REDEMPTION_METHOD, TERMINAL_TENDER_STATUSES, TIP_FEE_BASED_ON, activeIntent, allocateTenders, batchCloseDay, countTenderItems, createAttemptReference, createPaymentError, currencyDecimals, currentIntent, defaultReversalFor, definePaymentErrors, derivePaymentStatus, formatPaymentError, groupRedeems, hasRedeemPayment, isBatchCloseDue, isDeliveryFee, isIntentCovered, isManualPayment, isMixedTenders, isPaymentError, isProductReward, isRealPaymentMethod, isRedemptionReserved, isScopePaid, isTenderSettled, isTerminalLocked, isTipFee, liveRealTenders, liveTenders, memoryPaymentStorage, mergePaymentTender, missingDeviceFields, money, moneyMax, moneyMin, moneyNumber, moneyNumbers, moneySum, moneyZero, nextIntentStatus, orderRedeems, parsePaymentChallengeMessage, paymentChallengeDocument, primaryTender, primaryTenderOf, prorateMinor, realTenders, redeemsCoverTotal, redemptionDetailsOf, redemptionRewardsOf, resolvePaymentPolicy, resolveProviderEnvironment, roundTo, scopedPaymentStorage, splitMoney, taxBreakdown, tendersCoverage, tendersInScope, toChargeAmount, toPaymentAmount, toPaymentError, validateTendersAgainstRules, withTerminalLock };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/payments",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"description": "Fire Spark payments contract: adapters, errors, amounts and policy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"big.js": "6.2.1",
|
|
21
|
-
"@fire-spark/types": "^0.17.
|
|
21
|
+
"@fire-spark/types": "^0.17.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/big.js": "6.2.2",
|