PHP code example of avto-dev / cloud-payments-laravel

1. Go to this page and download the library: Download avto-dev/cloud-payments-laravel 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/ */

    

avto-dev / cloud-payments-laravel example snippets


use AvtoDev\CloudPayments\Config;

$config = new Config('pk_some_key', 'some_api_key');

$request_builder = new \AvtoDev\CloudPayments\Requests\Payments\Cards\CardsAuthRequestBuilder;

/** @var $request_builder \AvtoDev\CloudPayments\Requests\AbstractRequestBuilder */

$request_builder->setAccountId('some_id');
$request_builder->setName('name');

/** @var \AvtoDev\CloudPayments\Requests\AbstractRequestBuilder $request_builder */
/** @var \Psr\Http\Message\RequestInterface $request */

$request = $request_builder->buildRequest();

$client = new \AvtoDev\CloudPayments\Client(
    new \GuzzleHttp\Client,
    new \AvtoDev\CloudPayments\Config('public_id', 'api_key')
);

/** @var \Psr\Http\Message\RequestInterface $request */
$response = $client->send($request);

/** @var \AvtoDev\CloudPayments\Config $config */

use AvtoDev\CloudPayments\Client;
use GuzzleHttp\Client as GuzzleClient;

$client = new Client(new GuzzleClient, $config);

$request = new \GuzzleHttp\Psr7\Request('POST','https://api',[],'{"foo":"bar"}');

/** @var \AvtoDev\CloudPayments\Client $client */
$response = $client->send($request);

'providers' => [
    // ...
    AvtoDev\CloudPayments\Frameworks\Laravel\ServiceProvider::class,
]

return [
    // ...
    /*
    |--------------------------------------------------------------------------
    | CloudPayments Settings
    |--------------------------------------------------------------------------
    | - `public_id` (string) - Public ID  (You can find it in personal area)
    | - `api_key`   (string) - API Secret (You can find it in personal area)
    |
    */
    'cloud_payments' => [
        'public_id' => env('CLOUD_PAYMENTS_PUBLIC_ID', 'some id'),
        'api_key'   => env('CLOUD_PAYMENTS_API_KEY', 'some api key'),
    ],
];