Page MenuHomePhabricator

Move any remaining controller logic out of the form classes
Closed, ResolvedPublic4 Estimated Story Points

Description

The form classes should not contain any controller logic. Move that into the adapter, or even better, into a new controller class. Figure out how to wrap responses like redirect-iframe.

Thinking out loud:

GatewayPage

  • Controller for UI.
  • Any reason not to pull in the resultswitcher logic?
  • handleRequest
    • Reads from POST and SESSION
    • Performs UI side-effects.

GatewayAdapter

  • Should have processing-specific controller logic, the sequence of API calls to make.
  • initiatePayment
    • Call validation here?
    • Returns PaymentResponse object.

PaymentResponse

Encapsulate and decouple adapter initiatePayment response, can be mapped directly to a UI action to present to the donor.

  • recoverableError -> Refresh form, optionally displaying validation errors.
  • gatewayInteractionRequired -> Redirect to gateway, with GET params.
  • gatewayIframeRequired -> IFrame would ideally be handled by template engine simply refreshing and iframeUrl toggles conditional display.
  • unrecoverableError -> redirect to failure page, for example after a credit card transaction was declined.
  • success -> redirect to Thank You page

Notes

K4-713 reminds us to not short-circuit the orphan slayer, which relies on an existing mechanism to capture success status, etc.

Implementation

Documentation

http://www.mediawiki.org/wiki/Extension:DonationInterface#GatewayForm

Event Timeline

awight raised the priority of this task from to Needs Triage.
awight updated the task description. (Show Details)
awight moved this task to DI Refactor on the Fundraising-Backlog-Old board.
awight subscribed.
atgo triaged this task as Medium priority.Jan 15 2015, 12:15 AM
awight renamed this task from Move any remaining controller-type logic out of the form classes to Move any remaining controller logic out of the form classes.Jan 16 2015, 8:51 PM
awight updated the task description. (Show Details)
awight added subscribers: Ejegg, K4-713.
gerritbot subscribed.

Change 189133 had a related patch set uploaded (by Awight):
Consolidate GatewayPage logic in the base class

https://gerrit.wikimedia.org/r/189133

Patch-For-Review

Change 189136 had a related patch set uploaded (by Awight):
Use common code for Adyen form handling

https://gerrit.wikimedia.org/r/189136

Patch-For-Review

Change 189139 had a related patch set uploaded (by Awight):
WIP more controller logic consolidation

https://gerrit.wikimedia.org/r/189139

Patch-For-Review

Change 189153 had a related patch set uploaded (by Awight):
Move remaining controller logic into GatewayAdapter::doPayment()

https://gerrit.wikimedia.org/r/189153

Patch-For-Review

Oops... I still need to refactor the resultswitcher pages, but it's less urgent, cos these will not be using the universal form.

Change 189133 merged by jenkins-bot:
Consolidate GatewayPage logic in the base class

https://gerrit.wikimedia.org/r/189133

Change 189139 abandoned by Awight:
WIP more controller logic consolidation

Reason:
I think this was accomplished in an updated changeset.

https://gerrit.wikimedia.org/r/189139

Change 189153 merged by jenkins-bot:
Move remaining controller logic into GatewayAdapter::doPayment()

https://gerrit.wikimedia.org/r/189153

Change 189136 merged by jenkins-bot:
Use common code for Adyen form handling

https://gerrit.wikimedia.org/r/189136