From d71cf4dd4922f6ffc3cf1f8ff23b985b42fd34a6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 26 Jun 2016 19:38:36 +0300 Subject: [PATCH] Payment fixes --- .env.example | 8 +-- .../Controllers/ClientPortalController.php | 10 +-- .../PaymentDrivers/WePayPaymentDriver.php | 2 +- .../accounts/account_gateway_wepay.blade.php | 4 ++ .../views/payments/credit_card.blade.php | 2 + .../views/payments/payment_method.blade.php | 2 +- .../views/payments/paymentmethods.blade.php | 5 +- .../payments/stripe/bank_transfer.blade.php | 64 ++++++++++--------- 8 files changed, 53 insertions(+), 44 deletions(-) diff --git a/.env.example b/.env.example index c7cd8ea6d6..346e181095 100644 --- a/.env.example +++ b/.env.example @@ -71,12 +71,10 @@ API_SECRET=password WEPAY_CLIENT_ID= WEPAY_CLIENT_SECRET= -WEPAY_AUTO_UPDATE=true # Requires permission from WePay WEPAY_ENVIRONMENT=production # production or stage - +WEPAY_AUTO_UPDATE=true # Requires permission from WePay +WEPAY_ENABLE_CANADA=true WEPAY_FEE_PAYER=payee WEPAY_APP_FEE_MULTIPLIER=0.002 WEPAY_APP_FEE_FIXED=0 - -# See https://www.wepay.com/developer/reference/structures#theme -WEPAY_THEME='{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}' +WEPAY_THEME='{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}' # See https://www.wepay.com/developer/reference/structures#theme diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index 5962a3ce4c..2755ae7199 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -165,7 +165,7 @@ class ClientPortalController extends BaseController Session::put('contact_key', $contactKey);// track current contact - return redirect()->to($client->account->enable_client_portal?'/client/dashboard':'/client/invoices/'); + return redirect()->to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/invoices/'); } private function getPaymentTypes($account, $client, $invitation) @@ -694,7 +694,7 @@ class ClientPortalController extends BaseController Session::flash('message', trans('texts.payment_method_verified')); } - return redirect()->to($account->enable_client_portal?'/client/dashboard':'/client/payment_methods/'); + return redirect()->to($account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/'); } public function removePaymentMethod($publicId) @@ -718,7 +718,7 @@ class ClientPortalController extends BaseController Session::flash('error', $exception->getMessage()); } - return redirect()->to($client->account->enable_client_portal?'/client/dashboard':'/client/payment_methods/'); + return redirect()->to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/'); } public function setDefaultPaymentMethod(){ @@ -731,7 +731,7 @@ class ClientPortalController extends BaseController $validator = Validator::make(Input::all(), array('source' => 'required')); if ($validator->fails()) { - return Redirect::to($client->account->enable_client_portal?'/client/dashboard':'/client/payment_methods/'); + return Redirect::to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/'); } $paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN); @@ -745,7 +745,7 @@ class ClientPortalController extends BaseController Session::flash('message', trans('texts.payment_method_set_as_default')); - return redirect()->to($client->account->enable_client_portal?'/client/dashboard':'/client/payment_methods/'); + return redirect()->to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/'); } private function paymentMethodError($type, $error, $accountGateway = false, $exception = false) diff --git a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php index 74a979c09c..096172cfd7 100644 --- a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php @@ -210,7 +210,7 @@ class WePayPaymentDriver extends BasePaymentDriver private function calculateApplicationFee($amount) { - $fee = WEPAY_APP_FEE_MULTIPLIER * $amount + WEPAY_APP_FEE_FIXED; + $fee = (WEPAY_APP_FEE_MULTIPLIER * $amount) + WEPAY_APP_FEE_FIXED; return floor(min($fee, $amount * 0.2));// Maximum fee is 20% of the amount. } diff --git a/resources/views/accounts/account_gateway_wepay.blade.php b/resources/views/accounts/account_gateway_wepay.blade.php index 00367af2de..5017f43fc2 100644 --- a/resources/views/accounts/account_gateway_wepay.blade.php +++ b/resources/views/accounts/account_gateway_wepay.blade.php @@ -27,6 +27,10 @@ {!! Former::populateField('show_address', 1) !!} {!! Former::populateField('update_address', 1) !!} + @if (WEPAY_ENABLE_CANADA) + {!! Former::populateField('country', 'US') !!} + @endif +

{!! trans('texts.online_payments') !!}

diff --git a/resources/views/payments/credit_card.blade.php b/resources/views/payments/credit_card.blade.php index 6e8b3bff2d..a9c3f89e90 100644 --- a/resources/views/payments/credit_card.blade.php +++ b/resources/views/payments/credit_card.blade.php @@ -256,4 +256,6 @@

 

+ {!! Former::close() !!} + @stop diff --git a/resources/views/payments/payment_method.blade.php b/resources/views/payments/payment_method.blade.php index 27d58d9b6a..02ea7e1b2c 100644 --- a/resources/views/payments/payment_method.blade.php +++ b/resources/views/payments/payment_method.blade.php @@ -54,7 +54,7 @@
- {!! Former::close() !!} + + @endif + @if ($accountGateway->getPlaidEnabled())
@@ -149,35 +179,6 @@

{{ trans('texts.ach_verification_delay_help') }}


- {!! Former::open($url) - ->autocomplete('on') - ->addClass('payment-form') - ->id('payment-form') - ->rules(array( - 'country_id' => 'required', - 'currency_id' => 'required', - 'account_number' => 'required', - 'routing_number' => 'required', - 'account_holder_name' => 'required', - 'account_holder_type' => 'required', - 'authorize_ach' => 'required', - )) !!} - - {!! Former::populateField('account_holder_type', 'individual') !!} - {!! Former::populateField('country_id', $client->country_id) !!} - {!! Former::populateField('currency_id', $client->getCurrencyCode()) !!} - - @if (Utils::isNinjaDev()) - {!! Former::populateField('account_holder_name', 'Test Client') !!} - - @endif {!! Former::radios('account_holder_type')->radios(array( trans('texts.individual_account') => array('value' => 'individual'), @@ -235,7 +236,7 @@ ->withAttributes(['id'=>'add_account_button']) ->large() !!} - @if($accountGateway->getPlaidEnabled() && !empty($amount)) + @if ($accountGateway->getPlaidEnabled() && !empty($amount)) {!! Button::success(strtoupper(trans('texts.pay_now') . ' - ' . $account->formatMoney($amount, $client, true) )) ->submit() ->withAttributes(['style'=>'display:none', 'id'=>'pay_now_button']) @@ -244,6 +245,9 @@
+ {!! Former::close() !!} + +