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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { e as WalletPluginConfig, f as WalletPlugin, I as IWalletPaymentProvider } from './types-CrJxUVwX.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-CrJxUVwX.mjs';
3
- import { W as WalletAccountType } from './store-BQ3whei-.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-BQ3whei-.mjs';
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-iNUEzUgo.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-iNUEzUgo.js';
3
- import { W as WalletAccountType } from './store-BQ3whei-.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-BQ3whei-.js';
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(runtime) {
572
- const { client, flags } = runtime;
574
+ function createSettlementHooks(_runtime) {
573
575
  return {
574
- async onSettlementDebit(ctx) {
575
- if (!flags.enabled || !flags.settlementDebit) {
576
- return;
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(runtime),
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
- row = repo.create({
1793
- ownerType: type,
1794
- ownerId,
1795
- currency,
1796
- availableBalance: "0",
1797
- heldBalance: "0"
1798
- });
1799
- row = await repo.save(row);
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
  }