stan errors fixed
This commit is contained in:
@@ -247,3 +247,19 @@ function indexByValue(mixed $value, array $array): ?int
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert db type to php type
|
||||
*/
|
||||
function dbTypeToPhp(string $type): string
|
||||
{
|
||||
return match ($type) {
|
||||
'bigint' => 'int',
|
||||
'varchar' => 'string',
|
||||
'boolean' => 'bool',
|
||||
'timestamp(0) without time zone' => 'string',
|
||||
'json' => 'string',
|
||||
'jsonb' => 'string',
|
||||
default => 'string',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,26 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property null|string $address
|
||||
* @property null|string $unique_code
|
||||
* @property string $region
|
||||
* @property null|int $province_id
|
||||
* @property null|string $billing_username
|
||||
* @property null|string $billing_password
|
||||
* @property null|string $phone_numbers
|
||||
* @property bool $active
|
||||
* @property null|string $created_at
|
||||
* @property null|string $updated_at
|
||||
* @property null|string $billing_swift_username
|
||||
* @property null|string $billing_swift_password
|
||||
* @property null|string $billing_visa_master_username
|
||||
* @property null|string $billing_visa_master_password
|
||||
* @property null|string $billing_sber_username
|
||||
* @property null|string $billing_sber_password
|
||||
*/
|
||||
class Branch extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -256,11 +256,15 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
/**
|
||||
* Create payment record
|
||||
*
|
||||
* @param $payment
|
||||
* @param array<string, string> $payment
|
||||
* @param $resource
|
||||
*/
|
||||
public function createPaymentRecord($payment, $resource, $total_amount, $usd_payment)
|
||||
{
|
||||
public function createPaymentRecord(
|
||||
array $payment,
|
||||
VisaMasterPaymentOrder $resource,
|
||||
int|float|string $total_amount,
|
||||
int|float|string $usd_payment
|
||||
): void {
|
||||
VisaMasterPaymentOrderItem::create([
|
||||
'visa_master_payment_order_id' => $resource->id,
|
||||
'online_payment_history_id' => $payment['online_payment_history_id'],
|
||||
@@ -270,7 +274,12 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
]);
|
||||
}
|
||||
|
||||
public function canAcceptPayment($today)
|
||||
/**
|
||||
* Can payment be accepted?
|
||||
*
|
||||
* @param \Illuminate\Support\Carbon $today
|
||||
*/
|
||||
public function canAcceptPayment(\Illuminate\Support\Carbon $today): bool
|
||||
{
|
||||
$year = $today->format('Y');
|
||||
$month = $today->format('m');
|
||||
|
||||
@@ -36,6 +36,9 @@ class MakeSberPaymentAction extends Action
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param ActionFields $fields
|
||||
* @param Collection<array-key, \App\Modules\SberPaymentOrder\Models\SberPaymentOrder> $models
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models): mixed
|
||||
{
|
||||
@@ -102,7 +105,7 @@ class MakeSberPaymentAction extends Action
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
@@ -193,8 +196,10 @@ class MakeSberPaymentAction extends Action
|
||||
|
||||
/**
|
||||
* Order a payment page
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function order($resource, $amount)
|
||||
public function order(SberPaymentOrder $resource, int|float|string $amount): array
|
||||
{
|
||||
$onlinePaymentRepo = OnlinePaymentRepo::make();
|
||||
|
||||
@@ -256,11 +261,14 @@ class MakeSberPaymentAction extends Action
|
||||
/**
|
||||
* Create payment record
|
||||
*
|
||||
* @param $payment
|
||||
* @param $resource
|
||||
* @param array<string, string> $payment
|
||||
*/
|
||||
public function createPaymentRecord($payment, $resource, $total_amount, $usd_payment)
|
||||
{
|
||||
public function createPaymentRecord(
|
||||
array $payment,
|
||||
SberPaymentOrder $resource,
|
||||
int|float|string $total_amount,
|
||||
int|float|string $usd_payment
|
||||
): void {
|
||||
SberPaymentOrderItem::create([
|
||||
'sber_payment_order_id' => $resource->id,
|
||||
'online_payment_history_id' => $payment['online_payment_history_id'],
|
||||
@@ -270,7 +278,12 @@ class MakeSberPaymentAction extends Action
|
||||
]);
|
||||
}
|
||||
|
||||
public function canAcceptPayment($today)
|
||||
/**
|
||||
* Can payment be accepted?
|
||||
*
|
||||
* @param \Illuminate\Support\Carbon $today
|
||||
*/
|
||||
public function canAcceptPayment($today): bool
|
||||
{
|
||||
$year = $today->format('Y');
|
||||
$month = $today->format('m');
|
||||
|
||||
@@ -4,43 +4,46 @@ namespace App\Repos\Payment\Billing;
|
||||
|
||||
trait HandlesBillingSyncing
|
||||
{
|
||||
public static function syncWithBilling()
|
||||
{
|
||||
$curl = curl_init();
|
||||
/**
|
||||
* Sync with billing
|
||||
*/
|
||||
// public static function syncWithBilling(): bool|string
|
||||
// {
|
||||
// $curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf(
|
||||
'{
|
||||
"ecomId" : "%s",
|
||||
"agentId" : "%s",
|
||||
"eposId" : "30401238",
|
||||
"account" : "130420912769753",
|
||||
"rnn" : "110784016238",
|
||||
"amount" : 895.46,
|
||||
"payPurpose" : "Mart 2025"
|
||||
}',
|
||||
// $uuid,
|
||||
// $bankCode,
|
||||
// curl_setopt_array($curl, [
|
||||
// CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
// CURLOPT_RETURNTRANSFER => true,
|
||||
// CURLOPT_ENCODING => '',
|
||||
// CURLOPT_MAXREDIRS => 10,
|
||||
// CURLOPT_TIMEOUT => 0,
|
||||
// CURLOPT_FOLLOWLOCATION => true,
|
||||
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
// CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
// CURLOPT_POSTFIELDS => sprintf(
|
||||
// '{
|
||||
// "ecomId" : "%s",
|
||||
// "agentId" : "%s",
|
||||
// "eposId" : "30401238",
|
||||
// "account" : "130420912769753",
|
||||
// "rnn" : "110784016238",
|
||||
// "amount" : 895.46,
|
||||
// "payPurpose" : "Mart 2025"
|
||||
// }',
|
||||
// // $uuid,
|
||||
// // $bankCode,
|
||||
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
// ),
|
||||
// CURLOPT_HTTPHEADER => [
|
||||
// 'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
// 'Content-Type: application/json',
|
||||
// ],
|
||||
// ]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
// $response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
// curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
// return $response;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Repos\Payment;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Repos\Payment\Billing\HandlesBillingSyncing;
|
||||
use App\Repos\Payment\Card\HandlesCardOrderPayments;
|
||||
use App\Repos\Payment\Sber\HandlesSberPeyments;
|
||||
use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -38,7 +40,7 @@ class OnlinePaymentRepo
|
||||
/**
|
||||
* Status Values
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @return array<null|string, string>
|
||||
*/
|
||||
public static function statusValues(): array
|
||||
{
|
||||
@@ -187,8 +189,12 @@ class OnlinePaymentRepo
|
||||
*
|
||||
* @return array<string, bool|string>
|
||||
*/
|
||||
public static function successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL): array
|
||||
{
|
||||
public static function successfulPaymentResponse(
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
): array {
|
||||
return [
|
||||
'success' => true,
|
||||
'title' => __('Payment is successful'),
|
||||
@@ -201,9 +207,15 @@ class OnlinePaymentRepo
|
||||
|
||||
/**
|
||||
* Failed payment response
|
||||
*
|
||||
* @return array<string, bool|string>
|
||||
*/
|
||||
public static function failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL)
|
||||
{
|
||||
public static function failedPaymentResponse(
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
): array {
|
||||
return [
|
||||
'success' => false,
|
||||
'title' => __('Payment has failed'),
|
||||
@@ -216,6 +228,8 @@ class OnlinePaymentRepo
|
||||
|
||||
/**
|
||||
* Resource not found
|
||||
*
|
||||
* @return array<string, string|bool>
|
||||
*/
|
||||
protected static function resourceNotFound(): array
|
||||
{
|
||||
|
||||
@@ -5,4 +5,9 @@
|
||||
**completed**
|
||||
**cancelled**
|
||||
|
||||
Schema::getColumnListing('loan_order_required_docs')
|
||||
Schema::getColumnListing('branches')
|
||||
|
||||
$a = collect(Schema::getColumns('branches'))->map(fn ($column) => [
|
||||
'name' => $column['name'],
|
||||
'type' => ($column['nullable'] ? 'null|' : '') . dbTypeToPhp($column['type']),
|
||||
])->pluck('type', 'name')
|
||||
|
||||
Reference in New Issue
Block a user