Skip to content

Conversation

@wlara
Copy link
Collaborator

@wlara wlara commented Dec 13, 2025

No description provided.

@wlara wlara requested a review from AndrewWestberg December 13, 2025 20:05
@wlara wlara force-pushed the wlara/paypal-items-flag branch 3 times, most recently from 32972f1 to 7e535df Compare December 13, 2025 20:11
@wlara wlara changed the title added config flag to include/exclude PatPal invoice items added config flag to include/exclude PayPal invoice items Dec 13, 2025
@wlara wlara force-pushed the wlara/paypal-items-flag branch from 7e535df to d9230c3 Compare December 13, 2025 20:16
@wlara wlara changed the title added config flag to include/exclude PayPal invoice items feat: add config flag to include/exclude PayPal invoice items Dec 13, 2025
@wlara wlara force-pushed the wlara/paypal-items-flag branch from d9230c3 to 6a30617 Compare December 13, 2025 20:17
val payPalKoinModule =
module {
single<PayPalRepository> { PayPalRepositoryImpl(get(), get(QUALIFIER_PAYPAL_HTTP_CLIENT), get()) }
single<PayPalRepository> { PayPalRepositoryImpl(get(), get(), get(QUALIFIER_PAYPAL_HTTP_CLIENT), get()) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

enabled by default until tested

Copy link

Copilot AI left a comment

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 adds a configurable flag to control whether itemized invoice details are included in PayPal order creation requests. The feature allows NEWM to toggle between showing detailed line items (Distribution cost, Royalty split(s) fee, Service fee) or just the total amount when creating PayPal orders.

Key changes:

  • Added paypal.itemizedInvoiceEnabled configuration flag (defaults to true)
  • Made the items field nullable in PayPal API request model
  • Updated PayPal repository to conditionally include invoice items based on config

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
PayPalRepositoryImpl.kt Adds ConfigRepository dependency and conditional logic to include/exclude invoice items based on config flag
PayPalCreateOrderRequest.kt Makes items field nullable to support optional itemization
PayPalKoinModule.kt Updates dependency injection to include ConfigRepository
V83__ConfigUpdates.kt Database migration that creates the config entry with default value 'true'
ConfigRepository.kt Adds constant for the new config key

Comment on lines 68 to 83
items = takeIf { configRepository.getBoolean(CONFIG_KEY_PAYPAL_ITEMIZED_INVOICE_ENABLED) }?.let {
listOf(
PayPalItem(
name = "Distribution cost",
unitPriceUsd = paymentOption.dspPrice.toBigDecimalUsd()
),
PayPalItem(
name = "Royalty split(s) fee",
unitPriceUsd = paymentOption.collabPrice.toBigDecimalUsd()
),
PayPalItem(
name = "Service fee",
unitPriceUsd = paymentOption.mintPrice.toBigDecimalUsd()
)
)
)
}
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

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

The takeIf is being called on the wrong receiver. Currently it's called on an implicit receiver (likely this from outer scope), but it should be called on the boolean result of configRepository.getBoolean(). This will cause items to always be null when the condition should be false, but will incorrectly return the PayPalRepositoryImpl instance when it should check the config flag. Replace with: if (configRepository.getBoolean(CONFIG_KEY_PAYPAL_ITEMIZED_INVOICE_ENABLED)) listOf(...) else null

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@wlara I agree with this comment. A simple items = if (configRepository.getBoolean()) {...} else null seems like clearer code.

@wlara wlara force-pushed the wlara/paypal-items-flag branch from 6a30617 to fcd10d8 Compare December 14, 2025 17:11
@wlara wlara merged commit f1d44f1 into master Dec 14, 2025
2 checks passed
@wlara wlara deleted the wlara/paypal-items-flag branch December 14, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants