Skip to content

Commit

Permalink
Merge pull request #43 from pagantis/INT-943
Browse files Browse the repository at this point in the history
Int 943
  • Loading branch information
pgarcess authored Mar 13, 2020
2 parents 7daf520 + 3575dec commit deb8d63
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
15 changes: 12 additions & 3 deletions WC_Pagantis.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Pagantis
* Plugin URI: http://www.pagantis.com/
* Description: Financiar con Pagantis
* Version: 8.3.2
* Version: 8.3.3
* Author: Pagantis
*/

Expand Down Expand Up @@ -34,7 +34,8 @@ class WcPagantis

public $defaultConfigs = array(
'PAGANTIS_TITLE'=>'Pago en cuotas',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.PRODUCT_PAGE',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'=>'sdk.simulator.types.CHECKOUT_PAGE',
'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE',
'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,
Expand Down Expand Up @@ -258,6 +259,15 @@ public function pagantisActivation()
$wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s'));
}

//Adding new selector < v8.3.3
$tableName = $wpdb->prefix.self::CONFIG_TABLE;
$query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";
$results = $wpdb->get_results($query, ARRAY_A);
if (count($results) == 0) {
$wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s'));
$wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s'));
}

$dbConfigs = $wpdb->get_results("select * from $tableName", ARRAY_A);

// Convert a multimple dimension array for SQL insert statements into a simple key/value
Expand Down Expand Up @@ -326,7 +336,6 @@ public function pagantisAddProductSimulator()
'pagantisQuotesStart' => $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'],
'pagantisSimulatorSkin' => $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'],
'pagantisSimulatorPosition' => $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'],
'separator' => __('ó', 'pagantis'),
'finalDestination' => $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SITUATION'],
'variationSelector' => $this->extraConfig['PAGANTIS_SIMULATOR_SELECTOR_VARIATION']
);
Expand Down
11 changes: 7 additions & 4 deletions controllers/paymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function __construct()
$this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';
$this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
$this->language = strstr(get_locale(), '_', true);
if ($this->language=='') {
$this->language = 'ES';
}
$this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';

//Panel form fields
Expand Down Expand Up @@ -187,15 +190,15 @@ public function pagantisReceiptPage($order_id)
$userAddress
->setZipCode($shippingAddress['postcode'])
->setFullName($shippingAddress['first_name']." ".$shippingAddress['last_name'])
->setCountryCode($shippingAddress['country'] ? $shippingAddress['country'] : $this->language)
->setCountryCode(isset($shippingAddress['country']) ? $shippingAddress['country'] : $this->language)
->setCity($shippingAddress['city'])
->setAddress($shippingAddress['address_1']." ".$shippingAddress['address_2'])
;
$orderShippingAddress = new Address();
$orderShippingAddress
->setZipCode($shippingAddress['postcode'])
->setFullName($shippingAddress['first_name']." ".$shippingAddress['last_name'])
->setCountryCode($shippingAddress['country'] ? $shippingAddress['country'] : $this->language)
->setCountryCode(isset($shippingAddress['country']) ? $shippingAddress['country'] : $this->language)
->setCity($shippingAddress['city'])
->setAddress($shippingAddress['address_1']." ".$shippingAddress['address_2'])
->setFixPhone($shippingAddress['phone'])
Expand All @@ -207,7 +210,7 @@ public function pagantisReceiptPage($order_id)
$orderBillingAddress
->setZipCode($billingAddress['postcode'])
->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
->setCountryCode($billingAddress['country'] ? $billingAddress['country'] : $this->language)
->setCountryCode(isset($billingAddress['country']) ? $billingAddress['country'] : $this->language)
->setCity($billingAddress['city'])
->setAddress($billingAddress['address_1']." ".$billingAddress['address_2'])
->setFixPhone($billingAddress['phone'])
Expand Down Expand Up @@ -513,7 +516,7 @@ public function payment_fields()
'locale' => $locale,
'country' => $locale,
'allowed_country' => $allowedCountry,
'simulator_type' => $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'],
'simulator_type' => $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'],
'promoted_amount' => $promotedAmount,
'thousandSeparator' => $this->extraConfig['PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'],
'decimalSeparator' => $this->extraConfig['PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'],
Expand Down
13 changes: 1 addition & 12 deletions templates/product_simulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function checkSimulatorContent() {
var pgElement = pgDiv[0];
if (pgElement.innerHTML != '') {
simulatorLoaded = true;
prependSeparator();
}
}
return simulatorLoaded;
Expand Down Expand Up @@ -74,16 +73,6 @@ function checkAttempts() {
return (window.attempts > 4)
}

function prependSeparator()
{
var node = document.querySelector(findPositionSelector());
var textnode = document.createTextNode(<?php echo json_encode($separator);?>);
var spannode = document.createElement("span");
spannode.style.cssText = 'margin-right:5px';
spannode.appendChild(textnode);
node.prepend(spannode);
}

function loadSimulatorPagantis()
{
if(typeof pgSDK == 'undefined')
Expand Down Expand Up @@ -185,4 +174,4 @@ function updateSimulator()
echo $promotedMessage;
}
?>
<div class="pagantisSimulator" style="display:flex; margin-top: -30px;margin-bottom: 20px"></div><br/><br/>
<br/><div class="pagantisSimulator"></div><br/><br/>
4 changes: 2 additions & 2 deletions test/selenium/PagantisWoocommerceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ abstract class PagantisWoocommerceTest extends TestCase
protected $configuration = array(
'username' => 'demo@woocommerceshop.com',
'password' => 'woocommerceshop_demo',
'publicKey' => 'tk_fd53cd467ba49022e4f8215e',
'secretKey' => '21e57baa97459f6a',
'publicKey' => 'tk_05f3993ef51d41209c52eac7',
'secretKey' => 'c580df9e0b7b40c3',
'birthdate' => '05/05/2005',
'firstname' => 'Jøhn',
'lastname' => 'Dōè',
Expand Down
4 changes: 4 additions & 0 deletions test/selenium/buy/AbstractBuy.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ public function verifyPagantis()
*/
public function verifyOrderInformation()
{
echo $this->webDriver->getCurrentURL();

echo $this->webDriver->getPageSource();

$messageElementSearch = WebDriverBy::className('entry-title');
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($messageElementSearch);
$this->waitUntil($condition);
Expand Down

0 comments on commit deb8d63

Please sign in to comment.