Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for multiple of the same payment gateway #220

Open
nzphoenix opened this issue Jun 4, 2020 · 1 comment
Open

Adding support for multiple of the same payment gateway #220

nzphoenix opened this issue Jun 4, 2020 · 1 comment

Comments

@nzphoenix
Copy link

One use case that I've come across recently is where there is the need for multiple configurations for the same payment gateway. For example, using the Paystation_Hosted gateway with a specific config set for payments that are donations, but using a different Paystation_Hosted gateway config for fundraising. This could happen in the real world if different parts of a business have separate payment gateway accounts.

Currently this isn't possible as the YAML configuration for Omnipay uses the name of the gateway to then pull in the class, for example:

SilverStripe\Omnipay\GatewayInfo:
  Paystation_Hosted:
    parameters:

GatewayInfo.php functon niceTitle will call create() on GatewayFactory (omnipay common).

Is there a way to support using multiple of the same gateways, was thinking the ability to pass an optional parameter to the yaml to use that instead of forcing it to use the name for both the gateway attached to the payment and the class that gets instantiated:

SilverStripe\Omnipay\GatewayInfo:
  Paystation_Hosted1:
    gateway_class: Paystation_Hosted
    parameters:

SilverStripe\Omnipay\GatewayInfo:
  Paystation_Hosted2:
    gatway_class: Paystation_Hosted
    parameters:

Might not work, there's a tonne of abstraction to follow in the code, but thought I would see if anyone has had to solve this problem before?

@wernerkrauss
Copy link
Contributor

Thought about this, too. For now I have to subclass the gateway and set the parameters manually.

Maybe it's possible to use injector to initialise the gateway? Or some kind of "GatewayInjector"?
Then we could add params as we need and reuse the same php class for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants