Commit Graph

431 Commits

Author SHA1 Message Date
masoodafar-web d22eb1617f feat(payment): add per-user in-memory lock for gateway operations
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 9m58s
Introduce IUserPaymentLock to serialize payment initiate and verify flows
per user, preventing concurrent duplicate gateway requests across services.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 01:55:00 +03:30
masoodafar-web f08d3ac78f fix(payment): prevent duplicate wallet credit on package verify
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 11m29s
Add idempotent verify with serializable transaction and wallet-history check
to stop concurrent callback/race from charging the wallet twice.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 01:32:47 +03:30
masoodafar-web 4f2d313d5e fix(UserOrderService): update comment to reflect correct threshold value for Magic Wallet
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m50s
2026-05-29 19:58:36 +03:30
masoodafar-web 034679d915 fix(ZarinpalReconciliationJob): correct typo in logging method for unverified list
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 16m38s
2026-05-21 20:21:21 +03:30
masoodafar-web 6414e5663a fix(ZarinpalReconciliationJob): log information when unverified list is empty
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
2026-05-21 20:19:32 +03:30
masoodafar-web 90d4f65de4 chore: add missing using directives for System.Collections.Generic in ZarinpalReconciliationJob and ZarinPalPaymentService files
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 20m42s
2026-05-21 19:27:30 +03:30
masoodafar-web bc52240a41 feat(payment): add GetUnverifiedAuthoritiesAsync method to IPaymentGatewayService and ZarinPalPaymentService for payment reconciliation
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8m7s
- Introduced GetUnverifiedAuthoritiesAsync method to retrieve authorities with unverified payments.
- Implemented ZarinPal-specific logic for fetching unverified authorities from the new endpoint.
- Added background job for Zarinpal payment reconciliation every 30 minutes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-21 18:26:49 +03:30
masoodafar-web aac0d4271d feat(wallets): add DiscountBalance to GetAllUserWalletByFilter response; bump proto to 0.0.199
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 15m40s
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 01:13:56 +03:30
masoodafar-web da1a2fcf8e feat(commission): add BulkCreditPayouts — credit wallets for pending payouts
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 10m35s
- commission.proto: add BulkCreditPayouts rpc + request/response messages; bump version to 0.0.198
- BulkCreditPayoutsCommand + Handler: load all Pending payouts for given week, credit UserWallet.Balance for each user, create UserWalletHistory + CommissionPayoutHistory records, set Status=Paid + PaidAt
- CommissionService: wire up BulkCreditPayouts gRPC method
- CommissionProfile: add Mapster mappings for request/result ↔ proto types

Previously ProcessUserPayouts created records with Status=Pending but never credited wallets, making CustomerWithdrawBalance unreachable (it requires Status==Paid).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-18 00:38:25 +03:30
masoodafar-web cdd124ac25 fix: rename cancellationToken to ct in ProcessReturnAsync call
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m21s
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-17 22:38:40 +03:30
masoodafar-web 4d7932f335 fix(regular-store): deduct inventory and restore on cancel
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 19m38s
- UserOrderService.SubmitShopBuyOrder: inject IInventoryService; validate
  available stock per item before any financial operation; call ConfirmSaleAsync
  and increment Product.SaleCount after order is persisted.
- CancelOrderByAdminCommandHandler: inject IInventoryService; include
  FactorDetails in query; call ProcessReturnAsync for each item so stock
  is restored when an order is cancelled by admin.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-17 21:57:48 +03:30
masoodafar-web 18a2299d93 fix: update MagicWallet thresholds for consistency with business logic
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m11s
- Adjust MagicWalletEntryThreshold from 1,000,000 to 100,000
- Update MagicWalletDefaultMaxDeposit from 1,000,000,000 to 100,000,000
- Change MagicWalletDefaultMaxCredit from 2,500,000,000 to 250,000,000
- Modify comments in UserOrderService to reflect updated threshold values
2026-05-14 03:12:45 +03:30
masoodafar-web 6e60ca7c25 chore: bump CMSMicroservice.Protobuf version to 0.0.197
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m42s
2026-05-13 22:21:22 +03:30
masoodafar-web fd8b37a6b1 docs: add note on TLS certificate requirements for cms-tls in Ingress configuration
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m14s
2026-05-13 22:05:26 +03:30
masoodafar-web 683ed370b5 feat: extend discount product gRPC API with sort_by and sale_count
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 7m11s
- Add sort_by (StringValue) to GetDiscountProductsRequest proto to enable dynamic sorting
- Add sale_count (int32) to DiscountProductDto proto for top-seller exposure
- Update GetDiscountProductsQuery with SortBy property
- Update GetDiscountProductsQueryHandler to use ApplyOrder(SortBy) with fallback to Created desc; project SaleCount in SELECT
- Add SortBy and SaleCount Mapster mappings in DiscountProductProfile
- Bump CMSMicroservice.Protobuf version to 0.0.196

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 19:47:56 +03:30
masoodafar-web 98c2875ae2 feat: simplify UserId handling in GetOrderById method for improved clarity
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m12s
2026-05-10 21:37:30 +03:30
masoodafar-web 65db839642 feat: update GetOrderByIdQuery to allow nullable UserId and adjust query handling in GetOrderByIdQueryHandler
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m43s
2026-05-05 01:54:33 +03:30
masoodafar-web f7d6b0e3e7 feat: cast Created field to datetimeoffset in sp_GetUserWeeklyBalances for improved date handling
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m46s
2026-05-05 01:35:07 +03:30
masoodafar-web b905c308c1 feat: enhance sp_CalculateWeeklyBalances to track package activity and optimize member calculations
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 10m21s
2026-05-04 23:54:13 +03:30
masoodafar-web d09db638cc feat: enhance sp_CalculateWeeklyCommissionPool to include IsDeleted filter and update commission calculations for package-specific pools
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m44s
2026-05-04 18:44:28 +03:30
masoodafar-web 41e7f29a0d feat: add PackageId to CalculateWeeklyCommissionPoolCommand and related logic for package-specific calculations
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m43s
2026-05-04 02:31:26 +03:30
masoodafar-web c4409491c1 feat: update stored procedure to use UserWalletHistories and include PackageId in balance checks
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m19s
2026-05-04 01:28:04 +03:30
masoodafar-web e4279f3d05 Add migration to rename index and create stored procedure for user weekly balances
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m55s
- Added migration to rename index from IX_NetworkWeeklyBalances_PackageId to IX_NetworkWeeklyBalance_PackageId in the NetworkWeeklyBalances table.
- Created stored procedure sp_GetUserWeeklyBalances to retrieve weekly balances with pagination and various filters.
2026-05-04 00:36:31 +03:30
masoodafar-web c5dd1a2ef5 feat: improve package retrieval logic in AcceptClubMembershipContract and ActivateClubMembership handlers
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m0s
2026-05-03 22:03:47 +03:30
masoodafar-web eeb837f32e feat: enhance inventory release logic in ExpirePendingOrdersService and InventoryService
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m27s
2026-05-01 00:56:00 +03:30
masoodafar-web 624ab7ea9f feat: conditionally enable InventoryInitializer service and update appsettings for seed workers
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
2026-05-01 00:47:32 +03:30
masoodafar-web d8a3b49f4d feat: add GetNetworkTree stored procedure for network data retrieval
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
2026-05-01 00:28:25 +03:30
masoodafar-web 8518c7b3ec feat: Enhance club membership activation and commission pool validation
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m9s
- Updated AcceptClubMembershipContractCommandHandler to set PackagePurchasedAt to the contract-signing time, ensuring accurate pool charging.
- Modified ActivateClubMembershipCommand to allow specifying a PackageId for forced activation, defaulting to the base package if not provided.
- Improved ActivateClubMembershipCommandHandler to handle new and existing memberships differently regarding pool charging.
- Added validation logic in GetWeeklyCommissionPoolQueryHandler to compare TotalPoolAmount against actual activations.
- Introduced validation fields in WeeklyCommissionPoolDto for tracking discrepancies and expected amounts.
- Updated stored procedures to ensure accurate calculations based on package purchases and to handle empty pools.
- Enhanced protobuf definitions to include validation fields for commission pools and network tree nodes.
- Added mapping for new fields in CommissionProfile and NetworkMembershipProfile.
- Created DiscountProductProfile for mapping discount product requests and responses.
2026-05-01 00:07:05 +03:30
masoodafar-web 789aa0b870 fix: update response message for non-existent user during registration process
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m42s
2026-04-30 03:55:03 +03:30
masoodafar-web b4e7902870 fix: update Kavenegar API key in appsettings for staging environment
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m25s
2026-04-30 03:44:38 +03:30
masoodafar-web aa7f77bfec fix: return 'user not found' for login purpose instead of requiring referral code 2026-04-30 03:42:53 +03:30
masoodafar-web a4d04cb7bf fix: update Kavenegar API key in appsettings for staging environment
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m19s
2026-04-30 03:36:10 +03:30
masoodafar-web 85591aec30 fix: update Kavenegar API key in appsettings for staging environment
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m0s
2026-04-30 02:33:54 +03:30
masoodafar-web e93fad3b3d fix: update Kavenegar API key in appsettings for SMS provider
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
2026-04-30 02:31:45 +03:30
masoodafar-web 04e1a83838 feat: enhance OTP verification logic to support master code bypass and improve error handling 2026-04-29 22:58:16 +03:30
masoodafar-web 4a7df2083e feat: add master OTP bypass for login + referral code field support
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 22m37s
2026-04-29 00:49:25 +03:30
masoodafar-web e77b5f9658 fix(ci): fix proto publish - remove allow-insecure-connections, add CI=true env, use source name
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 16m36s
2026-04-24 04:43:28 +03:30
masoodafar-web b71ddfaf9b chore(proto): bump version to 0.0.193 for per-package commission fields
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 18m4s
2026-04-24 04:18:41 +03:30
masoodafar-web 4d6d77531d feat(commission): add per-package calculation support
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 15m3s
- SP sp_CalculateWeeklyBalances: added @PackageId, @InputMaxBalancesPerLeg, @InputMaxNetworkLevel params; filters by PackageId
- SP sp_CalculateWeeklyCommissionPool: added @PackageId param; all queries filter by PackageId/WeeklyPoolId for isolation
- ICommissionCalculationStrategy: added optional PackageId param to both methods
- StoredProcedureCommissionCalculationStrategy: loops per-package for both Balance and Pool methods; filters by packageId if provided
- OrmCommissionCalculationStrategy: signature updated to match interface
- TriggerWeeklyCalculationCommand: added PackageId optional field
- TriggerWeeklyCalculationCommandHandler: passes PackageId to strategy
- GetWeeklyCommissionPoolQuery: added optional PackageId filter
- GetWeeklyCommissionPoolQueryHandler: filters pool by PackageId if provided
- GetAllWeeklyPoolsQuery/Handler/DTO: added PackageId filter + PackageTitle in response
- Proto commission.proto: added package_id to TriggerWeeklyCalculationRequest, GetWeeklyCommissionPoolRequest, WeeklyCommissionPoolModel, GetWeeklyCommissionPoolResponse, GetAllWeeklyPoolsRequest
- CommissionProfile: added explicit mappings for TriggerWeeklyCalculation, GetWeeklyCommissionPool, GetAllWeeklyPools

Fixes: SP picks wrong pool when multiple packages per week
Fixes: SP ignores PackageId on ForceRecalculate (now uses WeeklyPoolId)
Fixes: Zero-balance pools not fully recorded (now sets TotalBalances=0, ValuePerBalance=0)
2026-04-24 03:43:20 +03:30
masoodafar-web a35e2eeb92 fix: add proxy timeout annotations to CMS ingress
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 23m45s
Add nginx.ingress.kubernetes.io/proxy-read-timeout: 3600
and proxy-send-timeout: 3600 to prevent 504 Gateway Timeout
on gRPC-Web requests through the nginx ingress controller.
2026-03-15 03:12:03 +03:30
masoodafar-web 0a66b09e7b ci: retry build - all NuGet packages pushed to Nexus
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 22m48s
2026-03-12 01:14:07 +03:30
masoodafar-web e946c56631 Revert "fix: bypass broken Nexus proxy, use nuget.org directly"
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 20m7s
This reverts commit 370f735cf2.
2026-03-12 00:06:14 +03:30
masoodafar-web 370f735cf2 fix: bypass broken Nexus proxy, use nuget.org directly
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Nexus nuget-all proxy returns 500. Replace with direct nuget.org
source. Keep foursat-hosted for proto push step only.
2026-03-12 00:03:42 +03:30
masoodafar-web 0e9d0cad2f feat: manual payment package-based + StockMovement constraint fix
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 7m23s
- ManualPayment: add package_id to proto, handler selects package by ID
- ManualPayment: remove manual amount input, use package price
- ManualPayment: validator now checks PackageId instead of Amount
- StockMovement: fix CHECK constraint (store negative qty for decreases)
- StockMovement: Reserved/Released don't change physical Quantity
- Proto NuGet bumped to 0.0.192
2026-03-11 23:44:28 +03:30
masoodafar-web 1a0bb83c99 feat: Enhance SMS verification with new token handling and update API key
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m45s
2026-02-28 04:01:45 +03:30
masoodafar-web 1e7c17f090 feat: Update payment processing and callback mechanisms
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m22s
- Refactor ActivateClubMembershipCommandHandler to use UserPackagePurchases instead of UserOrders for package activation.
- Modify PlaceOrderCommandHandler to redirect payment callbacks to the front office.
- Update ChargeDiscountWalletCommandHandler and ChargeMagicWalletCommandHandler to direct payment callbacks to the front office.
- Remove PaymentCallbackController and integrate payment verification directly into DiscountOrderService and UserWalletService.
- Add CustomerVerifyDiscountOrderPayment RPC to DiscountOrderService for verifying discount order payments.
- Implement VerifyMagicCharge and VerifyDiscountCharge methods in UserWalletService for wallet charge verifications.
- Update appsettings.json to use local URLs for development.
- Remove appsettings.Development.json as it is no longer needed.
- Comment out history tracking methods in ClubMembershipCycle and Package classes.
- Update PackageService to automatically activate club membership after successful payment verification.
- Adjust UserService to generate JWT tokens with user details.
2026-02-28 03:27:46 +03:30
masoodafar-web 01073084ab security: remove callback URL from user input — read from FrontOfficeBaseUrl config
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m28s
- PackageService: build callback URL from FrontOfficeBaseUrl config instead of request.CallbackUrl
- TransactionsService: same fix — callback URL from config
- Prevents potential open redirect vulnerability (user could send arbitrary URL)

All callback URLs now come from appsettings FrontOfficeBaseUrl or CmsBaseUrl.
2026-02-27 22:20:04 +03:30
masoodafar-web ed2b20a98e fix: wallet callback URL issues
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
- PaymentCallbackController: fix redirect paths /magic-wallet → /profile/magic-wallet
- Add appsettings.Development.json with local CmsBaseUrl (localhost:32846) and FrontOfficeBaseUrl (localhost:5268)
- Proto: fix comments ریال → تومان in wallet charge messages

Root cause: CmsBaseUrl in appsettings.json points to stage (cms.se.kbs1.ir),
so when testing locally, ZarinPal callback went to stage CMS instead of local.
Also redirect after verify used wrong FO path (/magic-wallet instead of /profile/magic-wallet).
2026-02-27 22:09:15 +03:30
masoodafar-web 721661af0f fix: pass amount to ZarinPal VerifyPaymentAsync — fix verify failure (amount=0 bug)
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m38s
- PackageService.CustomerVerifyPackagePurchase: look up PaymentTransaction.Amount and pass to 3-arg overload
- TransactionsService.CustomerPaymentVerification: same fix
- VerifyDiscountWalletChargeCommandHandler: look up amount from PaymentTransaction
- VerifyPackagePurchaseCommandHandler: fix copy-paste bug (Authority as verificationToken) + add amount
- IPaymentGatewayService: throw NotImplementedException in default 3-arg impl to prevent silent amount=0
- MockPaymentGatewayService & DayaPaymentService: add 3-arg overload for compatibility

Root cause: ZarinPal requires the exact amount in verify request.
The 2-arg overload was sending amount=0 which caused Code=-1 (تأیید تراکنش ناموفق).
2026-02-27 21:17:50 +03:30
masoodafar-web aee7b59fc1 fix: Toman/Rial — system uses Toman everywhere, only ZarinPal gets Rial
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 10m16s
Core change in ZarinPalPaymentService:
- InitiatePaymentAsync: Amount (Toman) × 10 → Rial for gateway
- VerifyPaymentWithAmountAsync: Amount (Toman) × 10 → Rial for verify
- Verify result: gateway Rial ÷ 10 → Toman back to system

Also fixed:
- Package.Price doc: ریال → تومان
- Error messages in 3 handlers: ریال → تومان
- ConfigurationService descriptions: ریال → تومان (7 entries)
- Notification SMS/email: ریال → تومان
- Doc comments in 5 command files: ریال → تومان
- PaymentCallback comments: ریال → تومان

14 files changed across Domain, Application, Infrastructure, WebApi
2026-02-27 21:03:27 +03:30