gurl_o/plugins/tps/birzha/classes/Payment.php

39 lines
1.3 KiB
PHP

<?php namespace TPS\Birzha\Classes;
use October\Rain\Network\Http;
abstract class Payment
{
abstract protected function getApiCredentials();
abstract protected function getApiUrl();
abstract protected function getRegistrationUri();
abstract protected function getStatusUri();
abstract protected function registerOrderParams($payment, $url);
abstract public function checkRegisterOrderErrorCode($registerOrderResponse);
abstract public function checkReturnUrlParams($returnUrlParams, $payment);
abstract public function checkOrderStatusResponseCodes($orderStatusResponse);
private function getClient($url){
return Http::make($this->getApiUrl() . $url, Http::METHOD_POST)
->data($this->getApiCredentials())
->timeout(3600);
}
public function registerOrder($payment, $url) {
$client = $this->getClient($this->getRegistrationUri());
$client->data($this->registerOrderParams($payment, $url));
$client->setOption(CURLOPT_POSTFIELDS,$client->getRequestData());
return $client->send();
}
public function getStatus($order_id) {
$client = $this->getClient($this->getStatusUri());
$client->data([
'orderId' => $order_id
]);
return $client->send();
}
}