PHP code example of fitnesshouse / payment-manager

1. Go to this page and download the library: Download fitnesshouse/payment-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fitnesshouse / payment-manager example snippets


// \config\payment.php
return [
    'system' => env('PAYMENT_SYSTEM', 'pscb'),
    
    /*
     * Настройки для ПСКБ
     * https://docs.pscb.ru/oos/index.html
     */
    'pscb' => [
        ...
    ]
]

use \Fh\PaymentManager\Facades\Payment;

// Платежная система по умолчанию
$system = Payment::system();

// Платежная система не установленная по умолчанию
$system = Payment::system('pscb');

// Создать запрос и перенаправить клиента в платежную систему для оплаты
$query = $system->createQuery(function (QueryBuilder $builder) {
    $builder->orderId('TEST_123');
    $builder->amount(100.00);
    // ... Другие параметры запроса
});
redirect($query->getPayUrl())

// Запросить параметры платежа
$request = $system->requestHandler()->create('checkPayment', ['orderId' => 'TEST_123'])
$response = $request->send();

use \Fh\PaymentManager\Facades\Payment;

$query = Payment::query()->create(function (QueryBuilder $builder) {
    $builder->orderId('TEST_123');
    $builder->amount(100.00);
    $builder->description('Тестовый платеж');
    $builder->customer([
        'phone' => '+7(123)-456-78-90',
        'email' => '[email protected]'
    ]);
    $builder->successUrl('https://youmarket.com/success');
    $builder->paymentMethod('ac');
});

use \Fh\PaymentManager\Facades\Payment;

$query = Payment::system('pscb')->createQuery(function (QueryBuilder $builder) {
    $builder->orderId('TEST_123');
    $builder->amount(100.00);
    ...
});

$payUrl = $query->getPayUrl();
redirect($payUrl);

use \Fh\PaymentManager\Facades\Payment;

$requestHandler = Payment::requestHandler()->create('checkPayment', ['orderId' => 'TEST_123']);

use \Fh\PaymentManager\Facades\Payment;

$requestHandler = Payment::system('pscb')->requestHandler()
                        ->create('checkPayment', ['orderId' => 'TEST_123']);

$response = $requestHandler->send();
bash
$ php artisan vendor:publish --tag=payment-config
\config\payment.php