multivendor-wallet 0.0.2 → 0.0.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/hooks/index.cjs +8 -25
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +8 -25
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +33 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/dist/{store-BQ3whei-.d.mts → store-By30oqos.d.mts} +7 -1
- package/dist/{store-BQ3whei-.d.ts → store-By30oqos.d.ts} +7 -1
- package/dist/typeorm/index.cjs +25 -8
- package/dist/typeorm/index.cjs.map +1 -1
- package/dist/typeorm/index.d.mts +1 -1
- package/dist/typeorm/index.d.ts +1 -1
- package/dist/typeorm/index.js +25 -8
- package/dist/typeorm/index.js.map +1 -1
- package/dist/{types-iNUEzUgo.d.ts → types-BzaT7Aqh.d.ts} +1 -1
- package/dist/{types-CrJxUVwX.d.mts → types-D46FcrKZ.d.mts} +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-
|
|
2
|
-
export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-
|
|
3
|
-
import { W as WalletAccountType } from './store-
|
|
4
|
-
export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-
|
|
1
|
+
import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-D46FcrKZ.mjs';
|
|
2
|
+
export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-D46FcrKZ.mjs';
|
|
3
|
+
import { W as WalletAccountType } from './store-By30oqos.mjs';
|
|
4
|
+
export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-By30oqos.mjs';
|
|
5
5
|
export { CreateWalletTables1790000000000, TypeOrmWalletStore, WalletAccountEntity, WalletHoldEntity, WalletLedgerEntryEntity, getWalletOrmMetadata } from './typeorm/index.mjs';
|
|
6
6
|
import { Router } from 'express';
|
|
7
7
|
import 'typeorm';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-
|
|
2
|
-
export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-
|
|
3
|
-
import { W as WalletAccountType } from './store-
|
|
4
|
-
export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-
|
|
1
|
+
import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-BzaT7Aqh.js';
|
|
2
|
+
export { D as DeliveredContext, O as OrderPaidContext, P as PaymentProviderWallet, R as RefundContext, S as SettlementDebitContext, g as WALLET_PLUGIN_TOKEN, h as WalletAdminMutationEvent, i as WalletConfig, C as WalletCreatePaymentInput, j as WalletFeatureFlags, k as WalletHttpConfig, l as WalletLedgerClient, W as WalletLifecycleHooks, b as WalletOrderPaidLine, m as WalletReconciliationConfig } from './types-BzaT7Aqh.js';
|
|
3
|
+
import { W as WalletAccountType } from './store-By30oqos.js';
|
|
4
|
+
export { B as BalanceDeltas, d as CancelHoldParams, C as CreditParams, D as DebitParams, G as GetTransactionsParams, H as HoldParams, f as HoldStatus, I as IWalletStore, g as IWalletStoreTx, h as LedgerEntryType, L as LedgerMutationResult, R as ReleaseParams, T as TransferParams, b as WalletAccount, c as WalletBalance, i as WalletHold, e as WalletLedgerEntry, j as WalletReference, a as WalletStoreContext } from './store-By30oqos.js';
|
|
5
5
|
export { CreateWalletTables1790000000000, TypeOrmWalletStore, WalletAccountEntity, WalletHoldEntity, WalletLedgerEntryEntity, getWalletOrmMetadata } from './typeorm/index.js';
|
|
6
6
|
import { Router } from 'express';
|
|
7
7
|
import 'typeorm';
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,9 @@ var WalletAccountType = /* @__PURE__ */ (function(WalletAccountType2) {
|
|
|
72
72
|
WalletAccountType2["CUSTOMER"] = "customer";
|
|
73
73
|
WalletAccountType2["VENDOR"] = "vendor";
|
|
74
74
|
WalletAccountType2["PLATFORM"] = "platform";
|
|
75
|
+
WalletAccountType2["INVESTOR"] = "investor";
|
|
76
|
+
WalletAccountType2["PLATFORM_INVESTOR_LIABILITY"] = "platform_investor_liability";
|
|
77
|
+
WalletAccountType2["PLATFORM_TDS_PAYABLE"] = "platform_tds_payable";
|
|
75
78
|
return WalletAccountType2;
|
|
76
79
|
})({});
|
|
77
80
|
var LedgerEntryType = /* @__PURE__ */ (function(LedgerEntryType2) {
|
|
@@ -568,31 +571,11 @@ function createRefundHooks(runtime) {
|
|
|
568
571
|
__name(createRefundHooks, "createRefundHooks");
|
|
569
572
|
|
|
570
573
|
// src/hooks/settlement.ts
|
|
571
|
-
function createSettlementHooks(
|
|
572
|
-
const { client, flags } = runtime;
|
|
574
|
+
function createSettlementHooks(_runtime) {
|
|
573
575
|
return {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
const txCtx = {
|
|
579
|
-
nativeTx: ctx.nativeTx
|
|
580
|
-
};
|
|
581
|
-
const amountPaise = toMinorUnit(ctx.amountRupees);
|
|
582
|
-
const vendorAccount = await client.getOrCreateAccount(WalletAccountType.VENDOR, ctx.vendorId, ctx.currency, txCtx);
|
|
583
|
-
const balance = await client.getBalance(vendorAccount.id, txCtx);
|
|
584
|
-
if (balance.available < amountPaise) {
|
|
585
|
-
throw new Error(`Insufficient vendor wallet balance for settlement (vendor ${ctx.vendorId})`);
|
|
586
|
-
}
|
|
587
|
-
await client.debit({
|
|
588
|
-
accountId: vendorAccount.id,
|
|
589
|
-
amount: amountPaise,
|
|
590
|
-
idempotencyKey: `settlement:${ctx.settlementId}:debit:${ctx.vendorId}`,
|
|
591
|
-
reference: {
|
|
592
|
-
referenceType: "settlement",
|
|
593
|
-
referenceId: String(ctx.settlementId)
|
|
594
|
-
}
|
|
595
|
-
}, txCtx);
|
|
576
|
+
/** @deprecated Settlement wallet debits removed — vendor payouts use wallet payout requests. */
|
|
577
|
+
async onSettlementDebit(_ctx) {
|
|
578
|
+
return;
|
|
596
579
|
}
|
|
597
580
|
};
|
|
598
581
|
}
|
|
@@ -1085,7 +1068,7 @@ __name(findCacheLedgerMismatches, "findCacheLedgerMismatches");
|
|
|
1085
1068
|
function createLifecycleHooks(runtime) {
|
|
1086
1069
|
return {
|
|
1087
1070
|
...createOrderHooks(runtime),
|
|
1088
|
-
...createSettlementHooks(
|
|
1071
|
+
...createSettlementHooks(),
|
|
1089
1072
|
...createRefundHooks(runtime)
|
|
1090
1073
|
};
|
|
1091
1074
|
}
|
|
@@ -1789,14 +1772,31 @@ var TypeOrmWalletStoreTx = (_a2 = class {
|
|
|
1789
1772
|
}
|
|
1790
1773
|
});
|
|
1791
1774
|
if (!row) {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1775
|
+
try {
|
|
1776
|
+
row = await repo.save(repo.create({
|
|
1777
|
+
ownerType: type,
|
|
1778
|
+
ownerId,
|
|
1779
|
+
currency,
|
|
1780
|
+
availableBalance: "0",
|
|
1781
|
+
heldBalance: "0"
|
|
1782
|
+
}));
|
|
1783
|
+
} catch (error) {
|
|
1784
|
+
const err = error;
|
|
1785
|
+
const code = err?.code || err?.errno;
|
|
1786
|
+
if (code === "ER_DUP_ENTRY" || code === 1062) {
|
|
1787
|
+
row = await repo.findOne({
|
|
1788
|
+
where: {
|
|
1789
|
+
ownerType: type,
|
|
1790
|
+
ownerId,
|
|
1791
|
+
currency
|
|
1792
|
+
}
|
|
1793
|
+
});
|
|
1794
|
+
if (row) {
|
|
1795
|
+
return toLedgerAccount(row);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
throw error;
|
|
1799
|
+
}
|
|
1800
1800
|
}
|
|
1801
1801
|
return toLedgerAccount(row);
|
|
1802
1802
|
}
|