πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
DemoInstallSign in
Socket

mollie-component-react-wrapper

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mollie-component-react-wrapper

πŸš€ **Unofficial React Wrapper for Mollie.js**\ This package provides a **React-friendly integration** for [Mollie Components](https://docs.mollie.com/docs/mollie-components), enabling secure and PCI-compliant card payment forms.

0.1.0
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
Β 
Created
Source

Mollie Component React Wrapper

πŸš€ Unofficial React Wrapper for Mollie.js
This package provides a React-friendly integration for Mollie Components, enabling secure and PCI-compliant card payment forms.

πŸ’‘ Note: This is an unofficial wrapper and is not maintained or endorsed by Mollie.

πŸ“¦ Installation

Install the package via npm:

npm install mollie-component-react-wrapper

Ensure you have React and ReactDOM installed as peer dependencies:

npm install react react-dom

πŸš€ Usage

1️⃣ Initialize Mollie with MollieComponentProvider

Wrap your application with MollieComponentProvider to initialize Mollie.js:

import React from 'react';
import ReactDOM from 'react-dom/client';
import { MollieComponentProvider } from 'mollie-component-react-wrapper';
import App from './App';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);

root.render(
  <MollieComponentProvider profileId="your_profile_id" options={{ locale: 'en_US' }}>
    <App />
  </MollieComponentProvider>
);

Replace your_profile_id with your Mollie Profile ID.

2️⃣ Using the Standalone MollieCardForm Component

MollieCardForm provides a fully integrated UI for collecting card details. It manages its own state and event handling.

import { MollieForm, MollieCardForm, useMollie } from 'mollie-component-react-wrapper';

const PaymentForm = () => {
  const { isLoaded } = useMollie();
  const handlePayment = (token: string) => {
    console.log('Received token:', token);
  };

  if (!isLoaded) return <h2>Loading...</h2>;

  return (
    <div>
      <h2>Complete Payment</h2>
      <MollieForm onSubmit={handlePayment}>
        <MollieCardForm />
      </MollieForm>
    </div>
  );
};

export default PaymentForm;

βœ” Handles all card input fields internally
βœ” Automatic validation and error handling
βœ” Generates a token upon submission

3️⃣ Using Individual Input Components

For custom layouts, use individual input components with forwardRef support:

import { MollieForm, MollieCardNumberInput, MollieCardHolderInput, MollieExpiryDateInput, MollieVerificationCodeInput } from 'mollie-component-react-wrapper';
import { useRef } from 'react';

const PaymentForm = () => {
  const cardNumberRef = useRef(null);
  const expiryDateRef = useRef(null);

  const handleSubmit = (token: string) => {
    console.log('Token received:', token);
  };

  return (
    <MollieForm onSubmit={handleSubmit}>
      <MollieCardNumberInput ref={cardNumberRef} onChange={() => console.log('Card number changed')} />
      <MollieCardHolderInput onBlur={() => console.log('Card holder field blurred')} />
      <MollieExpiryDateInput ref={expiryDateRef} onChange={() => console.log('Expiry date changed')} />
      <MollieVerificationCodeInput onBlur={() => console.log('CVC field blurred')} />
      <button type="submit">Pay Now</button>
    </MollieForm>
  );
};

export default PaymentForm;

βœ” Customizable layout
βœ” Event listeners available (onChange, onBlur, etc.)
βœ” Supports ref forwarding for better control

🎨 Styling Inputs

You can customize the input styles using the styles prop:

const inputStyle = {
  styles: {
    base: {
      color: '#333',
      fontSize: '16px',
      padding: '10px',
    }
  }
};

<MollieCardNumberInput styles={inputStyle} />

For more details, refer to Mollie’s Styling Guide.

⚑ API Reference

πŸ”Ή MollieComponentProvider

PropTypeRequiredDescription
profileIdstringβœ… YesMollie Profile ID
optionsobject❌ NoAdditional Mollie configuration options

πŸ”Ή useMollie

PropTypeDescription
isLoadedbooleanLoading state of mollie object
_mollieobjectA shallow reference to mollie object

πŸ”Ή MollieForm

PropTypeRequiredDescription
onSubmit(token: string) => voidβœ… YesCallback when a payment token is generated

πŸ”Ή Input Components

ComponentDescription
MollieCardNumberInputCaptures the card number
MollieCardHolderInputCaptures the cardholder's name
MollieExpiryDateInputCaptures the card's expiration date
MollieVerificationCodeInputCaptures the CVV security code

πŸ”Ή Event Listeners for Inputs

EventDescription
onChangeTriggered when input value changes
onBlurTriggered when the input loses focus
onFocusTriggered when the input gains focus

Example:

<MollieCardNumberInput onChange={() => console.log('Card number updated')} />

πŸ” Security Considerations

  • Do NOT store raw card details.
  • Always use tokenized payments for PCI compliance.
  • Use HTTPS for secure data transmission.

Keywords

mollie

FAQs

Package last updated on 02 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts