2017 © Pedro Peláez
 

library smoney

Smoney client

image

spyrit/smoney

Smoney client

  • Friday, March 9, 2018
  • by Spyrit_SI
  • Repository
  • 5 Watchers
  • 1 Stars
  • 907 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 3 Versions
  • 9 % Grown

The README.md

S-Money library

Installation

composer install

Usage

The S-Money API can be consumed using REST services., (*1)

Architecture

This library provides an implementation for these services, based on GuzzleHttp and JMS Serializer. In order to consume a webservice, one must first create a client object and a resource facade containing the data to send to the API., (*2)

Each client will return an updated facade object with the data returned by the webserice., (*3)

Configuration

A client must be provided with the API url, your secret token and the version of the API to use (see the official documentation in order to determine the correct version for each webservice)., (*4)

The version can be defined in the constructor and optionnaly overridden using the setVersion method:, (*5)

$client->setVersion('v1');

Examples

User

$token = '<secret_token>';
$version = 'v1';
$userClient = new UserClient(
    'https://rest-pp.s-money.fr/api/sandbox',
    $token,
    $version,
    new GuzzleHttp\Client(),
    JMS\Serializer\SerializerBuilder::create()->build()
);

Create Simple User

To create simple user and its attributes:, (*6)

$user = new UserFacade();
$user->appUserId = 'ALFRED';

/* Then, more complex attributes */

/* profile attribute */
$user->profile = new UserProfileFacade();
$user->profile->firstName = 'toto';
$user->profile->lastName = 'foo';
$user->profile->birthdate = new DateTime('1989-08-02T00:00:00', new DateTimeZone('Europe/Paris'));

/* address attribute which is UserFacade::$profile attribute */
$user->profile->address = new AddressFacade();
$user->profile->address->country = 'US';

/* Then we POST the $user */
$userClient->create($user);

Business User

You only need to set the type attribute of the 'UserFacade' to 2 and the set company attribute with name and siret:, (*7)

$user = new UserFacade();
//...
$user->type = 2;
$user->company = new CompanyFacade();
$user->company->name = 'HELLO LTD';
$user->company->siret = 'XXXXXXXX';

$userClient->create($user);

CardPayment

$cardPaymentClient = new CardPaymentClient(
    'https://rest-pp.s-money.fr/api/sandbox',
    $token,
    $version,
    new Client(),
    SerializerBuilder::create()->build()
);

Simple Payment

$cardPayment = new CardPaymentFacade();

$cardPayment->urlReturn = 'http://callback_after_payment.com';
$cardPayment->amount = 2;
$cardPayment->beneficiary = new SubAccountRefFacade();
$cardPayment->beneficiary->appAccountId = 'client-112';

$cardPaymentClient->create($appUserId, $cardPayment);

Multiple beneficiaries

Use API v2 for this service., (*8)

$cardPayment = new CardPaymentFacade();
$cardPayment->urlReturn = 'http://callback_after_payment.com';
$cardPayment->payments = new ArrayCollection();

$first = new PaymentFacade();
$first->beneficiary = new subAccountFacade();
$first->beneficiary->appAccountId = 'ALFRED';
$first->amount = 1500; // 15€ (amount in cents)

$cardPayment->payments->add($first);

$second = new PaymentFacade;
//...
$cardPayment->payments->add($second);

$cardPaymentClient->create($cardPayment);

Get one CardPayment by id

$cardPaymentClient->get($orderId);

List all CardPayments

$cardPaymentClient->index();

Payout

$payoutClient = new PayoutClient(
    'https://rest-pp.s-money.fr/api/sandbox',
    $token,
    $version,
    new Client(),
    SerializerBuilder::create()->build()
);

Create Payout

$payout = new PayoutFacade();
$payout->orderId = 'hello';
$payout->amount = 99;
$payout->bankAccount = new BankAccountFacade;
$payout->bankAccount->id = 25923;

$payoutClient->create('<appUserId>', $payout);

Payment

$paymentClient = new PaymentClient(
    'https://rest-pp.s-money.fr/api/sandbox',
    $token,
    $version,
    new Client(),
    SerializerBuilder::create()->build()
);

Create Payment

$payment = new PaymentFacade();
$payment->beneficiary = new SubAccountRefFacade();
$payment->beneficiary->appAccountId = 'YOUR PAL';
$payment->sender = new SubAccountRefFacade();
$payment->sender->appAccountId = 'ALFRED';
$payment->amount = 99;

$paymentClient->create('<appUserId>', $payment);

The Versions

09/03 2018

dev-symfony-3

dev-symfony-3 http://www.s-money.fr

Smoney client

  Sources   Download

MIT

The Requires

 

by Avatar sherlockode

09/03 2018

dev-symfony3

dev-symfony3 http://www.s-money.fr

Smoney client

  Sources   Download

MIT

The Requires

 

by Avatar sherlockode

11/01 2018

dev-master

9999999-dev http://www.s-money.fr

Smoney client

  Sources   Download

MIT

The Requires

 

by Avatar sherlockode