Skip to content

Commit

Permalink
Merge pull request #155 in PLUG_OPEN/swagpaymentpaypalunified from nt…
Browse files Browse the repository at this point in the history
…r/5.2/release to master

* commit '8b775e9e9a3dea97a21bd2437d8095b6bf97ded7':
  NTR - Prepare plugin for store update
  • Loading branch information
mitelg committed Oct 22, 2018
2 parents 66910db + 8b775e9 commit f8fbaf5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 deletions.
12 changes: 11 additions & 1 deletion Components/Services/Installments/InstallmentsRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getList($productPrice)
$financingRequest = new FinancingRequest();
$financingRequest->setFinancingCountryCode('DE');
$transactionAmount = new FinancingRequest\TransactionAmount();
$transactionAmount->setValue($productPrice);
$transactionAmount->setValue($this->formatPrice($productPrice));
$transactionAmount->setCurrencyCode('EUR');
$financingRequest->setTransactionAmount($transactionAmount);

Expand All @@ -64,4 +64,14 @@ public function getList($productPrice)
return null;
}
}

/**
* @param float|string $price
*
* @return float
*/
private function formatPrice($price)
{
return round((float) str_replace(',', '.', $price), 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TransactionAmount
{
/**
* @var float
* @var string
*/
private $value;

Expand All @@ -21,19 +21,19 @@ class TransactionAmount
private $currencyCode;

/**
* @return float
* @return string
*/
public function getValue()
{
return $this->value;
}

/**
* @param float $value
* @param float|string $value
*/
public function setValue($value)
{
$this->value = $value;
$this->value = (string) $value;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getPrice()
}

/**
* @param float $price
* @param float|string $price
*/
public function setPrice($price)
{
Expand Down
42 changes: 35 additions & 7 deletions Setup/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,46 @@ private function updateTo103()

private function updateTo110()
{
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
ADD COLUMN `landing_page_type` VARCHAR(255);
UPDATE `swag_payment_paypal_unified_settings_general` SET `landing_page_type` = "Login";';
if (!$this->checkIfColumnExist('swag_payment_paypal_unified_settings_general', 'landing_page_type')) {
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
ADD COLUMN `landing_page_type` VARCHAR(255);
UPDATE `swag_payment_paypal_unified_settings_general`
SET `landing_page_type` = "Login";';

$this->connection->executeQuery($sql);
$this->connection->executeQuery($sql);
}
}

private function updateTo111()
{
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
DROP COLUMN `logo_image`;';
if ($this->checkIfColumnExist('swag_payment_paypal_unified_settings_general', 'logo_image')) {
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
DROP COLUMN `logo_image`;';

$this->connection->executeQuery($sql);
}
}

/**
* Helper function to check if a column exists which is needed during update
*
* @param string $tableName
* @param string $columnName
*
* @return bool
*/
private function checkIfColumnExist($tableName, $columnName)
{
$sql = <<<SQL
SELECT column_name
FROM information_schema.columns
WHERE table_name = :tableName
AND column_name = :columnName
AND table_schema = DATABASE();
SQL;

$columnNameInDb = $this->connection->executeQuery($sql, ['tableName' => $tableName, 'columnName' => $columnName])->fetchColumn();

$this->connection->executeQuery($sql);
return $columnNameInDb === $columnName;
}
}
15 changes: 14 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@
<label lang="de">PayPal</label>
<label lang="en">PayPal</label>

<version>1.1.0</version>
<version>1.1.1</version>
<copyright>(c) by shopware AG</copyright>
<license>MIT</license>
<link>http://store.shopware.com</link>
<author>shopware AG</author>
<compatibility minVersion="5.2.0"/>

<changelog version="1.1.1">
<changes lang="de">
PT-8708 - Obsoleten Code und Tabellenspalte entfernt;
PT-9564 - Kompatibilität mit Safari auf iOS und MacOS verbessert;
PT-9710 - Übertragung von Preisen zu PayPal verbessert;
</changes>
<changes lang="en">
PT-8708 - Removed obsolete code and table column;
PT-9564 - Improved compatibility with Safari on iOS and MacOS;
PT-9710 - Improved transmission of prices to PayPal;
</changes>
</changelog>

<changelog version="1.1.0">
<changes lang="de">
PT-8708, PT-9707 - Die PayPal Experience Profile Logik wurde durch den Application Context ersetzt. Dadurch entfällt die Bildauswahl für das Logo auf der PayPal-Seite. Dies wird nun über das Händlerkonto bezogen;
Expand Down

0 comments on commit f8fbaf5

Please sign in to comment.