academe / SagePay-Integration

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

Add payment method object in transaction responses #39

Closed judgej closed 7 years ago

judgej commented 8 years ago

Implemented in API 09-06-2016 v1

The transaction response needs to be expanded for this new data.

judgej commented 8 years ago

There appears to be no specification for the paymentMenthod response object in the documentation, but plenty of examples are provided:

  "paymentMethod": {
        "card": {
            "cardType": "Visa",
            "lastFourDigits": "0006",
            "expiryDate": "0317"
        }
    },

This is not to be confused with the paymentMethod request object.

judgej commented 8 years ago

Do we need to create this object on the payment regardless of whether there is response data for the paymentMethod or not? It would help for consistency, so the application does not need to check that a payment method exists before attempting to read from it. It could default to a "null" payment method perhaps.

judgej commented 8 years ago

The PaymentMethod object is constructed in the Payment and Repeat message objects,

Simplified the handling of setting httpCode in a message. This is done only in the constructor or the fromData() method (these are the only two places the messages are instantiated, from a PSR-7 message or an array of data respectively).

judgej commented 8 years ago

To finish this off:

judgej commented 8 years ago

Done in issue #45

There are separate request and response Card objects, now moved to Model namespaces under their respective Request or Response. The Card response class may extend an abstract payment method when the gateway extends to additional payment methods (e.g. PayPal and bank accounts) but for now is self-contained).