-
Notifications
You must be signed in to change notification settings - Fork 0
PM-1279 - paypal fee collection #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
) { | ||
const feePercent = Number(ENV_CONFIG.TROLLEY_PAYPAL_FEE_PERCENT) / 100; | ||
feeAmount = Math.max( | ||
ENV_CONFIG.TROLLEY_PAYPAL_FEE_MAX_AMOUNT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
high
correctness
The calculation for feeAmount
seems incorrect. The Math.max
function should ensure that the fee does not exceed TROLLEY_PAYPAL_FEE_MAX_AMOUNT
, but currently, it sets the fee to at least TROLLEY_PAYPAL_FEE_MAX_AMOUNT
. Consider using Math.min
instead to ensure the fee does not exceed the maximum allowed amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vas3a I also think this needs correction and kind of struggle to understand it. Math.max
picks the larger of them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, good catch. wanted to test in dev, as I had some issues locally. restarting PC resolved local so I'll run through it before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small tweaks are required.
) { | ||
const feePercent = Number(ENV_CONFIG.TROLLEY_PAYPAL_FEE_PERCENT) / 100; | ||
feeAmount = Math.max( | ||
ENV_CONFIG.TROLLEY_PAYPAL_FEE_MAX_AMOUNT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vas3a I also think this needs correction and kind of struggle to understand it. Math.max
picks the larger of them all.
|
||
if (!recipient) { | ||
throw new Error(`Trolley recipient not found for user '${userId}'!`); | ||
paymentAmount -= feeAmount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do round up paymentAmount to 2nd digit after the point, right? Or shold we do it here?
winnings, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also include the TROLLEY_PAYPAL_FEE_PERCENT
and TROLLEY_PAYPAL_FEE_MAX_AMOUNT
in the meta please.
payoutMethod: trolleyRecipientPayoutDetails.payoutMethod, | ||
env_trolley_paypal_fee_percent: | ||
ENV_CONFIG.TROLLEY_PAYPAL_FEE_PERCENT, | ||
env_trolley_paypal_fee_max_amount: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
medium
correctness
Consider validating ENV_CONFIG.TROLLEY_PAYPAL_FEE_MAX_AMOUNT
to ensure it is a non-negative number. This can prevent potential issues if the environment variable is misconfigured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
https://topcoder.atlassian.net/browse/PM-1279 - PayPal fees collection