Working on credit card

This commit is contained in:
2024-01-28 19:54:29 +05:00
parent 0a631aec80
commit 9c22cce13b
11 changed files with 267 additions and 22 deletions

View File

@@ -3,28 +3,71 @@
namespace App\Repos\Payment;
use App\Models\Payment\ApiKeyHalkbank;
use App\Models\Payment\OnlinePaymentHistory;
use App\Repos\Order\OrderRepo;
use Exception;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class OnlinePaymentRepo
{
public function payCardOrder($resource): string
/**
* Pay card order
* @param [type] $resource
*/
public function payCardOrder($resource): array
{
$orderNumber = $this->generateOrderNumber($resource);
$response = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
try {
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber,
'amount' => "00" . $resource->priceAmount(),
'currency' => 934,
'language' => 'ru',
'userName' => $resource->branch->billing_username,
'password' => $resource->branch->billing_password,
'returnUrl' => urlencode(route('online-payment-store')),
'pageView' => 'DESKTOP',
'description' => urlencode('Kart tölegi'),
]);
} catch(Exception $exception) {
Log::channel('halkbank_payment_error')->error('Payment error', [
'response' => [
'body' => $paymentResponse->body(),
],
'exception' => [
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'message' => $exception->getMessage(),
]
]);
return [
'status' => 'success',
'url' => ''
];
}
OnlinePaymentHistory::create([
'online_paymantable_id' => $resource->id,
'online_paymantable_type' => $resource::$model,
'amount' => $resource->priceAmount(),
'orderNumber' => $orderNumber,
'amount' => $booking->total_price.'00',
'currency' => 934,
'language' => 'ru',
'userName' => 301161000067,
'password' => 'E3vb2SR3dgTPdff',
'returnUrl' => route('online-payment-store'),
'failUrl' => route('online-payment-store'),
'pageView' => 'DESKTOP',
'description' => 'Sargyt',
'description' => 'Kart tölegi',
'orderId' => $paymentResponse['orderId'],
'formUrl' => $paymentResponse['formUrl'],
'successUrl' => route('online-payment-store'),
'errorUrl' => route('online-payment-store'),
'api_client' => config('app.url'),
'username' => $resource->branch->billing_username,
'paymentStatus' => OrderRepo::PENDING
]);
return 'a';
return [
'status' => 'success',
'url' => $paymentResponse['formUrl']
];
}
/**