Skip to content

Commit f8fbaf5

Browse files
committed
Merge pull request #155 in PLUG_OPEN/swagpaymentpaypalunified from ntr/5.2/release to master
* commit '8b775e9e9a3dea97a21bd2437d8095b6bf97ded7': NTR - Prepare plugin for store update
2 parents 66910db + 8b775e9 commit f8fbaf5

File tree

5 files changed

+65
-14
lines changed

5 files changed

+65
-14
lines changed

Components/Services/Installments/InstallmentsRequestService.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getList($productPrice)
4646
$financingRequest = new FinancingRequest();
4747
$financingRequest->setFinancingCountryCode('DE');
4848
$transactionAmount = new FinancingRequest\TransactionAmount();
49-
$transactionAmount->setValue($productPrice);
49+
$transactionAmount->setValue($this->formatPrice($productPrice));
5050
$transactionAmount->setCurrencyCode('EUR');
5151
$financingRequest->setTransactionAmount($transactionAmount);
5252

@@ -64,4 +64,14 @@ public function getList($productPrice)
6464
return null;
6565
}
6666
}
67+
68+
/**
69+
* @param float|string $price
70+
*
71+
* @return float
72+
*/
73+
private function formatPrice($price)
74+
{
75+
return round((float) str_replace(',', '.', $price), 2);
76+
}
6777
}

PayPalBundle/Structs/Installments/FinancingRequest/TransactionAmount.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class TransactionAmount
1212
{
1313
/**
14-
* @var float
14+
* @var string
1515
*/
1616
private $value;
1717

@@ -21,19 +21,19 @@ class TransactionAmount
2121
private $currencyCode;
2222

2323
/**
24-
* @return float
24+
* @return string
2525
*/
2626
public function getValue()
2727
{
2828
return $this->value;
2929
}
3030

3131
/**
32-
* @param float $value
32+
* @param float|string $value
3333
*/
3434
public function setValue($value)
3535
{
36-
$this->value = $value;
36+
$this->value = (string) $value;
3737
}
3838

3939
/**

PayPalBundle/Structs/Payment/Transactions/ItemList/Item.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getPrice()
9797
}
9898

9999
/**
100-
* @param float $price
100+
* @param float|string $price
101101
*/
102102
public function setPrice($price)
103103
{

Setup/Updater.php

+35-7
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,46 @@ private function updateTo103()
7878

7979
private function updateTo110()
8080
{
81-
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
82-
ADD COLUMN `landing_page_type` VARCHAR(255);
83-
UPDATE `swag_payment_paypal_unified_settings_general` SET `landing_page_type` = "Login";';
81+
if (!$this->checkIfColumnExist('swag_payment_paypal_unified_settings_general', 'landing_page_type')) {
82+
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
83+
ADD COLUMN `landing_page_type` VARCHAR(255);
84+
UPDATE `swag_payment_paypal_unified_settings_general`
85+
SET `landing_page_type` = "Login";';
8486

85-
$this->connection->executeQuery($sql);
87+
$this->connection->executeQuery($sql);
88+
}
8689
}
8790

8891
private function updateTo111()
8992
{
90-
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
91-
DROP COLUMN `logo_image`;';
93+
if ($this->checkIfColumnExist('swag_payment_paypal_unified_settings_general', 'logo_image')) {
94+
$sql = 'ALTER TABLE `swag_payment_paypal_unified_settings_general`
95+
DROP COLUMN `logo_image`;';
96+
97+
$this->connection->executeQuery($sql);
98+
}
99+
}
100+
101+
/**
102+
* Helper function to check if a column exists which is needed during update
103+
*
104+
* @param string $tableName
105+
* @param string $columnName
106+
*
107+
* @return bool
108+
*/
109+
private function checkIfColumnExist($tableName, $columnName)
110+
{
111+
$sql = <<<SQL
112+
SELECT column_name
113+
FROM information_schema.columns
114+
WHERE table_name = :tableName
115+
AND column_name = :columnName
116+
AND table_schema = DATABASE();
117+
SQL;
118+
119+
$columnNameInDb = $this->connection->executeQuery($sql, ['tableName' => $tableName, 'columnName' => $columnName])->fetchColumn();
92120

93-
$this->connection->executeQuery($sql);
121+
return $columnNameInDb === $columnName;
94122
}
95123
}

plugin.xml

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,26 @@
55
<label lang="de">PayPal</label>
66
<label lang="en">PayPal</label>
77

8-
<version>1.1.0</version>
8+
<version>1.1.1</version>
99
<copyright>(c) by shopware AG</copyright>
1010
<license>MIT</license>
1111
<link>http://store.shopware.com</link>
1212
<author>shopware AG</author>
1313
<compatibility minVersion="5.2.0"/>
1414

15+
<changelog version="1.1.1">
16+
<changes lang="de">
17+
PT-8708 - Obsoleten Code und Tabellenspalte entfernt;
18+
PT-9564 - Kompatibilität mit Safari auf iOS und MacOS verbessert;
19+
PT-9710 - Übertragung von Preisen zu PayPal verbessert;
20+
</changes>
21+
<changes lang="en">
22+
PT-8708 - Removed obsolete code and table column;
23+
PT-9564 - Improved compatibility with Safari on iOS and MacOS;
24+
PT-9710 - Improved transmission of prices to PayPal;
25+
</changes>
26+
</changelog>
27+
1528
<changelog version="1.1.0">
1629
<changes lang="de">
1730
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;

0 commit comments

Comments
 (0)