Skip to content
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

Nuvei: Update Payouts request and some fixes #5327

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

javierpedrozaing
Copy link
Collaborator

Description

SER1494

This commit include Google and Apple pay for payout request additionnal this commit add the next fixes

  • Remove the unnecessary savePM flag. By default, Nuvei stores the payment method (PM), so we don't need to override this default behavior.

  • Fix ACH transaction by updating the SECCode field

  • Update authorization_from method

  • Use the user_token_id option only for the required test

Unit test

Finished in 1.789372 seconds.

25 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

13.97 tests/s, 68.18 assertions/s

Remote test

Finished in 102.124827 seconds.

36 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

0.35 tests/s, 1.15 assertions/s

Rubocop

804 files inspected, no offenses detected

Copy link
Collaborator

@Heavyblade Heavyblade left a comment

Choose a reason for hiding this comment

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

Looks pretty good @javierpedrozaing , left some minor comments

payment_data = payment.is_a?(CreditCard) || payment.is_a?(NetworkTokenizationCreditCard) ? credit_card_hash(payment) : payment

Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 Comment/Style:

Seems that we hand enough payment method types to justify a case instead of if/elsif/end structure

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, I think that all this method requires a code refactoring.

@@ -475,7 +477,11 @@ def success_from(response)
end

def authorization_from(action, response, post)
response.dig(:transactionId)
if post[:userTokenId].present? && post[:transactionType] == 'Auth' && post[:amount].to_i == 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 Comment:

maybe having an extra method that clarifies the reason for those '&', just by reading I'm understanding something like a zero auth request, perhaps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, I will update it.

if post[:userTokenId].present? && post[:transactionType] == 'Auth' && post[:amount].to_i == 0
response.dig(:paymentOption, :userPaymentOptionId)
else
response.dig(:transactionId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 COmment

Unless you are expecting to add more keys to the params a dig is an overkill over a simple []

@javierpedrozaing javierpedrozaing force-pushed the SER-1494_Nuvei_payouts branch 2 times, most recently from 3195e3c to d639494 Compare November 13, 2024 15:45
@javierpedrozaing javierpedrozaing marked this pull request as ready for review November 13, 2024 16:01
Copy link
Contributor

@naashton naashton left a comment

Choose a reason for hiding this comment

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

Generally looks pretty good, but I have a broad question. Since this PR is for Payouts, is there any transaction specific value that distinguishes the payout from a standard credit?

I'm wondering if there should be a specific test or if there is something that a user needs to specify which would make the payout different from an "unreferenced refund".

Copy link
Contributor

@naashton naashton left a comment

Choose a reason for hiding this comment

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

Regarding my last comment, I think I see now what I might have missed previously.

Payouts should be treated as an alternate operation for credit, but not the default operation. So, we should only perform the /payout if there is some explicit indicator, whether it's a GSF or something else, that tells us to send the request to the /payout endpoint instead of the unreferenced refund.

@javierpedrozaing
Copy link
Collaborator Author

Regarding my last comment, I think I see now what I might have missed previously.

Payouts should be treated as an alternate operation for credit, but not the default operation. So, we should only perform the /payout if there is some explicit indicator, whether it's a GSF or something else, that tells us to send the request to the /payout endpoint instead of the unreferenced refund.

Hi #naashton ahhh ok thanks, it's clearer to me now, I will working on it.

@javierpedrozaing javierpedrozaing force-pushed the SER-1494_Nuvei_payouts branch 5 times, most recently from 0af2ee3 to f97c039 Compare November 18, 2024 15:27
Description
-------------------------
[SER1494](https://spreedly.atlassian.net/browse/SER-1494)

This commit include Google and Apple pay for payout request
additionnal this commit add the next fixes

- Remove the unnecessary savePM flag. By default, Nuvei stores the payment method (PM),
so we don't need to override this default behavior.

- Fix ACH transaction by updating the SECCode field

- Use the user_token_id option only for the required test

- Refactor add_payment_method

Unit test
-------------------------
Finished in 1.789372 seconds.

25 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

13.97 tests/s, 68.18 assertions/s

Remote test
-------------------------

Finished in 102.124827 seconds.

36 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

0.35 tests/s, 1.15 assertions/s

Rubocop
-------------------------
804 files inspected, no offenses detected
@naashton naashton merged commit 6e98120 into master Nov 21, 2024
5 checks passed
@naashton naashton deleted the SER-1494_Nuvei_payouts branch November 21, 2024 20:35
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