diff --git a/app/Enums/PaymentMethod.php b/app/Enums/PaymentMethod.php new file mode 100644 index 0000000..dfc8163 --- /dev/null +++ b/app/Enums/PaymentMethod.php @@ -0,0 +1,11 @@ +code_country; - if($paymentMethod == 'CARD'){ + if($paymentMethod == PaymentMethod::CARD){ $aggregator = PaymentAggregator::where('name','like','%stripe%')->first(); } - if($paymentMethod == 'WALLET'){ + if($paymentMethod == PaymentMethod::WALLET){ $aggregator = PaymentAggregator::where('status',1)->first(); } if(!empty($aggregator)){ - $rate = $aggregator->rates()->where('country', $countryCode)->orWhere('country','ALL')->where('type', $paymentType) - ->where('method', $paymentMethod)->when($paymentChannel, function ($q) use($paymentChannel){ + $rate = $aggregator->rates()->where(function ($q) use($countryCode) { + 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); - })->first(); + }) + ->latest() + ->first(); if(!empty($rate)){ if(!empty($rate->fixed_fees)){