Giter VIP home page Giter VIP logo

mollie-api-php's Introduction

Mollie

Mollie API client for PHP

Accepting iDEAL, Bancontact/Mister Cash, SOFORT Banking, Creditcard, SEPA Bank transfer, SEPA Direct debit, Bitcoin, PayPal, Belfius Direct Net, KBC/CBC and paysafecard online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.

Build Status Latest Stable Version Total Downloads

Requirements

To use the Mollie API client, the following things are required:

  • Get yourself a free Mollie account. No sign up costs.
  • Create a new Website profile to generate API keys (live and test mode) and setup your webhook.
  • Now you're ready to use the Mollie API client in test mode.
  • In order to accept payments in live mode, payment methods must be activated in your account. Follow a few of steps, and let us handle the rest.
  • PHP >= 5.3
  • PHP cURL extension
  • Up-to-date OpenSSL (or other SSL/TLS toolkit)
  • SSL v3 disabled. Mollie does not support SSL v3 anymore.

Installation

By far the easiest way to install the Mollie API client is to require it with Composer.

$ composer require mollie/mollie-api-php:1.9.*

{
    "require": {
        "mollie/mollie-api-php": "1.9.*"
    }
}

You may also git checkout or download all the files, and include the Mollie API client manually.

How to receive payments

To successfully receive a payment, these steps should be implemented:

  1. Use the Mollie API client to create a payment with the requested amount, description and optionally, a payment method. It is important to specify a unique redirect URL where the customer is supposed to return to after the payment is completed.

  2. Immediately after the payment is completed, our platform will send an asynchronous request to the configured webhook to allow the payment details to be retrieved, so you know when exactly to start processing the customer's order.

  3. The customer returns, and should be satisfied to see that the order was paid and is now being processed.

Getting started

Requiring the included autoloader. If you're using Composer, you can skip this step.

require "Mollie/API/Autoloader.php";

Initializing the Mollie API client, and setting your API key.

$mollie = new Mollie_API_Client;
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");

Creating a new payment.

$payment = $mollie->payments->create(array(
    "amount"      => 10.00,
    "description" => "My first API payment",
    "redirectUrl" => "https://webshop.example.org/order/12345/",
    "webhookUrl"  => "https://webshop.example.org/mollie-webhook/",
));

After creation, the payment id is available in the $payment->id property. You should store this id with your order.

Retrieving a payment.

$payment = $mollie->payments->get($payment->id);

if ($payment->isPaid())
{
    echo "Payment received.";
}

Fully integrated iDEAL payments

If you want to fully integrate iDEAL payments in your web site, some additional steps are required. First, you need to retrieve the list of issuers (banks) that support iDEAL and have your customer pick the issuer he/she wants to use for the payment.

Retrieve the list of issuers:

$issuers = $mollie->issuers->all();

$issuers will be a list of Mollie_API_Object_Issuer objects. Use the property $id of this object in the API call, and the property $name for displaying the issuer to your customer. For a more in-depth example, see Example 4.

Create a payment with the selected issuer:

$payment = $mollie->payments->create(array(
    "amount"      => 10.00,
    "description" => "My first API payment",
    "redirectUrl" => "https://webshop.example.org/order/12345/",
    "webhookUrl"  => "https://webshop.example.org/mollie-webhook/",
    "method"      => Mollie_API_Object_Method::IDEAL,
    "issuer"      => $selected_issuer_id, // e.g. "ideal_INGBNL2A"
));

The links property of the $payment object will contain a string paymentUrl, which is a URL that points directly to the online banking environment of the selected issuer.

Refunding payments

The API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and definitive. Refunds are only supported for iDEAL, credit card, Bancontact/Mister Cash, SOFORT Banking, PayPal, Belfius Direct Net and bank transfer payments. Other types of payments cannot be refunded through our API at the moment.

$payment = $mollie->payments->get($payment->id);

// Refund € 15 of this payment
$refund = $mollie->payments->refund($payment, 15.00);

How to use OAuth2 to connect Mollie accounts to your application?

The resources permissions, organizations, refunds, profiles, settlements and invoices are only available with an OAuth2 access token. This is because an API key is linked to a website profile, and those resources are linked to an Mollie account. Visit our API documentation for more information about how to get an OAuth2 access token. For an example of how to use those resources, see Example 8, Example 9 and Example 10.

API documentation

If you wish to learn more about our API, please visit the Mollie Developer Portal. API Documentation is available in both Dutch and English.

Want to help us make our API client even better?

Want to help us make our API client even better? We take pull requests, sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. Check out our vacancies or get in touch.

License

BSD (Berkeley Software Distribution) License. Copyright (c) 2013-2017, Mollie B.V.

Support

Contact: www.mollie.com[email protected] — +31 20 820 20 70

mollie-api-php's People

Contributors

adriaanmol avatar companjo avatar dmvdbrugge avatar faapz avatar holtkamp avatar it-can avatar jesperveldhuizen avatar juukie avatar kloentje2 avatar lvgunst avatar mollierobbert avatar ndijkstra avatar perryz avatar ricardoj avatar rickwong avatar robin-mollie avatar smitsel avatar stefandoorn avatar teunvink avatar thijs-riezebeek avatar timvdalen avatar tom-mollie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.