2017 © Pedro Peláez
 

symfony-bundle mangopay-bundle

A set of Symfony services for use in your project in integrate with MangoPay API faster.

image

partfire/mangopay-bundle

A set of Symfony services for use in your project in integrate with MangoPay API faster.

  • Thursday, April 13, 2017
  • by carlamo
  • Repository
  • 2 Watchers
  • 1 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 26 % Grown

The README.md

MangoPay Bundle for Symfony

Build Status Scrutinizer Code Quality Packagist SensioLabsInsight Twitter Follow, (*1)

A set of Symfony services for use in your project to ease integration with Mangopay API., (*2)

This bundle depends upon the official Mangopay SDK PHP for Mangopay API v2. This means that this bundle only supports Mangopay API version v2.01 but not the earlier versions. Please check which version you are using., (*3)

Installation

Using composer you can simply require master for now until we have a stable release:, (*4)

$ composer require partfire/mangopay-bundle:dev-master

Configuration

Add your details to your app/config/parameters.yml file. For example:, (*5)

    mangopay_client_id: my_mango_id
    mangopay_client_password: XXXXXXXXXXXXXXXXXXXXXX
    mangopay_base_url: 'https://api.sandbox.mangopay.com'

Also add to your app/AppKernel.php file:, (*6)

    new PartFire\MangoPayBundle\PartFireMangoPayBundle()

Example Usage

Users

Create a user

    $userService = $this->container->get('part_fire_mango_pay.services.user');

    $userDto = new \PartFire\MangoPayBundle\Models\DTOs\User();
    $userDto->setFirstName('Dick');
    $userDto->setLastName('Jones');
    $userDto->setBirthday(new \DateTime());
    $userDto->setEmail('dick.jones@test.com');
    $userDto->setNationality('GB');
    $userDto->setCountryOfResidence('GB');

    $userDtoUpdated = $userService->create($userDto);

    if ($userDtoUpdated instanceof \PartFire\MangoPayBundle\Models\DTOs\User) {
        $userDtoUpdated->getId(); //The users MangoPay ID, DTO fully populated.
    }

    if ($userDtoUpdated instanceof \PartFire\MangoPayBundle\Models\Exception) {
        //an error you can deal with
    }
 ```

### Wallets

#### Create a wallet

```php
    $walletService = $this->container->get('part_fire_mango_pay.services.wallet');

    $walletDto = new \PartFire\MangoPayBundle\Models\DTOs\Wallet();
    $walletDto->setTag('TAG1');
    $walletDto->setOwenerId('123456');
    //$walletDto->setOwenerIds(['123456']);
    $walletDto->setDescription('A natural users wallet');
    $walletDto->setCurrency('GBP');

    $walletDtoUpdated = $walletService->create($walletDto);

    if ($walletDtoUpdated instanceof \PartFire\MangoPayBundle\Models\DTOs\Wallet) {
        $walletDtoUpdated->getId(); //The wallet DTO populated with MangoPay ID.
    }

    if ($walletDtoUpdated instanceof \PartFire\MangoPayBundle\Models\Exception) {
        //an error you can deal with
    }

Service List

part_fire_mango_pay.services.user
part_fire_mango_pay.services.wallet
part_fire_mango_pay.services.kyc
part_fire_mango_pay.services.transfer

Code Structure Explanation

In the 'Services' directory are the services that should be used my your client code. These services depend upon interfaces which are located inside the 'Models' directory. We then have an implementation of these abstractions in the 'Models/Adapters' directory. This means our services depend upon our abstractions, while the adapters also depend upon our abstractions., (*7)

The objects passed into the services and then adapters are simple DTOs (data type objects). These are just keys and values with setters and getters. We pass these in and out of the adapters so that none of our services / client code is dependant upon the MangoPay SDK., (*8)

Contributing

Feel free to add more methods to the services etc and create a pull request. I will merge them in if they follow the existing structure or you teach me a better way., (*9)

The Versions

13/04 2017

dev-master

9999999-dev

A set of Symfony services for use in your project in integrate with MangoPay API faster.

  Sources   Download

MIT

The Requires

 

The Development Requires