fix: improve where clause while fetch aggregator rates during fees calculation
This commit is contained in:
parent
81796c15bb
commit
b32efe96e1
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
|
||||||
|
abstract class PaymentMethod
|
||||||
|
{
|
||||||
|
const CARD = 'CARD'; // Les remboursements ou recharges vers des clients
|
||||||
|
const WALLET = 'WALLET'; // Les paiements effectués par les clients
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Enums\PaymentMethod;
|
||||||
use App\Enums\PaymentTransactionStatus;
|
use App\Enums\PaymentTransactionStatus;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\PaymentAggregator;
|
use App\Models\PaymentAggregator;
|
||||||
|
@ -170,19 +171,24 @@ class PaymentController extends Controller
|
||||||
$countryCode = $country->code_country;
|
$countryCode = $country->code_country;
|
||||||
|
|
||||||
|
|
||||||
if($paymentMethod == 'CARD'){
|
if($paymentMethod == PaymentMethod::CARD){
|
||||||
$aggregator = PaymentAggregator::where('name','like','%stripe%')->first();
|
$aggregator = PaymentAggregator::where('name','like','%stripe%')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($paymentMethod == 'WALLET'){
|
if($paymentMethod == PaymentMethod::WALLET){
|
||||||
$aggregator = PaymentAggregator::where('status',1)->first();
|
$aggregator = PaymentAggregator::where('status',1)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($aggregator)){
|
if(!empty($aggregator)){
|
||||||
$rate = $aggregator->rates()->where('country', $countryCode)->orWhere('country','ALL')->where('type', $paymentType)
|
$rate = $aggregator->rates()->where(function ($q) use($countryCode) {
|
||||||
->where('method', $paymentMethod)->when($paymentChannel, function ($q) use($paymentChannel){
|
return $q->where('country', $countryCode)->orWhere('country','ALL');
|
||||||
|
})->where('type', $paymentType)
|
||||||
|
->where('method', $paymentMethod)
|
||||||
|
->when($paymentChannel, function ($q) use($paymentChannel){
|
||||||
return $q->where('channel',$paymentChannel);
|
return $q->where('channel',$paymentChannel);
|
||||||
})->first();
|
})
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
|
||||||
if(!empty($rate)){
|
if(!empty($rate)){
|
||||||
if(!empty($rate->fixed_fees)){
|
if(!empty($rate->fixed_fees)){
|
||||||
|
|
Loading…
Reference in New Issue