diff --git a/app/Http/Controllers/EventCheckoutController.php b/app/Http/Controllers/EventCheckoutController.php index b83fd0fa..5275c35e 100644 --- a/app/Http/Controllers/EventCheckoutController.php +++ b/app/Http/Controllers/EventCheckoutController.php @@ -3,12 +3,15 @@ namespace App\Http\Controllers; use App\Events\OrderCompletedEvent; +use App\Models\Account; +use App\Models\AccountPaymentGateway; use App\Models\Affiliate; use App\Models\Attendee; use App\Models\Event; use App\Models\EventStats; use App\Models\Order; use App\Models\OrderItem; +use App\Models\PaymentGateway; use App\Models\QuestionAnswer; use App\Models\ReservedTickets; use App\Models\Ticket; @@ -184,6 +187,15 @@ class EventCheckoutController extends Controller ]); } + if (config('attendize.enable_dummy_payment_gateway') == TRUE) { + $activeAccountPaymentGateway = new AccountPaymentGateway(); + $activeAccountPaymentGateway->fill(['payment_gateway_id' => config('attendize.payment_gateway_dummy')]); + $paymentGateway= $activeAccountPaymentGateway; + } else { + $activeAccountPaymentGateway = count($event->account->active_payment_gateway) ? $event->account->active_payment_gateway : false; + $paymentGateway = count($event->account->active_payment_gateway) ? $event->account->active_payment_gateway->payment_gateway : false; + } + /* * The 'ticket_order_{event_id}' session stores everything we need to complete the transaction. */ @@ -203,8 +215,8 @@ class EventCheckoutController extends Controller 'order_requires_payment' => (ceil($order_total) == 0) ? false : true, 'account_id' => $event->account->id, 'affiliate_referral' => Cookie::get('affiliate_' . $event_id), - 'account_payment_gateway' => count($event->account->active_payment_gateway) ? $event->account->active_payment_gateway : false, - 'payment_gateway' => count($event->account->active_payment_gateway) ? $event->account->active_payment_gateway->payment_gateway : false, + 'account_payment_gateway' => $activeAccountPaymentGateway, + 'payment_gateway' => $paymentGateway ]); /* @@ -317,25 +329,43 @@ class EventCheckoutController extends Controller } try { + $transaction_data = []; + if (config('attendize.enable_dummy_payment_gateway') == TRUE) { + $formData = config('attendize.fake_card_data'); + $transaction_data = [ + 'card' => $formData + ]; - $gateway = Omnipay::create($ticket_order['payment_gateway']->name); + $gateway = Omnipay::create('Dummy'); + $gateway->initialize(); - $gateway->initialize($ticket_order['account_payment_gateway']->config + [ - 'testMode' => config('attendize.enable_test_payments'), - ]); + } else { + $gateway = Omnipay::create($ticket_order['payment_gateway']->name); + $gateway->initialize($ticket_order['account_payment_gateway']->config + [ + 'testMode' => config('attendize.enable_test_payments'), + ]); + } // Calculating grand total including tax $grand_total = $ticket_order['order_total'] + $ticket_order['organiser_booking_fee']; $tax_amt = ($grand_total * $event->organiser->taxvalue) / 100; $grand_total = $tax_amt + $grand_total; - $transaction_data = [ + $transaction_data += [ 'amount' => $grand_total, 'currency' => $event->currency->code, 'description' => 'Order for customer: ' . $request->get('order_email'), ]; switch ($ticket_order['payment_gateway']->id) { + case config('attendize.payment_gateway_dummy'): + $token = uniqid(); + $transaction_data += [ + 'token' => $token, + 'receipt_email' => $request->get('order_email'), + 'card' => $formData + ]; + break; case config('attendize.payment_gateway_paypal'): case config('attendize.payment_gateway_coinbase'): diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index fba0ed47..a334efd7 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "omnipay/paypal": "*", "omnipay/bitpay": "dev-master", "omnipay/coinbase": "dev-master", + "omnipay/dummy": "~2.2", "laracasts/utilities": "^2.1", "predis/predis": "~1.0", "guzzlehttp/guzzle": "^6.2", diff --git a/config/attendize.php b/config/attendize.php index db0fd810..e2a6e640 100644 --- a/config/attendize.php +++ b/config/attendize.php @@ -8,11 +8,16 @@ return [ 'ticket_status_after_sale_date' => 2,// 'enable_test_payments' => env('ENABLE_TEST_PAYMENTS', false), + 'enable_dummy_payment_gateway' => false, 'payment_gateway_stripe' => 1, 'payment_gateway_paypal' => 2, 'payment_gateway_coinbase' => 3, 'payment_gateway_migs' => 4, - + 'fake_card_data' => [ + 'number' => '4242424242424242', + 'expiryMonth' => '6', + 'expiryYear' => '2030', + 'cvv' => '123' 'outgoing_email_noreply' => env('MAIL_FROM_ADDRESS'), 'outgoing_email' => env('MAIL_FROM_ADDRESS'), 'outgoing_email_name' => env('MAIL_FROM_NAME'),