academe / SagePay-Integration

HTTP Messages for the Sage Pay REST (Pi) gateway.
GNU General Public License v3.0
9 stars 5 forks source link

Serialisation for choice objects #5

Closed judgej closed 8 years ago

judgej commented 8 years ago

Some objects are going to be needed over a number of page loads. For example, the SessionKeyResponse object can be used to get a card identifier token for up to three attempts. Once obtained, the CardIdentifierResponse will be valid for 200 seconds, so can be used to submit a form multiple times (catching validation errors each time). These objects will need to be serialisable so they can be saved and reconstructed on each page load.

judgej commented 8 years ago

The toArray() and fromArray() methods can be used in pairs to achieve this. These response messages are built entirely from data returned in a request, so don't rely on other objects to be injected in order to construct them.

judgej commented 8 years ago

JSON serialisation is used throughout, with appropriate items secured from accidental serialisation and logging or display.