Skip to content

Add Payment Method Discounts - #52

Merged
OmarLawaty merged 2 commits into
devfrom
feat/discounts/paymentMethod
Aug 27, 2026
Merged

OmarLawaty merged 2 commits into
devfrom
feat/discounts/paymentMethod

Conversation

@OmarLawaty

Copy link
Copy Markdown
Member

No description provided.

@OmarLawaty
OmarLawaty requested a lite review from Copilot August 27, 2026 05:46
@OmarLawaty OmarLawaty self-assigned this Aug 27, 2026
@OmarLawaty OmarLawaty added enhancement New feature or request feature labels Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 paymentMethods to the Discount model (DB + entity) and expose it through admin DTOs/creation DTO.
  • Thread paymentMethod through discount evaluation paths (code + automatic) and reject ineligible usage with a localized error.
  • Pass order paymentMethod into discount resolution during order creation and allow clients to provide paymentMethod when 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.

Comment thread src/discounts/discounts.service.ts Outdated
Comment thread src/discounts/controllers/discounts.controller.ts Outdated
Comment thread src/discounts/dtos/admin/admin-discount.dto.ts Outdated
Comment thread src/discounts/controllers/discounts.controller.ts
Comment thread src/discounts/discounts.service.ts
Comment thread src/discounts/entities/discount.entity.ts Outdated
@OmarLawaty
OmarLawaty merged commit 7bdcda7 into dev Aug 27, 2026
2 checks passed
@OmarLawaty
OmarLawaty deleted the feat/discounts/paymentMethod branch August 27, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants