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

(Can I) get a list of payment methods and/or banks from Mollie? #2

Closed
nilsenpaul opened this issue Jun 22, 2018 · 11 comments
Closed

(Can I) get a list of payment methods and/or banks from Mollie? #2

nilsenpaul opened this issue Jun 22, 2018 · 11 comments

Comments

@nilsenpaul
Copy link

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.

@lukeholder
Copy link
Member

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.

@nilsenpaul
Copy link
Author

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.

@nilsenpaul
Copy link
Author

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: thephpleague/omnipay-mollie#48

@lukeholder
Copy link
Member

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?

@nilsenpaul
Copy link
Author

I'm not. I was hoping you would know the way to do that :)

@lukeholder
Copy link
Member

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.

@nilsenpaul
Copy link
Author

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 ...

@lukeholder
Copy link
Member

lukeholder commented Jul 2, 2018

@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.

@nilsenpaul
Copy link
Author

@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?

@lenvanessen
Copy link

@lukeholder
When will this be merge into master?

@andris-sevcenko
Copy link
Contributor

This has actually been merged into the master. Oops.

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

4 participants