silverstripe / silverstripe-omnipay

Silverstripe integration with Omnipay PHP payments library.
BSD 3-Clause "New" or "Revised" License
39 stars 67 forks source link

How do you know exactly what config options you need for each gateway? #213

Closed muppsy007 closed 4 days ago

muppsy007 commented 4 years ago

Referring to this doc: https://github.com/silverstripe/silverstripe-omnipay/blob/master/docs/en/Configuration.md

How do developers know what the correct "allowed_gateways" value for each adapter is, and the related parameters? Are they literal values from the payment service? From the adapter code? What is the process for developers to work with this module?

Example, I am trying to set up a payment with stripe adapter. I have installed the module and the adapter, but how do I know what the adapter-specific settings in the payment.yml are supposed to be?

---
Name: payment
---
SilverStripe\Omnipay\Model\Payment:
  allowed_gateways:
    - 'Stripe'

SilverStripe\Omnipay\GatewayInfo:
  Stripe:
    parameters:
      i_guess_this_is_the_name_for_the_secret_key_var: 'sdfgsdfgsdfterw43534424'
bummzack commented 4 years ago

The allowed gateways should follow omnipay-naming conventions. These are outlined here: https://github.com/silverstripe/silverstripe-omnipay#gateway-naming-conventions

All settings that are specific to this module (silverstripe-omnipay that is) are described in the configuration documentation you linked in your question. Everything that goes into parameters are parameters that are directly passed to the omnipay gateway itself. These cannot be described here, because they are specific to each gateway. For stripe, it's what they have in the default parameters: https://github.com/thephpleague/omnipay-stripe/blob/master/src/AbstractGateway.php#L106

Eg. only the apiKey has to be set. Other than that I highly recommend setting testMode to true, especially for dev-environments.

muppsy007 commented 4 years ago

Thanks @bummzack. The second link helps a lot.

I am wondering if I am on the right path in using this module for my user case. We want to use Stripe's hosted payment form rather than creating a payment form in Silverstripe and posting it to Stripe. It doesn't appear the module actually supports this method in an abstract way.

Do you think for using hosted services like that, I am better off with bespoke code rather than a module like this?

bummzack commented 4 years ago

If you just use a single gateway (and don’t plan to add others in the future ), the benefit of the omnipay library in general can be questionable. Although I have also integrated StripeJS checkout with silverstripe-omnipay and silvershop. Here’s an example of that: https://gist.github.com/bummzack/e90a0cc4c65a681747c57db2f47da88e

On 20 Oct 2019, at 10:30, Aaron Cooper notifications@github.com wrote:

Thanks @bummzack. The second link helps a lot.

I am wondering if I am on the right path in using this module for my user case. We want to use Stripe's hosted payment form rather than creating a payment form in Silverstripe and posting it to Stripe. It doesn't appear the module actually supports this method in an abstract way.

Do you think for using hosted services like that, I am better off with bespoke code rather than a module like this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

muppsy007 commented 4 years ago

OK thanks @bummzack. Yeah I think if I was going that route the module might be overkill. Happy to adjust needs for the sake of flexibility. One of the main attractions of the module for us was giving the customer the ability to switch to another gateway if they chose to later. Without having to completely rewrite their checkout.

So looking at the documentation for self-hosted forms for posting to the gateway, can you guess why this would be returning zero form fields?

$factory = GatewayFieldsFactory::create('Stripe');
$fields = $factory->getFields();

Because it is "off-site"? If so, what exactly does this module do for gateways like Stripe?

bummzack commented 4 years ago

Generally speaking, the silverstripe-omnipay module helps with offsite gateways by providing callback URLs and dealing with async-notifications.

In the case of stripe it's slightly different though, since the checkout form is built with JS and then you get a token from that. You can still use it with the Omnipay Stripe gateway though, just pass in the token you get from the stripe checkout.