From a952d90c24830fc8d338a61b06d6f9a7114c21fc Mon Sep 17 00:00:00 2001 From: blkmutt Date: Wed, 9 Apr 2014 22:33:32 -0400 Subject: [PATCH] Updated Payments and routes to support additional PHP-Payments gateways. Masked account info on payments page. --- app/controllers/AccountController.php | 9 ++++++- app/controllers/PaymentController.php | 37 ++++++++++++++++++++++----- app/routes.php | 8 ++++++ 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 64c2c729cab9..867a75091181 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -191,10 +191,17 @@ class AccountController extends \BaseController { $recommendedGatewayArray[$recommendedGateway->name] = $arrayItem; } + $configFields = json_decode($config); + + foreach($configFields as $configField => $value) + { + $configFields->$configField = str_repeat('*', strlen($value)); + } + $data = [ 'account' => $account, 'accountGateway' => $accountGateway, - 'config' => json_decode($config), + 'config' => $configFields, 'gateways' => Gateway::remember(DEFAULT_QUERY_CACHE) ->orderBy('name') ->get(), diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index d1f46ec02b09..285d4ed87259 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -177,12 +177,17 @@ class PaymentController extends \BaseController 'currency_code' => $invoice->client->currency->code, ]; - if(strtolower($gateway->name) == 'beanstream') + switch($gateway->id) { - $data['phone'] = $input['phone']; - $data['email'] = $input['email']; - $data['country'] = $input['country']; - $data['ship_to_country'] = $input['country']; + case GATEWAY_BEANSTREAM: + $data['phone'] = $input['phone']; + $data['email'] = $input['email']; + $data['country'] = $input['country']; + $data['ship_to_country'] = $input['country']; + break; + case GATEWAY_BRAINTREE: + $data['ship_to_state'] = 'Ohio'; //$input['state']; + break; } if(strlen($data['cc_exp']) == 5) @@ -345,10 +350,28 @@ class PaymentController extends \BaseController } else if ($paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) { - $provider = $accountGateway->gateway->provider; - $p = new PHP_Payments; + $gateway = $accountGateway->gateway; + $provider = $gateway->provider; + $p = new PHP_Payments(array('mode' => 'test')); $config = Payment_Utility::load('config', 'drivers/'.$provider); + + switch($gateway->id) + { + case GATEWAY_BEANSTREAM: + $config['delay_charge'] = FALSE; + $config['bill_outstanding'] = TRUE; + break; + case GATEWAY_AMAZON: + $config['return_url'] = URL::to('complete'); + $config['abandon_url'] = URL::to('/'); + $config['immediate_return'] = 0; + $config['process_immediate'] = 1; + $config['ipn_url'] = URL::to('ipn'); + $config['collect_shipping_address'] = false; + break; + } + $details = self::getPaymentDetails($invoice, Input::all()); $response = $p->oneoff_payment($provider, $details, $config); diff --git a/app/routes.php b/app/routes.php index 56a6b007cdad..f5a0eab6a4c3 100755 --- a/app/routes.php +++ b/app/routes.php @@ -237,6 +237,14 @@ define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h'); define('PAYMENT_LIBRARY_OMNIPAY', 1); define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2); +define('GATEWAY_BEANSTREAM', 29); +define('GATEWAY_AMAZON', 30); +define('GATEWAY_BLUEPAY', 31); +define('GATEWAY_BRAINTREE', 32); +define('GATEWAY_GOOGLE', 33); +define('GATEWAY_PSIGATE', 34); +define('GATEWAY_QUICKBOOKS', 35); + if (Auth::check() && !Session::has(SESSION_TIMEZONE)) { Event::fire('user.refresh');