Merge pull request #5 from hillelcoren/master

Update fork
This commit is contained in:
Paul-Vincent Roll 2015-03-05 20:41:46 +01:00
commit dc5e256157
34 changed files with 974 additions and 423 deletions

View File

@ -97,7 +97,6 @@ class AccountController extends \BaseController
public function getSearchData() public function getSearchData()
{ {
$data = $this->accountRepo->getSearchData(); $data = $this->accountRepo->getSearchData();
return Response::json($data); return Response::json($data);
} }
@ -119,94 +118,16 @@ class AccountController extends \BaseController
return View::make('accounts.details', $data); return View::make('accounts.details', $data);
} elseif ($section == ACCOUNT_PAYMENTS) { } elseif ($section == ACCOUNT_PAYMENTS) {
$account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id);
$accountGateway = null;
$config = null;
$configFields = null;
$selectedCards = 0;
if (count($account->account_gateways) > 0) { $account = Auth::user()->account;
$accountGateway = $account->account_gateways[0]; $account->load('account_gateways');
$config = $accountGateway->config; $count = count($account->account_gateways);
$selectedCards = $accountGateway->accepted_credit_cards;
if ($count == 0) {
$configFields = json_decode($config); return Redirect::to('gateways/create');
foreach ($configFields as $configField => $value) {
$configFields->$configField = str_repeat('*', strlen($value));
}
} else { } else {
$accountGateway = AccountGateway::createNew(); return View::make('accounts.payments', ['showAdd' => $count < 2]);
$accountGateway->gateway_id = GATEWAY_MOOLAH;
} }
$recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE)
->where('recommended', '=', '1')
->orderBy('sort_order')
->get();
$recommendedGatewayArray = array();
foreach ($recommendedGateways as $recommendedGateway) {
$arrayItem = array(
'value' => $recommendedGateway->id,
'other' => 'false',
'data-imageUrl' => asset($recommendedGateway->getLogoUrl()),
'data-siteUrl' => $recommendedGateway->site_url,
);
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach ($creditCardsArray as $card => $name) {
if ($selectedCards > 0 && ($selectedCards & $card) == $card) {
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
} else {
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
}
}
$otherItem = array(
'value' => 1000000,
'other' => 'true',
'data-imageUrl' => '',
'data-siteUrl' => '',
);
$recommendedGatewayArray['Other Options'] = $otherItem;
$gateways = Gateway::remember(DEFAULT_QUERY_CACHE)->where('payment_library_id', '=', 1)->orderBy('name')->get();
foreach ($gateways as $gateway) {
$paymentLibrary = $gateway->paymentlibrary;
$gateway->fields = $gateway->getFields();
if ($accountGateway && $accountGateway->gateway_id == $gateway->id) {
$accountGateway->fields = $gateway->fields;
}
}
$tokenBillingOptions = [];
for ($i=1; $i<=4; $i++) {
$tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
}
$data = [
'account' => $account,
'accountGateway' => $accountGateway,
'config' => $configFields,
'gateways' => $gateways,
'dropdownGateways' => Gateway::remember(DEFAULT_QUERY_CACHE)
->where('recommended', '=', '0')
->where('payment_library_id', '=', 1)
->orderBy('name')
->get(),
'recommendedGateways' => $recommendedGatewayArray,
'creditCardTypes' => $creditCards,
'tokenBillingOptions' => $tokenBillingOptions,
];
return View::make('accounts.payments', $data);
} elseif ($section == ACCOUNT_NOTIFICATIONS) { } elseif ($section == ACCOUNT_NOTIFICATIONS) {
$data = [ $data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
@ -272,8 +193,6 @@ class AccountController extends \BaseController
{ {
if ($section == ACCOUNT_DETAILS) { if ($section == ACCOUNT_DETAILS) {
return AccountController::saveDetails(); return AccountController::saveDetails();
} elseif ($section == ACCOUNT_PAYMENTS) {
return AccountController::savePayments();
} elseif ($section == ACCOUNT_IMPORT_EXPORT) { } elseif ($section == ACCOUNT_IMPORT_EXPORT) {
return AccountController::importFile(); return AccountController::importFile();
} elseif ($section == ACCOUNT_MAP) { } elseif ($section == ACCOUNT_MAP) {
@ -614,102 +533,6 @@ class AccountController extends \BaseController
return Redirect::to('company/notifications'); return Redirect::to('company/notifications');
} }
private function savePayments()
{
$rules = array();
$recommendedId = Input::get('recommendedGateway_id');
if ($gatewayId = $recommendedId == 1000000 ? Input::get('gateway_id') : $recommendedId) {
$gateway = Gateway::findOrFail($gatewayId);
$paymentLibrary = $gateway->paymentlibrary;
$fields = $gateway->getFields();
foreach ($fields as $field => $details) {
if (!in_array($field, ['testMode', 'developerMode', 'headerImageUrl', 'solutionType', 'landingPage', 'brandName', 'logoImageUrl', 'borderColor'])) {
if (strtolower($gateway->name) == 'beanstream') {
if (in_array($field, ['merchant_id', 'passCode'])) {
$rules[$gateway->id.'_'.$field] = 'required';
}
} else {
$rules[$gateway->id.'_'.$field] = 'required';
}
}
}
}
$creditcards = Input::get('creditCardTypes');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('company/payments')
->withErrors($validator)
->withInput();
} else {
$account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id);
if ($gatewayId) {
$accountGateway = AccountGateway::createNew();
$accountGateway->gateway_id = $gatewayId;
$isMasked = false;
$config = new stdClass();
foreach ($fields as $field => $details) {
$value = trim(Input::get($gateway->id.'_'.$field));
if ($value && $value === str_repeat('*', strlen($value))) {
$isMasked = true;
}
$config->$field = $value;
}
$cardCount = 0;
if ($creditcards) {
foreach ($creditcards as $card => $value) {
$cardCount += intval($value);
}
}
// check if a gateway is already configured
$currentGateway = false;
if (count($account->account_gateways)) {
$currentGateway = $account->account_gateways[0];
}
// if the values haven't changed don't update the config
if ($isMasked && $currentGateway) {
$currentGateway->accepted_credit_cards = $cardCount;
$currentGateway->save();
// if there's an existing config for this gateway update it
} elseif (!$isMasked && $currentGateway && $currentGateway->gateway_id == $gatewayId) {
$currentGateway->accepted_credit_cards = $cardCount;
$currentGateway->config = json_encode($config);
$currentGateway->save();
// otherwise, create a new gateway config
} else {
$accountGateway->config = json_encode($config);
$accountGateway->accepted_credit_cards = $cardCount;
$account->account_gateways()->delete();
$account->account_gateways()->save($accountGateway);
}
if (Input::get('token_billing_type_id')) {
$account->token_billing_type_id = Input::get('token_billing_type_id');
$account->save();
}
Session::flash('message', trans('texts.updated_settings'));
} else {
Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));
}
return Redirect::to('company/payments');
}
}
private function saveDetails() private function saveDetails()
{ {
$rules = array( $rules = array(

View File

@ -0,0 +1,292 @@
<?php
/*
|--------------------------------------------------------------------------
| Confide Controller Template
|--------------------------------------------------------------------------
|
| This is the default Confide controller template for controlling user
| authentication. Feel free to change to your needs.
|
*/
use ninja\repositories\AccountRepository;
class AccountGatewayController extends BaseController
{
public function getDatatable()
{
$query = \DB::table('account_gateways')
->join('gateways', 'gateways.id', '=', 'account_gateways.gateway_id')
->where('account_gateways.deleted_at', '=', null)
->where('account_gateways.account_id', '=', \Auth::user()->account_id)
->select('account_gateways.public_id', 'gateways.name', 'account_gateways.deleted_at');
return Datatable::query($query)
->addColumn('name', function ($model) { return link_to('gateways/'.$model->public_id.'/edit', $model->name); })
->addColumn('dropdown', function ($model) {
$actions = '<div class="btn-group tr-action" style="visibility:hidden;">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
'.trans('texts.select').' <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">';
if (!$model->deleted_at) {
$actions .= '<li><a href="'.URL::to('gateways/'.$model->public_id).'/edit">'.uctrans('texts.edit_gateway').'</a></li>
<li class="divider"></li>
<li><a href="javascript:deleteAccountGateway('.$model->public_id.')">'.uctrans('texts.delete_gateway').'</a></li>';
}
$actions .= '</ul>
</div>';
return $actions;
})
->orderColumns(['name'])
->make();
}
public function edit($publicId)
{
$accountGateway = AccountGateway::scope($publicId)->firstOrFail();
$config = $accountGateway->config;
$selectedCards = $accountGateway->accepted_credit_cards;
$configFields = json_decode($config);
foreach ($configFields as $configField => $value) {
$configFields->$configField = str_repeat('*', strlen($value));
}
$data = self::getViewModel($accountGateway);
$data['url'] = 'gateways/'.$publicId;
$data['method'] = 'PUT';
$data['title'] = trans('texts.edit_gateway') . ' - ' . $accountGateway->gateway->name;
$data['config'] = $configFields;
return View::make('accounts.account_gateway', $data);
}
public function update($publicId)
{
return $this->save($publicId);
}
public function store()
{
return $this->save();
}
/**
* Displays the form for account creation
*
*/
public function create()
{
$data = self::getViewModel();
$data['url'] = 'gateways';
$data['method'] = 'POST';
$data['title'] = trans('texts.add_gateway');
return View::make('accounts.account_gateway', $data);
}
private function getViewModel($accountGateway = false)
{
$selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
$account = Auth::user()->account;
$recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE)
->where('recommended', '=', '1')
->orderBy('sort_order')
->get();
$recommendedGatewayArray = array();
foreach ($recommendedGateways as $recommendedGateway) {
$arrayItem = array(
'value' => $recommendedGateway->id,
'other' => 'false',
'data-imageUrl' => asset($recommendedGateway->getLogoUrl()),
'data-siteUrl' => $recommendedGateway->site_url,
);
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach ($creditCardsArray as $card => $name) {
if ($selectedCards > 0 && ($selectedCards & $card) == $card) {
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
} else {
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
}
}
$otherItem = array(
'value' => 1000000,
'other' => 'true',
'data-imageUrl' => '',
'data-siteUrl' => '',
);
$recommendedGatewayArray['Other Options'] = $otherItem;
$account->load('account_gateways');
$currentGateways = $account->account_gateways;
$gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name');
$onlyPayPal = false;
if (!$accountGateway) {
if (count($currentGateways) > 0) {
$currentGateway = $currentGateways[0];
if ($currentGateway->isPayPal()) {
$gateways->where('id', '!=', GATEWAY_PAYPAL_EXPRESS);
} else {
$gateways->where('id', '=', GATEWAY_PAYPAL_EXPRESS);
$onlyPayPal = true;
}
}
}
$gateways = $gateways->get();
foreach ($gateways as $gateway) {
$paymentLibrary = $gateway->paymentlibrary;
$gateway->fields = $gateway->getFields();
if ($accountGateway && $accountGateway->gateway_id == $gateway->id) {
$accountGateway->fields = $gateway->fields;
}
}
$tokenBillingOptions = [];
for ($i=1; $i<=4; $i++) {
$tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
}
return [
'account' => $account,
'accountGateway' => $accountGateway,
'config' => false,
'gateways' => $gateways,
'recommendedGateways' => $recommendedGatewayArray,
'creditCardTypes' => $creditCards,
'tokenBillingOptions' => $tokenBillingOptions,
'showBreadcrumbs' => false,
'onlyPayPal' => $onlyPayPal,
'countGateways' => count($currentGateways)
];
}
public function delete()
{
$accountGatewayPublicId = Input::get('accountGatewayPublicId');
$gateway = AccountGateway::scope($accountGatewayPublicId)->firstOrFail();
$gateway->delete();
Session::flash('message', trans('texts.deleted_gateway'));
return Redirect::to('company/payments');
}
/**
* Stores new account
*
*/
public function save($accountGatewayPublicId = false)
{
$rules = array();
$recommendedId = Input::get('recommendedGateway_id');
$gatewayId = ($recommendedId == 1000000 ? Input::get('gateway_id') : $recommendedId);
if (!$gatewayId) {
Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));
return Redirect::to('gateways/create')
->withInput();
}
$gateway = Gateway::findOrFail($gatewayId);
$paymentLibrary = $gateway->paymentlibrary;
$fields = $gateway->getFields();
foreach ($fields as $field => $details) {
if (!in_array($field, ['testMode', 'developerMode', 'headerImageUrl', 'solutionType', 'landingPage', 'brandName', 'logoImageUrl', 'borderColor'])) {
if (strtolower($gateway->name) == 'beanstream') {
if (in_array($field, ['merchant_id', 'passCode'])) {
$rules[$gateway->id.'_'.$field] = 'required';
}
} else {
$rules[$gateway->id.'_'.$field] = 'required';
}
}
}
$creditcards = Input::get('creditCardTypes');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('gateways/create')
->withErrors($validator)
->withInput();
} else {
$account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id);
if ($accountGatewayPublicId) {
$accountGateway = AccountGateway::scope($accountGatewayPublicId)->firstOrFail();
} else {
$accountGateway = AccountGateway::createNew();
$accountGateway->gateway_id = $gatewayId;
}
$isMasked = false;
$config = new stdClass();
foreach ($fields as $field => $details) {
$value = trim(Input::get($gateway->id.'_'.$field));
if ($value && $value === str_repeat('*', strlen($value))) {
$isMasked = true;
}
$config->$field = $value;
}
$cardCount = 0;
if ($creditcards) {
foreach ($creditcards as $card => $value) {
$cardCount += intval($value);
}
}
// if the values haven't changed don't update the config
if ($isMasked && $accountGatewayPublicId) {
$accountGateway->accepted_credit_cards = $cardCount;
$accountGateway->save();
// if there's an existing config for this gateway update it
} elseif (!$isMasked && $accountGatewayPublicId && $accountGateway->gateway_id == $gatewayId) {
$accountGateway->accepted_credit_cards = $cardCount;
$accountGateway->config = json_encode($config);
$accountGateway->save();
// otherwise, create a new gateway config
} else {
$accountGateway->config = json_encode($config);
$accountGateway->accepted_credit_cards = $cardCount;
$account->account_gateways()->save($accountGateway);
}
if (Input::get('token_billing_type_id')) {
$account->token_billing_type_id = Input::get('token_billing_type_id');
$account->save();
}
if ($accountGatewayPublicId) {
$message = trans('texts.updated_gateway');
} else {
$message = trans('texts.created_gateway');
}
Session::flash('message', $message);
return Redirect::to('company/payments');
}
}
}

View File

@ -167,8 +167,8 @@ class InvoiceController extends \BaseController
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date); $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
$invoice->due_date = Utils::fromSqlDate($invoice->due_date); $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
$invoice->is_pro = $client->account->isPro(); $invoice->is_pro = $client->account->isPro();
$contact = $invitation->contact; $contact = $invitation->contact;
$contact->setVisible([ $contact->setVisible([
'first_name', 'first_name',
@ -184,7 +184,8 @@ class InvoiceController extends \BaseController
'invitation' => $invitation, 'invitation' => $invitation,
'invoiceLabels' => $client->account->getInvoiceLabels(), 'invoiceLabels' => $client->account->getInvoiceLabels(),
'contact' => $contact, 'contact' => $contact,
'hasToken' => $client->getGatewayToken() 'hasToken' => $client->getGatewayToken(),
'countGateways' => AccountGateway::scope()->count(),
); );
return View::make('invoices.view', $data); return View::make('invoices.view', $data);

View File

@ -226,7 +226,7 @@ class PaymentController extends \BaseController
private function getPaymentDetails($invoice, $input = null) private function getPaymentDetails($invoice, $input = null)
{ {
$key = $invoice->invoice_number.'_details'; $key = $invoice->invoice_number.'_details';
$gateway = $invoice->client->account->account_gateways[0]->gateway; $gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
$paymentLibrary = $gateway->paymentlibrary; $paymentLibrary = $gateway->paymentlibrary;
$currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD'); $currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD');
@ -301,10 +301,25 @@ class PaymentController extends \BaseController
if (Input::get('use_token') == 'true') { if (Input::get('use_token') == 'true') {
return self::do_payment($invitationKey, false, true); return self::do_payment($invitationKey, false, true);
} }
// For PayPal Express we redirect straight to their site
$invitation = Invitation::with('invoice.client.account', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail(); if (Input::has('use_paypal')) {
$account = $invitation->invoice->client->account; Session::put('payment_type', Input::get('use_paypal') == 'true' ? PAYMENT_TYPE_PAYPAL : PAYMENT_TYPE_CREDIT_CARD);
if ($account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) { } elseif (!Session::has('payment_type')) {
Session::put('payment_type', PAYMENT_TYPE_ANY);
}
// For PayPal we redirect straight to their site
$usePayPal = false;
if ($usePayPal = Input::get('use_paypal')) {
$usePayPal = $usePayPal == 'true';
} else {
$invitation = Invitation::with('invoice.client.account', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$account = $invitation->invoice->client->account;
if (count($account->account_gateways) == 1 && $account->getGatewayByType(PAYMENT_TYPE_PAYPAL)) {
$usePayPal = true;
}
}
if ($usePayPal) {
if (Session::has('error')) { if (Session::has('error')) {
Session::reflash(); Session::reflash();
return Redirect::to('view/'.$invitationKey); return Redirect::to('view/'.$invitationKey);
@ -316,8 +331,8 @@ class PaymentController extends \BaseController
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail(); $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$client = $invoice->client; $client = $invoice->client;
$accountGateway = $invoice->client->account->account_gateways[0]; $accountGateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'));
$gateway = $invoice->client->account->account_gateways[0]->gateway; $gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
$paymentLibrary = $gateway->paymentlibrary; $paymentLibrary = $gateway->paymentlibrary;
$acceptedCreditCardTypes = $accountGateway->getCreditcardTypes(); $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
@ -363,7 +378,7 @@ class PaymentController extends \BaseController
$account = $this->accountRepo->getNinjaAccount(); $account = $this->accountRepo->getNinjaAccount();
$account->load('account_gateways.gateway'); $account->load('account_gateways.gateway');
$accountGateway = $account->account_gateways[0]; $accountGateway = $account->getGatewayByType(Session::get('payment_type'));
$gateway = $accountGateway->gateway; $gateway = $accountGateway->gateway;
$paymentLibrary = $gateway->paymentlibrary; $paymentLibrary = $gateway->paymentlibrary;
$acceptedCreditCardTypes = $accountGateway->getCreditcardTypes(); $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
@ -415,7 +430,7 @@ class PaymentController extends \BaseController
$account = $this->accountRepo->getNinjaAccount(); $account = $this->accountRepo->getNinjaAccount();
$account->load('account_gateways.gateway'); $account->load('account_gateways.gateway');
$accountGateway = $account->account_gateways[0]; $accountGateway = $account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD);
try { try {
$affiliate = Affiliate::find(Session::get('affiliate_id')); $affiliate = Affiliate::find(Session::get('affiliate_id'));
@ -527,7 +542,7 @@ class PaymentController extends \BaseController
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$client = $invoice->client; $client = $invoice->client;
$account = $client->account; $account = $client->account;
$accountGateway = $account->account_gateways[0]; $accountGateway = $account->getGatewayByType(Session::get('payment_type'));
$paymentLibrary = $accountGateway->gateway->paymentlibrary; $paymentLibrary = $accountGateway->gateway->paymentlibrary;
if ($onSite) { if ($onSite) {
@ -542,7 +557,7 @@ class PaymentController extends \BaseController
try { try {
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) { if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
$gateway = self::createGateway($accountGateway); $gateway = self::createGateway($accountGateway);
$details = self::getPaymentDetails($invoice, $useToken ? false : Input::all()); $details = self::getPaymentDetails($invoice, $useToken || !$onSite ? false : Input::all());
if ($accountGateway->gateway_id == GATEWAY_STRIPE) { if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
if ($useToken) { if ($useToken) {
@ -572,10 +587,14 @@ class PaymentController extends \BaseController
$ref = $response->getTransactionReference(); $ref = $response->getTransactionReference();
if (!$ref) { if (!$ref) {
Session::flash('error', $response->getMessage()); Session::flash('error', $response->getMessage());
return Redirect::to('payment/'.$invitationKey) if ($onSite) {
->withInput(); return Redirect::to('payment/'.$invitationKey)->withInput();
} else {
return Redirect::to('view/'.$invitationKey);
}
} }
if ($response->isSuccessful()) { if ($response->isSuccessful()) {
@ -587,64 +606,31 @@ class PaymentController extends \BaseController
$invitation->transaction_reference = $ref; $invitation->transaction_reference = $ref;
$invitation->save(); $invitation->save();
Session::save();
$response->redirect(); $response->redirect();
} else { } else {
Session::flash('error', $response->getMessage()); Session::flash('error', $response->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage()); return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
} }
} elseif ($paymentLibrary->id == PAYMENT_LIBRARY_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);
if (strtolower($response->status) == 'success') {
$payment = self::createPayment($invitation, $response->response_message);
Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/'.$payment->invitation->invitation_key);
} else {
Session::flash('error', $response->response_message);
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->response_message);
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$errorMessage = trans('texts.payment_error'); $errorMessage = trans('texts.payment_error');
Session::flash('error', $errorMessage."<p>".$e->getMessage()); Session::flash('error', $errorMessage."<p>".$e->getMessage());
Utils::logError(Utils::getErrorString($e)); Utils::logError(Utils::getErrorString($e));
return Redirect::to('payment/'.$invitationKey) if ($onSite) {
->withInput(); return Redirect::to('payment/'.$invitationKey)->withInput();
} else {
return Redirect::to('view/'.$invitationKey);
}
} }
} }
private function createPayment($invitation, $ref, $payerId = null) private function createPayment($invitation, $ref, $payerId = null)
{ {
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$accountGateway = $invoice->client->account->account_gateways[0]; $accountGateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'));
if ($invoice->account->account_key == NINJA_ACCOUNT_KEY) { if ($invoice->account->account_key == NINJA_ACCOUNT_KEY) {
$account = Account::find($invoice->client->public_id); $account = Account::find($invoice->client->public_id);
@ -681,7 +667,7 @@ class PaymentController extends \BaseController
$invitation = Invitation::with('invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('transaction_reference', '=', $token)->firstOrFail(); $invitation = Invitation::with('invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('transaction_reference', '=', $token)->firstOrFail();
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$accountGateway = $invoice->client->account->account_gateways[0]; $accountGateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'));
$gateway = self::createGateway($accountGateway); $gateway = self::createGateway($accountGateway);
try { try {

View File

@ -478,4 +478,30 @@ class UserController extends BaseController
return Redirect::to('/')->with('clearGuestKey', true); return Redirect::to('/')->with('clearGuestKey', true);
} }
public function changePassword()
{
// check the current password is correct
if (!Auth::validate([
'email' => Auth::user()->email,
'password' => Input::get('current_password')
])) {
return trans('texts.password_error_incorrect');
}
// validate the new password
$password = Input::get('new_password');
$confirm = Input::get('confirm_password');
if (strlen($password) < 6 || $password != $confirm) {
return trans('texts.password_error_invalid');
}
// save the new password
$user = Auth::user();
$user->password = $password;
$user->save();
return RESULT_SUCCESS;
}
} }

View File

@ -184,8 +184,13 @@ Route::filter('api.access', function()
Auth::loginUsingId($token->user_id); Auth::loginUsingId($token->user_id);
Session::set('token_id', $token->id); Session::set('token_id', $token->id);
} else { } else {
sleep(3);
return Response::make('Invalid token', 403, $headers); return Response::make('Invalid token', 403, $headers);
} }
if (!Utils::isNinja()) {
return null;
}
if (!Utils::isPro()) { if (!Utils::isPro()) {
return Response::make('API requires pro plan', 403, $headers); return Response::make('API requires pro plan', 403, $headers);

View File

@ -466,7 +466,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -532,7 +532,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -549,6 +549,23 @@ return array(
'edit_token' => 'Edit Token', 'edit_token' => 'Edit Token',
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -539,6 +539,23 @@ return array(
'edit_token' => 'Token bearbeiten', 'edit_token' => 'Token bearbeiten',
'delete_token' => 'Token löschen', 'delete_token' => 'Token löschen',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -464,7 +464,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -530,7 +530,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default <b>invoice footer</b>', 'default_invoice_footer' => 'Set default <b>invoice footer</b>',
@ -548,4 +548,21 @@ return array(
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -435,7 +435,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
@ -502,7 +502,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -520,4 +520,22 @@ return array(
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -456,7 +456,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Numéro de TVA', 'vat_number' => 'Numéro de TVA',
@ -523,7 +523,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -541,4 +541,22 @@ return array(
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -457,7 +457,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -525,7 +525,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -542,5 +542,23 @@ return array(
'edit_token' => 'Edit Token', 'edit_token' => 'Edit Token',
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -466,7 +466,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -533,7 +533,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -550,6 +550,24 @@ return array(
'edit_token' => 'Edit Token', 'edit_token' => 'Edit Token',
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -464,7 +464,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -531,7 +531,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -549,5 +549,22 @@ return array(
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -458,7 +458,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -526,7 +526,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -543,6 +543,24 @@ return array(
'edit_token' => 'Edit Token', 'edit_token' => 'Edit Token',
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -446,7 +446,7 @@ return array(
'payment_title' => 'Enter Your Billing Address and Credit Card information', 'payment_title' => 'Enter Your Billing Address and Credit Card information',
'payment_cvv' => '*This is the 3-4 digit number onthe back of your card', 'payment_cvv' => '*This is the 3-4 digit number onthe back of your card',
'payment_footer1' => '*Billing address must match address accociated with credit card.', 'payment_footer1' => '*Billing address must match address associated with credit card.',
'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'payment_footer2' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'vat_number' => 'Vat Number', 'vat_number' => 'Vat Number',
'id_number' => 'ID Number', 'id_number' => 'ID Number',
@ -513,7 +513,7 @@ return array(
'billing_address' => 'Billing address', 'billing_address' => 'Billing address',
'billing_method' => 'Billing method', 'billing_method' => 'Billing method',
'order_overview' => 'Order overview', 'order_overview' => 'Order overview',
'match_address' => '*Address must match address accociated with credit card.', 'match_address' => '*Address must match address associated with credit card.',
'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.',
'default_invoice_footer' => 'Set default invoice footer', 'default_invoice_footer' => 'Set default invoice footer',
@ -531,5 +531,23 @@ return array(
'delete_token' => 'Delete Token', 'delete_token' => 'Delete Token',
'token' => 'Token', 'token' => 'Token',
'add_gateway' => 'Add Gateway',
'delete_gateway' => 'Delete Gateway',
'edit_gateway' => 'Edit Gateway',
'updated_gateway' => 'Successfully updated gateway',
'created_gateway' => 'Successfully created gateway',
'deleted_gateway' => 'Successfully deleted gateway',
'pay_with_paypal' => 'PayPal',
'pay_with_card' => 'Credit card',
'change_password' => 'Change password',
'current_password' => 'Current password',
'new_password' => 'New password',
'confirm_password' => 'Confirm password',
'password_error_incorrect' => 'The current password is incorrect.',
'password_error_invalid' => 'The new password is invalid.',
'updated_password' => 'Successfully updated password',
); );

View File

@ -96,6 +96,21 @@ class Account extends Eloquent
} }
} }
public function getGatewayByType($type = PAYMENT_TYPE_ANY)
{
foreach ($this->account_gateways as $gateway) {
if ($type == PAYMENT_TYPE_ANY) {
return $gateway;
} elseif ($gateway->isPayPal() && $type == PAYMENT_TYPE_PAYPAL) {
return $gateway;
} elseif (!$gateway->isPayPal() && $type == PAYMENT_TYPE_CREDIT_CARD) {
return $gateway;
}
}
return false;
}
public function getGatewayConfig($gatewayId) public function getGatewayConfig($gatewayId)
{ {
foreach ($this->account_gateways as $gateway) { foreach ($this->account_gateways as $gateway) {

View File

@ -20,4 +20,9 @@ class AccountGateway extends EntityModel
return $arrayOfImages; return $arrayOfImages;
} }
public function isPayPal() {
return $this->gateway_id == GATEWAY_PAYPAL_EXPRESS;
}
} }

View File

@ -229,9 +229,9 @@ class Client extends EntityModel
return false; return false;
} }
$accountGateway = $this->account->account_gateways[0]; $accountGateway = $this->account->getGatewayConfig(GATEWAY_STRIPE);
if ($accountGateway->gateway_id != GATEWAY_STRIPE) { if (!$accountGateway) {
return false; return false;
} }

View File

@ -81,6 +81,7 @@ Route::group(array('before' => 'auth'), function() {
Route::post('users/delete', 'UserController@delete'); Route::post('users/delete', 'UserController@delete');
Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation'); Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation');
Route::get('restore_user/{user_id}', 'UserController@restoreUser'); Route::get('restore_user/{user_id}', 'UserController@restoreUser');
Route::post('users/change_password', 'UserController@changePassword');
Route::get('api/tokens', array('as'=>'api.tokens', 'uses'=>'TokenController@getDatatable')); Route::get('api/tokens', array('as'=>'api.tokens', 'uses'=>'TokenController@getDatatable'));
Route::resource('tokens', 'TokenController'); Route::resource('tokens', 'TokenController');
@ -102,6 +103,10 @@ Route::group(array('before' => 'auth'), function() {
Route::post('remove_logo', 'AccountController@removeLogo'); Route::post('remove_logo', 'AccountController@removeLogo');
Route::post('account/go_pro', 'AccountController@enableProPlan'); Route::post('account/go_pro', 'AccountController@enableProPlan');
Route::resource('gateways', 'AccountGatewayController');
Route::get('api/gateways', array('as'=>'api.gateways', 'uses'=>'AccountGatewayController@getDatatable'));
Route::post('gateways/delete', 'AccountGatewayController@delete');
Route::resource('clients', 'ClientController'); Route::resource('clients', 'ClientController');
Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable')); Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable'));
Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable')); Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable'));
@ -277,6 +282,7 @@ define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
define('GATEWAY_AUTHORIZE_NET', 1); define('GATEWAY_AUTHORIZE_NET', 1);
define('GATEWAY_AUTHORIZE_NET_SIM', 2); define('GATEWAY_AUTHORIZE_NET_SIM', 2);
define('GATEWAY_PAYPAL_EXPRESS', 17); define('GATEWAY_PAYPAL_EXPRESS', 17);
define('GATEWAY_PAYPAL_PRO', 18);
define('GATEWAY_STRIPE', 23); define('GATEWAY_STRIPE', 23);
define('GATEWAY_TWO_CHECKOUT', 27); define('GATEWAY_TWO_CHECKOUT', 27);
define('GATEWAY_BEANSTREAM', 29); define('GATEWAY_BEANSTREAM', 29);
@ -322,6 +328,10 @@ define('TOKEN_BILLING_OPT_IN', 2);
define('TOKEN_BILLING_OPT_OUT', 3); define('TOKEN_BILLING_OPT_OUT', 3);
define('TOKEN_BILLING_ALWAYS', 4); define('TOKEN_BILLING_ALWAYS', 4);
define('PAYMENT_TYPE_PAYPAL', 'PAYMENT_TYPE_PAYPAL');
define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
define('PAYMENT_TYPE_ANY', 'PAYMENT_TYPE_ANY');
/* /*
define('GATEWAY_AMAZON', 30); define('GATEWAY_AMAZON', 30);
define('GATEWAY_BLUEPAY', 31); define('GATEWAY_BLUEPAY', 31);
@ -347,7 +357,7 @@ define('CREDIT_CARDS', serialize($creditCards));
HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') { HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') {
$class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2) ) ? ' class="active"' : ''; $class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2.'/*') ) ? ' class="active"' : '';
$title = ucwords(trans("texts.$text")) . Utils::getProLabel($text); $title = ucwords(trans("texts.$text")) . Utils::getProLabel($text);
return '<li'.$class.'><a href="'.URL::to($url).'" '.$extra.'>'.$title.'</a></li>'; return '<li'.$class.'><a href="'.URL::to($url).'" '.$extra.'>'.$title.'</a></li>';
}); });

View File

@ -0,0 +1,153 @@
@extends('accounts.nav')
@section('content')
@parent
{{ Former::open($url)->method($method)->rule()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
{{ Former::populate($account) }}
{{ Former::legend($title) }}
@if ($accountGateway)
{{ Former::populateField('gateway_id', $accountGateway->gateway_id) }}
{{ Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) }}
@if ($config)
@foreach ($accountGateway->fields as $field => $junk)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
{{-- do nothing --}}
@elseif (isset($config->$field))
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, $config->$field) }}
@endif
@endforeach
@endif
@endif
<div class="two-column">
{{ Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
}}
</div>
<p/>&nbsp;<p/>
<div style="display:{{ $accountGateway ? 'none' : '' }}">
<div class="two-column" style="display:{{ $onlyPayPal ? 'none' : '' }}">
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateway')
->radios($recommendedGateways)->class('recommended-gateway')
}}
</div>
{{ Former::select('gateway_id')->label('Select Gateway')->addOption('', '')
->dataClass('gateway-dropdown')
->fromQuery($gateways, 'name', 'id')
->onchange('setFieldsShown()'); }}
</div>
@foreach ($gateways as $gateway)
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@foreach ($gateway->fields as $field => $details)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
{{-- do nothing --}}
@elseif ($field == 'testMode' || $field == 'developerMode')
{{-- Former::checkbox($gateway->id.'_'.$field)->label(Utils::toSpaceCase($field))->text('Enable') --}}
@elseif ($field == 'username' || $field == 'password')
{{ Former::text($gateway->id.'_'.$field)->label('API '. ucfirst(Utils::toSpaceCase($field))) }}
@else
{{ Former::text($gateway->id.'_'.$field)->label(Utils::toSpaceCase($field)) }}
@endif
@endforeach
@if ($gateway->getHelp())
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8 help-block">
{{ $gateway->getHelp() }}
</div>
</div>
@endif
@if ($gateway->id == GATEWAY_STRIPE)
{{ Former::select('token_billing_type_id')->options($tokenBillingOptions)->help(trans('texts.token_billing_help')) }}
@endif
</div>
@endforeach
<p/>&nbsp;<p/>
{{ Former::actions(
Button::lg_success_submit('Save')->append_with_icon('floppy-disk'),
$countGateways > 0 ? Button::lg_default_link('company/payments', 'Cancel')->append_with_icon('remove-circle') : false
)}}
{{ Former::close() }}
<script type="text/javascript">
function setFieldsShown() {
var recommendedVal = $('input:radio[name=recommendedGateway_id]:checked').val();
var gatewayVal = $('#gateway_id').val();
var val = recommendedVal && recommendedVal != 1000000 ? recommendedVal : gatewayVal;
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
$('#gateway_id').parent().parent().hide();
if(!$('input:radio[name=recommendedGateway_id][value!=1000000]:checked').val())
{
$('.recommended-gateway[value=1000000]').attr('checked', true);
$('#gateway_id').parent().parent().show();
}
}
function gatewayLink(url) {
var host = new URL(url).hostname;
if (host) {
openUrl(url, '/affiliate/' + host);
}
}
$(document).ready(function() {
$('.recommended-gateway').change(
function(){
var recVal = $(this).val();
if(recVal == 1000000)
{
$('#gateway_id').parent().parent().show();
}
else
{
$('#gateway_id').parent().parent().hide();
}
setFieldsShown();
}
);
$('.recommended-gateway[other != true]').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img src="' +$(this).attr('data-imageUrl') + '" /><br />');
$(this).parent().children().last().after('<a href="#" onclick="gatewayLink(\'' + $(this).attr('data-siteUrl') + '\')" style="padding-left:26px">Create an account</a>');
});
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');
});
setFieldsShown();
$('.two-column .form-group .col-lg-8').removeClass('col-lg-8');
$('.two-column .form-group .col-sm-8').removeClass('col-sm-8');
});
</script>
@stop

View File

@ -66,6 +66,7 @@
{{ Former::text('last_name') }} {{ Former::text('last_name') }}
{{ Former::text('email') }} {{ Former::text('email') }}
{{ Former::text('phone') }} {{ Former::text('phone') }}
{{ Former::actions(Button::primary_sm(trans('texts.change_password'), ['onclick'=>'showChangePassword()'])); }}
@endif @endif
{{ Former::legend('localization') }} {{ Former::legend('localization') }}
@ -88,16 +89,85 @@
{{ Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk') }} {{ Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk') }}
</center> </center>
<div class="modal fade" id="passwordModal" tabindex="-1" role="dialog" aria-labelledby="passwordModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="passwordModalLabel">{{ trans('texts.change_password') }}</h4>
</div>
<div style="background-color: #fff" id="changePasswordDiv" onkeyup="validateChangePassword()" onclick="validateChangePassword()" onkeydown="checkForEnter(event)">
&nbsp;
{{ Former::password('current_password')->style('width:300px') }}
{{ Former::password('new_password')->style('width:300px') }}
{{ Former::password('confirm_password')->style('width:300px') }}
&nbsp;
<br/>
<center>
<div id="changePasswordError"></div>
</center>
<br/>
</div>
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="working">
<h3>{{ trans('texts.working') }}...</h3>
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
<div style="background-color: #fff; padding-right:20px;padding-left:20px; display:none" id="successDiv">
<br/>
<h3>{{ trans('texts.success') }}</h3>
{{ trans('texts.updated_password') }}
<br/>
&nbsp;
<br/>
</div>
<div class="modal-footer" style="margin-top: 0px" id="changePasswordFooter">
<button type="button" class="btn btn-default" id="cancelChangePasswordButton" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" onclick="submitChangePassword()" id="changePasswordButton" disabled>
{{ trans('texts.save') }}
<i class="glyphicon glyphicon-floppy-disk"></i>
</button>
</div>
</div>
</div>
</div>
{{ Former::close() }} {{ Former::close() }}
{{ Form::open(['url' => 'remove_logo', 'class' => 'removeLogoForm']) }} {{ Form::open(['url' => 'remove_logo', 'class' => 'removeLogoForm']) }}
{{ Form::close() }} {{ Form::close() }}
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('#country_id').combobox(); $('#country_id').combobox();
$('#passwordModal').on('hidden.bs.modal', function () {
$(['current_password', 'new_password', 'confirm_password']).each(function(i, field) {
var $input = $('form #'+field);
$input.val('');
$input.closest('div.form-group').removeClass('has-success');
});
$('#changePasswordButton').prop('disabled', true);
})
$('#passwordModal').on('shown.bs.modal', function () {
$('#current_password').focus();
})
}); });
function deleteLogo() { function deleteLogo() {
@ -106,6 +176,77 @@
} }
} }
function showChangePassword() {
$('#passwordModal').modal('show');
}
function checkForEnter(event)
{
if (event.keyCode === 13){
event.preventDefault();
return false;
}
}
function validateChangePassword(showError)
{
var isFormValid = true;
$(['current_password', 'new_password', 'confirm_password']).each(function(i, field) {
var $input = $('form #'+field),
val = $.trim($input.val());
var isValid = val && val.length >= 6;
if (isValid && field == 'confirm_password') {
isValid = val == $.trim($('#new_password').val());
}
if (isValid) {
$input.closest('div.form-group').removeClass('has-error').addClass('has-success');
} else {
isFormValid = false;
$input.closest('div.form-group').removeClass('has-success');
if (showError) {
$input.closest('div.form-group').addClass('has-error');
}
}
});
$('#changePasswordButton').prop('disabled', !isFormValid);
return isFormValid;
}
function submitChangePassword()
{
if (!validateChangePassword(true)) {
return;
}
$('#changePasswordDiv, #changePasswordFooter').hide();
$('#working').show();
$.ajax({
type: 'POST',
url: '{{ URL::to('users/change_password') }}',
data: 'current_password=' + encodeURIComponent($('form #current_password').val()) +
'&new_password=' + encodeURIComponent($('form #new_password').val()) +
'&confirm_password=' + encodeURIComponent($('form #confirm_password').val()),
success: function(result) {
if (result == 'success') {
$('#changePasswordButton').hide();
$('#successDiv').show();
$('#cancelChangePasswordButton').html('{{ trans('texts.close') }}');
} else {
$('#changePasswordError').html(result);
$('#changePasswordDiv').show();
}
$('#changePasswordFooter').show();
$('#working').hide();
}
});
}
</script> </script>
@stop @stop

View File

@ -4,13 +4,13 @@
<ul class="nav nav-tabs nav nav-justified"> <ul class="nav nav-tabs nav nav-justified">
{{ HTML::nav_link('company/details', 'company_details') }} {{ HTML::nav_link('company/details', 'company_details') }}
{{ HTML::nav_link('company/payments', 'online_payments') }} {{ HTML::nav_link('company/payments', 'online_payments', 'gateways') }}
{{ HTML::nav_link('company/products', 'product_library') }} {{ HTML::nav_link('company/products', 'product_library') }}
{{ HTML::nav_link('company/notifications', 'notifications') }} {{ HTML::nav_link('company/notifications', 'notifications') }}
{{ HTML::nav_link('company/import_export', 'import_export', 'company/import_map') }} {{ HTML::nav_link('company/import_export', 'import_export', 'company/import_map') }}
{{ HTML::nav_link('company/advanced_settings/invoice_settings', 'advanced_settings', '*/advanced_settings/*') }} {{ HTML::nav_link('company/advanced_settings/invoice_settings', 'advanced_settings', '*/advanced_settings/*') }}
</ul> </ul>
<br/> <br/>
@stop @stop

View File

@ -4,8 +4,8 @@
{{ HTML::nav_link('company/advanced_settings/email_templates', 'email_templates') }} {{ HTML::nav_link('company/advanced_settings/email_templates', 'email_templates') }}
{{ HTML::nav_link('company/advanced_settings/data_visualizations', 'data_visualizations') }} {{ HTML::nav_link('company/advanced_settings/data_visualizations', 'data_visualizations') }}
{{ HTML::nav_link('company/advanced_settings/chart_builder', 'chart_builder') }} {{ HTML::nav_link('company/advanced_settings/chart_builder', 'chart_builder') }}
{{ HTML::nav_link('company/advanced_settings/user_management', 'users') }} {{ HTML::nav_link('company/advanced_settings/user_management', 'users', 'users') }}
{{ HTML::nav_link('company/advanced_settings/token_management', 'tokens') }} {{ HTML::nav_link('company/advanced_settings/token_management', 'tokens', 'tokens') }}
</ul> </ul>
<p>&nbsp;</p> <p>&nbsp;</p>

View File

@ -3,146 +3,58 @@
@section('content') @section('content')
@parent @parent
{{ Former::open()->rule()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }} {{ Former::open('gateways/delete')->addClass('user-form') }}
{{ Former::populate($account) }} {{ Former::legend('online_payments') }}
{{ Former::legend('Payment Gateway') }} <div style="display:none">
{{ Former::text('accountGatewayPublicId') }}
@if ($accountGateway) </div>
{{ Former::populateField('gateway_id', $accountGateway->gateway_id) }} {{ Former::close() }}
{{ Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) }}
@if ($config)
@foreach ($accountGateway->fields as $field => $junk)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
{{-- do nothing --}}
@elseif (isset($config->$field))
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, $config->$field) }}
@endif
@endforeach
@endif
@endif
<div class="two-column">
{{ Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
}}
</div>
<p/>&nbsp;<p/>
<div class="two-column">
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateway')
->radios($recommendedGateways)->class('recommended-gateway')
}}
</div>
{{ Former::select('gateway_id')->label('Select Gateway')->addOption('', '')
->dataClass('gateway-dropdown')
->fromQuery($dropdownGateways, 'name', 'id')
->onchange('setFieldsShown()'); }}
@foreach ($gateways as $gateway)
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@foreach ($gateway->fields as $field => $details)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
{{-- do nothing --}}
@elseif ($field == 'testMode' || $field == 'developerMode')
{{-- Former::checkbox($gateway->id.'_'.$field)->label(Utils::toSpaceCase($field))->text('Enable') --}}
@elseif ($field == 'username' || $field == 'password')
{{ Former::text($gateway->id.'_'.$field)->label('API '. ucfirst(Utils::toSpaceCase($field))) }}
@else
{{ Former::text($gateway->id.'_'.$field)->label(Utils::toSpaceCase($field)) }}
@endif
@endforeach
@if ($gateway->getHelp())
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8 help-block">
{{ $gateway->getHelp() }}
</div>
</div>
@endif
@if ($gateway->id == GATEWAY_STRIPE)
{{ Former::select('token_billing_type_id')->options($tokenBillingOptions)->help(trans('texts.token_billing_help')) }}
@endif
</div>
@endforeach
<p/>&nbsp;<p/>
{{ Former::actions( Button::lg_success_submit('Save')->append_with_icon('floppy-disk') ) }}
{{ Former::close() }}
<script type="text/javascript"> @if ($showAdd)
{{ Button::success_link(URL::to('gateways/create'), trans("texts.add_gateway"), array('class' => 'pull-right'))->append_with_icon('plus-sign') }}
@endif
function setFieldsShown() { {{ Datatable::table()
var recommendedVal = $('input:radio[name=recommendedGateway_id]:checked').val(); ->addColumn(
var gatewayVal = $('#gateway_id').val(); trans('texts.name'),
var val = recommendedVal && recommendedVal != 1000000 ? recommendedVal : gatewayVal; trans('texts.action'))
->setUrl(url('api/gateways/'))
$('.gateway-fields').hide(); ->setOptions('sPaginationType', 'bootstrap')
$('#gateway_' + val + '_div').show(); ->setOptions('bFilter', false)
->setOptions('bAutoWidth', false)
$('#gateway_id').parent().parent().hide(); ->setOptions('aoColumns', [[ "sWidth"=> "80%" ], ["sWidth"=> "20%"]])
if(!$('input:radio[name=recommendedGateway_id][value!=1000000]:checked').val()) ->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1]]])
{ ->render('datatable') }}
$('.recommended-gateway[value=1000000]').attr('checked', true);
$('#gateway_id').parent().parent().show();
}
}
function gatewayLink(url) { <script>
var host = new URL(url).hostname; window.onDatatableReady = function() {
if (host) { $('tbody tr').mouseover(function() {
openUrl(url, '/affiliate/' + host); $(this).closest('tr').find('.tr-action').css('visibility','visible');
} }).mouseout(function() {
} $dropdown = $(this).closest('tr').find('.tr-action');
if (!$dropdown.hasClass('open')) {
$dropdown.css('visibility','hidden');
}
});
}
$(document).ready(function() { /*
$('.recommended-gateway').change( function setTrashVisible() {
function(){ var checked = $('#trashed').is(':checked');
var recVal = $(this).val(); window.location = '{{ URL::to('view_archive/token') }}' + (checked ? '/true' : '/false');
}
if(recVal == 1000000) */
{
$('#gateway_id').parent().parent().show();
}
else
{
$('#gateway_id').parent().parent().hide();
}
setFieldsShown();
}
);
$('.recommended-gateway[other != true]').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img src="' +$(this).attr('data-imageUrl') + '" /><br />');
$(this).parent().children().last().after('<a href="#" onclick="gatewayLink(\'' + $(this).attr('data-siteUrl') + '\')" style="padding-left:26px">Create an account</a>');
});
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');
});
setFieldsShown(); function deleteAccountGateway(id) {
$('.two-column .form-group .col-lg-8').removeClass('col-lg-8'); if (!confirm('Are you sure?')) {
$('.two-column .form-group .col-sm-8').removeClass('col-sm-8'); return;
}); }
</script> $('#accountGatewayPublicId').val(id);
$('form.user-form').submit();
}
</script>
@stop @stop

View File

@ -21,7 +21,7 @@
{{ Former::actions( {{ Former::actions(
Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk'), Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk'),
Button::lg_default_link('company/products', 'Cancel')->append_with_icon('remove-circle') Button::lg_default_link('company/products', trans('texts.cancel'))->append_with_icon('remove-circle')
) }} ) }}
{{ Former::close() }} {{ Former::close() }}

View File

@ -2,6 +2,7 @@
@section('content') @section('content')
@parent @parent
@include('accounts.nav_advanced')
{{ Former::open($url)->method($method)->addClass('col-md-8 col-md-offset-2 warn-on-exit')->rules(array( {{ Former::open($url)->method($method)->addClass('col-md-8 col-md-offset-2 warn-on-exit')->rules(array(
'name' => 'required', 'name' => 'required',
@ -21,7 +22,7 @@
{{ Former::actions( {{ Former::actions(
Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk'), Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk'),
Button::lg_default_link('company/advanced_settings/token_management', 'Cancel')->append_with_icon('remove-circle') Button::lg_default_link('company/advanced_settings/token_management', trans('texts.cancel'))->append_with_icon('remove-circle')
) }} ) }}
{{ Former::close() }} {{ Former::close() }}

View File

@ -10,6 +10,10 @@
{{ Former::text('id')->value($client->public_id) }} {{ Former::text('id')->value($client->public_id) }}
</div> </div>
@if ($gatewayLink)
{{ Button::link($gatewayLink, trans('texts.view_in_stripe'), ['target' => '_blank']) }}
@endif
@if ($client->trashed()) @if ($client->trashed())
{{ Button::primary(trans('texts.restore_client'), ['onclick' => 'onRestoreClick()']) }} {{ Button::primary(trans('texts.restore_client'), ['onclick' => 'onRestoreClick()']) }}
@else @else

View File

@ -30,8 +30,13 @@
{{ Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}&nbsp;&nbsp; {{ Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}&nbsp;&nbsp;
@if ($hasToken) @if ($hasToken)
{{ DropdownButton::success_lg(trans('texts.pay_now'), [ {{ DropdownButton::success_lg(trans('texts.pay_now'), [
['url' => URL::to("payment/{$invitation->invitation_key}?use_token=true"), 'label' => trans('texts.use_card_on_file')], ['url' => URL::to("payment/{$invitation->invitation_key}?use_token=true&use_paypal=false"), 'label' => trans('texts.use_card_on_file')],
['url' => URL::to('payment/' . $invitation->invitation_key), 'label' => trans('texts.edit_payment_details')] ['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=false"), 'label' => trans('texts.edit_payment_details')]
])->addClass('btn-lg') }}
@elseif ($countGateways == 2)
{{ DropdownButton::success_lg(trans('texts.pay_now'), [
['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=true"), 'label' => trans('texts.pay_with_paypal')],
['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=false"), 'label' => trans('texts.pay_with_card')]
])->addClass('btn-lg') }} ])->addClass('btn-lg') }}
@else @else
{{ Button::success_link(URL::to('payment/' . $invitation->invitation_key), trans('texts.pay_now'), array('class' => 'btn-lg')) }} {{ Button::success_link(URL::to('payment/' . $invitation->invitation_key), trans('texts.pay_now'), array('class' => 'btn-lg')) }}

View File

@ -215,9 +215,6 @@ table.table thead .sorting_desc_disabled:after { content: '' !important }
<li id="menu-item-30" class="menu-item-30"> <li id="menu-item-30" class="menu-item-30">
{{ link_to(NINJA_WEB_URL . '/contact', trans('texts.support')) }} {{ link_to(NINJA_WEB_URL . '/contact', trans('texts.support')) }}
</li> </li>
<li id="menu-item-29" class="menu-item-29">
{{ link_to('/terms', trans('texts.terms')) }}
</li>
<li id="menu-item-31" class="menu-item-31"> <li id="menu-item-31" class="menu-item-31">
{{ link_to('#', 'Facebook', ['target' => '_blank', 'onclick' => 'openUrl("https://www.facebook.com/invoiceninja", "/footer/social/facebook")']) }} {{ link_to('#', 'Facebook', ['target' => '_blank', 'onclick' => 'openUrl("https://www.facebook.com/invoiceninja", "/footer/social/facebook")']) }}
</li> </li>

View File

@ -2,6 +2,7 @@
@section('content') @section('content')
@parent @parent
@include('accounts.nav_advanced')
{{ Former::open($url)->method($method)->addClass('col-md-8 col-md-offset-2 warn-on-exit')->rules(array( {{ Former::open($url)->method($method)->addClass('col-md-8 col-md-offset-2 warn-on-exit')->rules(array(
'first_name' => 'required', 'first_name' => 'required',
@ -21,8 +22,8 @@
{{ Former::actions( {{ Former::actions(
Button::lg_success_submit(trans($user && $user->confirmed ? 'texts.save' : 'texts.send_invite'))->append_with_icon($user && $user->confirmed ? 'floppy-disk' : 'send'), Button::lg_success_submit(trans($user && $user->confirmed ? 'texts.save' : 'texts.send_invite'))->append_with_icon($user && $user->confirmed ? 'floppy-disk' : 'send'),
Button::lg_default_link('company/advanced_settings/user_management', 'Cancel')->append_with_icon('remove-circle') Button::lg_default_link('company/advanced_settings/user_management', trans('texts.cancel'))->append_with_icon('remove-circle')
) }} )}}
{{ Former::close() }} {{ Former::close() }}

View File

@ -20,16 +20,16 @@
"intervention/image": "1.x", "intervention/image": "1.x",
"webpatser/laravel-countries": "dev-master", "webpatser/laravel-countries": "dev-master",
"barryvdh/laravel-ide-helper": "~1.0", "barryvdh/laravel-ide-helper": "~1.0",
"doctrine/dbal": "~2.3", "doctrine/dbal": "~2.3",
"jsanc623/phpbenchtime": "2.x", "jsanc623/phpbenchtime": "2.x",
"lokielse/omnipay-alipay": "dev-master", "lokielse/omnipay-alipay": "dev-master",
"coatesap/omnipay-datacash": "~2.0", "coatesap/omnipay-datacash": "~2.0",
"alfaproject/omnipay-neteller": "~1.0", "alfaproject/omnipay-neteller": "~1.0",
"mfauveau/omnipay-pacnet": "~2.0", "mfauveau/omnipay-pacnet": "~2.0",
"coatesap/omnipay-paymentsense": "~2.0", "coatesap/omnipay-paymentsense": "~2.0",
"coatesap/omnipay-realex": "~2.0", "coatesap/omnipay-realex": "~2.0",
"fruitcakestudio/omnipay-sisow": "~2.0", "fruitcakestudio/omnipay-sisow": "~2.0",
"alfaproject/omnipay-skrill": "dev-master" "alfaproject/omnipay-skrill": "dev-master"
}, },
"require-dev": { "require-dev": {
"codeception/codeception": "dev-master" "codeception/codeception": "dev-master"

View File

@ -31607,7 +31607,7 @@ function GetPdf(invoice, javascript){
if (invoice.invoice_footer) { if (invoice.invoice_footer) {
doc.setFontType('normal'); doc.setFontType('normal');
doc.setFontSize('8'); doc.setFontSize('8');
SetPdfColor('Black',doc); SetPdfColor(invoice.invoice_design_id == 2 || invoice.invoice_design_id == 3 ? 'White' : 'Black',doc);
var top = doc.internal.pageSize.height - layout.marginLeft; var top = doc.internal.pageSize.height - layout.marginLeft;
var numLines = invoice.invoice_footer.split("\n").length - 1; var numLines = invoice.invoice_footer.split("\n").length - 1;
doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer); doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer);
@ -32582,9 +32582,7 @@ function displayInvoiceItems(doc, invoice, layout) {
top = y - layout.tablePadding; top = y - layout.tablePadding;
newTop = top + (numLines * layout.tableRowHeight); newTop = top + (numLines * layout.tableRowHeight);
doc.addPage(); doc.addPage();
console.log('== ADD PAGE ==');
} }
console.log('Y: %s', y);
var left = layout.marginLeft - layout.tablePadding; var left = layout.marginLeft - layout.tablePadding;
var width = layout.marginRight + layout.tablePadding; var width = layout.marginRight + layout.tablePadding;

View File

@ -84,7 +84,7 @@ function GetPdf(invoice, javascript){
if (invoice.invoice_footer) { if (invoice.invoice_footer) {
doc.setFontType('normal'); doc.setFontType('normal');
doc.setFontSize('8'); doc.setFontSize('8');
SetPdfColor('Black',doc); SetPdfColor(invoice.invoice_design_id == 2 || invoice.invoice_design_id == 3 ? 'White' : 'Black',doc);
var top = doc.internal.pageSize.height - layout.marginLeft; var top = doc.internal.pageSize.height - layout.marginLeft;
var numLines = invoice.invoice_footer.split("\n").length - 1; var numLines = invoice.invoice_footer.split("\n").length - 1;
doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer); doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer);