assoconnect/smoney-client

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP client for S-Money API


README

PHP client for S-Money API.

Build Status Quality Gate Status

The following features of the S-Money API are implemented:

  • user creation and update
  • subaccount creation and update
  • bank account creation, update and delete
  • bank card registration creation
  • KYC request creation
  • you can also retrive SEPA payment or transfert payment

Feel free to submit a PR or contact us if you need a missing feature.

The package uses Guzzle as an HTTP client.

Installation

This package can be installed with composer

composer require assoconnect/smoney-client

Usage

This package provides several managers to handle the different S-Money features. They are self documented.

For instance, the following code creates a new User on S-Money:

$guzzle = GuzzleHttp\Client();
$client = new AssoConnect\SMoney\Client('YOUR S-MONEY ENDPOINT', 'YOUR S-MONEY TOKEN', $guzzle);

// Create a new User
$user = new AssoConnect\SMoney\Object\User([
    'appUserId' => 'appuserid-' . uniqid(),
    'type' => AssoConnect\SMoney\Object\User::TYPE_PROFESSIONAL_CLIENT,
    'profile' => new AssoConnect\SMoney\Object\UserProfile([
        'civility' => UserProfile::CIVILITY_MR,
        'firstname' => 'Test',
        'lastname' => 'McTestington',
        'birthdate' => new DateTime(),
        'address' => new AssoConnect\SMoney\Object\Address([
            'street' => 'rue du Test',
            'zipcode' => '75002',
            'city' => 'TestVille',
            'country' => 'FR',
        ]),
        'email' => 'test-' . uniqid() . '@test.com',
    ]),
    'company' => new AssoConnect\SMoney\Object\Company([
        'name' => 'CompanyName',
        'siret' => '123456789',
        'nafCode' => '4741Z',
    ])
]);

$userManager = new AssoConnect\SMoney\Manager\UserManager($client);
$userManager->createUser($userPro)->id; // S-Money's id of this newly created user

Main concepts

User and SubAccount

An S-Money User is the holder of an financial account maintained on S-Money servers. It can be a company or a person. Such a User is identified by two ids:

  • one generated by S-Money as an auto-incremented integer named "id"
  • one generated by the third party as a string named "app user id"

A default sub account is created for each User. It's app user id is the same as the parent User.

More sub accounts can be created by the third party.

When making a payment on S-Money (to/from outside or within S-Money)this default sub account is used for the sender and beneficiary unless stated otherwise.

Payment vs account top-up

For payment coming from outside of S-Money (bank transfer, card payment, ...), if the beneficiary is the same as the card holder (or bank account holder, ...) then this operation is not a payment but an account top-up.

S-Money used a boolean named isMine to set to true when the operation is indeed a top-up and to false when it is a payment.

Redirects and callbacks

When a person submits a form hosted by S-Money (card payment, mandate signature, ...), he is redirected to a confirmation page hosted by the third party. The URL of this page is named the "redirect URL" or "return URL".

As this web request may fail (is the user closes his browser too soon for instance), S-Money also sends another request to the third party server with a payload about the operation. The target URL of this request is named the "callback URL".

Processing of the operation by the third party is expected to be handled by the callback request while the return request is just for display and user information.