mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-22 21:03:01 +09:00
Finish 4.14
This commit is contained in:
commit
c45d5dc275
47 files changed
+660
-180
No files matched your search
@@ -1,3 +1,30 @@
|
||||
Release 4.14 (2015-02-03)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
* New event hook:
|
||||
* onBeforeThemeSettingsSave
|
||||
* New API(client) calls:
|
||||
* invoice_get_tax_rate
|
||||
* client_is_taxable
|
||||
* client_balance_get_total
|
||||
* Taxes are shown in the cart checkout summary
|
||||
* Email templates are generated after install
|
||||
* Footer links fix for Huraga theme
|
||||
* Only one coupon code name can be created and used;
|
||||
* Fixed CKEditor issue with canned responses
|
||||
* Custom payment gateway render error fixed
|
||||
* Fixed Centova Cast module
|
||||
* Password hash in email resolved
|
||||
* Orderbutton module popup improved
|
||||
* Client email confirmation logic updated
|
||||
* Variables in email templates list fixed
|
||||
* Generating email templates just after installing of BoxBilling
|
||||
* Allow only text in Notification module messages
|
||||
* Fixed constantly regenerating invoices issue
|
||||
* Add funds logic updated
|
||||
* Settings of footer links updated
|
||||
* Security and performance fixes and updates
|
||||
|
||||
Release 4.13 (2015-01-15)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Vendored
+5
-1
@@ -5,7 +5,11 @@ dir = File.dirname(File.expand_path(__FILE__))
|
||||
configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
|
||||
data = configValues['vagrantfile-local']
|
||||
|
||||
Vagrant.require_version '>= 1.6.0'
|
||||
begin
|
||||
Vagrant.require_version ">= 1.6.0"
|
||||
rescue NoMethodError
|
||||
raise 'BoxBilling is only supported on Vagrant >= 1.6. Please upgrade.'
|
||||
end
|
||||
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.box = "#{data['vm']['box']}"
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ vagrantfile-local:
|
||||
vm:
|
||||
box: puphpet/ubuntu1204-x64
|
||||
box_url: puphpet/ubuntu1204-x64
|
||||
hostname: 'boxbilling'
|
||||
hostname: 'boxbilling.test'
|
||||
memory: '512'
|
||||
cpus: '1'
|
||||
chosen_provider: virtualbox
|
||||
|
||||
@@ -92,6 +92,7 @@ class Service implements InjectionAwareInterface
|
||||
$search = isset($data['search']) ? $data['search'] : NULL;
|
||||
$priority = isset($data['priority']) ? $data['priority'] : NULL;
|
||||
$only_staff = isset($data['only_staff']) ? $data['only_staff'] : NULL;
|
||||
$admin_id = isset($data['admin_id']) ? $data['admin_id'] : NULL;
|
||||
$only_clients = isset($data['only_clients']) ? $data['only_clients'] : NULL;
|
||||
$no_info = isset($data['no_info']) ? $data['no_info'] : NULL;
|
||||
$no_debug = isset($data['no_debug']) ? $data['no_debug'] : NULL;
|
||||
@@ -115,6 +116,11 @@ class Service implements InjectionAwareInterface
|
||||
$where[] = 'm.admin_id IS NOT NULL';
|
||||
}
|
||||
|
||||
if($admin_id) {
|
||||
$where[] = 'm.admin_id = :admin_id';
|
||||
$params[':admin_id'] = $admin_id;
|
||||
}
|
||||
|
||||
if($only_clients) {
|
||||
$where[] = 'm.client_id IS NOT NULL';
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ class Service implements InjectionAwareInterface
|
||||
)
|
||||
);
|
||||
|
||||
list($order, $invoice_id, $orders) = $this->createFromCart($client, $gateway_id);
|
||||
list($order, $invoice, $orders) = $this->createFromCart($client, $gateway_id);
|
||||
|
||||
$this->rm($cart);
|
||||
|
||||
@@ -450,9 +450,8 @@ class Service implements InjectionAwareInterface
|
||||
);
|
||||
|
||||
// invoice may not be created if total is 0
|
||||
if ($invoice_id) {
|
||||
$idata = $this->di['db']->getExistingModelById('Invoice', $invoice_id, 'Invoice not found');
|
||||
$result['invoice_hash'] = $idata->hash;
|
||||
if ($invoice instanceof \Model_Invoice && $invoice->status == \Model_Invoice::STATUS_UNPAID) {
|
||||
$result['invoice_hash'] = $invoice->hash;
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -460,18 +459,12 @@ class Service implements InjectionAwareInterface
|
||||
|
||||
public function createFromCart(\Model_Client $client, $gateway_id = null)
|
||||
{
|
||||
$cart = $this->getSessionCart();
|
||||
$cartProducts = $this->di['db']->find('CartProduct', 'cart_id = :cart_id', array(':cart_id' => $cart->id));
|
||||
if (count($cartProducts) == 0) {
|
||||
$cart = $this->getSessionCart();
|
||||
$ca = $this->toApiArray($cart);
|
||||
if (count($ca['items']) == 0) {
|
||||
throw new \Box_Exception('Can not checkout empty cart.');
|
||||
}
|
||||
|
||||
$ca = $this->toApiArray($cart);
|
||||
|
||||
$create_invoice = true;
|
||||
if ($ca['total'] == 0) {
|
||||
$create_invoice = false;
|
||||
}
|
||||
|
||||
$currency = $this->di['db']->getExistingModelById('Currency', $cart->currency_id, 'Currency not found.');
|
||||
|
||||
@@ -521,7 +514,7 @@ class Service implements InjectionAwareInterface
|
||||
$order->updated_at = date('c');
|
||||
$this->di['db']->store($order);
|
||||
|
||||
$orders[] = $order->id;
|
||||
$orders[] = $order;
|
||||
|
||||
// mark promo as used
|
||||
if ($cart->promo_id) {
|
||||
@@ -568,44 +561,58 @@ class Service implements InjectionAwareInterface
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($create_invoice) {
|
||||
if ($ca['total'] > 0) { //crete invoice if order total > 0
|
||||
|
||||
$invoiceService = $this->di['mod_service']('Invoice');
|
||||
$invoice_id = $invoiceService->prepareInvoice($client, array('client_id' => $client->id, 'items' => $invoice_items, 'gateway_id' => $gateway_id));
|
||||
$invoiceModel = $this->di['db']->load('Invoice', $invoice_id);
|
||||
$invoiceService->approveInvoice($invoiceModel, array('id' => $invoice_id, 'use_credits' => true));
|
||||
$invoiceModel = $invoiceService->prepareInvoice($client, array('client_id' => $client->id, 'items' => $invoice_items, 'gateway_id' => $gateway_id));
|
||||
|
||||
foreach ($orders as $oid) {
|
||||
$o = $this->di['db']->load('ClientOrder', $oid);
|
||||
$o->unpaid_invoice_id = $invoice_id;
|
||||
$this->di['db']->store($o);
|
||||
}
|
||||
$clientBalanceService = $this->di['mod_service']('Client', 'Balance');
|
||||
$balanceAmount = $clientBalanceService->getClientBalance($client);
|
||||
$useCredits = $balanceAmount >= $ca['total'];
|
||||
|
||||
$result = array($master_order, $invoice_id, $orders);
|
||||
} else {
|
||||
$result = array($master_order, null, $orders);
|
||||
}
|
||||
$invoiceService->approveInvoice($invoiceModel, array('id' => $invoiceModel->id, 'use_credits' => $useCredits));
|
||||
|
||||
//activate orders if product is setup to be activated after order place or order total is $0
|
||||
$orderService = $this->di['mod_service']('Order');
|
||||
foreach ($orders as $oid) {
|
||||
|
||||
$order = $this->di['db']->load('ClientOrder', $oid);
|
||||
$oa = $orderService->toApiArray($order, false, $client);
|
||||
$product = $this->di['db']->getExistingModelById('Product', $oa['product_id']);
|
||||
if ($product->setup == \Model_ProductTable::SETUP_AFTER_ORDER || ($product->setup == \Model_ProductTable::SETUP_AFTER_PAYMENT && $oa['total'] - $oa['discount'] <= 0)) {
|
||||
try {
|
||||
$orderService->activateOrder($order);
|
||||
} catch (\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
$status = 'error';
|
||||
$notes = 'Order could not be activated after checkout due to error: ' . $e->getMessage();
|
||||
$orderService->orderStatusAdd($order, $status, $notes);
|
||||
if ($invoiceModel->status == \Model_Invoice::STATUS_UNPAID) {
|
||||
foreach ($orders as $order) {
|
||||
$order->unpaid_invoice_id = $invoiceModel->id;
|
||||
$this->di['db']->store($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
//activate orders if product is setup to be activated after order place or order total is $0
|
||||
$orderService = $this->di['mod_service']('Order');
|
||||
$ids = array();
|
||||
foreach ($orders as $order) {
|
||||
$ids[] = $order->id;
|
||||
$oa = $orderService->toApiArray($order, false, $client);
|
||||
$product = $this->di['db']->getExistingModelById('Product', $oa['product_id']);
|
||||
try {
|
||||
if ($product->setup == \Model_ProductTable::SETUP_AFTER_ORDER){
|
||||
$orderService->activateOrder($order);
|
||||
}
|
||||
|
||||
if ($ca['total'] <= 0 && $product->setup == \Model_ProductTable::SETUP_AFTER_PAYMENT && $oa['total'] - $oa['discount'] <= 0){
|
||||
$orderService->activateOrder($order);
|
||||
}
|
||||
|
||||
if ($ca['total'] > 0 && $product->setup == \Model_ProductTable::SETUP_AFTER_PAYMENT && $invoiceModel->status == \Model_Invoice::STATUS_PAID ){
|
||||
$orderService->activateOrder($order);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
$status = 'error';
|
||||
$notes = 'Order could not be activated after checkout due to error: ' . $e->getMessage();
|
||||
$orderService->orderStatusAdd($order, $status, $notes);
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
$master_order,
|
||||
isset($invoiceModel) ? $invoiceModel : null,
|
||||
$ids,
|
||||
);
|
||||
}
|
||||
|
||||
public function usePromo(\Model_Promo $promo)
|
||||
|
||||
@@ -309,4 +309,19 @@ class Client extends \Api_Abstract
|
||||
return $pager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get client balance
|
||||
* @return float
|
||||
*/
|
||||
public function balance_get_total()
|
||||
{
|
||||
$service = $this->di['mod_service']('Client', 'Balance');
|
||||
return $service->getClientBalance($this->identity);
|
||||
}
|
||||
|
||||
public function is_taxable()
|
||||
{
|
||||
return $this->getService()->isClientTaxable($this->identity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -119,9 +119,17 @@ class Guest extends \Api_Abstract
|
||||
|
||||
$client = $service->guestCreateClient($data);
|
||||
|
||||
|
||||
if (isset($config['require_email_confirmation']) && (int)$config['require_email_confirmation']) {
|
||||
if (!$client->email_approved) {
|
||||
throw new \Box_Exception('Account has been created. Please check your mailbox and confirm email address.', null, 7777);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['auto_login']) && $data['auto_login']) {
|
||||
|
||||
try {
|
||||
$this->login(array('email'=>$client->email, 'password' => $client->pass));
|
||||
$this->login(array('email'=>$client->email, 'password' => $data['password']));
|
||||
} catch(\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ class Service implements InjectionAwareInterface
|
||||
{
|
||||
$this->di['events_manager']->fire(array('event'=>'onBeforeAdminCreateClient', 'params'=>$data));
|
||||
$client = $this->createClient($data);
|
||||
$this->di['events_manager']->fire(array('event'=>'onAfterAdminCreateClient', 'params'=>array('id'=>$client->id, 'password'=>$client->pass)));
|
||||
$this->di['events_manager']->fire(array('event'=>'onAfterAdminCreateClient', 'params'=>array('id'=>$client->id, 'password'=>$data['password'])));
|
||||
$this->di['logger']->info('Created new client #%s', $client->id);
|
||||
|
||||
return $client->id;
|
||||
@@ -546,7 +546,7 @@ class Service implements InjectionAwareInterface
|
||||
$data['status'] = \Model_Client::ACTIVE;
|
||||
$client = $this->createClient($data);
|
||||
|
||||
$this->di['events_manager']->fire(array('event'=>'onAfterClientSignUp', 'params'=>array('id'=>$client->id, 'password'=>$client->pass)));
|
||||
$this->di['events_manager']->fire(array('event'=>'onAfterClientSignUp', 'params'=>array('id'=>$client->id, 'password'=>$data['password'])));
|
||||
$this->di['logger']->info('Client #%s signed up', $client->id);
|
||||
|
||||
return $client;
|
||||
@@ -592,7 +592,13 @@ class Service implements InjectionAwareInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->di['auth']->authorizeUser($model, $plainTextPassword);
|
||||
$config = $this->di['mod_config']('client');
|
||||
if (isset($config['require_email_confirmation']) && (int)$config['require_email_confirmation']) {
|
||||
if (!$model->email_approved) {
|
||||
throw new \Box_Exception('Please check your mailbox and confirm email address.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->di['auth']->authorizeUser($model, $plainTextPassword);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@
|
||||
</div>
|
||||
<div id="tab-custom-fields" class="tab_content nopadding">
|
||||
<fieldset>
|
||||
{% for i in 0..10 %}
|
||||
{% for i in 1..10 %}
|
||||
{% set field_name = 'custom_' ~ i %}
|
||||
{% set custom_field = attribute(params.custom_fields, field_name) %}
|
||||
<div class="rowElem noborder">
|
||||
|
||||
@@ -79,6 +79,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input">{% trans 'Company VAT' %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="company_vat" value="{{ profile.company_vat }}">
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input">{% trans 'Company Number' %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="company_number" value="{{ profile.company_number }}">
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input">{% trans 'Phone Country Code' %}</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -264,7 +264,8 @@ class Admin extends \Api_Abstract
|
||||
$enabled = isset($data['enabled']) ? $data['enabled'] : 0;
|
||||
$category = isset($data['category']) ? $data['category'] : NULL;
|
||||
|
||||
return $this->getService()->templateCreate($data['action_code'], $data['subject'], $data['content'], $enabled, $category);
|
||||
$templateModel = $this->getService()->templateCreate($data['action_code'], $data['subject'], $data['content'], $enabled, $category);
|
||||
return $templateModel->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -489,7 +489,7 @@ class Service implements \Box\InjectionAwareInterface
|
||||
|
||||
$this->di['logger']->info('Added new email template #%s', $modelId);
|
||||
|
||||
return $modelId;
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function templateBatchGenerate()
|
||||
@@ -516,15 +516,12 @@ class Service implements \Box\InjectionAwareInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
list($s, $c, $desc, $enabled, $mod) = $this->_getDefaults(array('code' => $code));
|
||||
$t = $this->di['db']->dispense('EmailTemplate');
|
||||
$t->enabled = $enabled;
|
||||
$t->action_code = $code;
|
||||
$t->category = $mod;
|
||||
$t->subject = $s;
|
||||
$t->content = $c;
|
||||
$t->description = $desc;
|
||||
$this->di['db']->store($t);
|
||||
list($subject, $content, $desc, $enabled, $mod) = $this->_getDefaults(array('code' => $code));
|
||||
$t = $this->templateCreate($code, $subject, $content, $enabled, $mod);
|
||||
if ($desc) {
|
||||
$t->description = $desc;
|
||||
$this->di['db']->store($t);
|
||||
}
|
||||
}
|
||||
|
||||
$this->di['logger']->info('Generated email templates for installed extensions');
|
||||
@@ -593,7 +590,7 @@ class Service implements \Box\InjectionAwareInterface
|
||||
$mail->addTo($queue->to, $queue->to_name);
|
||||
|
||||
if (APPLICATION_ENV != 'production') {
|
||||
//if(BB_DEBUG) error_log('Skip email sending');
|
||||
error_log('Skip email sending. Application ENV: '.APPLICATION_ENV);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
{% set active_menu = 'activity' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set config = admin.extension_config_get({"ext":"mod_email"}) %}
|
||||
{% if config.log_enabled is not defined or config.log_enabled != 1 %}
|
||||
<div class="nNote nInformation first">
|
||||
<p><strong>{% trans 'INFORMATION' %}: </strong>{% trans 'Email logging is not enabled. If you want to log sent mails to database, enable it in' %}
|
||||
<a href="{{'extension/settings/email'|alink}}"> {% trans 'email settings.' %}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="widget">
|
||||
<div class="head"><h5 class="iFrames">{% trans 'Email history' %}</h5></div>
|
||||
|
||||
|
||||
@@ -102,14 +102,29 @@
|
||||
|
||||
<tbody>
|
||||
{% for k,var in template.vars %}
|
||||
{% if var|keys|length > 0 %}
|
||||
{% for subkey,subvalue in var %}
|
||||
|
||||
<tr>
|
||||
<td>{{ '{{' }} {{ k }}.{{subkey}} {{ '}}' }}</td>
|
||||
<td>{{ subvalue }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if var is iterable %}
|
||||
{% for subkey,subvalue in var %}
|
||||
{% if subvalue is iterable %}
|
||||
{% for subsubkey,subsubvalue in var %}
|
||||
{% if subsubvalue is not iterable %}
|
||||
<tr>
|
||||
<td>{{ '{{' }} {{ k }}.{{subkey}}.{{subsubkey}}{{ '}}' }}</td>
|
||||
<td>{{ subsubvalue }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>{{ '{{' }} {{ k }}.{{subkey}}.{{subsubkey}}{{ '}}' }}</td>
|
||||
<td>Array [ ]</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>{{ '{{' }} {{ k }}.{{subkey}} {{ '}}' }}</td>
|
||||
<td>{{ subvalue }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>{{ '{{' }} {{ k }} {{ '}}' }}</td>
|
||||
@@ -117,7 +132,7 @@
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="2">{% trans 'This template does not receive any parameters' %}</td>
|
||||
</tr>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
{% if guest.extension_is_on({"mod":"spamchecker"}) %}
|
||||
{% set rc = guest.spamchecker_recaptcha %}
|
||||
{% if rc.enabled %}
|
||||
{% set server = "http://www.google.com/recaptcha/api" %}
|
||||
{% set server = "https://www.google.com/recaptcha/api" %}
|
||||
<script type="text/javascript">
|
||||
var RecaptchaOptions = {
|
||||
theme : 'custom',
|
||||
|
||||
@@ -93,7 +93,8 @@ class Admin extends \Api_Abstract
|
||||
|
||||
$client = $this->di['db']->getExistingModelById('Client', $data['client_id'], 'Client not found');
|
||||
|
||||
return $this->getService()->prepareInvoice($client, $data);
|
||||
$invoice = $this->getService()->prepareInvoice($client, $data);
|
||||
return $invoice->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -195,4 +195,10 @@ class Client extends \Api_Abstract
|
||||
|
||||
return $pager;
|
||||
}
|
||||
|
||||
public function get_tax_rate()
|
||||
{
|
||||
$service = $this->di['mod_service']('Invoice', 'Tax');
|
||||
return $service->getTaxRateForClient($this->identity);
|
||||
}
|
||||
}
|
||||
@@ -493,7 +493,7 @@ class Service implements InjectionAwareInterface
|
||||
}
|
||||
}
|
||||
|
||||
return $invoiceId;
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function setInvoiceDefaults(\Model_Invoice $model)
|
||||
|
||||
@@ -68,19 +68,9 @@ class Admin extends \Api_Abstract
|
||||
return false;
|
||||
}
|
||||
|
||||
$meta = $this->di['db']->dispense('extension_meta');
|
||||
$meta->extension = 'mod_notification';
|
||||
$meta->rel_type = 'staff';
|
||||
$meta->rel_id = 1;
|
||||
$meta->meta_key = 'message';
|
||||
$meta->meta_value = $data['message'];
|
||||
$meta->created_at = date('c');
|
||||
$meta->updated_at = date('c');
|
||||
$id = $this->di['db']->store($meta);
|
||||
$message = htmlspecialchars($data['message'], ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$this->di['events_manager']->fire(array('event' => 'onAfterAdminNotificationAdd', 'params' => array('id' => $id)));
|
||||
|
||||
return $id;
|
||||
return $this->getService()->create($message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,4 +45,21 @@ class Service implements InjectionAwareInterface
|
||||
{
|
||||
return $this->di['db']->toArray($row);
|
||||
}
|
||||
|
||||
public function create($message)
|
||||
{
|
||||
$meta = $this->di['db']->dispense('extension_meta');
|
||||
$meta->extension = 'mod_notification';
|
||||
$meta->rel_type = 'staff';
|
||||
$meta->rel_id = 1;
|
||||
$meta->meta_key = 'message';
|
||||
$meta->meta_value = $message;
|
||||
$meta->created_at = date('c');
|
||||
$meta->updated_at = date('c');
|
||||
$id = $this->di['db']->store($meta);
|
||||
|
||||
$this->di['events_manager']->fire(array('event' => 'onAfterAdminNotificationAdd', 'params' => array('id' => $id)));
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
@@ -141,20 +141,30 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{% trans 'Discount:' %}</strong></td>
|
||||
<td><strong>{{ cart.discount | money_convert }}</strong></td>
|
||||
<td><strong>- {{ cart.discount | money_convert }}</strong></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{% set tax_amount = 0 %}
|
||||
{% if client.client_is_taxable %}
|
||||
{% set tax_rate = client.invoice_get_tax_rate %}
|
||||
{% set tax_amount = cart.total * tax_rate / 100 %}
|
||||
<tr>
|
||||
<td><strong>{% trans 'VAT'%} ({{ tax_rate }}%) :</strong></td>
|
||||
<td><strong>{{ tax_amount | money_convert }}</strong></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><strong>{% trans 'Total:' %}</strong></td>
|
||||
<td><strong>{{ cart.total | money_convert }}</strong></td>
|
||||
<td><strong>{{ (cart.total + tax_amount) | money_convert }}</strong></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<form method="post" action="client/cart/checkout" class="form-horizontal" id="checkout-form" onsubmit="return false;">
|
||||
<fieldset>
|
||||
{% if cart.total %}
|
||||
{% set enough_in_balance = client.client_balance_get_total >= cart.total %}
|
||||
{% if cart.total and not enough_in_balance %}
|
||||
<div class="control-group">
|
||||
{% for gtw in guest.invoice_gateways %}
|
||||
{% if cart.currency.code in gtw.accepted_currencies %}
|
||||
@@ -168,6 +178,9 @@
|
||||
{% endif %}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{% if enough_in_balance %}
|
||||
<p>{% trans 'Total amount will be deducted from account balance' %}</p>
|
||||
{% endif %}
|
||||
<button class="btn btn-primary btn-large" type="submit">{% trans 'Checkout' %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -107,18 +107,19 @@ function popup(){
|
||||
$('#popup-iframe').show();
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof jQuery === "undefined") {
|
||||
(function(d, script) {
|
||||
script = d.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.onload = function(){
|
||||
show_popup();
|
||||
};
|
||||
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
|
||||
d.getElementsByTagName('head')[0].appendChild(script);
|
||||
}(document));
|
||||
}else{
|
||||
show_popup();
|
||||
};
|
||||
$( document ).ready(function() {
|
||||
if (typeof jQuery === "undefined") {
|
||||
(function(d, script) {
|
||||
script = d.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.onload = function(){
|
||||
show_popup();
|
||||
};
|
||||
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
|
||||
d.getElementsByTagName('head')[0].appendChild(script);
|
||||
}(document));
|
||||
}else{
|
||||
show_popup();
|
||||
};
|
||||
});
|
||||
@@ -17,7 +17,12 @@
|
||||
{% endif %}
|
||||
<div class="data-block">
|
||||
<div class="data-container">
|
||||
|
||||
<form method="post" action="" id="client-signup">
|
||||
<div class="alert alert-info" style="display: none" id="account-created-info-block">
|
||||
<button class="close" data-dismiss="alert">×</button>
|
||||
<strong>{% trans 'Account has been created' %}.</strong> {% trans 'Please check your mailbox and confirm email address' %}.
|
||||
</div>
|
||||
<fieldset>
|
||||
{% set r = guest.client_required %}
|
||||
<div class="control-group">
|
||||
@@ -211,13 +216,28 @@
|
||||
|
||||
{% block js %}
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#client-signup').bind('submit',function(event){
|
||||
bb.post('guest/client/create', $(this).serialize(), function(result){
|
||||
bb.redirect('/');
|
||||
$(function () {
|
||||
$('#client-signup').bind('submit', function (event) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: bb.restUrl('guest/client/create'),
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
if (data.error.code == 7777) {
|
||||
$('#account-created-info-block').show();
|
||||
} else {
|
||||
$('.wait').hide();
|
||||
bb.msg(data.error.message, 'error');
|
||||
}
|
||||
} else {
|
||||
bb.redirect('/');
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -287,7 +287,7 @@ class Service implements InjectionAwareInterface
|
||||
|
||||
$this->di['validator']->isPasswordStrong($password);
|
||||
|
||||
$client->pass = $password;
|
||||
$client->pass = $this->di['password']->hashIt($password);
|
||||
$this->di['db']->store($client);
|
||||
|
||||
$this->di['events_manager']->fire(array('event' => 'onAfterClientProfilePasswordChange', 'params' => array('id' => $client->id)));
|
||||
|
||||
@@ -47,6 +47,8 @@ class Admin implements \Box\InjectionAwareInterface
|
||||
*/
|
||||
public function save_theme_settings(\Box_App $app, $theme)
|
||||
{
|
||||
$this->di['events_manager']->fire(array('event' => 'onBeforeThemeSettingsSave', 'params' => $_POST));
|
||||
|
||||
$api = $app->getApiAdmin();
|
||||
|
||||
$mod = $this->di['mod']('theme');
|
||||
|
||||
@@ -86,10 +86,20 @@
|
||||
<div class="grid_5 omega">
|
||||
<div class="box">
|
||||
<div class="block pricing">
|
||||
{% set tax_amount = 0 %}
|
||||
{% if client.client_is_taxable %}
|
||||
{% set tax_rate = client.invoice_get_tax_rate %}
|
||||
{% set tax_amount = cart.total * tax_rate / 100 %}
|
||||
|
||||
<p>{% trans 'VAT'%} ({{ tax_rate }}%) :</p>
|
||||
|
||||
<div class="currency">{{ tax_amount | money_convert }}</div>
|
||||
{% endif %}
|
||||
<p>{% trans 'Total:' %}</p>
|
||||
<div class="currency">{{ cart.total | money_convert }}</div>
|
||||
<div class="currency">{{ (cart.total + tax_amount) | money_convert }}</div>
|
||||
<form method="post" action="{{ 'api/client/cart/checkout'|link }}" class="api-form" data-api-jsonp="onAfterCartCheckout">
|
||||
{% if cart.total %}
|
||||
{% set enough_in_balance = client.client_balance_get_total >= cart.total %}
|
||||
{% if cart.total and not enough_in_balance %}
|
||||
<div style="text-align: left;">
|
||||
{% for gtw in guest.invoice_gateways %}
|
||||
{% if cart.currency.code in gtw.accepted_currencies %}
|
||||
@@ -103,6 +113,9 @@
|
||||
{% endif %}
|
||||
<br/>
|
||||
<button class="bb-button bb-button-submit bb-button-big" type="submit">{% trans 'Checkout' %}</button>
|
||||
{% if enough_in_balance %}
|
||||
<p>{% trans 'Total amount will be deducted from account balance' %}</p>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -234,7 +234,7 @@ $(function() {
|
||||
//login after registration
|
||||
var login_details = {
|
||||
email: $('#reg-email').val(),
|
||||
password: $('#reg-password').val(),
|
||||
password: $('#reg-password').val()
|
||||
};
|
||||
bb.post(
|
||||
'guest/client/login',
|
||||
|
||||
@@ -269,27 +269,27 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td><label>Footer link #1</label></td>
|
||||
<td><input type="checkbox" name="footer_link_1_enabled"/> <input type="text" name="footer_link_1_title" value=""/> -> <select class="page" name="footer_link_1_page"/></td>
|
||||
<td><input type="checkbox" name="footer_link_1_enabled"/> <input type="text" name="footer_link_1_title" value=""/> -> <input type="text" name="footer_link_1_page"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label>Footer link #2</label></td>
|
||||
<td><input type="checkbox" name="footer_link_2_enabled"/> <input type="text" name="footer_link_2_title" value=""/> -> <select class="page" name="footer_link_2_page"/></td>
|
||||
<td><input type="checkbox" name="footer_link_2_enabled"/> <input type="text" name="footer_link_2_title" value=""/> -> <input type="text" name="footer_link_2_page"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label>Footer link #3</label></td>
|
||||
<td><input type="checkbox" name="footer_link_3_enabled"/> <input type="text" name="footer_link_3_title" value=""/> -> <select class="page" name="footer_link_3_page"/></td>
|
||||
<td><input type="checkbox" name="footer_link_3_enabled"/> <input type="text" name="footer_link_3_title" value=""/> -> <input type="text" name="footer_link_3_page"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label>Footer link #4</label></td>
|
||||
<td><input type="checkbox" name="footer_link_4_enabled"/> <input type="text" name="footer_link_4_title" value=""/> -> <select class="page" name="footer_link_4_page"/></td>
|
||||
<td><input type="checkbox" name="footer_link_4_enabled"/> <input type="text" name="footer_link_4_title" value=""/> -> <input type="text" name="footer_link_4_page"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><label>Footer link #5</label></td>
|
||||
<td><input type="checkbox" name="footer_link_5_enabled"/> <input type="text" name="footer_link_5_title" value=""/> -> <select class="page" name="footer_link_5_page"/></td>
|
||||
<td><input type="checkbox" name="footer_link_5_enabled"/> <input type="text" name="footer_link_5_title" value=""/> -> <input type="text" name="footer_link_5_page"/></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
@@ -172,27 +172,48 @@
|
||||
<ul>
|
||||
{% if settings.footer_link_1_enabled %}
|
||||
<li>
|
||||
{% if 'http://' in settings.footer_link_1_page or 'https://' in settings.footer_link_1_page%}
|
||||
<a href="{{ settings.footer_link_1_page }}">{{ settings.footer_link_1_title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ settings.footer_link_1_page | link }}">{{ settings.footer_link_1_title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if settings.footer_link_2_enabled %}
|
||||
<li>
|
||||
<a href="{{ settings.footer_link_2_page | link }}">{{ settings.footer_link_2_title }}</a>
|
||||
{% if 'http://' in settings.footer_link_2_page or 'https://' in settings.footer_link_2_page%}
|
||||
<a href="{{ settings.footer_link_2_page }}">{{ settings.footer_link_2_title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ settings.footer_link_2_page | link}}">{{ settings.footer_link_2_title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if settings.footer_link_3_enabled %}
|
||||
<li>
|
||||
{% if 'http://' in settings.footer_link_3_page or 'https://' in settings.footer_link_3_page%}
|
||||
<a href="{{ settings.footer_link_3_page }}">{{ settings.footer_link_3_title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ settings.footer_link_3_page | link }}">{{ settings.footer_link_3_title }}</a>
|
||||
|
||||
{%endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if settings.footer_link_4_enabled %}
|
||||
<li>
|
||||
{% if 'http://' in settings.footer_link_4_page or 'https://' in settings.footer_link_4_page%}
|
||||
<a href="{{ settings.footer_link_4_page }}">{{ settings.footer_link_4_title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ settings.footer_link_4_page | link }}">{{ settings.footer_link_4_title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if settings.footer_link_5_enabled %}
|
||||
<li>
|
||||
{% if 'http://' in settings.footer_link_5_page or 'https://' in settings.footer_link_5_page%}
|
||||
<a href="{{ settings.footer_link_5_page }}">{{ settings.footer_link_5_title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ settings.footer_link_5_page | link }}">{{ settings.footer_link_5_title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
||||
+23
-11
@@ -1,13 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @return bool
|
||||
* @see http://stackoverflow.com/a/2886224/2728507
|
||||
*/
|
||||
function isSSL() {
|
||||
return
|
||||
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| $_SERVER['SERVER_PORT'] == 443;
|
||||
}
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', '1');
|
||||
ini_set('error_log', dirname(__FILE__) . '/php_error.log');
|
||||
|
||||
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
|
||||
$protocol = isSSL() ? 'https' : 'http';
|
||||
$url = $protocol . "://" . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$current_url = pathinfo($url, PATHINFO_DIRNAME);
|
||||
$root_url = str_replace('/install', '', $current_url).'/';
|
||||
@@ -32,15 +42,6 @@ set_include_path(implode(PATH_SEPARATOR, array(
|
||||
BB_PATH_LIBRARY,
|
||||
get_include_path(),
|
||||
)));
|
||||
spl_autoload_register('bb_autoloader');
|
||||
|
||||
function bb_autoloader($className)
|
||||
{
|
||||
if(strpos($className, '_') !== false) {
|
||||
$className = str_replace('_', DIRECTORY_SEPARATOR, $className);
|
||||
}
|
||||
require_once $className.'.php';
|
||||
}
|
||||
|
||||
require BB_PATH_VENDOR . '/autoload.php';
|
||||
|
||||
@@ -113,6 +114,7 @@ final class Box_Installer
|
||||
}
|
||||
|
||||
$this->makeInstall($this->session);
|
||||
$this->generateEmailTemplates();
|
||||
session_destroy();
|
||||
print 'ok';
|
||||
} catch(Exception $e) {
|
||||
@@ -446,6 +448,16 @@ final class Box_Installer
|
||||
throw new Exception('License Key is not valid');
|
||||
}
|
||||
}
|
||||
|
||||
private function generateEmailTemplates()
|
||||
{
|
||||
define('BB_PATH_MODS', BB_PATH_ROOT . '/bb-modules');
|
||||
|
||||
$emailService = new \Box\Mod\Email\Service();
|
||||
$di = $di = include BB_PATH_ROOT . '/bb-di.php';
|
||||
$emailService->setDi($di);
|
||||
return $emailService->templateBatchGenerate();
|
||||
}
|
||||
}
|
||||
|
||||
$action = isset($_GET['a']) ? $_GET['a'] : 'index';
|
||||
|
||||
@@ -150,7 +150,12 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
->getMock();
|
||||
$adapterMock->expects($this->atLeastOnce())
|
||||
->method('getParam')
|
||||
->withConsecutive('notify_url', 'return_url', 'return_url', 'cancel_url');
|
||||
->withConsecutive(
|
||||
array('ik_co_id'),
|
||||
array('notify_url'),
|
||||
array('return_url'),
|
||||
array('return_url'),
|
||||
array('cancel_url'));
|
||||
|
||||
$paymentInvoiceMock = $this->getMockBuilder('Payment_Invoice')
|
||||
->getMock();
|
||||
@@ -234,7 +239,9 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$adapterMock->expects($this->atLeastOnce())
|
||||
->method('getParam')
|
||||
->withConsecutive('ik_co_id', 'ik_secret_key')
|
||||
->withConsecutive(
|
||||
array('ik_co_id'),
|
||||
array('ik_secret_key'))
|
||||
->willReturnOnConsecutiveCalls($shop_id, $secret_key);
|
||||
|
||||
$data = array(
|
||||
@@ -265,7 +272,9 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$adapterMock->expects($this->atLeastOnce())
|
||||
->method('getParam')
|
||||
->withConsecutive('ik_co_id', 'ik_secret_key')
|
||||
->withConsecutive(
|
||||
array('ik_co_id'),
|
||||
array('ik_secret_key'))
|
||||
->willReturnOnConsecutiveCalls($shop_id, $secret_key);
|
||||
|
||||
$data = array(
|
||||
@@ -291,7 +300,11 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$adapterMock->expects($this->atLeastOnce())
|
||||
->method('getParam')
|
||||
->withConsecutive('ik_co_id', 'ik_secret_key', 'test_mode', 'ik_secret_key_test')
|
||||
->withConsecutive(
|
||||
array('ik_co_id'),
|
||||
array('ik_secret_key'),
|
||||
array('test_mode'),
|
||||
array('ik_secret_key_test'))
|
||||
->willReturnOnConsecutiveCalls($shop_id, $secret_key, true, $secret_key);
|
||||
|
||||
$data = array(
|
||||
@@ -355,7 +368,10 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->withConsecutive('Transaction', 'Invoice', 'Client')
|
||||
->withConsecutive(
|
||||
array('Transaction'),
|
||||
array('Invoice'),
|
||||
array('Client'))
|
||||
->willReturnOnConsecutiveCalls($transactionModel, $invoiceModel, $clientModel);
|
||||
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
@@ -389,14 +405,18 @@ class Payment_Adapter_InterkassaTest extends PHPUnit_Framework_TestCase {
|
||||
$api_admin = new \Api_Handler($adminModel);
|
||||
|
||||
$transaction_id = 1;
|
||||
$invoice_id = 22;
|
||||
$data = array(
|
||||
'post' => array(
|
||||
'ik_x_iid' => 1,
|
||||
'ik_x_iid' => $invoice_id,
|
||||
'ik_trn_id' => 2,
|
||||
'ik_inv_st' => 'success',
|
||||
'ik_am' => 1.00,
|
||||
'ik_cur' => 'USD',
|
||||
),
|
||||
'get'=> array(
|
||||
'bb_invoice_id' => $invoice_id
|
||||
)
|
||||
);
|
||||
$gateway_id = 1;
|
||||
$adapterMock->processTransaction($api_admin, $transaction_id, $data, $gateway_id);
|
||||
|
||||
@@ -678,9 +678,6 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
|
||||
$promo->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$dbMock = $this->getMockBuilder('Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('getExistingModelById')
|
||||
->will($this->returnValue($invoice));
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->will($this->returnValue($promo));
|
||||
|
||||
@@ -175,5 +175,52 @@ class ClientTest extends \PHPUnit_Framework_TestCase {
|
||||
$result = $api->update($data);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testbalance_get_total()
|
||||
{
|
||||
$balanceAmount = 0.00;
|
||||
$model = new \Model_Client();
|
||||
$model->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$serviceMock = $this->getMockBuilder('\Box\Mod\Client\ServiceBalance')->getMock();
|
||||
$serviceMock->expects($this->atLeastOnce())
|
||||
->method('getClientBalance')
|
||||
->will($this->returnValue($balanceAmount));
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['mod_service'] = $di->protect(function ($name, $sub) use($serviceMock) {return $serviceMock;});
|
||||
|
||||
$api = new \Box\Mod\Client\Api\Client();
|
||||
$api->setDi($di);
|
||||
$api->setIdentity($model);
|
||||
|
||||
$result = $api->balance_get_total();
|
||||
|
||||
$this->assertInternalType('float', $result);
|
||||
$this->assertEquals($balanceAmount, $result);
|
||||
|
||||
}
|
||||
|
||||
public function testis_taxable()
|
||||
{
|
||||
$clientIsTaxable = true;
|
||||
|
||||
$serviceMock = $this->getMockBuilder('\Box\Mod\Client\Service')->getMock();
|
||||
$serviceMock->expects($this->atLeastOnce())
|
||||
->method('isClientTaxable')
|
||||
->willReturn($clientIsTaxable);
|
||||
|
||||
$client = new \Model_Client();
|
||||
$client->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$api = new \Box\Mod\Client\Api\Client();
|
||||
$api->setService($serviceMock);
|
||||
$api->setIdentity($client);
|
||||
|
||||
$result = $api->is_taxable();
|
||||
$this->assertInternalType('bool', $result);
|
||||
$this->assertEquals($clientIsTaxable, $result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,7 +1039,9 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
$di['auth'] = $authMock;
|
||||
|
||||
$di['mod_config'] = $di->protect(function ($name) use($di) {
|
||||
return array ('require_email_confirmation' => false);
|
||||
});
|
||||
$service = new \Box\Mod\Client\Service();
|
||||
$service->setDi($di);
|
||||
|
||||
@@ -1047,5 +1049,76 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
|
||||
$this->assertInstanceOf('\Model_Client', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box_Exception
|
||||
*/
|
||||
public function testauthorizeClientEmailRequiredNotConfirmed()
|
||||
{
|
||||
$email = 'example@boxbilling.vm';
|
||||
$password = '123456';
|
||||
|
||||
$clientModel = new \Model_Client();
|
||||
$clientModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('findOne')
|
||||
->with('Client')
|
||||
->willReturn($clientModel);
|
||||
|
||||
$authMock = $this->getMockBuilder('\Box_Authorization')->disableOriginalConstructor()->getMock();
|
||||
$authMock->expects($this->never())
|
||||
->method('authorizeUser')
|
||||
->with($clientModel, $password)
|
||||
->willReturn($clientModel);
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
$di['auth'] = $authMock;
|
||||
$di['mod_config'] = $di->protect(function ($name) use ($di) {
|
||||
return array('require_email_confirmation' => true);
|
||||
});
|
||||
$service = new \Box\Mod\Client\Service();
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->authorizeClient($email, $password);
|
||||
$this->assertInstanceOf('\Model_Client', $result);
|
||||
}
|
||||
|
||||
|
||||
public function testauthorizeClientEmailRequiredConfirmed()
|
||||
{
|
||||
$email = 'example@boxbilling.vm';
|
||||
$password = '123456';
|
||||
|
||||
$clientModel = new \Model_Client();
|
||||
$clientModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$clientModel->email_approved = 1;
|
||||
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('findOne')
|
||||
->with('Client')
|
||||
->willReturn($clientModel);
|
||||
|
||||
$authMock = $this->getMockBuilder('\Box_Authorization')->disableOriginalConstructor()->getMock();
|
||||
$authMock->expects($this->any())
|
||||
->method('authorizeUser')
|
||||
->with($clientModel, $password)
|
||||
->willReturn($clientModel);
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
$di['auth'] = $authMock;
|
||||
$di['mod_config'] = $di->protect(function ($name) use ($di) {
|
||||
return array('require_email_confirmation' => true);
|
||||
});
|
||||
$service = new \Box\Mod\Client\Service();
|
||||
$service->setDi($di);
|
||||
|
||||
$result = $service->authorizeClient($email, $password);
|
||||
$this->assertInstanceOf('\Model_Client', $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -411,6 +411,11 @@ class AdminTest extends \PHPUnit_Framework_TestCase
|
||||
$adminApi = new \Box\Mod\Email\Api\Admin();
|
||||
|
||||
$modelId = rand(1, 100);
|
||||
|
||||
$templateModel = new \Model_EmailTemplate();
|
||||
$templateModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$templateModel->id = $modelId;
|
||||
|
||||
$data = array(
|
||||
'action_code' => 'Action_code',
|
||||
'subject' => 'Subject',
|
||||
@@ -420,7 +425,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase
|
||||
$emailService = $this->getMockBuilder('Box\Mod\Email\Service')->setMethods(array('templateCreate'))->getMock();
|
||||
$emailService->expects($this->atLeastOnce())
|
||||
->method('templateCreate')
|
||||
->will($this->returnValue($modelId));
|
||||
->will($this->returnValue($templateModel));
|
||||
$adminApi->setService($emailService);
|
||||
|
||||
$result = $adminApi->template_create($data);
|
||||
|
||||
@@ -874,7 +874,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$result = $service->templateCreate($data['action_code'], $data['subject'], $data['content'], 1, $data['category']);
|
||||
|
||||
$this->assertEquals($id, $result);
|
||||
$this->assertEquals($emailTemplateModel, $result);
|
||||
}
|
||||
|
||||
public function testBatchTemplateGenerateProvider()
|
||||
|
||||
@@ -117,10 +117,14 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
);
|
||||
$newInvoiceId = 1;
|
||||
|
||||
$invoiceModel = new \Model_Invoice();
|
||||
$invoiceModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$invoiceModel->id = $newInvoiceId;
|
||||
|
||||
$serviceMock = $this->getMockBuilder('\Box\Mod\Invoice\Service')->getMock();
|
||||
$serviceMock->expects($this->atLeastOnce())
|
||||
->method('prepareInvoice')
|
||||
->will($this->returnValue($newInvoiceId));
|
||||
->will($this->returnValue($invoiceModel));
|
||||
|
||||
$validatorMock = $this->getMockBuilder('\Box_Validate')->getMock();
|
||||
$validatorMock->expects($this->atLeastOnce())
|
||||
|
||||
@@ -367,6 +367,33 @@ class ClientTest extends \PHPUnit_Framework_TestCase {
|
||||
$this->assertInternalType('array', $result);
|
||||
}
|
||||
|
||||
public function testget_tax_rate()
|
||||
{
|
||||
$client = new \Model_Client();
|
||||
$client->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$taxRate = 20;
|
||||
|
||||
$invoiceTaxService = $this->getMockBuilder('\Box\Mod\Invoice\ServiceTax')
|
||||
->getMock();
|
||||
$invoiceTaxService->expects($this->atLeastOnce())
|
||||
->method('getTaxRateForClient')
|
||||
->willReturn($taxRate);
|
||||
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['mod_service'] = $di->protect(function ($service, $sub) use($invoiceTaxService){
|
||||
if ($service == 'Invoice' && $sub == 'Tax'){
|
||||
return $invoiceTaxService;
|
||||
}
|
||||
});
|
||||
$this->api->setDi($di);
|
||||
$this->api->setIdentity($client);
|
||||
|
||||
$result = $this->api->get_tax_rate();
|
||||
$this->assertEquals($taxRate, $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -628,8 +628,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$serviceMock->setDi($di);
|
||||
$result = $serviceMock->prepareInvoice($clientModel, $data);
|
||||
$this->assertInternalType('int', $result);
|
||||
$this->assertEquals($newRecordId, $result);
|
||||
$this->assertInstanceOf('Model_Invoice', $result);
|
||||
}
|
||||
|
||||
public function testsetInvoiceDefaults()
|
||||
|
||||
@@ -362,18 +362,27 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
|
||||
$validatorMock = $this->getMockBuilder('\Box_Validate')->getMock();
|
||||
$validatorMock->expects($this->atLeastOnce())->method('isPasswordStrong');
|
||||
|
||||
$password = 'new password';
|
||||
|
||||
$passwordMock = $this->getMockBuilder('\Box_Password')->getMock();
|
||||
$passwordMock->expects($this->atLeastOnce())
|
||||
->method('hashIt')
|
||||
->with($password);
|
||||
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['logger'] = new \Box_Log();
|
||||
$di['events_manager'] = $emMock;
|
||||
$di['db'] = $dbMock;
|
||||
$di['validator'] = $validatorMock;
|
||||
$di['password'] = $passwordMock;
|
||||
|
||||
$model = new \Model_Client();
|
||||
$model->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$service = new Service();
|
||||
$service->setDi($di);
|
||||
$result = $service->changeClientPassword($model, 'new password');
|
||||
$result = $service->changeClientPassword($model, $password);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
->method('getService')
|
||||
->willReturn($themeServiceMock);
|
||||
|
||||
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
|
||||
$eventMock->expects($this->atLeastOnce())->method('fire');
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['mod'] = $di->protect(function ($name) use($modMock){
|
||||
if ($name == 'theme')
|
||||
@@ -129,6 +132,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
return $modMock;
|
||||
}
|
||||
});
|
||||
$di['events_manager'] = $eventMock;
|
||||
|
||||
$controller = new \Box\Mod\Theme\Controller\Admin();
|
||||
$controller->setDi($di);
|
||||
@@ -174,6 +178,9 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
->method('getService')
|
||||
->willReturn($themeServiceMock);
|
||||
|
||||
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
|
||||
$eventMock->expects($this->atLeastOnce())->method('fire');
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['mod'] = $di->protect(function ($name) use($modMock){
|
||||
if ($name == 'theme')
|
||||
@@ -181,6 +188,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase {
|
||||
return $modMock;
|
||||
}
|
||||
});
|
||||
$di['events_manager'] = $eventMock;
|
||||
|
||||
$controller = new \Box\Mod\Theme\Controller\Admin();
|
||||
$controller->setDi($di);
|
||||
|
||||
Vendored
+6
-6
@@ -7,12 +7,12 @@
|
||||
<client id="1" aid="1" role="client" email="client@boxbilling.com" pass="89e495e7941cf9e40e6980d14a16bf023ccd4c91" status="active" first_name="Demo" last_name="Client" phone_cc="1" phone="646-123-4567" company="BoxBilling" address_1="Wall Street 45" city="New York" country="US" currency="USD" postcode="123456" api_token="phpunit_token" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
<client_password_reset id="1" client_id="1" hash="hash" ip="123456" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
|
||||
<client_order id="1" client_id="1" group_id="1" product_id="1" currency="USD" service_type="custom" period="1M" quantity="1" price="10" status="pending_setup" notes="Created order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="2" client_id="1" group_id="1" product_id="2" currency="USD" service_type="license" period="1M" quantity="1" price="10" status="pending_setup" notes="License order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="3" client_id="1" group_id="1" product_id="10" currency="USD" service_type="domain" period="1M" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="1" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="1" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order_status id="1" client_order_id="1" status="pending" notes="Created order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="1" client_id="1" group_id="400" product_id="1" currency="USD" service_type="custom" period="1M" quantity="1" price="10" status="pending_setup" notes="Created order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="2" client_id="1" group_id="400" product_id="2" currency="USD" service_type="license" period="1M" quantity="1" price="10" status="pending_setup" notes="License order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="3" client_id="1" group_id="400" product_id="10" currency="USD" service_type="domain" period="1M" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="400" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="400" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order_status id="1" client_order_id="400" status="pending" notes="Created order" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<post id="1" title="Test" status="active" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
<post id="2" title="Test" status="active" slug="boxbilling-is-customizable" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
|
||||
Vendored
+13
-12
@@ -52,20 +52,20 @@
|
||||
<product id="16" product_category_id="1" product_payment_id="12" type="boxbillinglicense" title="BoxBilling license" description="BoxBilling License product" unit="product" active="1" is_addon="0" addons="" config='' setup="after_payment" plugin="" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
<product id="17" product_category_id="1" product_payment_id="13" type="boxbillinglicense" title="BoxBilling license" description="BoxBilling License product" unit="product" active="1" is_addon="0" addons="" config='' setup="after_payment" plugin="" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
|
||||
<client_order id="1" client_id="1" group_id="1" group_master="1" product_id="1" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="2" client_id="1" group_id="1" product_id="2" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" config='{"plugin":"Example"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="1" client_id="1" group_id="100" group_master="1" product_id="1" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="2" client_id="1" group_id="100" product_id="2" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" config='{"plugin":"Example"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<client_order id="3" client_id="1" group_id="3" product_id="6" currency="USD" service_type="license" period="1M" quantity="1" price="30" status="pending_setup" notes="" config='{"plugin":"Simple", "prefix":"PRO-"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="3" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="30" status="pending_setup" notes="" config='{"filename":"test.txt"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="3" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"mysuperdomain","tld":".com"}' created_at="2011-10-25T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="6" client_id="1" group_id="3" product_id="9" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"myresellerdomain","tld":".com"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="7" client_id="1" group_id="3" product_id="10" currency="USD" service_type="domain" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='{"action":"register","register_tld":".com","register_sld":"admindomain", "register_years":1}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="9" client_id="1" group_id="3" product_id="10" currency="USD" service_type="membership" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="3" client_id="1" group_id="300" product_id="6" currency="USD" service_type="license" period="1M" quantity="1" price="30" status="pending_setup" notes="" config='{"plugin":"Simple", "prefix":"PRO-"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="300" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="30" status="pending_setup" notes="" config='{"filename":"test.txt"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="300" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"mysuperdomain","tld":".com"}' created_at="2011-10-25T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="6" client_id="1" group_id="300" product_id="9" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"myresellerdomain","tld":".com"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="7" client_id="1" group_id="300" product_id="10" currency="USD" service_type="domain" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='{"action":"register","register_tld":".com","register_sld":"admindomain", "register_years":1}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="9" client_id="1" group_id="300" product_id="10" currency="USD" service_type="membership" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<client_order id="8" client_id="1" group_id="2" group_master="1" promo_id="3" promo_recurring="1" promo_used="1" product_id="1" currency="USD" service_type="custom" service_id="1" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="10" client_id="1" group_id="3" promo_id="3" promo_recurring="0" promo_used="1" product_id="1" currency="USD" service_type="custom" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="12" client_id="1" group_id="3" promo_id="" promo_recurring="0" promo_used="0" product_id="15" currency="USD" service_type="solusvm" period="3M" quantity="1" price="30" discount="0" status="pending_setup" notes="" config='{"server_id":"1", "plan":"Small", "hostname":"vpsdomain.com", "template":"centos-6-x86"}' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="13" client_id="1" group_id="3" service_type="boxbillinglicense" service_id="1" status="pending_setup"/>
|
||||
<client_order id="8" client_id="1" group_id="200" group_master="1" promo_id="3" promo_recurring="1" promo_used="1" product_id="1" currency="USD" service_type="custom" service_id="1" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="10" client_id="1" group_id="300" promo_id="3" promo_recurring="0" promo_used="1" product_id="1" currency="USD" service_type="custom" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="12" client_id="1" group_id="300" promo_id="" promo_recurring="0" promo_used="0" product_id="15" currency="USD" service_type="solusvm" period="3M" quantity="1" price="30" discount="0" status="pending_setup" notes="" config='{"server_id":"1", "plan":"Small", "hostname":"vpsdomain.com", "template":"centos-6-x86"}' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="13" client_id="1" group_id="300" service_type="boxbillinglicense" service_id="1" status="pending_setup"/>
|
||||
|
||||
<cart id="1" currency_id="1" created_at="2011-10-24T15:23:43+03:00"/>
|
||||
<invoice />
|
||||
@@ -76,6 +76,7 @@
|
||||
<service_downloadable />
|
||||
<service_hosting />
|
||||
<service_membership />
|
||||
<client_order_status />
|
||||
|
||||
<service_hosting id="1" client_id="1" service_hosting_hp_id="1" sld="exist" tld=".com" />
|
||||
|
||||
|
||||
Vendored
+11
-11
@@ -50,18 +50,18 @@
|
||||
<client_order id="1" client_id="1" group_id="1" group_master="1" product_id="1" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="2" client_id="1" group_id="1" product_id="2" currency="USD" service_type="custom" period="" quantity="1" price="10" status="pending_setup" notes="" config='{"plugin":"Example"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<client_order id="3" client_id="1" group_id="3" product_id="6" currency="USD" service_type="license" period="1M" quantity="1" price="30" status="pending_setup" notes="" config='{"plugin":"Simple", "prefix":"PRO-"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="3" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="30" status="pending_setup" notes="" config='{"filename":"test.txt"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="3" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"mysuperdomain","tld":".com"}' created_at="2011-10-25T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="6" client_id="1" group_id="3" product_id="9" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"myresellerdomain","tld":".com"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="7" client_id="1" group_id="3" product_id="10" currency="USD" service_type="domain" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='{"action":"register","register_tld":".com","register_sld":"admindomain", "register_years":1}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="9" client_id="1" group_id="3" product_id="10" currency="USD" service_type="membership" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="3" client_id="1" group_id="300" product_id="6" currency="USD" service_type="license" period="1M" quantity="1" price="30" status="pending_setup" notes="" config='{"plugin":"Simple", "prefix":"PRO-"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="300" product_id="7" currency="USD" service_type="downloadable" period="" quantity="1" price="30" status="pending_setup" notes="" config='{"filename":"test.txt"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="300" product_id="8" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"mysuperdomain","tld":".com"}' created_at="2011-10-25T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="6" client_id="1" group_id="300" product_id="9" currency="USD" service_type="hosting" period="3M" quantity="1" price="30" status="pending_setup" notes="" config='{"server_id":"1", "hosting_plan_id":"1", "sld":"myresellerdomain","tld":".com"}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="7" client_id="1" group_id="300" product_id="10" currency="USD" service_type="domain" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='{"action":"register","register_tld":".com","register_sld":"admindomain", "register_years":1}' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="9" client_id="1" group_id="300" product_id="10" currency="USD" service_type="membership" period="2Y" quantity="1" price="30" status="pending_setup" notes="" config='' created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<client_order id="8" client_id="1" group_id="2" group_master="1" promo_id="3" promo_recurring="1" promo_used="1" product_id="1" currency="USD" service_type="custom" service_id="1" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="10" client_id="1" group_id="3" promo_id="3" promo_recurring="0" promo_used="1" product_id="1" currency="USD" service_type="custom" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="12" client_id="1" group_id="3" promo_id="" promo_recurring="0" promo_used="0" product_id="15" currency="USD" service_type="solusvm" period="3M" quantity="1" price="30" discount="0" status="pending_setup" notes="" config='{"server_id":"1", "plan":"mazas", "hostname":"vpsdomain.com", "template":"centos-6-x86"}' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="13" client_id="1" group_id="3" service_type="boxbillinglicense" service_id="1" status="pending_setup"/>
|
||||
<client_order_status id="1" client_order_id="1" status="active" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" />
|
||||
<client_order id="8" client_id="1" group_id="200" group_master="1" promo_id="3" promo_recurring="1" promo_used="1" product_id="1" currency="USD" service_type="custom" service_id="1" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="10" client_id="1" group_id="300" promo_id="3" promo_recurring="0" promo_used="1" product_id="1" currency="USD" service_type="custom" period="1Y" quantity="1" price="30" discount="15" status="active" notes="" config='' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="12" client_id="1" group_id="300" promo_id="" promo_recurring="0" promo_used="0" product_id="15" currency="USD" service_type="solusvm" period="3M" quantity="1" price="30" discount="0" status="pending_setup" notes="" config='{"server_id":"1", "plan":"mazas", "hostname":"vpsdomain.com", "template":"centos-6-x86"}' expires_at="2011-12-25T15:23:43+03:00" created_at="2011-11-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="13" client_id="1" group_id="300" service_type="boxbillinglicense" service_id="1" status="pending_setup"/>
|
||||
<client_order_status id="1" client_order_id="100" status="active" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00" />
|
||||
|
||||
<cart />
|
||||
<service_custom />
|
||||
|
||||
Vendored
+3
-3
@@ -8,9 +8,9 @@
|
||||
<pay_gateway id="2" name="PayPal" gateway="PayPalEmail" enabled="1" config='{"email":"john.doe@gmail.com"}'/>
|
||||
<pay_gateway id="3" name="TwoCheckout" gateway="TwoCheckout" enabled="1" config='{"vendor_nr":"1", "secret":123}'/>
|
||||
|
||||
<client_order id="3" client_id="1" group_id="1" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="1" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="1" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="active" notes="" expires_at="2012-10-10" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="3" client_id="1" group_id="100" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="4" client_id="1" group_id="100" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="pending_setup" notes="" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
<client_order id="5" client_id="1" group_id="100" product_id="10" currency="USD" service_type="custom" period="1M" quantity="1" price="8.99" status="active" notes="" expires_at="2012-10-10" created_at="2011-10-24T15:23:43+03:00" updated_at="2011-10-24T15:23:43+03:00"/>
|
||||
|
||||
<invoice id="1" client_id="1" hash="hash" currency="USD" status="unpaid" due_at="2014-01-01T12:00:00+00:00" created_at="2011-11-01T12:00:00+00:00" updated_at="2011-11-01T12:00:00+00:00"/>
|
||||
<invoice_item id="1" invoice_id="1" type="custom" task="void" title="Payment for development services" period="" quantity="10" unit="hours" price="50" created_at="2011-01-01T12:00:00+00:00" updated_at="2011-01-01T12:00:00+00:00"/>
|
||||
|
||||
@@ -102,4 +102,86 @@ class Box_Mod_Cart_Api_ClientTest extends BBDbApiTestCase
|
||||
$this->assertEquals(9874, $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checkout cart with product with addon and client has insufficient funds to cover
|
||||
*/
|
||||
public function testAddonActivatedWhileOrderInvoiceUnpaid()
|
||||
{
|
||||
|
||||
$this->api_guest->cart_reset();
|
||||
$data = array(
|
||||
'id' => 11,
|
||||
'period' => '6M',
|
||||
'domain' => array(
|
||||
'action' => "register",
|
||||
'owndomain_sld' =>"",
|
||||
'owndomain_tld' =>".com",
|
||||
'register_sld' =>"newdomainregister",
|
||||
'register_tld' =>".com",
|
||||
'register_years' => "1",
|
||||
),
|
||||
'multiple' => 1,
|
||||
|
||||
);
|
||||
$this->api_guest->cart_add_item($data);
|
||||
$this->api_client->cart_checkout();
|
||||
|
||||
$masterOrder = $this->di['db']->findOne('ClientOrder', 'group_master = 1 ORDER BY id desc');
|
||||
$addonOrder = $this->di['db']->findOne('ClientOrder', 'group_id = ? and group_master = 0', array($masterOrder->group_id));
|
||||
|
||||
$invoiceModel = $this->di['db']->load('Invoice', $masterOrder->unpaid_invoice_id);
|
||||
|
||||
$this->assertInstanceOf('Model_ClientOrder', $masterOrder);
|
||||
$this->assertInstanceOf('Model_ClientOrder', $addonOrder);
|
||||
$this->assertInstanceOf('Model_Invoice', $invoiceModel);
|
||||
|
||||
$this->assertNotNull($masterOrder->unpaid_invoice_id);
|
||||
$this->assertEquals(Model_ClientOrder::STATUS_PENDING_SETUP, $masterOrder->status);
|
||||
$this->assertEquals(Model_ClientOrder::STATUS_PENDING_SETUP, $addonOrder->status);
|
||||
$this->assertEquals(Model_Invoice::STATUS_UNPAID, $invoiceModel->status);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* checkout cart with product with addon and client has sufficient funds to cover
|
||||
*/
|
||||
public function testOrderWithAddonCoverFromAccountBalance()
|
||||
{
|
||||
$this->api_guest->cart_reset();
|
||||
$data = array(
|
||||
'id' => 11,
|
||||
'period' => '6M',
|
||||
'domain' => array(
|
||||
'action' => "register",
|
||||
'owndomain_sld' =>"",
|
||||
'owndomain_tld' =>".com",
|
||||
'register_sld' =>"newdomainregister2",
|
||||
'register_tld' =>".com",
|
||||
'register_years' => "1",
|
||||
),
|
||||
'multiple' => 1,
|
||||
|
||||
);
|
||||
|
||||
$this->api_admin->client_balance_add_funds(array('id' => 1, 'amount' => 100, 'description' => 'Added from PHPUnit'));
|
||||
$this->api_guest->cart_add_item($data);
|
||||
$this->api_client->cart_checkout();
|
||||
|
||||
$masterOrder = $this->di['db']->findOne('ClientOrder', 'group_master = 1 ORDER BY id desc');
|
||||
$addonOrder = $this->di['db']->findOne('ClientOrder', 'group_id = ? and group_master = 0', array($masterOrder->group_id));
|
||||
|
||||
$invoiceItemModel = $this->di['db']->findOne('InvoiceItem', "type = 'order' and rel_id = ?", array($masterOrder->id));
|
||||
$invoiceModel = $this->di['db']->load('Invoice', $invoiceItemModel->invoice_id);
|
||||
|
||||
$this->assertInstanceOf('Model_ClientOrder', $masterOrder);
|
||||
$this->assertInstanceOf('Model_ClientOrder', $addonOrder);
|
||||
$this->assertInstanceOf('Model_Invoice', $invoiceModel);
|
||||
|
||||
$this->assertNull($masterOrder->unpaid_invoice_id);
|
||||
$this->assertEquals(Model_ClientOrder::STATUS_ACTIVE, $masterOrder->status);
|
||||
$this->assertEquals(Model_ClientOrder::STATUS_ACTIVE, $addonOrder->status);
|
||||
$this->assertEquals(Model_Invoice::STATUS_PAID, $invoiceModel->status);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -210,7 +210,7 @@ class Api_Admin_OrderTest extends BBDbApiTestCase
|
||||
$data['client_id'] = 1;
|
||||
$data['product_id'] = $pid;
|
||||
$data['period'] = '1M';
|
||||
$data['group_id'] = 2;
|
||||
$data['group_id'] = 200;
|
||||
// $data['currency'] = 'EUR';
|
||||
// $data['invoice_option'] = 'issue-invoice';
|
||||
$data['invoice_option'] = 'no-invoice';
|
||||
|
||||
Reference in new issue
Block a user