1

I am wondering how to implement payments in Flutter(or any other framework, like react or angular). There is an existing website built in Wordpress and WooCommerce. The following plugin is used:

How can I handle a payment, that matches the order id and moves the user to the payment banking screen?

When a user presses the "Checkout" button in the frontend, do I need to do the following?

  1. Call a custom function that was made in Wordpress PHP (wp-json/payment/create)
  2. Call the woocommerce endpoint create order in that PHP function. https://woocommerce.github.io/woocommerce-rest-api-docs/#create-an-order.
  3. And then call the mollie endpoint create payment in that PHP function? https://docs.mollie.com/reference/v2/payments-api/create-payment. Put order id in parameters that I received from the woocommerce endpoint.
  4. Then return the redirect link to the react or flutter app
  5. How can I know that the payment is succesful? Then I can call 'update order' and set the status from 'waiting for payment' to 'processing order'. (So Wordpress admin can see that the customer paid.

I could not find a tutorial on this topic and therefore I decided to make this question public. I only saw wordpress tutorials... So I hope this question can help a lot of people.

1 Answer 1

0

How far are you with this? Because I don't know if using the regular mollie plugin is going to help out.

Mollie has documentation on how to also implement their api on JS framework.

The question you need to answer first is:

  • Are you able to create an order using the WooCommerce API. So can you order a product, without actually using a payment gateway (the add to cart to checkout flow)?
  • Have you tried using the Mollie nodejs version?

A tip: Any payment gateway(stripe, mollie etc) add the order_id as meta_data on a order. So after going through the payment flow the order has to be created, with the right payment_id + the status (failed, pending blabla).

Edit:

Another option could be to create custom endpoints which loads something like this: https://github.com/mollie/mollie-api-php

So maybe something like:

  1. create the order using the woocommerce api
  2. after creating the order, return to the js app and then trigger another endpoint
  3. this endpoint would load the custom Mollie api

I hope this makes sense?

Sign up to request clarification or add additional context in comments.

11 Comments

Hey, thank you for your answer! Yes, I can create an order through the WooCommerce API. The status is "waiting for payment" at the moment. I have not tried Mollie Nodejs, because I thought PHP would make more sense. Since I can just edit functions.php to make the endpoint. Yea, I saw the meta_data in the mollie documentations indeed on: docs.mollie.com/reference/v2/payments-api/create-payment. However, I do get an error while trying to call $mollie->payments->create. Is it true that I first should create the order, and then call the payment API with the correct orderid?
Also do you recommend mollie nodejs over php?
Hmm I would prefer PHP over js, but that's me... Maybe you could try creating custom endpoints and then use something like this: github.com/mollie/mollie-api-php
hahaha, nice! I was just looking at that plugin, however, I do not get it. I followed the 'getting started' where they create a new payment. But I get this error: PHP Fatal error: Uncaught Error: Class 'Composer\CaBundle\CaBundle' not found in /var/www/vhosts/websitename/test.websitename/wp-content/plugins/mollie-payments-for-woocommerce/vendor/mollie/mollie-api-php/src/HttpAdapter/CurlMollieHttpAdapter.php:81 This may happen because I did not install anything extra. Do you know how to install this plugin so I can use it in my functions.php?
Have you managed to include the package in yur theme? You can do a manual install and set it up in your theme and from then on you could autoload it in your functions.php
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.