Skip to content

Commit

Permalink
release 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sveateam committed Jan 21, 2019
1 parent ac35024 commit 52f73e2
Show file tree
Hide file tree
Showing 77 changed files with 1,874 additions and 649 deletions.
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright [2018] [Svea Ekonomi AB]
Copyright [2019] [Svea Ekonomi AB]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -10,4 +10,4 @@ Copyright [2018] [Svea Ekonomi AB]
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## OpenCart - Svea checkout and payment modules

* Supports OpenCart 2.3.0.2 - 3.0.2.0 (older versions can be found in the branches)
* Supports OpenCart 2.3.0.2 - 3.1.0.0_a1 (older versions can be found in the branches)
* Requires PHP 5.3 or higher (namespace support)
* Includes Sveas iframe checkout page
* Includes Svea Checkout with invoices, payment plans, card and direct bank payments
Expand Down Expand Up @@ -216,13 +216,16 @@ To fix this you have to go in to your database and to the table oc_order and fin

## 3.3 Product Price Widget <a name="i3-3"></a>

Enabling the product price widget on either Svea Invoice or Svea Part payment will result in a "price box" appearing on the product page. Clicking the box will show different campaigns that the customer can use to pay.
Enabling the product price widget on either Svea Checkout, Svea Invoice or Svea Part payment will result in a "price box" appearing on the product page.

If you set "Show Product Price Widget" to yes in your module options a widget will be displaying the minimum invoice amount to pay on the product page. Note: Only applicable if Svea buys the invoices, and for private customers.
Only applies in Sweden, Norway, Finland.
Only applicable in Sweden, Norway, Finland.

Note! Requires [vQmod](https://github.com/vqmod).

Example:

![Product price widget](docs/image/widget.png "Product price widget")

## 3.4 Important information <a name="i3-4"></a>

The request made from the card and direct payment modules to Sveas systems is made through a redirected form.
Expand Down
Binary file added docs/image/Widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"module_name": "Opencart",
"module_version": "4.4.1",
"module_version": "4.5.0",
"module_shop_version_support": [
"4.4.1"
"4.5.0"
],
"invoice_paymentplan": {
"invoice": [
Expand Down
109 changes: 107 additions & 2 deletions src/admin/controller/extension/module/sco.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

require_once(DIR_APPLICATION . '../svea/config/configInclude.php');

class ControllerExtensionModuleSco extends Controller
{
private $error = array();

// Use this name as params prefix (Svea checkout)
private $module_version = '4.4.1';
private $module_version = '4.5.0';

//backwards compatability
private $userTokenString = "user_";
Expand Down Expand Up @@ -42,6 +44,11 @@ public function index()
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting($this->moduleString . 'sco', $this->request->post);

if($this->request->post[$this->moduleString . 'sco_show_widget_on_product_page'] == 1)
{
$this->updateCampaigns();
}

// success message
$this->session->data['success'] = $this->language->get('text_success');

Expand Down Expand Up @@ -87,13 +94,14 @@ public function index()
'show_coupons_on_checkout' => '1',
'show_voucher_on_checkout' => '1',
'show_order_comment_on_checkout' => '1',
'show_widget_on_product_page' => '0',
'checkout_terms_uri' => '',
'checkout_default_country_id' => '',
);
$data['options_on_checkout_page'] = array(
$this->moduleString . 'sco_show_coupons_on_checkout' => $this->language->get('text_show_coupons_on_checkout'),
$this->moduleString . 'sco_show_voucher_on_checkout' => $this->language->get('text_show_voucher_on_checkout'),
$this->moduleString . 'sco_show_order_comment_on_checkout' => $this->language->get('text_show_order_comment_on_checkout')
$this->moduleString . 'sco_show_order_comment_on_checkout' => $this->language->get('text_show_order_comment_on_checkout'),
);

$data['text_yes'] = $this->language->get('text_yes');
Expand Down Expand Up @@ -254,6 +262,7 @@ public function uninstall()

private function setLanguage()
{
$this->setVersionStrings();
$data = array();

// Set title
Expand Down Expand Up @@ -291,6 +300,11 @@ private function setLanguage()
$data['button_save'] = $this->language->get('button_save');
$data['button_cancel'] = $this->language->get('button_cancel');

$data['entry_' . $this->moduleString . 'sco_show_widget_on_product_page'] = $this->language->get('text_show_widget_on_product_page');
$data['entry_' . $this->moduleString . 'sco_show_widget_on_product_page_tooltip'] = $this->language->get('text_show_widget_on_product_page_tooltip');

$data['version'] = VERSION;

$module_info_data_url = $url = "https://raw.githubusercontent.com/sveawebpay/opencart-module/master/docs/info.json";
$json_info = file_get_contents($module_info_data_url);
$decoded_data = json_decode($json_info);
Expand Down Expand Up @@ -359,5 +373,96 @@ private function setCheckoutDBTable()
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ");
}
}
private function updateCampaigns()
{
$this->setVersionStrings();

$this->db->query('CREATE TABLE IF NOT EXISTS `' . DB_PREFIX . $this->moduleString .'sco_campaigns`
(`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`campaignCode` VARCHAR( 100 ) NOT NULL,
`contractLengthInMonths` INT NOT NULL ,
`description` VARCHAR( 100 ) NOT NULL ,
`fromAmount` DOUBLE NOT NULL ,
`initialFee` DOUBLE NOT NULL ,
`interestRatePercent` INT NOT NULL ,
`monthlyAnnuityFactor` DOUBLE NOT NULL ,
`notificationFee` DOUBLE NOT NULL ,
`numberOfInterestFreeMonths` INT NOT NULL ,
`numberOfPaymentFreeMonths` INT NOT NULL ,
`paymentPlanType` VARCHAR( 100 ) NOT NULL ,
`toAmount` DOUBLE NOT NULL ,
`timestamp` INT UNSIGNED NOT NULL,
`countryCode` VARCHAR( 100 ) NOT NULL,
`productionEnvironment` INT NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
');

$this->db->query('TRUNCATE TABLE ' . DB_PREFIX . $this->moduleString .'sco_campaigns');

$testMode = $this->model_setting_setting->getSettingValue($this->moduleString . 'sco_test_mode');

$config = ($testMode == "1") ? new OpencartSveaCheckoutConfigTest($this->config) : new OpencartSveaCheckoutConfig($this->config);
$testString = ($testMode == "1") ? "'" . $this->moduleString . "sco_checkout_test_merchant_id_%'" : "'" . $this->moduleString . "sco_checkout_merchant_id_%'";

$countriesQuery = $this->db->query("SELECT `key`, `value` FROM " . DB_PREFIX . "setting WHERE `key` LIKE " . $testString . ";");

foreach ($countriesQuery->rows as $val) {
if ($val['value'] != "") {
$request = \Svea\WebPay\WebPay::checkout($config);

$presetValueIsCompany = \Svea\WebPay\WebPayItem::presetValue()
->setTypeName(\Svea\WebPay\Checkout\Model\PresetValue::IS_COMPANY)
->setValue(false)
->setIsReadonly(true);

$request->setCountryCode(strtoupper(substr($val['key'], -2)))
->addPresetValue($presetValueIsCompany);

$response = $request->getAvailablePartPaymentCampaigns();

if ($response == null) {

} else {
foreach ($response as $responseResultItem) {
try {
$campaignCode = (isset($responseResultItem['CampaignCode'])) ? $responseResultItem['CampaignCode'] : "";
$description = (isset($responseResultItem['Description'])) ? $responseResultItem['Description'] : "";
$paymentPlanType = (isset($responseResultItem['PaymentPlanType'])) ? $responseResultItem['PaymentPlanType'] : "";
$contractLength = (isset($responseResultItem['ContractLengthInMonths'])) ? $responseResultItem['ContractLengthInMonths'] : "";
$monthlyAnnuityFactor = (isset($responseResultItem['MonthlyAnnuityFactor'])) ? $responseResultItem['MonthlyAnnuityFactor'] : "";
$initialFee = (isset($responseResultItem['InitialFee'])) ? $responseResultItem['InitialFee'] : "";
$notificationFee = (isset($responseResultItem['NotificationFee'])) ? $responseResultItem['NotificationFee'] : "";
$interestRatePercentage = (isset($responseResultItem['InterestRatePercent'])) ? $responseResultItem['InterestRatePercent'] : "";
$interestFreeMonths = (isset($responseResultItem['NumberOfInterestFreeMonths'])) ? $responseResultItem['NumberOfInterestFreeMonths'] : "";
$paymentFreeMonths = (isset($responseResultItem['NumberOfPaymentFreeMonths'])) ? $responseResultItem['NumberOfPaymentFreeMonths'] : "";
$fromAmount = (isset($responseResultItem['FromAmount'])) ? $responseResultItem['FromAmount'] : "";
$toAmount = (isset($responseResultItem['ToAmount'])) ? $responseResultItem['ToAmount'] : "";

try {
$this->db->query("INSERT INTO " . DB_PREFIX . $this->moduleString ."sco_campaigns SET
campaignCode = '" . $this->db->escape($campaignCode) . "',
contractLengthInMonths = '" . $this->db->escape($contractLength) . "',
description = '" . $this->db->escape($description) . "',
fromAmount = '" . $this->db->escape($fromAmount) . "',
initialFee = '" . $this->db->escape($initialFee) . "',
interestRatePercent = '" . $this->db->escape($interestRatePercentage) . "',
monthlyAnnuityFactor = '" . $this->db->escape($monthlyAnnuityFactor) . "',
notificationFee = '" . $this->db->escape($notificationFee) . "',
numberOfInterestFreeMonths = '" . $this->db->escape($interestFreeMonths) . "',
numberOfPaymentFreeMonths = '" . $this->db->escape($paymentFreeMonths) . "',
paymentPlanType = '" . $this->db->escape($paymentPlanType) . "',
toAmount = '" . $this->db->escape($toAmount) . "',
timestamp = '" . $this->db->escape(time()) . "',
countryCode = '" . $this->db->escape(strtoupper(substr($val['key'], -2))) . "'");
} catch (Exception $e) {
$this->log->write($e->getMessage());
}
} catch (Exception $e) {
$this->log->write($e->getMessage());
}
}
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/admin/controller/extension/payment/sco.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function index()
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data['version'] = VERSION;

$this->response->setOutput($this->load->view('extension/payment/sco', $data));
}

Expand Down
15 changes: 13 additions & 2 deletions src/admin/controller/extension/payment/svea_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ControllerExtensionPaymentSveacard extends Controller
{
protected $svea_version = '4.4.1';
protected $svea_version = '4.5.0';
private $error = array();

private $userTokenString = "user_";
Expand Down Expand Up @@ -55,6 +55,9 @@ public function index()
$data['entry_test'] = $this->language->get('entry_test');
$data['entry_prod'] = $this->language->get('entry_prod');

$data['entry_auto_deliver'] = $this->language->get('entry_auto_deliver');
$data['entry_auto_deliver_description'] = $this->language->get('entry_auto_deliver_description');

//Definitions lang
$data['entry_testmode'] = $this->language->get('entry_testmode');
$data['entry_merchant_id'] = $this->language->get('entry_merchant_id');
Expand Down Expand Up @@ -145,10 +148,18 @@ public function index()
$data[$this->paymentString . 'svea_card_testmode'] = $this->config->get($this->paymentString . 'svea_card_testmode');
}

if (isset($this->request->post[$this->paymentString . 'svea_card_auto_deliver'])) {
$data[$this->paymentString . 'svea_card_auto_deliver'] = $this->request->post[$this->paymentString . 'svea_card_auto_deliver'];
} else {
$data[$this->paymentString . 'svea_card_auto_deliver'] = $this->config->get($this->paymentString . 'svea_card_auto_deliver');
}

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data['version'] = VERSION;

$this->response->setOutput($this->load->view('extension/payment/svea_card', $data));
}

Expand All @@ -173,7 +184,7 @@ protected function getSveaVersion()
$json = file_get_contents($url);
$data = json_decode($json);

if ($data->module_version > $this->svea_version) {
if ($data->module_version <= $this->svea_version) {
return "You have the latest " . $this->svea_version . " version.";
} else {
return $this->svea_version . '<br />
Expand Down
6 changes: 4 additions & 2 deletions src/admin/controller/extension/payment/svea_directbank.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ControllerExtensionPaymentSveadirectbank extends Controller
{
protected $svea_version = '4.4.1';
protected $svea_version = '4.5.0';
private $error = array();

private $userTokenString = "user_";
Expand Down Expand Up @@ -147,6 +147,8 @@ public function index()
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data['version'] = VERSION;

$this->response->setOutput($this->load->view('extension/payment/svea_directbank', $data));
}

Expand All @@ -171,7 +173,7 @@ protected function getSveaVersion()
$json = file_get_contents($url);
$data = json_decode($json);

if ($data->module_version > $this->svea_version) {
if ($data->module_version <= $this->svea_version) {
return "You have the latest " . $this->svea_version . " version.";
} else {
return $this->svea_version . '<br />
Expand Down
6 changes: 4 additions & 2 deletions src/admin/controller/extension/payment/svea_invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ControllerExtensionPaymentSveaInvoice extends Controller
{
protected $svea_version = '4.4.1';
protected $svea_version = '4.5.0';
private $error = array();

//backwards compatability
Expand Down Expand Up @@ -186,6 +186,8 @@ public function index()
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data['version'] = VERSION;

$this->response->setOutput($this->load->view('extension/payment/svea_invoice', $data));
}

Expand All @@ -210,7 +212,7 @@ protected function getSveaVersion()
$json = file_get_contents($url);
$data = json_decode($json);

if ($data->module_version > $this->svea_version) {
if ($data->module_version <= $this->svea_version) {
return "You have the latest " . $this->svea_version . " version.";
} else {
return $this->svea_version . '<br />
Expand Down
6 changes: 4 additions & 2 deletions src/admin/controller/extension/payment/svea_partpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ControllerExtensionPaymentSveapartpayment extends Controller
{
protected $svea_version = '4.4.1';
protected $svea_version = '4.5.0';
private $error = array();

private $userTokenString = "user_";
Expand Down Expand Up @@ -166,6 +166,8 @@ public function index()
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

$data['version'] = VERSION;

$this->response->setOutput($this->load->view('extension/payment/svea_partpayment', $data));

}
Expand Down Expand Up @@ -331,7 +333,7 @@ protected function getSveaVersion()
$json = file_get_contents($url);
$data = json_decode($json);

if ($data->module_version > $this->svea_version) {
if ($data->module_version <= $this->svea_version) {
return "You have the latest " . $this->svea_version . " version.";
} else {
return $this->svea_version . '<br />
Expand Down
2 changes: 1 addition & 1 deletion src/admin/controller/extension/total/svea_fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ControllerExtensionTotalSveaFee extends Controller
{
protected $total_svea_version = '4.4.1';
protected $total_svea_version = '4.5.0';
private $error = array();

private $userTokenString = "user_";
Expand Down
2 changes: 2 additions & 0 deletions src/admin/language/en-gb/extension/module/sco.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
$_['text_show_voucher_on_checkout'] = 'Show Voucher on Checkout page';
$_['text_show_coupons_on_checkout'] = 'Show Coupon on Checkout page';
$_['text_show_order_comment_on_checkout'] = 'Show Message on Checkout page';
$_['text_show_widget_on_product_page'] = 'Show product price widget on product page';
$_['text_show_widget_on_product_page_tooltip'] = 'The lowest price of the campaign available for part payment will be displayed on the product page. Using this option require you to have VQMod installed.';

$_['item_voucher'] = 'Voucher';
$_['item_coupon'] = 'Coupon';
Expand Down
2 changes: 1 addition & 1 deletion src/admin/language/en-gb/extension/payment/sco.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
// Text
$_['text_payment'] = 'Payment';
$_['text_edit'] = 'Edit Svea Checkout';
$_['text_no_settings'] = 'There are no settings for this extension!';
$_['text_no_settings'] = 'The Svea Checkout module is found in the category "Module".' ;
$_['text_sco'] = '<img src="view/image/payment/english/sco.png" alt="Svea Checkout" title="Svea Checkout"/>';
$_['text_extension'] = 'Extension';
Loading

0 comments on commit 52f73e2

Please sign in to comment.