New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy payment gateway #398

Merged
merged 4 commits into from Jul 12, 2018
Jump to file or symbol
Failed to load files and symbols.
+53 −9
Diff settings

Always

Just for now

@@ -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 @@ public function postValidateTickets(Request $request, $event_id)
]);
}
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 @@ public function postValidateTickets(Request $request, $event_id)
'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 @@ public function postCreateOrder(Request $request, $event_id)
}
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'):
View
1 composer.json 100644 → 100755
@@ -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",
View
@@ -7,12 +7,18 @@
'ticket_status_sold_out' => 1,
'ticket_status_after_sale_date' => 2,//
'enable_test_payments' => env('ENABLE_TEST_PAYMENTS', false),
'enable_dummy_payment_gateway' => false,
'payment_gateway_dummy' => 0,
'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'),
View
@@ -119,6 +119,13 @@ docker-compose run php php artisan attendize:install
Attendize should now be available at `http://localhost:8080` and maildev at `http://localhost:1080`
### Enabling Dummy Payment Gateway for testing purposes ###
To be able to test the journey of buying and paying for tickets from the event page you need to have a payment gateway enabled else you can't complete the journey. To enable the dummy gateway that allows you to go through the journey
end to end change the configuration option enable_dummy_payment_gateway in ./config/attendize.php to true
```
'enable_dummy_payment_gateway' => true
```
### Manual Installation
---
ProTip! Use n and p to navigate between commits in a pull request.