Files
online.tbbank.gov.tm-larave…/app/Repos/Payment/Billing/HandlesBillingSyncing.php
2025-03-19 14:26:41 +05:00

69 lines
1.8 KiB
PHP

<?php
namespace App\Repos\Payment\Billing;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
trait HandlesBillingSyncing
{
/**
* Sync with billing
*/
public static function syncWithBilling(
string $uuid,
string $bank_code,
string $terminal_id,
string $account_number,
string $rrn,
string $amount,
string $pay_purpose,
) {
$body = sprintf('{
"ecomId": "%s",
"agentId": "%s",
"eposId": "%s",
"account": "%s",
"rnn": "%s",
"amount": "%s",
"payPurpose": "%s"
}',
$uuid,
$bank_code,
$terminal_id,
$account_number,
$rrn,
$amount,
$pay_purpose,
);
$request = new Request(
method: 'POST',
uri: 'http://10.3.158.102:8888/api/paytrn/new',
headers: [
'Content-Type' => 'application/json',
'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz',
],
body: $body
);
$client = new Client;
$response = $client->sendAsync($request)->wait();
// curl --location --request POST 'http://10.3.158.102:8888/api/paytrn/new' \
// --header 'Authorization: Basic YWRtaW46UUFad3N4MTIz' \
// --header 'Content-Type: application/json' \
// --data-raw '{
// "ecomId" : "0c406ee2-097d-42f7-86c8-18127bd87e10",
// "agentId" : "1307",
// "eposId" : "30400225",
// "account" : "4324234234",
// "rnn" : "002959773584",
// "amount" : 0.1,
// "payPurpose" : "Mart 2025"
// }'
return $response->getBody();
}
}