-
Notifications
You must be signed in to change notification settings - Fork 114
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
Implementing the Mollie payment gateway #688
Comments
Instead of using Full example, completely untested: public function process(PaymentResult $result): PaymentResult
{
$gateway = \Omnipay\Omnipay::create('Mollie');
$gateway->setApiKey('test_xxxxxxxxxxxxxxxxxxxxxxxx');
$response = $gateway->purchase(
[
"amount" => "10.00",
"currency" => "EUR",
"description" => "My first Payment",
'returnUrl' => $this->returnUrl(),
'cancelUrl' => $this->cancelUrl(),
]
)->send();
// This example assumes that if no redirect response is returned, something went wrong.
// Maybe there is a case, where a payment can succeed without a redirect?
if ( ! $response->isRedirect()) {
return $result->fail((array)$response->getData(), $response);
}
Session::put('mall.payment.callback', self::class);
return $result->redirectResponse($response->getRedirectResponse());
}
public function complete(PaymentResult $result): PaymentResult
{
$this->setOrder($result->order);
// Using the purchase example from the mollie docs, you don't have to do anything here.
// Just return $result->success to mark your purchase as successful.
// If you are using the "Order API" example, you would call $gateway->completeOrder here.
return $result->success($data, null);
} |
Hi Tobias, thank you very much for wanting to help out. I appreciate it. I've tried out your modifications, but unfortunately it throws the same error regardins CORS as before... Do you have another idea where the problem could be? I'd be more than happy to provide more details if you like. You can test the payment method out here: https://aircokopen.chocolata.be/categorie/webshop Is there maybe a way in which we can update a partial on the checkout page with a piece of JavaScript that redirects the user? P.S.: I double checked that the domains I'm using are allowed by Mollie - the CORS problem should be unrelated to the domains the sites are on now. P.P.S: Here is the resource that states that Mollie does not support AJAX calls: https://help.mollie.com/hc/en-us/articles/214017905-When-I-call-the-Mollie-API-via-AJAX-I-receive-the-error-message-No-Access-Control-Allow-Origin-header-is-present- |
If you never call
and the component returns it from the onCheckout method: oc-mall-plugin/components/Checkout.php Line 257 in 4ad704e
which in turn should do a proper redirect, no AJAX request. Can you share your full code? |
You can also try the method we use for paypal, use return $result->redirect($response->getRedirectResponse()->getTargetUrl()); If you submit the order, the response of the POST request should contain a |
Hi Tobias, thanks so much. It does seem to work with your final suggestions. I'll do some more experiments and keep you posted. Thanks again and have a great Christmas! |
Great! If you can confirm that it works we could integrate the final provider with the plugin. There have been multiple requests for a Mollie integration but there service is not known where I live so I never got around to come up with an implementation. |
Hi Tobias, that would be so great. I've got a few days of holiday, but I'll try to get the Mollie integration up and running for 100% as soon as possible and share the code with you for review. I hope it will be up to standard. I'll keep you posted. |
Mollie addition would be a really good news ! |
Any update on this? Would be interested in this as well :). |
Nice that there's some interest in this! I'll be working on a basic version of this this week and present it to Tobias by the end of it. |
Hi Tobias, just to let you know that I've created a temporary plugin called MollieMall, ready for your evaluation here: https://github.com/maartenmachiels/molliemall You can download the files of this repo to a folder named If you prefer to see it in action on another live site, you can visit: https://aircokopen.chocolata.be/product/kabelgoot-aluminium where the plugin is up and running. Can you please review the code? Everything seems to be working, but there is still some issues:
Do you have an idea how we could tackle those things? I chose not to use the Mollie Order API, since this requires the address to be split into very specific parts (street, zipcode and city all in separate fields) and this isn't available out of the box in the Mall plugin just yet. You have my contact information by mail if you want to go over some details. I'd be more than happy to take some time out to share my (Mollie backend) screen with you if this would be useful. Integrating into the Mall plugin core should be straightforward. In that case the Omnipay Mollie driver would have to be included, together with the Thanks again for all your help. |
Thank you very much for your work! I will take a look at the code as soon as time allows.
Did you set up the
Could this be something mollie specific? Does ist need another url besides the |
Hi Tobias, thanks for your answer and thanks that you're willing to look at it when you find the time. I've set up the I have to be honest that the payment mechanism is a bit unclear to me, so the problem surely will lie in my logic that handles the Mollie return. There is a mention of a
I also saw this issue, making me think there might be some serious limitations to the Omnipay package
Thanks again. Looking forward to your views. |
FYI: I noticed that every payment comes back as successful, even when not in Mollie. So something is definitely not working yet. I'll check it out myself later too :). |
Thank you Bensji - I'm starting to think more and more that we need to ditch the Mollie Omnipay package and use the Mollie PHP wrapper instead. When you say that every payment comes back as succesful, do you mean also in Stripe and other payment methods? Or is it only when using this plugin? Thanks again for your support. If you'd like to talk more in-depth about this, you can contact me via my website https://chocolata.be and we could for example schedule an online meeting or something. I'd be more than happy to put in more work. |
Hi guys, has anyone of you had the chance to look at this code? Thanks in advance. |
I did add an implementation in the mollie branch based on your plugin, @maartenmachiels: It's important to fetch the payment after the user has returned to the store and check the status of it. If the user canceled the payment it will have the Currently, this implementation is only one side of the story: If the user triggers a bank payment, the order status is changed to Maybe someone is willing to add these features to the branch. Otherwise, there remains a manual step for the shop owner. Please test this version and let me know if anything needs fixing. |
Hi Tobias - thanks so much for your work. I downloaded the repo and ran
When I remove the Offline folder from my plugins folder, the error message is gone (but replaced by an error message pertaining to the cart component not existing...). Could I have done something wrong on my end? Is there something else I could do to test out the new functionality? Thanks in advance. |
Make sure to run |
Hi Tobias, thanks for your insights. After some fidgeting, I got the testsetup working. These are my findings: When choosing a payment method and selecting any other payment status than "paid", the Mollie page just refreshes. I think when the payment is cancelled, failed or expired, the shop should display an according message. One thing I saw, but cannot seem to reproduce is that clicking the back link at the bottom of the Mollie page did yield a succesful order. In my next tests, clicking this link threw the right error message => payment cancelled. Could you kindly look into this? Did you receive the test api key I sent you via mail on January 7th? I'd be more than happy to do any further tests. |
That's what I experienced as well. I wasn't sure if my AdBlcoker is interfering or another problem exists. It's strange that this seems to be default behaviour. The shop should show a message in these cases.
It would be interesting to see what the oc-mall-plugin/classes/payments/Mollie.php Line 111 in 2feccf4
For the success message to appear the status would have to be Also, check the |
Hi Tobias, Thanks for your answer. Here is some additional information on the payment statuses in Mollie:
I feel like we are hitting the limits of the OmniPay Mollie library. Did you see these issues? |
I haven't looked in the Mollie API directly, but if they provide a good SDK changing the payment provider should be trivial. Would that problem be solved by handling the incoming webhooks? In case of a |
Hi tobias, sorry for the late reply... I've been dealing with some personal stuff but I'm getting back on the horse. Yes, their API should be very straightforward. I think that the issue would indeed be solved by handling the incoming webhook. Indeed, the pending payment would be updated to "Paid" or "Failed" when processing by Mollie is finished. Here you can see the payments documentation and a graph of how Mollie works in English (documentation is also available in German) https://docs.mollie.com/payments/overview Ah, and by the way, there are two packages available that can be used for implementing Mollie:
Is there maybe any way we could discuss this one on one? I'd be more than happy to do any work on this implementation, but I do feel I'd need some guidance on getting it up and running within the OFFLINE Mall Plugin. Would you feel up to that? If so, how would you like me to contact you? |
I'm closing this issue due to inactivity. If you need any further assistance feel free to reply. |
Hi,
I'm trying to get the payment gateway Mollie working with the Mall plugin. I've created a plugin and imported the relevant OmniPay packages (https://github.com/thephpleague/omnipay-mollie). I'm basing myself on the example as provided by the makers of the OmniPay Mollie package.
I would like the user to be redirected to the Mollie payment page (example https://www.mollie.com/payscreen/select-method/8sTxQCJ7Vy) and have them select their preferred way of paying there (debit card, credit card, paypal, bank transfer...) and have them redirected to the site once they complete the payment.
My in my Payment Provider class, the process method looks like this:
This almost works, but there is one big snag: it seems Mollie doesn't allow a redirect to their platform that originates in Ajax. So I get the following error message (both in localhost development and in a staging environment with a valid SSL-certificate):
Access to XMLHttpRequest at 'https://www.mollie.com/payscreen/select-method/8sTxQCJ7Vy' (redirected from 'http://localhost/myproject/checkout/confirm') from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I did some searching and saw that others encounter the same issue (with different platforms):
https://stackoverflow.com/questions/43766286/no-access-control-allow-origin-header-is-present-on-the-requested-resource-m
They ask that the redirect happens via another way, for example the user pressing a certain button, or a redirect in another way.
What would you recommend I do in this situation? Is there a workaround for such a thing?
Thanks in advance for your response.
The text was updated successfully, but these errors were encountered: