spree/spree — pull request #3765 by dkubb (2013-09-24 15:26:41+00:00)
Title: Adjust payment capture amount

This branch adds the ability for an admin user to edit a pending payment amount so that a different amount can be captured than the original authorization. In my specific use case we are applying adjustments to an order manually based on the customer's standing, whether they are known students (for student discount), employees and various other criteria that is difficult to automate. We want to be able to capture an amount equal to or less than the authorized amount, which this feature allows.

Fix #3738

--

Last commit description:

This adds a coffeescript file with classes to manage the payment object, as well as two classes to manage the show and edit view states for a payment.

The show view is the starting state and is added to each pending payment in the table. It will add the edit icon as well as make the amount clickable; clicking on either will change to the edit view.

The edit view will hide the capture and pending icons, as well as change the edit icon to save. It will also change the amount to a text field, which can be edited. Moving focus from the text field or clicking on the save icon will save the payment using an ajax request. The edit view may be cancelled and reverted back to the show view by clicking on the cancel button.

If the ajax request is successful, then the show view will return. If there is an error, a flash message will display at the top of the page and fade away after 5 seconds.

--

This branch also includes small fixes and refactorings to code that I had to modify in order to add this feature. I tried to follow conventions in the newer code, but if you disagree with anything please note it in the PR and I will fix it.