Skip to main content
This tutorial was written by Claude Code (an AI) and has not yet been reviewed. Follow along with caution. If the tutorial was helpful or a specific part was not clear/correct, please provide feedback at the bottom of the page. Thank you.
This guide covers integrating Mollie with CoCart Preview API. Requires CoCart v4.6+ and a configured Mollie payment gateway.

Overview

Mollie integration with CoCart uses Mollie Components (Mollie.js) for secure tokenization of payment data. This ensures sensitive card information never touches your server while providing PCI DSS SAQ A compliance and access to 30+ European payment methods. Mollie is the leading payment service provider in Europe, particularly strong in the Netherlands, Belgium, and Germany.

Prerequisites

Before implementing Mollie checkout, ensure you have:
  1. Mollie payment gateway configured in WooCommerce
  2. Mollie.js library loaded in your frontend
  3. A valid cart with items added
  4. Customer billing address information
  5. Mollie profile ID (found in Dashboard > Developers > API keys)

Integration Flow

1

Load Mollie.js

Initialize the Mollie JavaScript library
2

Initialize Mollie Object

Create Mollie instance with your profile ID
3

Create Components

Set up secure iframe-based payment input fields
4

Collect Payment Details

Securely collect card information from customers
5

Generate Card Token

Create a temporary card token using Mollie.js
6

Complete Checkout

Submit checkout with card token to CoCart for processing

Step 1: Load Mollie.js

Include the Mollie.js library in your checkout page:
Mollie.js is always served over HTTPS and automatically stays up to date with the latest version.

Step 2: HTML Structure

Create a checkout form with containers for Mollie Components:

Step 3: Initialize Mollie Components

Initialize Mollie.js and create components:

Step 4: Component Error Handling

Set up validation and error handling for components:

Step 5: Handle Form Submission

Process the checkout when the user submits the form:

Step 6: Process Checkout

Submit the checkout with card token to CoCart:

Complete Integration Example

Here’s a complete working implementation:

Styling Components

Add CSS to style the Mollie Components:

Testing

For development and testing with Mollie:

Test Mode

Enable test mode when initializing Mollie:

Test Card Numbers

Use these test cards in test mode:
  • Valid Card: 5555 5555 5555 4444 (Mastercard)
  • Declined Card: 5555 5555 5555 4440
  • Insufficient Funds: 5555 5555 5555 4442
  • Expired Card: 5555 5555 5555 4445

Test Card Details

  • Expiry Date: Any future date (e.g., 12/25)
  • CVC: Any 3 digits (e.g., 123)
  • Cardholder: Any name

3D Secure Testing

Mollie automatically handles 3D Secure authentication. In test mode, you’ll be redirected to a test authentication page.

Error Handling

Handle common Mollie error scenarios:

Troubleshooting

Common Issues

Problem: Mollie object is undefined.Solution:
  • Check browser console for loading errors
  • Verify no ad blockers are interfering
  • Ensure HTTPS is enabled (required)
Problem: Card fields don’t appear.Solution:
Problem: createToken() returns errors.Solution:
  • Ensure all card fields are filled
  • Verify card number is valid
  • Check expiration date is future
Problem: Backend doesn’t accept Mollie payment.Solution:
  • Verify Mollie gateway is enabled in WooCommerce
  • Check payment method ID matches gateway
  • Ensure Mollie API keys are configured
Problem: Works in test but not live.Solution:
Checklist:
  • Switch profile ID from test to live
  • Update API keys in WooCommerce
  • Disable test mode in Mollie initialization
  • Verify account is activated for live payments

Debug Mode

Getting Help

  1. Mollie Documentation: Mollie Components Guide
  2. Mollie Support: Contact through dashboard
  3. WooCommerce Logs: Check WooCommerce → Status → Logs

Best Practices

Security

  • Always use Mollie Components for card data
  • Never store raw card information
  • Use HTTPS for all requests
  • Implement proper form validation
  • Card tokens expire after 1 hour
  • Handle 3D Secure redirects properly

User Experience

  • Show real-time validation errors
  • Provide clear error messages
  • Handle declined cards gracefully
  • Support keyboard navigation
  • Display supported card brands
  • Auto-format card numbers

Compliance

  • Mollie Components provide SAQ A compliance
  • No sensitive card data touches your server
  • Implement proper error handling
  • Log transactions for auditing
  • Test with various card types
  • Follow GDPR requirements

Performance

  • Load Mollie.js from CDN
  • Components auto-update
  • Implement proper timeouts
  • Handle network failures
  • Monitor transaction success rates
  • Cache payment contexts appropriately

Supported Payment Methods

Beyond credit cards, Mollie supports 30+ payment methods:

European Payment Methods

  • iDEAL (Netherlands)
  • Bancontact (Belgium)
  • SOFORT (Germany, Austria)
  • Giropay (Germany)
  • EPS (Austria)
  • Przelewy24 (Poland)
  • KBC/CBC (Belgium)
  • Belfius (Belgium)

Other Methods

  • PayPal
  • Apple Pay
  • Credit Card (Visa, Mastercard, Amex)
  • SEPA Direct Debit
  • Bank Transfer
  • Gift Cards (Various brands)
Each payment method has its own component or API integration. Consult the Mollie documentation for specific implementation details.

Advanced Features

Apple Pay Integration

iDEAL Bank Selection

Troubleshooting

Common issues and solutions: Components not loading: Check that Mollie.js script is loaded and profile ID is correct. Card token creation fails: Verify all component fields are valid and filled. 3D Secure redirect fails: Ensure your redirect URLs are properly configured in Mollie dashboard. Styling not applied: Components use iframes; customize using Mollie’s styling API. Test mode not working: Verify testmode flag is set to true in Mollie initialization.
Always test your Mollie integration thoroughly using test mode before going live. Ensure your webhook endpoints are configured to handle payment status updates. Monitor your Mollie dashboard for declined transactions and implement appropriate retry logic.

Webhook Handling

Mollie sends webhooks for payment status updates:

Additional Resources