added better formatting

1) Omnipay doesn't accept decimals with more than a precision of 2.
2) Once order is created organiser_booking_fee is the correct value to use else use total_booking_fee
3) Controller makes use of OrderService instead of Order Model
This commit is contained in:
Jeremy Quinton 2018-07-10 16:50:46 +02:00
parent 43dab40873
commit a588b634b6
2 changed files with 9 additions and 10 deletions

View File

@ -255,7 +255,7 @@ class EventCheckoutController extends Controller
'event' => $event,
'secondsToExpire' => $secondsToExpire,
'is_embedded' => $this->is_embedded,
'orderService' => $orderService
'orderService' => $orderService
];
if ($this->is_embedded) {
@ -331,12 +331,11 @@ class EventCheckoutController extends Controller
'testMode' => config('attendize.enable_test_payments'),
]);
$order = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event);
$order->calculateFinalCosts();
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event);
$orderService->calculateFinalCosts();
$transaction_data = [
'amount' => $order->getGrandTotal(),
'amount' => $orderService->getGrandTotal(),
'currency' => $event->currency->code,
'description' => 'Order for customer: ' . $request->get('order_email'),
];
@ -538,7 +537,7 @@ class EventCheckoutController extends Controller
$order->is_payment_received = isset($request_data['pay_offline']) ? 0 : 1;
// Calculating grand total including tax
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event);
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event);
$orderService->calculateFinalCosts();
$order->taxamt = $orderService->getTaxAmount();
@ -716,7 +715,7 @@ class EventCheckoutController extends Controller
abort(404);
}
$orderService = new OrderService($order->amount, $order->booking_fee, $order->event);
$orderService = new OrderService($order->amount, $order->organiser_booking_fee, $order->event);
$orderService->calculateFinalCosts();
$data = [

View File

@ -74,7 +74,7 @@ class Order
public function getOrderTotalWithBookingFee($currencyFormatted = false) {
if ($currencyFormatted == false ) {
return $this->orderTotalWithBookingFee;
return number_format($this->grandTotal, 2, '.', '');
}
return money($this->orderTotalWithBookingFee, $this->event->currency);
@ -87,7 +87,7 @@ class Order
public function getTaxAmount($currencyFormatted = false) {
if ($currencyFormatted == false ) {
return $this->taxAmount;
return number_format($this->grandTotal, 2, '.', '');
}
return money($this->taxAmount, $this->event->currency);
@ -100,7 +100,7 @@ class Order
public function getGrandTotal($currencyFormatted = false) {
if ($currencyFormatted == false ) {
return $this->grandTotal;
return number_format($this->grandTotal, 2, '.', '');
}
return money($this->grandTotal, $this->event->currency);