Closed nilsenpaul closed 5 years ago
Looking at the mollie omnipay source code, it looks like things like iDeal are called issuers
? https://github.com/thephpleague/omnipay-mollie/blob/master/src/Gateway.php#L53
If mollie has additional options that are not presented in the current payment formmodel like issuers , we would need to expose that to this plugin.
I assume if you don't pass an issuer from the form, after redirect mollie shows a screen to let the customer to choose their issuer? As it looks like it is optional.
Luke, in Mollie API v2, what I need is called methods
. Each method can have one or more issuers. See https://docs.mollie.com/reference/v2/methods-api/get-method#id1 for an example of what response data for /methods/id looks like (if you include issuers).
So, iDeal would be a method, and the bank you choose would be the issuer. Both are optional, but I should be able to use both ids in the payment form, so Mollie redirects the visitor to the correct page.
In the Omnipay Mollie source, that would be fetchPaymentMethods
, I guess. From there, I should be able to get the payment method's issuers, I guess.
More on this ... It seems that Mollie API v1 (deprecated) which is used by OmniPay, has an issuers
endpoint that returns all iDeal banks. In API v2, there's a methods
endpoint, that allows you to include issuers in the response.
For now (API v1) I added this to commerce-mollie/src/gateways/Gateway.php
:
public function fetchPaymentMethods(array $parameters = [])
{
$paymentMethodsRequest = $this->createGateway()->fetchPaymentMethods($parameters);
return $paymentMethodsRequest->sendData($paymentMethodsRequest->getData())->getPaymentMethods();
}
public function fetchIssuers(array $parameters = [])
{
$issuersRequest = $this->createGateway()->fetchIssuers($parameters);
return $issuersRequest->sendData($issuersRequest->getData())->getIssuers();
}
If you could implement this in the Commerce Mollie plugin (in the correct way and style, of course), I would be very happy for now. It does the job, but moving to Mollie API v2 would be the better choice (as soon as Omnipay supports this, which they are working on: https://github.com/thephpleague/omnipay-mollie/issues/48
In addition to adding methods like those to the gateway, don't we also need to pass the issuer value the customer selects to the payment request/redirect? How are you doing that at the moment with those changes?
I'm not. I was hoping you would know the way to do that :)
OK, will need to do this on a new feature branch. Will let you know what to update your composer.json to so you can test for me. Thanks.
Nice @lukeholder! Could you let me know how soon this could be done? I need to know if I have to come up with a temporary solution ...
@nilsenpaul I have added initial support for payment methods and issuers on the feature/issuers branch. Try it by updating your composer.json version of commerce-mollie
to dev-feature/issuers
, then do a composer update.
The payment form is pretty rough, it is just 2 dropdowns, but welcome feedback.
Thanks.
@lukeholder Seems to be working just fine, thanks! Am I right in assuming that payment form values are not saved anywhere on Commerce's end, but only sent to Mollie?
@lukeholder When will this be merge into master?
This has actually been merged into the master. Oops.
Mollie provides you with a list of available payment methods and, if iDeal is chosen, banks through its API. (How) can I get those lists from my template? I know I once did it in Commerce v1, but can't seem to find the template source for that.