Skip to content

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

Merged
merged 3 commits into from
May 28, 2025
Merged

PM-1279 - paypal fee collection #66

merged 3 commits into from
May 28, 2025

Conversation

vas3a
Copy link
Collaborator

@vas3a vas3a commented May 28, 2025

@vas3a vas3a requested a review from kkartunov May 28, 2025 12:01
) {
const feePercent = Number(ENV_CONFIG.TROLLEY_PAYPAL_FEE_PERCENT) / 100;
feeAmount = Math.max(
ENV_CONFIG.TROLLEY_PAYPAL_FEE_MAX_AMOUNT,

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

@kkartunov kkartunov left a 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,
Copy link
Contributor

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;
Copy link
Contributor

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,
{
Copy link
Contributor

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:

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.

Copy link
Contributor

@kkartunov kkartunov left a comment

Choose a reason for hiding this comment

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

Looks good.

@vas3a vas3a merged commit 9827b18 into dev May 28, 2025
1 check passed
@vas3a vas3a deleted the PM-1279_paypal-fee-collection branch May 28, 2025 15:56
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.

2 participants