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

CyberSource: Refactor and add support for several fields #4623

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

rachelkirk
Copy link
Contributor

CER-243

This PR refactors the order of some methods to prevent XML parse errors. It also adds support for the following fields:

installment_gracePeriodDuration
taxManagementIndicator
purchaseTotals_invoiceAmount
purchaseTotals_originalAmount
invoiceHeader_referenceDataCode
invoiceHeader_invoiceNumber
ccCaptureService_gratuityAmount
ccAuthService_mobileRemotePaymentType
otherTax_vatTaxRate

Local:
5371 tests, 76705 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

Remote:
118 tests, 600 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 96.6102% passed
There is one additional remote test failure due to the fields not being added at the top level.

Unit:
123 tests, 588 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed

@rachelkirk rachelkirk requested a review from a team November 4, 2022 20:43
@@ -527,7 +554,7 @@ def test_authorize_and_capture
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_successful_response(auth)

assert capture = @gateway.capture(@amount, auth.authorization)
assert capture = @gateway.capture(@amount, auth.authorization, @capture_options)
assert_successful_response(capture)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is testing for gratuity_amount

}
merchant_descriptor_name: 'Test Name',
merchant_descriptor_address1: '123 Main Dr',
merchant_descriptor_locality: 'Durham'
}
Copy link
Contributor Author

@rachelkirk rachelkirk Nov 4, 2022

Choose a reason for hiding this comment

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

This test passes as implemented, but that's because the fields are not added as top level options. I was on the fence about whether to deal with this issue now or leave it for a later clean up task, so I'd love to hear your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test failure just exposes that this field implementation was already broken

invoice_number: '123',
mobile_remote_payment_type: 'A1',
vat_tax_rate: '1'
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't end up writing tests for each individual field, bc it seemed more important to make sure they'd be added to the request in order no matter the transaction type so I added them to the main options hash. I did include a few remote tests or addition where the situation seemed to call for it, like adding the capture_options since that field would only be added to a capture request.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's reasonable; given the strictness of the XML parser errors that you fought with, if this options hash doesn't cause problems throughout the test suite, we can assume the fields are applied safely to the request

Copy link
Contributor

@jcreiff jcreiff left a comment

Choose a reason for hiding this comment

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

This looks good to me - your work has uncovered that there is an existing issue with the add_merchant_description method, but that can be addressed in a separate task

}
merchant_descriptor_name: 'Test Name',
merchant_descriptor_address1: '123 Main Dr',
merchant_descriptor_locality: 'Durham'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This test failure just exposes that this field implementation was already broken

invoice_number: '123',
mobile_remote_payment_type: 'A1',
vat_tax_rate: '1'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's reasonable; given the strictness of the XML parser errors that you fought with, if this options hash doesn't cause problems throughout the test suite, we can assume the fields are applied safely to the request

@rachelkirk rachelkirk force-pushed the CER-243_cybersource_severalFields branch 2 times, most recently from 8a2715f to a3a1959 Compare November 7, 2022 15:23
CER-243

This PR refactors the order of some methods to prevent XML parse errors. It also adds support for the following fields:

installment_gracePeriodDuration
taxManagementIndicator
purchaseTotals_invoiceAmount
purchaseTotals_originalAmount
invoiceHeader_referenceDataCode
invoiceHeader_invoiceNumber
ccCaptureService_gratuityAmount
ccAuthService_mobileRemotePaymentType
otherTax_vatTaxRate

Local:
5371 tests, 76705 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
118 tests, 600 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.6102% passed
There is one additional remote test failure due to the fields not being added at the top level.

Unit:
123 tests, 588 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
@rachelkirk rachelkirk force-pushed the CER-243_cybersource_severalFields branch from a3a1959 to 9b4ffcc Compare November 7, 2022 15:28
@rachelkirk rachelkirk merged commit 9b4ffcc into master Nov 7, 2022
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