payment configured
This commit is contained in:
parent
25181538e8
commit
4ac8cb2e60
|
|
@ -15,6 +15,7 @@ use App\Models\PaymentGateway;
|
|||
use App\Models\QuestionAnswer;
|
||||
use App\Models\ReservedTickets;
|
||||
use App\Models\Ticket;
|
||||
use App\Payment\CardPayment;
|
||||
use App\Services\Order as OrderService;
|
||||
use Carbon\Carbon;
|
||||
use Cookie;
|
||||
|
|
@ -34,17 +35,23 @@ class EventCheckoutController extends Controller
|
|||
* @var bool
|
||||
*/
|
||||
protected $is_embedded;
|
||||
/**
|
||||
* Payment gateway
|
||||
* @var CardPayment
|
||||
*/
|
||||
protected $gateway;
|
||||
|
||||
/**
|
||||
* EventCheckoutController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
public function __construct(Request $request, CardPayment $gateway)
|
||||
{
|
||||
/*
|
||||
* See if the checkout is being called from an embedded iframe.
|
||||
*/
|
||||
$this->is_embedded = $request->get('is_embedded') == '1';
|
||||
$this->gateway = $gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -180,21 +187,21 @@ 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 = $event->account->getGateway($event->account->payment_gateway_id);
|
||||
//if no payment gateway configured and no offline pay, don't go to the next step and show user error
|
||||
if (empty($activeAccountPaymentGateway) && !$event->enable_offline_payments) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'No payment gateway configured',
|
||||
]);
|
||||
}
|
||||
$paymentGateway = $activeAccountPaymentGateway ? $activeAccountPaymentGateway->payment_gateway : false;
|
||||
}
|
||||
// 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 = $event->account->getGateway($event->account->payment_gateway_id);
|
||||
// //if no payment gateway configured and no offline pay, don't go to the next step and show user error
|
||||
// if (empty($activeAccountPaymentGateway) && !$event->enable_offline_payments) {
|
||||
// return response()->json([
|
||||
// 'status' => 'error',
|
||||
// 'message' => 'No payment gateway configured',
|
||||
// ]);
|
||||
// }
|
||||
// $paymentGateway = $activeAccountPaymentGateway ? $activeAccountPaymentGateway->payment_gateway : false;
|
||||
// }
|
||||
|
||||
/*
|
||||
* The 'ticket_order_{event_id}' session stores everything we need to complete the transaction.
|
||||
|
|
@ -215,8 +222,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' => $activeAccountPaymentGateway,
|
||||
'payment_gateway' => $paymentGateway
|
||||
// 'account_payment_gateway' => $activeAccountPaymentGateway,
|
||||
// 'payment_gateway' => $paymentGateway
|
||||
]);
|
||||
|
||||
/*
|
||||
|
|
@ -274,13 +281,17 @@ class EventCheckoutController extends Controller
|
|||
}
|
||||
|
||||
return view('Public.ViewEvent.EventPageCheckout', $data);
|
||||
|
||||
}
|
||||
|
||||
public function postValidateOrder(Request $request, $event_id)
|
||||
/**
|
||||
* Create the order, handle payment, update stats, fire off email jobs then redirect user
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $event_id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postCreateOrder(Request $request, $event_id)
|
||||
{
|
||||
session()->push('ticket_order_' . $event_id . '.request_data', $request->all());
|
||||
|
||||
//If there's no session kill the request and redirect back to the event homepage.
|
||||
if (!session()->get('ticket_order_' . $event_id)) {
|
||||
return response()->json([
|
||||
|
|
@ -331,72 +342,8 @@ class EventCheckoutController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'redirectUrl' => route('showEventPayment', [
|
||||
'event_id' => $event_id,
|
||||
'is_embedded' => $this->is_embedded
|
||||
])
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function showEventPayment(Request $request, $event_id)
|
||||
{
|
||||
$order_session = session()->get('ticket_order_' . $event_id);
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$payment_gateway = $order_session['payment_gateway'];
|
||||
$order_total = $order_session['order_total'];
|
||||
$account_payment_gateway = $order_session['account_payment_gateway'];
|
||||
|
||||
$orderService = new OrderService($order_session['order_total'], $order_session['total_booking_fee'], $event);
|
||||
$orderService->calculateFinalCosts();
|
||||
|
||||
switch ($payment_gateway->id) {
|
||||
case config('attendize.payment_gateway_stripe_sca'):
|
||||
\Stripe\Stripe::setApiKey($account_payment_gateway->config['apiKey']);
|
||||
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $order_total,
|
||||
'currency' => $event->currency->code,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
$secondsToExpire = Carbon::now()->diffInSeconds($order_session['expires']);
|
||||
|
||||
$viewData = ['event' => $event,
|
||||
'tickets' => $order_session['tickets'],
|
||||
'order_total' => $order_total,
|
||||
'orderService' => $orderService,
|
||||
'order_requires_payment' => (ceil($order_session['order_total']) == 0) ? false : true,
|
||||
'account_payment_gateway' => $account_payment_gateway,
|
||||
'payment_gateway' => $payment_gateway,
|
||||
'secondsToExpire' => $secondsToExpire
|
||||
];
|
||||
|
||||
if (!empty($intent)) {
|
||||
$viewData['client_secret'] = $intent->client_secret;
|
||||
}
|
||||
|
||||
return view('Public.ViewEvent.EventPagePayment', $viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the order, update stats, fire off email jobs then redirect user
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $event_id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postCreateOrder(Request $request, $event_id)
|
||||
{
|
||||
//Add the request data to a session in case payment is required off-site
|
||||
session()->push('ticket_order_' . $event_id . '.request_data', $request->except(['cardnumber', 'cvc']));
|
||||
|
||||
$ticket_order = session()->get('ticket_order_' . $event_id);
|
||||
$event = Event::findOrFail($event_id);
|
||||
session()->push('ticket_order_' . $event_id . '.request_data', $request->except(['card-number', 'card-cvc']));
|
||||
|
||||
$orderRequiresPayment = $ticket_order['order_requires_payment'];
|
||||
|
||||
|
|
@ -409,48 +356,34 @@ class EventCheckoutController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
//more transation data being put in here.
|
||||
//more transaction data being put in here.
|
||||
$transaction_data = [];
|
||||
if (config('attendize.enable_dummy_payment_gateway') == TRUE) {
|
||||
$formData = config('attendize.fake_card_data');
|
||||
$transaction_data = [
|
||||
'card' => $formData
|
||||
];
|
||||
|
||||
$gateway = Omnipay::create('Dummy');
|
||||
$gateway->initialize();
|
||||
|
||||
} else {
|
||||
|
||||
$gateway = Omnipay::create($ticket_order['payment_gateway']->name);
|
||||
$gateway->initialize($ticket_order['account_payment_gateway']->config + [
|
||||
'testMode' => config('attendize.enable_test_payments'),
|
||||
]);
|
||||
}
|
||||
|
||||
// if (config('attendize.enable_dummy_payment_gateway') == TRUE) {
|
||||
// $formData = config('attendize.fake_card_data');
|
||||
// $transaction_data = [
|
||||
// 'card' => $formData
|
||||
// ];
|
||||
//
|
||||
// $gateway = Omnipay::create('Dummy');
|
||||
// $gateway->initialize();
|
||||
//
|
||||
// } else {
|
||||
//// $gateway = Omnipay::create($ticket_order['payment_gateway']->name);
|
||||
//// $gateway->initialize($ticket_order['account_payment_gateway']->config + [
|
||||
//// 'testMode' => config('attendize.enable_test_payments'),
|
||||
//// ]);
|
||||
// $gateway = Omnipay::create('Dummy');
|
||||
// $gateway->initialize();
|
||||
// }
|
||||
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event);
|
||||
$orderService->calculateFinalCosts();
|
||||
|
||||
$transaction_data += [
|
||||
'amount' => $orderService->getGrandTotal(),
|
||||
'currency' => $event->currency->code,
|
||||
'amount' => $orderService->getGrandTotal()*10,//todo multiply by 10
|
||||
'currency' => 934,
|
||||
'description' => 'Order for customer: ' . $request->get('order_email'),
|
||||
];
|
||||
|
||||
//TODO: class with an interface that builds the transaction data.
|
||||
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'):
|
||||
|
||||
$transaction_data += [
|
||||
'cancelUrl' => route('showEventCheckoutPaymentReturn', [
|
||||
'orderNumber' => uniqid(),
|
||||
'failUrl' => route('showEventCheckoutPaymentReturn', [
|
||||
'event_id' => $event_id,
|
||||
'is_payment_cancelled' => 1
|
||||
]),
|
||||
|
|
@ -458,91 +391,81 @@ class EventCheckoutController extends Controller
|
|||
'event_id' => $event_id,
|
||||
'is_payment_successful' => 1
|
||||
]),
|
||||
'brandName' => isset($ticket_order['account_payment_gateway']->config['brandingName'])
|
||||
? $ticket_order['account_payment_gateway']->config['brandingName']
|
||||
: $event->organiser->name
|
||||
|
||||
];
|
||||
|
||||
$transaction = $gateway->purchase($transaction_data);
|
||||
$response = $transaction->send();
|
||||
//TODO: class with an interface that builds the transaction data.
|
||||
// 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'):
|
||||
//
|
||||
// $transaction_data += [
|
||||
// 'cancelUrl' => route('showEventCheckoutPaymentReturn', [
|
||||
// 'event_id' => $event_id,
|
||||
// 'is_payment_cancelled' => 1
|
||||
// ]),
|
||||
// 'returnUrl' => route('showEventCheckoutPaymentReturn', [
|
||||
// 'event_id' => $event_id,
|
||||
// 'is_payment_successful' => 1
|
||||
// ]),
|
||||
// 'brandName' => isset($ticket_order['account_payment_gateway']->config['brandingName'])
|
||||
// ? $ticket_order['account_payment_gateway']->config['brandingName']
|
||||
// : $event->organiser->name
|
||||
// ];
|
||||
// break;
|
||||
// case config('attendize.payment_gateway_stripe'):
|
||||
// $token = $request->get('stripeToken');
|
||||
// $transaction_data += [
|
||||
// 'token' => $token,
|
||||
// 'receipt_email' => $request->get('order_email'),
|
||||
// ];
|
||||
// break;
|
||||
// default:
|
||||
// Log::error('No payment gateway configured.');
|
||||
// return response()->json([
|
||||
// 'status' => 'error',
|
||||
// 'message' => 'No payment gateway configured.'
|
||||
// ]);
|
||||
// break;
|
||||
// }
|
||||
|
||||
break;
|
||||
case config('attendize.payment_gateway_stripe'):
|
||||
$token = $request->get('stripeToken');
|
||||
$transaction_data += [
|
||||
'token' => $token,
|
||||
'receipt_email' => $request->get('order_email'),
|
||||
'returnUrl' => route('showEventCheckoutPaymentReturn', [
|
||||
'event_id' => $event_id,
|
||||
'is_payment_successful' => 1
|
||||
]),
|
||||
];
|
||||
|
||||
$transaction = $gateway->purchase($transaction_data);
|
||||
$response = $transaction->send();
|
||||
|
||||
break;
|
||||
|
||||
case config('attendize.payment_gateway_stripe_sca'):
|
||||
|
||||
Log::error($ticket_order['payment_gateway']->name);
|
||||
|
||||
$paymentMethod = $request->get('paymentMethod');
|
||||
|
||||
$returnUrl = route('showEventCheckoutPaymentReturn', [
|
||||
'event_id' => $event_id,
|
||||
'is_payment_successful' => 1,
|
||||
]);
|
||||
|
||||
$transaction_data += [
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'receipt_email' => 'jeremyquinton@gmail.com', //$request->get('order_email'),
|
||||
'returnUrl' => $returnUrl,
|
||||
'confirm' => true,
|
||||
];
|
||||
|
||||
Log::error(print_r($transaction_data, true));
|
||||
|
||||
$response = $gateway->authorize($transaction_data)->send();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Log::error('No payment gateway configured.');
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'No payment gateway configured.'
|
||||
]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
|
||||
session()->push('ticket_order_' . $event_id . '.transaction_id',
|
||||
$response->getTransactionReference());
|
||||
|
||||
return $this->completeOrder($event_id);
|
||||
|
||||
} elseif ($response->isRedirect()) {
|
||||
$response = $this->gateway->registerPayment($transaction_data);
|
||||
|
||||
//todo start resolving payment here /////////////////////////////////////////////////////
|
||||
// if ($response->isSuccessful()) {
|
||||
//
|
||||
// session()->push('ticket_order_' . $event_id . '.transaction_id',
|
||||
// $response->getTransactionReference());
|
||||
//
|
||||
// return $this->completeOrder($event_id);
|
||||
//
|
||||
// } elseif ($response->isRedirect()) {
|
||||
if($response->isSuccessfull()){
|
||||
/*
|
||||
* As we're going off-site for payment we need to store some data in a session so it's available
|
||||
* when we return
|
||||
*/
|
||||
$transaction_data['orderId'] = $response->getPaymentReferenceId();
|
||||
session()->push('ticket_order_' . $event_id . '.transaction_data', $transaction_data);
|
||||
Log::info("Redirect url: " . $response->getRedirectUrl());
|
||||
|
||||
$return = [
|
||||
'status' => 'success',
|
||||
'redirectUrl' => $response->getRedirectUrl(),
|
||||
'message' => 'Redirecting to ' . $ticket_order['payment_gateway']->provider_name
|
||||
'message' => 'Redirecting to payment gateway'
|
||||
];
|
||||
|
||||
// GET method requests should not have redirectData on the JSON return string
|
||||
if($response->getRedirectMethod() == 'POST') {
|
||||
$return['redirectData'] = $response->getRedirectData();
|
||||
}
|
||||
// if($response->getRedirectMethod() == 'POST') {
|
||||
// $return['redirectData'] = $response->getRedirectData();
|
||||
// }
|
||||
|
||||
return response()->json($return);
|
||||
|
||||
|
|
@ -550,10 +473,11 @@ class EventCheckoutController extends Controller
|
|||
// display error to customer
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $response->getMessage(),
|
||||
'message' => $response->errorMessage(),
|
||||
]);
|
||||
}
|
||||
} catch (\Exeption $e) {
|
||||
// dd($e);
|
||||
Log::error($e);
|
||||
$error = 'Sorry, there was an error processing your payment. Please try again.';
|
||||
}
|
||||
|
|
@ -567,6 +491,7 @@ class EventCheckoutController extends Controller
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to complete a user's payment when they return from
|
||||
* an off-site gateway
|
||||
|
|
@ -578,6 +503,7 @@ class EventCheckoutController extends Controller
|
|||
public function showEventCheckoutPaymentReturn(Request $request, $event_id)
|
||||
{
|
||||
|
||||
|
||||
if ($request->get('is_payment_cancelled') == '1') {
|
||||
session()->flash('message', trans('Event.payment_cancelled'));
|
||||
return response()->redirectToRoute('showEventCheckout', [
|
||||
|
|
@ -586,27 +512,30 @@ class EventCheckoutController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
$ticket_order = session()->get('ticket_order_' . $event_id);
|
||||
$gateway = Omnipay::create($ticket_order['payment_gateway']->name);
|
||||
// $ticket_order = session()->get('ticket_order_' . $event_id);
|
||||
// $gateway = Omnipay::create($ticket_order['payment_gateway']->name);
|
||||
//
|
||||
// $gateway->initialize($ticket_order['account_payment_gateway']->config + [
|
||||
// 'testMode' => config('attendize.enable_test_payments'),
|
||||
// ]);
|
||||
//
|
||||
// $transaction = $gateway->completePurchase($ticket_order['transaction_data'][0]);
|
||||
// $gateway = app()->make('App\Payment\CardPayment');
|
||||
$transaction_data = session()->get('ticket_order_' . $event_id . '.transaction_data');
|
||||
// dd($transaction_data);
|
||||
$response = $this->gateway->getPaymentStatus($transaction_data[0]['orderId']);
|
||||
|
||||
$gateway->initialize($ticket_order['account_payment_gateway']->config + [
|
||||
'testMode' => config('attendize.enable_test_payments'),
|
||||
]);
|
||||
|
||||
$transaction = $gateway->completePurchase($ticket_order['transaction_data'][0]);
|
||||
|
||||
$response = $transaction->send();
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
session()->push('ticket_order_' . $event_id . '.transaction_id', $response->getTransactionReference());
|
||||
if ($response->isSuccessfull()) {
|
||||
session()->push('ticket_order_' . $event_id . '.transaction_id', $response->getPaymentReferenceId());
|
||||
return $this->completeOrder($event_id, false);
|
||||
} else {
|
||||
session()->flash('message', $response->getMessage());
|
||||
session()->flash('message', $response->errorMessage());
|
||||
return response()->redirectToRoute('showEventCheckout', [
|
||||
'event_id' => $event_id,
|
||||
'is_payment_failed' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -625,7 +554,6 @@ class EventCheckoutController extends Controller
|
|||
|
||||
$order = new Order();
|
||||
$ticket_order = session()->get('ticket_order_' . $event_id);
|
||||
|
||||
$request_data = $ticket_order['request_data'][0];
|
||||
$event = Event::findOrFail($ticket_order['event_id']);
|
||||
$attendee_increment = 1;
|
||||
|
|
@ -637,9 +565,9 @@ class EventCheckoutController extends Controller
|
|||
if (isset($ticket_order['transaction_id'])) {
|
||||
$order->transaction_id = $ticket_order['transaction_id'][0];
|
||||
}
|
||||
if ($ticket_order['order_requires_payment'] && !isset($request_data['pay_offline'])) {
|
||||
$order->payment_gateway_id = $ticket_order['payment_gateway']->id;
|
||||
}
|
||||
// if ($ticket_order['order_requires_payment'] && !isset($request_data['pay_offline'])) {
|
||||
// $order->payment_gateway_id = $ticket_order['payment_gateway']->id;
|
||||
// }
|
||||
$order->first_name = sanitise($request_data['order_first_name']);
|
||||
$order->last_name = sanitise($request_data['order_last_name']);
|
||||
$order->email = sanitise($request_data['order_email']);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class EventDashboardController extends MyBaseController
|
|||
public function showDashboard($event_id = false)
|
||||
{
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
//dd($event->sales_volume);
|
||||
$num_days = 20;
|
||||
|
||||
/*
|
||||
|
|
@ -69,7 +69,7 @@ class EventDashboardController extends MyBaseController
|
|||
'date' => $date->format('Y-m-d'),
|
||||
'views' => $views,
|
||||
'unique_views' => $unique_views,
|
||||
'sales_volume' => $sales_volume + $organiser_fees_volume,
|
||||
'sales_volume' => $sales_volume, //+ $organiser_fees_volume,
|
||||
'tickets_sold' => $tickets_sold,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ class ManageAccountController extends MyBaseController
|
|||
'account' => Account::find(Auth::user()->account_id),
|
||||
'timezones' => Timezone::pluck('location', 'id'),
|
||||
'currencies' => Currency::pluck('title', 'id'),
|
||||
'payment_gateways' => PaymentGateway::getAllWithDefaultSet(),
|
||||
'default_payment_gateway_id' => PaymentGateway::getDefaultPaymentGatewayId(),
|
||||
'payment_gateways' => PaymentGateway::pluck('provider_name', 'id'),
|
||||
'account_payment_gateways' => AccountPaymentGateway::scope()->get(),
|
||||
'version_info' => $this->getVersionInfo(),
|
||||
];
|
||||
|
|
@ -125,7 +124,7 @@ class ManageAccountController extends MyBaseController
|
|||
public function postEditAccountPayment(Request $request)
|
||||
{
|
||||
$account = Account::find(Auth::user()->account_id);
|
||||
$gateway_id = $request->get('payment_gateway');
|
||||
$gateway_id = $request->get('payment_gateway_id');
|
||||
|
||||
switch ($gateway_id) {
|
||||
case config('attendize.payment_gateway_stripe') : //Stripe
|
||||
|
|
@ -134,16 +133,10 @@ class ManageAccountController extends MyBaseController
|
|||
case config('attendize.payment_gateway_paypal') : //PayPal
|
||||
$config = $request->get('paypal');
|
||||
break;
|
||||
case config('attendize.payment_gateway_stripe_sca') : //Stripe SCA
|
||||
$config = $request->get('stripe_sca');
|
||||
break;
|
||||
case config('attendize.payment_gateway_altyn_asyr') : // AltynAsyr
|
||||
$config = $request->get('altyn_asyr');
|
||||
}
|
||||
|
||||
PaymentGateway::query()->update(['default' => 0]);
|
||||
$payment_gateway = PaymentGateway::where('id', '=', $gateway_id)->first();
|
||||
$payment_gateway->default = 1;
|
||||
$payment_gateway->save();
|
||||
|
||||
$account_payment_gateway = AccountPaymentGateway::firstOrNew(
|
||||
[
|
||||
'payment_gateway_id' => $gateway_id,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
*/
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Account::class);
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: merdan
|
||||
* Date: 8/15/2019
|
||||
* Time: 17:47
|
||||
*/
|
||||
|
||||
namespace App\Payment;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CardPayment{
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Client(config('payment.card.config'));
|
||||
}
|
||||
|
||||
public function registerPayment($transaction_data){
|
||||
|
||||
$params['form_params'] = array_merge($transaction_data,config('payment.card.params'));
|
||||
$response = new PaymentRegistrationResponse();
|
||||
//dd($params);
|
||||
try{
|
||||
$request = $this->client->post('register.do',$params);
|
||||
$response->setResponseData($request->getBody());
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
Log::error($ex);
|
||||
$error = 'Sorry, there was an error processing your payment. Please try again.';
|
||||
$response->setExceptionMessage($error);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPaymentStatus($orderId){
|
||||
$params['form_params'] = config('payment.card.params');
|
||||
$params['form_params']['orderId'] = $orderId;
|
||||
$response = new PaymentStatusResponse();
|
||||
try{
|
||||
$request = $this->client->post('getOrderStatus.do',$params);
|
||||
$response->setResponseData($request->getBody());
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
Log::error($ex);
|
||||
$response->setExceptionMessage($ex->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: merdan
|
||||
* Date: 8/16/2019
|
||||
* Time: 12:44
|
||||
*/
|
||||
|
||||
namespace App\Payment;
|
||||
|
||||
|
||||
class PaymentRegistrationResponse extends PaymentResponse {
|
||||
|
||||
|
||||
public function isSuccessfull(){
|
||||
if (!$this->exception_message)
|
||||
return $this->response_data['errorCode'] == 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRedirectUrl(){
|
||||
if($this->response_data)
|
||||
return $this->response_data['formUrl'];
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getPaymentReferenceId()
|
||||
{
|
||||
return $this->response_data['orderId'];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: merdan
|
||||
* Date: 8/16/2019
|
||||
* Time: 13:30
|
||||
*/
|
||||
|
||||
namespace App\Payment;
|
||||
|
||||
|
||||
abstract class PaymentResponse
|
||||
{
|
||||
protected $response_data;
|
||||
protected $exception_message;
|
||||
|
||||
public function setResponseData($data){
|
||||
$this->response_data = json_decode($data, true);
|
||||
}
|
||||
|
||||
public function setExceptionMessage($message){
|
||||
$this->exception_message = $message;
|
||||
}
|
||||
|
||||
public function errorMessage(){
|
||||
if(!$this->exception_message)
|
||||
return $this->response_data['errorMessage'];
|
||||
else
|
||||
return $this->exception_message;
|
||||
}
|
||||
|
||||
public abstract function isSuccessfull();
|
||||
public abstract function getPaymentReferenceId();
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: merdan
|
||||
* Date: 8/16/2019
|
||||
* Time: 13:26
|
||||
*/
|
||||
|
||||
namespace App\Payment;
|
||||
|
||||
|
||||
class PaymentStatusResponse extends PaymentResponse
|
||||
{
|
||||
|
||||
public function isSuccessfull()
|
||||
{
|
||||
if(!$this->exception_message)
|
||||
return $this->response_data['ErrorCode'] == 0
|
||||
&& $this->response_data['OrderStatus'] == 2;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPaymentReferenceId()
|
||||
{
|
||||
return $this->response_data['OrderNumber'];
|
||||
}
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'timezone' => env('TIMEZONE', 'UTC'),
|
||||
'timezone' => env('TIMEZONE', 'Asia/Ashgabat'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ return [
|
|||
'payment_gateway_dummy' => 0,
|
||||
'payment_gateway_stripe' => 1,
|
||||
'payment_gateway_paypal' => 2,
|
||||
'payment_gateway_altyn_asyr' => 3,
|
||||
'fake_card_data' => [
|
||||
'number' => '4242424242424242',
|
||||
'expiryMonth' => '6',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: merdan
|
||||
* Date: 8/15/2019
|
||||
* Time: 17:56
|
||||
*/
|
||||
return [
|
||||
'card' =>[
|
||||
'config' => [
|
||||
'base_uri' => 'https://mpi.gov.tm/payment/rest/',
|
||||
'timeout' => 10,
|
||||
'connect_timeout' => 10,
|
||||
'verify' => true,
|
||||
'http_errors' => false,
|
||||
],
|
||||
'params' => [
|
||||
'userName' => '101131003020',
|
||||
'password' => 'Pr2d3gW1dh15',
|
||||
'language' => 'ru',
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
@ -29,7 +29,9 @@ class OrderStatusSeeder extends Seeder
|
|||
'name' => 'Cancelled',
|
||||
],
|
||||
];
|
||||
|
||||
Schema::disableForeignKeyConstraints();
|
||||
DB::table('order_statuses')->delete();
|
||||
Schema::enableForeignKeyConstraints();
|
||||
DB::table('order_statuses')->insert($order_statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,56 +11,29 @@ class PaymentGatewaySeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$dummyGateway = DB::table('payment_gateways')->where('name', '=', 'Dummy')->first();
|
||||
|
||||
if ($dummyGateway === null) {
|
||||
// user doesn't exist
|
||||
DB::table('payment_gateways')->insert(
|
||||
$payment_gateways = [
|
||||
[
|
||||
'provider_name' => 'Dummy/Test Gateway',
|
||||
'provider_url' => 'none',
|
||||
'id' => 3,
|
||||
'name' => 'Altyn_Asyr_Kart',
|
||||
'provider_name' => 'Altyn Asyr',
|
||||
'provider_url' => 'https://mpi.gov.tm/payment/',
|
||||
'is_on_site' => 1,
|
||||
'can_refund' => 1,
|
||||
'name' => 'Dummy',
|
||||
'default' => 0,
|
||||
'admin_blade_template' => '',
|
||||
'checkout_blade_template' => 'Public.ViewEvent.Partials.Dummy'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$stripe = DB::table('payment_gateways')->where('name', '=', 'Stripe')->first();
|
||||
if ($stripe === null) {
|
||||
DB::table('payment_gateways')->insert(
|
||||
[
|
||||
'name' => 'Stripe',
|
||||
'provider_name' => 'Stripe',
|
||||
'provider_url' => 'https://www.stripe.com',
|
||||
'is_on_site' => 1,
|
||||
'can_refund' => 1,
|
||||
'default' => 0,
|
||||
'admin_blade_template' => 'ManageAccount.Partials.Stripe',
|
||||
'checkout_blade_template' => 'Public.ViewEvent.Partials.PaymentStripe'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$stripePaymentIntents = DB::table('payment_gateways')->where('name', '=', 'Stripe\PaymentIntents')->first();
|
||||
if ($stripePaymentIntents === null) {
|
||||
DB::table('payment_gateways')->insert(
|
||||
[
|
||||
'provider_name' => 'Stripe SCA',
|
||||
'provider_url' => 'https://www.stripe.com',
|
||||
'is_on_site' => 0,
|
||||
'can_refund' => 1,
|
||||
'name' => 'Stripe\PaymentIntents',
|
||||
'default' => 0,
|
||||
'admin_blade_template' => 'ManageAccount.Partials.StripeSCA',
|
||||
'checkout_blade_template' => 'Public.ViewEvent.Partials.PaymentStripeSCA'
|
||||
]
|
||||
);
|
||||
}
|
||||
'can_refund' => 0,
|
||||
],
|
||||
// [
|
||||
// 'id' => 2,
|
||||
// 'name' => 'PayPal_Express',
|
||||
// 'provider_name' => 'PayPal Express',
|
||||
// 'provider_url' => 'https://www.paypal.com',
|
||||
// 'is_on_site' => 0,
|
||||
// 'can_refund' => 0
|
||||
//
|
||||
// ]
|
||||
];
|
||||
Schema::disableForeignKeyConstraints();
|
||||
DB::table('payment_gateways')->delete();
|
||||
Schema::enableForeignKeyConstraints();
|
||||
DB::table('payment_gateways')->insert($payment_gateways);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,9 @@ class QuestionTypesSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
Schema::disableForeignKeyConstraints();
|
||||
DB::table('question_types')->delete();
|
||||
Schema::enableForeignKeyConstraints();
|
||||
DB::table('question_types')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ class TicketStatusSeeder extends Seeder
|
|||
'name' => 'On Sale',
|
||||
],
|
||||
];
|
||||
|
||||
Schema::disableForeignKeyConstraints();
|
||||
DB::table('ticket_statuses')->delete();
|
||||
Schema::enableForeignKeyConstraints();
|
||||
DB::table('ticket_statuses')->insert($ticket_statuses);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ class TimezoneSeeder extends Seeder
|
|||
'Pacific/Fiji' => '(GMT+12:00) Fiji',
|
||||
];
|
||||
|
||||
Schema::disableForeignKeyConstraints();
|
||||
DB::table('timezones')->delete();
|
||||
Schema::enableForeignKeyConstraints();
|
||||
foreach ($timezones as $name => $location) {
|
||||
\App\Models\Timezone::create(['name' => $name, 'location' => $location]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<!-- tab -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#general_account" data-toggle="tab">@lang("ManageAccount.general")</a></li>
|
||||
<li><a href="#payment_account" data-toggle="tab">@lang("ManageAccount.payment")</a></li>
|
||||
{{--<li><a href="#payment_account" data-toggle="tab">@lang("ManageAccount.payment")</a></li>--}}
|
||||
<li><a href="#users_account" data-toggle="tab">@lang("ManageAccount.users")</a></li>
|
||||
<li><a href="#about" data-toggle="tab">@lang("ManageAccount.about")</a></li>
|
||||
</ul>
|
||||
|
|
@ -93,11 +93,11 @@
|
|||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
<div class="tab-pane " id="payment_account">
|
||||
{{--<div class="tab-pane " id="payment_account">--}}
|
||||
|
||||
@include('ManageAccount.Partials.PaymentGatewayOptions')
|
||||
{{--@include('ManageAccount.Partials.PaymentGatewayOptions')--}}
|
||||
|
||||
</div>
|
||||
{{--</div>--}}
|
||||
<div class="tab-pane" id="users_account">
|
||||
{!! Form::open(array('url' => route('postInviteUser'), 'class' => 'ajax ')) !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="stat-box">
|
||||
<h3>{{ money($event->sales_volume + $event->organiser_fees_volume, $event->currency) }}</h3>
|
||||
<h3>{{ money($event->sales_volume, $event->currency) }}</h3>
|
||||
<span>@lang("Dashboard.sales_volume")</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
<h3 class="panel-title">
|
||||
@lang("Dashboard.ticket_sales_volume")
|
||||
<span style="color: green; float: right;">
|
||||
{{money($event->sales_volume + $event->organiser_fees_volume, $event->currency)}}
|
||||
{{money($event->sales_volume, $event->currency)}}
|
||||
@lang("basic.total")
|
||||
</span>
|
||||
</h3>
|
||||
|
|
|
|||
Loading…
Reference in New Issue