diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index 1ef8d61e98..bd7cb2599b 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -110,13 +110,25 @@ class AccountGatewayController extends BaseController continue; } + if ($type == PAYMENT_TYPE_STRIPE && $account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD)) { + // Another gateway is already handling credit card payments + continue; + } + if ($type == PAYMENT_TYPE_DIRECT_DEBIT && $stripeGateway = $account->getGatewayByType(PAYMENT_TYPE_STRIPE)) { - if (!empty($stripeGateway->getConfig()->enableAch)) { + if (!empty($stripeGateway->getAchEnabled())) { // Stripe is already handling ACH payments continue; } } + if ($type == PAYMENT_TYPE_PAYPAL && $braintreeGateway = $account->getGatewayConfig(GATEWAY_BRAINTREE)) { + if (!empty($braintreeGateway->getPayPalEnabled())) { + // PayPal is already enabled + continue; + } + } + $paymentTypes[$type] = $type == PAYMENT_TYPE_CREDIT_CARD ? trans('texts.other_providers'): trans('texts.'.strtolower($type)); if ($type == PAYMENT_TYPE_BITCOIN) { @@ -300,6 +312,10 @@ class AccountGatewayController extends BaseController $config->enableAch = boolval(Input::get('enable_ach')); } + if ($gatewayId == GATEWAY_BRAINTREE) { + $config->enablePayPal = boolval(Input::get('enable_paypal')); + } + $cardCount = 0; if ($creditcards) { foreach ($creditcards as $card => $value) { diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 555f9965e3..84d2814781 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -152,63 +152,83 @@ class PaymentController extends BaseController $account->account_gateways[0]->getPaymentType(); } - if ($paymentType == PAYMENT_TYPE_TOKEN) { - $useToken = true; - $accountGateway = $invoice->client->account->getTokenGateway(); - $paymentType = $accountGateway->getPaymentType(); - } else { - $accountGateway = $invoice->client->account->getGatewayByType($paymentType); - } + $data = array(); - Session::put($invitation->id . 'payment_type', $paymentType); - - $gateway = $accountGateway->gateway; - - $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes(); - - $isOffsite = ($paymentType != PAYMENT_TYPE_CREDIT_CARD && $accountGateway->getPaymentType() != PAYMENT_TYPE_STRIPE) - || $gateway->id == GATEWAY_EWAY - || $gateway->id == GATEWAY_TWO_CHECKOUT - || $gateway->id == GATEWAY_PAYFAST - || $gateway->id == GATEWAY_MOLLIE; - - // Handle offsite payments - if ($useToken || $isOffsite) { - if (Session::has('error')) { - Session::reflash(); - return Redirect::to('view/'.$invitationKey); + if ($paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL) { + if ($paymentType == PAYMENT_TYPE_TOKEN) { + $useToken = true; + $accountGateway = $invoice->client->account->getTokenGateway(); + $paymentType = $accountGateway->getPaymentType(); } else { - return self::do_payment($invitationKey, false, $useToken, $sourceId); + $accountGateway = $invoice->client->account->getGatewayByType($paymentType); } + + Session::put($invitation->id . 'payment_type', $paymentType); + + $gateway = $accountGateway->gateway; + + $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes(); + + $isOffsite = ($paymentType != PAYMENT_TYPE_CREDIT_CARD && $accountGateway->getPaymentType() != PAYMENT_TYPE_STRIPE) + || $gateway->id == GATEWAY_EWAY + || $gateway->id == GATEWAY_TWO_CHECKOUT + || $gateway->id == GATEWAY_PAYFAST + || $gateway->id == GATEWAY_MOLLIE; + + // Handle offsite payments + if ($useToken || $isOffsite) { + if (Session::has('error')) { + Session::reflash(); + return Redirect::to('view/' . $invitationKey); + } else { + return self::do_payment($invitationKey, false, $useToken, $sourceId); + } + } + + $data += [ + 'accountGateway' => $accountGateway, + 'acceptedCreditCardTypes' => $acceptedCreditCardTypes, + 'gateway' => $gateway, + 'showAddress' => $accountGateway->show_address, + ]; + + if ($paymentType == PAYMENT_TYPE_STRIPE_ACH) { + $data['currencies'] = Cache::get('currencies'); + } + + if ($gateway->id == GATEWAY_BRAINTREE) { + $data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account); + } + + } else { + if ($deviceData = Input::get('details')) { + Session::put($invitation->id . 'device_data', $deviceData); + } + + Session::put($invitation->id . 'payment_type', PAYMENT_TYPE_BRAINTREE_PAYPAL); + $paypalDetails = json_decode(Input::get('details')); + if (!$sourceId || !$paypalDetails) { + return Redirect::to('view/'.$invitationKey); + } + $data['paypalDetails'] = $paypalDetails; } - $data = [ + $data += [ 'showBreadcrumbs' => false, 'url' => 'payment/'.$invitationKey, 'amount' => $invoice->getRequestedAmount(), 'invoiceNumber' => $invoice->invoice_number, 'client' => $client, 'contact' => $invitation->contact, - 'gateway' => $gateway, - 'accountGateway' => $accountGateway, - 'acceptedCreditCardTypes' => $acceptedCreditCardTypes, 'paymentType' => $paymentType, 'countries' => Cache::get('countries'), 'currencyId' => $client->getCurrencyId(), 'currencyCode' => $client->currency ? $client->currency->code : ($account->currency ? $account->currency->code : 'USD'), 'account' => $client->account, + 'sourceId' => $sourceId, 'clientFontUrl' => $client->account->getFontsUrl(), - 'showAddress' => $accountGateway->show_address, ]; - if ($paymentType == PAYMENT_TYPE_STRIPE_ACH) { - $data['currencies'] = Cache::get('currencies'); - } - - if ($gateway->id == GATEWAY_BRAINTREE) { - $data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account); - } - return View::make('payments.add_paymentmethod', $data); } @@ -381,7 +401,6 @@ class PaymentController extends BaseController $paymentType = Session::get($invitation->id . 'payment_type'); $accountGateway = $account->getGatewayByType($paymentType); - $rules = [ 'first_name' => 'required', 'last_name' => 'required', @@ -399,7 +418,9 @@ class PaymentController extends BaseController ); } - if ($accountGateway->show_address) { + $requireAddress = $accountGateway->show_address && $paymentType != PAYMENT_TYPE_STRIPE_ACH && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL; + + if ($requireAddress) { $rules = array_merge($rules, [ 'address1' => 'required', 'city' => 'required', @@ -418,7 +439,7 @@ class PaymentController extends BaseController ->withInput(Request::except('cvv')); } - if ($accountGateway->update_address) { + if ($requireAddress && $accountGateway->update_address) { $client->address1 = trim(Input::get('address1')); $client->address2 = trim(Input::get('address2')); $client->city = trim(Input::get('city')); @@ -471,6 +492,11 @@ class PaymentController extends BaseController } } } elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) { + $deviceData = Input::get('device_data'); + if (!$deviceData) { + $deviceData = Session::get($invitation->id . 'device_data'); + } + if ($token = Input::get('payment_method_nonce')) { $details['token'] = $token; unset($details['card']); @@ -496,6 +522,10 @@ class PaymentController extends BaseController return Redirect::to('payment/'.$invitationKey)->withInput(Request::except('cvv')); } } + + if($deviceData) { + $details['deviceData'] = $deviceData; + } } $response = $gateway->purchase($details)->send(); diff --git a/app/Http/Controllers/PublicClientController.php b/app/Http/Controllers/PublicClientController.php index 72e48c2e24..6f43314ad3 100644 --- a/app/Http/Controllers/PublicClientController.php +++ b/app/Http/Controllers/PublicClientController.php @@ -95,6 +95,7 @@ class PublicClientController extends BaseController 'phone', ]); + $data = array(); $paymentTypes = $this->getPaymentTypes($client, $invitation); $paymentURL = ''; if (count($paymentTypes) == 1) { @@ -104,6 +105,12 @@ class PublicClientController extends BaseController } } + if ($braintreeGateway = $account->getGatewayConfig(GATEWAY_BRAINTREE)){ + if($braintreeGateway->getPayPalEnabled()) { + $data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account); + } + } + $showApprove = $invoice->quote_invoice_id ? false : true; if ($invoice->due_date) { $showApprove = time() < strtotime($invoice->due_date); @@ -125,7 +132,7 @@ class PublicClientController extends BaseController } } - $data = array( + $data += array( 'account' => $account, 'showApprove' => $showApprove, 'showBreadcrumbs' => false, @@ -167,20 +174,28 @@ class PublicClientController extends BaseController if ($paymentMethod['type']->id == PAYMENT_TYPE_ACH) { $html = '
'.htmlentities($paymentMethod['bank_name']).'
'; + } elseif ($paymentMethod['type']->id == PAYMENT_TYPE_ID_PAYPAL) { + $html = ''.trans('; } else { $code = htmlentities(str_replace(' ', '', strtolower($paymentMethod['type']->name))); $html = ''.trans('; } - if ($paymentMethod['type']->id != PAYMENT_TYPE_ACH) { + $url = URL::to("/payment/{$invitation->invitation_key}/token/".$paymentMethod['id']); + + if ($paymentMethod['type']->id == PAYMENT_TYPE_ID_PAYPAL) { + $html .= '  '.$paymentMethod['email'].''; + $url .= '#braintree_paypal'; + } elseif ($paymentMethod['type']->id != PAYMENT_TYPE_ACH) { $html .= '
'.trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($paymentMethod['expiration'], false)->format('m/y'))).'
'; + $html .= '•••'.$paymentMethod['last4'].'
'; } else { $html .= '
'; + $html .= '•••'.$paymentMethod['last4'].'
'; } - $html .= '•••'.$paymentMethod['last4'].''; $paymentTypes[] = [ - 'url' => URL::to("/payment/{$invitation->invitation_key}/token/".$paymentMethod['id']), + 'url' => $url, 'label' => $html, ]; } @@ -219,6 +234,13 @@ class PublicClientController extends BaseController $paymentTypes[] = [ 'url' => $url, 'label' => $label ]; + + if($gateway->getPayPalEnabled()) { + $paymentTypes[] = [ + 'label' => trans('texts.paypal'), + 'url' => $url = URL::to("/payment/{$invitation->invitation_key}/braintree_paypal"), + ]; + } } } } @@ -270,6 +292,12 @@ class PublicClientController extends BaseController 'gateway' => $account->getTokenGateway(), 'paymentMethods' => $this->paymentService->getClientPaymentMethods($client), ]; + + if ($braintreeGateway = $account->getGatewayConfig(GATEWAY_BRAINTREE)){ + if($braintreeGateway->getPayPalEnabled()) { + $data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account); + } + } return response()->view('invited.dashboard', $data); } @@ -413,18 +441,21 @@ class PublicClientController extends BaseController ->addColumn('invoice_number', function ($model) { return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number; }) ->addColumn('transaction_reference', function ($model) { return $model->transaction_reference ? $model->transaction_reference : 'Manual entry'; }) ->addColumn('payment_type', function ($model) { return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? 'Online payment' : ''); }) - ->addColumn('payment_source', function ($model) { - if (!$model->last4) return ''; + ->addColumn('payment_source', function ($model) { $code = str_replace(' ', '', strtolower($model->payment_type)); $card_type = trans("texts.card_" . $code); if ($model->payment_type_id != PAYMENT_TYPE_ACH) { - $expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y'))); - return '' . htmlentities($card_type) . '  •••' . $model->last4 . ' ' . $expiration; - } else { + if($model->last4) { + $expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y'))); + return '' . htmlentities($card_type) . '  •••' . $model->last4 . ' ' . $expiration; + } elseif ($model->email) { + return $model->email; + } + } elseif ($model->last4) { $bankData = PaymentController::getBankData($model->routing_number); if (is_array($bankData)) { return $bankData['name'].'  •••' . $model->last4; - } else { + } elseif($model->last4) { return '' . htmlentities($card_type) . '  •••' . $model->last4; } } @@ -728,6 +759,12 @@ class PublicClientController extends BaseController 'title' => trans('texts.payment_methods') ); + if ($braintreeGateway = $account->getGatewayConfig(GATEWAY_BRAINTREE)){ + if($braintreeGateway->getPayPalEnabled()) { + $data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account); + } + } + return response()->view('payments.paymentmethods', $data); } @@ -771,7 +808,7 @@ class PublicClientController extends BaseController return redirect()->to($client->account->enable_client_portal?'/client/dashboard':'/client/paymentmethods/'); } - public function addPaymentMethod($paymentType) + public function addPaymentMethod($paymentType, $token=false) { if (!$invitation = $this->getInvitation()) { return $this->returnError(); @@ -785,6 +822,18 @@ class PublicClientController extends BaseController $paymentType = 'PAYMENT_TYPE_' . strtoupper($paymentType); $accountGateway = $invoice->client->account->getTokenGateway(); $gateway = $accountGateway->gateway; + + if ($token && $paymentType == PAYMENT_TYPE_BRAINTREE_PAYPAL) { + $sourceId = $this->paymentService->createToken($this->paymentService->createGateway($accountGateway), array('token'=>$token), $accountGateway, $client, $invitation->contact_id); + + if(empty($sourceId)) { + $this->paymentMethodError('Token-No-Ref', $this->paymentService->lastError, $accountGateway); + } else { + Session::flash('message', trans('texts.payment_method_added')); + } + return redirect()->to($account->enable_client_portal?'/client/dashboard':'/client/paymentmethods/'); + } + $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes(); diff --git a/app/Http/routes.php b/app/Http/routes.php index 82a5b00f2c..09d53a76b5 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -45,7 +45,7 @@ Route::group(['middleware' => 'auth:client'], function() { Route::match(['GET', 'POST'], 'complete', 'PaymentController@offsite_payment'); Route::get('client/paymentmethods', 'PublicClientController@paymentMethods'); Route::post('client/paymentmethods/verify', 'PublicClientController@verifyPaymentMethod'); - Route::get('client/paymentmethods/add/{payment_type}', 'PublicClientController@addPaymentMethod'); + Route::get('client/paymentmethods/add/{payment_type}/{source_id?}', 'PublicClientController@addPaymentMethod'); Route::post('client/paymentmethods/add/{payment_type}', 'PublicClientController@postAddPaymentMethod'); Route::post('client/paymentmethods/default', 'PublicClientController@setDefaultPaymentMethod'); Route::post('client/paymentmethods/{source_id}/remove', 'PublicClientController@removePaymentMethod'); @@ -638,6 +638,7 @@ if (!defined('CONTACT_EMAIL')) { define('PAYMENT_TYPE_EUROCARD', 11); define('PAYMENT_TYPE_NOVA', 12); define('PAYMENT_TYPE_CREDIT_CARD_OTHER', 13); + define('PAYMENT_TYPE_ID_PAYPAL', 14); define('PAYMENT_TYPE_CARTE_BLANCHE', 17); define('PAYMENT_TYPE_UNIONPAY', 18); define('PAYMENT_TYPE_JCB', 19); @@ -650,6 +651,7 @@ if (!defined('CONTACT_EMAIL')) { define('PAYMENT_TYPE_STRIPE', 'PAYMENT_TYPE_STRIPE'); define('PAYMENT_TYPE_STRIPE_CREDIT_CARD', 'PAYMENT_TYPE_STRIPE_CREDIT_CARD'); define('PAYMENT_TYPE_STRIPE_ACH', 'PAYMENT_TYPE_STRIPE_ACH'); + define('PAYMENT_TYPE_BRAINTREE_PAYPAL', 'PAYMENT_TYPE_BRAINTREE_PAYPAL'); define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD'); define('PAYMENT_TYPE_DIRECT_DEBIT', 'PAYMENT_TYPE_DIRECT_DEBIT'); define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN'); diff --git a/app/Models/Account.php b/app/Models/Account.php index 234d9a5b63..2915b4c86d 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -383,6 +383,15 @@ class Account extends Eloquent $type = PAYMENT_TYPE_STRIPE; } + if ($type == PAYMENT_TYPE_BRAINTREE_PAYPAL) { + $gateway = $this->getGatewayConfig(GATEWAY_BRAINTREE); + + if (!$gateway || !$gateway->getPayPalEnabled()){ + return false; + } + return $gateway; + } + foreach ($this->account_gateways as $gateway) { if (!$type || $type == PAYMENT_TYPE_ANY) { return $gateway; diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php index 13a990bb3a..6de95e8593 100644 --- a/app/Models/AccountGateway.php +++ b/app/Models/AccountGateway.php @@ -77,6 +77,11 @@ class AccountGateway extends EntityModel return !empty($this->getConfigField('enableAch')); } + public function getPayPAlEnabled() + { + return !empty($this->getConfigField('enablePayPal')); + } + public function getPlaidSecret() { if ( ! $this->isGateway(GATEWAY_STRIPE)) { diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php index 221cea40ce..b2022f2e19 100644 --- a/app/Ninja/Repositories/PaymentRepository.php +++ b/app/Ninja/Repositories/PaymentRepository.php @@ -56,6 +56,7 @@ class PaymentRepository extends BaseRepository 'payments.refunded', 'payments.expiration', 'payments.last4', + 'payments.email', 'payments.routing_number', 'invoices.is_deleted as invoice_is_deleted', 'gateways.name as gateway_name', @@ -119,6 +120,7 @@ class PaymentRepository extends BaseRepository 'payments.refunded', 'payments.expiration', 'payments.last4', + 'payments.email', 'payments.routing_number', 'payments.payment_status_id', 'payment_statuses.name as payment_status_name' diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 01d420eefd..3ec068ba91 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -234,6 +234,13 @@ class PaymentService extends BaseService 'last4' => $source->last4, 'expiration' => $source->expirationYear . '-' . $source->expirationMonth . '-00', ); + } elseif ($source instanceof \Braintree\PayPalAccount) { + $paymentMethods[] = array( + 'id' => $source->token, + 'default' => $source->isDefault(), + 'type' => $paymentTypes->find(PAYMENT_TYPE_ID_PAYPAL), + 'email' => $source->email, + ); } } } @@ -524,10 +531,16 @@ class PaymentService extends BaseService } } } elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) { - $card = $purchaseResponse->getData()->transaction->creditCardDetails; - $payment->last4 = $card->last4; - $payment->expiration = $card->expirationYear . '-' . $card->expirationMonth . '-00'; - $payment->payment_type_id = $this->parseCardType($card->cardType); + $transaction = $purchaseResponse->getData()->transaction; + if ($transaction->paymentInstrumentType == 'credit_card') { + $card = $transaction->creditCardDetails; + $payment->last4 = $card->last4; + $payment->expiration = $card->expirationYear . '-' . $card->expirationMonth . '-00'; + $payment->payment_type_id = $this->parseCardType($card->cardType); + } elseif ($transaction->paymentInstrumentType == 'paypal_account') { + $payment->payment_type_id = PAYMENT_TYPE_ID_PAYPAL; + $payment->email = $transaction->paypalDetails->payerEmail; + } } if ($payerId) { @@ -734,17 +747,20 @@ class PaymentService extends BaseService [ 'source', function ($model) { - if (!$model->last4) return ''; $code = str_replace(' ', '', strtolower($model->payment_type)); $card_type = trans("texts.card_" . $code); if ($model->payment_type_id != PAYMENT_TYPE_ACH) { - $expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y'))); - return '' . htmlentities($card_type) . '  •••' . $model->last4 . ' ' . $expiration; - } else { + if($model->last4) { + $expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y'))); + return '' . htmlentities($card_type) . '  •••' . $model->last4 . ' ' . $expiration; + } elseif ($model->email) { + return $model->email; + } + } elseif ($model->last4) { $bankData = PaymentController::getBankData($model->routing_number); if (is_array($bankData)) { return $bankData['name'].'  •••' . $model->last4; - } else { + } elseif($model->last4) { return '' . htmlentities($card_type) . '  •••' . $model->last4; } } diff --git a/database/migrations/2016_04_23_182223_payments_changes.php b/database/migrations/2016_04_23_182223_payments_changes.php index 1f8c2037fe..fea4e73977 100644 --- a/database/migrations/2016_04_23_182223_payments_changes.php +++ b/database/migrations/2016_04_23_182223_payments_changes.php @@ -32,6 +32,7 @@ class PaymentsChanges extends Migration $table->smallInteger('last4')->unsigned()->nullable(); $table->date('expiration')->nullable(); $table->text('gateway_error')->nullable(); + $table->string('email')->nullable(); }); Schema::table('invoices', function($table) @@ -61,6 +62,7 @@ class PaymentsChanges extends Migration $table->dropColumn('last4'); $table->dropColumn('expiration'); $table->dropColumn('gateway_error'); + $table->dropColumn('email'); }); Schema::table('invoices', function ($table) { diff --git a/public/images/credit_cards/paypa.png b/public/images/credit_cards/paypal.png similarity index 100% rename from public/images/credit_cards/paypa.png rename to public/images/credit_cards/paypal.png diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 5ff2f333d8..70f585bc0f 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1276,7 +1276,13 @@ $LANG = array( 'disabled_by_client' => 'Disabled by client', 'manage_auto_bill' => 'Manage Auto-bill', 'enabled' => 'Enabled', - '' + 'paypal' => 'PayPal', + 'braintree_enable_paypal' => 'Enable PayPal payments through BrainTree', + 'braintree_paypal_disabled_help' => 'The PayPal gateway is processing PayPal payments', + 'braintree_paypal_help' => 'You must also :link.', + 'braintree_paypal_help_link_text' => 'link PayPal to your BrainTree account', + 'token_billing_braintree_paypal' => 'Save payment details', + 'add_paypal_account' => 'Add PayPal Account' ); return $LANG; diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php index 4d4e79d7a1..bd5f100671 100644 --- a/resources/views/accounts/account_gateway.blade.php +++ b/resources/views/accounts/account_gateway.blade.php @@ -23,6 +23,7 @@ {!! Former::populateField('update_address', intval($accountGateway->update_address)) !!} {!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!} {!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? '1' : null) !!} + {!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? '1' : null) !!} {!! Former::populateField('plaid_client_id', $accountGateway->getPlaidClientId() ? str_repeat('*', strlen($accountGateway->getPlaidClientId())) : '') !!} {!! Former::populateField('plaid_secret', $accountGateway->getPlaidSecret() ? str_repeat('*', strlen($accountGateway->getPlaidSecret())) : '') !!} {!! Former::populateField('plaid_public_key', $accountGateway->getPlaidPublicKey() ? str_repeat('*', strlen($accountGateway->getPlaidPublicKey())) : '') !!} @@ -95,6 +96,25 @@ ->options($tokenBillingOptions) ->help(trans('texts.token_billing_help')) !!} @endif + + @if ($gateway->id == GATEWAY_BRAINTREE) + @if ($account->getGatewayByType(PAYMENT_TYPE_PAYPAL)) + {!! Former::checkbox('enable_paypal') + ->label(trans('texts.paypal')) + ->text(trans('texts.braintree_enable_paypal')) + ->value(null) + ->disabled(true) + ->help(trans('texts.braintree_paypal_disabled_help')) !!} + @else + {!! Former::checkbox('enable_paypal') + ->label(trans('texts.paypal')) + ->help(trans('texts.braintree_paypal_help', [ + 'link'=>''. + trans('texts.braintree_paypal_help_link_text').'' + ])) + ->text(trans('texts.braintree_enable_paypal')) !!} + @endif + @endif @endforeach diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index f6aebb6cb7..31c8f68a9e 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -21,6 +21,45 @@ margin-bottom:5px; } + + @if (!empty($braintreeClientToken)) + + + @endif @stop @section('content') diff --git a/resources/views/payments/add_paymentmethod.blade.php b/resources/views/payments/add_paymentmethod.blade.php index b2e13dcac8..5e49b08d6f 100644 --- a/resources/views/payments/add_paymentmethod.blade.php +++ b/resources/views/payments/add_paymentmethod.blade.php @@ -64,7 +64,7 @@ }); }); - @elseif ($accountGateway->getPublishableStripeKey()) + @elseif (isset($accountGateway) && $accountGateway->getPublishableStripeKey()) - @if ($accountGateway->getPlaidEnabled()) + @if (isset($accountGateway) && $accountGateway->getPlaidEnabled()) @endif diff --git a/resources/views/payments/paymentmethods_list.blade.php b/resources/views/payments/paymentmethods_list.blade.php index caff836535..3436315acf 100644 --- a/resources/views/payments/paymentmethods_list.blade.php +++ b/resources/views/payments/paymentmethods_list.blade.php @@ -16,28 +16,65 @@ display:inline-block; } +@if (!empty($braintreeClientToken)) + + +@endif @if(!empty($paymentMethods)) @foreach ($paymentMethods as $paymentMethod)
{{trans(name)))}}"> + @if(!empty($paymentMethod['last4'])) •••••{{$paymentMethod['last4']}} + @endif @if($paymentMethod['type']->id == PAYMENT_TYPE_ACH) - {{ $paymentMethod['bank_name'] }} - @if($paymentMethod['status'] == 'new') - ({{trans('texts.complete_verification')}}) - @elseif($paymentMethod['status'] == 'verification_failed') - ({{trans('texts.verification_failed')}}) - @endif + {{ $paymentMethod['bank_name'] }} + @if($paymentMethod['status'] == 'new') + ({{trans('texts.complete_verification')}}) + @elseif($paymentMethod['status'] == 'verification_failed') + ({{trans('texts.verification_failed')}}) + @endif + @elseif($paymentMethod['type']->id == PAYMENT_TYPE_ID_PAYPAL) + {{ $paymentMethod['email'] }} @else - {!! trans('texts.card_expiration', array('expires'=>Utils::fromSqlDate($paymentMethod['expiration'], false)->format('m/y'))) !!} + {!! trans('texts.card_expiration', array('expires'=>Utils::fromSqlDate($paymentMethod['expiration'], false)->format('m/y'))) !!} @endif @if($paymentMethod['default']) - ({{trans('texts.used_for_auto_bill')}}) + ({{trans('texts.used_for_auto_bill')}}) @elseif($paymentMethod['type']->id != PAYMENT_TYPE_ACH || $paymentMethod['status'] == 'verified') - ({{trans('texts.use_for_auto_bill')}}) + ({{trans('texts.use_for_auto_bill')}}) @endif ×
@@ -49,8 +86,15 @@ ->asLinkTo(URL::to('/client/paymentmethods/add/'.($gateway->getPaymentType() == PAYMENT_TYPE_STRIPE ? 'stripe_credit_card' : 'credit_card'))) !!} @if($gateway->getACHEnabled())   - {!! Button::success(strtoupper(trans('texts.add_bank_account'))) - ->asLinkTo(URL::to('/client/paymentmethods/add/stripe_ach')) !!} + {!! Button::success(strtoupper(trans('texts.add_bank_account'))) + ->asLinkTo(URL::to('/client/paymentmethods/add/stripe_ach')) !!} + @endif + @if($gateway->getPayPalEnabled()) +   + {!! Button::success(strtoupper(trans('texts.add_paypal_account'))) + ->withAttributes(['id'=>'add-paypal']) + ->asLinkTo(URL::to('/client/paymentmethods/add/braintree_paypal')) !!} +
@endif