BoxLang 🚀 A New JVM Dynamic Language Learn More...
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.
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.
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'
);
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";
<!--- 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 />
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.
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
}
mollie-cfml currently covers these methods of the Mollie API v2:
| Mollie API | methods available | |
|---|---|---|
| Payments | createPayment() | |
| getPayment() | ||
| updatePayment() | ||
| cancelPayment() | ||
| listPayments() | ||
| Methods | listMethods() | |
| listAllMethods() | ||
| getMethod() | ||
| Refunds | createRefund() | |
| getRefund() | ||
| cancelRefund() | ||
| listRefunds() | ||
| listAllRefunds() | ||
| Chargebacks | getChargeback() | |
| listChargebacks() | ||
| listAllChargebacks() | ||
| Customers | createCustomer() | |
| getCustomer() | ||
| updateCustomer() | ||
| deleteCustomer() | ||
| listCustomers() | ||
| createCustomerPayment() | ||
| listCustomerPayments() | ||
| Mandates | createMandate() | |
| getMandate() | ||
| revokeMandate() | ||
| listMandates() | ||
| Subscriptions | createSubscription() | |
| getSubscription() | ||
| updateSubscription() | ||
| cancelSubscription() | ||
| listCustomerSubscriptions() | ||
| listAllSubscriptions() | ||
| listSubscriptionPayments() | ||
| Settlements | getSettlement() | |
| listSettlementPayments() | ||
| listSettlementRefunds() | ||
| listSettlementChargebacks() |
This project was inspired by stripecfml created by jcberquist.
$
box install molliecfml