mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for login api
This commit is contained in:
parent
9431abb300
commit
da0c0080a5
@ -16,8 +16,10 @@ use App\Http\Controllers\Controller;
|
||||
use App\Jobs\Account\CreateAccount;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Libraries\OAuth\OAuth;
|
||||
use App\Models\Account;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\User;
|
||||
use App\Transformers\AccountTransformer;
|
||||
use App\Transformers\CompanyUserTransformer;
|
||||
use App\Transformers\UserTransformer;
|
||||
use App\Utils\Traits\UserSessionAttributes;
|
||||
@ -43,9 +45,9 @@ class LoginController extends BaseController
|
||||
use AuthenticatesUsers;
|
||||
use UserSessionAttributes;
|
||||
|
||||
protected $entity_type = CompanyUser::class;
|
||||
protected $entity_type = Account::class;
|
||||
|
||||
protected $entity_transformer = CompanyUserTransformer::class;
|
||||
protected $entity_transformer = AccountTransformer::class;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
@ -107,9 +109,9 @@ class LoginController extends BaseController
|
||||
|
||||
$user->setCompany($user->user_companies->first()->account->default_company);
|
||||
|
||||
$ct = CompanyUser::whereUserId($user->id);
|
||||
//$ct = CompanyUser::whereUserId($user->id);
|
||||
|
||||
return $this->listResponse($ct);
|
||||
return $this->itemResponse($user->user_companies->first()->account);
|
||||
//return $this->itemResponse($this->guard()->user());
|
||||
}
|
||||
else {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use = namespace\Cache;
|
||||
use App\Filters\PaymentFilters;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Payment;
|
||||
@ -79,7 +80,8 @@ class PaymentController extends Controller
|
||||
* Presents the payment screen for a given
|
||||
* gateway and payment method.
|
||||
* The request will also contain the amount
|
||||
* and invoice ids for reference
|
||||
* and invoice ids for reference.
|
||||
*
|
||||
* @param int $company_gateway_id The CompanyGateway ID
|
||||
* @param int $payment_method_id The PaymentMethod ID
|
||||
* @return void
|
||||
@ -87,10 +89,16 @@ class PaymentController extends Controller
|
||||
public function process($company_gateway_id, $payment_method_id)
|
||||
{
|
||||
|
||||
$invoices = request()->input('ids');
|
||||
$invoices = Invoice::whereIn('id', $this->transformKeys(request()->input('invoice_ids')))
|
||||
->whereClientId(auth()->user()->client->id)
|
||||
->get();
|
||||
|
||||
$amount = request()->input('amount');
|
||||
|
||||
//build a cache record to maintain state
|
||||
$cache_hash = str_random(config('ninja.key_length'));
|
||||
|
||||
Cache::put($cache_hash, 'value', now()->addMinutes(10));
|
||||
|
||||
//boot the payment gateway
|
||||
|
||||
@ -99,9 +107,10 @@ class PaymentController extends Controller
|
||||
|
||||
$data = [
|
||||
'redirect_url' =>,
|
||||
'amount' =>,
|
||||
'invoices' => $invoices,
|
||||
'amount' => $amount,
|
||||
'gateway_data' =>,
|
||||
'cache_hash' =>,
|
||||
'cache_hash' => $cache_hash,
|
||||
];
|
||||
|
||||
return view('', $data);
|
||||
|
@ -42,21 +42,6 @@ class BasePaymentDriver
|
||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
||||
}
|
||||
|
||||
/* Stubbed in parent.
|
||||
*
|
||||
* The boot method should be used in the superclass
|
||||
* to initialize all the member variables for the
|
||||
* given driver / payment gateway
|
||||
*
|
||||
* ie.
|
||||
*
|
||||
* ->gateway()
|
||||
* ->boot()
|
||||
*
|
||||
* @return Instance
|
||||
*/
|
||||
public function boot(){}
|
||||
|
||||
/**
|
||||
* Returns the Omnipay driver
|
||||
* @return object Omnipay initialized object
|
||||
@ -101,13 +86,6 @@ class BasePaymentDriver
|
||||
];
|
||||
}
|
||||
|
||||
public function setRefundable($value)
|
||||
{
|
||||
$this->refundable = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether refunds are possible with the gateway
|
||||
* @return boolean TRUE|FALSE
|
||||
@ -117,13 +95,6 @@ class BasePaymentDriver
|
||||
return $this->refundable;
|
||||
}
|
||||
|
||||
public function setTokenBilling($value)
|
||||
{
|
||||
$this->token_billing = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether token billing is possible with the gateway
|
||||
* @return boolean TRUE|FALSE
|
||||
|
@ -23,11 +23,6 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
protected $customer_reference = 'customerReferenceParam';
|
||||
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->setRefundable($this->refundable);
|
||||
$this->setTokenBilling($this->token_billing);
|
||||
}
|
||||
/**
|
||||
* Methods in this class are divided into
|
||||
* two separate streams
|
||||
@ -76,6 +71,40 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
|
||||
return $types;
|
||||
|
||||
}
|
||||
|
||||
public function viewForType($payment_type)
|
||||
{
|
||||
switch ($payment_type) {
|
||||
case GatewayType::CREDIT_CARD:
|
||||
return 'gateways.stripe.credit_card';
|
||||
break;
|
||||
case GatewayType::TOKEN:
|
||||
return 'gateways.stripe.token';
|
||||
break;
|
||||
case GatewayType::SOFORT:
|
||||
return 'gateways.stripe.sofort';
|
||||
break;
|
||||
case GatewayType::BANK_TRANSFER:
|
||||
return 'gateways.stripe.ach';
|
||||
break;
|
||||
case GatewayType::SEPA:
|
||||
return 'gateways.stripe.sepa';
|
||||
break;
|
||||
case GatewayType::BITCOIN:
|
||||
return 'gateways.stripe.other';
|
||||
break;
|
||||
case GatewayType::ALIPAY:
|
||||
return 'gateways.stripe.other';
|
||||
break;
|
||||
case GatewayType::APPLE_PAY:
|
||||
return 'gateways.stripe.other';
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
/************************************** Omnipay API methods **********************************************************/
|
||||
|
||||
|
@ -33,7 +33,7 @@ class AccountTransformer extends EntityTransformer
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
//'default_company',
|
||||
//'user',
|
||||
'user',
|
||||
'company_users'
|
||||
];
|
||||
|
||||
@ -85,8 +85,9 @@ class AccountTransformer extends EntityTransformer
|
||||
{
|
||||
|
||||
$transformer = new UserTransformer($this->serializer);
|
||||
return $this->includeItem(auth()->user(), $transformer, User::class);
|
||||
|
||||
return $this->includeItem($account->default_company->owner(), $transformer, User::class);
|
||||
// return $this->includeItem($account->default_company->owner(), $transformer, User::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -104,10 +104,10 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'invoice_footer' => $invoice->invoice_footer ?: '',
|
||||
'partial' => (float) ($invoice->partial ?: 0.0),
|
||||
'partial_due_date' => $invoice->partial_due_date ?: '',
|
||||
'custom_value1' => (float) $invoice->custom_value1,
|
||||
'custom_value2' => (float) $invoice->custom_value2,
|
||||
'custom_value3' => (bool) $invoice->custom_value3,
|
||||
'custom_value4' => (bool) $invoice->custom_value4,
|
||||
'custom_value1' => (string) $invoice->custom_value1,
|
||||
'custom_value2' => (string) $invoice->custom_value2,
|
||||
'custom_value3' => (string) $invoice->custom_value3,
|
||||
'custom_value4' => (string) $invoice->custom_value4,
|
||||
'has_tasks' => (bool) $invoice->has_tasks,
|
||||
'has_expenses' => (bool) $invoice->has_expenses,
|
||||
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
|
||||
|
@ -6,8 +6,8 @@ return [
|
||||
'app_name' => env('APP_NAME'),
|
||||
'site_url' => env('APP_URL', 'https://v2.invoiceninja.com'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoiceninja.com'),
|
||||
'app_version' => '0.1',
|
||||
'api_version' => '0.1',
|
||||
'app_version' => '0.0.1',
|
||||
'api_version' => '0.0.1',
|
||||
'terms_version' => '1.0.1',
|
||||
'app_env' => env('APP_ENV', 'development'),
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
@ -0,0 +1,63 @@
|
||||
@extends('portal.default.layouts.master')
|
||||
@section('header')
|
||||
|
||||
@stop
|
||||
@section('body')
|
||||
<main class="main">
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="padding-top: 30px;">
|
||||
<div class="col d-flex justify-content-center">
|
||||
<div class="card w-50 p-10">
|
||||
<div class="card-header">
|
||||
{{ ctrans('texts.payment')}}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="list-group">
|
||||
@foreach($invoices as $invoice)
|
||||
<a class="list-group-item list-group-item-action flex-column align-items-start" href="javascript:void(0);">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mr-4"># {{ $invoice->invoice_number }}</h5>
|
||||
<small>{{ $invoice->due_date }}</small>
|
||||
</div>
|
||||
<p class="mb-1 pull-right">{{ $invoice->balance }}</p>
|
||||
<small>
|
||||
@if($invoice->po_number)
|
||||
{{ $invoice->po_number }}
|
||||
@elseif($invoice->public_notes)
|
||||
{{ $invoice->public_notes }}
|
||||
@else
|
||||
{{ $invoice->invoice_date}}
|
||||
@endif
|
||||
</small>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="py-md-5">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.total')}}</strong>
|
||||
<h3><span class="badge badge-primary badge-pill"><strong>{{ $amount }}</strong></span></h3>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Stripe Credit Card Payment Form-->
|
||||
<div class="py-md-5">
|
||||
|
||||
</div>
|
||||
<!-- Stripe Credit Card Payment Form-->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
@endsection
|
||||
@push('scripts')
|
||||
|
||||
@endpush
|
||||
@section('footer')
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user