Repository navigation
Add Payment Method Discounts - #52
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces payment-method-aware discounts in the NestJS discounts/orders domain, allowing discounts to be restricted to one or more supported order payment methods and enforcing that restriction during discount resolution.
Changes:
- Add
paymentMethodsto theDiscountmodel (DB + entity) and expose it through admin DTOs/creation DTO. - Thread
paymentMethodthrough discount evaluation paths (code + automatic) and reject ineligible usage with a localized error. - Pass order
paymentMethodinto discount resolution during order creation and allow clients to providepaymentMethodwhen querying discount applicability.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/orders/services/orders.service.ts | Passes paymentMethod into discount resolution during order creation. |
| src/i18n/messages/en.ts | Adds English translation for payment-method-ineligible discount error. |
| src/i18n/messages/ar.ts | Adds Arabic translation for payment-method-ineligible discount error. |
| src/discounts/entities/discount.entity.ts | Adds paymentMethods enum-array column to the Discount entity. |
| src/discounts/dtos/admin/create-discount.dto.ts | Allows admins to set paymentMethods when creating discounts. |
| src/discounts/dtos/admin/admin-discount.dto.ts | Exposes paymentMethods in the admin discount response DTO. |
| src/discounts/discounts.service.ts | Enforces payment method eligibility during discount validation/selection and threads the new parameter through APIs. |
| src/discounts/controllers/discounts.controller.ts | Adds optional paymentMethod query param to discount lookup and forwards it to the service. |
| migrations/1787807825494-DiscountPaymentMethod.ts | Adds DB enum + payment_methods column to discount. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.