1. Go to this page and download the library: Download freddiegar/declarations-api 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/ */
freddiegar / declarations-api example snippets
namespace App\Contracts\Incomes;
use PlacetoPay\DeclarationClient\Exceptions\DeclarationClientException;
use PlacetoPay\DeclarationClient\Models\Service;
class IncomeRequestService extends Service
{
public function __construct(array $options = [])
{
if (empty($options['url'])) {
throw new DeclarationClientException('Set url service');
}
if (empty($options['login'])) {
throw new DeclarationClientException('Set login service use');
}
if (empty($options['password'])) {
throw new DeclarationClientException('Set password service use');
}
if (empty($options['action'])) {
throw new DeclarationClientException('Set action execute in service');
}
if (empty($options['data'])) {
throw new DeclarationClientException('Set data to send');
}
$this->url($options['url'])
->login($options['login'])
->password($options['password'])
->action($options['action'])
->data($options['data']);
foreach (['url', 'login', 'password', 'action', 'data'] as $option) {
unset($options[$option]);
}
// Extra options @see PlacetoPay\DeclarationClient\Constants\Command;
// $options[] = Command::REQUEST;
// $options[] = Command::NO_CALL;
parent::__construct($options);
}
protected function setResponse($response = null, $escapeHtml = true, $append = true)
{
$this->response($response);
return $this;
}
}