thephpleague / omnipay-common

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

Card / Customer splitting #183

Open barryvdh opened 6 years ago

barryvdh commented 6 years ago

For many projects, the 'CreditCard' object is used for just customerData. We could split it up, but what would be the best way to do this, without BC breaks?

Gateways use getCard and users use setCard, so we can't just add a Customer object by default.

The most that bugs me is the name of the object, and the validation of the object. So could we just use the same object but allow both card and customer as objects? And change the validation a bit?

eg. passing customer would behave the same as card, by setting card internally And validate() could behave different when parameters are passed.

See also https://github.com/thephpleague/omnipay-common/pull/80

judgej commented 6 years ago

I think the approach should be deciding what the new interface should be, then mapping the old CreditCard object onto the new interface internally. The CreditCard object could be deprecated (with longer term support for some time) but ultimately there would be a better interface to use, with a better division of data into value objects: address, person, business, payment types/sources classes (credit card, debit card, direct debit, magnetic stripe, giropay, temporary AJAX token, repeat transaction, saved card token etc). I think V4 gives us a chance to take a step back and look at the whole API with a fresh look, as payment gateways have moved on a long way since Omnipay was first created. Mapping the V3 API to a more robust API would be built-in, or even installed as a separate V3-compatibility extension.

Omnipay does not have to provide all features of all gateways, but have a better idea of what features gateways supply and people want to use, so I believe the interface needs to be abstract enough to be able to plug in custom handling classes for all these features.

That's my 2p worth.

barryvdh commented 6 years ago

I made a cosmetic change here: https://github.com/thephpleague/omnipay-common/pull/185 Ideally those would be split but that would be a big breaking change.

xini commented 5 years ago

What is the status of this? And what exactly happened to #80? Thanks.

barryvdh commented 5 years ago

That was reverted, because we decided to do a minimal 3.x upgrade.

xini commented 5 years ago

Thanks @barryvdh. What are the plans and timeline to integrate this?