Adding support for user and account gateways #209
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, Big fan! I really appreciate all of the work you all did to put Omnipay together.
I work for a company that is building an application that is sort of a "merchant marketplace" where essentially we are providing a platform for non-profits to create accounts and solicit donations. Like many others that have discovered Omnipay, we built our application and then discovered that we didn't totally love the payment processor we were using.
So, we began to build Omnipay into our platform but quickly noticed that there wasn't much in support for a common api for creating accounts and users with the payment processor platforms. This PR lays the foundation for that support.
If this fork is accepted, driver developers should now think of their drivers as providing 3 gateways:
Accessing the gateways would follow the same conventions from before but unlike
Omnipay\Omnipay::create('[name]')
to retrieve the payment gateway, you would useOmnipay\Omnipay::user('[name]')
andOmnipay\Omnipay::account('[name]')
to retrieve the user gateway and the account gateway. In the PR,::create
was left alone but we also added::payment
as an alias to create.For the GatewayFactory to resolve the payment gateway, it will look for a gateway with the following namespace pattern:
Omnipay\[name]\Gateway
. As you can see, this was left alone. But for User and Account gateways, the Gateway factory will look forOmnipay\[name]\User\Gateway
andOmnipay\[name]\Account\Gateway
respectively.To support these new gateways, we added
AbstractAccountGateway
andAbstractUserGateway
. Again, my goal in this PR was to not break all of the existing v3 drivers, thus, some of the naming might look funky. For instance,AbstractGateway
is still the class a driver would extend to build their Payment Gateway. And now, these three abstract classes extend fromAbstractGenericGateway
. I think in an ideal world, we'd have an AbstractPaymentGateway and then all of these classes would extend AbstractGateway, but I digress.Further,
AbstractRequest
now extendsAbstractGenericRequest
and the new gateways can use requests that extend this new base abstract class.To support testing of the new gateways, we forked the omnipay-tests package to radcampaign/omnipay-tests and added
AccountGatewayTestCase
andUserGatewayTestCase
. If this PR is accepted, I'll submit a PR for this fork as well.For an example of how a driver might look with this new PR - we are actively working on a wepay driver that can be found at radcampaign/omnipay-wepay. Please keep in mind though that this is under active development.
Thank you much! I hope that this PR furthers this project in productive way.