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

Add new method to build non-Worldpay payments #255

Merged
merged 2 commits into from
Sep 4, 2018

Conversation

irisfaraway
Copy link
Member

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.

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 irisfaraway self-assigned this Sep 4, 2018
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.
@irisfaraway irisfaraway merged commit 3a2ac10 into master Sep 4, 2018
@irisfaraway irisfaraway deleted the feature/new-transfer-payment branch September 4, 2018 13:29
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
@irisfaraway irisfaraway added the enhancement New feature or request label Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants