neyric/mangopay-bundle

MangoPay bundle for Symfony


Keywords
symfony, mangopay
License
MIT

Documentation

MangoPay Bundle for Symfony Build Status Latest Stable Version Total Downloads License

A Symfony bundle for MangoPay, providing additionnal services on top of the official MangoPay PHP SDK

  • Provide a service to access the API for a better Symfony integration
  • Add useful commands
  • Webhook handler (HTTP controller) + Webhook Event

Requirements

  • Php 7.1
  • Symfony 4.4

Installation

$ composer require neyric/mangopay-bundle

Load the bundle in your app

$bundles = [
    // ...
    new \Neyric\MangoPayBundle\NeyricMangoPayBundle(),
];

Configuration

The bundle (in particular the MangoPayService), expects those 3 environement variables to be defined

Commands

Display a list of installed hooks :

php bin/console neyric_mangopay:hooks:list

Display rate limits (performs 1 api call) :

php bin/console neyric_mangopay:ratelimits

Using the webhook handler

First, setup the route in your routes.yaml file :

neyric_mangopay:
    path: /mangopay_webook/hook_handler # Customizable url
    controller: Neyric\MangoPayBundle\Controller\HookController::hookHandlerAction

Then register the webhook, you want using the Mangopay console.

Create a subscriber

use Neyric\MangoPayBundle\Event\MangoPayHookEvent;

class MySubscriber implements EventSubscriberInterface
{
    
    public function onMangopayKycSucceeded(MangoPayHookEvent $event)
    {
        // ...
    }

    public function onMangopayUboDeclarationValidated(MangoPayHookEvent $event)
    {
        // ...
    }

    public static function getSubscribedEvents()
    {
        return [
            'MANGOPAY_KYC_SUCCEEDED' => ['onMangopayKycSucceeded', 1],
            'MANGOPAY_UBO_DECLARATION_VALIDATED' => ['onMangopayUboDeclarationValidated', 1],
        ];
    }
}

And eventually declare the service with the kernel.event_subscriber tag :

    App\Subscriber\MySubscriber:
        class: App\Subscriber\MySubscriber
        tags:
            - { name: kernel.event_subscriber }

License

neyric/mangopay-bundle is distributed under MIT license, see the LICENSE file.

Contacts

Report bugs or suggest features using issue tracker on GitHub.