FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

Mollie CFML

v0.5.5 Modules

mollie-cfml

mollie-cfml is a CFML library for interacting with the Mollie API v2. Mollie is a Payment Service Provider (PSP) focusing on the European market.

Installation

This wrapper can be installed as standalone library or as a ColdBox Module. Either approach requires a simple CommandBox command:

$ box install molliecfml

Alternatively the git repository can be cloned.

Standalone Usage

Once the library has been installed, the core mollie component can be instantiated directly:

mollie = new path.to.molliecfml.mollie(
    key = 'YOUR_MOLLIE_API_KEY',
    baseUrl = 'https://api.mollie.com/v2'
);

ColdBox Module

To use the library as a ColdBox Module, add the init arguments to the moduleSettings struct in config/Coldbox.cfc:

moduleSettings = {
    molliecfml: {
        key: 'YOUR_MOLLIE_API_KEY',
        baseUrl: 'https://api.mollie.com/v2'
    }
}

You can subsequently reference the library via the injection DSL: mollie@molliecfml:

property name="mollie" inject="mollie@molliecfml";

Getting Started

<!--- Create a payment and send the user to Mollie's checkout --->
<cfset paymentLink = mollie.createPayment(
        currency = "EUR",
        value = "20.00",
        description = "My Item",
        redirectUrl = "https://my.site.com/thankyou",
        webhookUrl = "https://my.site.com/mollie",
        method = "[sofort,giropay,creditcard,applepay,ideal,eps]",
        metadata = [ { "orderid": "ABC001" } ]
    ) />

<cflocation url=paymentLink.data._links.checkout.href addtoken=false />    

Configuration

The only required config parameter is your Mollie API key. mollie-cfml will happily accept both test and live keys. The baseUrl parameter is optional and defaults to https://api.mollie.com/v2.

Responses

Mollie's API returns JSON objects in response to all requests. mollie-cfml deserializes this response into a CFML struct and makes it available under the data key.

Responses to API calls are all returned as structs in the following format:

{
    data: {}                // struct containing the body of the response
    error: {}               // struct containing error messages received
    success: true|false    // boolean containing the overall result of the request
}

Methods Available

mollie-cfml currently covers these methods of the Mollie API v2:

Mollie APImethods available
PaymentscreatePayment()
getPayment()
updatePayment()
cancelPayment()
listPayments()
MethodslistMethods()
listAllMethods()
getMethod()
RefundscreateRefund()
getRefund()
cancelRefund()
listRefunds()
listAllRefunds()
ChargebacksgetChargeback()
listChargebacks()
listAllChargebacks()
CustomerscreateCustomer()
getCustomer()
updateCustomer()
deleteCustomer()
listCustomers()
createCustomerPayment()
listCustomerPayments()
MandatescreateMandate()
getMandate()
revokeMandate()
listMandates()
SubscriptionscreateSubscription()
getSubscription()
updateSubscription()
cancelSubscription()
listCustomerSubscriptions()
listAllSubscriptions()
listSubscriptionPayments()
SettlementsgetSettlement()
listSettlementPayments()
listSettlementRefunds()
listSettlementChargebacks()

Todo

  • Add ColdBox interceptors
  • Write more tests

Acknowledgements

This project was inspired by stripecfml created by jcberquist.

$ box install molliecfml

No collaborators yet.
   
  • {{ getFullDate("2022-10-14T14:38:33Z") }}
  • {{ getFullDate("2023-02-24T09:39:30Z") }}
  • 820
  • 127