Jump to content

Recommended Posts

I ran into this issue too. I edited the Mollie module to fit my own needs, a bit too many changes to create a merge request, but it deals with this issue. 


<?php namespace ProcessWire;

// Here you can find more information about the Mollie php api https://github.com/mollie/mollie-api-php

require_once __DIR__ . "/vendor/autoload.php";

class PaymentMollie extends PaymentModule

    public static function getModuleInfo()
        return [
            'title' => 'PaymentMollie',
            'version' => '0.0.2',
            'summary' => 'Mollie Payment method',
            'singular' => false,
            'autoload' => false,
            'requires' => 'ProcessWire>=3.0.98, PaymentModule',

    public function init()
        ini_set('display_errors', 1);
        ini_set('display_startup_errors', 1);

    public function getTitle()
        return $this->_("Mollie: iDeal, Bancontact");

    public function getFailureReason()
        return "Error";

    public function processPayment()
        $payment_id = wire()->input->post->id;
        $order_id = wire()->input->urlSegment2;

        $mollie = new \Mollie\Api\MollieApiClient();

        if ($this->live_check == "1") {

        $payment = $mollie->payments->get($payment_id);
        $order_id = $payment->metadata->order_id;

        wire()->log->save("mollie", "Processing payment for... $order_id");

        if ($payment->isPaid() == true) {

            wire()->log->save("mollie", "Order $order_id was paid using mollie!");

            $order = wire()->pages->get($order_id);
            $order->pad_paid = time();
            $order->addNote($this->_("Order paid using Mollie") . ": " . $payment->id);

            return true;
        } elseif ($payment->isOpen() == FALSE) {
            return false;
        return false;

    public function getMollieMethods()
        $mollie = new \Mollie\Api\MollieApiClient();

        if ($this->live_check == "1") {

        $methods = $mollie->methods->all();
        $return = [


        foreach ($methods as $method) {
            $return[] = [
                "title" => htmlspecialchars($method->description),
                "icon" => htmlspecialchars($method->image->size1x),
                "icon2x" => htmlspecialchars($method->image->size2x),

        return $return;

    public function render()
        $output = "";

        $mollie = new \Mollie\Api\MollieApiClient();

        if ($this->live_check == "1") {

        $paymentInfo = [
            "amount"   => [
                    "value" => number_format(($this->getTotalAmount() /100), 2, '.', ''),
                    "currency" => 'EUR',
            "description" => "Bestelling van: " . $this->customer->givenName . " " . $this->customer->familyName,
            "redirectUrl" => $this->httphost . "checkout/?id=" . $this->id,
            "webhookUrl"  => $this->httphost. "checkout/processmollie/" . $this->id . "/",

            // Specify here wat you want
            "metadata" => [
                "order_id" => $this->id,
                    "customer_name" => $this->customer->givenName,
                    "customer_familyName" => $this->customer->familyName,
                    "customer_address" => $this->customer->streetAddress,
                    "customer_locality" => $this->customer->locality,
                    "customer_postalCode" => $this->customer->postalCode,
                    "customer_country" => $this->customer->country,
                    "customer_email" => $this->customer->email

        // $output .= "<pre>" . print_r($paymentInfo, true) . "</pre>";

        $payment = $mollie->payments->create($paymentInfo);

        wire()->log->save("mollie", "Creating the payment... $order_id");

        // Type here your custom HTML
        // use $payment->getPaymentUrl() as url for your payment link

        foreach ($methods as $method) {
            $output .= '<div style="line-height:40px; vertical-align:top">';
            $output .= '<img src="' . htmlspecialchars($method->image->size1x) . '" srcset="' . htmlspecialchars($method->image->size2x) . ' 2x"> ';
            $output .= htmlspecialchars($method->description) . ' (' . htmlspecialchars($method->id) . ')';
            $output .= '</div>';
        $output .= "</div>";

        $output  .= "<div><form action='{$payment->getCheckoutUrl()}'>
            <button type='submit'>". __('Pay') ."</button></form></div>";

        return $output;

    public static function getModuleConfigInputfields(array $data)
        $inputfields = new InputfieldWrapper();

        // Test API
        $live_api_field = wire('modules')->get('InputfieldText');
        $live_api_field->name = 'test_api_key';
        $live_api_field->label = __("Test API Key");
        $live_api_field->notes = __("");
        if (isset($data['test_api_key'])) {
            $live_api_field->value = $data['test_api_key'];


        // Live API
        $test_api_field = wire('modules')->get('InputfieldText');
        $test_api_field->name = 'api_key';
        $test_api_field->label = __("Live API Key");
        $test_api_field->notes = __("");
        if (isset($data['api_key'])) {
            $test_api_field->value = $data['api_key'];


        // Select live or test API
        $check_api_field = wire('modules')->get('InputfieldCheckbox');
        $check_api_field->name = 'live_check';
        $check_api_field->checked = $data['live_check'];
        $check_api_field->label = __("Use Live API Key");
        $check_api_field->notes = __("If not selected, the test-api will be used. Keep in mind that you also have to activate the Live api on your Mollie dashboard");
        if (isset($data['live_check'])) {
            $check_api_field->value = $data['live_check'];


        // HTTP Host url
        $httphost_field = wire('modules')->get('InputfieldURL');
        $httphost_field->name = 'httphost';
        $httphost_field->label = __("HTTP Host");
        $httphost_field->notes = __("");
        if (isset($data['httphost'])) {
            $httphost_field->value = $data['httphost'];


        return $inputfields;


  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jonathan Sachse Mikkelsen
      I'm developing a site where the client wants a one time donation form with Mollie payment integration.
      I've been using PW for about 3 years now (and of course loving it 😉), but have absolutely no experience with any form of webshop functionality and after a full day of googling around I find myself utterly stuck in how to make this happen...
      Is there anyone out there that could point me in a direction of the simplest solution possible? I really don't want to, nor am i capable right now, to be developing a fully fledged webshop for this small feature on this particularly site 😬, so any help is greatly appreciated! 
    • By Jeannette
      Hello, I have a wonderful webshop with lovely skills here : cheval-ami.fr
      I need some support sometimes to make sure that everything is nice and up to date.
      We want to improve the integration of Paypal, Stripe, DHL ... create personal accounts for our clients, keep our visual configurateur smooth, include a search enigne and be the nicest shop in the equine industry. We are a start up and very much interested in a long time, kind and friendly relationship without any stress, but good support in case of urgency. 
      We speak english, german and french. We a have our own designer aware of ProcessWire. We could meet in hamburg or Paris.
      Contact: mail@cheval-ami.fr or +33 626 22 1000 or +49 170 20 28 215
      Thank you !
    • By Typografics
      Each year we cycle 1000km with our company to fight against cancer. To participate with 4 teams we have to collect 20.000 euros.
      Our graphic designers made some goodies en we also organise a spaghetti fundraiser. To help the sales we decided to make a webshop with our webteam. And of course we used our favourite CMS for the job! 🙂
      At this moment we raised more than 20.000 euros, so all our teams can participate. This is a very special project for us, unfortunately one of our colleagues has been diagnosed with cancer and currently is fighting against this terrible disease. 
      Premium PW modules used in this project:
      With a few hooks here and there we managed to make it work. To handle the payments we made use of Mollie, we created our own payment module and will opensource this soon.
      You can read more about this project in our blog (in dutch) 
      Unfortunately we're currently only shipping to Belgium
      We’re already brainstorming to make a 2.0 version of this webshop, so all your feedback is more than welcome.
    • By dzervas
      Hello, I want to develop an eshop with processwire + padloper + any needed module (ex. ProCache n stuff).
      Right now, the eshop is in CS-Cart and I hate it. Will pw be able to support "proper" eshop features such as some simple sales graphs, 1k+ products, shipping methods & costs, user registration, search history, order status, payment status (for bank transfers for example) etc.
      For example I'm thinking that products and orders as sub-pages will be problematic (10k+ sub-pages)
      I also want to know if it's actually worth it or if it would be better to move to a bigger platform which has some of these features out of the box.
      Currently, the problem with CS-Cart is major lack of documentation which limits me in writing custom features (connection with shipping providers, export of data via CardDAV and more). Also CS-Cart is too complex to handle without documentation. I can manage and understand the code of PW but CS-Cart is just too big.

      Of course the server is beefy enough to handle things even heavier than CS-Cart. My focus is on development process and workflow (I've already set up CD from github to a docker container for a small website)
      EDIT: Sylius and Thelia2 really caught my eye. Comments on them will be appreciated
    • By kongondo
      Released 29 May 2017
      Variations is a simple yet powerful commercial ProcessWire module that allows website editors to create attributes and their values and from those generate variations of any entity, most notably products.
      The module consists of  FieldtypeVariations and InputfieldVariations as well as a ProcessVariations for managing variations configurations and attributes.   Setting up the field is quite easy.   First, create a field of type Variations. Define some custom inputs that will need to be directly edited on the page containing the field, for instance a product price, SKU, etc.   Secondly, via the Inputfield, create a couple of attributes.   Thirdly, create a variations configuration and add the attributes and values you want in the configuration. Link that variations configuration to your page and the module will automatically generate all possible combinations (variations) of the attribute values in that configuration. These, together with the custom inputs you created when setting up the field will be displayed on the page (e.g. a product page), ready for editing. This makes this module quite unique; variations are defined at the page-level rather than at the field level. This presents lots of possibilities such as infinitely reusable attributes and variations configurations.    For those using Padloper, integration with the e-commerce platform is quite simple as demonstrated in this tutorial.  The module consists of 4 modules
      ProcessVariations FieldtypeVariations InputfieldVariations VariationsCustomTableManager (autoload module, working behind the scenes) Video Demo: https://youtu.be/T93nn96UL8o
      Documentation: https://variations.kongondo.com/
      Shop: https://processwireshop.pw/plugins/variations/
      Requires: ProcessWire 2.5 or newer
      Easily create variations of anything, including products for e-commerce websites, etc Create an attribute once, use it everywhere, multiple times, picking and choosing all or only the attribute values you want Bulk editing of variations configurations and attributes Reusable variations configurations Works with Padloper out-of-the-box with minimal coding User-friendly, intuitive and easy to set up
  • Create New...