File: /var/www/vhost/disk-apps/alq-cali.bikenow.co/app/Core/Payment/Methods/Onepay/OnepayClient.php
<?php
declare(strict_types=1);
namespace App\Core\Payment\Methods\Onepay;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
class OnepayClient
{
private $parameters;
private $client;
public function __construct($parameters)
{
$this->parameters = $parameters;
$this->client = new Client([
'base_uri' => $this->parameters->is_productive ? $this->parameters->gw_url_prd : $this->parameters->gw_url_sandbox
]);
}
public function createPayment($paymentIntent)
{
$response = $this->client->post(
'payments',
[
'headers' => [
'Authorization' => 'Bearer ' . $this->parameters->client_secret,
'x-idempotency' => time()
],
RequestOptions::JSON => $paymentIntent
]
);
return json_decode($response->getBody()->getContents());
}
public function retrieve($payment)
{
$response = $this->client->get(
'payments/' . $payment->paymentGatewayTxId(),
[
'headers' => [
'Authorization' => 'Bearer ' . $this->parameters->client_secret
]
]
);
return json_decode($response->getBody()->getContents());
}
}