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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 []

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
@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.

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