-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add new method to build non-Worldpay payments #255
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://eaflood.atlassian.net/browse/WC-377 Initally we were building these payments in the back office: DEFRA/waste-carriers-back-office#97 However, making creating a new payment the responsibility of the Payment model feels like a better fit. This also means we are more consistent with how we create different types of payments. Also removed the manual_payment attribute, as after looking at the waste-carriers-service, it doesn't look like this is ever persisted or used for anything.
irisfaraway
added a commit
to DEFRA/waste-carriers-back-office
that referenced
this pull request
Sep 4, 2018
We'll be doing more with the order once DEFRA/waste-carriers-engine#255 is merged in.
Cruikshanks
approved these changes
Sep 4, 2018
irisfaraway
added a commit
to DEFRA/waste-carriers-back-office
that referenced
this pull request
Sep 6, 2018
* Finance users can record electronic bank transfer payment https://eaflood.atlassian.net/browse/WC-377 A user with the finance or finance_admin role should be able to record when a bank transfer payment has been received. Recording the receipt of the payment should also update the balance. This PR should lay the groundwork for recording payments of other types. * Set up form objects for payments Create a new PaymentForm and a TransferPaymentForm which inherits from it. The form creates a new payment with attributes from the params and adds it to the transient_object (if valid). * Set up TransferPaymentFormsController We can now send requests to submit the form with the params. We also add the current user's email to the params so we can include that in the payment details. There's also a rudimentary view, although this is missing fields – however, it's enough to pass the tests for now. Also tweaked one of the existing tests so that it doesn't fail if the date in the factory is changed. * Standardise field name Let's use updated_by_user from the start, rather than flipping over from current_user_email. * Get order_key from order We'll be doing more with the order once DEFRA/waste-carriers-engine#255 is merged in. * Add all fields to form Add the necessary fields to the bank transfer form, plus microcopy. * Validate the form These validations are taken from the existing form in waste-carriers-frontend. * Refactor PaymentForm to use new engine method The WasteCarriersEngine now has a new Payment.new_from_non_worldpay method to create payments, so we can strip that out from the form. However, we do need to do a little more prep before we pass that data to the new method. * Fix post-merge issue with authorising forms After merging in the new role-based authorisation changes, the payment form broke as we hadn't yet added any authorisation. We will be adding some authorisation for this form - however, just in case we have forms which don't, we should still fix this issue. This change means that we don't attempt to check authorisation if no auth method is passed in to the AdminFormController from the child form controllers. * Move payment form into partial This is in preparation for when we have multiple types of payment to enter. * Only allow finance users to enter a bank transfer payment All other users who try to access this page should be redirected to an error. * Link from transient reg page to payment Soon there will be an intermediary page where users can select the type of payment to log, but for the purposes of joining up the journey, let's link directly for now. * Convert amount from pounds to pence We ask users to enter this value in pounds (120.50) but it is stored in the DB in pence (12050), so we need to convert it before saving. * Balance should update after payment is entered This test doesn't pass yet because of a bug in the engine which means it will always ignore non-Worldpay payments for the balance. Awaiting this fix: DEFRA/waste-carriers-engine#256
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WC-377
Initally we were building these payments in the back office: DEFRA/waste-carriers-back-office#97 However, making creating a new payment the responsibility of the Payment model feels like a better fit. This also means we are more consistent with how we create different types of payments.
Also removed the manual_payment attribute, as after looking at the waste-carriers-service, it doesn't look like this is ever persisted or used for anything.