thephpleague / omnipay-common

Core components for the Omnipay PHP payment processing library
MIT License
329 stars 242 forks source link

Add json/xml helpers #156

Closed barryvdh closed 6 years ago

barryvdh commented 7 years ago

This adds a json and xml helper method to the HttpClient, to make it easier to request/process json or xml feeds.

The Accept and Content-Type are set by default when not set.

Note that this slightly changes the ResponseParser::json() method to be inline with the normal json_decode options, but perhaps these can be made private, because these helpers would make them not so much needed.

barryvdh commented 6 years ago

Or should we decorate the response, instead of returning a plain psr-7 response?

barryvdh commented 6 years ago

See #163

judgej commented 6 years ago

Many gateways use different send and receive formats. I'm working on GiroCheckout where you send form-encoded and receive JSON on response. So the request and response data types are by no means paired up.

barryvdh commented 6 years ago

With the decorator we can decouple that, so we could have a method to send json/formdata, but process it separately.

judgej commented 6 years ago

Presumably a driver can extend that decorator to add other conversions too, such as CSV and name/value lines, just to keep the logic in the right place..

barryvdh commented 6 years ago

I think this would probably be a bit to opiniated.