diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 3047e8835772..f194f2bf99b0 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -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 { diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index d3346efd3f1a..6cab926f64c0 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -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); diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index 6a11a0b43b8f..d0412f989ea1 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -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 diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 25122935314f..9480115c1cff 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -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 **********************************************************/ diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 98be784d6d11..135a66bbc836 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -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); } } diff --git a/app/Transformers/InvoiceTransformer.php b/app/Transformers/InvoiceTransformer.php index 14ba888581d6..e9b4dedf52d3 100644 --- a/app/Transformers/InvoiceTransformer.php +++ b/app/Transformers/InvoiceTransformer.php @@ -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 ?: '', diff --git a/config/ninja.php b/config/ninja.php index b7a8fdab9724..1ee7b38b0b7d 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -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', ''), diff --git a/resources/views/portal/default/gateways/stripe/credit_card.blade.php b/resources/views/portal/default/gateways/stripe/credit_card.blade.php new file mode 100644 index 000000000000..7314a46daf94 --- /dev/null +++ b/resources/views/portal/default/gateways/stripe/credit_card.blade.php @@ -0,0 +1,63 @@ +@extends('portal.default.layouts.master') +@section('header') + +@stop +@section('body') +
+
+ +
+
+ +@endsection +@push('scripts') + +@endpush +@section('footer') +@endsection +