diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index e66d2ff..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-@eaDir
\ No newline at end of file
diff --git a/Bootstrap.php b/Bootstrap.php
index 8b04669..0ea314b 100644
--- a/Bootstrap.php
+++ b/Bootstrap.php
@@ -13,8 +13,14 @@
use JTL\Shop;
use JTL\Smarty\JTLSmarty;
use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayFlexiPayDirect;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayGiropay;
use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayHirePurchaseDirectDebit;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayInvoice;
use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayInvoiceFactoring;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayInvoiceGuaranteed;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpaySEPADirectDebitGuaranteed;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpaySofort;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerApplePay;
use Plugin\s360_unzer_shop5\Seeders\Shop4PluginMigrationSeeder;
use Plugin\s360_unzer_shop5\src\ApplePay\CertificationService;
use Plugin\s360_unzer_shop5\src\Controllers\Admin\AdminApplePayController;
@@ -362,7 +368,13 @@ private function getDeprecatedPaymentMethods(): array
return [
HeidelpayInvoiceFactoring::class,
HeidelpayHirePurchaseDirectDebit::class,
- HeidelpayFlexiPayDirect::class
+ HeidelpayFlexiPayDirect::class,
+ UnzerApplePay::class,
+ HeidelpaySofort::class,
+ HeidelpayGiropay::class,
+ HeidelpayInvoice::class,
+ HeidelpayInvoiceGuaranteed::class,
+ HeidelpaySEPADirectDebitGuaranteed::class,
];
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 64d4ffd..051b4f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [2.0.0] (December 2025)
+
+> [!CAUTION]
+> Version 2.0.0 is a breaking change - remember to test and create backup before updating your LIVE environment.
+
+### Added
+- EAA Support, https://docs.unzer.com/online-payments/compliance/eaa/
+- **Klarna** Payment Method
+- **Wero** Payment Method
+
+### Changed
+- Migration from Unzer UI Component V1 to Unzer UI Component V2
+- Deprecated payment methods have been replaced with new ones, removed or renamed. For full list see [README.md](README.md) for an updated list.
+
## [1.8.2] (September 2025)
### Added
- added JTL 5.6 compatability
diff --git a/README.md b/README.md
index 02219a8..a7513dd 100644
--- a/README.md
+++ b/README.md
@@ -2,34 +2,29 @@
Dieses Plugin integriert die folgenden Unzer-Zahlungsarten im JTL Shop:
-- Alipay
-- ApplePay
+- Apple Pay
- Bancontact
-- Direktüberweisung
+- Kreditkarte und Click to Pay
- EPS
-- Giropay
- Google Pay
- iDEAL
-- Kreditkarte
-- Lastschrift
-- SEPA Lastschrift
+- Klarna
- PayPal
- Przelewy24
+- TWINT
+- Direktüberweisung
+- SEPA Lastschrift
+- Lastschrift
- Ratenkauf
- Rechnungskauf
-- SOFORT
-- TWINT
- Vorkasse
- WeChat Pay
-- (Veraltet) Unzer Ratenkauf
-- (Veraltet) Unzer Rechnungskauf
-- (Veraltet) Unzer Rechnungskauf (secured)
-- (Veraltet) Unzer Lastschrift Gesichert
+- Wero
## Installation / Update
### Systemvoraussetzungen
- JTL-Shop 5.0.0+ und dessen Vorraussetzungen
-- PHP Version: 7.4 - 8.3
+- PHP Version: 7.4 - 8.4
- Die folgenden PHP Erweiterungen
- ext-json
- ext-curl
@@ -37,13 +32,6 @@ Dieses Plugin integriert die folgenden Unzer-Zahlungsarten im JTL Shop:
### Weitere Voraussetzungen
Sie müssen bei Unzer registriert sein.
-#### Apple Pay
-Wenn Sie Apple Pay auf Ihrer Seite anbieten möchten, müssen Sie außerdem die folgenden Voraussetzungen erfüllen:
-
-- Apple Developer Account mit Teilnahme am Apple Developer Program, siehe Mitgliedschaft auswählen - Support - Apple Developer
-
-> **Ohne Teilnahme am am Apple Developer Program kann Apple Pay im Plugin nicht genutzt werden! Der einfache und kostenlose Apple Developer Account reicht nicht aus!**
-
### Plugin-Installation
Die Installation des Plugins erfolgt im Standardverfahren für JTL-Shop 5, wie es [hier](https://jtl-devguide.readthedocs.io/projects/jtl-shop/de/latest/shop_plugins/allgemein.html#pluginverwaltung-im-backend-von-jtl-shop) beschrieben ist.
@@ -55,4 +43,59 @@ Gehen Sie dann in die Pluginverwaltung und betätigen Sie den Update-Button.
## Konfiguration
Nach der eigentlichen Plugin-Installation ist es notwendig, die neuen Zahlungsmethoden zu aktivieren und zu den gewünschten Versandarten hinzuzufügen.
-Weitere Informationen und Konfiguration finden Sie in der [Anleitung](https://redirect.solution360.de/?r=docsunzerjtl5)
\ No newline at end of file
+Weitere Informationen und Konfiguration finden Sie in der [Anleitung](https://redirect.solution360.de/?r=docsunzerjtl5)
+
+
+
+
+---
+
+
+
+
+# Unzer payment methods (JTL Shop 5)
+
+This plugin integrates the following Unzer payment methods into the JTL Shop:
+
+- Apple Pay
+- Bancontact
+- Cards and Click to Pay
+- EPS
+- Google Pay
+- iDEAL
+- Klarna
+- PayPal
+- Przelewy24
+- TWINT
+- Direct Bank Transfer
+- SEPA Direct Debit
+- Direct Debit
+- Installment
+- Invoice
+- Prepayment
+- WeChat Pay
+- Wero
+
+## Installation/update
+### System requirements
+- JTL-Shop 5.0.0+ and its requirements
+- PHP version: 7.4 - 8.4
+- The following PHP extensions
+ - ext-json
+ - ext-curl
+
+### Additional requirements
+You must be registered with Unzer.
+
+### Plugin installation
+The plugin is installed using the standard procedure for JTL-Shop 5, as described [here](https://jtl-devguide.readthedocs.io/projects/jtl-shop/de/latest/shop_plugins/allgemein.html#pluginverwaltung-im-backend-von-jtl-shop).
+
+### Plugin update
+To update, upload the latest version of the plugin as you would for an installation (overwriting any existing plugin files if necessary) or follow the instructions in the Extension Store.
+
+Then go to the plugin management section and click the update button.
+
+## Configuration
+After installing the plugin, you need to activate the new payment methods and add them to the desired shipping methods.
+
+For more information and configuration details, see the [instructions](https://redirect.solution360.de/?r=docsunzerjtl5).
\ No newline at end of file
diff --git a/adminmenu/template/partials/_order_detail.tpl b/adminmenu/template/partials/_order_detail.tpl
index a5cd74e..cc366ae 100644
--- a/adminmenu/template/partials/_order_detail.tpl
+++ b/adminmenu/template/partials/_order_detail.tpl
@@ -215,9 +215,26 @@
{else}
{__($hpPayment->getPaymentType()->getResourceName())}
{/if}
-
- ({$hpPayment->getPaymentType()->getId()})
+
+ {if $hpOrder->Zahlungsinfo && !empty($hpOrder->Zahlungsinfo->cIBAN)}
+ {if !empty($hpOrder->Zahlungsinfo->cIBAN)}
+
\ No newline at end of file
diff --git a/frontend/template/instalment_info.tpl b/frontend/template/instalment_info.tpl
index 1b144ad..1e5ef21 100644
--- a/frontend/template/instalment_info.tpl
+++ b/frontend/template/instalment_info.tpl
@@ -1 +1,10 @@
-{$info}
\ No newline at end of file
+
+
+
{$info}
\ No newline at end of file
diff --git a/frontend/template/partials/payment_info.tpl b/frontend/template/partials/payment_info.tpl
index 6771608..1cdd834 100644
--- a/frontend/template/partials/payment_info.tpl
+++ b/frontend/template/partials/payment_info.tpl
@@ -2,10 +2,18 @@
{if $Bestellung->Zahlungsinfo}
{/if}
{/block}
\ No newline at end of file
diff --git a/info.xml b/info.xml
index 74801a5..fc95203 100644
--- a/info.xml
+++ b/info.xml
@@ -6,7 +6,7 @@
http://www.solution360.de1005.0.0
- 1.8.2
+ 2.0.0s360_unzer_shop52020-10-27
@@ -15,9 +15,9 @@
-
+
@@ -303,12 +303,108 @@
Note: The total amount shown differs from the amount to be paid. Please refer to your instalment plan for the amount to be paid.]]>
+
+
+ s360_hp_company_type_label
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_placeholder
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_authority
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_association
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_sole
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_company
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_other
+
+
+
+
+
+
+
+
+
+
+
+ s360_hp_company_type_missing
+
+
+
+
+
+
+
+
+
+
- images/Card.svg01
@@ -331,10 +427,17 @@
+
+
+
+
+
+
+ enable_ctp
+
- images/SEPA.svg01
@@ -360,7 +463,6 @@
- images/SEPA.svg01
@@ -386,7 +488,6 @@
- images/InvoiceWL.svg01
@@ -412,7 +513,6 @@
- images/InvoiceWL.svg01
@@ -438,7 +538,6 @@
- images/InvoiceWL.svg01
@@ -489,7 +588,6 @@
- images/Paypal.svg01
@@ -515,7 +613,6 @@
- images/Sofort.svg01
@@ -541,7 +638,6 @@
- images/Giropay.svg01
@@ -567,7 +663,6 @@
- images/Przelewy24.svg01
@@ -593,7 +688,6 @@
- images/Ideal.svg01
@@ -619,7 +713,6 @@
- images/PrepaymentWL.svg01
@@ -645,7 +738,6 @@
- images/EPS.svg01
@@ -696,7 +788,6 @@
- images/Alipay.svg01
@@ -722,7 +813,6 @@
- images/WeChatPay.svg01
@@ -780,7 +870,6 @@
- images/ApplePay.svg101
@@ -806,7 +895,6 @@
- images/Bancontact.svg201
@@ -832,7 +920,6 @@
- images/InstalmentWL.svg301
@@ -858,7 +945,6 @@
- images/Default.svg401
@@ -884,7 +970,6 @@
- images/GooglePay.svg501
@@ -1030,7 +1115,6 @@
- images/Twint.svg601
@@ -1057,7 +1141,6 @@
- images/ApplePay.svg151
@@ -1091,10 +1174,8 @@
-
- images/DirectBankTransferWL.svg701
@@ -1118,6 +1199,67 @@
+
+
+
+ 80
+ 1
+
+ OTHER
+ 1
+ 0
+ 1
+ 0
+ UnzerKlarna.php
+ UnzerKlarna
+ template/dummy.tpl
+ template/klarna.tpl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 90
+ 1
+
+ OTHER
+ 1
+ 0
+ 1
+ 0
+ UnzerWero.php
+ UnzerWero
+ template/dummy.tpl
+ template/wero.tpl
+
+
+
+
+
+
+
+
+
+
+
+
+
+ booking_mode
+
+
+
+
+
+
\ No newline at end of file
diff --git a/locale/de-DE/base.mo b/locale/de-DE/base.mo
index 8ebd0b8..7e2dd17 100644
Binary files a/locale/de-DE/base.mo and b/locale/de-DE/base.mo differ
diff --git a/locale/de-DE/base.po b/locale/de-DE/base.po
index fcfdb44..93b4858 100644
--- a/locale/de-DE/base.po
+++ b/locale/de-DE/base.po
@@ -5,85 +5,97 @@ msgid "Einstellungen"
msgstr "Einstellungen"
msgid "Unzer Kreditkarte"
-msgstr "Unzer Kreditkarte"
+msgstr "Kreditkarte"
msgid "Unzer SEPA-Lastschrift"
-msgstr "Unzer SEPA Lastschrift"
+msgstr "SEPA Lastschrift"
msgid "Unzer Lastschrift"
-msgstr "Unzer SEPA Lastschrift"
+msgstr "SEPA Lastschrift"
msgid "Unzer SEPA-Lastschrift (guaranteed)"
-msgstr "(Veraltet) Unzer Direct Debit (Gesichert)"
+msgstr "(Veraltet) Direct Debit (Gesichert)"
msgid "Unzer Lastschrift (secured)"
-msgstr "(Veraltet) Unzer Direct Debit (Gesichert)"
+msgstr "(Veraltet) Direct Debit (Gesichert)"
msgid "Unzer Lastschrift (Paylater)"
-msgstr "Unzer Lastschrift"
+msgstr "Lastschrift"
msgid "Unzer Rechnung"
-msgstr "(Veraltet) Unzer Rechnungskauf"
+msgstr "(Veraltet) Rechnungskauf"
msgid "Unzer Rechnung (guaranteed)"
-msgstr "(Veraltet) Unzer Rechnungskauf Gesichert"
+msgstr "(Veraltet) Rechnungskauf Gesichert"
msgid "Unzer Rechnung (secured)"
-msgstr "(Veraltet) Unzer Rechnungskauf Gesichert"
+msgstr "(Veraltet) Rechnungskauf Gesichert"
msgid "Unzer Fakturierung von Rechnungen"
-msgstr "Unzer Fakturierung von Rechnungen"
+msgstr "Fakturierung von Rechnungen"
msgid "Unzer Rechnungskauf"
-msgstr "Unzer Rechnungskauf"
+msgstr "Rechnungskauf"
msgid "Unzer PayPal"
-msgstr "Unzer PayPal"
+msgstr "PayPal"
msgid "Unzer SOFORT"
-msgstr "(Veraltet) Unzer SOFORT"
+msgstr "(Veraltet) SOFORT"
msgid "Unzer Giropay"
-msgstr "(Veraltet) Unzer Giropay"
+msgstr "(Veraltet) Giropay"
msgid "Unzer Przelewy24"
-msgstr "Unzer Przelewy24"
+msgstr "Przelewy24"
msgid "Unzer iDEAL"
-msgstr "Unzer iDEAL"
+msgstr " iDEAL"
msgid "Unzer Prepayment"
-msgstr "Unzer Vorkasse"
+msgstr "Vorkasse"
msgid "Unzer EPS"
-msgstr "Unzer EPS"
+msgstr "EPS"
msgid "Unzer FlexiPay Direct"
-msgstr "Unzer FlexiPay Direct"
+msgstr "FlexiPay Direct"
msgid "Unzer Direktüberweisung"
-msgstr "(Veraltet) Unzer Direktüberweisung"
+msgstr "(Veraltet) Direktüberweisung"
msgid "Unzer Alipay"
-msgstr "Unzer Alipay"
+msgstr "Alipay"
msgid "Unzer WeChat Pay"
-msgstr "Unzer WeChat Pay"
+msgstr "WeChat Pay"
msgid "Unzer FlexiPay Installment (Hire Purchase)"
-msgstr "Unzer FlexiPay Instalment (Hire Purchase)"
+msgstr "FlexiPay Instalment (Hire Purchase)"
msgid "Unzer Instalment"
-msgstr "(Veraltet) Unzer Ratenkauf"
+msgstr "(Veraltet) Ratenkauf"
msgid "Unzer Ratenkauf"
-msgstr "(Veraltet) Unzer Ratenkauf"
+msgstr "(Veraltet) Ratenkauf"
msgid "Unzer Rechnung (Jetzt kaufen, Später bezahlen)"
-msgstr "Unzer Rechnungskauf"
+msgstr "Rechnungskauf"
msgid "Unzer Ratenzahlung (Paylater)"
-msgstr "Unzer Ratenkauf"
+msgstr "Ratenkauf"
+
+msgid "Unzer Bancontact"
+msgstr "Bancontact"
+
+msgid "Unzer Google Pay"
+msgstr "Google Pay"
+
+msgid "Unzer TWINT"
+msgstr "TWINT"
+
+msgid "Unzer Vorkasse"
+msgstr "Vorkasse"
msgid "hpError"
msgstr "Fehler"
@@ -305,7 +317,7 @@ msgid "hpSettingsMerchantIdHelp"
msgstr "Die Händler ID (Merchant ID) des Insight Portal wird benötigt, um in den Bestelldetails einen Link zur jeweiligen Transaktion im Insight Portal bereitzustellen."
msgid "hpSettingsStyles"
-msgstr "Styles"
+msgstr "(Veraltet) Styles"
msgid "hpSettingsFontSize"
msgstr "Schriftgröße"
@@ -518,7 +530,7 @@ msgstr ""
"Sie verwenden die Zahlungsmethode `GiroPay`, beachten Sie, dass GiroPay den Service eingestellt hat. Das bedeutet, dass Kunden den Dienst nicht mehr nutzen können!"
msgid "Key Pairs"
-msgstr "Schlüsselpaare"
+msgstr "Zusätzliche Schlüsselpaare"
msgid "hpKeyPairEdit"
msgstr "Schlüsselpaar bearbeiten"
@@ -571,14 +583,14 @@ msgstr "Die Webhooks wurden erfolgreich registriert."
msgid "twint"
msgstr "TWINT"
-msgid "Apple Pay"
-msgstr "(Veraltet) Apple Pay"
+# msgid "Apple Pay"
+# msgstr "(Veraltet) Apple Pay"
msgid "Unzer Apple Pay"
-msgstr "(Veraltet) Unzer Apple Pay"
+msgstr "(Veraltet) Apple Pay"
msgid "Unzer Apple Pay v2"
-msgstr "Unzer Apple Pay"
+msgstr "Apple Pay"
msgid "hpApplePayMigrationNotification"
msgstr ""
@@ -599,8 +611,77 @@ msgstr ""
msgid "hpApplePayMissingMerchantIdDomainAssociation"
msgstr "Die Apple Pay-Verifizierungsdatei konnte nicht gefunden werden. Laden Sie die Verifizierungsdatei von Apple wie folgt auf Ihren Server hoch: %1$s/.well-known/apple-developer-merchantid-domain-association"
+msgid "hpSettingsUIComponents"
+msgstr "UI Components"
+
+msgid "hpSettingsUIVersion"
+msgstr "Version"
+
+msgid "hpSettingsFontFamilyHelp"
+msgstr "z.B. Arial, Helvetica, sans-serif"
+
+msgid "hpSettingsTextColor"
+msgstr "Schriftfarbe"
+
+msgid "hpSettingsTextColorPlaceholder"
+msgstr "z.B. red oder #ff0000"
+
+msgid "hpSettingsTextColorHelp"
+msgstr "Die für die Typografie verwendete Schriftfarbe."
+
+msgid "hpSettingsBrandColor"
+msgstr "Marken/Primär-Farbe"
+
+msgid "hpSettingsBrandColorPlaceholder"
+msgstr "z.B. red oder #ff0000"
+
+msgid "hpSettingsBrandColorHelp"
+msgstr "Die Hauptfarbe der Anwendung."
+
+msgid "hpSettingsBackgroundColor"
+msgstr "Hintergrund-Farbe"
+
+msgid "hpSettingsBackgroundColorPlaceholder"
+msgstr "z.B. red oder #ff0000"
+
+msgid "hpSettingsBackgroundColorHelp"
+msgstr "Die Hintergrundfarbe der Seite."
+
+msgid "hpSettingsLinkColor"
+msgstr "Link-Farbe"
+
+msgid "hpSettingsLinkColorPlaceholder"
+msgstr "z.B. red oder #ff0000"
+
+msgid "hpSettingsLinkColorHelp"
+msgstr "Die Farbe der Links."
+
+msgid "hpSettingsCornerRadius"
+msgstr "Abgerundete Kanten"
+
+msgid "hpSettingsCornerRadiusHelp"
+msgstr "Ob die Steuerelemente abgerundete Ecken haben sollen oder nicht."
+
+msgid "hpSettingsShadows"
+msgstr "Schatten"
+
+msgid "hpSettingsShadowsHelp"
+msgstr "Ob Schatten aktiviert sind oder nicht."
+
msgid "Unzer Direct Bank Transfer"
-msgstr "Unzer Direktüberweisung"
+msgstr "Direktüberweisung"
msgid "openbanking-pis"
-msgstr "Unzer Direktüberweisung"
\ No newline at end of file
+msgstr "Direktüberweisung"
+
+msgid "Unzer Klarna"
+msgstr "Klarna"
+
+msgid "Unzer Wero"
+msgstr "Wero"
+
+msgid "clicktopay"
+msgstr "Click to Pay"
+
+msgid "klarna"
+msgstr "Klarna"
diff --git a/locale/en-GB/base.mo b/locale/en-GB/base.mo
index 92e29f6..b58b4ff 100644
Binary files a/locale/en-GB/base.mo and b/locale/en-GB/base.mo differ
diff --git a/locale/en-GB/base.po b/locale/en-GB/base.po
index 49bfd1a..51b136a 100644
--- a/locale/en-GB/base.po
+++ b/locale/en-GB/base.po
@@ -5,88 +5,97 @@ msgid "Einstellungen"
msgstr "Settings"
msgid "Unzer Kreditkarte"
-msgstr "Unzer Credit Card"
+msgstr "Credit Card"
msgid "Unzer SEPA-Lastschrift"
-msgstr "Unzer SEPA Direct Debit"
+msgstr "SEPA Direct Debit"
msgid "Unzer Lastschrift"
-msgstr "Unzer SEPA Direct Debit"
+msgstr "SEPA Direct Debit"
msgid "Unzer SEPA-Lastschrift (guaranteed)"
-msgstr "(Deprecated) Unzer SEPA Direct Debit (secured)"
+msgstr "(Deprecated) SEPA Direct Debit (secured)"
msgid "Unzer Lastschrift (secured)"
-msgstr "(Deprecated) Unzer Direct Debit (secured)"
+msgstr "(Deprecated) Direct Debit (secured)"
msgid "Unzer Lastschrift (Paylater)"
-msgstr "Unzer Direct Debit"
+msgstr "Direct Debit"
msgid "Unzer Rechnung"
-msgstr "(Deprecated) Unzer Invoice"
+msgstr "(Deprecated) Invoice"
msgid "Unzer Rechnung (guaranteed)"
-msgstr "(Deprecated) Unzer Invoice Secured"
+msgstr "(Deprecated) Invoice Secured"
msgid "Unzer Rechnung (secured)"
-msgstr "(Deprecated) Unzer Invoice Secured"
+msgstr "(Deprecated) Invoice Secured"
msgid "Unzer Fakturierung von Rechnungen"
-msgstr "Unzer Invoice Factoring"
+msgstr "Invoice Factoring"
msgid "Unzer Rechnungskauf"
-msgstr "Unzer Invoice"
+msgstr "Invoice"
msgid "Unzer PayPal"
-msgstr "Unzer PayPal"
+msgstr "PayPal"
msgid "Unzer SOFORT"
-msgstr "(Deprecated) Unzer SOFORT"
+msgstr "(Deprecated) SOFORT"
msgid "Unzer Giropay"
-msgstr "(Deprecated) Unzer Giropay"
+msgstr "(Deprecated) Giropay"
msgid "Unzer Przelewy24"
-msgstr "Unzer Przelewy24"
+msgstr "Przelewy24"
msgid "Unzer iDEAL"
-msgstr "Unzer iDEAL"
+msgstr "iDEAL"
msgid "Unzer Prepayment"
-msgstr "Unzer Prepayment"
+msgstr "Prepayment"
msgid "Unzer Vorkasse"
-msgstr "Unzer Prepayment"
+msgstr "Prepayment"
msgid "Unzer EPS"
-msgstr "Unzer EPS"
+msgstr "EPS"
msgid "Unzer FlexiPay Direct"
-msgstr "Unzer FlexiPay Direct"
+msgstr "FlexiPay Direct"
msgid "Unzer Direktüberweisung"
-msgstr "(Deprecated) Unzer Bank Transfer"
+msgstr "(Deprecated) Bank Transfer"
msgid "Unzer Alipay"
-msgstr "Unzer Alipay"
+msgstr "Alipay"
msgid "Unzer WeChat Pay"
-msgstr "Unzer WeChat Pay"
+msgstr "WeChat Pay"
msgid "Unzer FlexiPay Installment (Hire Purchase)"
-msgstr "Unzer FlexiPay Instalment (Hire Purchase)"
+msgstr "FlexiPay Instalment (Hire Purchase)"
msgid "Unzer Instalment"
-msgstr "(Deprecated) Unzer Installment"
+msgstr "(Deprecated) Installment"
msgid "Unzer Ratenkauf"
-msgstr "(Deprecated) Unzer Instalment"
+msgstr "(Deprecated) Instalment"
msgid "Unzer Rechnung (Jetzt kaufen, Später bezahlen)"
-msgstr "Unzer Invoice"
+msgstr "Invoice"
msgid "Unzer Ratenzahlung (Paylater)"
-msgstr "Unzer Installment"
+msgstr "Installment"
+
+msgid "Unzer Bancontact"
+msgstr "Bancontact"
+
+msgid "Unzer Google Pay"
+msgstr "Google Pay"
+
+msgid "Unzer TWINT"
+msgstr "TWINT"
msgid "hpError"
msgstr "Error"
@@ -542,10 +551,10 @@ msgid "Die Webhooks wurden erfolgreich gespeichert."
msgstr "Webhooks have been registered successfully."
msgid "Key Pairs"
-msgstr "Key Pairs"
+msgstr "Additional Keypairs"
msgid "hpKeyPairEdit"
-msgstr "Edit Key Pair"
+msgstr "Edit Keypair"
msgid "hpKeypairIsB2B"
msgstr "B2B"
@@ -676,14 +685,14 @@ msgstr "The country code of the acquirer (default DK)."
msgid "twint"
msgstr "TWINT"
-msgid "Apple Pay"
-msgstr "(Deprecated) Apple Pay"
+# msgid "Apple Pay"
+# msgstr "(Deprecated) Apple Pay"
msgid "Unzer Apple Pay"
-msgstr "(Deprecated) Unzer Apple Pay"
+msgstr "(Deprecated) Apple Pay"
msgid "Unzer Apple Pay v2"
-msgstr "Unzer Apple Pay"
+msgstr "Apple Pay"
msgid "hpApplePayMigrationNotification"
msgstr ""
@@ -703,8 +712,83 @@ msgstr ""
msgid "hpApplePayMissingMerchantIdDomainAssociation"
msgstr "Could not find Apple Pay Verification File. Upload the verification file from Apple to your server as follows: %1$s/.well-known/apple-developer-merchantid-domain-association"
+msgid "hpSettingsUIComponents"
+msgstr "UI Components"
+
+msgid "hpSettingsUIVersion"
+msgstr "Version"
+
+msgid "hpSettingsFontFamilyHelp"
+msgstr "e.g. Arial, Helvetica, sans-serif"
+
+msgid "hpSettingsTextColor"
+msgstr "Text Color"
+
+msgid "hpSettingsTextColorPlaceholder"
+msgstr "e.g. red or #ff0000"
+
+msgid "hpSettingsTextColorHelp"
+msgstr "The font color use for typography."
+
+msgid "hpSettingsBrandColor"
+msgstr "Primary Color"
+
+msgid "hpSettingsBrandColorPlaceholder"
+msgstr "e.g. red or #ff0000"
+
+msgid "hpSettingsBrandColorHelp"
+msgstr "The main color of the application."
+
+msgid "hpSettingsBackgroundColor"
+msgstr "Background Color"
+
+msgid "hpSettingsBackgroundColorPlaceholder"
+msgstr "e.g. red or #ff0000"
+
+msgid "hpSettingsBackgroundColorHelp"
+msgstr "The page background."
+
+msgid "hpSettingsLinkColor"
+msgstr "Link Color"
+
+msgid "hpSettingsLinkColorPlaceholder"
+msgstr "e.g. red or #ff0000"
+
+msgid "hpSettingsLinkColorHelp"
+msgstr "The color of links."
+
+msgid "hpSettingsCornerRadius"
+msgstr "Rounded Corners"
+
+msgid "hpSettingsCornerRadiusHelp"
+msgstr "Whether controls will have rounded corners or not."
+
+msgid "hpSettingsShadows"
+msgstr "Shadows"
+
+msgid "hpSettingsShadowsHelp"
+msgstr "Whether shadows are enabled or not."
+
msgid "Unzer Direct Bank Transfer"
-msgstr "Unzer Direct Bank Transfer"
+msgstr "Direct Bank Transfer"
msgid "openbanking-pis"
-msgstr "Unzer Direct Bank Transfer"
\ No newline at end of file
+msgstr "Direct Bank Transfer"
+
+msgid "\"Click to Pay\" aktivieren"
+msgstr "Enable \"Click to Pay\""
+
+msgid "Unzer Klarna"
+msgstr "Klarna"
+
+msgid "Unzer Wero"
+msgstr "Wero"
+
+msgid "Wollen Sie den Eintrag wirklich löschen?"
+msgstr "Are you sure you want to delete this entry?"
+
+msgid "clicktopay"
+msgstr "Click to Pay"
+
+msgid "klarna"
+msgstr "Klarna"
diff --git a/paymentmethod/HeidelpayCreditCard.php b/paymentmethod/HeidelpayCreditCard.php
index 1e5bc57..4db293d 100644
--- a/paymentmethod/HeidelpayCreditCard.php
+++ b/paymentmethod/HeidelpayCreditCard.php
@@ -20,6 +20,7 @@
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
use Plugin\s360_unzer_shop5\src\Utils\Config;
+use UnzerSDK\Resources\PaymentTypes\Clicktopay;
/**
* HeidelpayCreditCard Payment Method.
@@ -61,33 +62,35 @@ class HeidelpayCreditCard extends HeidelpayPaymentMethod implements
public function getOrderAttributes(Bestellung $order, AbstractTransactionType $transaction): array
{
try {
- /** @var Card $type */
+ /** @var Card|Clicktopay $type */
$type = $transaction->getPayment()->getPaymentType();
- // Save Payment Info
- $oPaymentInfo = new ZahlungsInfo(0, $order->kBestellung);
- $oPaymentInfo->kKunde = $order->kKunde;
- $oPaymentInfo->kBestellung = $order->kBestellung;
- $oPaymentInfo->cInhaber = Text::convertUTF8($type->getCardHolder() ?? '');
- $oPaymentInfo->cKartenNr = Text::convertUTF8($type->getNumber() ?? '');
- $oPaymentInfo->cGueltigkeit = Text::convertUTF8($type->getExpiryDate() ?? '');
- $oPaymentInfo->cCVV = Text::convertUTF8($type->getCvc() ?? '');
- $oPaymentInfo->cKartenTyp = Text::convertUTF8($type->getBrand() ?? '');
- $oPaymentInfo->cBankName = '';
- $oPaymentInfo->cKartenNr = '';
- $oPaymentInfo->cCVV = '';
-
-
- isset($oPaymentInfo->kZahlungsInfo) ? $oPaymentInfo->updateInDB() : $oPaymentInfo->insertInDB();
-
- // Order Attributes
- return [
- self::ATTR_CARD_HOLDER => $oPaymentInfo->cInhaber,
- self::ATTR_CARD_NUMBER => $oPaymentInfo->cKartenNr,
- self::ATTR_CARD_EXPIRY_DATE => $oPaymentInfo->cGueltigkeit,
- self::ATTR_CARD_CVC => $oPaymentInfo->cCVV,
- self::ATTR_CARD_TYPE => $oPaymentInfo->cKartenTyp
- ];
+ if ($type instanceof Card) {
+ // Save Payment Info
+ $oPaymentInfo = new ZahlungsInfo(0, $order->kBestellung);
+ $oPaymentInfo->kKunde = $order->kKunde;
+ $oPaymentInfo->kBestellung = $order->kBestellung;
+ $oPaymentInfo->cInhaber = Text::convertUTF8($type->getCardHolder() ?? '');
+ $oPaymentInfo->cKartenNr = Text::convertUTF8($type->getNumber() ?? '');
+ $oPaymentInfo->cGueltigkeit = Text::convertUTF8($type->getExpiryDate() ?? '');
+ $oPaymentInfo->cCVV = Text::convertUTF8($type->getCvc() ?? '');
+ $oPaymentInfo->cKartenTyp = Text::convertUTF8($type->getBrand() ?? '');
+ $oPaymentInfo->cBankName = '';
+ $oPaymentInfo->cKartenNr = '';
+ $oPaymentInfo->cCVV = '';
+
+
+ isset($oPaymentInfo->kZahlungsInfo) ? $oPaymentInfo->updateInDB() : $oPaymentInfo->insertInDB();
+
+ // Order Attributes
+ return [
+ self::ATTR_CARD_HOLDER => $oPaymentInfo->cInhaber,
+ self::ATTR_CARD_NUMBER => $oPaymentInfo->cKartenNr,
+ self::ATTR_CARD_EXPIRY_DATE => $oPaymentInfo->cGueltigkeit,
+ self::ATTR_CARD_CVC => $oPaymentInfo->cCVV,
+ self::ATTR_CARD_TYPE => $oPaymentInfo->cKartenTyp
+ ];
+ }
} catch (Exception $exc) {
$this->errorLog(
'An exception was thrown while trying to get the order attributes '
@@ -115,6 +118,7 @@ public function handleStepAdditional(JTLSmarty $view): void
Config::FONT_FAMILY => $config->get(Config::FONT_FAMILY),
Config::FONT_SIZE => $config->get(Config::FONT_SIZE),
];
+ $data['enableCTP'] = $config->getPaymentSetting(Config::ENABLE_CTP, $this->moduleID) === 'Y';
$view->assign('hpPayment', $data);
}
diff --git a/paymentmethod/HeidelpayFlexiPayDirect.php b/paymentmethod/HeidelpayFlexiPayDirect.php
index 35937c0..11b0a04 100644
--- a/paymentmethod/HeidelpayFlexiPayDirect.php
+++ b/paymentmethod/HeidelpayFlexiPayDirect.php
@@ -77,4 +77,14 @@ public function isSelectable(): bool
//! Note: Payment Method is deprecated -> should not be used anymore
return false;
}
+
+ /**
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
+ */
+ public function isValidIntern($args = []): bool
+ {
+ return false;
+ }
}
diff --git a/paymentmethod/HeidelpayHirePurchaseDirectDebit.php b/paymentmethod/HeidelpayHirePurchaseDirectDebit.php
index 3f60408..cf0ad92 100644
--- a/paymentmethod/HeidelpayHirePurchaseDirectDebit.php
+++ b/paymentmethod/HeidelpayHirePurchaseDirectDebit.php
@@ -187,6 +187,9 @@ public function isSelectable(): bool
*/
public function isValidIntern($args = []): bool
{
+ //! Note: Payment Method is deprecated -> should not be used anymore
+ return false;
+
/** @var Config $config */
$config = Shop::Container()->get(Config::class);
$effectiveInterest = $config->getPaymentSetting('effectiveInterest', $this->moduleID);
diff --git a/paymentmethod/HeidelpayInvoice.php b/paymentmethod/HeidelpayInvoice.php
index 3bb2549..7234bde 100644
--- a/paymentmethod/HeidelpayInvoice.php
+++ b/paymentmethod/HeidelpayInvoice.php
@@ -34,28 +34,13 @@ class HeidelpayInvoice extends HeidelpayPaymentMethod
use HasCustomer;
/**
- * @inheritDoc
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
*/
- public function initBackendNotification(): void
+ public function isValidIntern($args = []): bool
{
- // Add deprecation notice IF paymethod is used (ie assigned to a shipping method)
- $payMethod = $this->plugin->getPaymentMethods()->getMethodByID($this->moduleID);
-
- if ($payMethod !== null && $payMethod->getActive()) {
- $this->kZahlungsart = $payMethod->getMethodID();
- $result = Shop::Container()->getDB()->select('tversandartzahlungsart', 'kZahlungsart', $this->kZahlungsart);
-
- if ($result) {
- $notification = new NotificationEntry(
- NotificationEntry::TYPE_INFO,
- sprintf(__('hpDeprecationPaymentMethodTitle'), $payMethod->getName()),
- sprintf(nl2br(__('hpDeprecationInvoiceNotice')), $payMethod->getName())
- );
-
- $notification->setPluginId((string) $this->plugin->getID());
- Notification::getInstance()->addNotify($notification);
- }
- }
+ return false;
}
/**
diff --git a/paymentmethod/HeidelpayInvoiceFactoring.php b/paymentmethod/HeidelpayInvoiceFactoring.php
index 37d6376..e0aa464 100644
--- a/paymentmethod/HeidelpayInvoiceFactoring.php
+++ b/paymentmethod/HeidelpayInvoiceFactoring.php
@@ -38,6 +38,16 @@ class HeidelpayInvoiceFactoring extends HeidelpayInvoice implements CancelableIn
use HasMetadata;
use SupportsB2B;
+ /**
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
+ */
+ public function isValidIntern($args = []): bool
+ {
+ return false;
+ }
+
/**
* Cancel the Charge.
*
diff --git a/paymentmethod/HeidelpayInvoiceGuaranteed.php b/paymentmethod/HeidelpayInvoiceGuaranteed.php
index 14a205c..2f6d38b 100644
--- a/paymentmethod/HeidelpayInvoiceGuaranteed.php
+++ b/paymentmethod/HeidelpayInvoiceGuaranteed.php
@@ -41,6 +41,16 @@ class HeidelpayInvoiceGuaranteed extends HeidelpayInvoice implements HandleStepA
use HasMetadata;
use SupportsB2B;
+ /**
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
+ */
+ public function isValidIntern($args = []): bool
+ {
+ return false;
+ }
+
/**
* Cancel the Charge.
*
diff --git a/paymentmethod/HeidelpaySEPADirectDebitGuaranteed.php b/paymentmethod/HeidelpaySEPADirectDebitGuaranteed.php
index 9798c8d..37423f8 100644
--- a/paymentmethod/HeidelpaySEPADirectDebitGuaranteed.php
+++ b/paymentmethod/HeidelpaySEPADirectDebitGuaranteed.php
@@ -51,6 +51,16 @@ class HeidelpaySEPADirectDebitGuaranteed extends HeidelpayPaymentMethod implemen
use SupportsB2B;
use TranslatorTrait;
+ /**
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
+ */
+ public function isValidIntern($args = []): bool
+ {
+ return false;
+ }
+
/**
* Cancel the Charge.
*
diff --git a/paymentmethod/HeidelpaySofort.php b/paymentmethod/HeidelpaySofort.php
index fead65c..1394b0d 100644
--- a/paymentmethod/HeidelpaySofort.php
+++ b/paymentmethod/HeidelpaySofort.php
@@ -27,6 +27,7 @@
* and those who prefer online payment methods over invoices.
*
* @see https://docs.heidelpay.com/docs/sofort-payment
+ * @deprecated
*/
class HeidelpaySofort extends HeidelpayPaymentMethod implements RedirectPaymentInterface
{
@@ -43,6 +44,16 @@ protected function getAllowedCurrencies(): array
return ['EUR', 'CHF'];
}
+ /**
+ * Deactivate as the payment method is deprecated
+ * @param array $args
+ * @return bool
+ */
+ public function isValidIntern($args = []): bool
+ {
+ return false;
+ }
+
/**
* @inheritDoc
* @return AbstractTransactionType|Charge
diff --git a/paymentmethod/UnzerApplePay.php b/paymentmethod/UnzerApplePay.php
index 80e4e64..c42e823 100644
--- a/paymentmethod/UnzerApplePay.php
+++ b/paymentmethod/UnzerApplePay.php
@@ -27,6 +27,7 @@
* Apple Pay is a mobile wallet solution available to all users of Apple devices.
*
* @see https://docs.unzer.com/payment-methods/applepay/
+ * @deprecated Replaced by UnzerApplePayV2
*/
class UnzerApplePay extends HeidelpayPaymentMethod implements HandleStepAdditionalInterface, NotificationInterface
{
@@ -34,31 +35,6 @@ class UnzerApplePay extends HeidelpayPaymentMethod implements HandleStepAddition
use HasMetadata;
use HasBasket;
- /**
- * @inheritDoc
- */
- public function initBackendNotification(): void
- {
- // Add deprecation notice IF paymethod is used (ie assigned to a shipping method)
- $payMethod = $this->plugin->getPaymentMethods()->getMethodByID($this->moduleID);
-
- if ($payMethod !== null && $payMethod->getActive()) {
- $this->kZahlungsart = $payMethod->getMethodID();
- $result = Shop::Container()->getDB()->select('tversandartzahlungsart', 'kZahlungsart', $this->kZahlungsart);
-
- if ($result) {
- $notification = new NotificationEntry(
- NotificationEntry::TYPE_INFO,
- sprintf(__('hpDeprecationPaymentMethodTitle'), __($payMethod->getName())),
- nl2br(__('hpApplePayMigrationNotification'))
- );
-
- $notification->setPluginId((string) $this->plugin->getID());
- Notification::getInstance()->addNotify($notification);
- }
- }
- }
-
/**
* @param JTLSmarty $view
* @return void
@@ -103,6 +79,8 @@ public function handleStepAdditional(JTLSmarty $view): void
*/
public function isValidIntern($args = []): bool
{
+ return false; // !NOTE: Discontinued
+
try {
/** @var CertificationService $certService */
$certService = Shop::Container()->get(CertificationService::class);
diff --git a/paymentmethod/UnzerApplePayV2.php b/paymentmethod/UnzerApplePayV2.php
index c18774c..cec60bd 100644
--- a/paymentmethod/UnzerApplePayV2.php
+++ b/paymentmethod/UnzerApplePayV2.php
@@ -12,17 +12,18 @@
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HasPayButton;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\NotificationInterface;
use Plugin\s360_unzer_shop5\src\Payments\Traits\CancelPaymentTransaction;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\HasAuthorization;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasBasket;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
use Plugin\s360_unzer_shop5\src\Utils\Config;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
-use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Charge;
class UnzerApplePayV2 extends HeidelpayPaymentMethod implements HasPayButton, NotificationInterface, CancelableInterface
{
+ use HasAuthorization;
use HasCustomer;
use HasMetadata;
use HasBasket;
@@ -113,15 +114,8 @@ protected function performTransaction(BasePaymentType $payment, Bestellung $orde
// Authorize payment
if ($config->getPaymentSetting(Config::APPLEPAY_BOOKING_MODE, $this->moduleID) === 'authorize') {
- $authorization = new Authorization(
- $this->getTotalPriceCustomerCurrency($order),
- $order->Waehrung->getCode(),
- $this->getReturnURL($order)
- );
- $authorization->setOrderId($order->cBestellNr ?? null);
-
return $this->adapter->getCurrentConnection()->performAuthorization(
- $authorization,
+ $this->createAuthorization($session->getCustomer(), $order),
$payment->getId(),
$customer,
$this->createMetadata(),
diff --git a/paymentmethod/UnzerGooglePay.php b/paymentmethod/UnzerGooglePay.php
index 73410f9..71af85e 100644
--- a/paymentmethod/UnzerGooglePay.php
+++ b/paymentmethod/UnzerGooglePay.php
@@ -12,6 +12,7 @@
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\CancelableInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HasPayButton;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\RedirectPaymentInterface;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\HasAuthorization;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasBasket;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
@@ -28,6 +29,7 @@
class UnzerGooglePay extends HeidelpayPaymentMethod implements HasPayButton, RedirectPaymentInterface, CancelableInterface
{
+ use HasAuthorization;
use HasMetadata;
use HasCustomer;
use HasBasket;
@@ -95,11 +97,12 @@ public function handleAdditional($post): bool
$config = Shop::Container()->get(Config::class);
// $channelId = $config->getPaymentSetting(Config::GPAY_GATEWAY_MERCHANT_ID, $this->moduleID);
- // if (empty($channelId)) {
- $this->adapter->getConnectionForSession();
- $channelId = $this->adapter->getChannelIdForPaymentType(Googlepay::getResourceName());
+ $this->adapter->getConnectionForSession();
+ $channelId = $this->adapter->getChannelIdForPaymentType(Googlepay::getResourceName());
+
+ if (!empty($channelId)) {
$config->savePaymentSetting(Config::GPAY_GATEWAY_MERCHANT_ID, $this->moduleID, $channelId);
- // }
+ }
$this->sessionHelper->setCheckoutSession(null, $channelId);
@@ -212,15 +215,8 @@ protected function performTransaction(BasePaymentType $payment, Bestellung $orde
// Authorize payment
if ($config->getPaymentSetting(Config::GPAY_BOOKING_MODE, $this->moduleID) === 'authorize') {
- $authorization = new Authorization(
- $this->getTotalPriceCustomerCurrency($order),
- $order->Waehrung->getCode(),
- $this->getReturnURL($order)
- );
- $authorization->setOrderId($order->cBestellNr ?? null);
-
return $this->adapter->getCurrentConnection()->performAuthorization(
- $authorization,
+ $this->createAuthorization($shopCustomer, $order),
$payment->getId(),
$customer,
$this->createMetadata(),
diff --git a/paymentmethod/UnzerKlarna.php b/paymentmethod/UnzerKlarna.php
new file mode 100644
index 0000000..7f0723d
--- /dev/null
+++ b/paymentmethod/UnzerKlarna.php
@@ -0,0 +1,167 @@
+ 'AUD',
+ 'AT' => 'EUR',
+ 'BE' => 'EUR',
+ 'CA' => 'CAD',
+ 'CZ' => 'CZK',
+ 'DK' => 'DKK',
+ 'FI' => 'EUR',
+ 'FR' => 'EUR',
+ 'DE' => 'EUR',
+ 'GR' => 'EUR',
+ 'HU' => 'HUF',
+ 'IE' => 'EUR',
+ 'IT' => 'EUR',
+ 'MX' => 'MXN',
+ 'NL' => 'EUR',
+ 'NZ' => 'NZD',
+ 'NO' => 'NOK',
+ 'PL' => 'PLN',
+ 'PT' => 'EUR',
+ 'RO' => 'RON',
+ 'SK' => 'EUR',
+ 'ES' => 'EUR',
+ 'SE' => 'SEK',
+ 'CH' => 'CHF',
+ 'GB' => 'GBP',
+ 'US' => 'USD',
+ ];
+ }
+
+ protected function getAllowedCountries(): array
+ {
+ return array_keys($this->getAllowedCountryCurrencyCombination());
+ }
+
+ protected function getAllowedCurrencies(): array
+ {
+ return array_values($this->getAllowedCountryCurrencyCombination());
+ }
+
+ /**
+ * Add Customer Resource to view.
+ *
+ * @param JTLSmarty $view
+ * @return void
+ */
+ public function handleStepAdditional(JTLSmarty $view): void
+ {
+ $this->adapter->getConnectionForSession();
+ $shopCustomer = $this->sessionHelper->getFrontendSession()->getCustomer();
+ $customer = $this->createOrFetchHeidelpayCustomer(
+ $this->adapter,
+ $this->sessionHelper,
+ $this->isB2BCustomer($shopCustomer)
+ );
+ $customer->setShippingAddress(
+ $this->createHeidelpayAddress(
+ $this->sessionHelper->getFrontendSession()->get('Lieferadresse')
+ )
+ );
+
+ $data = $view->getTemplateVars('hpPayment') ?: [];
+ $data['customer'] = $customer;
+
+ $view->assign('hpPayment', $data);
+ }
+
+ /**
+ * Check country+currency combination
+ *
+ * @return bool
+ */
+ public function isSelectable(): bool
+ {
+ if (!parent::isSelectable()) {
+ return false;
+ }
+
+ // Check Country + Currency combination
+ $country = $this->sessionHelper->getFrontendSession()->getCustomer()->cLand;
+ $currency = $this->sessionHelper->getFrontendSession()->getCurrency()->getCode();
+
+ if ($this->getAllowedCountryCurrencyCombination()[$country] !== $currency) {
+ return false;
+ }
+
+ return true;
+ }
+
+ protected function performTransaction(BasePaymentType $payment, Bestellung $order): AbstractTransactionType
+ {
+ // Create or fetch customer resource
+ $shopCustomer = $this->sessionHelper->getFrontendSession()->getCustomer();
+ $customer = $this->createOrFetchHeidelpayCustomer(
+ $this->adapter,
+ $this->sessionHelper,
+ $this->isB2BCustomer($shopCustomer)
+ );
+ $customer->setShippingAddress($this->createHeidelpayAddress($order->Lieferadresse));
+ $customer->setBillingAddress($this->createHeidelpayAddress($order->oRechnungsadresse));
+
+ if (empty($customer->getLanguage())) {
+ $customer->setLanguage(strtolower($this->sessionHelper->getFrontendSession()->getCustomer()->cLand ?? 'de'));
+ }
+
+ $this->debugLog('Customer Resource: ' . $customer->jsonSerialize(), static::class);
+
+ // Update existing customer resource if needed
+ if ($customer->getId()) {
+ $customer = $this->adapter->getCurrentConnection()->updateCustomer($customer);
+ $this->debugLog('Updated Customer Resource: ' . $customer->jsonSerialize(), static::class);
+ }
+
+ // Create Basket
+ $session = $this->sessionHelper->getFrontendSession();
+ $basket = $this->createHeidelpayBasket(
+ $session->getCart(),
+ $order->Waehrung,
+ $session->getLanguage(),
+ $order->cBestellNr ?? $payment->getId()
+ );
+ $this->debugLog('Basket Resource: ' . $basket->jsonSerialize(), static::class);
+
+ return $this->adapter->getCurrentConnection()->performAuthorization(
+ $this->createAuthorization($shopCustomer, $order, false),
+ $payment->getId(),
+ $customer,
+ $this->createMetadata(),
+ $basket
+ );
+ }
+}
diff --git a/paymentmethod/UnzerPaylaterDirectDebit.php b/paymentmethod/UnzerPaylaterDirectDebit.php
index 8eabbab..cbb5d1b 100644
--- a/paymentmethod/UnzerPaylaterDirectDebit.php
+++ b/paymentmethod/UnzerPaylaterDirectDebit.php
@@ -4,38 +4,34 @@
namespace Plugin\s360_unzer_shop5\paymentmethod;
-use DateTime;
use JTL\Checkout\Bestellung;
-use JTL\Checkout\Lieferadresse;
-use JTL\Shop;
use JTL\Smarty\JTLSmarty;
use Plugin\s360_unzer_shop5\src\Payments\HeidelpayPaymentMethod;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\CancelableInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepAdditionalInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepReviewOrderInterface;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\CancelPaymentTransaction;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\HasAuthorization;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasBasket;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
use Plugin\s360_unzer_shop5\src\Payments\Traits\SupportsB2B;
-use Plugin\s360_unzer_shop5\src\Utils\Config;
use Plugin\s360_unzer_shop5\src\Utils\SessionHelper;
-use UnzerSDK\Resources\EmbeddedResources\RiskData;
-use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Authorization;
-use UnzerSDK\Resources\TransactionTypes\Cancellation;
-use UnzerSDK\Resources\TransactionTypes\Charge;
class UnzerPaylaterDirectDebit extends HeidelpayPaymentMethod implements
HandleStepAdditionalInterface,
HandleStepReviewOrderInterface,
CancelableInterface
{
+ use HasAuthorization;
use HasMetadata;
use HasCustomer;
use HasBasket;
use SupportsB2B;
+ use CancelPaymentTransaction;
protected function getAllowedCountries(): array
{
@@ -47,38 +43,6 @@ protected function getAllowedCurrencies(): array
return ['EUR'];
}
- /**
- * Cancel the Charge or authorization
- *
- * @param Payment $payment
- * @param Charge|Authorization $transaction
- * @param Bestellung $order
- * @return Cancellation
- */
- public function cancelPaymentTransaction(
- Payment $payment,
- AbstractTransactionType $transaction,
- Bestellung $order
- ): Cancellation {
- $api = $this->adapter->getConnectionForOrder($order);
-
- $reference = str_replace(
- ['%ORDER_ID%', '%SHOPNAME%'],
- [$order->cBestellNr, Shop::getSettingValue(CONF_GLOBAL, 'global_shopname')],
- $this->trans(Config::LANG_CANCEL_PAYMENT_REFERENCE)
- );
-
- $cancel = (new Cancellation($transaction->getAmount()))->setPaymentReference($reference);
-
- // Cancel before charge (reversal)
- if ($transaction instanceof Authorization) {
- return $api->cancelAuthorizedPayment($payment, $cancel);
- }
-
- // Cancel after charge (refund)
- return $api->cancelChargedPayment($payment, $cancel);
- }
-
/**
* Save the payment reference and some other bank data.
*
@@ -155,6 +119,7 @@ public function handleStepAdditional(JTLSmarty $view): void
/**
* Generate and add threat metrix id (fraud prevention).
*
+ * @deprecated Only used for backwards compatibility (UI Components v1)
* @param JTLSmarty $view
* @return null|string
*/
@@ -167,6 +132,23 @@ public function handleStepReviewOrder(JTLSmarty $view): ?string
return 'template/partials/_threatMetrix';
}
+
+ /**
+ * @SuppressWarnings(PHPMD.Superglobals)
+ * @return bool
+ */
+ public function validateAdditional(): bool
+ {
+ $postPaymentData = $_POST['paymentData'] ?? [];
+
+ // Save Threat Metrix ID
+ if (isset($postPaymentData['threatMetrixId'])) {
+ $this->sessionHelper->set(SessionHelper::KEY_THREAT_METRIX_ID, $postPaymentData['threatMetrixId']);
+ }
+
+ return parent::validateAdditional();
+ }
+
protected function performTransaction(BasePaymentType $payment, Bestellung $order): AbstractTransactionType
{
// Create or fetch customer resource
@@ -196,24 +178,8 @@ protected function performTransaction(BasePaymentType $payment, Bestellung $orde
);
$this->debugLog('Basket Resource: ' . $basket->jsonSerialize(), static::class);
- // Authorize Transaction
- $riskData = (new RiskData())
- ->setThreatMetrixId($this->sessionHelper->get(SessionHelper::KEY_THREAT_METRIX_ID))
- ->setRegistrationLevel($shopCustomer->nRegistriert == '1' ? '1' : '0')
- ->setRegistrationDate(
- DateTime::createFromFormat('Y-m-d', $shopCustomer->dErstellt ?? date('Y-m-d'))->format('Ymd')
- );
-
- $authorization = new Authorization(
- $this->getTotalPriceCustomerCurrency($order),
- $order->Waehrung->getCode(),
- $this->getReturnURL($order)
- );
- $authorization->setOrderId($order->cBestellNr ?? null);
- $authorization->setRiskData($riskData);
-
return $this->adapter->getCurrentConnection()->performAuthorization(
- $authorization,
+ $this->createAuthorization($shopCustomer, $order),
$payment->getId(),
$customer,
$this->createMetadata(),
diff --git a/paymentmethod/UnzerPaylaterInstallment.php b/paymentmethod/UnzerPaylaterInstallment.php
index 5035dd1..cef2a89 100644
--- a/paymentmethod/UnzerPaylaterInstallment.php
+++ b/paymentmethod/UnzerPaylaterInstallment.php
@@ -4,7 +4,6 @@
namespace Plugin\s360_unzer_shop5\paymentmethod;
-use DateTime;
use JTL\Cart\Cart;
use JTL\Checkout\Bestellung;
use JTL\Checkout\ZahlungsInfo;
@@ -17,13 +16,13 @@
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepAdditionalInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepReviewOrderInterface;
use Plugin\s360_unzer_shop5\src\Payments\PaymentHandler;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\HasAuthorization;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasBasket;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
use Plugin\s360_unzer_shop5\src\Payments\Traits\SupportsB2B;
use Plugin\s360_unzer_shop5\src\Utils\Config;
use Plugin\s360_unzer_shop5\src\Utils\SessionHelper;
-use UnzerSDK\Resources\EmbeddedResources\RiskData;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\Payment;
@@ -35,6 +34,7 @@ class UnzerPaylaterInstallment extends HeidelpayPaymentMethod implements
HandleStepReviewOrderInterface,
CancelableInterface
{
+ use HasAuthorization;
use HasMetadata;
use HasCustomer;
use HasBasket;
@@ -178,6 +178,11 @@ public function validateAdditional(): bool
{
$postPaymentData = $_POST['paymentData'] ?? [];
+ // Save Threat Metrix ID
+ if (isset($postPaymentData['threatMetrixId'])) {
+ $this->sessionHelper->set(SessionHelper::KEY_THREAT_METRIX_ID, $postPaymentData['threatMetrixId']);
+ }
+
// Save Customer ID if it exists
if (isset($postPaymentData['customerId'])) {
$this->sessionHelper->set(SessionHelper::KEY_CUSTOMER_ID, $postPaymentData['customerId']);
@@ -201,6 +206,7 @@ public function validateAdditional(): bool
/**
* Generate and add threat metrix id (fraud prevention).
*
+ * @deprecated ThreatMetrix Only used for backwards compatibility (UI Components v1)
* @param JTLSmarty $view
* @return null|string
*/
@@ -277,23 +283,8 @@ protected function performTransaction(BasePaymentType $payment, Bestellung $orde
$this->debugLog('Basket Resource: ' . $basket->jsonSerialize(), static::class);
// Authorize Transaction
- $riskData = (new RiskData())
- ->setThreatMetrixId($this->sessionHelper->get(SessionHelper::KEY_THREAT_METRIX_ID))
- ->setRegistrationLevel($shopCustomer->nRegistriert == '1' ? '1' : '0')
- ->setRegistrationDate(
- DateTime::createFromFormat('Y-m-d', $shopCustomer->dErstellt ?? date('Y-m-d'))->format('Ymd')
- );
-
- $authorization = new Authorization(
- $this->getTotalPriceCustomerCurrency($order),
- $order->Waehrung->getCode(),
- $this->getReturnURL($order)
- );
- $authorization->setOrderId($order->cBestellNr ?? null);
- $authorization->setRiskData($riskData);
-
return $this->adapter->getCurrentConnection()->performAuthorization(
- $authorization,
+ $this->createAuthorization($shopCustomer, $order),
$payment->getId(),
$customer,
$this->createMetadata(),
diff --git a/paymentmethod/UnzerPaylaterInvoice.php b/paymentmethod/UnzerPaylaterInvoice.php
index 9d5d364..48551bc 100644
--- a/paymentmethod/UnzerPaylaterInvoice.php
+++ b/paymentmethod/UnzerPaylaterInvoice.php
@@ -4,42 +4,43 @@
namespace Plugin\s360_unzer_shop5\paymentmethod;
-use DateTime;
use JTL\Checkout\Bestellung;
use JTL\Checkout\Lieferadresse;
use JTL\Checkout\ZahlungsInfo;
use JTL\Helpers\Text;
-use JTL\Shop;
use JTL\Smarty\JTLSmarty;
use Plugin\s360_unzer_shop5\src\Payments\HeidelpayPaymentMethod;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\CancelableInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepAdditionalInterface;
use Plugin\s360_unzer_shop5\src\Payments\Interfaces\HandleStepReviewOrderInterface;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\CancelPaymentTransaction;
+use Plugin\s360_unzer_shop5\src\Payments\Traits\HasAuthorization;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasBasket;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasCustomer;
use Plugin\s360_unzer_shop5\src\Payments\Traits\HasMetadata;
use Plugin\s360_unzer_shop5\src\Payments\Traits\SupportsB2B;
-use Plugin\s360_unzer_shop5\src\Utils\Config;
use Plugin\s360_unzer_shop5\src\Utils\SessionHelper;
use stdClass;
+use UnzerSDK\Constants\CompanyCommercialSectorItems;
+use UnzerSDK\Constants\CompanyRegistrationTypes;
+use UnzerSDK\Constants\CompanyTypes;
use UnzerSDK\Constants\ShippingTypes;
-use UnzerSDK\Resources\EmbeddedResources\RiskData;
+use UnzerSDK\Resources\EmbeddedResources\CompanyInfo;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Authorization;
-use UnzerSDK\Resources\Payment;
-use UnzerSDK\Resources\TransactionTypes\Cancellation;
-use UnzerSDK\Resources\TransactionTypes\Charge;
class UnzerPaylaterInvoice extends HeidelpayPaymentMethod implements
HandleStepAdditionalInterface,
HandleStepReviewOrderInterface,
CancelableInterface
{
+ use HasAuthorization;
use HasMetadata;
use HasCustomer;
use HasBasket;
use SupportsB2B;
+ use CancelPaymentTransaction;
protected function getAllowedCountries(): array
{
@@ -51,39 +52,6 @@ protected function getAllowedCurrencies(): array
return ['EUR', 'CHF'];
}
- /**
- * Cancel the Charge or authorization
- *
- * @param Payment $payment
- * @param Charge|Authorization $transaction
- * @param Bestellung $order
- * @return Cancellation
- */
- public function cancelPaymentTransaction(
- Payment $payment,
- AbstractTransactionType $transaction,
- Bestellung $order
- ): Cancellation {
- $api = $this->adapter->getConnectionForOrder($order);
-
- $reference = str_replace(
- ['%ORDER_ID%', '%SHOPNAME%'],
- [$order->cBestellNr, Shop::getSettingValue(CONF_GLOBAL, 'global_shopname')],
- $this->trans(Config::LANG_CANCEL_PAYMENT_REFERENCE)
- );
-
- $cancel = (new Cancellation($transaction->getAmount()))->setPaymentReference($reference);
-
- // Cancel before charge (reversal)
- if ($transaction instanceof Authorization) {
- return $api->cancelAuthorizedPayment($payment, $cancel);
- }
-
- // Cancel after charge (refund)
- return $api->cancelChargedPayment($payment, $cancel);
- }
-
-
/**
* Data the merchant needs to put on the Invoice.
*
@@ -145,10 +113,12 @@ public function handleStepAdditional(JTLSmarty $view): void
$this->sessionHelper->getFrontendSession()->get('Lieferadresse')
)
);
+ $this->sessionHelper->set(SessionHelper::KEY_CUSTOMER_ID, $customer->getId());
$data = $view->getTemplateVars('hpPayment') ?: [];
$data['customer'] = $customer;
$data['isB2B'] = $this->isB2BCustomer($shopCustomer);
+ $data['companyTypes'] = [CompanyTypes::AUTHORITY, CompanyTypes::ASSOCIATION, CompanyTypes::COMPANY, CompanyTypes::SOLE, CompanyTypes::OTHER];
$view->assign('hpPayment', $data);
}
@@ -156,6 +126,7 @@ public function handleStepAdditional(JTLSmarty $view): void
/**
* Generate and add threat metrix id (fraud prevention).
*
+ * @deprecated Only used for backwards compatibility (UI Components v1)
* @param JTLSmarty $view
* @return null|string
*/
@@ -180,6 +151,30 @@ public function validateAdditional(): bool
{
$postPaymentData = $_POST['paymentData'] ?? [];
+ // Save Threat Metrix ID
+ if (isset($postPaymentData['threatMetrixId'])) {
+ $this->sessionHelper->set(SessionHelper::KEY_THREAT_METRIX_ID, $postPaymentData['threatMetrixId']);
+ }
+
+ // Save company info type
+ if ($this->isB2BCustomer($this->sessionHelper->getFrontendSession()->getCustomer())) {
+ $shopCustomer = $this->sessionHelper->getFrontendSession()->getCustomer();
+ $customer = $this->createOrFetchHeidelpayCustomer(
+ $this->adapter,
+ $this->sessionHelper,
+ $this->isB2BCustomer($shopCustomer)
+ );
+
+ // Set company info for b2b customers
+ if ($customer->getCompanyInfo() === null) {
+ $customer->setCompanyInfo(new CompanyInfo());
+ $customer->getCompanyInfo()
+ ->setRegistrationType(CompanyRegistrationTypes::REGISTRATION_TYPE_NOT_REGISTERED)
+ ->setFunction('OWNER')
+ ->setCommercialSector(CompanyCommercialSectorItems::OTHER);
+ }
+ }
+
// Save Customer ID if it exists
if (isset($postPaymentData['customerId'])) {
$this->sessionHelper->set(SessionHelper::KEY_CUSTOMER_ID, $postPaymentData['customerId']);
@@ -198,7 +193,7 @@ public function validateAdditional(): bool
$names = $this->getNamesFromAddress($customer->getShippingAddress());
$shipping->cVorname = $names['firstname'] ?: $shipping->cVorname;
$shipping->cNachname = $names['lastname'] ?: $shipping->cNachname;
- $shipping->cBundesland = $customer->getShippingAddress()->getState();
+ $shipping->cBundesland = $customer->getShippingAddress()->getState() ?? $shopCustomer->cBundesland;
$shipping->cPLZ = $customer->getShippingAddress()->getZip();
$shipping->cOrt = $customer->getShippingAddress()->getCity();
$shipping->cLand = $customer->getShippingAddress()->getCountry();
@@ -216,7 +211,7 @@ public function validateAdditional(): bool
$shopCustomer->cNachname = $names['lastname'] ?: $shopCustomer->cNachname;
if ($this->isB2BCustomer($shopCustomer)) {
- $shopCustomer->cBundesland = $customer->getBillingAddress()->getState() ?? '';
+ $shopCustomer->cBundesland = $customer->getBillingAddress()->getState() ?? $shopCustomer->cBundesland;
$shopCustomer->cPLZ = $customer->getBillingAddress()->getZip();
$shopCustomer->cOrt = $customer->getBillingAddress()->getCity();
$shopCustomer->cLand = $customer->getBillingAddress()->getCountry();
@@ -292,24 +287,8 @@ protected function performTransaction(BasePaymentType $payment, $order): Abstrac
);
$this->debugLog('Basket Resource: ' . $basket->jsonSerialize(), static::class);
- // Authorize Transaction
- $riskData = (new RiskData())
- ->setThreatMetrixId($this->sessionHelper->get(SessionHelper::KEY_THREAT_METRIX_ID))
- ->setRegistrationLevel($shopCustomer->nRegistriert == '1' ? '1' : '0')
- ->setRegistrationDate(
- DateTime::createFromFormat('Y-m-d', $shopCustomer->dErstellt ?? date('Y-m-d'))->format('Ymd')
- );
-
- $authorization = new Authorization(
- $this->getTotalPriceCustomerCurrency($order),
- $order->Waehrung->getCode(),
- $this->getReturnURL($order)
- );
- $authorization->setOrderId($order->cBestellNr ?? null);
- $authorization->setRiskData($riskData);
-
return $this->adapter->getCurrentConnection()->performAuthorization(
- $authorization,
+ $this->createAuthorization($shopCustomer, $order),
$payment->getId(),
$customer,
$this->createMetadata(),
diff --git a/paymentmethod/UnzerWero.php b/paymentmethod/UnzerWero.php
new file mode 100644
index 0000000..3fadd33
--- /dev/null
+++ b/paymentmethod/UnzerWero.php
@@ -0,0 +1,93 @@
+get(Config::class);
+
+ // Create or fetch customer resource
+ $shopCustomer = $this->sessionHelper->getFrontendSession()->getCustomer();
+ $customer = $this->createOrFetchHeidelpayCustomer(
+ $this->adapter,
+ $this->sessionHelper,
+ $this->isB2BCustomer($shopCustomer)
+ );
+ $customer->setShippingAddress($this->createHeidelpayAddress($order->Lieferadresse));
+ $customer->setBillingAddress($this->createHeidelpayAddress($order->oRechnungsadresse));
+ $customer->setLanguage(strtolower($this->sessionHelper->getFrontendSession()->getCustomer()->cLand ?? 'de'));
+
+ $this->debugLog('Customer Resource: ' . $customer->jsonSerialize(), static::class);
+
+ // Update existing customer resource if needed
+ if ($customer->getId()) {
+ $customer = $this->adapter->getCurrentConnection()->updateCustomer($customer);
+ $this->debugLog('Updated Customer Resource: ' . $customer->jsonSerialize(), static::class);
+ }
+
+ // Create Basket
+ $session = $this->sessionHelper->getFrontendSession();
+ $basket = $this->createHeidelpayBasket(
+ $session->getCart(),
+ $order->Waehrung,
+ $session->getLanguage(),
+ $order->cBestellNr ?? $payment->getId()
+ );
+ $this->debugLog('Basket Resource: ' . $basket->jsonSerialize(), static::class);
+
+ // Authorize payment
+ if ($config->getPaymentSetting(Config::PAYMENT_BOOKING_MODE, $this->moduleID) === 'authorize') {
+ return $this->adapter->getCurrentConnection()->performAuthorization(
+ $this->createAuthorization($shopCustomer, $order, false),
+ $payment->getId(),
+ $customer,
+ $this->createMetadata(),
+ $basket
+ );
+ }
+
+ // Charge Payment
+ return $this->adapter->getCurrentConnection()->performCharge(
+ $this->createCharge($order),
+ $payment->getId(),
+ $customer,
+ $this->createMetadata(),
+ $basket
+ );
+ }
+}
\ No newline at end of file
diff --git a/paymentmethod/template/_components_v2.tpl b/paymentmethod/template/_components_v2.tpl
new file mode 100644
index 0000000..f1f054d
--- /dev/null
+++ b/paymentmethod/template/_components_v2.tpl
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+{if $hpPayment.isSandbox && $hpPayment.isDev}
+
+{else}
+
+{/if}
+ {* TODO *}
\ No newline at end of file
diff --git a/paymentmethod/template/alipay_form.tpl b/paymentmethod/template/alipay_form.tpl
index 9ba5868..1d470ca 100644
--- a/paymentmethod/template/alipay_form.tpl
+++ b/paymentmethod/template/alipay_form.tpl
@@ -1,15 +1,13 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
{$hpPayment.redirectingNote}
+
+
{$hpPayment.redirectingNote}
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/applepay.tpl b/paymentmethod/template/applepay.tpl
index 90103d5..96a76e2 100644
--- a/paymentmethod/template/applepay.tpl
+++ b/paymentmethod/template/applepay.tpl
@@ -1,35 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
-
-
-
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/bancontact_form.tpl b/paymentmethod/template/bancontact_form.tpl
index 8d9d05d..c57a843 100644
--- a/paymentmethod/template/bancontact_form.tpl
+++ b/paymentmethod/template/bancontact_form.tpl
@@ -1,19 +1,10 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
+
+
+
+
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
diff --git a/paymentmethod/template/credit_card_form.tpl b/paymentmethod/template/credit_card_form.tpl
index 65915f1..7d66bf6 100644
--- a/paymentmethod/template/credit_card_form.tpl
+++ b/paymentmethod/template/credit_card_form.tpl
@@ -1,36 +1,10 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/direct_bank_transfer.tpl b/paymentmethod/template/direct_bank_transfer.tpl
index 207511b..5f7d29d 100644
--- a/paymentmethod/template/direct_bank_transfer.tpl
+++ b/paymentmethod/template/direct_bank_transfer.tpl
@@ -1,15 +1,13 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
{$hpPayment.redirectingNote}
+
+
{$hpPayment.redirectingNote}
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/giropay_form.tpl b/paymentmethod/template/giropay_form.tpl
index ea759e5..96a76e2 100644
--- a/paymentmethod/template/giropay_form.tpl
+++ b/paymentmethod/template/giropay_form.tpl
@@ -1,15 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
{$hpPayment.redirectingNote}
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/hire_purchase_direct_debit_form.tpl b/paymentmethod/template/hire_purchase_direct_debit_form.tpl
index 4fcb58c..96a76e2 100644
--- a/paymentmethod/template/hire_purchase_direct_debit_form.tpl
+++ b/paymentmethod/template/hire_purchase_direct_debit_form.tpl
@@ -1,27 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/ideal_form.tpl b/paymentmethod/template/ideal_form.tpl
index a608861..452fd0d 100644
--- a/paymentmethod/template/ideal_form.tpl
+++ b/paymentmethod/template/ideal_form.tpl
@@ -1,16 +1,11 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/invoice_factoring_form.tpl b/paymentmethod/template/invoice_factoring_form.tpl
index df415ce..96a76e2 100644
--- a/paymentmethod/template/invoice_factoring_form.tpl
+++ b/paymentmethod/template/invoice_factoring_form.tpl
@@ -1,23 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/invoice_form.tpl b/paymentmethod/template/invoice_form.tpl
index 2889e47..96a76e2 100644
--- a/paymentmethod/template/invoice_form.tpl
+++ b/paymentmethod/template/invoice_form.tpl
@@ -1,15 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
{$hpPayment.redirectingNote}
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/invoice_guaranteed_form.tpl b/paymentmethod/template/invoice_guaranteed_form.tpl
index ca6918c..96a76e2 100644
--- a/paymentmethod/template/invoice_guaranteed_form.tpl
+++ b/paymentmethod/template/invoice_guaranteed_form.tpl
@@ -1,23 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/klarna.tpl b/paymentmethod/template/klarna.tpl
new file mode 100644
index 0000000..11d44a3
--- /dev/null
+++ b/paymentmethod/template/klarna.tpl
@@ -0,0 +1,14 @@
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
+
+
+
{$hpPayment.redirectingNote}
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/paylater_direct_debit_form.tpl b/paymentmethod/template/paylater_direct_debit_form.tpl
index 6b691bf..62f7d1e 100644
--- a/paymentmethod/template/paylater_direct_debit_form.tpl
+++ b/paymentmethod/template/paylater_direct_debit_form.tpl
@@ -1,24 +1,12 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/paylater_installment_form.tpl b/paymentmethod/template/paylater_installment_form.tpl
index 3cdd4bd..d0c31b4 100644
--- a/paymentmethod/template/paylater_installment_form.tpl
+++ b/paymentmethod/template/paylater_installment_form.tpl
@@ -1,26 +1,16 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
+
+
+
+
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
diff --git a/paymentmethod/template/paylater_invoice_form.tpl b/paymentmethod/template/paylater_invoice_form.tpl
index e6d70a9..cf1b8e9 100644
--- a/paymentmethod/template/paylater_invoice_form.tpl
+++ b/paymentmethod/template/paylater_invoice_form.tpl
@@ -1,24 +1,12 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/paypal_form.tpl b/paymentmethod/template/paypal_form.tpl
index 7703c73..699cd44 100644
--- a/paymentmethod/template/paypal_form.tpl
+++ b/paymentmethod/template/paypal_form.tpl
@@ -1,16 +1,10 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/prepayment_form.tpl b/paymentmethod/template/prepayment_form.tpl
index cf62ad5..c6403e0 100644
--- a/paymentmethod/template/prepayment_form.tpl
+++ b/paymentmethod/template/prepayment_form.tpl
@@ -1,15 +1,13 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
{$hpPayment.redirectingNote}
+
+
{$hpPayment.redirectingNote}
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
diff --git a/paymentmethod/template/sepa_guaranteed_form.tpl b/paymentmethod/template/sepa_guaranteed_form.tpl
index f3e1c1d..96a76e2 100644
--- a/paymentmethod/template/sepa_guaranteed_form.tpl
+++ b/paymentmethod/template/sepa_guaranteed_form.tpl
@@ -1,29 +1 @@
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
-
-
-
-
- {$hpPayment.mandate}
-
-
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/sofort_form.tpl b/paymentmethod/template/sofort_form.tpl
index 3c8b9ba..96a76e2 100644
--- a/paymentmethod/template/sofort_form.tpl
+++ b/paymentmethod/template/sofort_form.tpl
@@ -1,15 +1 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
-
-
{$hpPayment.redirectingNote}
-
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+{* !! DEPRECATED !! *}
\ No newline at end of file
diff --git a/paymentmethod/template/twint.tpl b/paymentmethod/template/twint.tpl
index b7097d9..40c993d 100644
--- a/paymentmethod/template/twint.tpl
+++ b/paymentmethod/template/twint.tpl
@@ -1,15 +1,13 @@
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_includes.tpl"}
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
-
{$hpPayment.redirectingNote}
+
+
{$hpPayment.redirectingNote}
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
-
-
-{include file="{$hpPayment.pluginPath}paymentmethod/template/_footer.tpl"}
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/paymentmethod/template/wero.tpl b/paymentmethod/template/wero.tpl
new file mode 100644
index 0000000..89f2030
--- /dev/null
+++ b/paymentmethod/template/wero.tpl
@@ -0,0 +1,13 @@
+{include file="{$hpPayment.pluginPath}paymentmethod/template/_components_v2.tpl"}
+
+
+
{$hpPayment.redirectingNote}
+
+
+
+
+
\ No newline at end of file
diff --git a/phpmd-ruleset.xml b/phpmd-ruleset.xml
deleted file mode 100644
index 1ee4545..0000000
--- a/phpmd-ruleset.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
- Inspired by https://github.com/phpmd/phpmd/issues/137
- using http://phpmd.org/documentation/creating-a-ruleset.html
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Controllers/Admin/AdminController.php b/src/Controllers/Admin/AdminController.php
index 50177f5..c3ff370 100644
--- a/src/Controllers/Admin/AdminController.php
+++ b/src/Controllers/Admin/AdminController.php
@@ -18,6 +18,7 @@
* Abstract Admin Controller
*
* @package Plugin\s360_unzer_shop5\src\Controllers\Admin
+ * @deprecated
*/
abstract class AdminController extends Controller
{
diff --git a/src/Controllers/Admin/AdminKeyPairsController.php b/src/Controllers/Admin/AdminKeyPairsController.php
index 7cb9ea2..58fdd9f 100644
--- a/src/Controllers/Admin/AdminKeyPairsController.php
+++ b/src/Controllers/Admin/AdminKeyPairsController.php
@@ -8,6 +8,11 @@
use UnzerSDK\Validators\PrivateKeyValidator;
use UnzerSDK\Validators\PublicKeyValidator;
use JTL\Helpers\Request;
+use Plugin\s360_unzer_shop5\paymentmethod\HeidelpaySEPADirectDebit;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerDirectBankTransfer;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterDirectDebit;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterInstallment;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterInvoice;
use Plugin\s360_unzer_shop5\src\Controllers\AjaxResponse;
use Plugin\s360_unzer_shop5\src\Controllers\HasAjaxResponse;
use Plugin\s360_unzer_shop5\src\KeyPairs\KeyPairEntity;
@@ -81,12 +86,28 @@ public function handleAjax(): void
$item = $this->saveKeypair($item);
}
+ // Filter payment methods
+ $availablePaymentMethods = [];
+ $methodIds = [
+ UnzerPaylaterInvoice::class,
+ UnzerPaylaterDirectDebit::class,
+ UnzerPaylaterInstallment::class,
+ HeidelpaySEPADirectDebit::class
+ // UnzerDirectBankTransfer::class
+ ];
+
+ foreach ($this->paymentMethods as $method) {
+ if ($method->getActive() && \in_array($method->getClassName(), $methodIds)) {
+ $availablePaymentMethods[$method->getMethodID()] = $method;
+ }
+ }
+
// Response
$data = [
'item' => $item,
'items' => $this->model->all(),
'currencies' => $this->model->getCurrencies(),
- 'paymentMethods' => $this->paymentMethods,
+ 'paymentMethods' => $availablePaymentMethods,
'url' => $this->linkHelper->getFullAdminTabUrl(JtlLinkHelper::ADMIN_TAB_ORDERS)
];
diff --git a/src/Controllers/Admin/AdminSettingsController.php b/src/Controllers/Admin/AdminSettingsController.php
index a18e97e..4a5c744 100644
--- a/src/Controllers/Admin/AdminSettingsController.php
+++ b/src/Controllers/Admin/AdminSettingsController.php
@@ -62,7 +62,6 @@ public function handle(): string
$settings = $this->smarty->getTemplateVars('hpSettings');
$settings['config'] = $this->config->all();
-
try {
if (
empty($this->config->get(Config::PRIVATE_KEY))
@@ -134,6 +133,14 @@ protected function handleSaveRequest(): void
$this->config->set(Config::PQ_SELECTOR_REVIEW_STEP, Request::postVar('pqSelectorReviewStep'));
$this->config->set(Config::PQ_METHOD_REVIEW_STEP, Request::postVar('pqMethodReviewStep'));
$this->config->set(Config::ADD_INCOMING_PAYMENTS, Request::postVar('addIncomingPayments', false));
+
+ $this->config->set(Config::UI_FONT_FAMILY, Request::postVar('ui-font-family', ''));
+ $this->config->set(Config::UI_TEXT_COLOR, Request::postVar('ui-text-color', ''));
+ $this->config->set(Config::UI_BRAND_COLOR, Request::postVar('ui-brand-color', ''));
+ $this->config->set(Config::UI_BACKGROUND_COLOR, Request::postVar('ui-background-color', ''));
+ $this->config->set(Config::UI_LINK_COLOR, Request::postVar('ui-link-color', ''));
+ $this->config->set(Config::UI_CORNER_RADIUS, Request::postVar('ui-corner-radius', ''));
+ $this->config->set(Config::UI_SHADOWS, Request::postVar('ui-shadows', ''));
$this->saveChannelId(null);
// Validate
diff --git a/src/Controllers/PaymentController.php b/src/Controllers/PaymentController.php
index ab26cbb..a3b34d9 100644
--- a/src/Controllers/PaymentController.php
+++ b/src/Controllers/PaymentController.php
@@ -70,7 +70,7 @@ public function handle(): string
// Instalment Info
if ($paymentMethod instanceof UnzerPaylaterInstallment) {
- $method = $this->config->get(Config::PQ_METHOD_INSTALMENT_INFO, 'after');
+ $method = $this->config->get(Config::PQ_METHOD_INSTALMENT_INFO, 'before');
$data = [
'info' => $this->plugin->getLocalization()->getTranslation(Config::LANG_INSTLAMENT_INFO)
];
diff --git a/src/Controllers/SyncController.php b/src/Controllers/SyncController.php
index 509a2f0..7295d4b 100644
--- a/src/Controllers/SyncController.php
+++ b/src/Controllers/SyncController.php
@@ -119,13 +119,13 @@ public function handle(): string
// Action routing
if ($this->action == self::ACTION_SHIPMENT) {
$this->handleShipment($mappedOrder);
- $this->model->save($mappedOrder);
+ $this->updatePaymentState($mappedOrder);
return self::ACTION_SHIPMENT;
}
if ($this->action == self::ACTION_CANCEL) {
$this->handleCancel($mappedOrder);
- $this->model->save($mappedOrder);
+ $this->updatePaymentState($mappedOrder);
return self::ACTION_CANCEL;
}
@@ -262,7 +262,7 @@ private function handleCancel(OrderMappingEntity $entity): void
// Most payment types probably contain only one charge, but for a full cancelation we have to cancel all.
foreach ($payment->getCharges() as $charge) {
/** @var Charge $charge */
- $charge = $api->fetchCharge($charge);
+ $charge = $api->fetchChargeById($payment, $charge->getId());
if (!$charge->isError()) {
try {
@@ -274,9 +274,11 @@ private function handleCancel(OrderMappingEntity $entity): void
continue;
}
+ $key = $this->adapter->getCurrentConnection()->getKey();
+ $key = substr($key, 0, -16) . str_repeat('•', 16);
$this->errorLog(
'An API error occured while trying to cancel the transaction: ' .
- $exc->getMerchantMessage() . ' | ' . $exc->getCode()
+ $exc->getMerchantMessage() . ' | Id: ' . $exc->getErrorId() . ' | Code: ' . $exc->getCode() . ' | API-Key: ' . $key
);
}
}
@@ -332,4 +334,13 @@ private function cancelTransaction(Payment $payment, $transaction, HeidelpayPaym
static::class
);
}
+
+ private function updatePaymentState(OrderMappingEntity $entity): void
+ {
+ $this->adapter->getConnectionForOrder($this->order);
+ $payment = $this->adapter->fetchPayment($entity->getPaymentId());
+ $entity->setPaymentState($payment->getStateName());
+
+ $this->model->save($entity);
+ }
}
diff --git a/src/Payments/HeidelpayApiAdapter.php b/src/Payments/HeidelpayApiAdapter.php
index d2874b2..dad1134 100644
--- a/src/Payments/HeidelpayApiAdapter.php
+++ b/src/Payments/HeidelpayApiAdapter.php
@@ -5,6 +5,7 @@
namespace Plugin\s360_unzer_shop5\src\Payments;
use Exception;
+use UnzerSDK\Resources\PaymentTypes\Applepay;
use UnzerSDK\Unzer;
use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
@@ -14,6 +15,7 @@
use UnzerSDK\Resources\PaymentTypes\PaylaterInvoice;
use UnzerSDK\Resources\PaymentTypes\PaylaterDirectDebit;
use UnzerSDK\Resources\PaymentTypes\PaylaterInstallment;
+use UnzerSDK\Resources\PaymentTypes\Klarna;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use JTL\Cart\Cart;
@@ -26,6 +28,7 @@
use Plugin\s360_unzer_shop5\src\Utils\JtlLinkHelper;
use Plugin\s360_unzer_shop5\src\Utils\JtlLoggerTrait;
use Plugin\s360_unzer_shop5\src\Utils\SessionHelper;
+use UnzerSDK\Resources\PaymentTypes\Wero;
/**
* Heidelpay API Adapter for JTL Shop.
@@ -47,7 +50,10 @@ class HeidelpayApiAdapter
PaylaterInvoice::class,
PaylaterInstallment::class,
PaylaterDirectDebit::class,
- Googlepay::class
+ Googlepay::class,
+ Applepay::class,
+ Klarna::class,
+ Wero::class
];
/**
diff --git a/src/Payments/HeidelpayPaymentMethod.php b/src/Payments/HeidelpayPaymentMethod.php
index 3138c22..b322013 100644
--- a/src/Payments/HeidelpayPaymentMethod.php
+++ b/src/Payments/HeidelpayPaymentMethod.php
@@ -427,11 +427,12 @@ public function handleNotification($order, $hash, $args): void
{
parent::handleNotification($order, $hash, $args);
+ $paymentId = $this->sessionHelper->get(SessionHelper::KEY_PAYMENT_ID);
$this->handler->finishPayment($hash);
try {
$this->adapter->getConnectionForOrder($order);
- $payment = $this->adapter->fetchPayment();
+ $payment = $this->adapter->fetchPayment($paymentId);
$transaction = $this->adapter->getPaymentTransaction($payment);
// update cBestellNummer because we already have generated it but have no way of telling JTL to use
@@ -443,9 +444,8 @@ public function handleNotification($order, $hash, $args): void
}
// Preorder = 1 => Order was not finalized before and therefore no order mapping was saved. Do this now!
- if (isset($args['state']) && $args['state'] == self::STATE_DURING_CHECKOUT) {
- $this->handler->saveOrderMapping($transaction->getPayment(), $order);
- }
+ // Otherwise, we update the order mapping with possible new payment status (ie user aborted or payment failed already!)
+ $this->handler->saveOrderMapping($transaction->getPayment(), $order);
// The payment process has been successful (probably, as it can be pending).
if ($payment->isCompleted() || $payment->isPending()) {
diff --git a/src/Payments/PaymentHandler.php b/src/Payments/PaymentHandler.php
index 542464f..f2f7e07 100644
--- a/src/Payments/PaymentHandler.php
+++ b/src/Payments/PaymentHandler.php
@@ -411,6 +411,8 @@ public function prepareView(): void
$data['locale'] = $this->adapter->mapToLocale(
$this->session->getFrontendSession()->getLanguage()->cISOSprache ?? 'eng'
);
+ $data['isSandbox'] = $this->config->isSandbox();
+ $data['isDev'] = stripos(Shop::getURL(), 'solution360.dev') !== false || stripos(Shop::getURL(), '.test') !== false;
$publicKey = $this->adapter->getKeypairService()->getPublicKey(
isset(Frontend::getCustomer()->cFirma) && strlen(trim(Frontend::getCustomer()->cFirma)) > 0,
diff --git a/src/Payments/PaymentMethodModuleFactory.php b/src/Payments/PaymentMethodModuleFactory.php
index 9d007c3..1f554c5 100644
--- a/src/Payments/PaymentMethodModuleFactory.php
+++ b/src/Payments/PaymentMethodModuleFactory.php
@@ -25,18 +25,23 @@
use Plugin\s360_unzer_shop5\paymentmethod\HeidelpaySofort;
use Plugin\s360_unzer_shop5\paymentmethod\HeidelpayWeChatPay;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerApplePay;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerApplePayV2;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerBancontact;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerDirectBankTransfer;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerGooglePay;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerKlarna;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterDirectDebit;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterInstallment;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerPaylaterInvoice;
use Plugin\s360_unzer_shop5\paymentmethod\UnzerTwint;
+use Plugin\s360_unzer_shop5\paymentmethod\UnzerWero;
use Plugin\s360_unzer_shop5\src\Utils\Config;
use UnzerSDK\Resources\PaymentTypes\Alipay;
use UnzerSDK\Resources\PaymentTypes\Applepay;
use UnzerSDK\Resources\PaymentTypes\Bancontact;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\PaymentTypes\Card;
+use UnzerSDK\Resources\PaymentTypes\Clicktopay;
use UnzerSDK\Resources\PaymentTypes\EPS;
use UnzerSDK\Resources\PaymentTypes\Giropay;
use UnzerSDK\Resources\PaymentTypes\Googlepay;
@@ -44,6 +49,8 @@
use UnzerSDK\Resources\PaymentTypes\InstallmentSecured;
use UnzerSDK\Resources\PaymentTypes\Invoice;
use UnzerSDK\Resources\PaymentTypes\InvoiceSecured;
+use UnzerSDK\Resources\PaymentTypes\OpenbankingPis;
+use UnzerSDK\Resources\PaymentTypes\Klarna;
use UnzerSDK\Resources\PaymentTypes\PaylaterDirectDebit;
use UnzerSDK\Resources\PaymentTypes\PaylaterInstallment;
use UnzerSDK\Resources\PaymentTypes\PaylaterInvoice;
@@ -56,6 +63,7 @@
use UnzerSDK\Resources\PaymentTypes\Sofort;
use UnzerSDK\Resources\PaymentTypes\Twint;
use UnzerSDK\Resources\PaymentTypes\Wechatpay;
+use UnzerSDK\Resources\PaymentTypes\Wero;
/**
* Factory to create payment method modules.
@@ -88,12 +96,16 @@ class PaymentMethodModuleFactory
HeidelpaySEPADirectDebitGuaranteed::class => ['unzersepalastschrift(guaranteed)', 'unzerlastschrift(secured)'],
HeidelpayWeChatPay::class => 'unzerwechatpay',
UnzerApplePay::class => 'unzerapplepay',
- UnzerPaylaterInvoice::class => 'unzerrechnung(jetztkaufen,späterbezahlen)',
+ UnzerApplePayV2::class => 'unzerapplepayv2',
UnzerBancontact::class => 'unzerbancontact',
- UnzerPaylaterInstallment::class => 'unzerratenzahlung(paylater)',
- UnzerPaylaterDirectDebit::class => 'unzerlastschrift(paylater)',
+ UnzerDirectBankTransfer::class => 'unzerdirectbanktransfer',
UnzerGooglePay::class => 'unzergooglepay',
+ UnzerPaylaterDirectDebit::class => 'unzerlastschrift(paylater)',
+ UnzerPaylaterInstallment::class => 'unzerratenzahlung(paylater)',
+ UnzerPaylaterInvoice::class => 'unzerrechnung(jetztkaufen,späterbezahlen)',
UnzerTwint::class => 'unzertwint',
+ UnzerKlarna::class => 'unzerklarna',
+ UnzerWero::class => 'unzerwero',
];
private const MAPPING = [
@@ -106,7 +118,6 @@ class PaymentMethodModuleFactory
Ideal::class => HeidelpayiDEAL::class,
Invoice::class => HeidelpayInvoice::class,
InvoiceSecured::class => HeidelpayInvoiceGuaranteed::class,
- PaylaterInvoice::class => UnzerPaylaterInvoice::class,
Paypal::class => HeidelpayPayPal::class,
PIS::class => HeidelpayFlexiPayDirect::class,
Prepayment::class => HeidelpayPrepayment::class,
@@ -115,11 +126,17 @@ class PaymentMethodModuleFactory
SepaDirectDebitSecured::class => HeidelpaySEPADirectDebitGuaranteed::class,
Sofort::class => HeidelpaySofort::class,
Wechatpay::class => HeidelpayWeChatPay::class,
+ Applepay::class => UnzerApplePayV2::class,
Bancontact::class => UnzerBancontact::class,
- PaylaterInstallment::class => UnzerPaylaterInstallment::class,
- PaylaterDirectDebit::class => UnzerPaylaterDirectDebit::class,
+ OpenbankingPis::class => UnzerDirectBankTransfer::class,
Googlepay::class => UnzerGooglePay::class,
- Twint::class => UnzerTwint::class
+ PaylaterDirectDebit::class => UnzerPaylaterDirectDebit::class,
+ PaylaterInstallment::class => UnzerPaylaterInstallment::class,
+ PaylaterInvoice::class => UnzerPaylaterInvoice::class,
+ Twint::class => UnzerTwint::class,
+ Clicktopay::class => HeidelpayCreditCard::class,
+ Klarna::class => UnzerKlarna::class,
+ Wero::class => UnzerWero::class,
];
public function __construct()
diff --git a/src/Payments/Traits/CancelPaymentTransaction.php b/src/Payments/Traits/CancelPaymentTransaction.php
index 917cf94..22f3bf1 100644
--- a/src/Payments/Traits/CancelPaymentTransaction.php
+++ b/src/Payments/Traits/CancelPaymentTransaction.php
@@ -13,6 +13,7 @@
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Cancellation;
+use UnzerSDK\Resources\TransactionTypes\Charge;
/**
* Implements a default for CancelableInterface
diff --git a/src/Payments/Traits/HasAuthorization.php b/src/Payments/Traits/HasAuthorization.php
new file mode 100644
index 0000000..340b7e8
--- /dev/null
+++ b/src/Payments/Traits/HasAuthorization.php
@@ -0,0 +1,49 @@
+getLinkService()->getSpecialPages();
+
+ $authorization = new Authorization(
+ $this->getTotalPriceCustomerCurrency($order),
+ $order->Waehrung->getCode(),
+ $this->getReturnURL($order)
+ );
+
+ $authorization->setTermsAndConditionUrl(
+ $specialpages->first(static fn(LinkInterface $link) => $link->getLinkType() === LINKTYP_AGB)?->getUrl()
+ );
+ $authorization->setPrivacyPolicyUrl(
+ $specialpages->first(static fn(LinkInterface $link) => $link->getLinkType() === LINKTYP_DATENSCHUTZ)?->getUrl()
+ );
+ $authorization->setOrderId($order->cBestellNr ?? null);
+
+ if ($withRiskData) {
+ $riskData = (new RiskData())
+ ->setThreatMetrixId($this->sessionHelper->get(SessionHelper::KEY_THREAT_METRIX_ID))
+ ->setRegistrationLevel($customer->nRegistriert == '1' ? '1' : '0')
+ ->setRegistrationDate(
+ DateTime::createFromFormat('Y-m-d', $customer->dErstellt ?? date('Y-m-d'))->format('Ymd')
+ );
+
+ $authorization->setRiskData($riskData);
+ }
+
+ return $authorization;
+ }
+}
\ No newline at end of file
diff --git a/src/Payments/Traits/HasCustomer.php b/src/Payments/Traits/HasCustomer.php
index 2746b1e..b06d7f6 100644
--- a/src/Payments/Traits/HasCustomer.php
+++ b/src/Payments/Traits/HasCustomer.php
@@ -83,7 +83,9 @@ protected function createOrFetchHeidelpayCustomer(
// Create new customer object but do not save the customer in the api
// because some mandatory fields (e.g. birthday) may be missing!
if ($isB2B) {
- return $this->createHeidelpayB2BCustomer($session->getFrontendSession()->getCustomer());
+ return $adapter->getCurrentConnection()->createOrUpdateCustomer(
+ $this->createHeidelpayB2BCustomer($session->getFrontendSession()->getCustomer())
+ );
}
return $adapter->getCurrentConnection()->createOrUpdateCustomer(
diff --git a/src/Payments/Traits/HasDirectCharge.php b/src/Payments/Traits/HasDirectCharge.php
new file mode 100644
index 0000000..8f16948
--- /dev/null
+++ b/src/Payments/Traits/HasDirectCharge.php
@@ -0,0 +1,27 @@
+getTotalPriceCustomerCurrency($order),
+ $order->Waehrung->getCode(),
+ $this->getReturnURL($order)
+ );
+ $charge->setOrderId($order->cBestellNr ?? null);
+
+ return $charge;
+ }
+}
\ No newline at end of file
diff --git a/src/Utils/Config.php b/src/Utils/Config.php
index 9c83643..f07711a 100644
--- a/src/Utils/Config.php
+++ b/src/Utils/Config.php
@@ -46,6 +46,8 @@ class Config
public const LANG_APPLE_PAY_CANCEL_BY_USER = 's360_hp_apple_pay_cancel_by_user';
public const LANG_CANCEL_PAYMENT_REFERENCE = 's360_hp_cancel_payment_reference';
public const LANG_INSTLAMENT_INFO = 's360_hp_instalment_info';
+ public const LANG_COMPANY_TYPE_MISSING = 's360_hp_company_type_missing';
+
// Config Keys
public const PRIVATE_KEY = 'privateKey';
@@ -69,6 +71,17 @@ class Config
public const PQ_SELECTOR_PLACE_ORDER_BUTTON = 'pqSelectorPlaceOrderButton';
public const PQ_SELECTOR_ORDER_CONFIRM_FORM = 'pqSelectorOrderConfirmForm';
+ public const PAYMENT_BOOKING_MODE = 'booking_mode';
+ public const UI_FONT_FAMILY = 'ui_fontFamily';
+ public const UI_TEXT_COLOR = 'ui_textColor';
+ public const UI_BRAND_COLOR = 'ui_brandColor';
+ public const UI_BACKGROUND_COLOR = 'ui_backgroundColor';
+ public const UI_LINK_COLOR = 'ui_linkColor';
+ public const UI_CORNER_RADIUS = 'ui_cornerRadius';
+ public const UI_SHADOWS = 'ui_shadows';
+
+ public const ENABLE_CTP = 'enable_ctp';
+
// Apple Pay Config Keys
public const APPLEPAY_MERCHANT_IDENTIFIER = 'applepay_merchant_identifier';
public const APPLEPAY_MERCHANT_DOMAIN = 'applepay_merchant_domain';
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 2a95046..294ea2b 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -2,27 +2,29 @@
"packages": [
{
"name": "paragonie/constant_time_encoding",
- "version": "v3.0.0",
- "version_normalized": "3.0.0.0",
+ "version": "v3.1.3",
+ "version_normalized": "3.1.3.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
- "reference": "df1e7fde177501eee2037dd159cf04f5f301a512"
+ "reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512",
- "reference": "df1e7fde177501eee2037dd159cf04f5f301a512",
+ "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77",
+ "reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77",
"shasum": ""
},
"require": {
"php": "^8"
},
"require-dev": {
- "phpunit/phpunit": "^9",
- "vimeo/psalm": "^4|^5"
+ "infection/infection": "^0",
+ "nikic/php-fuzzer": "^0",
+ "phpunit/phpunit": "^9|^10|^11",
+ "vimeo/psalm": "^4|^5|^6"
},
- "time": "2024-05-08T12:36:18+00:00",
+ "time": "2025-09-24T15:06:41+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -125,17 +127,17 @@
},
{
"name": "phpseclib/phpseclib",
- "version": "3.0.43",
- "version_normalized": "3.0.43.0",
+ "version": "3.0.46",
+ "version_normalized": "3.0.46.0",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
- "reference": "709ec107af3cb2f385b9617be72af8cf62441d02"
+ "reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/709ec107af3cb2f385b9617be72af8cf62441d02",
- "reference": "709ec107af3cb2f385b9617be72af8cf62441d02",
+ "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6",
+ "reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6",
"shasum": ""
},
"require": {
@@ -153,7 +155,7 @@
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
- "time": "2024-12-14T21:12:59+00:00",
+ "time": "2025-06-26T16:29:55+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -218,7 +220,7 @@
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
- "source": "https://github.com/phpseclib/phpseclib/tree/3.0.43"
+ "source": "https://github.com/phpseclib/phpseclib/tree/3.0.46"
},
"funding": [
{
@@ -238,17 +240,17 @@
},
{
"name": "unzerdev/php-sdk",
- "version": "3.11.0",
- "version_normalized": "3.11.0.0",
+ "version": "3.13.1",
+ "version_normalized": "3.13.1.0",
"source": {
"type": "git",
"url": "https://github.com/unzerdev/php-sdk.git",
- "reference": "274650b6120b8665c8867627210cd8adab65406b"
+ "reference": "0a26d70b33185d52e49b06cb500a6e01bb6f1087"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/274650b6120b8665c8867627210cd8adab65406b",
- "reference": "274650b6120b8665c8867627210cd8adab65406b",
+ "url": "https://api.github.com/repos/unzerdev/php-sdk/zipball/0a26d70b33185d52e49b06cb500a6e01bb6f1087",
+ "reference": "0a26d70b33185d52e49b06cb500a6e01bb6f1087",
"shasum": ""
},
"require": {
@@ -262,7 +264,7 @@
"suggest": {
"ext-curl": "*"
},
- "time": "2024-12-04T08:14:47+00:00",
+ "time": "2025-09-23T14:21:50+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -278,7 +280,7 @@
"description": "This is the php sdk to connect to the Unzer rest API.",
"support": {
"email": "support@unzer.com",
- "source": "https://github.com/unzerdev/php-sdk/tree/3.11.0"
+ "source": "https://github.com/unzerdev/php-sdk/tree/3.13.1"
},
"install-path": "../unzerdev/php-sdk"
}
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index 4521064..07f5e42 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -1,9 +1,9 @@
array(
'name' => 's360/s360_unzer_shop5',
- 'pretty_version' => 'dev-master',
- 'version' => 'dev-master',
- 'reference' => 'dbc2aa7d6bf36b6c68fe0e57fa9f776e52ebe65f',
+ 'pretty_version' => 'dev-develop',
+ 'version' => 'dev-develop',
+ 'reference' => '7003c4acea1ff6298834f293122048fcffe8814b',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,9 +11,9 @@
),
'versions' => array(
'paragonie/constant_time_encoding' => array(
- 'pretty_version' => 'v3.0.0',
- 'version' => '3.0.0.0',
- 'reference' => 'df1e7fde177501eee2037dd159cf04f5f301a512',
+ 'pretty_version' => 'v3.1.3',
+ 'version' => '3.1.3.0',
+ 'reference' => 'd5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77',
'type' => 'library',
'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
'aliases' => array(),
@@ -29,27 +29,27 @@
'dev_requirement' => false,
),
'phpseclib/phpseclib' => array(
- 'pretty_version' => '3.0.43',
- 'version' => '3.0.43.0',
- 'reference' => '709ec107af3cb2f385b9617be72af8cf62441d02',
+ 'pretty_version' => '3.0.46',
+ 'version' => '3.0.46.0',
+ 'reference' => '56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6',
'type' => 'library',
'install_path' => __DIR__ . '/../phpseclib/phpseclib',
'aliases' => array(),
'dev_requirement' => false,
),
's360/s360_unzer_shop5' => array(
- 'pretty_version' => 'dev-master',
- 'version' => 'dev-master',
- 'reference' => 'dbc2aa7d6bf36b6c68fe0e57fa9f776e52ebe65f',
+ 'pretty_version' => 'dev-develop',
+ 'version' => 'dev-develop',
+ 'reference' => '7003c4acea1ff6298834f293122048fcffe8814b',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'unzerdev/php-sdk' => array(
- 'pretty_version' => '3.11.0',
- 'version' => '3.11.0.0',
- 'reference' => '274650b6120b8665c8867627210cd8adab65406b',
+ 'pretty_version' => '3.13.1',
+ 'version' => '3.13.1.0',
+ 'reference' => '0a26d70b33185d52e49b06cb500a6e01bb6f1087',
'type' => 'library',
'install_path' => __DIR__ . '/../unzerdev/php-sdk',
'aliases' => array(),
diff --git a/vendor/paragonie/constant_time_encoding/composer.json b/vendor/paragonie/constant_time_encoding/composer.json
index 5023095..11fad5e 100644
--- a/vendor/paragonie/constant_time_encoding/composer.json
+++ b/vendor/paragonie/constant_time_encoding/composer.json
@@ -40,8 +40,10 @@
"php": "^8"
},
"require-dev": {
- "phpunit/phpunit": "^9",
- "vimeo/psalm": "^4|^5"
+ "infection/infection": "^0",
+ "nikic/php-fuzzer": "^0",
+ "phpunit/phpunit": "^9|^10|^11",
+ "vimeo/psalm": "^4|^5|^6"
},
"autoload": {
"psr-4": {
@@ -52,5 +54,14 @@
"psr-4": {
"ParagonIE\\ConstantTime\\Tests\\": "tests/"
}
+ },
+ "scripts": {
+ "mutation-test": "infection"
+ },
+ "config": {
+ "process-timeout": 0,
+ "allow-plugins": {
+ "infection/extension-installer": true
+ }
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Base32.php b/vendor/paragonie/constant_time_encoding/src/Base32.php
index 48d00b9..379552a 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base32.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base32.php
@@ -3,8 +3,15 @@
namespace ParagonIE\ConstantTime;
use InvalidArgumentException;
+use Override;
use RangeException;
+use SensitiveParameter;
use TypeError;
+use function pack;
+use function rtrim;
+use function strlen;
+use function substr;
+use function unpack;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -44,8 +51,9 @@ abstract class Base32 implements EncoderInterface
* @param bool $strictPadding
* @return string
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
@@ -60,7 +68,7 @@ public static function decode(
* @return string
*/
public static function decodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $strictPadding = false
): string {
@@ -74,8 +82,9 @@ public static function decodeUpper(
* @return string
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
return static::doEncode($binString, false, true);
@@ -87,9 +96,10 @@ public static function encode(
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, false, false);
@@ -101,9 +111,10 @@ public static function encodeUnpadded(
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, true);
@@ -115,9 +126,10 @@ public static function encodeUpper(
* @param string $src
* @return string
* @throws TypeError
+ * @api
*/
public static function encodeUpperUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
return static::doEncode($src, true, false);
@@ -129,6 +141,7 @@ public static function encodeUpperUnpadded(
*
* @param int $src
* @return int
+ * @api
*/
protected static function decode5Bits(int $src): int
{
@@ -151,6 +164,7 @@ protected static function decode5Bits(int $src): int
*
* @param int $src
* @return int
+ * @api
*/
protected static function decode5BitsUpper(int $src): int
{
@@ -171,6 +185,7 @@ protected static function decode5BitsUpper(int $src): int
*
* @param int $src
* @return string
+ * @api
*/
protected static function encode5Bits(int $src): string
{
@@ -179,7 +194,7 @@ protected static function encode5Bits(int $src): string
// if ($src > 25) $ret -= 72;
$diff -= ((25 - $src) >> 8) & 73;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
/**
@@ -190,6 +205,7 @@ protected static function encode5Bits(int $src): string
*
* @param int $src
* @return string
+ * @api
*/
protected static function encode5BitsUpper(int $src): string
{
@@ -198,20 +214,21 @@ protected static function encode5BitsUpper(int $src): string
// if ($src > 25) $ret -= 40;
$diff -= ((25 - $src) >> 8) & 41;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
/**
* @param string $encodedString
* @param bool $upper
* @return string
+ * @api
*/
public static function decodeNoPadding(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $upper = false
): string {
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -242,7 +259,7 @@ public static function decodeNoPadding(
* @throws TypeError
*/
protected static function doDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $upper = false,
bool $strictPadding = false
@@ -253,7 +270,7 @@ protected static function doDecode(
: 'decode5Bits';
// Remove padding
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
if ($srcLen === 0) {
return '';
}
@@ -273,8 +290,8 @@ protected static function doDecode(
);
}
} else {
- $src = \rtrim($src, '=');
- $srcLen = Binary::safeStrlen($src);
+ $src = rtrim($src, '=');
+ $srcLen = strlen($src);
}
$err = 0;
@@ -282,7 +299,7 @@ protected static function doDecode(
// Main loop (no padding):
for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
+ $chunk = unpack('C*', substr($src, $i, 8));
/** @var int $c0 */
$c0 = static::$method($chunk[1]);
/** @var int $c1 */
@@ -300,7 +317,7 @@ protected static function doDecode(
/** @var int $c7 */
$c7 = static::$method($chunk[8]);
- $dest .= \pack(
+ $dest .= pack(
'CCCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -313,7 +330,7 @@ protected static function doDecode(
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
/** @var int $c0 */
$c0 = static::$method($chunk[1]);
@@ -331,7 +348,7 @@ protected static function doDecode(
/** @var int $c6 */
$c6 = static::$method($chunk[7]);
- $dest .= \pack(
+ $dest .= pack(
'CCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -354,7 +371,7 @@ protected static function doDecode(
/** @var int $c5 */
$c5 = static::$method($chunk[6]);
- $dest .= \pack(
+ $dest .= pack(
'CCCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -372,7 +389,7 @@ protected static function doDecode(
/** @var int $c4 */
$c4 = static::$method($chunk[5]);
- $dest .= \pack(
+ $dest .= pack(
'CCC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
@@ -390,7 +407,7 @@ protected static function doDecode(
/** @var int $c3 */
$c3 = static::$method($chunk[4]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
@@ -405,7 +422,7 @@ protected static function doDecode(
/** @var int $c2 */
$c2 = static::$method($chunk[3]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
(($c1 << 6) | ($c2 << 1) ) & 0xff
@@ -418,7 +435,7 @@ protected static function doDecode(
/** @var int $c1 */
$c1 = static::$method($chunk[2]);
- $dest .= \pack(
+ $dest .= pack(
'C',
(($c0 << 3) | ($c1 >> 2) ) & 0xff
);
@@ -427,7 +444,7 @@ protected static function doDecode(
$err |= ($c1 << 6) & 0xff;
}
} else {
- $dest .= \pack(
+ $dest .= pack(
'C',
(($c0 << 3) ) & 0xff
);
@@ -453,10 +470,10 @@ protected static function doDecode(
* @throws TypeError
*/
protected static function doEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $upper = false,
- $pad = true
+ bool $pad = true
): string {
// We do this to reduce code duplication:
$method = $upper
@@ -464,12 +481,12 @@ protected static function doEncode(
: 'encode5Bits';
$dest = '';
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
// Main loop (no padding):
for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 5));
+ $chunk = unpack('C*', substr($src, $i, 5));
$b0 = $chunk[1];
$b1 = $chunk[2];
$b2 = $chunk[3];
@@ -488,7 +505,7 @@ protected static function doEncode(
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
if ($i + 3 < $srcLen) {
$b1 = $chunk[2];
diff --git a/vendor/paragonie/constant_time_encoding/src/Base32Hex.php b/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
index b868dd0..4323a57 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base32Hex.php
@@ -2,6 +2,9 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+use function pack;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -40,6 +43,7 @@ abstract class Base32Hex extends Base32
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode5Bits(int $src): int
{
$ret = -1;
@@ -60,6 +64,7 @@ protected static function decode5Bits(int $src): int
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode5BitsUpper(int $src): int
{
$ret = -1;
@@ -80,6 +85,7 @@ protected static function decode5BitsUpper(int $src): int
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode5Bits(int $src): string
{
$src += 0x30;
@@ -87,7 +93,7 @@ protected static function encode5Bits(int $src): string
// if ($src > 0x39) $src += 0x61 - 0x3a; // 39
$src += ((0x39 - $src) >> 8) & 39;
- return \pack('C', $src);
+ return pack('C', $src);
}
/**
@@ -99,6 +105,7 @@ protected static function encode5Bits(int $src): string
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode5BitsUpper(int $src): string
{
$src += 0x30;
@@ -106,6 +113,6 @@ protected static function encode5BitsUpper(int $src): string
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
$src += ((0x39 - $src) >> 8) & 7;
- return \pack('C', $src);
+ return pack('C', $src);
}
}
\ No newline at end of file
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64.php b/vendor/paragonie/constant_time_encoding/src/Base64.php
index 2e3ecc8..9679748 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64.php
@@ -3,8 +3,23 @@
namespace ParagonIE\ConstantTime;
use InvalidArgumentException;
+use Override;
use RangeException;
+use SensitiveParameter;
+use SodiumException;
use TypeError;
+use function extension_loaded;
+use function pack;
+use function rtrim;
+use function sodium_base642bin;
+use function sodium_bin2base64;
+use function strlen;
+use function substr;
+use function unpack;
+use const SODIUM_BASE64_VARIANT_ORIGINAL;
+use const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING;
+use const SODIUM_BASE64_VARIANT_URLSAFE;
+use const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -47,10 +62,25 @@ abstract class Base64 implements EncoderInterface
*
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_bin2base64($binString, $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
return static::doEncode($binString, true);
}
@@ -63,11 +93,26 @@ public static function encode(
* @return string
*
* @throws TypeError
+ * @api
*/
public static function encodeUnpadded(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src
): string {
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_bin2base64($src, $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
return static::doEncode($src, false);
}
@@ -79,16 +124,16 @@ public static function encodeUnpadded(
* @throws TypeError
*/
protected static function doEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $src,
bool $pad = true
): string {
$dest = '';
- $srcLen = Binary::safeStrlen($src);
+ $srcLen = strlen($src);
// Main loop (no padding):
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 3));
+ $chunk = unpack('C*', substr($src, $i, 3));
$b0 = $chunk[1];
$b1 = $chunk[2];
$b2 = $chunk[3];
@@ -102,7 +147,7 @@ protected static function doEncode(
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
if ($i + 1 < $srcLen) {
$b1 = $chunk[2];
@@ -137,13 +182,14 @@ protected static function doEncode(
* @throws RangeException
* @throws TypeError
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
// Remove padding
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -167,9 +213,24 @@ public static function decode(
'Incorrect padding'
);
}
+ if (extension_loaded('sodium')) {
+ $variant = match(static::class) {
+ Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
+ Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,
+ default => 0,
+ };
+ if ($variant > 0) {
+ try {
+ return sodium_base642bin(substr($encodedString, 0, $srcLen), $variant);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
+ }
} else {
- $encodedString = \rtrim($encodedString, '=');
- $srcLen = Binary::safeStrlen($encodedString);
+ // Just remove all padding.
+ $encodedString = rtrim($encodedString, '=');
+ $srcLen = strlen($encodedString);
}
$err = 0;
@@ -177,13 +238,13 @@ public static function decode(
// Main loop (no padding):
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, 4));
+ $chunk = unpack('C*', substr($encodedString, $i, 4));
$c0 = static::decode6Bits($chunk[1]);
$c1 = static::decode6Bits($chunk[2]);
$c2 = static::decode6Bits($chunk[3]);
$c3 = static::decode6Bits($chunk[4]);
- $dest .= \pack(
+ $dest .= pack(
'CCC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff),
@@ -194,13 +255,13 @@ public static function decode(
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array $chunk */
- $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, $srcLen - $i));
+ $chunk = unpack('C*', substr($encodedString, $i, $srcLen - $i));
$c0 = static::decode6Bits($chunk[1]);
if ($i + 2 < $srcLen) {
$c1 = static::decode6Bits($chunk[2]);
$c2 = static::decode6Bits($chunk[3]);
- $dest .= \pack(
+ $dest .= pack(
'CC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff)
@@ -211,7 +272,7 @@ public static function decode(
}
} elseif ($i + 1 < $srcLen) {
$c1 = static::decode6Bits($chunk[2]);
- $dest .= \pack(
+ $dest .= pack(
'C',
((($c0 << 2) | ($c1 >> 4)) & 0xff)
);
@@ -235,12 +296,13 @@ public static function decode(
/**
* @param string $encodedString
* @return string
+ * @api
*/
public static function decodeNoPadding(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString
): string {
- $srcLen = Binary::safeStrlen($encodedString);
+ $srcLen = strlen($encodedString);
if ($srcLen === 0) {
return '';
}
@@ -314,6 +376,6 @@ protected static function encode6Bits(int $src): string
// if ($src > 62) $diff += 0x2f - 0x2b - 1; // 3
$diff += ((62 - $src) >> 8) & 3;
- return \pack('C', $src + $diff);
+ return pack('C', $src + $diff);
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php b/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
index 5e98a8f..8477517 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64DotSlash.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -44,6 +46,7 @@ abstract class Base64DotSlash extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -70,6 +73,7 @@ protected static function decode6Bits(int $src): int
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$src += 0x2e;
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php b/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
index 9780b14..2c42db3 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -44,6 +46,7 @@ abstract class Base64DotSlashOrdered extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -67,6 +70,7 @@ protected static function decode6Bits(int $src): int
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$src += 0x2e;
diff --git a/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php b/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
index 8192c63..845aaf6 100644
--- a/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
+++ b/vendor/paragonie/constant_time_encoding/src/Base64UrlSafe.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -45,6 +47,7 @@ abstract class Base64UrlSafe extends Base64
* @param int $src
* @return int
*/
+ #[Override]
protected static function decode6Bits(int $src): int
{
$ret = -1;
@@ -74,6 +77,7 @@ protected static function decode6Bits(int $src): int
* @param int $src
* @return string
*/
+ #[Override]
protected static function encode6Bits(int $src): string
{
$diff = 0x41;
diff --git a/vendor/paragonie/constant_time_encoding/src/Binary.php b/vendor/paragonie/constant_time_encoding/src/Binary.php
index a958f2f..3695844 100644
--- a/vendor/paragonie/constant_time_encoding/src/Binary.php
+++ b/vendor/paragonie/constant_time_encoding/src/Binary.php
@@ -2,7 +2,10 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
use TypeError;
+use function strlen;
+use function substr;
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
@@ -46,16 +49,10 @@ abstract class Binary
* @return int
*/
public static function safeStrlen(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): int {
- if (\function_exists('mb_strlen')) {
- // mb_strlen in PHP 7.x can return false.
- /** @psalm-suppress RedundantCast */
- return (int) \mb_strlen($str, '8bit');
- } else {
- return \strlen($str);
- }
+ return strlen($str);
}
/**
@@ -72,7 +69,7 @@ public static function safeStrlen(
* @throws TypeError
*/
public static function safeSubstr(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str,
int $start = 0,
?int $length = null
@@ -80,14 +77,11 @@ public static function safeSubstr(
if ($length === 0) {
return '';
}
- if (\function_exists('mb_substr')) {
- return \mb_substr($str, $start, $length, '8bit');
- }
// Unlike mb_substr(), substr() doesn't accept NULL for length
if ($length !== null) {
- return \substr($str, $start, $length);
+ return substr($str, $start, $length);
} else {
- return \substr($str, $start);
+ return substr($str, $start);
}
}
}
diff --git a/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php b/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
index 9cafbf9..cb358ea 100644
--- a/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
+++ b/vendor/paragonie/constant_time_encoding/src/EncoderInterface.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
+
/**
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
@@ -38,7 +40,10 @@ interface EncoderInterface
* @param string $binString (raw binary)
* @return string
*/
- public static function encode(string $binString): string;
+ public static function encode(
+ #[SensitiveParameter]
+ string $binString
+ ): string;
/**
* Convert a binary string into a hexadecimal string without cache-timing
@@ -48,5 +53,9 @@ public static function encode(string $binString): string;
* @param bool $strictPadding Error on invalid padding
* @return string (raw binary)
*/
- public static function decode(string $encodedString, bool $strictPadding = false): string;
+ public static function decode(
+ #[SensitiveParameter]
+ string $encodedString,
+ bool $strictPadding = false
+ ): string;
}
diff --git a/vendor/paragonie/constant_time_encoding/src/Encoding.php b/vendor/paragonie/constant_time_encoding/src/Encoding.php
index 8b7e387..b28a501 100644
--- a/vendor/paragonie/constant_time_encoding/src/Encoding.php
+++ b/vendor/paragonie/constant_time_encoding/src/Encoding.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use RangeException;
+use SensitiveParameter;
use TypeError;
/**
@@ -30,6 +32,7 @@
/**
* Class Encoding
* @package ParagonIE\ConstantTime
+ * @api
*/
abstract class Encoding
{
@@ -41,7 +44,7 @@ abstract class Encoding
* @throws TypeError
*/
public static function base32Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encode($str);
@@ -55,7 +58,7 @@ public static function base32Encode(
* @throws TypeError
*/
public static function base32EncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -69,7 +72,7 @@ public static function base32EncodeUpper(
* @throws TypeError
*/
public static function base32Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decode($str);
@@ -83,7 +86,7 @@ public static function base32Decode(
* @throws TypeError
*/
public static function base32DecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str);
@@ -97,7 +100,7 @@ public static function base32DecodeUpper(
* @throws TypeError
*/
public static function base32HexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::encode($str);
@@ -111,7 +114,7 @@ public static function base32HexEncode(
* @throws TypeError
*/
public static function base32HexEncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::encodeUpper($str);
@@ -125,7 +128,7 @@ public static function base32HexEncodeUpper(
* @throws TypeError
*/
public static function base32HexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::decode($str);
@@ -139,7 +142,7 @@ public static function base32HexDecode(
* @throws TypeError
*/
public static function base32HexDecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32Hex::decodeUpper($str);
@@ -153,7 +156,7 @@ public static function base32HexDecodeUpper(
* @throws TypeError
*/
public static function base64Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::encode($str);
@@ -167,7 +170,7 @@ public static function base64Encode(
* @throws TypeError
*/
public static function base64Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::decode($str);
@@ -182,7 +185,7 @@ public static function base64Decode(
* @throws TypeError
*/
public static function base64EncodeDotSlash(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlash::encode($str);
@@ -195,11 +198,11 @@ public static function base64EncodeDotSlash(
*
* @param string $str
* @return string
- * @throws \RangeException
+ * @throws RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlash(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlash::decode($str);
@@ -214,7 +217,7 @@ public static function base64DecodeDotSlash(
* @throws TypeError
*/
public static function base64EncodeDotSlashOrdered(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::encode($str);
@@ -227,11 +230,11 @@ public static function base64EncodeDotSlashOrdered(
*
* @param string $str
* @return string
- * @throws \RangeException
+ * @throws RangeException
* @throws TypeError
*/
public static function base64DecodeDotSlashOrdered(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64DotSlashOrdered::decode($str);
@@ -246,7 +249,7 @@ public static function base64DecodeDotSlashOrdered(
* @throws TypeError
*/
public static function hexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::encode($bin_string);
@@ -258,10 +261,10 @@ public static function hexEncode(
*
* @param string $hex_string
* @return string (raw binary)
- * @throws \RangeException
+ * @throws RangeException
*/
public static function hexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $hex_string
): string {
return Hex::decode($hex_string);
@@ -276,7 +279,7 @@ public static function hexDecode(
* @throws TypeError
*/
public static function hexEncodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::encodeUpper($bin_string);
@@ -290,7 +293,7 @@ public static function hexEncodeUpper(
* @return string
*/
public static function hexDecodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $bin_string
): string {
return Hex::decode($bin_string);
diff --git a/vendor/paragonie/constant_time_encoding/src/Hex.php b/vendor/paragonie/constant_time_encoding/src/Hex.php
index 97c2046..b515b97 100644
--- a/vendor/paragonie/constant_time_encoding/src/Hex.php
+++ b/vendor/paragonie/constant_time_encoding/src/Hex.php
@@ -2,11 +2,20 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use Override;
use RangeException;
+use SensitiveParameter;
+use SodiumException;
use TypeError;
+use function extension_loaded;
+use function pack;
+use function sodium_bin2hex;
+use function sodium_hex2bin;
+use function strlen;
+use function unpack;
/**
- * Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
+ * Copyright (c) 2016 - 2025 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -42,19 +51,27 @@ abstract class Hex implements EncoderInterface
* @return string
* @throws TypeError
*/
+ #[Override]
public static function encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
+ if (extension_loaded('sodium')) {
+ try {
+ return sodium_bin2hex($binString);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
$hex = '';
- $len = Binary::safeStrlen($binString);
+ $len = strlen($binString);
for ($i = 0; $i < $len; ++$i) {
/** @var array $chunk */
- $chunk = \unpack('C', $binString[$i]);
+ $chunk = unpack('C', $binString[$i]);
$c = $chunk[1] & 0xf;
$b = $chunk[1] >> 4;
- $hex .= \pack(
+ $hex .= pack(
'CC',
(87 + $b + ((($b - 10) >> 8) & ~38)),
(87 + $c + ((($c - 10) >> 8) & ~38))
@@ -72,19 +89,19 @@ public static function encode(
* @throws TypeError
*/
public static function encodeUpper(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $binString
): string {
$hex = '';
- $len = Binary::safeStrlen($binString);
+ $len = strlen($binString);
for ($i = 0; $i < $len; ++$i) {
/** @var array $chunk */
- $chunk = \unpack('C', $binString[$i]);
+ $chunk = unpack('C', $binString[$i]);
$c = $chunk[1] & 0xf;
$b = $chunk[1] >> 4;
- $hex .= \pack(
+ $hex .= pack(
'CC',
(55 + $b + ((($b - 10) >> 8) & ~6)),
(55 + $c + ((($c - 10) >> 8) & ~6))
@@ -102,15 +119,23 @@ public static function encodeUpper(
* @return string (raw binary)
* @throws RangeException
*/
+ #[Override]
public static function decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $encodedString,
bool $strictPadding = false
): string {
+ if (extension_loaded('sodium') && $strictPadding) {
+ try {
+ return sodium_hex2bin($encodedString);
+ } catch (SodiumException $ex) {
+ throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
+ }
+ }
$hex_pos = 0;
$bin = '';
$c_acc = 0;
- $hex_len = Binary::safeStrlen($encodedString);
+ $hex_len = strlen($encodedString);
$state = 0;
if (($hex_len & 1) !== 0) {
if ($strictPadding) {
@@ -124,7 +149,7 @@ public static function decode(
}
/** @var array $chunk */
- $chunk = \unpack('C*', $encodedString);
+ $chunk = unpack('C*', $encodedString);
while ($hex_pos < $hex_len) {
++$hex_pos;
$c = $chunk[$hex_pos];
@@ -142,7 +167,7 @@ public static function decode(
if ($state === 0) {
$c_acc = $c_val * 16;
} else {
- $bin .= \pack('C', $c_acc | $c_val);
+ $bin .= pack('C', $c_acc | $c_val);
}
$state ^= 1;
}
diff --git a/vendor/paragonie/constant_time_encoding/src/RFC4648.php b/vendor/paragonie/constant_time_encoding/src/RFC4648.php
index 7cd2e99..fb66f73 100644
--- a/vendor/paragonie/constant_time_encoding/src/RFC4648.php
+++ b/vendor/paragonie/constant_time_encoding/src/RFC4648.php
@@ -2,6 +2,7 @@
declare(strict_types=1);
namespace ParagonIE\ConstantTime;
+use SensitiveParameter;
use TypeError;
/**
@@ -33,6 +34,7 @@
* This class conforms strictly to the RFC
*
* @package ParagonIE\ConstantTime
+ * @api
*/
abstract class RFC4648
{
@@ -47,7 +49,7 @@ abstract class RFC4648
* @throws TypeError
*/
public static function base64Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::encode($str);
@@ -64,7 +66,7 @@ public static function base64Encode(
* @throws TypeError
*/
public static function base64Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64::decode($str, true);
@@ -81,7 +83,7 @@ public static function base64Decode(
* @throws TypeError
*/
public static function base64UrlSafeEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64UrlSafe::encode($str);
@@ -98,7 +100,7 @@ public static function base64UrlSafeEncode(
* @throws TypeError
*/
public static function base64UrlSafeDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base64UrlSafe::decode($str, true);
@@ -115,7 +117,7 @@ public static function base64UrlSafeDecode(
* @throws TypeError
*/
public static function base32Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -132,7 +134,7 @@ public static function base32Encode(
* @throws TypeError
*/
public static function base32Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
@@ -149,7 +151,7 @@ public static function base32Decode(
* @throws TypeError
*/
public static function base32HexEncode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::encodeUpper($str);
@@ -166,7 +168,7 @@ public static function base32HexEncode(
* @throws TypeError
*/
public static function base32HexDecode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Base32::decodeUpper($str, true);
@@ -183,7 +185,7 @@ public static function base32HexDecode(
* @throws TypeError
*/
public static function base16Encode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Hex::encodeUpper($str);
@@ -198,7 +200,7 @@ public static function base16Encode(
* @return string
*/
public static function base16Decode(
- #[\SensitiveParameter]
+ #[SensitiveParameter]
string $str
): string {
return Hex::decode($str, true);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php b/vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php
index fa750ba..ad8f63b 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php
@@ -126,7 +126,9 @@ public static function unpackSSH2($format, &$data)
// 64-bit floats can be used to get larger numbers then 32-bit signed ints would allow
// for. sure, you're not gonna get the full precision of 64-bit numbers but just because
// you need > 32-bit precision doesn't mean you need the full 64-bit precision
- extract(unpack('Nupper/Nlower', self::shift($data, 8)));
+ $unpacked = unpack('Nupper/Nlower', self::shift($data, 8));
+ $upper = $unpacked['upper'];
+ $lower = $unpacked['lower'];
$temp = $upper ? 4294967296 * $upper : 0;
$temp += $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower;
// $temp = hexdec(bin2hex(self::shift($data, 8)));
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php
index 3cb2b30..998cf8b 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php
@@ -129,7 +129,7 @@ class Blowfish extends BlockCipher
/**
* Block Length of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
+ * @see Common\SymmetricKey::block_size
* @var int
*/
protected $block_size = 8;
@@ -137,7 +137,7 @@ class Blowfish extends BlockCipher
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'blowfish';
@@ -145,7 +145,7 @@ class Blowfish extends BlockCipher
/**
* Optimizing value while CFB-encrypting
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
+ * @see Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
@@ -325,7 +325,7 @@ class Blowfish extends BlockCipher
* derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
* of that, we'll just precompute it once.}
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setKeyLength()
+ * @see Common\SymmetricKey::setKeyLength()
* @var int
*/
protected $key_length = 16;
@@ -368,7 +368,7 @@ public function setKeyLength($length)
*
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
+ * @see Common\SymmetricKey::isValidEngine()
* @param int $engine
* @return bool
*/
@@ -394,7 +394,7 @@ protected function isValidEngineHelper($engine)
/**
* Setup the key (expansion)
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey()
+ * @see Common\SymmetricKey::_setupKey()
*/
protected function setupKey()
{
@@ -755,7 +755,7 @@ protected function decryptBlock($in)
/**
* Setup the performance-optimized function for de/encrypt()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupInlineCrypt()
+ * @see Common\SymmetricKey::_setupInlineCrypt()
*/
protected function setupInlineCrypt()
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/JWK.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/JWK.php
index 4c761b8..98b8dac 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/JWK.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/JWK.php
@@ -50,6 +50,14 @@ public static function load($key, $password = '')
return $key;
}
+ if (!is_object($key)) {
+ throw new \RuntimeException('invalid JWK: not an object');
+ }
+
+ if (!isset($key->keys)) {
+ throw new \RuntimeException('invalid JWK: object has no property "keys"');
+ }
+
if (count($key->keys) != 1) {
throw new \RuntimeException('Although the JWK key format supports multiple keys phpseclib does not');
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
index 6c9a650..2211a87 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
@@ -361,7 +361,9 @@ protected static function load($key, $password = '')
if (!$temp) {
throw new \RuntimeException('Unable to decode BER');
}
- extract(ASN1::asn1map($temp[0], Maps\PBEParameter::MAP));
+ $map = ASN1::asn1map($temp[0], Maps\PBEParameter::MAP);
+ $salt = $map['salt'];
+ $iterationCount = $map['iterationCount'];
$iterationCount = (int) $iterationCount->toString();
$cipher->setPassword($password, $kdf, $hash, $salt, $iterationCount);
$key = $cipher->decrypt($decrypted['encryptedData']);
@@ -379,7 +381,8 @@ protected static function load($key, $password = '')
throw new \RuntimeException('Unable to decode BER');
}
$temp = ASN1::asn1map($temp[0], Maps\PBES2params::MAP);
- extract($temp);
+ $keyDerivationFunc = $temp['keyDerivationFunc'];
+ $encryptionScheme = $temp['encryptionScheme'];
$cipher = self::getPBES2EncryptionObject($encryptionScheme['algorithm']);
$meta['meta']['cipher'] = $encryptionScheme['algorithm'];
@@ -389,7 +392,8 @@ protected static function load($key, $password = '')
throw new \RuntimeException('Unable to decode BER');
}
$temp = ASN1::asn1map($temp[0], Maps\PBES2params::MAP);
- extract($temp);
+ $keyDerivationFunc = $temp['keyDerivationFunc'];
+ $encryptionScheme = $temp['encryptionScheme'];
if (!$cipher instanceof RC2) {
$cipher->setIV($encryptionScheme['parameters']['octetString']);
@@ -398,7 +402,9 @@ protected static function load($key, $password = '')
if (!$temp) {
throw new \RuntimeException('Unable to decode BER');
}
- extract(ASN1::asn1map($temp[0], Maps\RC2CBCParameter::MAP));
+ $map = ASN1::asn1map($temp[0], Maps\RC2CBCParameter::MAP);
+ $rc2ParametersVersion = $map['rc2ParametersVersion'];
+ $iv = $map['iv'];
$effectiveKeyLength = (int) $rc2ParametersVersion->toString();
switch ($effectiveKeyLength) {
case 160:
@@ -423,9 +429,13 @@ protected static function load($key, $password = '')
if (!$temp) {
throw new \RuntimeException('Unable to decode BER');
}
- $prf = ['algorithm' => 'id-hmacWithSHA1'];
$params = ASN1::asn1map($temp[0], Maps\PBKDF2params::MAP);
- extract($params);
+ if (empty($params['prf'])) {
+ $params['prf'] = ['algorithm' => 'id-hmacWithSHA1'];
+ }
+ $salt = $params['salt'];
+ $iterationCount = $params['iterationCount'];
+ $prf = $params['prf'];
$meta['meta']['prf'] = $prf['algorithm'];
$hash = str_replace('-', '/', substr($prf['algorithm'], 11));
$params = [
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
index 85da83a..ff4a95a 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
@@ -199,7 +199,7 @@ public static function load($key, $password)
$source = Strings::packSSH2('ssss', $type, $encryption, $components['comment'], $public);
- extract(unpack('Nlength', Strings::shift($public, 4)));
+ $length = unpack('Nlength', Strings::shift($public, 4))['length'];
$newtype = Strings::shift($public, $length);
if ($newtype != $type) {
throw new \RuntimeException('The binary type does not match the human readable type field');
@@ -227,7 +227,10 @@ public static function load($key, $password)
$parallelism = trim(preg_replace('#Argon2-Parallelism: (\d+)#', '$1', $key[$offset++]));
$salt = Strings::hex2bin(trim(preg_replace('#Argon2-Salt: ([0-9a-f]+)#', '$1', $key[$offset++])));
- extract(self::generateV3Key($password, $flavour, $memory, $passes, $salt));
+ $v3key = self::generateV3Key($password, $flavour, $memory, $passes, $salt);
+ $symkey = $v3key['symkey'];
+ $symiv = $v3key['symiv'];
+ $hashkey = $v3key['hashkey'];
break;
case 2:
@@ -323,7 +326,10 @@ protected static function wrapPrivateKey($public, $private, $type, $password, ar
$key .= "Argon2-Passes: 13\r\n";
$key .= "Argon2-Parallelism: 1\r\n";
$key .= "Argon2-Salt: " . Strings::bin2hex($salt) . "\r\n";
- extract(self::generateV3Key($password, 'Argon2id', 8192, 13, $salt));
+ $v3key = self::generateV3Key($password, 'Argon2id', 8192, 13, $salt);
+ $symkey = $v3key['symkey'];
+ $symiv = $v3key['symiv'];
+ $hashkey = $v3key['hashkey'];
$hash = new Hash('sha256');
$hash->setKey($hashkey);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php
index 0d96908..c7c080f 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php
@@ -26,7 +26,7 @@ abstract class StreamCipher extends SymmetricKey
*
* Stream ciphers do not have a block size
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
+ * @see SymmetricKey::block_size
* @var int
*/
protected $block_size = 0;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
index 3b03830..93d7ad2 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
@@ -68,7 +68,7 @@ class DES extends BlockCipher
/**
* Block Length of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
+ * @see Common\SymmetricKey::block_size
* @var int
*/
protected $block_size = 8;
@@ -76,7 +76,7 @@ class DES extends BlockCipher
/**
* Key Length (in bytes)
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setKeyLength()
+ * @see Common\SymmetricKey::setKeyLength()
* @var int
*/
protected $key_length = 8;
@@ -84,7 +84,7 @@ class DES extends BlockCipher
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'des';
@@ -92,7 +92,7 @@ class DES extends BlockCipher
/**
* The OpenSSL names of the cipher / modes
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::openssl_mode_names
+ * @see Common\SymmetricKey::openssl_mode_names
* @var array
*/
protected $openssl_mode_names = [
@@ -106,7 +106,7 @@ class DES extends BlockCipher
/**
* Optimizing value while CFB-encrypting
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
+ * @see Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
@@ -586,7 +586,7 @@ public function __construct($mode)
*
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
+ * @see Common\SymmetricKey::isValidEngine()
* @param int $engine
* @return bool
*/
@@ -615,7 +615,7 @@ protected function isValidEngineHelper($engine)
*
* DES also requires that every eighth bit be a parity bit, however, we'll ignore that.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey()
+ * @see Common\SymmetricKey::setKey()
* @param string $key
*/
public function setKey($key)
@@ -631,8 +631,8 @@ public function setKey($key)
/**
* Encrypts a block
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
+ * @see Common\SymmetricKey::encryptBlock()
+ * @see Common\SymmetricKey::encrypt()
* @see self::encrypt()
* @param string $in
* @return string
@@ -645,8 +645,8 @@ protected function encryptBlock($in)
/**
* Decrypts a block
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
+ * @see Common\SymmetricKey::decryptBlock()
+ * @see Common\SymmetricKey::decrypt()
* @see self::decrypt()
* @param string $in
* @return string
@@ -747,7 +747,7 @@ private function processBlock($block, $mode)
/**
* Creates the key schedule
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey()
+ * @see Common\SymmetricKey::setupKey()
*/
protected function setupKey()
{
@@ -1281,7 +1281,7 @@ protected function setupKey()
/**
* Setup the performance-optimized function for de/encrypt()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt()
+ * @see Common\SymmetricKey::setupInlineCrypt()
*/
protected function setupInlineCrypt()
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php
index f6177f4..8549a2e 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php
@@ -56,7 +56,10 @@ public static function load($key, $password = '')
if (!isset($components['private'])) {
return $components;
}
- extract($components);
+ $type = $components['type'];
+ $comment = $components['comment'];
+ $public = $components['public'];
+ $private = $components['private'];
unset($components['public'], $components['private']);
list($p, $q, $g, $y) = Strings::unpackSSH2('iiii', $public);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php
index 87cd77a..9025213 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php
@@ -88,7 +88,9 @@ public function sign($message)
return $signature;
}
- extract(ASN1Signature::load($signature));
+ $loaded = ASN1Signature::load($signature);
+ $r = $loaded['r'];
+ $s = $loaded['s'];
return $format::save($r, $s);
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php
index c14ffbd..3e16762 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php
@@ -40,7 +40,8 @@ public function verify($message, $signature)
if ($params === false || count($params) != 2) {
return false;
}
- extract($params);
+ $r = $params['r'];
+ $s = $params['s'];
if (self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods())) {
$sig = $format != 'ASN1' ? ASN1Signature::save($r, $s) : $signature;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php
index b792e16..431f957 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php
@@ -246,7 +246,7 @@ public function multiplyPoint(array $p, BigInteger $d)
*
* x=X/Z
*
- * @return \phpseclib3\Math\PrimeField\Integer[]
+ * @return PrimeInteger[]
*/
public function convertToInternal(array $p)
{
@@ -266,7 +266,7 @@ public function convertToInternal(array $p)
/**
* Returns the affine point
*
- * @return \phpseclib3\Math\PrimeField\Integer[]
+ * @return PrimeInteger[]
*/
public function convertToAffine(array $p)
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php
index 6200401..b197055 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php
@@ -751,7 +751,7 @@ private static function getJSFPoints(Integer $k1, Integer $k2)
* To convert a Jacobian Coordinate to an Affine Point
* you do (x / z^2, y / z^3)
*
- * @return \phpseclib3\Math\PrimeField\Integer[]
+ * @return PrimeInteger[]
*/
public function convertToAffine(array $p)
{
@@ -770,7 +770,7 @@ public function convertToAffine(array $p)
/**
* Converts an affine point to a jacobian coordinate
*
- * @return \phpseclib3\Math\PrimeField\Integer[]
+ * @return PrimeInteger[]
*/
public function convertToInternal(array $p)
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php
index 004406a..99aa38b 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php
@@ -171,7 +171,7 @@ public function getBasePoint()
/**
* Returns the affine point
*
- * @return PrimeField\Integer[]
+ * @return PrimeInteger[]
*/
public function convertToAffine(array $p)
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php
index b0cb126..7f6cf63 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php
@@ -71,6 +71,10 @@ public static function load($key, $password = '')
$use_errors = libxml_use_internal_errors(true);
+ if (substr($key, 0, 5) != '' . $key . '';
+ }
+
$temp = self::isolateNamespace($key, 'http://www.w3.org/2009/xmldsig11#');
if ($temp) {
$key = $temp;
@@ -82,9 +86,6 @@ public static function load($key, $password = '')
}
$dom = new \DOMDocument();
- if (substr($key, 0, 5) != '' . $key . '';
- }
if (!$dom->loadXML($key)) {
libxml_use_internal_errors($use_errors);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php
index 91253b8..9947bb7 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php
@@ -157,7 +157,10 @@ public function sign($message)
return $signature;
}
- extract(ASN1Signature::load($signature));
+ $loaded = ASN1Signature::load($signature);
+ $r = $loaded['r'];
+ $s = $loaded['s'];
+
return $this->formatSignature($r, $s);
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php
index 4558ce3..d34c6c4 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php
@@ -115,7 +115,8 @@ public function verify($message, $signature)
if ($params === false || count($params) != 2) {
return false;
}
- extract($params);
+ $r = $params['r'];
+ $s = $params['s'];
if (self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods())) {
$sig = $format != 'ASN1' ? ASN1Signature::save($r, $s) : $signature;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
index 09e48f9..cc5b42c 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
@@ -194,6 +194,15 @@ class Hash
private static $maxwordrange128;
/**#@-*/
+ /**#@+
+ * AES_CMAC variables
+ *
+ * @var string
+ */
+ private $k1;
+ private $k2;
+ /**#@-*/
+
/**
* Default Constructor.
*
@@ -299,6 +308,14 @@ public function setHash($hash)
$this->length = abs(substr($hash, -3)) >> 3;
$this->algo = 'umac';
return;
+ case 'aes_cmac':
+ if ($oldHash != $this->hashParam) {
+ $this->recomputeAESKey = true;
+ }
+ $this->blockSize = 128;
+ $this->length = 16;
+ $this->algo = 'aes_cmac';
+ return;
case 'md2-96':
case 'md5-96':
case 'sha1-96':
@@ -977,6 +994,69 @@ private static function L3Hash($k1, $k2, $m)
public function hash($text)
{
$algo = $this->algo;
+ // https://www.rfc-editor.org/rfc/rfc4493.html
+ // https://en.wikipedia.org/wiki/One-key_MAC
+ if ($algo == 'aes_cmac') {
+ $constZero = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+ if ($this->recomputeAESKey) {
+ if (!is_string($this->key)) {
+ throw new InsufficientSetupException('No key has been set');
+ }
+ if (strlen($this->key) != 16) {
+ throw new \LengthException('Key must be 16 bytes long');
+ }
+ // Algorithm Generate_Subkey
+ $constRb = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x87";
+ $this->c = new AES('ecb');
+ $this->c->setKey($this->key);
+ $this->c->disablePadding();
+ $l = $this->c->encrypt($constZero);
+ $msb = ($l & "\x80") == "\x80";
+ $l = new BigInteger($l, 256);
+ $l->setPrecision(128);
+ $l = $l->bitwise_leftShift(1)->toBytes();
+ // make it constant time
+ $k1 = $msb ? $l ^ $constRb : $l | $constZero;
+
+ $msb = ($k1 & "\x80") == "\x80";
+ $k2 = new BigInteger($k1, 256);
+ $k2->setPrecision(128);
+ $k2 = $k2->bitwise_leftShift(1)->toBytes();
+ // make it constant time
+ $k2 = $msb ? $k2 ^ $constRb : $k2 | $constZero;
+
+ $this->k1 = $k1;
+ $this->k2 = $k2;
+ }
+
+ $len = strlen($text);
+ $const_Bsize = 16;
+ $M = strlen($text) ? str_split($text, $const_Bsize) : [''];
+
+ // Step 2
+ $n = ceil($len / $const_Bsize);
+ // Step 3
+ if ($n == 0) {
+ $n = 1;
+ $flag = false;
+ } else {
+ $flag = $len % $const_Bsize == 0;
+ }
+ // Step 4
+ $M_last = $flag ?
+ $M[$n - 1] ^ $k1 :
+ self::OMAC_padding($M[$n - 1], $const_Bsize) ^ $k2;
+ // Step 5
+ $x = $constZero;
+ // Step 6
+ $c = &$this->c;
+ for ($i = 0; $i < $n - 1; $i++) {
+ $y = $x ^ $M[$i];
+ $x = $c->encrypt($y);
+ }
+ $y = $M_last ^ $x;
+ return $c->encrypt($y);
+ }
if ($algo == 'umac') {
if ($this->recomputeAESKey) {
if (!is_string($this->nonce)) {
@@ -1790,6 +1870,17 @@ private static function sha512_64($m, $hash)
return pack('J*', ...$hash);
}
+ /**
+ * OMAC Padding
+ *
+ * @link https://www.rfc-editor.org/rfc/rfc4493.html#section-2.4
+ */
+ private static function OMAC_padding($m, $length)
+ {
+ $count = $length - strlen($m) - 1;
+ return "$m\x80" . str_repeat("\0", $count);
+ }
+
/**
* __toString() magic method
*/
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php
index 61afbae..3626408 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php
@@ -32,6 +32,7 @@ abstract class PublicKeyLoader
* @return AsymmetricKey
* @param string|array $key
* @param string $password optional
+ * @throws NoKeyLoadedException if key is not valid
*/
public static function load($key, $password = false)
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php
index 654c906..175c52e 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php
@@ -45,7 +45,7 @@ class RC2 extends BlockCipher
/**
* Block Length of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
+ * @see Common\SymmetricKey::block_size
* @var int
*/
protected $block_size = 8;
@@ -53,7 +53,7 @@ class RC2 extends BlockCipher
/**
* The Key
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::key
+ * @see Common\SymmetricKey::key
* @see self::setKey()
* @var string
*/
@@ -62,7 +62,7 @@ class RC2 extends BlockCipher
/**
* The Original (unpadded) Key
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::key
+ * @see Common\SymmetricKey::key
* @see self::setKey()
* @see self::encrypt()
* @see self::decrypt()
@@ -81,7 +81,7 @@ class RC2 extends BlockCipher
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'rc2';
@@ -89,7 +89,7 @@ class RC2 extends BlockCipher
/**
* Optimizing value while CFB-encrypting
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
+ * @see Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 500;
@@ -261,7 +261,7 @@ public function __construct($mode)
*
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
+ * @see Common\SymmetricKey::__construct()
* @param int $engine
* @return bool
*/
@@ -323,7 +323,7 @@ public function getKeyLength()
* has more then 128 bytes in it, and set $key to a single null byte if
* it is empty.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey()
+ * @see Common\SymmetricKey::setKey()
* @param string $key
* @param int|boolean $t1 optional Effective key length in bits.
* @throws \LengthException if the key length isn't supported
@@ -426,8 +426,8 @@ public function decrypt($ciphertext)
/**
* Encrypts a block
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
+ * @see Common\SymmetricKey::encryptBlock()
+ * @see Common\SymmetricKey::encrypt()
* @param string $in
* @return string
*/
@@ -470,8 +470,8 @@ protected function encryptBlock($in)
/**
* Decrypts a block
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
+ * @see Common\SymmetricKey::decryptBlock()
+ * @see Common\SymmetricKey::decrypt()
* @param string $in
* @return string
*/
@@ -514,7 +514,7 @@ protected function decryptBlock($in)
/**
* Creates the key schedule
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey()
+ * @see Common\SymmetricKey::setupKey()
*/
protected function setupKey()
{
@@ -534,7 +534,7 @@ protected function setupKey()
/**
* Setup the performance-optimized function for de/encrypt()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt()
+ * @see Common\SymmetricKey::setupInlineCrypt()
*/
protected function setupInlineCrypt()
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php
index 5f3bff2..98cf011 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php
@@ -72,7 +72,7 @@ class RC4 extends StreamCipher
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'arcfour';
@@ -98,7 +98,7 @@ class RC4 extends StreamCipher
*
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
+ * @see Common\SymmetricKey::__construct()
* @param int $engine
* @return bool
*/
@@ -159,7 +159,7 @@ public function setKey($key)
/**
* Encrypts a message.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
+ * @see Common\SymmetricKey::decrypt()
* @see self::crypt()
* @param string $plaintext
* @return string $ciphertext
@@ -178,7 +178,7 @@ public function encrypt($plaintext)
* $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)).
* At least if the continuous buffer is disabled.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
+ * @see Common\SymmetricKey::encrypt()
* @see self::crypt()
* @param string $ciphertext
* @return string $plaintext
@@ -214,7 +214,7 @@ protected function decryptBlock($in)
/**
* Setup the key (expansion)
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey()
+ * @see Common\SymmetricKey::_setupKey()
*/
protected function setupKey()
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php
index 9cbe6bf..0a11957 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php
@@ -357,10 +357,9 @@ public static function createKey($bits = 2048)
if ($i != $num_primes) {
$primes[$i] = BigInteger::randomPrime($regSize);
} else {
- extract(BigInteger::minMaxBits($bits));
- /** @var BigInteger $min
- * @var BigInteger $max
- */
+ $minMax = BigInteger::minMaxBits($bits);
+ $min = $minMax['min'];
+ $max = $minMax['max'];
list($min) = $min->divide($n);
$min = $min->add(self::$one);
list($max) = $max->divide($n);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php
index b60e48e..035fc8c 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php
@@ -88,13 +88,11 @@ public static function load($key, $password = '')
// PUBLICKEYSTRUC publickeystruc
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa387453(v=vs.85).aspx
- extract(unpack('atype/aversion/vreserved/Valgo', Strings::shift($key, 8)));
- /**
- * @var string $type
- * @var string $version
- * @var integer $reserved
- * @var integer $algo
- */
+ $unpacked = unpack('atype/aversion/vreserved/Valgo', Strings::shift($key, 8));
+ $type = $unpacked['type'];
+ $version = $unpacked['version'];
+ $reserved = $unpacked['reserved'];
+ $algo = $unpacked['algo'];
switch (ord($type)) {
case self::PUBLICKEYBLOB:
case self::PUBLICKEYBLOBEX:
@@ -121,12 +119,10 @@ public static function load($key, $password = '')
// RSAPUBKEY rsapubkey
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa387685(v=vs.85).aspx
// could do V for pubexp but that's unsigned 32-bit whereas some PHP installs only do signed 32-bit
- extract(unpack('Vmagic/Vbitlen/a4pubexp', Strings::shift($key, 12)));
- /**
- * @var integer $magic
- * @var integer $bitlen
- * @var string $pubexp
- */
+ $unpacked = unpack('Vmagic/Vbitlen/a4pubexp', Strings::shift($key, 12));
+ $magic = $unpacked['magic'];
+ $bitlen = $unpacked['bitlen'];
+ $pubexp = $unpacked['pubexp'];
switch ($magic) {
case self::RSA2:
$components['isPublicKey'] = false;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
index 7633556..68d9270 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
@@ -96,6 +96,20 @@ public static function load($key, $password = '')
$components['isPublicKey'] = true;
}
+ $components = $components + $key;
+ foreach ($components as &$val) {
+ if ($val instanceof BigInteger) {
+ $val = self::makePositive($val);
+ }
+ if (is_array($val)) {
+ foreach ($val as &$subval) {
+ if ($subval instanceof BigInteger) {
+ $subval = self::makePositive($subval);
+ }
+ }
+ }
+ }
+
return $components + $key;
}
@@ -157,4 +171,17 @@ public static function savePublicKey(BigInteger $n, BigInteger $e)
return self::wrapPublicKey($key, 'RSA');
}
+
+ /**
+ * Negative numbers make no sense in RSA so convert them to positive
+ *
+ * @param BigInteger $x
+ * @return string
+ */
+ private static function makePositive(BigInteger $x)
+ {
+ return $x->isNegative() ?
+ new BigInteger($x->toBytes(true), 256) :
+ $x;
+ }
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php
index 293903c..8416758 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php
@@ -56,7 +56,10 @@ public static function load($key, $password = '')
if (!isset($components['private'])) {
return $components;
}
- extract($components);
+ $type = $components['type'];
+ $comment = $components['comment'];
+ $public = $components['public'];
+ $private = $components['private'];
unset($components['public'], $components['private']);
$isPublicKey = false;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php
index ff31f9c..5ba7cf7 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php
@@ -74,8 +74,8 @@ class Rijndael extends BlockCipher
* or not for the current $block_size/$key_length.
* In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
- * @see \phpseclib3\Crypt\Common\SymmetricKey::engine
+ * @see Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::engine
* @see self::isValidEngine()
* @var string
*/
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php
index 1ff5ed0..932b7c6 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php
@@ -66,8 +66,8 @@ class TripleDES extends DES
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\DES::cipher_name_mcrypt
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see DES::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'tripledes';
@@ -75,7 +75,7 @@ class TripleDES extends DES
/**
* Optimizing value while CFB-encrypting
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
+ * @see Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 750;
@@ -84,7 +84,7 @@ class TripleDES extends DES
* max possible size of $key
*
* @see self::setKey()
- * @see \phpseclib3\Crypt\DES::setKey()
+ * @see DES::setKey()
* @var string
*/
protected $key_length_max = 24;
@@ -126,8 +126,8 @@ class TripleDES extends DES
*
* - cbc3 (same as cbc)
*
- * @see \phpseclib3\Crypt\DES::__construct()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
+ * @see Crypt\DES::__construct()
+ * @see Common\SymmetricKey::__construct()
* @param string $mode
*/
public function __construct($mode)
@@ -169,7 +169,7 @@ public function __construct($mode)
*
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
+ * @see Common\SymmetricKey::__construct()
* @param int $engine
* @return bool
*/
@@ -189,7 +189,7 @@ protected function isValidEngineHelper($engine)
*
* SetIV is not required when \phpseclib3\Crypt\Common\SymmetricKey::MODE_ECB is being used.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setIV()
+ * @see Common\SymmetricKey::setIV()
* @param string $iv
*/
public function setIV($iv)
@@ -209,7 +209,7 @@ public function setIV($iv)
*
* If you want to use a 64-bit key use DES.php
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey:setKeyLength()
+ * @see Common\SymmetricKey:setKeyLength()
* @throws \LengthException if the key length is invalid
* @param int $length
*/
@@ -233,8 +233,8 @@ public function setKeyLength($length)
*
* DES also requires that every eighth bit be a parity bit, however, we'll ignore that.
*
- * @see \phpseclib3\Crypt\DES::setKey()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey()
+ * @see DES::setKey()
+ * @see Common\SymmetricKey::setKey()
* @throws \LengthException if the key length is invalid
* @param string $key
*/
@@ -270,7 +270,7 @@ public function setKey($key)
/**
* Encrypts a message.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
+ * @see Common\SymmetricKey::encrypt()
* @param string $plaintext
* @return string $cipertext
*/
@@ -296,7 +296,7 @@ public function encrypt($plaintext)
/**
* Decrypts a message.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
+ * @see Common\SymmetricKey::decrypt()
* @param string $ciphertext
* @return string $plaintext
*/
@@ -351,7 +351,7 @@ public function decrypt($ciphertext)
* continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them),
* however, they are also less intuitive and more likely to cause you problems.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::enableContinuousBuffer()
+ * @see Common\SymmetricKey::enableContinuousBuffer()
* @see self::disableContinuousBuffer()
*/
public function enableContinuousBuffer()
@@ -369,7 +369,7 @@ public function enableContinuousBuffer()
*
* The default behavior.
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::disableContinuousBuffer()
+ * @see Common\SymmetricKey::disableContinuousBuffer()
* @see self::enableContinuousBuffer()
*/
public function disableContinuousBuffer()
@@ -385,8 +385,8 @@ public function disableContinuousBuffer()
/**
* Creates the key schedule
*
- * @see \phpseclib3\Crypt\DES::setupKey()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey()
+ * @see DES::setupKey()
+ * @see Common\SymmetricKey::setupKey()
*/
protected function setupKey()
{
@@ -419,8 +419,8 @@ protected function setupKey()
/**
* Sets the internal crypt engine
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
- * @see \phpseclib3\Crypt\Common\SymmetricKey::setPreferredEngine()
+ * @see Common\SymmetricKey::__construct()
+ * @see Common\SymmetricKey::setPreferredEngine()
* @param int $engine
*/
public function setPreferredEngine($engine)
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php
index bf76563..141ad01 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php
@@ -49,7 +49,7 @@ class Twofish extends BlockCipher
/**
* The mcrypt specific name of the cipher
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
+ * @see Common\SymmetricKey::cipher_name_mcrypt
* @var string
*/
protected $cipher_name_mcrypt = 'twofish';
@@ -57,7 +57,7 @@ class Twofish extends BlockCipher
/**
* Optimizing value while CFB-encrypting
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
+ * @see Common\SymmetricKey::cfb_init_len
* @var int
*/
protected $cfb_init_len = 800;
@@ -431,7 +431,7 @@ public function setKey($key)
/**
* Setup the key (expansion)
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey()
+ * @see Common\SymmetricKey::_setupKey()
*/
protected function setupKey()
{
@@ -700,7 +700,7 @@ protected function decryptBlock($in)
/**
* Setup the performance-optimized function for de/encrypt()
*
- * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupInlineCrypt()
+ * @see Common\SymmetricKey::_setupInlineCrypt()
*/
protected function setupInlineCrypt()
{
diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php
index c4b06a5..2f1fb8a 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php
@@ -273,8 +273,7 @@ private static function decode_ber($encoded, $start = 0, $encoded_pos = 0)
// tags of indefinte length don't really have a header length; this length includes the tag
$current += ['headerlength' => $length + 2];
$start += $length;
- extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
- /** @var integer $length */
+ $length = unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))['length'];
} else {
$current += ['headerlength' => 2];
}
@@ -931,7 +930,19 @@ private static function encode_der($source, array $mapping, $idx = null, array $
an untagged "DummyReference" (see ITU-T Rec. X.683 | ISO/IEC 8824-4, 8.3)."
*/
if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) {
- $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
+ if ($child['constant'] <= 30) {
+ $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
+ } else {
+ $constant = $child['constant'];
+ $subtag = '';
+ while ($constant > 0) {
+ $subtagvalue = $constant & 0x7F;
+ $subtag = (chr(0x80 | $subtagvalue)) . $subtag;
+ $constant = $constant >> 7;
+ }
+ $subtag[strlen($subtag) - 1] = $subtag[strlen($subtag) - 1] & chr(0x7F);
+ $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | 0x1f) . $subtag;
+ }
$temp = $subtag . self::encodeLength(strlen($temp)) . $temp;
} else {
$subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']);
@@ -1140,6 +1151,8 @@ private static function encode_der($source, array $mapping, $idx = null, array $
*/
public static function decodeOID($content)
{
+ // BigInteger's are used because of OIDs like 2.25.329800735698586629295641978511506172918
+ // https://healthcaresecprivacy.blogspot.com/2011/02/creating-and-using-unique-id-uuid-oid.html elaborates.
static $eighty;
if (!$eighty) {
$eighty = new BigInteger(80);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/X509.php b/vendor/phpseclib/phpseclib/phpseclib/File/X509.php
index 00504f1..80e0bab 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/File/X509.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/File/X509.php
@@ -626,7 +626,9 @@ private function mapOutExtensions(array &$root, $path)
$extensions = &$this->subArray($root, $path, !empty($this->extensionValues));
foreach ($this->extensionValues as $id => $data) {
- extract($data);
+ $critical = $data['critical'];
+ $replace = $data['replace'];
+ $value = $data['value'];
$newext = [
'extnId' => $id,
'extnValue' => $value,
@@ -1858,7 +1860,7 @@ public function getDN($format = self::DN_ARRAY, $dn = null)
$dn = $this->getDN(self::DN_CANON, $dn);
$hash = new Hash('sha1');
$hash = $hash->hash($dn);
- extract(unpack('Vhash', $hash));
+ $hash = unpack('Vhash', $hash)['hash'];
return strtolower(Strings::bin2hex(pack('N', $hash)));
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php
index 2a9cc0b..965d7ff 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php
@@ -143,6 +143,11 @@ private static function initialize_static_variables()
['PHP64', ['DefaultEngine']],
['PHP32', ['DefaultEngine']]
];
+ // per https://phpseclib.com/docs/speed PHP 8.4.0+ _significantly_ sped up BCMath
+ if (version_compare(PHP_VERSION, '8.4.0') >= 0) {
+ $engines[1][0] = 'BCMath';
+ $engines[2][0] = 'PHP64';
+ }
foreach ($engines as $engine) {
try {
@@ -333,12 +338,10 @@ public function modInverse(BigInteger $n)
*/
public function extendedGCD(BigInteger $n)
{
- extract($this->value->extendedGCD($n->value));
- /**
- * @var BigInteger $gcd
- * @var BigInteger $x
- * @var BigInteger $y
- */
+ $extended = $this->value->extendedGCD($n->value);
+ $gcd = $extended['gcd'];
+ $x = $extended['x'];
+ $y = $extended['y'];
return [
'gcd' => new static($gcd),
'x' => new static($x),
@@ -617,10 +620,9 @@ public static function minMaxBits($bits)
self::initialize_static_variables();
$class = self::$mainEngine;
- extract($class::minMaxBits($bits));
- /** @var BigInteger $min
- * @var BigInteger $max
- */
+ $minMax = $class::minMaxBits($bits);
+ $min = $minMax['min'];
+ $max = $minMax['max'];
return [
'min' => new static($min),
'max' => new static($max)
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php
index e3a4990..7b62830 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php
@@ -38,6 +38,11 @@ class BCMath extends Engine
*/
const ENGINE_DIR = 'BCMath';
+ /**
+ * Test to see if bcmod() accepts 2 or 3 parameters
+ */
+ const BCMOD_THREE_PARAMS = PHP_VERSION_ID >= 72000;
+
/**
* Test for engine validity
*
@@ -148,7 +153,7 @@ public function toBytes($twos_compliment = false)
}
while (bccomp($current, '0', 0) > 0) {
- $temp = bcmod($current, '16777216');
+ $temp = self::BCMOD_THREE_PARAMS ? bcmod($current, '16777216', 0) : bcmod($current, '16777216');
$value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value;
$current = bcdiv($current, '16777216', 0);
}
@@ -167,7 +172,7 @@ public function toBytes($twos_compliment = false)
public function add(BCMath $y)
{
$temp = new self();
- $temp->value = bcadd($this->value, $y->value);
+ $temp->value = bcadd($this->value, $y->value, 0);
return $this->normalize($temp);
}
@@ -181,7 +186,7 @@ public function add(BCMath $y)
public function subtract(BCMath $y)
{
$temp = new self();
- $temp->value = bcsub($this->value, $y->value);
+ $temp->value = bcsub($this->value, $y->value, 0);
return $this->normalize($temp);
}
@@ -195,7 +200,7 @@ public function subtract(BCMath $y)
public function multiply(BCMath $x)
{
$temp = new self();
- $temp->value = bcmul($this->value, $x->value);
+ $temp->value = bcmul($this->value, $x->value, 0);
return $this->normalize($temp);
}
@@ -217,7 +222,7 @@ public function divide(BCMath $y)
$remainder = new self();
$quotient->value = bcdiv($this->value, $y->value, 0);
- $remainder->value = bcmod($this->value, $y->value);
+ $remainder->value = self::BCMOD_THREE_PARAMS ? bcmod($this->value, $y->value, 0) : bcmod($this->value, $y->value);
if ($remainder->value[0] == '-') {
$remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0);
@@ -297,8 +302,7 @@ public function extendedGCD(BCMath $n)
*/
public function gcd(BCMath $n)
{
- extract($this->extendedGCD($n));
- /** @var BCMath $gcd */
+ $gcd = $this->extendedGCD($n)['gcd'];
return $gcd;
}
@@ -475,7 +479,7 @@ protected function normalize(BCMath $result)
$result->bitmask = $this->bitmask;
if ($result->bitmask !== false) {
- $result->value = bcmod($result->value, $result->bitmask->value);
+ $result->value = self::BCMOD_THREE_PARAMS ? bcmod($result->value, $result->bitmask->value, 0) : bcmod($result->value, $result->bitmask->value);
}
return $result;
@@ -523,7 +527,7 @@ public static function randomRange(BCMath $min, BCMath $max)
protected function make_odd()
{
if (!$this->isOdd()) {
- $this->value = bcadd($this->value, '1');
+ $this->value = bcadd($this->value, '1', 0);
}
}
@@ -547,7 +551,7 @@ protected function testSmallPrimes()
$value = $this->value;
foreach (self::PRIMES as $prime) {
- $r = bcmod($this->value, $prime);
+ $r = self::BCMOD_THREE_PARAMS ? bcmod($this->value, $prime, 0) : bcmod($this->value, $prime);
if ($r == '0') {
return $this->value == $prime;
}
@@ -587,7 +591,7 @@ public static function scan1divide(BCMath $r)
public function pow(BCMath $n)
{
$temp = new self();
- $temp->value = bcpow($this->value, $n->value);
+ $temp->value = bcpow($this->value, $n->value, 0);
return $this->normalize($temp);
}
@@ -656,8 +660,9 @@ public function isOdd()
*/
public function testBit($x)
{
+ $divisor = bcpow('2', $x + 1, 0);
return bccomp(
- bcmod($this->value, bcpow('2', $x + 1, 0)),
+ self::BCMOD_THREE_PARAMS ? bcmod($this->value, $divisor, 0) : bcmod($this->value, $divisor),
bcpow('2', $x, 0),
0
) >= 0;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php
index fe21e04..88cd93e 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php
@@ -91,7 +91,7 @@ protected static function prepareReduce($x, $n, $class)
*/
protected static function multiplyReduce($x, $y, $n, $class)
{
- return static::reduce(bcmul($x, $y), $n);
+ return static::reduce(bcmul($x, $y, 0), $n);
}
/**
@@ -105,6 +105,6 @@ protected static function multiplyReduce($x, $y, $n, $class)
*/
protected static function squareReduce($x, $n, $class)
{
- return static::reduce(bcmul($x, $x), $n);
+ return static::reduce(bcmul($x, $x, 0), $n);
}
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php
index b7ca8a2..f8bbcfa 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php
@@ -33,7 +33,7 @@ abstract class BuiltIn extends BCMath
protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n)
{
$temp = new BCMath();
- $temp->value = bcpowmod($x->value, $e->value, $n->value);
+ $temp->value = bcpowmod($x->value, $e->value, $n->value, 0);
return $x->normalize($temp);
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php
index 9e01bf0..1bec0a1 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php
@@ -67,7 +67,7 @@ protected static function reduce($n, $m)
$m_length = strlen($m);
if (strlen($n) > 2 * $m_length) {
- return bcmod($n, $m);
+ return self::BCMOD_THREE_PARAMS ? bcmod($n, $m, 0) : bcmod($n, $m);
}
// if (m.length >> 1) + 2 <= m.length then m is too small and n can't be reduced
@@ -89,14 +89,16 @@ protected static function reduce($n, $m)
$lhs = '1' . str_repeat('0', $m_length + ($m_length >> 1));
$u = bcdiv($lhs, $m, 0);
- $m1 = bcsub($lhs, bcmul($u, $m));
+ $m1 = bcsub($lhs, bcmul($u, $m, 0), 0);
$cache[self::DATA][] = [
'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1)
'm1' => $m1 // m.length
];
} else {
- extract($cache[self::DATA][$key]);
+ $cacheValues = $cache[self::DATA][$key];
+ $u = $cacheValues['u'];
+ $m1 = $cacheValues['m1'];
}
$cutoff = $m_length + ($m_length >> 1);
@@ -104,8 +106,8 @@ protected static function reduce($n, $m)
$lsd = substr($n, -$cutoff);
$msd = substr($n, 0, -$cutoff);
- $temp = bcmul($msd, $m1); // m.length + (m.length >> 1)
- $n = bcadd($lsd, $temp); // m.length + (m.length >> 1) + 1 (so basically we're adding two same length numbers)
+ $temp = bcmul($msd, $m1, 0); // m.length + (m.length >> 1)
+ $n = bcadd($lsd, $temp, 0); // m.length + (m.length >> 1) + 1 (so basically we're adding two same length numbers)
//if ($m_length & 1) {
// return self::regularBarrett($n, $m);
//}
@@ -114,31 +116,31 @@ protected static function reduce($n, $m)
$temp = substr($n, 0, -$m_length + 1);
// if even: ((m.length >> 1) + 2) + (m.length >> 1) == m.length + 2
// if odd: ((m.length >> 1) + 2) + (m.length >> 1) == (m.length - 1) + 2 == m.length + 1
- $temp = bcmul($temp, $u);
+ $temp = bcmul($temp, $u, 0);
// if even: (m.length + 2) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + 1
// if odd: (m.length + 1) - ((m.length >> 1) + 1) = m.length - (m.length >> 1)
$temp = substr($temp, 0, -($m_length >> 1) - 1);
// if even: (m.length - (m.length >> 1) + 1) + m.length = 2 * m.length - (m.length >> 1) + 1
// if odd: (m.length - (m.length >> 1)) + m.length = 2 * m.length - (m.length >> 1)
- $temp = bcmul($temp, $m);
+ $temp = bcmul($temp, $m, 0);
// at this point, if m had an odd number of digits, we'd be subtracting a 2 * m.length - (m.length >> 1) digit
// number from a m.length + (m.length >> 1) + 1 digit number. ie. there'd be an extra digit and the while loop
// following this comment would loop a lot (hence our calling _regularBarrett() in that situation).
- $result = bcsub($n, $temp);
+ $result = bcsub($n, $temp, 0);
//if (bccomp($result, '0') < 0) {
if ($result[0] == '-') {
$temp = '1' . str_repeat('0', $m_length + 1);
- $result = bcadd($result, $temp);
+ $result = bcadd($result, $temp, 0);
}
- while (bccomp($result, $m) >= 0) {
- $result = bcsub($result, $m);
+ while (bccomp($result, $m, 0) >= 0) {
+ $result = bcsub($result, $m, 0);
}
- return $correctionNeeded ? substr($result, 0, -1) : $result;
+ return $correctionNeeded && $result != '0' ? substr($result, 0, -1) : $result;
}
/**
@@ -161,7 +163,7 @@ private static function regularBarrett($x, $n)
$n_length = strlen($n);
if (strlen($x) > 2 * $n_length) {
- return bcmod($x, $n);
+ return self::BCMOD_THREE_PARAMS ? bcmod($x, $n, 0) : bcmod($x, $n);
}
if (($key = array_search($n, $cache[self::VARIABLE])) === false) {
@@ -172,21 +174,21 @@ private static function regularBarrett($x, $n)
}
$temp = substr($x, 0, -$n_length + 1);
- $temp = bcmul($temp, $cache[self::DATA][$key]);
+ $temp = bcmul($temp, $cache[self::DATA][$key], 0);
$temp = substr($temp, 0, -$n_length - 1);
$r1 = substr($x, -$n_length - 1);
- $r2 = substr(bcmul($temp, $n), -$n_length - 1);
+ $r2 = substr(bcmul($temp, $n, 0), -$n_length - 1);
$result = bcsub($r1, $r2);
//if (bccomp($result, '0') < 0) {
if ($result[0] == '-') {
$q = '1' . str_repeat('0', $n_length + 1);
- $result = bcadd($result, $q);
+ $result = bcadd($result, $q, 0);
}
- while (bccomp($result, $n) >= 0) {
- $result = bcsub($result, $n);
+ while (bccomp($result, $n, 0) >= 0) {
+ $result = bcsub($result, $n, 0);
}
return $result;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php
index e033ba5..040d7b5 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php
@@ -58,7 +58,7 @@ protected static function generateCustomReduction(BCMath $m, $class)
$m_length = strlen($m);
if ($m_length < 5) {
- $code = 'return bcmod($x, $n);';
+ $code = 'return self::BCMOD_THREE_PARAMS ? bcmod($x, $n, 0) : bcmod($x, $n);';
eval('$func = function ($n) { ' . $code . '};');
self::$custom_reduction = $func;
return;
@@ -66,7 +66,7 @@ protected static function generateCustomReduction(BCMath $m, $class)
$lhs = '1' . str_repeat('0', $m_length + ($m_length >> 1));
$u = bcdiv($lhs, $m, 0);
- $m1 = bcsub($lhs, bcmul($u, $m));
+ $m1 = bcsub($lhs, bcmul($u, $m, 0), 0);
$cutoff = $m_length + ($m_length >> 1);
@@ -78,23 +78,23 @@ protected static function generateCustomReduction(BCMath $m, $class)
$lsd = substr($n, -' . $cutoff . ');
$msd = substr($n, 0, -' . $cutoff . ');
- $temp = bcmul($msd, ' . $m1 . ');
- $n = bcadd($lsd, $temp);
+ $temp = bcmul($msd, ' . $m1 . ', 0);
+ $n = bcadd($lsd, $temp, 0);
$temp = substr($n, 0, ' . (-$m_length + 1) . ');
- $temp = bcmul($temp, ' . $u . ');
+ $temp = bcmul($temp, ' . $u . ', 0);
$temp = substr($temp, 0, ' . (-($m_length >> 1) - 1) . ');
- $temp = bcmul($temp, ' . $m . ');
+ $temp = bcmul($temp, ' . $m . ', 0);
- $result = bcsub($n, $temp);
+ $result = bcsub($n, $temp, 0);
if ($result[0] == \'-\') {
$temp = \'1' . str_repeat('0', $m_length + 1) . '\';
- $result = bcadd($result, $temp);
+ $result = bcadd($result, $temp, 0);
}
while (bccomp($result, ' . $m . ') >= 0) {
- $result = bcsub($result, ' . $m . ');
+ $result = bcsub($result, ' . $m . ', 0);
}
return $result;';
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php
index 474abe1..1892042 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php
@@ -316,11 +316,9 @@ protected function modInverseHelper(Engine $n)
return $this->normalize($n->subtract($temp));
}
- extract($this->extendedGCD($n));
- /**
- * @var Engine $gcd
- * @var Engine $x
- */
+ $extended = $this->extendedGCD($n);
+ $gcd = $extended['gcd'];
+ $x = $extended['x'];
if (!$gcd->equals(static::$one[static::class])) {
return false;
@@ -644,7 +642,7 @@ protected function powModOuter(Engine $e, Engine $n)
return $this->normalize($temp->powModInner($e, $n));
}
- if ($this->compare($n) > 0) {
+ if ($this->compare($n) > 0 || $this->isNegative()) {
list(, $temp) = $this->divide($n);
return $temp->powModInner($e, $n);
}
@@ -740,11 +738,9 @@ protected static function slidingWindow(Engine $x, Engine $e, Engine $n, $class)
*/
public static function random($size)
{
- extract(static::minMaxBits($size));
- /**
- * @var BigInteger $min
- * @var BigInteger $max
- */
+ $minMax = static::minMaxBits($size);
+ $min = $minMax['min'];
+ $max = $minMax['max'];
return static::randomRange($min, $max);
}
@@ -758,11 +754,9 @@ public static function random($size)
*/
public static function randomPrime($size)
{
- extract(static::minMaxBits($size));
- /**
- * @var static $min
- * @var static $max
- */
+ $minMax = static::minMaxBits($size);
+ $min = $minMax['min'];
+ $max = $minMax['max'];
return static::randomRangePrime($min, $max);
}
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php
index f616362..0db43ae 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php
@@ -296,7 +296,10 @@ public function modInverse(GMP $n)
*/
public function extendedGCD(GMP $n)
{
- extract(gmp_gcdext($this->value, $n->value));
+ $extended = gmp_gcdext($this->value, $n->value);
+ $g = $extended['g'];
+ $s = $extended['s'];
+ $t = $extended['t'];
return [
'gcd' => $this->normalize(new self($g)),
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php
index 2d89595..de556a3 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php
@@ -533,6 +533,9 @@ protected function divideHelper(PHP $y)
$quotient = new static();
$remainder = new static();
$quotient->value = $q;
+ if ($this->is_negative) {
+ $r = $y->value[0] - $r;
+ }
$remainder->value = [$r];
$quotient->is_negative = $this->is_negative != $y->is_negative;
return [$this->normalize($quotient), $this->normalize($remainder)];
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php
index 8868966..e624f3c 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php
@@ -98,7 +98,9 @@ protected static function reduce(array $n, array $m, $class)
'm1' => $m1 // m.length
];
} else {
- extract($cache[self::DATA][$key]);
+ $cacheValues = $cache[self::DATA][$key];
+ $u = $cacheValues['u'];
+ $m1 = $cacheValues['m1'];
}
$cutoff = $m_length + ($m_length >> 1);
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php b/vendor/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php
index 15eb99c..1ebb2f5 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php
@@ -54,10 +54,24 @@ class Integer extends Base
/**
* Zero
*
- * @var BigInteger
+ * @var BigInteger[]
*/
protected static $zero;
+ /**
+ * One
+ *
+ * @var BigInteger[]
+ */
+ protected static $one;
+
+ /**
+ * Two
+ *
+ * @var BigInteger[]
+ */
+ protected static $two;
+
/**
* Default constructor
*
@@ -68,7 +82,7 @@ public function __construct($instanceID, $num = null)
{
$this->instanceID = $instanceID;
if (!isset($num)) {
- $this->value = clone static::$zero[static::class];
+ $this->value = clone static::$zero[$instanceID];
} else {
$reduce = static::$reduce[$instanceID];
$this->value = $reduce($num);
@@ -95,8 +109,8 @@ public static function setModulo($instanceID, BigInteger $modulo)
public static function setRecurringModuloFunction($instanceID, callable $function)
{
static::$reduce[$instanceID] = $function;
- if (!isset(static::$zero[static::class])) {
- static::$zero[static::class] = new BigInteger();
+ if (!isset(static::$zero[$instanceID])) {
+ static::$zero[$instanceID] = new BigInteger();
}
}
@@ -107,6 +121,9 @@ public static function cleanupCache($instanceID)
{
unset(static::$modulo[$instanceID]);
unset(static::$reduce[$instanceID]);
+ unset(static::$zero[$instanceID]);
+ unset(static::$one[$instanceID]);
+ unset(static::$two[$instanceID]);
}
/**
@@ -240,32 +257,35 @@ public function pow(BigInteger $x)
*/
public function squareRoot()
{
- static $one, $two;
- if (!isset($one)) {
- $one = new BigInteger(1);
- $two = new BigInteger(2);
+ if (!isset(static::$one[$this->instanceID])) {
+ static::$one[$this->instanceID] = new BigInteger(1);
+ static::$two[$this->instanceID] = new BigInteger(2);
}
- $reduce = static::$reduce[$this->instanceID];
- $p_1 = static::$modulo[$this->instanceID]->subtract($one);
+ $one = &static::$one[$this->instanceID];
+ $two = &static::$two[$this->instanceID];
+ $modulo = &static::$modulo[$this->instanceID];
+ $reduce = &static::$reduce[$this->instanceID];
+
+ $p_1 = $modulo->subtract($one);
$q = clone $p_1;
$s = BigInteger::scan1divide($q);
list($pow) = $p_1->divide($two);
- for ($z = $one; !$z->equals(static::$modulo[$this->instanceID]); $z = $z->add($one)) {
- $temp = $z->powMod($pow, static::$modulo[$this->instanceID]);
+ for ($z = $one; !$z->equals($modulo); $z = $z->add($one)) {
+ $temp = $z->powMod($pow, $modulo);
if ($temp->equals($p_1)) {
break;
}
}
$m = new BigInteger($s);
- $c = $z->powMod($q, static::$modulo[$this->instanceID]);
- $t = $this->value->powMod($q, static::$modulo[$this->instanceID]);
+ $c = $z->powMod($q, $modulo);
+ $t = $this->value->powMod($q, $modulo);
list($temp) = $q->add($one)->divide($two);
- $r = $this->value->powMod($temp, static::$modulo[$this->instanceID]);
+ $r = $this->value->powMod($temp, $modulo);
while (!$t->equals($one)) {
for ($i = clone $one; $i->compare($m) < 0; $i = $i->add($one)) {
- if ($t->powMod($two->pow($i), static::$modulo[$this->instanceID])->equals($one)) {
+ if ($t->powMod($two->pow($i), $modulo)->equals($one)) {
break;
}
}
@@ -273,7 +293,7 @@ public function squareRoot()
if ($i->compare($m) == 0) {
return false;
}
- $b = $c->powMod($two->pow($m->subtract($i)->subtract($one)), static::$modulo[$this->instanceID]);
+ $b = $c->powMod($two->pow($m->subtract($i)->subtract($one)), $modulo);
$m = $i;
$c = $reduce($b->multiply($b));
$t = $reduce($t->multiply($c));
@@ -356,6 +376,8 @@ public function getNAF($w = 1)
{
$w++;
+ $zero = &static::$zero[$this->instanceID];
+
$mask = new BigInteger((1 << $w) - 1);
$sub = new BigInteger(1 << $w);
//$sub = new BigInteger(1 << ($w - 1));
@@ -363,7 +385,7 @@ public function getNAF($w = 1)
$d_i = [];
$i = 0;
- while ($d->compare(static::$zero[static::class]) > 0) {
+ while ($d->compare($zero) > 0) {
if ($d->isOdd()) {
// start mods
@@ -377,7 +399,7 @@ public function getNAF($w = 1)
} else {
$d_i[$i] = 0;
}
- $shift = !$d->equals(static::$zero[static::class]) && $d->bitwise_and($mask)->equals(static::$zero[static::class]) ? $w : 1; // $w or $w + 1?
+ $shift = !$d->equals($zero) && $d->bitwise_and($mask)->equals($zero) ? $w : 1; // $w or $w + 1?
$d = $d->bitwise_rightShift($shift);
while (--$shift > 0) {
$d_i[++$i] = 0;
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
index 47dac48..7e25544 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php
@@ -836,6 +836,8 @@ public function realpath($path)
return false;
}
+ $path = (string) $path;
+
if (!$this->canonicalize_paths) {
if ($this->pwd === true) {
return '.';
@@ -923,6 +925,8 @@ public function chdir($dir)
return false;
}
+ $dir = (string) $dir;
+
// assume current dir if $dir is empty
if ($dir === '') {
$dir = './';
@@ -3355,8 +3359,7 @@ private function get_sftp_packet($request_id = null)
if (strlen($this->packet_buffer) < 4) {
throw new \RuntimeException('Packet is too small');
}
- extract(unpack('Nlength', Strings::shift($this->packet_buffer, 4)));
- /** @var integer $length */
+ $length = unpack('Nlength', Strings::shift($this->packet_buffer, 4))['length'];
$tempLength = $length;
$tempLength -= strlen($this->packet_buffer);
@@ -3386,7 +3389,7 @@ private function get_sftp_packet($request_id = null)
$this->packet_type = ord(Strings::shift($this->packet_buffer));
if ($this->use_request_id) {
- extract(unpack('Npacket_id', Strings::shift($this->packet_buffer, 4))); // remove the request id
+ $packet_id = unpack('Npacket_id', Strings::shift($this->packet_buffer, 4))['packet_id']; // remove the request id
$length -= 5; // account for the request id and the packet type
} else {
$length -= 1; // account for the packet type
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php
index 24047b4..a1f2fa2 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php
@@ -139,7 +139,15 @@ public function __construct()
protected function parse_path($path)
{
$orig = $path;
- extract(parse_url($path) + ['port' => 22]);
+ $url = parse_url($path) + ['port' => 22];
+
+ $keys = ['scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'];
+ foreach ($keys as $key) {
+ if (isset($url[$key])) {
+ $$key = $url[$key];
+ }
+ }
+
if (isset($query)) {
$path .= '?' . $query;
} elseif (preg_match('/(\?|\?#)$/', $orig)) {
diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php
index ac44eaa..1c8a0e2 100644
--- a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php
+++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php
@@ -1477,7 +1477,7 @@ private function connect()
}
if (defined('NET_SSH2_LOGGING')) {
- $this->append_log('<- (network: ' . round($totalElapsed, 4) . ')', $line);
+ $this->append_log('<- (network: ' . round($totalElapsed, 4) . ')', $data);
}
if (feof($this->fsock)) {
@@ -1487,7 +1487,13 @@ private function connect()
$extra = $matches[1];
- $this->server_identifier = trim($data, "\r\n");
+ // earlier the SSH specs were quoted.
+ // "The server MAY send other lines of data before sending the version string." they said.
+ // the implication of this is that the lines of data before the server string are *not* a part of it
+ // getting this right is important because the correct server identifier needs to be fed into the
+ // exchange hash for the shared keys to be calculated correctly
+ $data = explode("\r\n", trim($data, "\r\n"));
+ $this->server_identifier = $data[count($data) - 1];
if (strlen($extra)) {
$this->errors[] = $data;
}
@@ -1677,7 +1683,6 @@ private function key_exchange($kexinit_payload_server = false)
case NET_SSH2_MSG_DISCONNECT:
return $this->handleDisconnect($kexinit_payload_server);
}
-
$this->kex_buffer[] = $kexinit_payload_server;
}
@@ -2977,7 +2982,7 @@ public function getOpenChannelCount()
*/
protected function open_channel($channel, $skip_extended = false)
{
- if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_CLOSE) {
+ if (isset($this->channel_status[$channel])) {
throw new \RuntimeException('Please close the channel (' . $channel . ') before trying to open it again');
}
@@ -3346,6 +3351,27 @@ public function reset($channel = null)
}
}
+ /**
+ * Send EOF on a channel
+ *
+ * Sends an EOF to the stream; this is typically used to close standard
+ * input, while keeping output and error alive.
+ *
+ * @param int|null $channel Channel id returned by self::getInteractiveChannelId()
+ * @return void
+ */
+ public function sendEOF($channel = null)
+ {
+ if ($channel === null) {
+ $channel = $this->get_interactive_channel();
+ }
+
+ $excludeStatuses = [NET_SSH2_MSG_CHANNEL_EOF, NET_SSH2_MSG_CHANNEL_CLOSE];
+ if (isset($this->channel_status[$channel]) && !in_array($this->channel_status[$channel], $excludeStatuses)) {
+ $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$channel]));
+ }
+ }
+
/**
* Is timeout?
*
@@ -3722,7 +3748,7 @@ private function get_binary_packet()
}
$padding_length = 0;
$payload = $packet->plain;
- extract(unpack('Cpadding_length', Strings::shift($payload, 1)));
+ $padding_length = unpack('Cpadding_length', Strings::shift($payload, 1))['padding_length'];
if ($padding_length > 0) {
Strings::pop($payload, $padding_length);
}
@@ -3788,8 +3814,7 @@ private function get_binary_packet()
$this->key_exchange();
}
- // don't filter if we're in the middle of a key exchange (since _filter might send out packets)
- return $this->keyExchangeInProgress ? $payload : $this->filter($payload);
+ return $this->filter($payload);
}
/**
@@ -3809,13 +3834,13 @@ private function get_binary_packet_size(&$packet)
switch ($this->decryptName) {
case 'aes128-gcm@openssh.com':
case 'aes256-gcm@openssh.com':
- extract(unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size)));
+ $packet_length = unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size))['packet_length'];
$packet->size = $packet_length_header_size + $packet_length + $this->decrypt_block_size; // expect tag
break;
case 'chacha20-poly1305@openssh.com':
$this->lengthDecrypt->setNonce(pack('N2', 0, $this->get_seq_no));
$packet_length_header = $this->lengthDecrypt->decrypt(substr($packet->raw, 0, $packet_length_header_size));
- extract(unpack('Npacket_length', $packet_length_header));
+ $packet_length = unpack('Npacket_length', $packet_length_header)['packet_length'];
$packet->size = $packet_length_header_size + $packet_length + 16; // expect tag
break;
default:
@@ -3824,17 +3849,17 @@ private function get_binary_packet_size(&$packet)
return;
}
$packet->plain = $this->decrypt->decrypt(substr($packet->raw, 0, $this->decrypt_block_size));
- extract(unpack('Npacket_length', Strings::shift($packet->plain, $packet_length_header_size)));
+ $packet_length = unpack('Npacket_length', Strings::shift($packet->plain, $packet_length_header_size))['packet_length'];
$packet->size = $packet_length_header_size + $packet_length;
$added_validation_length = $packet_length_header_size;
} else {
- extract(unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size)));
+ $packet_length = unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size))['packet_length'];
$packet->size = $packet_length_header_size + $packet_length;
}
break;
}
} else {
- extract(unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size)));
+ $packet_length = unpack('Npacket_length', substr($packet->raw, 0, $packet_length_header_size))['packet_length'];
$packet->size = $packet_length_header_size + $packet_length;
$added_validation_length = $packet_length_header_size;
}
@@ -3884,9 +3909,15 @@ private function handleDisconnect($payload)
*/
private function filter($payload)
{
+ if (ord($payload[0]) == NET_SSH2_MSG_DISCONNECT) {
+ return $this->handleDisconnect($payload);
+ }
+
+ if ($this->session_id === false && $this->keyExchangeInProgress) {
+ return $payload;
+ }
+
switch (ord($payload[0])) {
- case NET_SSH2_MSG_DISCONNECT:
- return $this->handleDisconnect($payload);
case NET_SSH2_MSG_IGNORE:
$payload = $this->get_binary_packet();
break;
@@ -3900,7 +3931,7 @@ private function filter($payload)
break; // return payload
case NET_SSH2_MSG_KEXINIT:
// this is here for server initiated key re-exchanges after the initial key exchange
- if ($this->session_id !== false) {
+ if (!$this->keyExchangeInProgress && $this->session_id !== false) {
if (!$this->key_exchange($payload)) {
$this->disconnect_helper(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
throw new ConnectionClosedException('Key exchange failed');
@@ -3920,6 +3951,26 @@ private function filter($payload)
$payload = $this->get_binary_packet();
}
+ /*
+ Once a party has sent a SSH_MSG_KEXINIT message for key exchange or
+ re-exchange, until it has sent a SSH_MSG_NEWKEYS message (Section
+ 7.3), it MUST NOT send any messages other than:
+
+ o Transport layer generic messages (1 to 19) (but
+ SSH_MSG_SERVICE_REQUEST and SSH_MSG_SERVICE_ACCEPT MUST NOT be
+ sent);
+
+ o Algorithm negotiation messages (20 to 29) (but further
+ SSH_MSG_KEXINIT messages MUST NOT be sent);
+
+ o Specific key exchange method messages (30 to 49).
+
+ -- https://www.rfc-editor.org/rfc/rfc4253#section-7.1
+ */
+ if ($this->keyExchangeInProgress) {
+ return $payload;
+ }
+
// see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in
if (($this->bitmap & self::MASK_CONNECTED) && !$this->isAuthenticated() && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) {
Strings::shift($payload, 1);
@@ -3932,7 +3983,10 @@ private function filter($payload)
switch (ord($payload[0])) {
case NET_SSH2_MSG_CHANNEL_REQUEST:
if (strlen($payload) == 31) {
- extract(unpack('cpacket_type/Nchannel/Nlength', $payload));
+ $unpacked = unpack('cpacket_type/Nchannel/Nlength', $payload);
+ $packet_type = $unpacked['packet_type'];
+ $channel = $unpacked['channel'];
+ $length = $unpacked['length'];
if (substr($payload, 9, $length) == 'keepalive@openssh.com' && isset($this->server_channels[$channel])) {
if (ord(substr($payload, 9 + $length))) { // want reply
$this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_SUCCESS, $this->server_channels[$channel]));
@@ -4096,7 +4150,8 @@ public function isPTYEnabled()
protected function get_channel_packet($client_channel, $skip_extended = false)
{
if (!empty($this->channel_buffers[$client_channel])) {
- switch ($this->channel_status[$client_channel]) {
+ // in phpseclib 4.0 this should be changed to $this->channel_status[$client_channel] ?? null
+ switch (isset($this->channel_status[$client_channel]) ? $this->channel_status[$client_channel] : null) {
case NET_SSH2_MSG_CHANNEL_REQUEST:
foreach ($this->channel_buffers[$client_channel] as $i => $packet) {
switch (ord($packet[0])) {
@@ -4164,7 +4219,7 @@ protected function get_channel_packet($client_channel, $skip_extended = false)
continue 2;
case NET_SSH2_MSG_CHANNEL_REQUEST:
- if ($this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_CLOSE) {
+ if (!isset($this->channel_status[$channel])) {
continue 2;
}
list($value) = Strings::unpackSSH2('s', $response);
@@ -4182,10 +4237,14 @@ protected function get_channel_packet($client_channel, $skip_extended = false)
$this->errors[count($this->errors) - 1] .= "\r\n$error_message";
}
- $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
- $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel]));
+ if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_CLOSE) {
+ if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) {
+ $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$channel]));
+ }
+ $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel]));
- $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF;
+ $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE;
+ }
continue 3;
case 'exit-status':
@@ -4286,11 +4345,11 @@ protected function get_channel_packet($client_channel, $skip_extended = false)
$this->close_channel_bitmap($channel);
- if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) {
+ if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_CLOSE) {
$this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel]));
}
- $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE;
+ unset($this->channel_status[$channel]);
$this->channelCount--;
if ($client_channel == $channel) {
@@ -4515,7 +4574,7 @@ private function append_log($message_number, $message)
protected function append_log_helper($constant, $message_number, $message, array &$message_number_log, array &$message_log, &$log_size, &$realtime_log_file, &$realtime_log_wrap, &$realtime_log_size)
{
// remove the byte identifying the message type from all but the first two messages (ie. the identification strings)
- if (strlen($message_number) > 2) {
+ if (!in_array(substr($message_number, 0, 4), ['<- (', '-> (']) && strlen($message_number) > 2) {
Strings::shift($message);
}
@@ -4655,27 +4714,24 @@ protected function send_channel_packet($client_channel, $data)
* @param bool $want_reply
* @return void
*/
- private function close_channel($client_channel, $want_reply = false)
+ private function close_channel($client_channel)
{
// see http://tools.ietf.org/html/rfc4254#section-5.3
- $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
-
- if (!$want_reply) {
- $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel]));
+ if ($this->channel_status[$client_channel] != NET_SSH2_MSG_CHANNEL_EOF) {
+ $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
}
+ $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel]));
$this->channel_status[$client_channel] = NET_SSH2_MSG_CHANNEL_CLOSE;
+
$this->channelCount--;
$this->curTimeout = 5;
-
while (!is_bool($this->get_channel_packet($client_channel))) {
}
- if ($want_reply) {
- $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel]));
- }
+ unset($this->channel_status[$client_channel]);
$this->close_channel_bitmap($client_channel);
}
diff --git a/vendor/unzerdev/php-sdk/CHANGELOG.md b/vendor/unzerdev/php-sdk/CHANGELOG.md
index 384135b..468e50c 100644
--- a/vendor/unzerdev/php-sdk/CHANGELOG.md
+++ b/vendor/unzerdev/php-sdk/CHANGELOG.md
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres
to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [3.13.1](https://github.com/unzerdev/php-sdk/compare/3.13.0..3.13.1)
+
+### Added
+
+* Added support for payment method `Wero`.
+
+## [3.13.0](https://github.com/unzerdev/php-sdk/compare/3.12.0..3.13.0)
+
+### Changed
+
+* Ensure type hints of nullable function parameters are explicitly defined as such to address deprecation warnings.
+* Change paypage v2 test domain ending from ".io" to ".com".
+
+## [3.12.0](https://github.com/unzerdev/php-sdk/compare/3.11.0..3.12.0)
+
+### Added
+
+* Add Styling properties for v2 Paypage `\UnzerSDK\Resources\V2\Paypage`:
+ * `basketBackgroundColor`
+ * `paymentFormBackgroundColor`
+* Add prototypes for v2 Customer: `\UnzerSDK\Resources\V2\Customer`.
+* Add prototypes for v3 Basket: `\UnzerSDK\Resources\V3\Basket`.
+
## [3.11.0](https://github.com/unzerdev/php-sdk/compare/3.10.0..3.11.0)
### Added
diff --git a/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php b/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php
index 824650a..b23a463 100644
--- a/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php
+++ b/vendor/unzerdev/php-sdk/src/Adapter/ApplepayAdapter.php
@@ -67,7 +67,7 @@ public function validMerchantValidationDomain(string $merchantValidationURL): bo
* This is necessary if the ssl cert file doesn't contain key already.
* @param string|null $caCert Path to CA certificate.
*/
- public function init(string $sslCert, string $sslKey = null, string $caCert = null): void
+ public function init(string $sslCert, ?string $sslKey = null, ?string $caCert = null): void
{
$timeout = EnvironmentService::getTimeout();
$curlVerbose = EnvironmentService::isCurlVerbose();
diff --git a/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php b/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php
index e3ddd2b..5535eb4 100644
--- a/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php
+++ b/vendor/unzerdev/php-sdk/src/Adapter/CurlAdapter.php
@@ -10,11 +10,10 @@
namespace UnzerSDK\Adapter;
-use UnzerSDK\Unzer;
-use UnzerSDK\Services\EnvironmentService;
-use UnzerSDK\Exceptions\UnzerApiException;
use RuntimeException;
-
+use UnzerSDK\Exceptions\UnzerApiException;
+use UnzerSDK\Services\EnvironmentService;
+use UnzerSDK\Unzer;
use function extension_loaded;
use function in_array;
@@ -37,7 +36,7 @@ public function __construct()
/**
* {@inheritDoc}
*/
- public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
+ public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
{
$timeout = EnvironmentService::getTimeout();
$curlVerbose = EnvironmentService::isCurlVerbose();
diff --git a/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php b/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php
index 4e238b8..2e2bd0a 100644
--- a/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php
+++ b/vendor/unzerdev/php-sdk/src/Adapter/HttpAdapterInterface.php
@@ -25,7 +25,7 @@ interface HttpAdapterInterface
* @param string|null $payload Json encoded payload string.
* @param string $httpMethod The Http method to perform.
*/
- public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void;
+ public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void;
/**
* Executes the request and returns the response.
diff --git a/vendor/unzerdev/php-sdk/src/Apis/PaymentApiConfigBearerAuth.php b/vendor/unzerdev/php-sdk/src/Apis/PaymentApiConfigBearerAuth.php
new file mode 100644
index 0000000..b0d166e
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Apis/PaymentApiConfigBearerAuth.php
@@ -0,0 +1,17 @@
+clientMessage = empty($clientMessage) ? static::CLIENT_MESSAGE : $clientMessage;
diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/CancelServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/CancelServiceInterface.php
index efa5314..5400380 100644
--- a/vendor/unzerdev/php-sdk/src/Interfaces/CancelServiceInterface.php
+++ b/vendor/unzerdev/php-sdk/src/Interfaces/CancelServiceInterface.php
@@ -8,13 +8,13 @@
namespace UnzerSDK\Interfaces;
+use RuntimeException;
use UnzerSDK\Constants\CancelReasonCodes;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Cancellation;
use UnzerSDK\Resources\TransactionTypes\Charge;
-use RuntimeException;
interface CancelServiceInterface
{
@@ -30,7 +30,7 @@ interface CancelServiceInterface
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation;
+ public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation;
/**
* Performs a Cancellation transaction for the Authorization of the given Payment object.
@@ -44,7 +44,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation;
+ public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation;
/**
* Performs a Cancellation transaction for the given Charge and returns the resulting Cancellation object.
@@ -67,11 +67,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca
public function cancelChargeById(
$payment,
string $chargeId,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation;
/**
@@ -93,11 +93,11 @@ public function cancelChargeById(
*/
public function cancelCharge(
Charge $charge,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation;
/**
@@ -119,11 +119,11 @@ public function cancelCharge(
*/
public function cancelPayment(
$payment,
- float $amount = null,
+ ?float $amount = null,
?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): array;
/**
@@ -167,5 +167,5 @@ public function cancelChargedPayment($payment, ?Cancellation $cancellation = nul
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK.
*/
- public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation;
+ public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation;
}
diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php
index 477e03e..d461397 100644
--- a/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php
+++ b/vendor/unzerdev/php-sdk/src/Interfaces/PaymentServiceInterface.php
@@ -9,6 +9,7 @@
namespace UnzerSDK\Interfaces;
use DateTime;
+use RuntimeException;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\AbstractUnzerResource;
use UnzerSDK\Resources\Basket;
@@ -24,7 +25,6 @@
use UnzerSDK\Resources\TransactionTypes\Charge;
use UnzerSDK\Resources\TransactionTypes\Payout;
use UnzerSDK\Resources\TransactionTypes\Shipment;
-use RuntimeException;
interface PaymentServiceInterface
{
@@ -48,8 +48,8 @@ public function performAuthorization(
Authorization $authorization,
$paymentType,
$customer = null,
- Metadata $metadata = null,
- Basket $basket = null
+ ?Metadata $metadata = null,
+ ?Basket $basket = null
): Authorization;
/**
@@ -130,8 +130,8 @@ public function performCharge(
Charge $charge,
$paymentType,
$customer = null,
- Metadata $metadata = null,
- Basket $basket = null
+ ?Metadata $metadata = null,
+ ?Basket $basket = null
): Charge;
/**
@@ -229,9 +229,9 @@ public function performChargeOnPayment(
*/
public function chargeAuthorization(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge;
/**
@@ -252,9 +252,9 @@ public function chargeAuthorization(
*/
public function chargePayment(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge;
/**
@@ -284,11 +284,11 @@ public function payout(
$paymentType,
string $returnUrl,
$customer = null,
- string $orderId = null,
- Metadata $metadata = null,
- Basket $basket = null,
- string $invoiceId = null,
- string $referenceText = null
+ ?string $orderId = null,
+ ?Metadata $metadata = null,
+ ?Basket $basket = null,
+ ?string $invoiceId = null,
+ ?string $referenceText = null
): Payout;
/**
@@ -303,7 +303,7 @@ public function payout(
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment;
+ public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment;
/**
* Initializes a PayPage for charge transaction and returns the PayPage resource.
@@ -328,9 +328,9 @@ public function ship($payment, string $invoiceId = null, string $orderId = null)
*/
public function initPayPageCharge(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage;
/**
@@ -356,9 +356,9 @@ public function initPayPageCharge(
*/
public function initPayPageAuthorize(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage;
/**
@@ -378,7 +378,7 @@ public function fetchInstallmentPlans(
float $amount,
string $currency,
float $effectiveInterest,
- DateTime $orderDate = null
+ ?DateTime $orderDate = null
): InstalmentPlans;
/**
diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php
index a95fe3e..6f26b0a 100644
--- a/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php
+++ b/vendor/unzerdev/php-sdk/src/Interfaces/ResourceServiceInterface.php
@@ -30,7 +30,7 @@
interface ResourceServiceInterface
{
/**
- * Retrieves an Payout resource via the API using the corresponding Payment or paymentId.
+ * Retrieves a Payout resource via the API using the corresponding Payment or paymentId.
* The Payout resource can not be fetched using its id since they are unique only within the Payment.
* A Payment can have zero or one Payouts.
*
@@ -57,7 +57,7 @@ public function fetchPayout($payment): Payout;
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring;
+ public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring;
/**
* Fetch and return payment by given payment id or payment object.
@@ -162,7 +162,7 @@ public function createBasket(Basket $basket): Basket;
public function fetchBasket($basket): Basket;
/**
- * Update the a basket resource with the given basket object (id must be set).
+ * Update a basket resource with the given basket object (id must be set).
*
* @param Basket $basket
*
@@ -195,12 +195,12 @@ public function createPaymentType(BasePaymentType $paymentType): BasePaymentType
* @return BasePaymentType|AbstractUnzerResource The updated PaymentType object.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
- * @throws RuntimeException A RuntimeException is thrown when there is a error while using the SDK.
+ * @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function updatePaymentType(BasePaymentType $paymentType): BasePaymentType;
/**
- * Fetch the payment type with the given Id from the API.
+ * Fetch the payment type with the given ID from the API.
*
* @param string $typeId
*
@@ -257,7 +257,7 @@ public function fetchCustomer($customer): Customer;
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function fetchCustomerByExtCustomerId(string $customerId): Customer;
+ public function fetchCustomerByExtCustomerId(string $customerId, int $version): Customer;
/**
* Update and return a Customer object via API.
@@ -325,8 +325,8 @@ public function fetchCharge(Charge $charge): Charge;
* Fetch a chargeback object by combination of payment id, chargeback id and charge id.
* Chargeback ids are not unique to a merchant but to the payment.
*
- * @param Payment|string $payment The payment object or payment id to fetch the authorization from.
- * @param string $chargebackId The id of the chargeback to fetch.
+ * @param string $paymentId The payment object or payment id to fetch the authorization from.
+ * @param string $chargebackId The id of the chargeback to fetch.
*
* @return Chargeback|AbstractUnzerResource The fetched chargeback.
*
diff --git a/vendor/unzerdev/php-sdk/src/Interfaces/WebhookServiceInterface.php b/vendor/unzerdev/php-sdk/src/Interfaces/WebhookServiceInterface.php
index 48c89e2..8ae6b5a 100644
--- a/vendor/unzerdev/php-sdk/src/Interfaces/WebhookServiceInterface.php
+++ b/vendor/unzerdev/php-sdk/src/Interfaces/WebhookServiceInterface.php
@@ -8,10 +8,10 @@
namespace UnzerSDK\Interfaces;
+use RuntimeException;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\AbstractUnzerResource;
use UnzerSDK\Resources\Webhook;
-use RuntimeException;
interface WebhookServiceInterface
{
@@ -106,5 +106,5 @@ public function registerMultipleWebhooks(string $url, array $events): array;
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource;
+ public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource;
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/Basket.php b/vendor/unzerdev/php-sdk/src/Resources/Basket.php
index 007af2b..3397f90 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/Basket.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/Basket.php
@@ -4,8 +4,9 @@
use stdClass;
use UnzerSDK\Adapter\HttpAdapterInterface;
+use UnzerSDK\Constants\ApiVersions;
use UnzerSDK\Resources\EmbeddedResources\BasketItem;
-use function count;
+use UnzerSDK\Resources\V2\BasketProperties as BasketV2Properties;
/**
* This represents the basket resource.
@@ -15,6 +16,8 @@
*/
class Basket extends AbstractUnzerResource
{
+ use BasketV2Properties;
+
/**
* @var float $amountTotalGross
*
@@ -36,21 +39,6 @@ class Basket extends AbstractUnzerResource
*/
protected $amountTotalVat = 0.0;
- /** @var float $totalValueGross */
- protected $totalValueGross = 0.0;
-
- /** @var string $currencyCode */
- protected $currencyCode;
-
- /** @var string $orderId */
- protected $orderId = '';
-
- /** @var string $note */
- protected $note;
-
- /** @var BasketItem[] $basketItems */
- private $basketItems;
-
/**
* Basket constructor.
*
@@ -86,9 +74,9 @@ public function getAmountTotalGross(): float
/**
* @param float $amountTotalGross
*
+ * @return Basket
* @deprecated since 1.1.5.0 @see setTotalValueGross().
*
- * @return Basket
*/
public function setAmountTotalGross(float $amountTotalGross): Basket
{
@@ -96,25 +84,6 @@ public function setAmountTotalGross(float $amountTotalGross): Basket
return $this;
}
- /**
- * @return float
- */
- public function getTotalValueGross(): float
- {
- return $this->totalValueGross;
- }
-
- /**
- * @param float $totalValueGross
- *
- * @return Basket
- */
- public function setTotalValueGross(float $totalValueGross): Basket
- {
- $this->totalValueGross = $totalValueGross;
- return $this;
- }
-
/**
* @return float
*
@@ -128,9 +97,9 @@ public function getAmountTotalDiscount(): float
/**
* @param float $amountTotalDiscount
*
+ * @return Basket
* @deprecated since 1.1.5.0 Property is redundant and is no longer needed.
*
- * @return Basket
*/
public function setAmountTotalDiscount(float $amountTotalDiscount): Basket
{
@@ -151,9 +120,9 @@ public function getAmountTotalVat(): float
/**
* @param float $amountTotalVat
*
+ * @return Basket
* @deprecated since 1.1.5.0 Property is redundant and is no longer needed.
*
- * @return Basket
*/
public function setAmountTotalVat(float $amountTotalVat): Basket
{
@@ -162,122 +131,6 @@ public function setAmountTotalVat(float $amountTotalVat): Basket
}
/**
- * @return string
- */
- public function getCurrencyCode(): string
- {
- return $this->currencyCode;
- }
-
- /**
- * @param string $currencyCode
- *
- * @return Basket
- */
- public function setCurrencyCode(string $currencyCode): Basket
- {
- $this->currencyCode = $currencyCode;
- return $this;
- }
-
- /**
- * @return int
- */
- public function getItemCount(): int
- {
- return count($this->basketItems);
- }
-
- /**
- * @return string|null
- */
- public function getNote(): ?string
- {
- return $this->note;
- }
-
- /**
- * @param string|null $note
- *
- * @return Basket
- */
- public function setNote(?string $note): Basket
- {
- $this->note = $note;
- return $this;
- }
-
- /**
- * @return string
- */
- public function getOrderId(): string
- {
- return $this->orderId;
- }
-
- /**
- * @param string $orderId
- *
- * @return Basket
- */
- public function setOrderId(string $orderId): Basket
- {
- $this->orderId = $orderId;
- return $this;
- }
-
- /**
- * @return array
- */
- public function getBasketItems(): array
- {
- return $this->basketItems;
- }
-
- /**
- * @param array $basketItems
- *
- * @return Basket
- */
- public function setBasketItems(array $basketItems): Basket
- {
- $this->basketItems = [];
-
- foreach ($basketItems as $basketItem) {
- $this->addBasketItem($basketItem);
- }
-
- return $this;
- }
-
- /**
- * Adds the given BasketItem to the Basket.
- *
- * @param BasketItem $basketItem
- *
- * @return Basket
- */
- public function addBasketItem(BasketItem $basketItem): Basket
- {
- $this->basketItems[] = $basketItem;
- if ($basketItem->getBasketItemReferenceId() === null) {
- $basketItem->setBasketItemReferenceId((string)$this->getKeyOfLastBasketItemAdded());
- }
- return $this;
- }
-
- /**
- * @param int $index
- *
- * @return BasketItem|null
- */
- public function getBasketItemByIndex(int $index): ?BasketItem
- {
- return $this->basketItems[$index] ?? null;
- }
-
- /**
- * Add the dynamically set meta data.
* {@inheritDoc}
*/
public function expose(): array
@@ -301,7 +154,7 @@ public function expose(): array
public function getApiVersion(): string
{
if (!empty($this->getTotalValueGross())) {
- return 'v2';
+ return ApiVersions::V2;
}
return parent::getApiVersion();
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/CustomerFactory.php b/vendor/unzerdev/php-sdk/src/Resources/CustomerFactory.php
index 777c142..b353644 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/CustomerFactory.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/CustomerFactory.php
@@ -6,6 +6,7 @@
use UnzerSDK\Constants\CompanyRegistrationTypes;
use UnzerSDK\Resources\EmbeddedResources\Address;
use UnzerSDK\Resources\EmbeddedResources\CompanyInfo;
+use UnzerSDK\Resources\V2\Customer as CustomerV2;
/**
* Creates the different Customer objects.
@@ -15,6 +16,18 @@
*/
class CustomerFactory
{
+ private static int $version = 1;
+
+ public static function setVersion(int $version): void
+ {
+ self::$version = $version;
+ }
+
+ public static function getVersion(): int
+ {
+ return self::$version;
+ }
+
/**
* Creates a local Customer object for B2C transactions.
* Please use Unzer::createCustomer(...) to create the customer resource on the API side.
@@ -26,7 +39,7 @@ class CustomerFactory
*/
public static function createCustomer(string $firstname, string $lastname): Customer
{
- return (new Customer())->setFirstname($firstname)->setLastname($lastname);
+ return self::getCustomer()->setFirstname($firstname)->setLastname($lastname);
}
/**
@@ -58,7 +71,7 @@ public static function createNotRegisteredB2bCustomer(
->setFunction('OWNER')
->setCommercialSector($commercialSector);
- return (new Customer())
+ return self::getCustomer()
->setFirstname($firstname)
->setLastname($lastname)
->setBirthDate($birthDate)
@@ -89,9 +102,17 @@ public static function createRegisteredB2bCustomer(
->setCommercialRegisterNumber($commercialRegisterNumber)
->setCommercialSector($commercialSector);
- return (new Customer())
+ return self::getCustomer()
->setCompany($company)
->setBillingAddress($billingAddress)
->setCompanyInfo($companyInfo);
}
+
+ /**
+ * @return Customer
+ */
+ protected static function getCustomer(): Customer
+ {
+ return (self::$version == 2) ? new CustomerV2() : new Customer();
+ }
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/BasketItem.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/BasketItem.php
index bffe0eb..feaa2b3 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/BasketItem.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/BasketItem.php
@@ -3,6 +3,7 @@
namespace UnzerSDK\Resources\EmbeddedResources;
use UnzerSDK\Resources\AbstractUnzerResource;
+use UnzerSDK\Resources\V2\BasketItemProperties as BasketV2ItemProperties;
/**
* This trait adds amount properties to a class.
@@ -12,14 +13,7 @@
*/
class BasketItem extends AbstractUnzerResource
{
- /** @var string $basketItemReferenceId */
- protected $basketItemReferenceId;
-
- /** @var int $quantity */
- protected $quantity = 1;
-
- /** @var float $vat */
- protected $vat = 0.0;
+ use BasketV2ItemProperties;
/**
* @var float $amountDiscount
@@ -28,9 +22,6 @@ class BasketItem extends AbstractUnzerResource
*/
protected $amountDiscount = 0.0;
- /** @var float $amountDiscountPerUnitGross */
- protected $amountDiscountPerUnitGross = 0.0;
-
/**
* @var float $amountGross
*
@@ -52,9 +43,6 @@ class BasketItem extends AbstractUnzerResource
*/
protected $amountPerUnit = 0.0;
- /** @var float $amountPerUnitGross */
- protected $amountPerUnitGross = 0.0;
-
/**
* @var float $amountNet
*
@@ -62,98 +50,27 @@ class BasketItem extends AbstractUnzerResource
*/
protected $amountNet = 0.0;
- /** @var string $unit */
- protected $unit;
-
- /** @var string $title */
- protected $title = '';
-
- /** @var string|null $subTitle */
- protected $subTitle;
-
- /** @var string|null $imageUrl */
- protected $imageUrl;
-
- /** @var string|null $type */
- protected $type;
-
/**
* BasketItem constructor.
*
+ * @param string $title
+ * @param float $amountNet
+ * @param float $amountPerUnit
+ * @param int $quantity
* @deprecated since 1.1.5.0 Please call constructor without parameters and use setter functions instead.
*
- * @param string $title
- * @param float $amountNet
- * @param float $amountPerUnit
- * @param int $quantity
*/
public function __construct(
string $title = '',
float $amountNet = 0.0,
float $amountPerUnit = 0.0,
- int $quantity = 1
- ) {
- $this->title = $title;
- $this->quantity = $quantity;
- $this->setAmountNet($amountNet);
- $this->setAmountPerUnit($amountPerUnit);
- }
-
- /**
- * @return string|null
- */
- public function getBasketItemReferenceId(): ?string
- {
- return $this->basketItemReferenceId;
- }
-
- /**
- * @param string|null $basketItemReferenceId
- *
- * @return BasketItem
- */
- public function setBasketItemReferenceId(?string $basketItemReferenceId): BasketItem
- {
- $this->basketItemReferenceId = $basketItemReferenceId;
- return $this;
- }
-
- /**
- * @return int
- */
- public function getQuantity(): int
- {
- return $this->quantity;
- }
-
- /**
- * @param int $quantity
- *
- * @return BasketItem
- */
- public function setQuantity(int $quantity): BasketItem
+ int $quantity = 1
+ )
{
+ $this->title = $title;
$this->quantity = $quantity;
- return $this;
- }
-
- /**
- * @return float
- */
- public function getVat(): float
- {
- return $this->vat;
- }
-
- /**
- * @param float $vat
- *
- * @return BasketItem
- */
- public function setVat(float $vat): BasketItem
- {
- $this->vat = $vat;
- return $this;
+ $this->setAmountNet($amountNet);
+ $this->setAmountPerUnit($amountPerUnit);
}
/**
@@ -169,9 +86,9 @@ public function getAmountDiscount(): float
/**
* @param float $amountDiscount
*
+ * @return BasketItem
* @deprecated since 1.1.5.0 @see $setAmountDiscountPerUnitGross.
*
- * @return BasketItem
*/
public function setAmountDiscount(float $amountDiscount): BasketItem
{
@@ -192,9 +109,9 @@ public function getAmountGross(): float
/**
* @param float $amountGross
*
+ * @return BasketItem
* @deprecated since 1.1.5.0 Property is redundant and is no longer needed.
*
- * @return BasketItem
*/
public function setAmountGross(float $amountGross): BasketItem
{
@@ -202,43 +119,6 @@ public function setAmountGross(float $amountGross): BasketItem
return $this;
}
- /**
- * @return float
- */
- public function getAmountDiscountPerUnitGross(): float
- {
- return $this->amountDiscountPerUnitGross;
- }
-
- /**
- * @param float $amountDiscountPerUnitGross
- *
- * @return BasketItem
- */
- public function setAmountDiscountPerUnitGross(float $amountDiscountPerUnitGross): BasketItem
- {
- $this->amountDiscountPerUnitGross = $amountDiscountPerUnitGross;
- return $this;
- }
-
- /**
- * @return float
- */
- public function getAmountPerUnitGross(): float
- {
- return $this->amountPerUnitGross;
- }
-
- /**
- * @param float $amountPerUnitGross
- *
- * @return BasketItem
- */
- public function setAmountPerUnitGross(float $amountPerUnitGross): BasketItem
- {
- $this->amountPerUnitGross = $amountPerUnitGross;
- return $this;
- }
/**
* @return float
@@ -253,9 +133,9 @@ public function getAmountVat(): float
/**
* @param float $amountVat
*
+ * @return BasketItem
* @deprecated since 1.1.5.0 Property is redundant and is no longer needed.
*
- * @return BasketItem
*/
public function setAmountVat(float $amountVat): BasketItem
{
@@ -276,9 +156,9 @@ public function getAmountPerUnit(): float
/**
* @param float $amountPerUnit
*
+ * @return BasketItem
* @deprecated since 1.1.5.0 @see setAmountPerUnitGross
*
- * @return BasketItem
*/
public function setAmountPerUnit(float $amountPerUnit): BasketItem
{
@@ -299,111 +179,13 @@ public function getAmountNet(): float
/**
* @param float $amountNet
*
+ * @return BasketItem
* @deprecated since 1.1.5.0 Property is redundant and is no longer needed.
*
- * @return BasketItem
*/
public function setAmountNet(float $amountNet): BasketItem
{
$this->amountNet = $amountNet;
return $this;
}
-
- /**
- * @return string|null
- */
- public function getUnit(): ?string
- {
- return $this->unit;
- }
-
- /**
- * @param string|null $unit
- *
- * @return BasketItem
- */
- public function setUnit(?string $unit): BasketItem
- {
- $this->unit = $unit;
- return $this;
- }
-
- /**
- * @return string
- */
- public function getTitle(): string
- {
- return $this->title;
- }
-
- /**
- * @param string $title
- *
- * @return BasketItem
- */
- public function setTitle(string $title): BasketItem
- {
- $this->title = $title;
- return $this;
- }
-
- /**
- * @return string|null
- */
- public function getImageUrl(): ?string
- {
- return $this->imageUrl;
- }
-
- /**
- * @param string|null $imageUrl
- *
- * @return BasketItem
- */
- public function setImageUrl(?string $imageUrl): BasketItem
- {
- $this->imageUrl = $imageUrl;
- return $this;
- }
-
- /**
- * @return string|null
- */
- public function getSubTitle(): ?string
- {
- return $this->subTitle;
- }
-
- /**
- * @param string|null $subTitle
- *
- * @return BasketItem
- */
- public function setSubTitle(?string $subTitle): BasketItem
- {
- $this->subTitle = $subTitle;
- return $this;
- }
-
- /**
- * @return string|null
- */
- public function getType(): ?string
- {
- return $this->type;
- }
-
- /**
- * The type of the basket item.
- * Please refer to UnzerSDK\Constants\BasketItemTypes for available type constants.
- *
- * @param string|null $type
- *
- * @return BasketItem
- */
- public function setType(?string $type): BasketItem
- {
- $this->type = $type;
- return $this;
- }
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php
index 647474d..31dfa91 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/GooglePay/SignedMessage.php
@@ -15,12 +15,7 @@ class SignedMessage extends AbstractUnzerResource
/** @var string */
protected $encryptedMessage;
- /**
- * @param string $tag
- * @param string $ephemeralPublicKey
- * @param string $encryptedMessage
- */
- public function __construct(string $tag = null, string $ephemeralPublicKey = null, string $encryptedMessage = null)
+ public function __construct(?string $tag = null, ?string $ephemeralPublicKey = null, ?string $encryptedMessage = null)
{
$this->tag = $tag;
$this->ephemeralPublicKey = $ephemeralPublicKey;
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodConfig.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodConfig.php
index e63914c..1f75a8d 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodConfig.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodConfig.php
@@ -3,6 +3,7 @@
namespace UnzerSDK\Resources\EmbeddedResources\Paypage;
use UnzerSDK\Resources\AbstractUnzerResource;
+use UnzerSDK\Resources\EmbeddedResources\WeroEventDependentPayment;
class PaymentMethodConfig extends AbstractUnzerResource
{
@@ -15,6 +16,19 @@ class PaymentMethodConfig extends AbstractUnzerResource
protected ?bool $credentialOnFile = null; // card only.
protected ?string $exemption = null; // card only.
+ protected ?WeroEventDependentPayment $eventDependentPayment = null;
+
+ public function getEventDependentPayment(): ?WeroEventDependentPayment
+ {
+ return $this->eventDependentPayment;
+ }
+
+ public function setEventDependentPayment(?WeroEventDependentPayment $eventDependentPayment): PaymentMethodConfig
+ {
+ $this->eventDependentPayment = $eventDependentPayment;
+ return $this;
+ }
+
/**
* @param bool|null $enabled
* @param int|null $order
@@ -80,4 +94,4 @@ public function setExemption(?string $exemption): PaymentMethodConfig
$this->exemption = $exemption;
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodsConfigs.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodsConfigs.php
index cb150f3..312e865 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodsConfigs.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/PaymentMethodsConfigs.php
@@ -11,6 +11,7 @@ class PaymentMethodsConfigs extends AbstractUnzerResource
const PAYPAGE_TYPE_NAME_MAPPING = [
'card' => 'cards',
'eps' => 'eps',
+ 'openbankingpis' => 'openbankingpis',
'payu' => 'payu',
'postfinanceefinance' => 'pfefinance',
'postfinancecard' => 'pfcard'
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Style.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Style.php
index 492a47d..1b27cff 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Style.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/Paypage/Style.php
@@ -20,6 +20,30 @@ class Style extends AbstractUnzerResource
protected ?string $logoImage = null;
protected ?string $linkColor = null;
protected ?string $textColor = null;
+ protected ?string $basketBackgroundColor = null;
+ protected ?string $paymentFormBackgroundColor = null;
+
+ public function getBasketBackgroundColor(): ?string
+ {
+ return $this->basketBackgroundColor;
+ }
+
+ public function setBasketBackgroundColor(?string $basketBackgroundColor): Style
+ {
+ $this->basketBackgroundColor = $basketBackgroundColor;
+ return $this;
+ }
+
+ public function getPaymentFormBackgroundColor(): ?string
+ {
+ return $this->paymentFormBackgroundColor;
+ }
+
+ public function setPaymentFormBackgroundColor(?string $paymentFormBackgroundColor): Style
+ {
+ $this->paymentFormBackgroundColor = $paymentFormBackgroundColor;
+ return $this;
+ }
public function getHideBasket(): ?bool
{
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroEventDependentPayment.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroEventDependentPayment.php
new file mode 100644
index 0000000..71e32eb
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroEventDependentPayment.php
@@ -0,0 +1,70 @@
+captureTrigger;
+ }
+
+ /**
+ * @see WeroCaptureTriggers for allowed values
+ */
+ public function setCaptureTrigger(?string $captureTrigger): WeroEventDependentPayment
+ {
+ $this->captureTrigger = $captureTrigger;
+ return $this;
+ }
+
+ public function getAmountPaymentType(): ?string
+ {
+ return $this->amountPaymentType;
+ }
+
+ /**
+ * @see WeroAmountPaymentTypes for allowed values
+ */
+ public function setAmountPaymentType(?string $amountPaymentType): WeroEventDependentPayment
+ {
+ $this->amountPaymentType = $amountPaymentType;
+ return $this;
+ }
+
+ public function getMaxAuthToCaptureTime(): ?int
+ {
+ return $this->maxAuthToCaptureTime;
+ }
+
+ public function setMaxAuthToCaptureTime(?int $maxAuthToCaptureTime): WeroEventDependentPayment
+ {
+ $this->maxAuthToCaptureTime = $maxAuthToCaptureTime;
+ return $this;
+ }
+
+ public function getMultiCapturesAllowed(): ?bool
+ {
+ return $this->multiCapturesAllowed;
+ }
+
+ public function setMultiCapturesAllowed(?bool $multiCapturesAllowed): WeroEventDependentPayment
+ {
+ $this->multiCapturesAllowed = $multiCapturesAllowed;
+ return $this;
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroTransactionData.php b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroTransactionData.php
new file mode 100644
index 0000000..e172e4e
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/EmbeddedResources/WeroTransactionData.php
@@ -0,0 +1,48 @@
+eventDependentPayment;
+ }
+
+ /**
+ * @param WeroEventDependentPayment|null $eventDependentPayment
+ * @return WeroTransactionData
+ */
+ public function setEventDependentPayment(?WeroEventDependentPayment $eventDependentPayment): WeroTransactionData
+ {
+ $this->eventDependentPayment = $eventDependentPayment;
+ return $this;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function handleResponse($response, string $method = HttpAdapterInterface::REQUEST_GET): void
+ {
+ parent::handleResponse($response, $method);
+ if ($response instanceof stdClass && isset($response->eventDependentPayment)) {
+ $edp = $this->getEventDependentPayment() ?? new WeroEventDependentPayment();
+ $edp->handleResponse($response->eventDependentPayment);
+ $this->setEventDependentPayment($edp);
+ }
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/InstalmentPlan.php b/vendor/unzerdev/php-sdk/src/Resources/InstalmentPlan.php
index bcdcf85..3c97695 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/InstalmentPlan.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/InstalmentPlan.php
@@ -3,10 +3,10 @@
namespace UnzerSDK\Resources;
use DateTime;
+use stdClass;
use UnzerSDK\Adapter\HttpAdapterInterface;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Traits\CanAuthorizeWithCustomer;
-use stdClass;
/**
* Resource representing the installment plan for Installment Secured.
@@ -77,17 +77,17 @@ class InstalmentPlan extends BasePaymentType
* @param float|null $lastRate
*/
public function __construct(
- int $numberOfRates = null,
- string $dayOfPurchase = null,
- float $totalPurchaseAmount = null,
- float $totalInterestAmount = null,
- float $totalAmount = null,
- float $effectiveInterestRate = null,
- float $nominalInterestRate = null,
- float $feeFirstRate = null,
- float $feePerRate = null,
- float $monthlyRate = null,
- float $lastRate = null
+ ?int $numberOfRates = null,
+ ?string $dayOfPurchase = null,
+ ?float $totalPurchaseAmount = null,
+ ?float $totalInterestAmount = null,
+ ?float $totalAmount = null,
+ ?float $effectiveInterestRate = null,
+ ?float $nominalInterestRate = null,
+ ?float $feeFirstRate = null,
+ ?float $feePerRate = null,
+ ?float $monthlyRate = null,
+ ?float $lastRate = null
) {
$this->numberOfRates = $numberOfRates;
$this->dayOfPurchase = $dayOfPurchase;
diff --git a/vendor/unzerdev/php-sdk/src/Resources/Payment.php b/vendor/unzerdev/php-sdk/src/Resources/Payment.php
index 20f956d..4a75656 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/Payment.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/Payment.php
@@ -829,11 +829,11 @@ public function getExternalId(): ?string
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function cancelAmount(
- float $amount = null,
+ ?float $amount = null,
?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL,
- string $paymentReference = null,
- float $amountNet = null,
- float $amountVat = null
+ ?string $paymentReference = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): array {
return $this->getUnzerObject()->cancelPayment($this, $amount, $reasonCode, $paymentReference, $amountNet, $amountVat);
}
@@ -850,7 +850,7 @@ public function cancelAmount(
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function cancelAuthorizationAmount(float $amount = null): ?Cancellation
+ public function cancelAuthorizationAmount(?float $amount = null): ?Cancellation
{
return $this->getUnzerObject()->cancelPaymentAuthorization($this, $amount);
}
@@ -865,7 +865,7 @@ public function cancelAuthorizationAmount(float $amount = null): ?Cancellation
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function charge(float $amount = null): Charge
+ public function charge(?float $amount = null): Charge
{
return $this->getUnzerObject()->chargePayment($this, $amount);
}
@@ -881,7 +881,7 @@ public function charge(float $amount = null): Charge
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function ship(string $invoiceId = null, string $orderId = null)
+ public function ship(?string $invoiceId = null, ?string $orderId = null)
{
return $this->getUnzerObject()->ship($this, $invoiceId, $orderId);
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Card.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Card.php
index 3a68888..3ada8c5 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Card.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Card.php
@@ -2,6 +2,8 @@
namespace UnzerSDK\Resources\PaymentTypes;
+use RuntimeException;
+use stdClass;
use UnzerSDK\Adapter\HttpAdapterInterface;
use UnzerSDK\Resources\EmbeddedResources\CardDetails;
use UnzerSDK\Traits\CanAuthorize;
@@ -9,8 +11,6 @@
use UnzerSDK\Traits\CanPayout;
use UnzerSDK\Traits\CanRecur;
use UnzerSDK\Validators\ExpiryDateValidator;
-use RuntimeException;
-use stdClass;
/**
* This represents the card payment type which supports credit card as well as debit card payments.
@@ -56,7 +56,7 @@ class Card extends BasePaymentType
* @param string|null $expiryDate
* @param string|null $email
*/
- public function __construct(?string $number, ?string $expiryDate, string $email = null)
+ public function __construct(?string $number, ?string $expiryDate, ?string $email = null)
{
$this->setNumber($number);
$this->setExpiryDate($expiryDate);
diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/InstallmentSecured.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/InstallmentSecured.php
index 1410d71..15a1dd0 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/InstallmentSecured.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/InstallmentSecured.php
@@ -34,7 +34,7 @@ class InstallmentSecured extends InstalmentPlan
* @param null|DateTime|string $invoiceDate
* @param null|DateTime|string $invoiceDueDate
*/
- public function __construct(InstalmentPlan $selectedPlan = null, $iban = null, $accountHolder = null, $orderDate = null, $bic = null, $invoiceDate = null, $invoiceDueDate = null)
+ public function __construct(?InstalmentPlan $selectedPlan = null, $iban = null, $accountHolder = null, $orderDate = null, $bic = null, $invoiceDate = null, $invoiceDueDate = null)
{
parent::__construct();
diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/OpenbankingPis.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/OpenbankingPis.php
index f8e07de..c7fa5af 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/OpenbankingPis.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/OpenbankingPis.php
@@ -9,7 +9,7 @@ class OpenbankingPis extends BasePaymentType
/** @var string|null $ibanCountry */
protected $ibanCountry;
- public function __construct(string $ibanCountry = null)
+ public function __construct(?string $ibanCountry = null)
{
$this->ibanCountry = $ibanCountry;
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/PaylaterDirectDebit.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/PaylaterDirectDebit.php
index fb7c3a1..8c89b59 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/PaylaterDirectDebit.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/PaylaterDirectDebit.php
@@ -12,7 +12,7 @@ class PaylaterDirectDebit extends BasePaymentType
/** @var string $holder */
protected $holder;
- public function __construct(string $iban = null, string $holder = null)
+ public function __construct(?string $iban = null, ?string $holder = null)
{
$this->iban = $iban;
$this->holder = $holder;
diff --git a/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Wero.php b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Wero.php
new file mode 100644
index 0000000..93a3f04
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/PaymentTypes/Wero.php
@@ -0,0 +1,7 @@
+handleRiskData($additionalTransactionData);
$this->handleShipping($additionalTransactionData);
$this->handleCardTransactionData($additionalTransactionData);
+ $this->handleWeroTransactionData($additionalTransactionData);
}
}
@@ -223,4 +225,21 @@ protected function handleCardTransactionData(stdClass $additionalTransactionData
$this->setCardTransactionData($cardTransactionData);
}
}
+
+ /**
+ * Handle WeroTransactionData object contained in additional transaction data from API response.
+ *
+ * @param stdClass $additionalTransactionData
+ *
+ * @return void
+ */
+ protected function handleWeroTransactionData(stdClass $additionalTransactionData): void
+ {
+ $wero = $additionalTransactionData->wero ?? null;
+ if ($wero !== null) {
+ $weroTransactionData = $this->getWeroTransactionData() ?? new WeroTransactionData();
+ $weroTransactionData->handleResponse($wero);
+ $this->setWeroTransactionData($weroTransactionData);
+ }
+ }
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php
index b37ac71..6936b8b 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Authorization.php
@@ -2,6 +2,7 @@
namespace UnzerSDK\Resources\TransactionTypes;
+use RuntimeException;
use UnzerSDK\Adapter\HttpAdapterInterface;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\Payment;
@@ -9,7 +10,6 @@
use UnzerSDK\Traits\HasCancellations;
use UnzerSDK\Traits\HasDescriptor;
use UnzerSDK\Traits\HasRecurrenceType;
-use RuntimeException;
/**
* This represents the authorization transaction.
@@ -55,7 +55,7 @@ class Authorization extends AbstractTransactionType
* @param string|null $currency
* @param string|null $returnUrl
*/
- public function __construct(float $amount = null, string $currency = null, string $returnUrl = null)
+ public function __construct(?float $amount = null, ?string $currency = null, ?string $returnUrl = null)
{
$this->setAmount($amount);
$this->setCurrency($currency);
@@ -250,7 +250,7 @@ protected function getResourcePath(string $httpMethod = HttpAdapterInterface::RE
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function cancel(float $amount = null): Cancellation
+ public function cancel(?float $amount = null): Cancellation
{
return $this->getUnzerObject()->cancelAuthorization($this, $amount);
}
@@ -265,7 +265,7 @@ public function cancel(float $amount = null): Cancellation
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function charge(float $amount = null): Charge
+ public function charge(?float $amount = null): Charge
{
$payment = $this->getPayment();
if (!$payment instanceof Payment) {
diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php
index 26d92e8..ad41d1c 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Cancellation.php
@@ -6,7 +6,6 @@
use UnzerSDK\Constants\CancelReasonCodes;
use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\PaymentTypes\InstallmentSecured;
-
use function in_array;
/**
@@ -49,7 +48,7 @@ class Cancellation extends AbstractTransactionType
*
* @param float|null $amount The amount to be cancelled, is transferred as grossAmount in case of Installment Secured.
*/
- public function __construct(float $amount = null)
+ public function __construct(?float $amount = null)
{
$this->setAmount($amount);
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php
index d7f1685..278cc9c 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Charge.php
@@ -2,6 +2,7 @@
namespace UnzerSDK\Resources\TransactionTypes;
+use RuntimeException;
use UnzerSDK\Adapter\HttpAdapterInterface;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Traits\HasAccountInformation;
@@ -9,7 +10,6 @@
use UnzerSDK\Traits\HasChargebacks;
use UnzerSDK\Traits\HasDescriptor;
use UnzerSDK\Traits\HasRecurrenceType;
-use RuntimeException;
/**
* This represents the charge transaction.
@@ -47,7 +47,7 @@ class Charge extends AbstractTransactionType
* @param string|null $currency
* @param string|null $returnUrl
*/
- public function __construct(float $amount = null, string $currency = null, string $returnUrl = null)
+ public function __construct(?float $amount = null, ?string $currency = null, ?string $returnUrl = null)
{
$this->setAmount($amount);
$this->setCurrency($currency);
@@ -199,11 +199,11 @@ protected function getResourcePath(string $httpMethod = HttpAdapterInterface::RE
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function cancel(
- float $amount = null,
- string $reasonCode = null,
- string $paymentReference = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $paymentReference = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation {
return $this->getUnzerObject()->cancelCharge(
$this,
diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php
index 7c0c592..2ef22d0 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Chargeback.php
@@ -24,7 +24,7 @@ class Chargeback extends AbstractTransactionType
/**
* @param float|null $amount The amount to be cancelled, is transferred as grossAmount in case of Installment Secured.
*/
- public function __construct(float $amount = null)
+ public function __construct(?float $amount = null)
{
$this->setAmount($amount);
}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php
index 39f6a93..15f0767 100644
--- a/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php
+++ b/vendor/unzerdev/php-sdk/src/Resources/TransactionTypes/Payout.php
@@ -24,14 +24,7 @@ class Payout extends AbstractTransactionType
/** @var string $paymentReference */
protected $paymentReference;
- /**
- * Payout constructor.
- *
- * @param float|null $amount
- * @param string|null $currency
- * @param null $returnUrl
- */
- public function __construct(float $amount = null, string $currency = null, $returnUrl = null)
+ public function __construct(?float $amount = null, ?string $currency = null, $returnUrl = null)
{
$this->setAmount($amount);
$this->setCurrency($currency);
diff --git a/vendor/unzerdev/php-sdk/src/Resources/V2/BasketItemProperties.php b/vendor/unzerdev/php-sdk/src/Resources/V2/BasketItemProperties.php
new file mode 100644
index 0000000..fb5dc95
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/V2/BasketItemProperties.php
@@ -0,0 +1,254 @@
+title = $title;
+ $this->quantity = $quantity;
+ $this->setAmountPerUnitGross($amountNet);
+ $this->setAmountPerUnit($amountPerUnit);
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getBasketItemReferenceId(): ?string
+ {
+ return $this->basketItemReferenceId;
+ }
+
+ /**
+ * @param string|null $basketItemReferenceId
+ *
+ * @return BasketItem
+ */
+ public function setBasketItemReferenceId(?string $basketItemReferenceId): BasketItem
+ {
+ $this->basketItemReferenceId = $basketItemReferenceId;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getQuantity(): int
+ {
+ return $this->quantity;
+ }
+
+ /**
+ * @param int $quantity
+ *
+ * @return BasketItem
+ */
+ public function setQuantity(int $quantity): self
+ {
+ $this->quantity = $quantity;
+ return $this;
+ }
+
+ /**
+ * @return float
+ */
+ public function getVat(): float
+ {
+ return $this->vat;
+ }
+
+ /**
+ * @param float $vat
+ *
+ * @return BasketItem
+ */
+ public function setVat(float $vat): BasketItem
+ {
+ $this->vat = $vat;
+ return $this;
+ }
+
+ /**
+ * @return float
+ */
+ public function getAmountDiscountPerUnitGross(): float
+ {
+ return $this->amountDiscountPerUnitGross;
+ }
+
+ /**
+ * @param float $amountDiscountPerUnitGross
+ *
+ * @return BasketItem
+ */
+ public function setAmountDiscountPerUnitGross(float $amountDiscountPerUnitGross): BasketItem
+ {
+ $this->amountDiscountPerUnitGross = $amountDiscountPerUnitGross;
+ return $this;
+ }
+
+ /**
+ * @return float
+ */
+ public function getAmountPerUnitGross(): float
+ {
+ return $this->amountPerUnitGross;
+ }
+
+ /**
+ * @param float $amountPerUnitGross
+ *
+ * @return BasketItem
+ */
+ public function setAmountPerUnitGross(float $amountPerUnitGross): BasketItem
+ {
+ $this->amountPerUnitGross = $amountPerUnitGross;
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getUnit(): ?string
+ {
+ return $this->unit;
+ }
+
+ /**
+ * @param string|null $unit
+ *
+ * @return BasketItem
+ */
+ public function setUnit(?string $unit): self
+ {
+ $this->unit = $unit;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle(): string
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ *
+ * @return BasketItem
+ */
+ public function setTitle(string $title): self
+ {
+ $this->title = $title;
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getImageUrl(): ?string
+ {
+ return $this->imageUrl;
+ }
+
+ /**
+ * @param string|null $imageUrl
+ *
+ * @return BasketItem
+ */
+ public function setImageUrl(?string $imageUrl): self
+ {
+ $this->imageUrl = $imageUrl;
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getSubTitle(): ?string
+ {
+ return $this->subTitle;
+ }
+
+ /**
+ * @param string|null $subTitle
+ *
+ * @return BasketItem
+ */
+ public function setSubTitle(?string $subTitle): self
+ {
+ $this->subTitle = $subTitle;
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getType(): ?string
+ {
+ return $this->type;
+ }
+
+ /**
+ * The type of the basket item.
+ * Please refer to UnzerSDK\Constants\BasketItemTypes for available type constants.
+ *
+ * @param string|null $type
+ *
+ * @return BasketItem
+ */
+ public function setType(?string $type): BasketItem
+ {
+ $this->type = $type;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/vendor/unzerdev/php-sdk/src/Resources/V2/BasketProperties.php b/vendor/unzerdev/php-sdk/src/Resources/V2/BasketProperties.php
new file mode 100644
index 0000000..d19c17a
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/V2/BasketProperties.php
@@ -0,0 +1,158 @@
+totalValueGross;
+ }
+
+ /**
+ * @param float $totalValueGross
+ *
+ * @return Basket
+ */
+ public function setTotalValueGross(float $totalValueGross): Basket
+ {
+ $this->totalValueGross = $totalValueGross;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCurrencyCode(): string
+ {
+ return $this->currencyCode;
+ }
+
+ /**
+ * @param string $currencyCode
+ *
+ * @return Basket
+ */
+ public function setCurrencyCode(string $currencyCode): Basket
+ {
+ $this->currencyCode = $currencyCode;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getItemCount(): int
+ {
+ return count($this->basketItems);
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getNote(): ?string
+ {
+ return $this->note;
+ }
+
+ /**
+ * @param string|null $note
+ *
+ * @return Basket
+ */
+ public function setNote(?string $note): Basket
+ {
+ $this->note = $note;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOrderId(): string
+ {
+ return $this->orderId;
+ }
+
+ /**
+ * @param string $orderId
+ *
+ * @return Basket
+ */
+ public function setOrderId(string $orderId): Basket
+ {
+ $this->orderId = $orderId;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getBasketItems(): array
+ {
+ return $this->basketItems;
+ }
+
+ /**
+ * @param array $basketItems
+ *
+ * @return Basket
+ */
+ public function setBasketItems(array $basketItems): Basket
+ {
+ $this->basketItems = [];
+
+ foreach ($basketItems as $basketItem) {
+ $this->addBasketItem($basketItem);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds the given BasketItem to the Basket.
+ *
+ * @param BasketItem $basketItem
+ *
+ * @return Basket
+ */
+ public function addBasketItem(BasketItem $basketItem): Basket
+ {
+ $this->basketItems[] = $basketItem;
+ if ($basketItem->getBasketItemReferenceId() === null) {
+ $basketItem->setBasketItemReferenceId((string)$this->getKeyOfLastBasketItemAdded());
+ }
+ return $this;
+ }
+
+ /**
+ * @param int $index
+ *
+ * @return BasketItem|null
+ */
+ public function getBasketItemByIndex(int $index): ?BasketItem
+ {
+ return $this->basketItems[$index] ?? null;
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/src/Resources/V2/Customer.php b/vendor/unzerdev/php-sdk/src/Resources/V2/Customer.php
new file mode 100644
index 0000000..528b1d7
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/src/Resources/V2/Customer.php
@@ -0,0 +1,31 @@
+orderId = $orderId;
+ $this->setTotalValueGross($totalValueGross);
+ $this->currencyCode = $currencyCode;
+ $this->setBasketItems($basketItems);
+ }
+
+ public function getApiVersion(): string
+ {
+ return ApiVersions::V3;
+ }
+
+ public function getApiConfig(): string
+ {
+ return PaymentApiConfigBearerAuth::class;
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/src/Services/CancelService.php b/vendor/unzerdev/php-sdk/src/Services/CancelService.php
index 354cb90..3710617 100644
--- a/vendor/unzerdev/php-sdk/src/Services/CancelService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/CancelService.php
@@ -12,7 +12,6 @@
use UnzerSDK\Resources\TransactionTypes\Cancellation;
use UnzerSDK\Resources\TransactionTypes\Charge;
use UnzerSDK\Unzer;
-
use function in_array;
use function is_string;
@@ -67,7 +66,7 @@ public function getResourceService(): ResourceService
/**
* {@inheritDoc}
*/
- public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation
+ public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation
{
$cancellation = new Cancellation($amount);
$cancellation->setPayment($authorization->getPayment())->setParentResource($authorization);
@@ -80,7 +79,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount
/**
* {@inheritDoc}
*/
- public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation
+ public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation
{
$authorization = $this->getResourceService()->fetchAuthorization($payment);
return $this->cancelAuthorization($authorization, $amount);
@@ -92,11 +91,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca
public function cancelChargeById(
$payment,
string $chargeId,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation {
$charge = $this->getResourceService()->fetchChargeById($payment, $chargeId);
return $this->cancelCharge($charge, $amount, $reasonCode, $referenceText, $amountNet, $amountVat);
@@ -107,11 +106,11 @@ public function cancelChargeById(
*/
public function cancelCharge(
Charge $charge,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation {
$cancellation = new Cancellation($amount);
$cancellation
@@ -131,11 +130,11 @@ public function cancelCharge(
*/
public function cancelPayment(
$payment,
- float $amount = null,
+ ?float $amount = null,
?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): array {
$paymentObject = $payment;
if (is_string($payment)) {
@@ -186,7 +185,7 @@ public function cancelPayment(
/**
* {@inheritDoc}
*/
- public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation
+ public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation
{
$cancellation = null;
$completeCancel = $amount === null;
diff --git a/vendor/unzerdev/php-sdk/src/Services/HttpService.php b/vendor/unzerdev/php-sdk/src/Services/HttpService.php
index e8b4866..cce644c 100644
--- a/vendor/unzerdev/php-sdk/src/Services/HttpService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/HttpService.php
@@ -18,7 +18,6 @@
* This service provides for functionalities concerning http transactions.
*
* @link https://docs.unzer.com/
- *
*/
class HttpService
{
@@ -82,32 +81,32 @@ public function setEnvironmentService(EnvironmentService $environmentService): H
}
/**
- * @deprecated use sendRequest() instead.
- *
* send post request to payment server
*
- * @param $uri string|null uri of the target system
- * @param ?AbstractUnzerResource $resource
- * @param string $httpMethod
- * @param string $apiVersion
+ * @param string|null $uri uri of the target system
+ * @param AbstractUnzerResource|null $resource
+ * @param string $httpMethod
+ * @param string|null $apiVersion
*
* @return string
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
+ * @deprecated use sendRequest() instead.
*/
public function send(
?string $uri = null,
?AbstractUnzerResource $resource = null,
string $httpMethod = HttpAdapterInterface::REQUEST_GET,
- string $apiVersion = Unzer::API_VERSION
- ): string {
+ ?string $apiVersion = null
+ ): string
+ {
if (!$resource instanceof AbstractUnzerResource) {
throw new RuntimeException('Transfer object is empty!');
}
$unzerObj = $resource->getUnzerObject();
- $apiRequest = (new ApiRequest($uri, $resource, $httpMethod, $unzerObj, $apiVersion));
+ $apiRequest = (new ApiRequest($uri, $resource, $httpMethod, $unzerObj, $apiVersion ?? $resource->getApiVersion()));
return $this->sendRequest($apiRequest);
}
@@ -115,15 +114,11 @@ public function send(
/**
* send post request to payment server
*
- * @param ApiRequest $request
- * @return string
- *
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
- public function sendRequest(
- ApiRequest $request
- ): string {
+ public function sendRequest(ApiRequest $request): string
+ {
$unzerObj = $request->getResource()->getUnzerObject();
$apiConfig = $request->getResource()->getApiConfig();
@@ -137,8 +132,8 @@ public function sendRequest(
$headers = $this->composeHttpHeaders($unzerObj, $apiConfig::getAuthorizationMethod());
$httpMethod = $request->getHttpMethod();
$this->initRequest($requestUrl, $payload, $httpMethod, $headers);
- $httpAdapter = $this->getAdapter();
- $response = $httpAdapter->execute();
+ $httpAdapter = $this->getAdapter();
+ $response = $httpAdapter->execute();
$responseCode = $httpAdapter->getResponseCode();
$httpAdapter->close();
@@ -158,7 +153,7 @@ public function sendRequest(
* @param string $uri
* @param string $payload
* @param string $httpMethod
- * @param array $httpHeaders
+ * @param array $httpHeaders
*
* @throws RuntimeException
*/
@@ -174,7 +169,7 @@ private function initRequest(string $uri, string $payload, string $httpMethod, a
* Handles error responses by throwing an UnzerApiException with the returned messages and error code.
* Returns doing nothing if no error occurred.
*
- * @param string $responseCode
+ * @param string $responseCode
* @param string|null $response
*
* @throws UnzerApiException
@@ -187,15 +182,15 @@ private function handleErrors(string $responseCode, ?string $response): void
$responseObject = json_decode($response, false);
if (!is_numeric($responseCode) || (int)$responseCode >= 400 || isset($responseObject->errors)) {
- $code = null;
- $errorId = null;
+ $code = null;
+ $errorId = null;
$customerMessage = $code;
$merchantMessage = $customerMessage;
if (isset($responseObject->errors[0])) {
- $errors = $responseObject->errors[0];
+ $errors = $responseObject->errors[0];
$merchantMessage = $errors->merchantMessage ?? '';
$customerMessage = $errors->customerMessage ?? '';
- $code = $errors->code ?? '';
+ $code = $errors->code ?? '';
}
if (isset($responseObject->id)) {
$errorId = $responseObject->id;
@@ -209,23 +204,24 @@ private function handleErrors(string $responseCode, ?string $response): void
}
/**
- * @param Unzer $unzerObj
- * @param string $payload
- * @param mixed $headers
- * @param string $responseCode
- * @param string $httpMethod
- * @param string $url
+ * @param Unzer $unzerObj
+ * @param string $payload
+ * @param mixed $headers
+ * @param string $responseCode
+ * @param string $httpMethod
+ * @param string $url
* @param string|null $response
*/
public function debugLog(
Unzer $unzerObj,
string $payload,
- $headers,
- string $responseCode,
+ $headers,
+ string $responseCode,
string $httpMethod,
string $url,
?string $response
- ): void {
+ ): void
+ {
// mask auth string
$authHeader = explode(' ', $headers['Authorization']);
$authHeader[1] = ValueService::maskValue($authHeader[1]);
@@ -275,16 +271,16 @@ private function buildRequestUrl(ApiRequest $request): string
*/
public function composeHttpHeaders(Unzer $unzer, string $authorizationMethod = AuthorizationMethods::BASIC): array
{
- $locale = $unzer->getLocale();
- $clientIp = $unzer->getClientIp();
- $key = $unzer->getKey();
+ $locale = $unzer->getLocale();
+ $clientIp = $unzer->getClientIp();
+ $key = $unzer->getKey();
$httpHeaders = [
'Authorization' => $this->findAuthentication($unzer, $authorizationMethod),
- 'Content-Type' => 'application/json',
- 'SDK-VERSION' => Unzer::SDK_VERSION,
- 'SDK-TYPE' => Unzer::SDK_TYPE,
- 'PHP-VERSION' => PHP_VERSION
+ 'Content-Type' => 'application/json',
+ 'SDK-VERSION' => Unzer::SDK_VERSION,
+ 'SDK-TYPE' => Unzer::SDK_TYPE,
+ 'PHP-VERSION' => PHP_VERSION
];
if (!empty($locale)) {
$httpHeaders['Accept-Language'] = $locale;
@@ -347,6 +343,7 @@ public function isApiConfig($className): bool
/**
* @param Unzer $unzer
+ *
* @return string
*/
private function findAuthentication(Unzer $unzer, string $authorizationMethod = AuthorizationMethods::BASIC): string
diff --git a/vendor/unzerdev/php-sdk/src/Services/IdService.php b/vendor/unzerdev/php-sdk/src/Services/IdService.php
index aecb23b..231ba17 100644
--- a/vendor/unzerdev/php-sdk/src/Services/IdService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/IdService.php
@@ -3,7 +3,6 @@
namespace UnzerSDK\Services;
use RuntimeException;
-
use function count;
/**
@@ -22,7 +21,7 @@ class IdService
*
* @param string $url
* @param string $idString
- * @param bool $onlyLast
+ * @param bool $onlyLast
*
* @return string
*
@@ -31,7 +30,7 @@ class IdService
public static function getResourceIdFromUrl(string $url, string $idString, bool $onlyLast = false): string
{
$matches = [];
- $pattern = '/\/([s|p]{1}-' . $idString . '-[a-z\d]+)\/?' . ($onlyLast ? '$' : '') . '/';
+ $pattern = '/\/([s|p]{1}-' . $idString . '-[a-z\d-]+)\/?' . ($onlyLast ? '$' : '') . '/';
preg_match($pattern, $url, $matches);
if (count($matches) < 2) {
@@ -76,7 +75,7 @@ public static function isPaymentChargeback(string $url): string
*
* @param string $url
* @param string $idString
- * @param bool $onlyLast
+ * @param bool $onlyLast
*
* @return string|null
*/
@@ -117,4 +116,10 @@ public static function getResourceTypeFromIdString(string $typeId): ?string
return $typeIdString;
}
+
+ public static function isUUIDResource(string $id): bool
+ {
+ preg_match('/^[sp]-([a-z]{3}|p24)-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/', $id, $matches);
+ return count($matches) > 0;
+ }
}
diff --git a/vendor/unzerdev/php-sdk/src/Services/JwtService.php b/vendor/unzerdev/php-sdk/src/Services/JwtService.php
index 57bdee9..2d12f96 100644
--- a/vendor/unzerdev/php-sdk/src/Services/JwtService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/JwtService.php
@@ -9,12 +9,11 @@ class JwtService
public static function validateExpiryTime(string $jwt, int $expiryBufferSeconds = self::Expiry_Buffer): bool
{
$jwtData = self::extractPayload($jwt);
- $expireTime = $jwtData['exp'];
- $currentTime = time();
- return ($expireTime - $expiryBufferSeconds) > $currentTime;
+ $expireTime = $jwtData['exp'] ?? 0;
+ return ($expireTime - $expiryBufferSeconds) > time();
}
- private static function extractPayload(string $jwt)
+ private static function extractPayload(string $jwt): ?array
{
$tokenSegments = explode('.', $jwt);
return json_decode(base64_decode($tokenSegments[1]), true);
diff --git a/vendor/unzerdev/php-sdk/src/Services/PaymentService.php b/vendor/unzerdev/php-sdk/src/Services/PaymentService.php
index c59cd81..8eefc35 100644
--- a/vendor/unzerdev/php-sdk/src/Services/PaymentService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/PaymentService.php
@@ -73,12 +73,15 @@ public function getResourceService(): ResourceService
return $this->getUnzer()->getResourceService();
}
+ /**
+ * {@inheritDoc}
+ */
public function performAuthorization(
Authorization $authorization,
$paymentType,
$customer = null,
- Metadata $metadata = null,
- Basket $basket = null
+ ?Metadata $metadata = null,
+ ?Basket $basket = null
): Authorization {
$payment = $this->createPayment($paymentType);
$paymentType = $payment->getPaymentType();
@@ -144,7 +147,7 @@ public function authorize(
/**
* {@inheritDoc}
*/
- public function performCharge(Charge $charge, $paymentType, $customer = null, Metadata $metadata = null, Basket $basket = null): Charge
+ public function performCharge(Charge $charge, $paymentType, $customer = null, ?Metadata $metadata = null, ?Basket $basket = null): Charge
{
$payment = $this->createPayment($paymentType);
$paymentType = $payment->getPaymentType();
@@ -214,9 +217,9 @@ public function charge(
*/
public function chargeAuthorization(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge {
return $this->chargePayment($payment, $amount, $orderId, $invoiceId);
}
@@ -226,9 +229,9 @@ public function chargeAuthorization(
*/
public function chargePayment(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge {
$charge = new Charge($amount);
@@ -263,11 +266,11 @@ public function payout(
$paymentType,
string $returnUrl,
$customer = null,
- string $orderId = null,
- Metadata $metadata = null,
- Basket $basket = null,
- string $invoiceId = null,
- string $referenceText = null
+ ?string $orderId = null,
+ ?Metadata $metadata = null,
+ ?Basket $basket = null,
+ ?string $invoiceId = null,
+ ?string $referenceText = null
): Payout {
$payment = $this->createPayment($paymentType);
$payout = (new Payout($amount, $currency, $returnUrl))
@@ -283,7 +286,7 @@ public function payout(
/**
* {@inheritDoc}
*/
- public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment
+ public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment
{
$shipment = new Shipment();
$shipment->setInvoiceId($invoiceId)->setOrderId($orderId);
@@ -297,9 +300,9 @@ public function ship($payment, string $invoiceId = null, string $orderId = null)
*/
public function initPayPageCharge(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage {
return $this->initPayPage($paypage, TransactionTypes::CHARGE, $customer, $basket, $metadata);
}
@@ -309,9 +312,9 @@ public function initPayPageCharge(
*/
public function initPayPageAuthorize(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage {
return $this->initPayPage($paypage, TransactionTypes::AUTHORIZATION, $customer, $basket, $metadata);
}
@@ -323,7 +326,7 @@ public function fetchInstallmentPlans(
float $amount,
string $currency,
float $effectiveInterest,
- DateTime $orderDate = null
+ ?DateTime $orderDate = null
): InstalmentPlans {
$ins = (new InstallmentSecured(null, null, null))->setParentResource($this->unzer);
$plans = (new InstalmentPlans($amount, $currency, $effectiveInterest, $orderDate))->setParentResource($ins);
@@ -365,9 +368,9 @@ public function fetchPaylaterInstallmentPlans(
private function initPayPage(
Paypage $paypage,
string $action,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage {
$paypage->setAction($action)->setParentResource($this->unzer);
$payment = $this->createPayment($paypage)->setBasket($basket)->setCustomer($customer)->setMetadata($metadata)->setPayPage($paypage);
diff --git a/vendor/unzerdev/php-sdk/src/Services/ResourceService.php b/vendor/unzerdev/php-sdk/src/Services/ResourceService.php
index 6de8c08..b4bedfe 100644
--- a/vendor/unzerdev/php-sdk/src/Services/ResourceService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/ResourceService.php
@@ -9,6 +9,7 @@
use UnzerSDK\Adapter\HttpAdapterInterface;
use UnzerSDK\Apis\Constants\AuthorizationMethods;
use UnzerSDK\Constants\ApiResponseCodes;
+use UnzerSDK\Constants\ApiVersions;
use UnzerSDK\Constants\IdStrings;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Interfaces\ResourceServiceInterface;
@@ -51,6 +52,7 @@
use UnzerSDK\Resources\PaymentTypes\Sofort;
use UnzerSDK\Resources\PaymentTypes\Twint;
use UnzerSDK\Resources\PaymentTypes\Wechatpay;
+use UnzerSDK\Resources\PaymentTypes\Wero;
use UnzerSDK\Resources\Recurring;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Cancellation;
@@ -58,7 +60,9 @@
use UnzerSDK\Resources\TransactionTypes\Chargeback;
use UnzerSDK\Resources\TransactionTypes\Payout;
use UnzerSDK\Resources\TransactionTypes\Shipment;
+use UnzerSDK\Resources\V2\Customer as CustomerV2;
use UnzerSDK\Resources\V2\Paypage as PaypageV2;
+use UnzerSDK\Resources\V3\Basket as BasketV3;
use UnzerSDK\Traits\CanRecur;
use UnzerSDK\Unzer;
use function in_array;
@@ -106,8 +110,8 @@ public function setUnzer(Unzer $unzer): ResourceServiceInterface
* Send request to API.
*
* @param AbstractUnzerResource $resource
- * @param string $httpMethod
- * @param string $apiVersion
+ * @param string $httpMethod
+ * @param string|null $apiVersion
*
* @return stdClass
*
@@ -117,15 +121,16 @@ public function setUnzer(Unzer $unzer): ResourceServiceInterface
public function send(
AbstractUnzerResource $resource,
string $httpMethod = HttpAdapterInterface::REQUEST_GET,
- string $apiVersion = Unzer::API_VERSION
- ): stdClass {
- $configClass = $resource->getApiConfig();
- if (!$resource instanceof Token && $configClass::getAuthorizationMethod() === AuthorizationMethods::BEARER) {
+ ?string $apiVersion = null
+ ): stdClass
+ {
+ $apiConfig = $resource->getApiConfig();
+ if (!$resource instanceof Token && $apiConfig::getAuthorizationMethod() === AuthorizationMethods::BEARER) {
$this->unzer->prepareJwtToken();
}
- $appendId = $httpMethod !== HttpAdapterInterface::REQUEST_POST;
- $uri = $resource->getUri($appendId, $httpMethod);
+ $appendId = $httpMethod !== HttpAdapterInterface::REQUEST_POST;
+ $uri = $resource->getUri($appendId, $httpMethod);
$responseJson = $resource->getUnzerObject()->getHttpService()->send($uri, $resource, $httpMethod, $apiVersion);
return !empty($responseJson) ? json_decode($responseJson, false) : new stdClass();
}
@@ -159,9 +164,9 @@ public function getResource(AbstractUnzerResource $resource): AbstractUnzerResou
public function fetchResourceByUrl($url)
{
$resource = null;
- $unzer = $this->unzer;
+ $unzer = $this->unzer;
- $resourceId = IdService::getLastResourceIdFromUrlString($url);
+ $resourceId = IdService::getLastResourceIdFromUrlString($url);
if (empty($resourceId)) {
return null;
}
@@ -187,8 +192,8 @@ public function fetchResourceByUrl($url)
);
break;
case $resourceType === IdStrings::CANCEL:
- $paymentId = IdService::getResourceIdFromUrl($url, IdStrings::PAYMENT);
- $chargeId = IdService::getResourceIdOrNullFromUrl($url, IdStrings::CHARGE);
+ $paymentId = IdService::getResourceIdFromUrl($url, IdStrings::PAYMENT);
+ $chargeId = IdService::getResourceIdOrNullFromUrl($url, IdStrings::CHARGE);
if (IdService::isPaymentCancellation($url)) {
$isRefund = preg_match('/charge/', $url) === 1;
if ($isRefund) {
@@ -333,8 +338,8 @@ public function deleteResource(AbstractUnzerResource &$resource): ?AbstractUnzer
/**
* Updates the given local resource object (id must be set)
*
- * @param AbstractUnzerResource $resource The local resource object to update.
- * @param string $apiVersion
+ * @param AbstractUnzerResource $resource The local resource object to update.
+ * @param string|null $apiVersion
*
* @return AbstractUnzerResource The updated resource object.
*
@@ -342,7 +347,7 @@ public function deleteResource(AbstractUnzerResource &$resource): ?AbstractUnzer
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
* @throws Exception
*/
- public function fetchResource(AbstractUnzerResource $resource, string $apiVersion = Unzer::API_VERSION): AbstractUnzerResource
+ public function fetchResource(AbstractUnzerResource $resource, ?string $apiVersion = null): AbstractUnzerResource
{
$method = HttpAdapterInterface::REQUEST_GET;
$response = $this->send($resource, $method, $apiVersion);
@@ -375,7 +380,7 @@ public function fetchPayout($payment): Payout
/**
* {@inheritDoc}
*/
- public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring
+ public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring
{
$paymentTypeObject = $paymentType;
if (is_string($paymentType)) {
@@ -549,15 +554,20 @@ public function createBasket(Basket $basket): Basket
public function fetchBasket($basket): Basket
{
$basketObj = $basket;
+
if (is_string($basket)) {
- $basketObj = (new Basket())->setId($basket);
+ $isV3Basket = IdService::isUUIDResource($basket);
+ $basketObj = $isV3Basket ? new BasketV3() : new Basket();
+ $basketObj->setId($basket);
}
+
$basketObj->setParentResource($this->unzer);
+ $basketVersion = $basketObj->getApiVersion() === ApiVersions::V3 ? ApiVersions::V3 : ApiVersions::V2;
try {
- $this->fetchResource($basketObj, 'v2');
+ $this->fetchResource($basketObj, $basketVersion);
} catch (UnzerApiException $exception) {
- if ($exception->getCode() !== ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND) {
+ if ($exception->getCode() !== ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND || $basketVersion === ApiVersions::V3) {
throw $exception;
}
$this->fetchResource($basketObj);
@@ -648,7 +658,9 @@ public function fetchCustomer($customer): Customer
$customerObject = $customer;
if (is_string($customer)) {
- $customerObject = (new Customer())->setId($customer);
+ $isUUID = IdService::isUUIDResource($customer);
+ $customerObject = $isUUID ? new CustomerV2() : new Customer();
+ $customerObject->setId($customer);
}
$this->fetchResource($customerObject->setParentResource($this->unzer));
@@ -658,7 +670,7 @@ public function fetchCustomer($customer): Customer
/**
* {@inheritDoc}
*/
- public function fetchCustomerByExtCustomerId(string $customerId): Customer
+ public function fetchCustomerByExtCustomerId(string $customerId, int $version = 1): Customer
{
$customerObject = (new Customer())->setCustomerId($customerId);
$this->fetchResource($customerObject->setParentResource($this->unzer));
@@ -946,6 +958,9 @@ public static function getTypeInstanceFromIdString($typeId): BasePaymentType
case IdStrings::WECHATPAY:
$paymentType = new Wechatpay();
break;
+ case IdStrings::WERO:
+ $paymentType = new Wero();
+ break;
case IdStrings::OPEN_BANKING:
$paymentType = new OpenbankingPis();
break;
diff --git a/vendor/unzerdev/php-sdk/src/Services/WebhookService.php b/vendor/unzerdev/php-sdk/src/Services/WebhookService.php
index c8117d1..a273bb5 100644
--- a/vendor/unzerdev/php-sdk/src/Services/WebhookService.php
+++ b/vendor/unzerdev/php-sdk/src/Services/WebhookService.php
@@ -2,14 +2,13 @@
namespace UnzerSDK\Services;
-use UnzerSDK\Unzer;
+use RuntimeException;
use UnzerSDK\Interfaces\ResourceServiceInterface;
use UnzerSDK\Interfaces\WebhookServiceInterface;
use UnzerSDK\Resources\AbstractUnzerResource;
use UnzerSDK\Resources\Webhook;
use UnzerSDK\Resources\Webhooks;
-use RuntimeException;
-
+use UnzerSDK\Unzer;
use function is_string;
/**
@@ -165,7 +164,7 @@ public function registerMultipleWebhooks(string $url, array $events): array
/**
* {@inheritDoc}
*/
- public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource
+ public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource
{
$resourceObject = null;
$eventData = json_decode($eventJson ?? $this->readInputStream(), false);
diff --git a/vendor/unzerdev/php-sdk/src/Traits/CanPayout.php b/vendor/unzerdev/php-sdk/src/Traits/CanPayout.php
index 4458e68..f03042d 100644
--- a/vendor/unzerdev/php-sdk/src/Traits/CanPayout.php
+++ b/vendor/unzerdev/php-sdk/src/Traits/CanPayout.php
@@ -8,13 +8,13 @@
namespace UnzerSDK\Traits;
+use RuntimeException;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Interfaces\UnzerParentInterface;
use UnzerSDK\Resources\Basket;
use UnzerSDK\Resources\Customer;
use UnzerSDK\Resources\Metadata;
use UnzerSDK\Resources\TransactionTypes\Payout;
-use RuntimeException;
trait CanPayout
{
@@ -44,11 +44,11 @@ public function payout(
string $currency,
string $returnUrl,
$customer = null,
- string $orderId = null,
+ ?string $orderId = null,
$metadata = null,
- Basket $basket = null,
- string $invoiceId = null,
- string $paymentReference = null
+ ?Basket $basket = null,
+ ?string $invoiceId = null,
+ ?string $paymentReference = null
): Payout {
if ($this instanceof UnzerParentInterface) {
return $this->getUnzerObject()->payout(
diff --git a/vendor/unzerdev/php-sdk/src/Traits/CanPayoutWithCustomer.php b/vendor/unzerdev/php-sdk/src/Traits/CanPayoutWithCustomer.php
index 389a4bf..76c5673 100644
--- a/vendor/unzerdev/php-sdk/src/Traits/CanPayoutWithCustomer.php
+++ b/vendor/unzerdev/php-sdk/src/Traits/CanPayoutWithCustomer.php
@@ -8,13 +8,13 @@
namespace UnzerSDK\Traits;
+use RuntimeException;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Interfaces\UnzerParentInterface;
use UnzerSDK\Resources\Basket;
use UnzerSDK\Resources\Customer;
use UnzerSDK\Resources\Metadata;
use UnzerSDK\Resources\TransactionTypes\Payout;
-use RuntimeException;
trait CanPayoutWithCustomer
{
@@ -42,9 +42,9 @@ public function payout(
string $currency,
string $returnUrl,
$customer,
- string $orderId = null,
+ ?string $orderId = null,
$metadata = null,
- Basket $basket = null
+ ?Basket $basket = null
): Payout {
if ($this instanceof UnzerParentInterface) {
return $this->getUnzerObject()->payout(
diff --git a/vendor/unzerdev/php-sdk/src/Traits/HasAdditionalTransactionData.php b/vendor/unzerdev/php-sdk/src/Traits/HasAdditionalTransactionData.php
index 3dcd4b2..ff8ced7 100644
--- a/vendor/unzerdev/php-sdk/src/Traits/HasAdditionalTransactionData.php
+++ b/vendor/unzerdev/php-sdk/src/Traits/HasAdditionalTransactionData.php
@@ -14,6 +14,7 @@
use UnzerSDK\Resources\EmbeddedResources\CardTransactionData;
use UnzerSDK\Resources\EmbeddedResources\RiskData;
use UnzerSDK\Resources\EmbeddedResources\ShippingData;
+use UnzerSDK\Resources\EmbeddedResources\WeroTransactionData;
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Services\ResourceService;
@@ -221,4 +222,29 @@ public function setCardTransactionData(?CardTransactionData $cardTransactionData
$this->addAdditionalTransactionData(AdditionalTransactionDataKeys::CARD, $cardTransactionData);
return $this;
}
+
+ /**
+ * Get the wero field from additional transaction Data.
+ *
+ * @return WeroTransactionData|null "wero" object of additionalTransaction data.
+ */
+ public function getWeroTransactionData(): ?WeroTransactionData
+ {
+ $key = AdditionalTransactionDataKeys::WERO;
+ $wero = $this->getAdditionalTransactionData()->$key ?? null;
+ return $wero instanceof WeroTransactionData ? $wero : null;
+ }
+
+ /**
+ * Sets WeroTransactionData object as "wero" field of additionalTransactionData.
+ *
+ * @param WeroTransactionData|null $weroTransactionData
+ *
+ * @return self
+ */
+ public function setWeroTransactionData(?WeroTransactionData $weroTransactionData): self
+ {
+ $this->addAdditionalTransactionData(AdditionalTransactionDataKeys::WERO, $weroTransactionData);
+ return $this;
+ }
}
diff --git a/vendor/unzerdev/php-sdk/src/Unzer.php b/vendor/unzerdev/php-sdk/src/Unzer.php
index 733b7e3..b4dc186 100644
--- a/vendor/unzerdev/php-sdk/src/Unzer.php
+++ b/vendor/unzerdev/php-sdk/src/Unzer.php
@@ -5,6 +5,7 @@
use DateTime;
use RuntimeException;
use UnzerSDK\Adapter\HttpAdapterInterface;
+use UnzerSDK\Constants\ApiVersions;
use UnzerSDK\Constants\CancelReasonCodes;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Interfaces\CancelServiceInterface;
@@ -55,9 +56,9 @@ class Unzer implements
CancelServiceInterface
{
public const BASE_URL = 'api.unzer.com';
- public const API_VERSION = 'v1';
+ public const API_VERSION = ApiVersions::V1;
public const SDK_TYPE = 'UnzerPHP';
- public const SDK_VERSION = '3.11.0';
+ public const SDK_VERSION = '3.13.1';
/** @var string $key */
private $key;
@@ -94,7 +95,7 @@ class Unzer implements
* Construct a new Unzer object.
*
* @param string $key The private key your received from your Unzer contact person.
- * @param ?string $locale The locale of the customer defining defining the translation (e.g. 'en-GB' or 'de-DE').
+ * @param string|null $locale The locale of the customer defining defining the translation (e.g. 'en-GB' or 'de-DE').
*
* @throws RuntimeException A RuntimeException will be thrown if the key is not of type private.
*
@@ -357,7 +358,7 @@ public function getUri(bool $appendId = true, string $httpMethod = HttpAdapterIn
/**
* {@inheritDoc}
*/
- public function activateRecurringPayment($paymentType, string $returnUrl, string $recurrenceType = null): Recurring
+ public function activateRecurringPayment($paymentType, string $returnUrl, ?string $recurrenceType = null): Recurring
{
return $this->resourceService->activateRecurringPayment($paymentType, $returnUrl, $recurrenceType);
}
@@ -485,9 +486,9 @@ public function fetchCustomer($customer): Customer
/**
* {@inheritDoc}
*/
- public function fetchCustomerByExtCustomerId(string $customerId): Customer
+ public function fetchCustomerByExtCustomerId(string $customerId, int $version = 1): Customer
{
- return $this->resourceService->fetchCustomerByExtCustomerId($customerId);
+ return $this->resourceService->fetchCustomerByExtCustomerId($customerId, $version);
}
/**
@@ -666,7 +667,7 @@ public function registerMultipleWebhooks(string $url, array $events): array
/**
* {@inheritDoc}
*/
- public function fetchResourceFromEvent(string $eventJson = null): AbstractUnzerResource
+ public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource
{
return $this->webhookService->fetchResourceFromEvent($eventJson);
}
@@ -678,8 +679,8 @@ public function performAuthorization(
Authorization $authorization,
$paymentType,
$customer = null,
- Metadata $metadata = null,
- Basket $basket = null
+ ?Metadata $metadata = null,
+ ?Basket $basket = null
): Authorization
{
return $this->paymentService->performAuthorization($authorization, $paymentType, $customer, $metadata, $basket);
@@ -734,8 +735,8 @@ public function performCharge(
Charge $charge,
$paymentType,
$customer = null,
- Metadata $metadata = null,
- Basket $basket = null
+ ?Metadata $metadata = null,
+ ?Basket $basket = null
): Charge
{
return $this->paymentService->performCharge($charge, $paymentType, $customer, $metadata, $basket);
@@ -785,9 +786,9 @@ public function charge(
*/
public function chargeAuthorization(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge
{
return $this->paymentService->chargeAuthorization($payment, $amount, $orderId, $invoiceId);
@@ -798,9 +799,9 @@ public function chargeAuthorization(
*/
public function chargePayment(
$payment,
- float $amount = null,
- string $orderId = null,
- string $invoiceId = null
+ ?float $amount = null,
+ ?string $orderId = null,
+ ?string $invoiceId = null
): Charge
{
return $this->paymentService->chargePayment($payment, $amount, $orderId, $invoiceId);
@@ -814,7 +815,7 @@ public function performChargeOnPayment($payment, Charge $charge): Charge
/**
* {@inheritDoc}
*/
- public function cancelAuthorization(Authorization $authorization, float $amount = null): Cancellation
+ public function cancelAuthorization(Authorization $authorization, ?float $amount = null): Cancellation
{
return $this->cancelService->cancelAuthorization($authorization, $amount);
}
@@ -822,7 +823,7 @@ public function cancelAuthorization(Authorization $authorization, float $amount
/**
* {@inheritDoc}
*/
- public function cancelAuthorizationByPayment($payment, float $amount = null): Cancellation
+ public function cancelAuthorizationByPayment($payment, ?float $amount = null): Cancellation
{
return $this->cancelService->cancelAuthorizationByPayment($payment, $amount);
}
@@ -832,11 +833,11 @@ public function cancelAuthorizationByPayment($payment, float $amount = null): Ca
*/
public function cancelPayment(
$payment,
- float $amount = null,
+ ?float $amount = null,
?string $reasonCode = CancelReasonCodes::REASON_CODE_CANCEL,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): array
{
return $this->cancelService
@@ -846,7 +847,7 @@ public function cancelPayment(
/**
* {@inheritDoc}
*/
- public function cancelPaymentAuthorization($payment, float $amount = null): ?Cancellation
+ public function cancelPaymentAuthorization($payment, ?float $amount = null): ?Cancellation
{
return $this->cancelService->cancelPaymentAuthorization($payment, $amount);
}
@@ -857,11 +858,11 @@ public function cancelPaymentAuthorization($payment, float $amount = null): ?Can
public function cancelChargeById(
$payment,
string $chargeId,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation
{
return $this->cancelService
@@ -873,11 +874,11 @@ public function cancelChargeById(
*/
public function cancelCharge(
Charge $charge,
- float $amount = null,
- string $reasonCode = null,
- string $referenceText = null,
- float $amountNet = null,
- float $amountVat = null
+ ?float $amount = null,
+ ?string $reasonCode = null,
+ ?string $referenceText = null,
+ ?float $amountNet = null,
+ ?float $amountVat = null
): Cancellation
{
return $this->cancelService
@@ -916,7 +917,7 @@ public function createAuthToken(): Token
/**
* {@inheritDoc}
*/
- public function ship($payment, string $invoiceId = null, string $orderId = null): Shipment
+ public function ship($payment, ?string $invoiceId = null, ?string $orderId = null): Shipment
{
return $this->paymentService->ship($payment, $invoiceId, $orderId);
}
@@ -930,11 +931,11 @@ public function payout(
$paymentType,
string $returnUrl,
$customer = null,
- string $orderId = null,
- Metadata $metadata = null,
- Basket $basket = null,
- string $invoiceId = null,
- string $referenceText = null
+ ?string $orderId = null,
+ ?Metadata $metadata = null,
+ ?Basket $basket = null,
+ ?string $invoiceId = null,
+ ?string $referenceText = null
): Payout
{
return $this->paymentService->payout(
@@ -1003,9 +1004,9 @@ public function fetchPaypageV2($paypage): PaypageV2
*/
public function initPayPageCharge(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage
{
return $this->paymentService->initPayPageCharge($paypage, $customer, $basket, $metadata);
@@ -1016,9 +1017,9 @@ public function initPayPageCharge(
*/
public function initPayPageAuthorize(
Paypage $paypage,
- Customer $customer = null,
- Basket $basket = null,
- Metadata $metadata = null
+ ?Customer $customer = null,
+ ?Basket $basket = null,
+ ?Metadata $metadata = null
): Paypage
{
return $this->paymentService->initPayPageAuthorize($paypage, $customer, $basket, $metadata);
@@ -1031,7 +1032,7 @@ public function fetchInstallmentPlans(
float $amount,
string $currency,
float $effectiveInterest,
- DateTime $orderDate = null
+ ?DateTime $orderDate = null
): InstalmentPlans
{
return $this->paymentService
@@ -1070,16 +1071,24 @@ public function debugLog($message): void
/**
* Request a JWT token from the Token Service and stores it for following request.
- * If the token is already set, it will not be requested again.
+ * Manual call of this method should only be necessary if already existing Token needs to be provided.
+ * If an active token is already set, it will not be requested again.
+ * Token will automaically be renewed if it is expired.
*
+ * @param string|null $jwtToken If set, the given token will be used instead as long it is valid.
* @throws UnzerApiException
*/
- public function prepareJwtToken()
+ public function prepareJwtToken(?string $jwtToken = null): string
{
+ if ($jwtToken !== null && JwtService::validateExpiryTime($jwtToken)) {
+ $this->jwtToken = $jwtToken;
+ }
+
if ($this->jwtToken !== null && JwtService::validateExpiryTime($this->jwtToken)) {
- return;
+ return $this->getJwtToken();
}
$this->jwtToken = $this->createAuthToken()->getAccessToken();
+ return $this->jwtToken;
}
public function getJwtToken()
diff --git a/vendor/unzerdev/php-sdk/test/BasePaymentTest.php b/vendor/unzerdev/php-sdk/test/BasePaymentTest.php
index 54da6b6..c96bd0d 100644
--- a/vendor/unzerdev/php-sdk/test/BasePaymentTest.php
+++ b/vendor/unzerdev/php-sdk/test/BasePaymentTest.php
@@ -25,6 +25,7 @@
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Charge;
+use UnzerSDK\Resources\V3\Basket as BasketV3;
use UnzerSDK\test\Fixtures\CustomerFixtureTrait;
use UnzerSDK\Unzer;
@@ -33,6 +34,7 @@ class BasePaymentTest extends TestCase
use CustomerFixtureTrait;
protected const RETURN_URL = 'https://dev.unzer.com';
public const API_VERSION_2 = 'v2';
+ public const API_VERSION_3 = 'v3';
/** @var Unzer $unzer */
protected $unzer;
@@ -206,6 +208,28 @@ public function createV2Basket(): Basket
return $basket;
}
+ /**
+ * Creates a v2 Basket resource and returns it.
+ *
+ * @return Basket
+ */
+ public function createV3Basket(): Basket
+ {
+ $orderId = 'b' . self::generateRandomId();
+ $basket = new BasketV3($orderId);
+ $basket->setTotalValueGross(99.99)
+ ->setCurrencyCode('EUR');
+
+ $basketItem = (new BasketItem())
+ ->setAmountPerUnitGross(99.99)
+ ->setQuantity(1)
+ ->setBasketItemReferenceId('item1')
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+ $this->unzer->createBasket($basket);
+ return $basket;
+ }
+
/**
* Creates a Card object for tests.
*
@@ -268,7 +292,7 @@ public function createCharge($amount = 100.0): Charge
*/
public static function generateRandomId(): string
{
- return str_replace('.', '', microtime(true));
+ return str_replace('.', '', microtime(true)) . random_int(1000, 9999);
}
/**
diff --git a/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/PaylaterInstallmentTest.php b/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/PaylaterInstallmentTest.php
index 3770a9a..bb98d74 100644
--- a/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/PaylaterInstallmentTest.php
+++ b/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/PaylaterInstallmentTest.php
@@ -13,18 +13,18 @@
namespace UnzerSDK\test\integration\PaymentTypes;
use UnzerSDK\Constants\CustomerTypes;
+use UnzerSDK\Constants\ShippingTypes;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\Customer;
use UnzerSDK\Resources\CustomerFactory;
use UnzerSDK\Resources\EmbeddedResources\Address;
-use UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlansQuery;
use UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlan;
+use UnzerSDK\Resources\EmbeddedResources\Paylater\InstallmentPlansQuery;
use UnzerSDK\Resources\PaymentTypes\PaylaterInstallment;
use UnzerSDK\Resources\TransactionTypes\Authorization;
use UnzerSDK\Resources\TransactionTypes\Cancellation;
use UnzerSDK\Resources\TransactionTypes\Charge;
use UnzerSDK\test\BaseIntegrationTest;
-
use function count;
class PaylaterInstallmentTest extends BaseIntegrationTest
@@ -232,7 +232,7 @@ protected function createAuthorizeTransaction(): Authorization
$ins = new PaylaterInstallment($plans->getId(), $selectedPlan->getNumberOfRates(), 'DE89370400440532013000', 'DE', 'Peter Mustermann');
$this->unzer->createPaymentType($ins);
- $customer = $this->getCustomer()->setFirstname('Peter')->setLastname('Mustermann');
+ $customer = $this->getCustomer();
$basket = $this->createBasket();
$authorization = new Authorization(99.99, 'EUR', self::RETURN_URL);
@@ -244,17 +244,22 @@ protected function createAuthorizeTransaction(): Authorization
*/
public function getCustomer(): Customer
{
- $customer = CustomerFactory::createCustomer('Manuel', 'Weißmann');
+ $customer = CustomerFactory::createCustomer('Maximilian', 'Mustermann');
$address = (new Address())
- ->setStreet('Hugo-Junckers-Straße 3')
+ ->setName('Maximilian Mustermann')
+ ->setStreet('Hugo-Junkers-Str. 3')
->setState('DE-BO')
->setZip('60386')
->setCity('Frankfurt am Main')
->setCountry('DE');
$customer
+ ->setSalutation('mr')
->setBillingAddress($address)
- ->setBirthDate('2000-12-12')
- ->setEmail('manuel-weissmann@unzer.com');
+ ->setCustomerId('c' . substr(self::generateRandomId(), 0, 7))
+ ->setShippingAddress((clone $address)->setShippingType(ShippingTypes::EQUALS_BILLING))
+ ->setLanguage('de')
+ ->setBirthDate('1974-10-02')
+ ->setEmail('accept@unzer.com');
return $customer;
}
diff --git a/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/WeroTest.php b/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/WeroTest.php
new file mode 100644
index 0000000..a7c08e8
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/integration/PaymentTypes/WeroTest.php
@@ -0,0 +1,105 @@
+unzer->createPaymentType(new Wero());
+ $this->assertInstanceOf(Wero::class, $wero);
+ $this->assertNotEmpty($wero->getId());
+
+ $fetched = $this->unzer->fetchPaymentType($wero->getId());
+ $this->assertInstanceOf(Wero::class, $fetched);
+ $this->assertNotSame($wero, $fetched);
+ $this->assertEquals($wero->expose(), $fetched->expose());
+
+ return $fetched;
+ }
+
+ /**
+ * Verify Wero can authorize.
+ *
+ * @test
+ *
+ * @depends weroShouldBeCreatableAndFetchable
+ */
+ public function weroShouldBeAuthorizable(Wero $wero): void
+ {
+ $authorization = new Authorization(100.0, 'EUR', self::RETURN_URL);
+
+ // Add Wero additional transaction data
+ $weroData = (new WeroTransactionData())
+ ->setEventDependentPayment(
+ (new WeroEventDependentPayment())
+ ->setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false)
+ );
+ $authorization->setWeroTransactionData($weroData);
+
+ $authorization = $this->unzer->performAuthorization($authorization, $wero);
+ $this->assertNotNull($authorization);
+ $this->assertNotEmpty($authorization->getId());
+ $this->assertNotEmpty($authorization->getRedirectUrl());
+
+ $payment = $authorization->getPayment();
+ $this->assertNotNull($payment);
+ $this->assertTrue($payment->isPending());
+ }
+
+ /**
+ * Verify Wero can charge.
+ *
+ * @test
+ *
+ * @depends weroShouldBeCreatableAndFetchable
+ */
+ public function weroShouldBeChargeable(Wero $wero): void
+ {
+ $charge = new Charge(100.0, 'EUR', self::RETURN_URL);
+
+ // Add Wero additional transaction data
+ $weroData = (new WeroTransactionData())
+ ->setEventDependentPayment(
+ (new WeroEventDependentPayment())
+ ->setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false)
+ );
+ $charge->setWeroTransactionData($weroData);
+
+ $charge = $this->unzer->performCharge($charge, $wero);
+ $this->assertNotNull($charge);
+ $this->assertNotEmpty($charge->getId());
+ $this->assertNotEmpty($charge->getRedirectUrl());
+
+ $fetched = $this->unzer->fetchChargeById($charge->getPayment()->getId(), $charge->getId());
+
+ $this->assertEquals(($charge->getPaymentId()), $fetched->getPaymentId());
+ $this->assertEquals(($charge->getAmount()), $fetched->getAmount());
+ $this->assertEquals(($charge->getId()), $fetched->getId());
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV2Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV2Test.php
index 677f691..ec9a666 100644
--- a/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV2Test.php
+++ b/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV2Test.php
@@ -21,8 +21,6 @@
class BasketV2Test extends BaseIntegrationTest
{
- //
-
/**
* Verify basket can be created and fetched.
*
@@ -299,10 +297,6 @@ public function chargeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void
$this->assertEquals($basket->expose(), $fetchedPayment->getBasket()->expose());
}
- //
-
- //
-
/**
* @return array
*/
@@ -315,6 +309,4 @@ public function basketItemWithInvalidUrlWillThrowAnErrorDP(): array
'invalid not available' => [true, 'https://files.readme.io/does-not-exist.jpg', ApiResponseCodes::API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL]
];
}
-
- //
}
diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV3Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV3Test.php
new file mode 100644
index 0000000..55f60d9
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/integration/Resources/BasketV3Test.php
@@ -0,0 +1,299 @@
+unzer->prepareJwtToken(self::$token);
+ }
+
+ /**
+ * Verify basket can be created and fetched.
+ *
+ * @test
+ */
+ public function minV3BasketShouldBeCreatableAndFetchable(): void
+ {
+ $orderId = 'b' . self::generateRandomId();
+ $basket = new Basket($orderId, 99.99, 'EUR');
+
+ $basketItem = new BasketItem();
+ $basketItem->setBasketItemReferenceId('item1')
+ ->setQuantity(1)
+ ->setAmountPerUnitGross(99.99)
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+ $this->assertEmpty($basket->getId());
+
+ $this->unzer->createBasket($basket);
+ $this->assertNotEmpty($basket->getId());
+ $this->unzer->prepareJwtToken();
+
+ $fetchedBasket = $this->unzer->fetchBasket($basket->getId())->setOrderId($orderId);
+ $this->assertEquals($basket->expose(), $fetchedBasket->expose());
+ }
+
+ /**
+ * Verify basket can be created and fetched.
+ *
+ * @test
+ */
+ public function BasketShouldBeCreatableAndFetchable(): void
+ {
+ $orderId = microtime(true);
+ $basket = new Basket();
+ $basket->setTotalValueGross(100)
+ ->setOrderId('testOrderId')
+ ->setCurrencyCode('EUR');
+ $basketItem = new BasketItem();
+ $basketItem->setBasketItemReferenceId('item1')
+ ->setQuantity(1)
+ ->setAmountPerUnitGross(100)
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+ $this->assertEmpty($basket->getId());
+
+ $this->unzer->createBasket($basket);
+ $this->assertNotEmpty($basket->getId());
+
+ $fetchedBasket = $this->unzer->fetchBasket($basket->getId());
+ $this->assertEquals($basket->expose(), $fetchedBasket->expose());
+ }
+
+ /**
+ * Verify basket can be created and fetched.
+ *
+ * @test
+ */
+ public function maxBasketShouldBeCreatableAndFetchable(): void
+ {
+ $orderId = 'o' . self::generateRandomId();
+ $basket = new Basket();
+ $basket->setOrderId($orderId)
+ ->setCurrencyCode('EUR')
+ ->setNote('note this!')
+ ->setTotalValueGross(133.33);
+
+ $basketItem = (new BasketItem())
+ ->setBasketItemReferenceId('refIdOne')
+ ->setQuantity(10)
+ ->setAmountPerUnitGross(10.11)
+ ->setVat(19)
+ ->setTitle('Item Title 1')
+ ->setUnit('ert')
+ ->setAmountDiscountPerUnitGross(0.11)
+ ->setSubTitle('This is some subtitle for this item')
+ ->setImageUrl('https://docs.unzer.com/card/card.png')
+ ->setType('this is some type');
+ $basket->addBasketItem($basketItem);
+
+ $basketItem = (new BasketItem())
+ ->setBasketItemReferenceId('refIdtwo')
+ ->setQuantity(1)
+ ->setAmountPerUnitGross(33.33)
+ ->setVat(19.5)
+ ->setTitle('Item Title 1')
+ ->setUnit('ert')
+ ->setAmountDiscountPerUnitGross(0.0)
+ ->setSubTitle('This is some subtitle for this item')
+ ->setImageUrl('https://docs.unzer.com/card/card.png')
+ ->setType('this is some type');
+ $basket->addBasketItem($basketItem);
+
+ $this->assertEmpty($basket->getId());
+
+ $this->unzer->createBasket($basket);
+ $this->assertNotEmpty($basket->getId());
+
+ $fetchedBasket = $this->unzer->fetchBasket($basket->getId());
+ $exposedBasket = $basket->expose();
+ unset($exposedBasket['note']);
+ $this->assertEquals($exposedBasket, $fetchedBasket->expose());
+ $this->assertEquals(
+ $basket->getBasketItemByIndex(0)->expose(),
+ $fetchedBasket->getBasketItemByIndex(0)->expose()
+ );
+ }
+
+ /**
+ * Verify basketItem with invalid imageUrl will return an error.
+ *
+ * @test
+ *
+ * @dataProvider basketItemWithInvalidUrlWillThrowAnErrorDP
+ *
+ * @param $expectException
+ * @param $imageUrl
+ * @param null $exceptionCode
+ */
+ public function basketItemWithInvalidUrlWillThrowAnError($expectException, $imageUrl, $exceptionCode = null): void
+ {
+ $basket = new Basket('b' . self::generateRandomId());
+ $basket->setTotalValueGross(100)
+ ->setCurrencyCode('EUR');
+
+ $basketItem = (new BasketItem())
+ ->setImageUrl($imageUrl)
+ ->setAmountPerUnitGross(100)
+ ->setQuantity(1)
+ ->setBasketItemReferenceId('item1')
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+
+ try {
+ $this->unzer->createBasket($basket);
+ $this->assertFalse(
+ $expectException,
+ 'Failed asserting that exception of type "UnzerSDK\Exceptions\UnzerApiException" is thrown.'
+ );
+ } catch (UnzerApiException $e) {
+ $this->assertTrue($expectException);
+ $this->assertEquals($exceptionCode, $e->getCode());
+ $this->assertNotNull($e->getErrorId());
+ }
+ }
+
+ /**
+ * Verify the Basket can be updated.
+ *
+ * @test
+ */
+ public function basketShouldBeUpdateable(): void
+ {
+ $orderId = 'b' . self::generateRandomId();
+ $basket = new Basket($orderId, 99.99, 'EUR');
+
+ $basketItem = (new BasketItem())
+ ->setAmountPerUnitGross(99.99)
+ ->setQuantity(1)
+ ->setBasketItemReferenceId('item1')
+ ->setTitle('title');
+
+ $basket->addBasketItem($basketItem);
+ $this->unzer->createBasket($basket);
+
+ $updateBasket = $this->unzer->fetchBasket($basket->getId());
+ $updateBasket->setTotalValueGross(123.45)
+ ->getBasketItemByIndex(0)
+ ->setAmountPerUnitGross(123.45)
+ ->setTitle('This item can also be updated!');
+ $this->unzer->updateBasket($updateBasket);
+
+ $this->unzer->fetchBasket($basket);
+ $this->assertEquals($orderId, $basket->getOrderId());
+ $this->assertEquals(123.45, $basket->getTotalValueGross());
+ $this->assertNotEquals($basket->getBasketItemByIndex(0)->expose(), $basketItem->expose());
+ }
+
+ /**
+ * Verify basket can be passed to the payment on authorize.
+ *
+ * @test
+ */
+ public function authorizeTransactionsShouldPassAlongTheBasketIdIfSet(): void
+ {
+ $basket = $this->createV3Basket();
+ $this->assertNotEmpty($basket->getId());
+
+ /** @var Paypal $paypal */
+ $paypal = $this->unzer->createPaymentType(new Paypal());
+ $authorize = $paypal->authorize(123.4, 'EUR', 'https://unzer.com', null, null, null, $basket);
+
+ $fetchedPayment = $this->unzer->fetchPayment($authorize->getPaymentId());
+ $this->assertEquals($basket->expose(), $fetchedPayment->getBasket()->expose());
+ }
+
+ /**
+ * Verify basket will be created and passed to the payment on authorize if it does not exist yet.
+ *
+ * @test
+ */
+ public function authorizeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void
+ {
+ $orderId = 'b' . self::generateRandomId();
+ $basket = new Basket($orderId);
+ $basket->setTotalValueGross(99.99)
+ ->setCurrencyCode('EUR');
+
+ $basketItem = (new BasketItem())
+ ->setAmountPerUnitGross(99.99)
+ ->setQuantity(1)
+ ->setBasketItemReferenceId('item1')
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+ $this->assertEmpty($basket->getId());
+
+ /** @var Paypal $paypal */
+ $paypal = $this->unzer->createPaymentType(new Paypal());
+ $authorize = $paypal->authorize(123.4, 'EUR', 'https://unzer.com', null, null, null, $basket);
+ $this->assertNotEmpty($basket->getId());
+
+ $fetchedPayment = $this->unzer->fetchPayment($authorize->getPaymentId());
+ $this->assertEquals($basket->expose(), $fetchedPayment->getBasket()->expose());
+ }
+
+ /**
+ * Verify basket will be created and passed to the payment on charge if it does not exist yet.
+ *
+ * @test
+ */
+ public function chargeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void
+ {
+ $orderId = 'b' . self::generateRandomId();
+ $basket = new Basket($orderId);
+ $basket->setTotalValueGross(99.99)
+ ->setCurrencyCode('EUR');
+
+ $basketItem = (new BasketItem())
+ ->setAmountPerUnitGross(99.99)
+ ->setQuantity(1)
+ ->setBasketItemReferenceId('item1')
+ ->setTitle('title');
+ $basket->addBasketItem($basketItem);
+ $this->assertEmpty($basket->getId());
+
+ /** @var Paypal $paypal */
+ $paypal = $this->unzer->createPaymentType(new Paypal());
+ $charge = $paypal->charge(123.4, 'EUR', 'https://unzer.com', null, null, null, $basket);
+ $this->assertNotEmpty($basket->getId());
+
+ $fetchedPayment = $this->unzer->fetchPayment($charge->getPaymentId());
+ $this->assertEquals($basket->expose(), $fetchedPayment->getBasket()->expose());
+ }
+
+ /**
+ * @return array
+ */
+ public function basketItemWithInvalidUrlWillThrowAnErrorDP(): array
+ {
+ return [
+ 'valid ' => [false, 'https://docs.unzer.com/card/card.png'],
+ 'valid null' => [false, null],
+ 'valid empty' => [false, ''],
+ 'invalid not available' => [true, 'https://files.readme.io/does-not-exist.jpg', ApiResponseCodes::API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL]
+ ];
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/CustomerV2Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/CustomerV2Test.php
new file mode 100644
index 0000000..f49d74b
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/integration/Resources/CustomerV2Test.php
@@ -0,0 +1,456 @@
+getMinimalCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $geoLocation = $customer->getGeoLocation();
+ $this->assertNull($geoLocation->getClientIp());
+ $this->assertNull($geoLocation->getCountryCode());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $exposeArray = $customer->expose();
+ $exposeArray['salutation'] = Salutations::UNKNOWN;
+ $this->assertEquals($exposeArray, $fetchedCustomer->expose());
+
+ $geoLocation = $fetchedCustomer->getGeoLocation();
+ $this->assertNotEmpty($geoLocation->getClientIp());
+ $this->assertNotEmpty($geoLocation->getCountryCode());
+
+ return $customer;
+ }
+
+ /**
+ * Max customer should be creatable via the sdk.
+ *
+ * @test
+ *
+ * @return Customer
+ */
+ public function maxCustomerCanBeCreatedAndFetched(): Customer
+ {
+ $customer = $this->getMaximumCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($customer->expose(), $fetchedCustomer->expose());
+
+ return $customer;
+ }
+
+ /**
+ * Verify shipping type can be set for shipping address of customer resource.
+ *
+ * @test
+ */
+ public function customerWithShippingTypeCanBeCreatedAndFetched()
+ {
+ $customer = $this->getMaximumCustomerInclShippingAddress();
+ $customer->getShippingAddress()->setShippingType('shippingType');
+
+ $this->getUnzerObject()->createCustomer($customer);
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals('shippingType', $fetchedCustomer->getShippingAddress()->getShippingType());
+ }
+
+ /**
+ * @param Customer $customer
+ *
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ */
+ public function customerCanBeFetchedById(Customer $customer): void
+ {
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($customer->getId(), $fetchedCustomer->getId());
+ }
+
+ /**
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ */
+ public function customerCanBeFetchedByCustomerId(): void
+ {
+ $customerId = 'c' . self::generateRandomId();
+ $customer = $this->getMaximumCustomer()->setCustomerId($customerId);
+ $this->getUnzerObject()->createCustomer($customer);
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomerByExtCustomerId($customer->getCustomerId());
+ $this->assertEquals($customer->expose(), $fetchedCustomer->expose());
+ }
+
+ /**
+ * @param Customer $customer
+ *
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ */
+ public function customerCanBeFetchedByObject(Customer $customer): void
+ {
+ $customerToFetch = (new Customer())->setId($customer->getId());
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customerToFetch);
+ $this->assertEquals($customer->getId(), $fetchedCustomer->getId());
+ }
+
+ /**
+ * @param Customer $customer
+ *
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ */
+ public function customerCanBeFetchedByObjectWithData(Customer $customer): void
+ {
+ $customerToFetch = $this->getMinimalCustomer()->setId($customer->getId());
+ $this->assertNotEquals($customer->getFirstname(), $customerToFetch->getFirstname());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customerToFetch);
+ $this->assertEquals($customer->getFirstname(), $fetchedCustomer->getFirstname());
+ }
+
+ /**
+ * Customer can be referenced by payment.
+ *
+ * @test
+ */
+ public function transactionShouldCreateAndReferenceCustomerIfItDoesNotExistYet(): void
+ {
+ $customerId = 'c' . self::generateRandomId();
+ $customer = $this->getMaximumCustomerInclShippingAddress()->setCustomerId($customerId);
+
+ /** @var Paypal $paypal */
+ $paypal = $this->getUnzerObject()->createPaymentType(new Paypal());
+ $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer);
+
+ $secPayment = $this->getUnzerObject()->fetchPayment($authorization->getPayment()->getId());
+
+ /** @var Customer $secCustomer */
+ $secCustomer = $secPayment->getCustomer();
+ $this->assertNotNull($secCustomer);
+ $this->assertEquals($customer->expose(), $secCustomer->expose());
+ }
+
+ /**
+ * Customer can be referenced by payment.
+ *
+ * @test
+ */
+ public function transactionShouldReferenceCustomerIfItExist(): void
+ {
+ $customer = $this->getMaximumCustomer();
+ $this->getUnzerObject()->createCustomer($customer);
+
+ /** @var Paypal $paypal */
+ $paypal = $this->getUnzerObject()->createPaymentType(new Paypal());
+ $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer);
+
+ $secPayment = $this->getUnzerObject()->fetchPayment($authorization->getPayment()->getId());
+
+ /** @var Customer $secCustomer */
+ $secCustomer = $secPayment->getCustomer();
+ $this->assertNotNull($secCustomer);
+ $this->assertEquals($customer->expose(), $secCustomer->expose());
+ }
+
+ /**
+ * Customer can be referenced by payment.
+ *
+ * @test
+ */
+ public function transactionShouldReferenceCustomerIfItExistAndItsIdHasBeenPassed(): void
+ {
+ $customer = $this->getMaximumCustomer();
+ $this->getUnzerObject()->createCustomer($customer);
+
+ /** @var Paypal $paypal */
+ $paypal = $this->getUnzerObject()->createPaymentType(new Paypal());
+ $authorization = $paypal->authorize(12.0, 'EUR', self::RETURN_URL, $customer->getId());
+
+ $secPayment = $this->getUnzerObject()->fetchPayment($authorization->getPayment()->getId());
+
+ /** @var Customer $secCustomer */
+ $secCustomer = $secPayment->getCustomer();
+ $this->assertNotNull($secCustomer);
+ $this->assertEquals($customer->expose(), $secCustomer->expose());
+ }
+
+ /**
+ * Customer can be updated.
+ *
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ *
+ * @param Customer $customer
+ */
+ public function customerShouldBeUpdateable(Customer $customer): void
+ {
+ $this->assertEquals('Peter', $customer->getFirstname());
+ $customer->setFirstname('Not Peter');
+ $this->getUnzerObject()->updateCustomer($customer);
+ $this->assertEquals('Not Peter', $customer->getFirstname());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($customer->getId(), $fetchedCustomer->getId());
+ $this->assertEquals('Not Peter', $fetchedCustomer->getFirstname());
+ }
+
+ /**
+ * Customer can be deleted.
+ *
+ * @depends maxCustomerCanBeCreatedAndFetched
+ *
+ * @test
+ *
+ * @param Customer $customer
+ */
+ public function customerShouldBeDeletableById(Customer $customer): void
+ {
+ $this->assertNotNull($customer);
+ $this->assertNotNull($customer->getId());
+
+ $this->getUnzerObject()->deleteCustomer($customer->getId());
+
+ $this->expectException(UnzerApiException::class);
+ $this->expectExceptionCode(ApiResponseCodes::API_ERROR_CUSTOMER_DOES_NOT_EXIST);
+ $this->getUnzerObject()->fetchCustomer($customer->getId());
+ }
+
+ /**
+ * Customer can be deleted.
+ *
+ * @test
+ */
+ public function customerShouldBeDeletableByObject(): void
+ {
+ $customer = $this->getUnzerObject()->createCustomer($this->getMaximumCustomer());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertNotNull($customer);
+ $this->assertNotNull($customer->getId());
+
+ $this->getUnzerObject()->deleteCustomer($customer);
+
+ $this->expectException(UnzerApiException::class);
+ $this->expectExceptionCode(ApiResponseCodes::API_ERROR_CUSTOMER_DOES_NOT_EXIST);
+ $this->getUnzerObject()->fetchCustomer($fetchedCustomer->getId());
+ }
+
+ /**
+ * Verify an Exception is thrown if the customerId already exists.
+ *
+ * @test
+ */
+ public function apiShouldReturnErrorIfCustomerAlreadyExists(): void
+ {
+ $customerId = str_replace(' ', '', microtime());
+
+ // create customer with api
+ $customer = $this->getUnzerObject()->createCustomer($this->getMaximumCustomer()->setCustomerId($customerId));
+ $this->assertNotEmpty($customer->getCustomerId());
+
+ $this->expectException(UnzerApiException::class);
+ $this->expectExceptionCode(ApiResponseCodes::API_ERROR_CUSTOMER_ID_ALREADY_EXISTS);
+
+ // create new customer with the same customerId
+ $this->getUnzerObject()->createCustomer($this->getMaximumCustomer()->setCustomerId($customerId));
+ }
+
+ /**
+ * Verify a Customer is fetched and updated when its customerId already exist.
+ *
+ * @test
+ */
+ public function customerShouldBeFetchedByCustomerIdAndUpdatedIfItAlreadyExists(): void
+ {
+ $customerId = str_replace(' ', '', microtime());
+
+ try {
+ // fetch non-existing customer by customerId
+ $this->getUnzerObject()->fetchCustomerByExtCustomerId($customerId, 2);
+ $this->assertTrue(false, 'Exception should be thrown here.');
+ } catch (UnzerApiException $e) {
+ $this->assertEquals(ApiResponseCodes::API_ERROR_CUSTOMER_CAN_NOT_BE_FOUND, $e->getCode());
+ $this->assertNotNull($e->getErrorId());
+ }
+
+ // create customer with api
+ $customer = $this->getUnzerObject()->createOrUpdateCustomer($this->getMaximumCustomer()->setCustomerId($customerId));
+ $this->assertNotEmpty($customer->getCustomerId());
+ $this->assertEquals($customerId, $customer->getCustomerId());
+ $this->assertEquals('Peter', $customer->getFirstname());
+
+ $newCustomerData = $this->getMaximumCustomer()->setCustomerId($customerId)->setFirstname('Petra');
+ $this->getUnzerObject()->createOrUpdateCustomer($newCustomerData);
+
+ $this->assertEquals('Petra', $newCustomerData->getFirstname());
+ $this->assertEquals($customerId, $newCustomerData->getCustomerId());
+ $this->assertEquals($customer->getId(), $newCustomerData->getId());
+ }
+
+ /**
+ * Verify customer address can take a name as long as both first and lastname concatenated.
+ *
+ * @test
+ */
+ public function addressNameCanHoldFirstAndLastNameConcatenated(): void
+ {
+ $customerId = 'c' . self::generateRandomId();
+ $customer = $this->getMaximumCustomerInclShippingAddress()->setCustomerId($customerId);
+ $longName = 'firstfirstfirstfirstfirstfirstfirstfirst lastlastlastlastlastlastlastlastlastlast';
+ $customer->getShippingAddress()->setName($longName);
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertEquals($longName, $customer->getShippingAddress()->getName());
+
+ $veryLongName = $longName . 'X';
+ $customer->getShippingAddress()->setName($veryLongName);
+ $this->expectException(UnzerApiException::class);
+ $this->expectExceptionCode(ApiResponseCodes::API_ERROR_ADDRESS_NAME_TO_LONG);
+ $this->getUnzerObject()->updateCustomer($customer);
+ }
+
+ /**
+ * Not registered B2B customer should be creatable.
+ *
+ * @test
+ *
+ * @return Customer
+ */
+ public function minNotRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer
+ {
+ $customer = $this->getMinimalNotRegisteredB2bCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $exposeArray = $customer->expose();
+ $exposeArray['salutation'] = Salutations::UNKNOWN;
+ $this->assertEquals($exposeArray, $fetchedCustomer->expose());
+
+ return $customer;
+ }
+
+ /**
+ * Max not registered customer should be creatable.
+ *
+ * @test
+ */
+ public function maxNotRegisteredB2bCustomerCanBeCreatedAndFetched(): void
+ {
+ $customer = $this->getMaximalNotRegisteredB2bCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($customer->expose(), $fetchedCustomer->expose());
+ }
+
+ /**
+ * Registered B2B customer should be creatable.
+ *
+ * @test
+ *
+ * @return Customer
+ */
+ public function minRegisteredB2bCustomerCanBeCreatedAndFetched(): Customer
+ {
+ $customer = $this->getMinimalRegisteredB2bCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $exposeArray = $customer->expose();
+ $exposeArray['salutation'] = Salutations::UNKNOWN;
+ $this->assertEquals($exposeArray, $fetchedCustomer->expose());
+
+ return $customer;
+ }
+
+ /**
+ * Max registered customer should be creatable.
+ *
+ * @test
+ */
+ public function maxRegisteredB2bCustomerCanBeCreatedAndFetched(): void
+ {
+ $customer = $this->getMaximalRegisteredB2bCustomer();
+ $this->assertEmpty($customer->getId());
+ $this->getUnzerObject()->createCustomer($customer);
+ $this->assertNotEmpty($customer->getId());
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($customer->expose(), $fetchedCustomer->expose());
+ }
+
+ /**
+ * Customer should contain clientIp set via header.
+ *
+ * @test
+ */
+ public function customerShouldContainClientIpSetViaHeader()
+ {
+ $customer = $this->getMinimalCustomer();
+ $clientIp = '123.123.123.123';
+ $this->getUnzerObject()->setClientIp($clientIp);
+ $this->getUnzerObject()->createCustomer($customer);
+
+ $fetchedCustomer = $this->getUnzerObject()->fetchCustomer($customer->getId());
+ $this->assertEquals($clientIp, $fetchedCustomer->getGeoLocation()->getClientIp());
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/LinkpayV2Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/LinkpayV2Test.php
index 38486b1..949c35a 100644
--- a/vendor/unzerdev/php-sdk/test/integration/Resources/LinkpayV2Test.php
+++ b/vendor/unzerdev/php-sdk/test/integration/Resources/LinkpayV2Test.php
@@ -12,6 +12,14 @@
*/
class LinkpayV2Test extends BaseIntegrationTest
{
+ private static ?string $token = null;
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ self::$token = $this->unzer->prepareJwtToken(self::$token);
+ }
+
/**
* @test
*/
@@ -128,7 +136,8 @@ public function updateLinkpayExpiryDate()
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getAlias(), $updatePaypage->getAlias());
$this->assertEquals($paypage->getAmountSettings(), $updatePaypage->getAmountSettings());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
}
/**
@@ -167,8 +176,11 @@ public function updateLinkpayAmount()
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getAlias(), $updatePaypage->getAlias());
$this->assertEquals($paypage->getAmountSettings(), $updatePaypage->getAmountSettings());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
$this->assertEquals($paypage->getExpiresAt(), $updatePaypage->getExpiresAt());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
+ $this->assertEmpty($updatePaypage->getResources()->getCustomerId());
+ $this->assertEmpty($updatePaypage->getResources()->getBasketId());
}
/**
@@ -208,8 +220,11 @@ public function updateLinkpayAmountSettings()
$this->assertEquals($paypage->getAmount(), $updatePaypage->getAmount());
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getExpiresAt(), $updatePaypage->getExpiresAt());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
$this->assertEquals('linkpay', $paypage->getType());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
+ $this->assertEmpty($updatePaypage->getResources()->getCustomerId());
+ $this->assertEmpty($updatePaypage->getResources()->getBasketId());
}
/**
diff --git a/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php b/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php
index 0a92acd..18ca4ac 100644
--- a/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php
+++ b/vendor/unzerdev/php-sdk/test/integration/Resources/PaypageV2Test.php
@@ -2,14 +2,18 @@
namespace UnzerSDK\test\integration\Resources;
+use UnzerSDK\Constants\CustomerGroups;
use UnzerSDK\Constants\ExemptionType;
use UnzerSDK\Constants\PaypageCheckoutTypes;
+use UnzerSDK\Constants\WeroAmountPaymentTypes;
+use UnzerSDK\Constants\WeroCaptureTriggers;
use UnzerSDK\Resources\EmbeddedResources\Paypage\PaymentMethodConfig;
use UnzerSDK\Resources\EmbeddedResources\Paypage\PaymentMethodsConfigs;
use UnzerSDK\Resources\EmbeddedResources\Paypage\Resources;
use UnzerSDK\Resources\EmbeddedResources\Paypage\Style;
use UnzerSDK\Resources\EmbeddedResources\Paypage\Urls;
use UnzerSDK\Resources\EmbeddedResources\Risk;
+use UnzerSDK\Resources\EmbeddedResources\WeroEventDependentPayment;
use UnzerSDK\Resources\Metadata;
use UnzerSDK\Resources\PaymentTypes\Alipay;
use UnzerSDK\Resources\PaymentTypes\Applepay;
@@ -41,6 +45,14 @@
*/
class PaypageV2Test extends BaseIntegrationTest
{
+ private static ?string $token = null;
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ self::$token = $this->unzer->prepareJwtToken(self::$token);
+ }
+
/**
* @test
*/
@@ -99,7 +111,6 @@ public function JwtTokenShouldBeReusedForMultipleRequests()
$this->assertNull($paypageSecond->getRedirectUrl());
// Create Firt paypage
- $this->assertNull($unzer->getJwtToken());
$unzer->createPaypage($paypageFirst);
$InitialJwtToken = $unzer->getJwtToken();
$this->assertNotNull($InitialJwtToken);
@@ -181,6 +192,8 @@ public function createPaypageWithStyle()
->setLinkColor('#1f1f1f')
->setLogoImage('https://logoimage.com')
->setShadows(true)
+ ->setBasketBackgroundColor('#1f1f1f')
+ ->setPaymentFormBackgroundColor('#1f1f1f')
->setTextColor('#1f1f1f');
$paypage = new Paypage(9.99, 'EUR', 'charge');
@@ -226,7 +239,7 @@ public function createPaypageWithRiskData()
$unzer = $this->getUnzerObject();
$risk = new Risk();
- $risk->setCustomerGroup('neutral')
+ $risk->setCustomerGroup(CustomerGroups::NEUTRAL)
->setConfirmedAmount('1234')
->setConfirmedOrders('42')
->setRegistrationLevel('1')
@@ -239,6 +252,18 @@ public function createPaypageWithRiskData()
$this->assertCreatedPaypage($paypage);
}
+ /** @test
+ */
+ public function createPaypageWithZeroAmount()
+ {
+ $unzer = $this->getUnzerObject();
+
+ $paypage = new Paypage(0, 'EUR', 'preauthorize');
+ $unzer->createPaypage($paypage);
+
+ $this->assertCreatedPaypage($paypage);
+ }
+
/**
* @param Paypage $paypage
* @return void
@@ -272,6 +297,18 @@ public function paymentMethodsConfigsDataProvider()
'paypal' => $enabledConfig
]);
+ $withWeroConfig = new PaymentMethodsConfigs();
+ $withWeroConfig->setMethodConfigs([
+ 'wero' => (new PaymentMethodConfig())
+ ->setEnabled(true)
+ ->setEventDependentPayment($edp = (new WeroEventDependentPayment())
+ ->setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false)
+ )
+ ]);
+
$withCardSpecificConfig = (new PaymentMethodsConfigs())->addMethodConfig(Card::class, $cardConfig);
@@ -297,8 +334,7 @@ public function paymentMethodsConfigsDataProvider()
->addMethodConfig(PostFinanceEfinance::class, $enabledConfig)
->addMethodConfig(PostFinanceCard::class, $enabledConfig)
->addMethodConfig(Twint::class, $enabledConfig)
- ->addMethodConfig(OpenbankingPis::class, $enabledConfig)
- ;
+ ->addMethodConfig(OpenbankingPis::class, $enabledConfig);
$withPaylaterConfig = (new PaymentMethodsConfigs())
->addMethodConfig(PaylaterInvoice::class, $paylaterConfig);
@@ -310,7 +346,8 @@ public function paymentMethodsConfigsDataProvider()
'Method Configs' => [$withMethodConfigs],
'CardSpecificConfig' => [$withCardSpecificConfig],
'ClassNames' => [$withClassNames],
- 'PaylaterConfig' => [$withPaylaterConfig]
+ 'PaylaterConfig' => [$withPaylaterConfig],
+ 'WeroConfig' => [$withWeroConfig]
];
}
}
diff --git a/vendor/unzerdev/php-sdk/test/unit/Resources/EmbeddedResources/WeroTransactionDataTest.php b/vendor/unzerdev/php-sdk/test/unit/Resources/EmbeddedResources/WeroTransactionDataTest.php
new file mode 100644
index 0000000..feca25e
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/unit/Resources/EmbeddedResources/WeroTransactionDataTest.php
@@ -0,0 +1,40 @@
+setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false);
+
+ $wtd = (new WeroTransactionData())
+ ->setEventDependentPayment($edp);
+
+ // Getters
+ $this->assertInstanceOf(WeroEventDependentPayment::class, $wtd->getEventDependentPayment());
+ $this->assertEquals(WeroCaptureTriggers::SERVICEFULFILMENT, $wtd->getEventDependentPayment()->getCaptureTrigger());
+
+ // Expose
+ $exposed = $wtd->expose();
+ $this->assertArrayHasKey('eventDependentPayment', $exposed);
+ $this->assertEquals(WeroCaptureTriggers::SERVICEFULFILMENT, $exposed['eventDependentPayment']['captureTrigger']);
+ $this->assertEquals(WeroAmountPaymentTypes::PAY, $exposed['eventDependentPayment']['amountPaymentType']);
+ $this->assertSame(300, $exposed['eventDependentPayment']['maxAuthToCaptureTime']);
+ $this->assertSame(false, $exposed['eventDependentPayment']['multiCapturesAllowed']);
+ $this->assertArrayNotHasKey('enabled', $exposed);
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php b/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php
index 399d50c..a377870 100644
--- a/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php
+++ b/vendor/unzerdev/php-sdk/test/unit/Services/DummyAdapter.php
@@ -18,7 +18,7 @@ class DummyAdapter implements HttpAdapterInterface
/**
* {@inheritDoc}
*/
- public function init(string $url, string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
+ public function init(string $url, ?string $payload = null, string $httpMethod = HttpAdapterInterface::REQUEST_GET): void
{
// do nothing
}
diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/IdServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/IdServiceTest.php
new file mode 100644
index 0000000..cd3c023
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/unit/Services/IdServiceTest.php
@@ -0,0 +1,58 @@
+assertTrue($isUUID);
+ }
+
+ /**
+ * @test
+ *
+ * @dataProvider invalidUUIDsDP
+ *
+ * @param string $id
+ */
+ public function shortIdShouldReturnFalse(string $id)
+ {
+ $isUUID = IdService::isUUIDResource($id);
+ $this->assertFalse($isUUID);
+ }
+
+ public function validUUIDsDP(): array
+ {
+ return [
+ ['s-bsk-123e4567-e89b-12d3-a456-426614174000'],
+ ['s-cst-123e4567-e89b-12d3-a456-426614174001'],
+ ['p-bsk-123e4567-e89b-12d3-a456-426614174000'],
+ ['p-cst-123e4567-e89b-12d3-a456-426614174001'],
+ ];
+ }
+
+ public function invalidUUIDsDP(): array
+ {
+ return [
+ [''],
+ ['s-cst'],
+ ['s-bsk-123e4567-e89b-12d3-a456-426614174000-'],
+ ['-s-bsk-123e4567-e89b-12d3-a456-426614174000'],
+ ['s-bskt-123e4567-e89b-12d3-a456-426614174000'],
+ ['a-bsk-123e4567-e89b-12d3-a456-426614174000'],
+ ['s-cst-123456abcdef'],
+ ];
+ }
+}
diff --git a/vendor/unzerdev/php-sdk/test/unit/Services/JwtServiceTest.php b/vendor/unzerdev/php-sdk/test/unit/Services/JwtServiceTest.php
new file mode 100644
index 0000000..d65d794
--- /dev/null
+++ b/vendor/unzerdev/php-sdk/test/unit/Services/JwtServiceTest.php
@@ -0,0 +1,46 @@
+
-
- /**^^
+ /**
* Verify setters and getters work properly.
*
* @test
@@ -93,7 +94,7 @@ public function gettersAndSettersShouldWorkProperly(): void
*
* @param string $method
* @param string $uri
- * @param bool $appendId
+ * @param bool $appendId
*/
public function sendShouldCallSendOnHttpService(string $method, string $uri, bool $appendId): void
{
@@ -128,7 +129,7 @@ public function sendShouldCallSendOnHttpService(string $method, string $uri, boo
*
* @param string $method
* @param string $uri
- * @param bool $appendId
+ * @param bool $appendId
*/
public function AuthTokenShouldBeRequestedAutomatically(string $method, string $uri, bool $appendId): void
{
@@ -151,9 +152,47 @@ public function AuthTokenShouldBeRequestedAutomatically(string $method, string $
$this->assertEquals('paypage response', $response->response);
}
- //
+ /**
+ * Verify send will call send on httpService.
+ *
+ * @group CC-1309
+ * @group CC-1376
+ *
+ * @test
+ *
+ * @dataProvider customerV2CreationShouldCallV2EnpointDP
+ *
+ * @param string $method
+ * @param string $uri
+ * @param bool $appendId
+ */
+ public function customerV2CreationShouldCallV2Enpoint(string $uri, bool $appendId): void
+ {
+ $unzer = new Unzer('s-priv-1234');
+ $httpMethod = HttpAdapterInterface::REQUEST_POST;
+ $customer = new CustomerV2();
+ $customer->setParentResource($unzer);
+
+ //prepare http service mock.
+ $method = 'send';
+ $httpSrvMock = $this->getMockBuilder(HttpService::class)->setMethods([$method])->getMock();
+ $resourceSrv = new ResourceService($unzer);
+
+ /** @var HttpService $httpSrvMock */
+ $unzer->setHttpService($httpSrvMock);
- //
+ $httpSrvMock->expects($this->exactly(2))->method($method)->withConsecutive(
+ ['/auth/token'],
+ [$uri, $customer, $method]
+ )
+ ->willReturnOnConsecutiveCalls(
+ '{"accessToken": "jwt.auth.token"}',
+ '{"response": "paypage response"}'
+ );
+
+ $response = $resourceSrv->send($customer, $method);
+ $this->assertEquals('paypage response', $response->response);
+ }
/**
* Verify getResourceIdFromUrl works correctly.
@@ -170,7 +209,8 @@ public function getResourceIdFromUrlShouldIdentifyAndReturnTheIdStringFromAGiven
$expected,
$uri,
$idString
- ): void {
+ ): void
+ {
$this->assertEquals($expected, IdService::getResourceIdFromUrl($uri, $idString));
}
@@ -190,10 +230,6 @@ public function getResourceIdFromUrlShouldThrowExceptionIfTheIdCanNotBeFound($ur
IdService::getResourceIdFromUrl($uri, $idString);
}
- //
-
- //
-
/**
* Verify fetchResource calls fetch if its id is set and it has never been fetched before.
*
@@ -400,7 +436,7 @@ public function fetchShouldCallSendWithGetUpdateFetchedAtAndCallHandleResponse()
* @dataProvider fetchResourceByUrlShouldFetchTheDesiredResourceDP
*
* @param string $fetchMethod
- * @param mixed $arguments
+ * @param mixed $arguments
* @param string $resourceUrl
*/
public function fetchResourceByUrlShouldFetchTheDesiredResource($fetchMethod, $arguments, $resourceUrl): void
@@ -455,8 +491,8 @@ public function fetchResourceByUrlForAPaymentTypeShouldReturnNullIfTheTypeIsUnkn
* @dataProvider fetchShouldCallFetchResourceDP
*
* @param string $fetchMethod
- * @param array $arguments
- * @param mixed $callback
+ * @param array $arguments
+ * @param mixed $callback
*/
public function fetchShouldCallFetchResource(string $fetchMethod, array $arguments, $callback): void
{
@@ -478,10 +514,6 @@ static function ($resource) use ($callback, $unzer) {
$this->assertEquals($unzer, $resource->getUnzerObject());
}
- //
-
- //
-
/**
* Verify createPaymentType method will set parentResource to Unzer object and call create.
*
@@ -545,10 +577,6 @@ public function updatePaymentTypeShouldCallUpdateMethod(): void
$this->assertSame($paymentType, $returnedPaymentType);
}
- //
-
- //
-
/**
* Verify createCustomer calls create with customer object and the Unzer resource is set.
*
@@ -604,8 +632,8 @@ public function createOrUpdateCustomerShouldFetchAndUpdateCustomerIfItAlreadyExi
->with($this->callback(static function ($customerToUpdate) use ($customer) {
/** @var Customer $customerToUpdate */
return $customerToUpdate === $customer &&
- $customerToUpdate->getId() === $customer->getId() &&
- $customerToUpdate->getEmail() === 'customer@email.de';
+ $customerToUpdate->getId() === $customer->getId() &&
+ $customerToUpdate->getEmail() === 'customer@email.de';
}));
// Make the call and assertions.
@@ -722,10 +750,6 @@ public function deleteCustomerShouldFetchCustomerByIdIfTheIdIsGiven(): void
$resourceSrvMock->deleteCustomer('myCustomerId');
}
- //
-
- //
-
/**
* Verify fetchAuthorization fetches payment object and returns its authorization.
*
@@ -769,10 +793,6 @@ public function fetchAuthorizationShouldThrowExceptionIfNoAuthorizationIsPresent
$resourceSrvMock->fetchAuthorization('paymentId');
}
- //
-
- //
-
/**
* Verify fetchPayout fetches payment object and returns its payout.
*
@@ -795,10 +815,6 @@ public function fetchPayoutShouldFetchPaymentAndReturnItsPayout(): void
$this->assertSame($payout, $returnedPayout);
}
- //
-
- //
-
/**
* Verify fetchChargeById fetches payment object and gets and returns the charge object from it.
*
@@ -862,10 +878,6 @@ public function fetchChargeByIdShouldThrowExceptionIfChargeDoesNotExist(): void
$resourceSrvMock->fetchChargeById($paymentMock, 'chargeId');
}
- //
-
- //
-
/**
* Verify fetchReversalByAuthorization fetches authorization and gets and returns the reversal object from it.
*
@@ -947,15 +959,11 @@ public function fetchRefundShouldGetAndFetchDesiredChargeCancellation(): void
/** @noinspection PhpParamsInspection */
$resourceSrvMock->expects($this->once())->method('fetchResource')->with($cancel)->willReturn($cancel);
- /** @var Charge $chargeMock*/
+ /** @var Charge $chargeMock */
$returnedCancellation = $resourceSrvMock->fetchRefund($chargeMock, 'cancellationId');
$this->assertSame($cancel, $returnedCancellation);
}
- //
-
- //
-
/**
* Verify fetchShipment fetches payment object and returns the desired shipment from it.
*
@@ -972,15 +980,11 @@ public function fetchShipmentShouldFetchPaymentAndReturnTheDesiredShipmentFromIt
/** @noinspection PhpParamsInspection */
$paymentMock->expects($this->once())->method('getShipment')->with('shipmentId', false)->willReturn($shipment);
- /** @var Payment $paymentMock */
+ /** @var Payment $paymentMock */
$returnedShipment = $resourceSrvMock->fetchShipment('paymentId', 'shipmentId');
$this->assertSame($shipment, $returnedShipment);
}
- //
-
- //
-
/**
* Verify createMetadata calls create with the given metadata object.
*
@@ -997,10 +1001,6 @@ public function createMetadataShouldCallCreateWithTheGivenMetadataObject(): void
$this->assertSame($metadata, $resourceSrvMock->createMetadata($metadata));
}
- //
-
- //
-
/**
* Verify createBasket will set parentResource and call create with the given basket.
*
@@ -1063,7 +1063,7 @@ public function fetchBasketShouldCallV1EnpointIfBasketWasNotFound(): void
$resourceServiceMock->expects(self::exactly(2))
->method('fetchResource')
- ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket, Unzer::API_VERSION])
+ ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket])
->will($this->returnCallback(function ($basket, $version) {
if ($version === BasePaymentTest::API_VERSION_2) {
throw new UnzerApiException(null, null, ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND);
@@ -1092,7 +1092,7 @@ public function fetchBasketShouldCallFetchResourceMaxTwoTimes(): void
$resourceServiceMock->expects(self::exactly(2))
->method('fetchResource')
- ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket, Unzer::API_VERSION])
+ ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket])
->willThrowException(new UnzerApiException(null, null, ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND));
$this->expectException(UnzerApiException::class);
@@ -1147,9 +1147,108 @@ public function fetchBasketShouldNotCallFetchResourcheMethodIfAnyOtherExceptionI
$resourceServiceMock->fetchBasket($basket);
}
- //
+ /**
+ * Verify createBasket will set parentResource and call create with the given basket.
+ *
+ * @test
+ */
+ public function createV3BasketShouldCallV3Endpoint(): void
+ {
+ $unzer = new Unzer('s-priv-123');
+ /** @var ResourceServiceInterface|MockObject $resourceSrvMock */
+ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setConstructorArgs([$unzer])->setMethods(['send'])->getMock();
+ $basket = new BasketV3();
+ $resourceSrvMock->expects($this->once())
+ ->method('send')
+ ->with($basket, 'POST', BasePaymentTest::API_VERSION_3);
- //
+ try {
+ $basket->getParentResource();
+ $this->assertTrue(false, 'This exception should have been thrown!');
+ } catch (RuntimeException $e) {
+ $this->assertEquals('Parent resource reference is not set!', $e->getMessage());
+ }
+
+ $this->assertSame($basket, $resourceSrvMock->createBasket($basket));
+ $this->assertSame($unzer, $basket->getParentResource());
+ }
+
+ /**
+ * Verify updateBasket calls update with the given basket and returns it.
+ *
+ * @test
+ */
+ public function updateV3BasketShouldCallSendMethodWithV3Version(): void
+ {
+ $unzer = new Unzer('s-priv-123');
+ /** @var ResourceServiceInterface|MockObject $resourceSrvMock */
+ $resourceSrvMock = $this->getMockBuilder(ResourceService::class)->setConstructorArgs([$unzer])->setMethods(['send'])->getMock();
+ $basket = new BasketV3();
+ /** @noinspection PhpParamsInspection */
+ $resourceSrvMock->expects($this->once())->method('send')->with($basket, 'PUT', ApiVersions::V3);
+
+ $returnedBasket = $resourceSrvMock->updateBasket($basket);
+
+ $this->assertSame($basket, $returnedBasket);
+ $this->assertEquals($unzer, $basket->getParentResource());
+ $this->assertEquals($unzer, $basket->getUnzerObject());
+ }
+
+ /**
+ * @test
+ */
+ public function fetchV3BasketIdShouldFetchV3Basket(): void
+ {
+ $unzer = new Unzer('s-priv-123');
+ $basket = (new BasketV3());
+ $basket->setId('s-bsk-123e4567-e89b-12d3-a456-426614174000');
+ $basket->setParentResource($unzer);
+
+ /** @var ResourceServiceInterface|MockObject $resourceServiceMock */
+ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)
+ ->setConstructorArgs([$unzer])
+ ->setMethods(['send'])->getMock();
+
+ $result = (object)$basket->expose();
+ $result->orderId = 'orderId';
+ $resourceServiceMock->expects(self::once())
+ ->method('send')
+ ->with($basket, 'GET', BasePaymentTest::API_VERSION_3)
+ ->willReturn($result);
+
+ $resourceServiceMock->fetchBasket('s-bsk-123e4567-e89b-12d3-a456-426614174000');
+ }
+
+ /**
+ * @test
+ */
+ public function fetchUnknownV3BasketIdShouldFetchV3Basket(): void
+ {
+ $unzer = new Unzer('s-priv-123');
+ $basket = (new BasketV3());
+ $basket->setId('s-bsk-123e4567-e89b-12d3-a456-426614174000');
+ $basket->setParentResource($unzer);
+
+ /** @var ResourceServiceInterface|MockObject $resourceServiceMock */
+ $resourceServiceMock = $this->getMockBuilder(ResourceService::class)
+ ->setConstructorArgs([$unzer])
+ ->setMethods(['send'])->getMock();
+
+ $result = (object)$basket->expose();
+ $result->orderId = 'orderId';
+ $resourceServiceMock->expects(self::once())
+ ->method('send')
+ ->with($basket, 'GET', BasePaymentTest::API_VERSION_3)
+ ->willThrowException(new UnzerApiException(
+ 'Basket not found',
+ 'Basket not found',
+ ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND
+ ));
+
+ $this->expectException(UnzerApiException::class);
+ $this->expectExceptionCode(ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND);
+ $resourceServiceMock->fetchBasket('s-bsk-123e4567-e89b-12d3-a456-426614174000');
+ }
/**
* Verify createRecurring calls fetch for the payment type if it is given the id.
@@ -1210,10 +1309,6 @@ public function createRecurringShouldThrowExceptionWhenRecurringPaymentIsNotSupp
$resourceService->activateRecurringPayment(new Sofort(), 'returnUrl', null);
}
- //
-
- //
-
/**
* Data provider for getResourceIdFromUrlShouldIdentifyAndReturnTheIdStringFromAGivenString.
*
@@ -1235,7 +1330,7 @@ public function urlIdStringProvider(): array
*/
public function failingUrlIdStringProvider(): array
{
- return[
+ return [
['https://myurl.test/s-test-1234', 'aut'],
['https://myurl.test/authorizep-aut-99988776655', 'foo'],
['https://myurl.test/s-test-1234/z-bar-123456787', 'bar']
@@ -1284,18 +1379,19 @@ public function fetchResourceByUrlShouldFetchTheDesiredResourceDP(): array
{
return [
'Authorization' => ['fetchAuthorization', ['s-pay-100746'], 'https://api.unzer.com/v1/payments/s-pay-100746/authorize/s-aut-1/'],
- 'Charge' => ['fetchChargeById', ['s-pay-100798', 's-chg-1'], 'https://api.unzer.com/v1/payments/s-pay-100798/charges/s-chg-1/'],
- 'Shipment' => ['fetchShipment', ['s-pay-100801', 's-shp-1'], 'https://api.unzer.com/v1/payments/s-pay-100801/shipments/s-shp-1/'],
- 'Refund' => ['fetchRefundById', ['s-pay-100802', 's-chg-1', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100802/charges/s-chg-1/cancels/s-cnl-1/'],
+ 'Charge' => ['fetchChargeById', ['s-pay-100798', 's-chg-1'], 'https://api.unzer.com/v1/payments/s-pay-100798/charges/s-chg-1/'],
+ 'Shipment' => ['fetchShipment', ['s-pay-100801', 's-shp-1'], 'https://api.unzer.com/v1/payments/s-pay-100801/shipments/s-shp-1/'],
+ 'Refund' => ['fetchRefundById', ['s-pay-100802', 's-chg-1', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100802/charges/s-chg-1/cancels/s-cnl-1/'],
'Payment Refund' => ['fetchPaymentRefund', ['s-pay-100802', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100802/charges/cancels/s-cnl-1/'],
- 'Reversal' => ['fetchReversal', ['s-pay-100803', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100803/authorize/s-aut-1/cancels/s-cnl-1/'],
+ 'Reversal' => ['fetchReversal', ['s-pay-100803', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100803/authorize/s-aut-1/cancels/s-cnl-1/'],
'Payment Reversal' => ['fetchPaymentReversal', ['s-pay-100803', 's-cnl-1'], 'https://api.unzer.com/v1/payments/s-pay-100803/authorize/cancels/s-cnl-1/'],
- 'Payment' => ['fetchPayment', ['s-pay-100801'], 'https://api.unzer.com/v1/payments/s-pay-100801'],
- 'Metadata' => ['fetchMetadata', ['s-mtd-6glqv9axjpnc'], 'https://api.unzer.com/v1/metadata/s-mtd-6glqv9axjpnc/'],
- 'Customer' => ['fetchCustomer', ['s-cst-50c14d49e2fe'], 'https://api.unzer.com/v1/customers/s-cst-50c14d49e2fe'],
- 'v1Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v1/baskets/s-bsk-1254/'],
- 'v2Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v2/baskets/s-bsk-1254/'],
- 'Payout' => ['fetchPayout', ['s-pay-100746'], 'https://api.unzer.com/v1/payments/s-pay-100746/payout/s-out-1/']
+ 'Payment' => ['fetchPayment', ['s-pay-100801'], 'https://api.unzer.com/v1/payments/s-pay-100801'],
+ 'Metadata' => ['fetchMetadata', ['s-mtd-6glqv9axjpnc'], 'https://api.unzer.com/v1/metadata/s-mtd-6glqv9axjpnc/'],
+ 'Customer' => ['fetchCustomer', ['s-cst-50c14d49e2fe'], 'https://api.unzer.com/v1/customers/s-cst-50c14d49e2fe'],
+ 'v2Customer' => ['fetchCustomer', ['s-cst-123e4567-e89b-12d3-a456-426614174000'], 'https://api.unzer.com/v2/customers/s-cst-123e4567-e89b-12d3-a456-426614174000'],
+ 'v1Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v1/baskets/s-bsk-1254/'],
+ 'v2Basket' => ['fetchBasket', ['s-bsk-1254'], 'https://api.unzer.com/v2/baskets/s-bsk-1254/'],
+ 'Payout' => ['fetchPayout', ['s-pay-100746'], 'https://api.unzer.com/v1/payments/s-pay-100746/payout/s-out-1/']
];
}
@@ -1307,30 +1403,31 @@ public function fetchResourceByUrlShouldFetchTheDesiredResourceDP(): array
public function fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentTypeDP(): array
{
return [
- 'ALIPAY' => ['s-ali-xen2ybcovn56', 'https://api.unzer.com/v1/types/alipay/s-ali-xen2ybcovn56/'],
- 'APPLEPAY' => ['s-apl-xen2ybcovn56', 'https://api.unzer.com/v1/types/appelpay/s-apl-xen2ybcovn56/'],
- 'BANCONTACT' => ['s-bct-xen2ybcovn56', 'https://api.unzer.com/v1/types/bancontact/s-bct-xen2ybcovn56/'],
- 'CARD' => ['s-crd-xen2ybcovn56', 'https://api.unzer.com/v1/types/card/s-crd-xen2ybcovn56/'],
- 'EPS' => ['s-eps-xen2ybcovn56', 'https://api.unzer.com/v1/types/eps/s-eps-xen2ybcovn56/'],
- 'GIROPAY' => ['s-gro-xen2ybcovn56', 'https://api.unzer.com/v1/types/giropay/s-gro-xen2ybcovn56/'],
- 'HIRE_PURCHASE_DIRECT_DEBIT' => ['s-hdd-xen2ybcovn56', 'https://api.unzer.com/v1/types/hire-purchase-direct-debit/s-hdd-xen2ybcovn56/'],
- 'IDEAL' => ['s-idl-xen2ybcovn56', 'https://api.unzer.com/v1/types/ideal/s-idl-xen2ybcovn56/'],
- 'INVOICE' => ['s-ivc-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice/s-ivc-xen2ybcovn56/'],
- 'INVOICE_FACTORING' => ['s-ivf-xen2ybcovn56', 'https://api.unzer.com/v1/types/wechatpay/s-ivf-xen2ybcovn56/'],
- 'INVOICE_GUARANTEED' => ['s-ivg-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice-guaranteed/s-ivg-xen2ybcovn56/'],
- 'INVOICE_SECURED' => ['s-ivs-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice-secured/s-ivs-xen2ybcovn56/'],
- 'Installment_SECURED' => ['s-ins-xen2ybcovn56', 'https://api.unzer.com/v1/types/installment-secured/s-ins-xen2ybcovn56/'],
- 'PAYLATER_INVOICE' => ['s-piv-xen2ybcovn56', 'https://api.unzer.com/v1/types/paylater-invoice/s-piv-xen2ybcovn56/'],
- 'PAYPAL' => ['s-ppl-xen2ybcovn56', 'https://api.unzer.com/v1/types/paypal/s-ppl-xen2ybcovn56/'],
- 'PIS' => ['s-pis-xen2ybcovn56', 'https://api.unzer.com/v1/types/pis/s-pis-xen2ybcovn56/'],
- 'POST_FINANCE_EFINANCE' => ['s-pfe-xen2ybcovn56', 'https://api.unzer.com/v1/types/pfe/s-pfe-xen2ybcovn56/'],
- 'POST_FINANCE_CARD' => ['s-pfc-xen2ybcovn56', 'https://api.unzer.com/v1/types/pfc/s-pfc-xen2ybcovn56/'],
- 'PREPAYMENT' => ['s-ppy-xen2ybcovn56', 'https://api.unzer.com/v1/types/prepayment/s-ppy-xen2ybcovn56/'],
- 'PRZELEWY24' => ['s-p24-xen2ybcovn56', 'https://api.unzer.com/v1/types/przelewy24/s-p24-xen2ybcovn56/'],
- 'SEPA_DIRECT_DEBIT' => ['s-sdd-xen2ybcovn56', 'https://api.unzer.com/v1/types/direct-debit/s-sdd-xen2ybcovn56/'],
+ 'ALIPAY' => ['s-ali-xen2ybcovn56', 'https://api.unzer.com/v1/types/alipay/s-ali-xen2ybcovn56/'],
+ 'APPLEPAY' => ['s-apl-xen2ybcovn56', 'https://api.unzer.com/v1/types/appelpay/s-apl-xen2ybcovn56/'],
+ 'BANCONTACT' => ['s-bct-xen2ybcovn56', 'https://api.unzer.com/v1/types/bancontact/s-bct-xen2ybcovn56/'],
+ 'CARD' => ['s-crd-xen2ybcovn56', 'https://api.unzer.com/v1/types/card/s-crd-xen2ybcovn56/'],
+ 'EPS' => ['s-eps-xen2ybcovn56', 'https://api.unzer.com/v1/types/eps/s-eps-xen2ybcovn56/'],
+ 'GIROPAY' => ['s-gro-xen2ybcovn56', 'https://api.unzer.com/v1/types/giropay/s-gro-xen2ybcovn56/'],
+ 'HIRE_PURCHASE_DIRECT_DEBIT' => ['s-hdd-xen2ybcovn56', 'https://api.unzer.com/v1/types/hire-purchase-direct-debit/s-hdd-xen2ybcovn56/'],
+ 'IDEAL' => ['s-idl-xen2ybcovn56', 'https://api.unzer.com/v1/types/ideal/s-idl-xen2ybcovn56/'],
+ 'INVOICE' => ['s-ivc-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice/s-ivc-xen2ybcovn56/'],
+ 'INVOICE_FACTORING' => ['s-ivf-xen2ybcovn56', 'https://api.unzer.com/v1/types/wechatpay/s-ivf-xen2ybcovn56/'],
+ 'INVOICE_GUARANTEED' => ['s-ivg-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice-guaranteed/s-ivg-xen2ybcovn56/'],
+ 'INVOICE_SECURED' => ['s-ivs-xen2ybcovn56', 'https://api.unzer.com/v1/types/invoice-secured/s-ivs-xen2ybcovn56/'],
+ 'Installment_SECURED' => ['s-ins-xen2ybcovn56', 'https://api.unzer.com/v1/types/installment-secured/s-ins-xen2ybcovn56/'],
+ 'PAYLATER_INVOICE' => ['s-piv-xen2ybcovn56', 'https://api.unzer.com/v1/types/paylater-invoice/s-piv-xen2ybcovn56/'],
+ 'PAYPAL' => ['s-ppl-xen2ybcovn56', 'https://api.unzer.com/v1/types/paypal/s-ppl-xen2ybcovn56/'],
+ 'PIS' => ['s-pis-xen2ybcovn56', 'https://api.unzer.com/v1/types/pis/s-pis-xen2ybcovn56/'],
+ 'POST_FINANCE_EFINANCE' => ['s-pfe-xen2ybcovn56', 'https://api.unzer.com/v1/types/pfe/s-pfe-xen2ybcovn56/'],
+ 'POST_FINANCE_CARD' => ['s-pfc-xen2ybcovn56', 'https://api.unzer.com/v1/types/pfc/s-pfc-xen2ybcovn56/'],
+ 'PREPAYMENT' => ['s-ppy-xen2ybcovn56', 'https://api.unzer.com/v1/types/prepayment/s-ppy-xen2ybcovn56/'],
+ 'PRZELEWY24' => ['s-p24-xen2ybcovn56', 'https://api.unzer.com/v1/types/przelewy24/s-p24-xen2ybcovn56/'],
+ 'SEPA_DIRECT_DEBIT' => ['s-sdd-xen2ybcovn56', 'https://api.unzer.com/v1/types/direct-debit/s-sdd-xen2ybcovn56/'],
'SEPA_DIRECT_DEBIT_GUARANTEED' => ['s-ddg-xen2ybcovn56', 'https://api.unzer.com/v1/types/direct-debit-guaranteed/s-ddg-xen2ybcovn56/'],
- 'SOFORT' => ['s-sft-xen2ybcovn56', 'https://api.unzer.com/v1/types/sofort/s-sft-xen2ybcovn56/'],
- 'WECHATPAY' => ['s-wcp-xen2ybcovn56', 'https://api.unzer.com/v1/types/wechatpay/s-wcp-xen2ybcovn56/']
+ 'SOFORT' => ['s-sft-xen2ybcovn56', 'https://api.unzer.com/v1/types/sofort/s-sft-xen2ybcovn56/'],
+ 'WECHATPAY' => ['s-wcp-xen2ybcovn56', 'https://api.unzer.com/v1/types/wechatpay/s-wcp-xen2ybcovn56/'],
+ 'WERO' => ['s-wro-xen2ybcovn56', 'https://api.unzer.com/v1/types/wero/s-wro-xen2ybcovn56/']
];
}
@@ -1340,10 +1437,10 @@ public function fetchResourceByUrlForAPaymentTypeShouldCallFetchPaymentTypeDP():
public function sendShouldCallSendOnHttpServiceDP(): array
{
return [
- HttpAdapterInterface::REQUEST_GET => [HttpAdapterInterface::REQUEST_GET, '/my/get/uri', true],
- HttpAdapterInterface::REQUEST_PATCH => [HttpAdapterInterface::REQUEST_PATCH, '/my/patch/uri', true],
- HttpAdapterInterface::REQUEST_POST => [HttpAdapterInterface::REQUEST_POST, '/my/post/uri', false],
- HttpAdapterInterface::REQUEST_PUT => [HttpAdapterInterface::REQUEST_PUT, '/my/put/uri', true],
+ HttpAdapterInterface::REQUEST_GET => [HttpAdapterInterface::REQUEST_GET, '/my/get/uri', true],
+ HttpAdapterInterface::REQUEST_PATCH => [HttpAdapterInterface::REQUEST_PATCH, '/my/patch/uri', true],
+ HttpAdapterInterface::REQUEST_POST => [HttpAdapterInterface::REQUEST_POST, '/my/post/uri', false],
+ HttpAdapterInterface::REQUEST_PUT => [HttpAdapterInterface::REQUEST_PUT, '/my/put/uri', true],
HttpAdapterInterface::REQUEST_DELETE => [HttpAdapterInterface::REQUEST_DELETE, '/my/delete/uri', true],
];
}
@@ -1354,7 +1451,7 @@ public function sendShouldCallSendOnHttpServiceDP(): array
public function AuthTokenShouldBeRequestedAutomaticallyDP(): array
{
return [
- HttpAdapterInterface::REQUEST_POST => [HttpAdapterInterface::REQUEST_POST, '/auth/token', false],
+ HttpAdapterInterface::REQUEST_POST => [HttpAdapterInterface::REQUEST_POST, '/auth/token', false],
];
}
@@ -1363,22 +1460,22 @@ public function AuthTokenShouldBeRequestedAutomaticallyDP(): array
*/
public function fetchShouldCallFetchResourceDP(): array
{
- $fetchPaymentCB = static function ($payment) {
+ $fetchPaymentCB = static function ($payment) {
return $payment instanceof Payment && $payment->getId() === 'myPaymentId';
};
$fetchPaymentByOrderIdCB = static function ($payment) {
return $payment instanceof Payment && $payment->getOrderId() === 'myOrderId';
};
- $fetchKeypairCB = static function ($keypair) {
+ $fetchKeypairCB = static function ($keypair) {
return $keypair instanceof Keypair;
};
- $fetchCustomerCB = static function ($customer) {
+ $fetchCustomerCB = static function ($customer) {
return $customer instanceof Customer && $customer->getId() === 'myCustomerId';
};
- $fetchMetadataCB = static function ($metadata) {
+ $fetchMetadataCB = static function ($metadata) {
return $metadata instanceof Metadata && $metadata->getId() === 's-mtd-1234';
};
- $fetchBasketCB = static function ($basket) {
+ $fetchBasketCB = static function ($basket) {
return $basket instanceof Basket && $basket->getId() === 'myBasketId';
};
@@ -1452,5 +1549,10 @@ public function fetchShouldCallFetchResourceDP(): array
];
}
- //
+ public function customerV2CreationShouldCallV2EnpointDP()
+ {
+ return [
+ 'Customer' => ['/customers', false]
+ ];
+ }
}
diff --git a/vendor/unzerdev/php-sdk/test/unit/Traits/HasAdditionalTransactionDataTest.php b/vendor/unzerdev/php-sdk/test/unit/Traits/HasAdditionalTransactionDataTest.php
index 2a926e8..9370719 100644
--- a/vendor/unzerdev/php-sdk/test/unit/Traits/HasAdditionalTransactionDataTest.php
+++ b/vendor/unzerdev/php-sdk/test/unit/Traits/HasAdditionalTransactionDataTest.php
@@ -11,9 +11,13 @@
namespace UnzerSDK\test\unit\Traits;
+use UnzerSDK\Constants\WeroAmountPaymentTypes;
+use UnzerSDK\Constants\WeroCaptureTriggers;
use UnzerSDK\Resources\EmbeddedResources\CardTransactionData;
use UnzerSDK\Resources\EmbeddedResources\RiskData;
use UnzerSDK\Resources\EmbeddedResources\ShippingData;
+use UnzerSDK\Resources\EmbeddedResources\WeroEventDependentPayment;
+use UnzerSDK\Resources\EmbeddedResources\WeroTransactionData;
use UnzerSDK\Resources\PaymentTypes\Paypal;
use UnzerSDK\test\BasePaymentTest;
@@ -110,6 +114,69 @@ public function exposeCardDataAsExpected(): void
$this->assertEquals('exemptionType', $additionalTransactionData->card['exemptionType']);
}
+ /**
+ * WeroData setters/getters should work as expected.
+ *
+ * @test
+ */
+ public function setAndGetWeroData(): void
+ {
+ $dummy = new TraitDummyHasAdditionalTransactionData();
+ $this->assertNull($dummy->getWeroTransactionData());
+
+ $edp = (new WeroEventDependentPayment())
+ ->setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false);
+
+ $weroTransactionData = (new WeroTransactionData())
+ ->setEventDependentPayment($edp);
+
+ $dummy->setWeroTransactionData($weroTransactionData);
+
+ $wero = $dummy->getWeroTransactionData();
+ $this->assertNotNull($wero);
+ $this->assertInstanceOf(WeroTransactionData::class, $wero);
+ $this->assertInstanceOf(WeroEventDependentPayment::class, $wero->getEventDependentPayment());
+ $this->assertEquals(WeroCaptureTriggers::SERVICEFULFILMENT, $wero->getEventDependentPayment()->getCaptureTrigger());
+ $this->assertEquals(WeroAmountPaymentTypes::PAY, $wero->getEventDependentPayment()->getAmountPaymentType());
+ $this->assertSame(300, $wero->getEventDependentPayment()->getMaxAuthToCaptureTime());
+ $this->assertSame(false, $wero->getEventDependentPayment()->getMultiCapturesAllowed());
+ }
+
+ /**
+ * WeroData should be exposed correctly.
+ *
+ * @test
+ */
+ public function exposeWeroDataAsExpected(): void
+ {
+ $dummy = new TraitDummyHasAdditionalTransactionData();
+ $this->assertNull($dummy->getWeroTransactionData());
+
+ $edp = (new WeroEventDependentPayment())
+ ->setCaptureTrigger(WeroCaptureTriggers::SERVICEFULFILMENT)
+ ->setAmountPaymentType(WeroAmountPaymentTypes::PAY)
+ ->setMaxAuthToCaptureTime(300)
+ ->setMultiCapturesAllowed(false);
+
+ $weroTransactionData = (new WeroTransactionData())
+ ->setEventDependentPayment($edp);
+
+ $dummy->setWeroTransactionData($weroTransactionData);
+
+ $exposedResource = $dummy->expose();
+ $this->assertNotNull($exposedResource['additionalTransactionData']);
+ $additionalTransactionData = $exposedResource['additionalTransactionData'];
+
+ $this->assertArrayHasKey('eventDependentPayment', $additionalTransactionData->wero);
+ $this->assertEquals(WeroCaptureTriggers::SERVICEFULFILMENT, $additionalTransactionData->wero['eventDependentPayment']['captureTrigger']);
+ $this->assertEquals(WeroAmountPaymentTypes::PAY, $additionalTransactionData->wero['eventDependentPayment']['amountPaymentType']);
+ $this->assertSame(300, $additionalTransactionData->wero['eventDependentPayment']['maxAuthToCaptureTime']);
+ $this->assertSame(false, $additionalTransactionData->wero['eventDependentPayment']['multiCapturesAllowed']);
+ }
+
/**
* Verify checkoutType can be set via typeId correctly.
*