Package Data | |
---|---|
Maintainer Username: | restoore |
Maintainer Contact: | florian.congre@gmail.com (Florian Congre) |
Package Create Date: | 2016-03-02 |
Package Last Update: | 2019-03-08 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:00:56 |
Package Statistics | |
---|---|
Total Downloads: | 10,107 |
Monthly Downloads: | 11 |
Daily Downloads: | 3 |
Total Stars: | 5 |
Total Watchers: | 3 |
Total Forks: | 6 |
Total Open Issues: | 1 |
The library provides an easy and fast systempay form creation. She helps to instanciate all required parameters and create the form to access to payment interface. To know required parameters, go to https://systempay.cyberpluspaiement.com/html/documentation.html
First you need to add the component to your composer.json
composer require restoore/laravel-systempay
Update your packages with composer update or install with composer install. Execute php artisan vendor:publish --provider="Restoore\Systempay\SystempayServiceProvider" command to copy systempay.php configuration file in your environment
After updating composer, add the ServiceProvider to the providers array in config/app.php
'providers' => [
...
Restoore\Systempay\SystempayServiceProvider::class,
]
'providers' => [
...
Restoore\Systempay\SystempayServiceProvider,
]
It's automatic, thanks to xmoroccan for this update
By default, the package comes with an example configuration file : config/systempay.php
return [
'YOUR_SITE_ID' => [
'key' => 'YOUR_KEY',
'env' => 'PRODUCTION',
'params' => [
//Put here your generals payment call parameters
'vads_page_action' => 'PAYMENT',
'vads_action_mode' => 'INTERACTIVE',
'vads_payment_config' => 'SINGLE',
'vads_page_action' => 'PAYMENT',
'vads_version' => 'V2',
'vads_currency' => '978'
]
],
//Systempay's url
'url' => 'https://paiement.systempay.fr/vads-payment/',
];
In this file, you have to put your site_id and your key. This two parameters are given by Systempay. As you can see, you can create a configuration array to several shops. In this array, you can also put generals parameters of your transaction.
If you are running your app in a test environment, you can override key and env parameters using .env file
Use this following constants names : SYSTEMPAY_<SITE_ID>KEY and SYSTEMPAY<SITE_ID>_ENV
Now we are finally ready to use the package! Here is a little example of code to explain how does it work
//create a Systempay object class with your site id in parameter. Note that it will automatically get your configuration in config/systempay.php
$systempay = App::make('systempay', ['site_id' => '11111']);
//add some parameters
$systempay->set_amount(1500)
->set_trans_id(1112441)
->set_order_info2('New customer !');
//create the signature
$systempay->set_signature();
//create html systempay call form
$payment_form = $systempay->get_form('<button class="btn btn-lg btn-primary btn-payment" type="submit">Valider et payer</button>');
Add a product to the order
array $product , must have the following keys : 'label,amount,type,ref,qty
$systempay = App::make('systempay', ['site_id' => '11111']);
$systempay->add_product(
[
'label' => 'Concert Coldplay 2016',
'amount' => 235.00,
'type' => 'ENTERTAINMENT',
'ref' => 'COLD016',
'qty' => 3
]
);
Note : the amount of each products price must not be multiplied by 100
Defines the total amount of the order. If you doesn't give the amount in parameter, it will be automaticly calculated by the sum of products you've got in your basket.
[optional] int $amount, systempay format. ex : for a product with a price of 150€, give 15000
$systempay = App::make('systempay', ['site_id' => '11111']);
$systempay->add_product(
[
'label' => 'Concert Coldplay 2016',
'amount' => 235.00,
'type' => 'ENTERTAINMENT',
'ref' => 'COLD016',
'qty' => 3
]
);
$systempay->set_amount();
echo $systempay->get_amount(); //will display 705.00 (3*235.00)
Get total amount of the order
[optional] bool $decimal if true, you get a decimal otherwise you get standard systempay amount format (int). Default value is true.
$systempay = App::make('systempay', ['site_id' => '11111']);
$systempay->add_product(
[
'label' => 'Concert Coldplay 2016',
'amount' => 235.00,
'type' => 'ENTERTAINMENT',
'ref' => 'COLD016',
'qty' => 3
]
);
$systempay->set_amount();
echo $systempay->get_amount(); //will display 705.00 (3*235.00)
echo $systempay->get_amount(false); //will display 70500 (3*235.00)
Method to do massive assignement of parameters
array $params associative array of systempay parameters
$systempay = App::make('systempay', ['site_id' => '11111']);
$systempay->set_params(
[
'vads_page_action' => 'PAYMENT',
'vads_action_mode' => 'INTERACTIVE',
'vads_payment_config' => 'SINGLE',
'vads_page_action' => 'PAYMENT',
'vads_version' => 'V2',
'vads_trans_date' => gmdate('YmdHis'),
'vads_currency' => '978'
]
);