diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index a4750896..00000000 --- a/.php_cs.dist +++ /dev/null @@ -1,22 +0,0 @@ -in(__DIR__); -return PhpCsFixer\Config::create() - ->setUsingCache(false) - ->setRules([ - '@PSR2' => true, - '@Symfony' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_class_elements' => true, - 'ordered_imports' => true, - 'phpdoc_order' => true, - 'phpdoc_summary' => false, - 'phpdoc_to_comment' => false, - 'phpdoc_align' => false, - 'phpdoc_var_without_name' => false, - 'blank_line_after_opening_tag' => true, - 'concat_space' => ['spacing' => 'one'], - 'array_syntax' => ['syntax' => 'short'] - ]) - ->setFinder($finder) -; \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 3ec9a1fe..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,55 +0,0 @@ -# Changelog Plentymarkets BS Payone Plugin - -## v1.0.9 (2018-04-10) -* Changed user_guide alert Text - -## v1.0.8 (2018-25-09) -* Changed Support Tab information -* Updated Changelog - -## v1.0.7 (2018-20-09) - -* Updated config.json / new Pluginformat -* Added Translations -* Changed Userguide -* Changed guzzle/httpguzzle Version in dependency for PayPal compatibility - -## v1.0.6 (2018-05-15) - -* enable Sofort display in frontend -* enable Paydirekt display in frontend -* enable invoice secure display in frontend -* enable PayPal display in frontend -* improve rendering of payment error popup - -## v1.0.5 (2018-04-06) - -* update Logos an plugin name - -## v1.0.4 (2018-03-27) - -* update documentation - -## v1.0.3 (2018-03-26) - -* add english documentation -* use current payone php api - -## v1.0.2 (2018-03-21) - -* use Scriptloader to include payone scripts in template - -## v1.0.1 (2018-03-01) - -* update plugin documentation - -## v1.0.1 (2018-03-01) - -Plugin release supporting following payment methods: - -* invoice -* pre payment -* cash on delivery -* debit payment -* credit card -* credit card 3DS \ No newline at end of file diff --git a/README.md b/README.md index 0311d481..3b4bca97 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# BS Payone plugin for plentymarkets 7 +# PAYONE plugin for plentymarkets 7 ## Plugin description and requirements @@ -9,7 +9,7 @@ See the [plugin description](./meta/documents/user_guide_de.md) for the plentyma The plugin has been developed for the Ceres template. The plugins IO and Ceres are required and have to be active. -Also, please configure your payment portal in your BS PAYONE PMI for sha2-384 hashes. The TransactionStatus URL follows this template: +Also, please configure your payment portal in your PAYONE PMI for sha2-384 hashes. The TransactionStatus URL follows this template: https://www.example.com/payone/status/ @@ -85,4 +85,4 @@ See the [changelog](./CHANGELOG.md). ## Need help? -Please contact our technical support team at +49 259 68-500 or tech.support[at]bspayone.com \ No newline at end of file +Please contact our technical support team at +49 259 68-500 or tech.support[at]bspayone.com diff --git a/build.xml b/build.xml deleted file mode 100644 index a5eb6ec4..00000000 --- a/build.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/composer.json b/composer.json index e018a1b5..364ff757 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,5 @@ "type": "git", "url": "https://github.com/plentymarkets/plugin-interface.git" } - ], - "require": { - "arvatis/payone-php-api":"2.2.*" - } + ] } diff --git a/config.json b/config.json index 3ae6bb26..af155b1d 100644 --- a/config.json +++ b/config.json @@ -63,6 +63,12 @@ } ] } + }, + "userId": { + "type": "inputText", + "required": false, + "label": "Config.userId", + "options": {} } } }, @@ -162,6 +168,18 @@ "label": "Config.PAYONEPAYONEINVOICESECUREDescriptionLabel", "options": {} }, + "PAYONE_PAYONE_INVOICE_SECURE.portalid": { + "type": "inputText", + "required": false, + "label": "Config.portalidLabel", + "options": {} + }, + "PAYONE_PAYONE_INVOICE_SECURE.key": { + "type": "inputText", + "required": false, + "label": "Config.keyLabel", + "options": {} + }, "PAYONE_PAYONE_INVOICE_SECURE.minCartAmount": { "type": "inputText", "required": false, @@ -810,29 +828,6 @@ } } } - }, - "Config.DebuggingTab": { - "label": "Config.DebuggingTab", - "formFields": { - "debugging.active": { - "type": "selectBox", - "required": false, - "label": "Config.debuggingActiveLabel", - "options": { - "defaultValue": "0", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.debuggingActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.debuggingActivePossibleValue1" - } - ] - } - } - } } } } \ No newline at end of file diff --git a/meta/documents/changelog_de.md b/meta/documents/changelog_de.md index 7268c364..5b96077f 100644 --- a/meta/documents/changelog_de.md +++ b/meta/documents/changelog_de.md @@ -1,2 +1,167 @@ -Das Changelog wird zentralisiert in [github](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/CHANGELOG.md) -gepflegt, das es sich um ein Open Source Projekt handelt. \ No newline at end of file +# Release Notes für PAYONE + +## 1.1.14 (2020-07-08) + +### Hinzugefügt +- Zahlungsart "Secure Invoice" hinzugefügt + +## 1.1.13 (2020-07-07) + +### Geändert +- Icon für das Backend hinzugefügt +- User Guide aktualisiert + +## 1.1.12 (2020-03-09) + +### Geändert +- Logging des Datenaustausches zur Payone Schnittstelle optimiert. + +## 1.1.11 (2020-03-03) + +### Geändert +- Logos und Bilder getauscht +- Funktionalitäten hinzugefügt für Backend-Sichtbarkeiten und Backend-Name + +## 1.1.10 (2019-12-09) + +### Behoben +- Auftragsnotizen bei Rückerstattungen werden nun wieder korrekt geschrieben. + +## 1.1.9 (2019-11-07) + +### Behoben +- Teilrückerstattungen können nun auch mehrfach ausgeführt werden, dies führte unter bestimmten Konstelationen zu einem Fehler. + +## 1.1.8 (2019-10-25) + +### Behoben +- Teilrückerstattungen werden nun über den korrekten Betrag ausgeführt. + +### Geändert +- Rückerstattungen werden nun dem Auftrag zugeordnet von dem diese ausgeführt wurden. +- Ladezeiten des Plugins wurden verbessert. + +## 1.1.7 (2019-09-26) + +### Hinzugefügt +- Rückzahlungen werden nun per Notiz am Auftrag hinterlegt. Dazu muss in der Konfiguration eine UserID hinterlegt werden. + +## 1.1.6 (2019-08-23) + +### Behoben +- Fehlerhafte Auftragsanlage behoben + +## 1.1.5 (2019-08-23) + +### Behoben +- Aufträge die von externe Importiert werden und eine Zahlungsart von Payone nutzen werden nun korrekt angelegt und nicht durch das Plugin abgefangen. + +## 1.1.4 (2019-08-15) + +### Geändert +- Das Payone SDK wurde umgezogen. + +### Hinzugefügt +- Die Zahlungsart Amazon Pay wurde für das Backend hinzugefügt. + +### Behoben +- Einige Meldungen im Log + +## 1.1.3 (2019-06-13) + +### Geändert +- Optimierungen für die Eingabe des Geburtsdatums im Bestellprozess. +- User Guide aktualisiert. + +## 1.1.2 (2019-05-10) + +### Geändert +- Die Eingabe des Geburtsdatums ist nun im Bestellprozess ein Pflichtfeld. Dieses Feld muss in den Einstellungen von Ceres für den Bestellprozess aktiviert werden. + +### Hinzugefügt +- Netto Bestellungen können nun durchgeführt werden. + +## 1.1.1 (2019-04-02) + +### Behoben +- Ein Fehler, der während der Zahlungsabwicklung zur Anlage von Auftragsduplikaten geführt hatte, wurde behoben +- Ein Fehler bei der Kreditkartentypauswahl wurde behoben + +## 1.1.0 (2019-03-27) + +### Geändert +- Supportübernahme durch plentysystems +- Icons getauscht und Beschreibungen aktualisiert +- Updates an den User Guides in deutscher und englischer Sprache + +## 1.0.9 (2018-04-10) + +### Geändert +- Hinweistext im User Guide ergänzt + +## 1.0.8 (2018-25-09) + +### Geändert +- Informationen im Support-Tab aktualisiert +- Changelog aktualisiert + +## 1.0.7 (2018-20-09) + +### Geändert +- Aktualisierung der config.json Datei zur Bereitstellung des neuen Plugin-Formats + +### Hinzugefügt +- Übersetzungen hinzugefügt + +### Geändert +- User Guide aktualisiert +- guzzle/httpguzzle Version hinzugefügt, um Kompatibilität mit PayPal zu erreichen + +## 1.0.6 (2018-05-15) + +### Hinzugefügt +- Die Zahlungsart Sofort wird jetzt im Frontend angezeigt +- Die Zahlungsart Paydirekt wird jetzt im Frontend angezeigt +- Die Zahlungsart Gesicherte Rechnung wird jetzt im Frontend angezeigt +- Die Zahlungsart PayPal wird jetzt im Frontend angezeigt + +### Geändert +- Verbesserte Darstellung der Popup-Meldung bei fehlerhaften Zahlungen + +## 1.0.5 (2018-04-06) + +### Geändert +- Logos und Name des Plugins aktualisiert + +## 1.0.4 (2018-03-27) + +### Geändert +- Dokumentation aktualisiert + +## 1.0.3 (2018-03-26) + +### Hinzugefügt +- Dokumentation in englischer Sprache hinzugefügt + +### Geändert +- Die aktuelle Payone PHP API wird nun genutzt + +## 1.0.2 (2018-03-21) + +### Geändert +- Scriptloader wird nun genutzt, um Payone Skripte in Templates einzubinden + +## 1.0.1 (2018-03-01) + +### Geändert +- Plugin-Dokumentation aktualisiert + +## 1.0.1 (2018-03-01) +Veröffentlichung des Plugins inklusive Unterstützung der folgenden Zahlungsarten: + +- Rechnung +- Vorkasse +- Nachnahme +- Lastschrift +- Kreditkarte +- Kreditkarte 3DS diff --git a/meta/documents/changelog_en.md b/meta/documents/changelog_en.md index f37abed3..017faac6 100644 --- a/meta/documents/changelog_en.md +++ b/meta/documents/changelog_en.md @@ -1 +1,167 @@ -The changelog will be maintained at [github](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/CHANGELOG.md). \ No newline at end of file +# Release Notes for PAYONE + +## 1.1.14 (2020-07-08) + +### Added +- Payment method "Secure Invoice" added + +## 1.1.13 (2020-07-07) + +### Changed +- Added Icon for the backend +- Updated user guide + +## 1.1.12 (2020-03-09) + +### Changed +- Optimized logging of the data transfer with the Payone Api. + +## 1.1.11 (2020-03-03) + +### Changed +- New logos and images +- Added methods for the backend visibility and backend name + +## 1.1.10 (2019-12-09) + +### Fixed +- Writing Order notes during a refund works properly again. + +## 1.1.9 (2019-11-07) + +### Fixed +- Partial refunds can now be executed more than once. Under certain constellations an error came up. + +## 1.1.8 (2019-10-25) + +### Fixed +- Partial refunds will use the correct amount from the credit note or return. + +### Changed +- Refund payments will added to the credit note or return from where they were executed. +- The loading times of the plugin have been improved. + +## 1.1.7 (2019-09-26) + +### Added +- An order note will added for refunds. Please add an user ID in the plugin configurations. + +## 1.1.6 (2019-08-23) + +### Fixed +- Fix wrong order creation + +## 1.1.5 (2019-08-23) + +### Fixed +- External orders will be created correct without skipping by the plugin. + +## 1.1.4 (2019-08-15) + +### Changed +- The Payone SDK was relocated + +### Added +- The payment method Amazon Pay was added for the backend. + +### Fixed +- Some log messages + +## 1.1.3 (2019-06-13) + +### Changed +- Optimisation for Entering the date of birth in the checkout process. +- Updated user guide + +## 1.1.2 (2019-05-10) + +### Changed +- Entering the date of birth is now mandatory in the checkout process. The field for the date of birth must be activated in the Ceres settings for the checkout process. + +### Added +- Net orders can now be executed. + +## 1.1.1 (2019-04-02) + +### Fixed +- An error causing the creation of duplicate orders during payment processing has been fixed +- An error with the credit card type selection was fixed + +## 1.1.0 (2019-03-27) + +### Changed +- Support is now within the responsibility of plentysystems +- Added new icons and customised descriptions +- Updated German and English user guides + +## 1.0.9 (2018-04-10) + +### Changed +- Added alert text to user guide + +## 1.0.8 (2018-25-09) + +### Changed +- Updated information in the support tab +- Updated changelog + +## 1.0.7 (2018-20-09) + +### Updated +- Updated the config.json file to implement new plugin format + +### Added +- Added translations + +### Changed +- Updated user guide +- Implemented guzzle/httpguzzle version in dependency for PayPal compatibility + +## 1.0.6 (2018-05-15) + +### Added +- Sofort is now displayed in the front end +- Paydirekt is now displayed in the front end +- Secure invoice is now displayed in the front end +- PayPal is now displayed in the front end + +### Changed +- Improved rendering of payment error message + +## 1.0.5 (2018-04-06) + +### Changed +- Updated logos and plugin name + +## 1.0.4 (2018-03-27) + +### Changed +- Updated documentation + +## 1.0.3 (2018-03-26) + +### Added +- Added English documentation + +### Changed +- The current Payone PHP API is now used + +## 1.0.2 (2018-03-21) + +### Changed +- Scriptloader is now used to include Payone scripts in templates + +## 1.0.1 (2018-03-01) + +### Changed +- Update plugin documentation + +## 1.0.1 (2018-03-01) +Plugin release supporting the following payment methods: + +- Invoice +- Prepayment +- Cash on delivery +- Debit payment +- Credit card +- Credit card 3DS diff --git a/meta/documents/icon_plugin_md.png b/meta/documents/icon_plugin_md.png deleted file mode 100644 index 1b7f03f6..00000000 Binary files a/meta/documents/icon_plugin_md.png and /dev/null differ diff --git a/meta/documents/support_contact_de.md b/meta/documents/support_contact_de.md index 3d344521..638557f3 100644 --- a/meta/documents/support_contact_de.md +++ b/meta/documents/support_contact_de.md @@ -1,5 +1,3 @@ -## Support +## Webseite -Zwischen arvatis media und Payone besteht für dieses Plugin keine Support- und Wartungsvereinbarung. -Bitte wenden Sie sich bei Fragem oder Problemen direkt an [Payone](https://www.bspayone.com/DE/de/contact-germany), -über E-Mail [tech.support@bspayone.com](mailto:tech.support@bspayone.com) oder Telefon [+49 431 25968-500](tel:+49 431 25968-500). \ No newline at end of file +[https://www.plentymarkets.eu/](https://www.plentymarkets.eu/) \ No newline at end of file diff --git a/meta/documents/support_contact_en.md b/meta/documents/support_contact_en.md index 6f146ef0..00c81cc2 100644 --- a/meta/documents/support_contact_en.md +++ b/meta/documents/support_contact_en.md @@ -1,5 +1,3 @@ -## Support +## Web page -arvatis media and Payone have no Support- and Maintenancecontract. -Please contact [Payone](https://www.bspayone.com/DE/en/contact-germany) if you experience any Problems or have a Question. -Or contact Payone via E-Mail [tech.support@bspayone.com](mailto:tech.support@bspayone.com) or Phone: [+49 431 25968-500](tel:+49 431 25968-500). \ No newline at end of file +[https://www.plentymarkets.co.uk/](https://www.plentymarkets.co.uk/) \ No newline at end of file diff --git a/meta/documents/user_guide_de.md b/meta/documents/user_guide_de.md index a67bd89f..bb90bdc7 100644 --- a/meta/documents/user_guide_de.md +++ b/meta/documents/user_guide_de.md @@ -1,34 +1,433 @@ -# BS PAYONE Payment für plentymarkets 7 + -**Hinweis: Für den Alleinvertrieb, innerhalb Plentymarkets System, ist die PSG Projektmanagement GmbH zuständig. [Hier geht’s zum Anmeldeformular](https://www.psg-projektmanagement.de/bs-payone/)** +# PAYONE Payment für plentymarkets -Payment mit BS PAYONE überzeugt +Das plentymarkets PAYONE Plugin bietet Zugang zu internationalen und lokalen Zahlungsarten. Gleichzeitig hast du Zugriff auf ein integriertes Risikomanagement, automatisierte Gutschriften und schnelle Retourenabwicklung. -Eine Lösung, ein Partner, ein Vertrag: Einfach & effizient. Technische Abwicklung und Finanzdienstleistungen aus einer Hand. +Aktuell beinhaltet das Plugin die folgenden Zahlungsarten: -* Internationale Zahlungsabwicklung: Zugang zu internationalen und lokalen Zahlungsarten on demand. +* Gesicherter Rechnungskauf +* Visa & MasterCard (inkl. Maestro) +* American Express - Anbindung Ihres bestehenden Akzeptanzvertrages +* SEPA Lastschrift +* giropay - Online-Überweisung Deutschland +* Sofortüberweisung - Online-Überweisung international +* Überweisung - Vorkasse & Rechnung & Nachnahme +* PayPal - Anbindung Ihres PayPal-Accounts +* Amazon Pay - Anbindung Ihres Amazon Pay-Accounts (In Kürze verfügbar!) -* Integriertes Risikomanagement: Minimierung von Zahlungsausfällen und Betrug. Für mehr Profitabilität. +## Erste Schritte -* Automatisches Debitorenmanagement: Effektive Entlastung der Buchhaltung durch Transaktionszuordnung und Kontenabgleich. +Für die Nutzung benötigst du einen PAYONE Account und die PAYONE Zugangsdaten. Wenn du noch kein PAYONE Kunde bist und demnach keinen PAYONE Account besitzt, wende dich bitte an: -* Zahlungsartenübergreifende Gutschriften: Schnelles Retourenmanagement. Mit automatisierten Gutschriften. +PSG Projektmanagement GmbH
+Meergässle 4
+89180 Berghülen
+Telefon: 07344-9592588
+E-Mail: plenty@psg-projektmanagement.de
+Internet: http://www.psg-projektmanagement.de
+Oder nutze folgendes Anmeldeformular
+https://www.psg-projektmanagement.de/payone-plentymarkets/ -* Beste Referenzen, langjährige Erfahrung: Ausgewiesene Experten. Persönlicher Kundenservice. Bei jedem E-Commerce-Projekt. + -## Aktuell unterstützte Zahlarten +Nach Erhalt der Zugangsdaten loggst du dich im PAYONE Merchant Interface ein und nimmst die folgenden Einstellungen vor. -* Rechnung -* Vorkasse -* Nachnahme -* Lastschrift -* Kreditkarte -* Kreditkarte 3DS -* Gesicherte Rechnung -* PayPal -* Paydirekt -* Sofortüberweisung +##### Einstellungen im PAYONE Merchant Interface vornehmen: -## Installationsanleitung +1. Öffne das Menü **Konfiguration » Zahlungsportale**. +2. Öffne das Tab **Erweitert** des Zahlungsportals deines Shops. +3. Trage im Feld **TransactionStatusURL** eine URL nach dem Schema **DOMAIN/payment/payone/status** ein. Den Platzhalter **DOMAIN** durch die URL zu deinem Webshop ersetzen. +4. Wähle als **Verfahren Hashwert-Prüfung** die Option **md5 oder sha2-384 (für Migration)**. +5. **Speichere** die Einstellungen. -[Hinweise zur Installation und Einrichtung](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/README.md) \ No newline at end of file +Aktiviere die gewünschten PAYONE-Zahlungsarten in deinem plentymarkets Backend einmalig im Menü **Einrichtung » Aufträge » Zahlung » Zahlungsarten**. Weitere Informationen dazu findest du auf der Handbuchseite Zahlungsarten verwalten . + +Stelle zudem sicher, dass die Zahlungsart unter dem Punkt **Erlaubte Zahlungsarten** in den Kundenklassen vorhanden ist und nicht im Bereich **Gesperrte Zahlungsarten** in den Versandprofilen aufgeführt ist. + +## Einrichtung des Plugins + +Die folgenden Einrichtungsschritte für das plentymarkets PAYONE Plugin erfolgen direkt in der Plugin-Übersicht deines plentymarkets-Systems. Gehe dazu wie im Folgenden beschrieben vor. + +##### Grundeinstellungen vornehmen: + +1. Öffne das Menü **Plugins » Plugin-Übersicht**. +2. Klicke in der Liste der Plugins auf den Namen des Plugins **PAYONE**. +→ Die Detailansicht des Plugins öffnet sich. +3. Öffne den Menüpunkt **Konfiguration**. +4. Klicke auf **Grundeinstellungen**. Nimm die Einstellungen anhand der Informationen in Tabelle 1 vor. +5. **Speichere** die Einstellungen. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 1: Grundeinstellungen vornehmen
+ Einstellung + + Erläuterung +
+ Merchant ID + + Gib hier die Kundennummer ein, die du bei der Registrierung bei PAYONE erhalten hast. +
+ Portal ID + + Gib hier die ID des Zahlungsportals ein, die du bei der Registrierung bei PAYONE erhalten hast. +
+ Account ID + + Gib hier die Account-ID ein, die du bei der Registrierung bei PAYONE erhalten hast. +
+ Schlüssel + + Gib hier den Schlüssel ein, den du bei der Registrierung bei PAYONE erhalten hast. +
+ Modus + + Wähle zwischen den Optionen Test und Live. Wir empfehlen, während der Einrichtung des Plugins den Testmodus zu wählen. Währenddessen ist die Zahlungsart noch nicht in deinem Webshop verfügbar. Nach erfolgter Einrichtung wechsele in den Livemodus und mach somit die Zahlungsart in deinem Webshop sichtbar. +
+ Art der Autorisierung + + Vorautorisierung: Wähle diese Option, wenn der Zahlungseinzug beim Käufer nur vorgemerkt werden soll. Der Zahlungseinzug erfolgt dann durch eine Ereignisaktion, die beim Warenausgang ausgelöst werden muss (siehe Tabelle 5).
+ Autorisierung:: Wähle diese Option, wenn der Zahlungseinzug beim Käufer sofort stattfinden soll. Der Zahlungseingang wird somit direkt nach dem Kaufabschluss im Webshop in deinem plentymarkets-System gebucht. +
+ +### Zahlungsarten einrichten + +Im Folgenden legst du fest, welche PAYONE-Zahlungsarten deinen Kunden im Webshop zur Verfügung stehen sollen. Außerdem nimmst du für die festgelegten Zahlungsarten genauere Einstellungen vor. Gehe dazu wie im Folgenden beschrieben vor. + + +##### Zahlungsarten einrichten: + +1. Öffne den Menüpunkt **Konfiguration** in der Detailansicht des Plugins. +2. Klicke auf den Menüpunkt der Zahlungsart. Nimm die Einstellungen anhand der Informationen in Tabelle 2 vor. +5. **Speichere** die Einstellungen. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 2: Zahlungsarten einrichten
+ Einstellung + + Erläuterung +
+ Aktiv + + Wähle die Option Ja, um die Zahlungsart zu aktivieren und somit im Webshop anzubieten.
Wähle die Option Nein, wenn die Zahlungsart deaktiviert werden und damit nicht zur Verfügung stehen soll. +
+ Name + + Gib einen Namen für die Zahlungsart ein. Dieser Name ist für deine Kunden im Webshop sichtbar. +
+ Beschreibung + + Gib einen Beschreibungstext für die Zahlungsart ein. Dieser Text ist für deine Kunden im Webshop sichtbar. +
+ Minimaler Bestellwert + + Gib einen minimalen Bestellwert ein, ab dem die Zahlungsart im Webshop verfügbar sein soll. +
+ Maximaler Bestellwert + + Gib einen maximalen Bestellwert ein, bis zu dem die Zahlungsart im Webshop verfügbar sein soll. Wird dieser Wert überschritten, ist die Zahlungsart nicht mehr verfügbar. +
+ Erlaubte Lieferländer + + Gib kommasepariert die Lieferländer aus, für die die Zahlungsart verfügbar sein soll. +
+ +**Hinweis**: Die Zahlungsart **Kreditkarte** stellt einen Sonderfall dar. Für diese Zahlungsart sind zusätzliche Einstellungen notwendig. Diese Einstellungen werden in Tabelle 3 beschrieben. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 3: Zahlungsart Kreditkarte einrichten
+ Einstellung + + Erläuterung +
+ Minimale Kartengültigkeit in Tagen + + Gib die erforderliche minimale Kartengültigkeit an, über die eine Kreditkarte verfügen muss, um für die Zahlungsart akzeptiert zu werden. +
+ Kreditkartenfelder Default Style + + Standardmäßig ist hier voreingestellt, in welcher Farbe, Schriftgröße und Schriftart die Eingabefelder für die Kreditkartendaten für Kunden im Webshop angezeigt werden. Die Werte sind editierbar. +
+ Kreditkartenfelder Höhe in px + + Standardmäßig ist hier die Höhe der Eingabefelder in px voreingestellt. Der Wert ist editierbar. +
+ Kreditkartenfelder Breite in px + + Standardmäßig ist hier die Breite der Eingabefelder in px voreingestellt. Der Wert ist editierbar. +
+ Erlaubte Kartentypen + + Aktiviere die Kartentypen, die für die Zahlungsart akzeptiert werden sollen. +
+ +**Hinweis**: Für die Zahlungsart **Gesicherter Rechnungskauf** sind eine eigene **Portal-ID** sowie ein eigener **Schlüssel** notwendig. Diese Portal-ID und dieser Schlüssel müssen im Plugin unter **Gesicherte Rechnung** bei der Konfiguration separat hinterlegt werden. Die Portal-ID und den Schlüssel erhältst du über das PAYONE Merchant Interface über das Menü **Konfiguration » Zahlungsportale**. + +## Ceres-Checkout anpassen + +Als Nächstes ist eine Anpassung im Ceres Checkout notwendig, damit deine Kunden bei Bezahlvorgängen mit PAYONE ihr Geburtsdatum (nur für den gesicherten Rechnungskauf) korrekt eingeben können. + + + +##### Ceres-Checkout anpassen für den gesicherten Rechnungskauf: + +1. Öffne das Menü **Plugins » Plugin-Übersicht**.
+→ Die Plugin-Übersicht wird geöffnet. +2. Klicke auf **Ceres**.
+→ Das Plugin wird geöffnet. +3. Klicke im Verzeichnisbaum auf **Konfiguration**. +4. Wechsele in das Tab **Kaufabwicklung und Mein Konto.** +5. Klappe den Bereich **Rechnungsadressfelder im Adressformular anzeigen (DE)** auf. +6. Aktiviere über die Checkbox die Option **Geburtsdatum**. +7. **Speichere** die Einstellungen.
Im Checkout wird deinen Kunden nun ein Feld zur Eingabe des Geburtsdatums angezeigt. + +## Template-Container verknüpfen + +Für die Zahlungsart PAYONE stehen dir verschiedene Möglichkeiten zur Verfügung, um sie in deinem Webshop einzubinden. +Hierfür sind in den Templates in plentymarkets an relevanten Stellen Container hinterlegt, mit denen zur Individualisierung Contents verknüpft werden. + +##### Container verknüpfen: + +1. Öffne das Menü **Plugins » Plugin-Set-Übersicht**. +2. Öffne das Plugin-Set, das du bearbeiten möchtest. +3. Öffne die **Einstellungen** des Payone-Plugins. +4. Klicke auf **Container-Verknüpfungen**. +5. Wähle aus der Dropdown-Liste den Datenanbieter aus, den du verknüpfen möchtest. +6. Wähle den Container aus, mit dem du den Datenanbieter verknüpfen möchtest. Beachte dazu die Erläuterungen in Tabelle 4. +7. Wiederhole Schritte 5 und 6 für alle Datenanbieter, die due verknüpfen möchtest. +8. **Speichere** die Einstellungen. + + + + + + + + + + + + + + + + + +
Tab. 4: Container verknüpfen
+ Content + + Erläuterung +
+ Payone Order Confirmation Page Payment Data + + Verknüpfe diesen Content mit dem Container Order confirmation: Additional payment information, um die PAYONE-Zahlungsarten auf der Bestellbestätigungsseite im Webshop anzuzeigen. +
+ Payone Checkout JS + + Verknüpfe diesen Content mit dem Container Script loader: After script loaded, um die PAYONE-Zahlungsarten während der Kaufabwicklung im Webshop anzuzeigen. +
+ +## Automatische Versandbestätigung an PAYONE senden + +Richte eine Ereignisaktion ein, um eine automatische Versandbestätigung an PAYONE zu senden, sobald du den Auftrag versendet hast. + +**Hinweis:** Die Einrichtung dieser Ereignisaktion ist zwingend notwendig, wenn als **Art der Autorisierung** die Option **Vorautorisierung** gewählt wurde (siehe Tabelle 1). Hast du die Option **Autorisierung** gewählt, ist diese Ereignisaktion nicht nutzbar und nicht notwendig. + +##### Ereignisaktion einrichten: + +1. Öffne das Menü **System » Aufträge » Ereignisaktionen**. +2. Klicke auf **Ereignisaktion hinzufügen**.
+→ Das Fenster **Neue Ereignisaktion erstellen** wird geöffnet. +3. Gib einen Namen ein. +4. Wähle das Ereignis gemäß Tabelle 5. +5. **Speichere** die Einstellungen.
+→ Die Ereignisaktion wird angelegt. +6. Nimm die weiteren Einstellungen gemäß Tabelle 5 vor. +7. Setze ein Häkchen bei **Aktiv**. +8. **Speichere** die Einstellungen.
+→ Die Ereignisaktion wird gespeichert. + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tab. 5: Ereignisaktion zum Senden einer automatischen Versandbestätigung an PAYONE +
+ Einstellung + + Option + + Auswahl +
EreignisDas Ereignis wählen, nach dem die Versandbestätigung automatisch versendet werden soll, beispielsweise Auftragsänderung > Warenausgang gebucht
Filter 1Auftrag > ZahlungsartPlugin: PAYONE +
AktionPlugin > PAYONE | Versandbestätigung senden
+ +## PAYONE-Zahlung automatisch zurückzahlen + +Richte eine Ereignisaktion ein, um die Rückzahlung einer Zahlung über PAYONE zu automatisieren. + +##### Ereignisaktion einrichten: + +1. Öffne das Menü **System » Aufträge » Ereignisaktionen**. +2. Klicke auf **Ereignisaktion hinzufügen**.
+→ Das Fenster **Neue Ereignisaktion erstellen** wird geöffnet. +3. Gib einen Namen ein. +4. Wähle das Ereignis gemäß Tabelle 6. +5. **Speichere** die Einstellungen.
+→ Die Ereignisaktion wird angelegt. +6. Nimm die weiteren Einstellungen gemäß Tabelle 6 vor. +7. Setze ein Häkchen bei **Aktiv**. +8. **Speichere** die Einstellungen.
+→ Die Ereignisaktion wird gespeichert. + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tab. 6: Ereignisaktion zur automatischen Rückzahlung der PAYONE-Zahlung +
+ Einstellung + + Option + + Auswahl +
EreignisDas Ereignis wählen, nach dem eine Rückzahlung erfolgen soll.
Filter 1Auftrag > ZahlungsartPlugin: PAYONE +
AktionPlugin > PAYONE | Rückerstattung senden
diff --git a/meta/documents/user_guide_en.md b/meta/documents/user_guide_en.md index cf13377e..3f2971b4 100644 --- a/meta/documents/user_guide_en.md +++ b/meta/documents/user_guide_en.md @@ -1,35 +1,431 @@ -# BS PAYONE Payment for plentymarkets 7 + -**Hinweis: The Distribution in Plentymarkets system is controlled by PSG Projektmanagement GmbH. [Click here for Registration](https://www.psg-projektmanagement.de/bs-payone/)** +# PAYONE Payment for plentymarkets -Payment with BS PAYONE convinces +The plentymarkets PAYONE plugin offers you access to international as well as local payment methods. In addition, the plugin offers the advantages of an integrated risk management system, automated refunds and swift processing of returns. -One solution, one partner, one contract: simple & efficient. Technical handling and financial services from a single -source. +The plugin currently offers the following payment methods: -* International payment processing: access to international and local payment methods on demand. +* Secure Invoice +* Visa & MasterCard (incl. Maestro) +* American Express - Integration of your existing acceptance contract +* SEPA direct debit +* giropay - online bank transfer Germany +* Sofortüberweisung - Online bank transfer international +* Transfer - Cash in advance & Invoice & Cash on Delivery +* PayPal - Integration of your PayPal account +* Amazon Pay - Integration of your Amazon Pay accounts (Available soon!) -* Integrated risk management: minimizing defaults and fraud. For more profitability. +## First steps -* Automatic Debtor Management: Effectively relieving the bookkeeping through transaction assignment and account reconciliation. +The use requires a PAYONE account as well as PAYONE access data. If you are not a PAYONE customer yet and thus do not have a PAYONE account, please contact: -* Multi-payment refunds: Fast returns management. With automated refunds. +PSG Projektmanagement GmbH
+Meergässle 4
+89180 Berghülen
+Phone: 07344-9592588
+E-mail: plenty@psg-projektmanagement.de
+Website: http://www.psg-projektmanagement.de
+Or use the following registration form:
+https://www.psg-projektmanagement.de/payone-plentymarkets/ -* Best references, many years of experience: proven experts. Personal customer service. For every e-commerce project. + -## Currently supported payment methods +Upon receipt of your access data, log in to the PAYONE merchant interface and carry out the following settings. -* invoice -* pre payment -* cash on delivery -* debit payment -* credit card -* credit card 3DS -* invoice secure -* PayPal -* Paydirekt -* Sofortüberweisung +##### Carrying out settings in the PAYONE merchant interface -## Installation guide +1. Go to **Configuration » Payment portals**. +2. Open the **Extended Tab** of the payment portal belonging to your online store. +3. In the field **TransactionStatusURL**, enter a URL following the pattern **DOMAIN/payment/payone/status**. Replace **DOMAIN** with the URL of your online store. +4. For the option **Method hash calculation**, select the option **md5 or sha2-384 (during migration)**. +5. **Save** the settings. -[Information for installation and setup](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/README.md) \ No newline at end of file +In your plentymarkets back end, activate the payment method once in the **Setup » Orders » Payment » Methods** menu. More information on carrying out this setting is available on the Managing payment methods page of the manual. + +In addition, make sure that the payment method is included among the Permitted payment methods in the customer classes and that it is not listed among the Blocked payment methods in the shipping profiles. + +## Setting up the plugin + +The following steps for setting up the plentymarkets PAYONE plugin are carried out in the plugin overview of your plentymarkets system. Proceed as described below to set up the plugin. + +##### Carrying out the basic settings + +1. Go to **Plugin » Plugin overview**. +2. In the plugin list, click on the name of the plugin **PAYONE**.
+→ The detail view of the plugin opens. +3. Open the menu entry **Configuration**. +4. Click on **Basic settings**. Carry out the settings according to the information provided in table 1. +5. **Save** the settings. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 1: Carrying out the basic settings
+ Setting + + Explanation +
+ Merchant ID + + Enter the customer number as received after the registration process with PAYONE. +
+ Portal ID + + Enter the payment portal ID as received after the registration process with PAYONE. +
+ Account ID + + Enter the account ID as received after the registration process with PAYONE. +
+ Key + + Enter the key as received after the registration process with PAYONE. +
+ Mode + + Select one of the options Test and Live. We recommend using the test mode while setting up the plugin. The test mode ensures that the payment method is not available in your online store during the setup process. After completing the setup of the plugin, select the live mode so that the payment method becomes visible in your online store. +
+ Authorisation method + + Preauthorisation: Select this option if payment collection should only be prepared for the customer. The definite collection of payment has to be effected by an event procedure that should be triggered by booking outgoing items (see table 5).
+ Authorisation: Select this option if the payment should be collected from the customer immediately. Incoming payment is then booked directly after the customer has completed the checkout process in the online store. +
+ +### Setting up payment methods + +In the following, you select the PAYONE payment methods that should be available for your customers in the online store. In addition, you carry out more detailed settings for the selected payment methods. Proceed as described below. + + +##### Setting up payment methods: + +1. Open the menu entry **Configuration** in the detail view of the plugin. +2. Click on the menu entry of the payment method. Carry out the settings according to the information provided in table 2. +5. **Save** the settings. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 2: Setting up payment methods
+ Setting + + Explanation +
+ Active + + Select the option Yes to activate the payment method and thus offer it in the online store.
Select the option No if the payment method should be deactivated and thus not be available. +
+ Name + + Enter a name for the payment method. This name is visible for your customers in the online store. +
+ Description + + Enter a description for the payment method. This text is visible for your customers in the online store. +
+ Minimum order value + + Enter a minimum order value for which the payment method should be available in the online store. +
+ Maximum order value + + Enter a maximum order value for which the payment method should be available in the online store. The payment method is not available for orders exceeding this value. +
+ Allowed countries of delivery + + Enter the countries of delivery (separated by a comma) for which the payment method should be available. +
+ +**Note:** The payment method **Credit card** requires particular attention. Additional settings are necessary for this payment method. The settings are described in table 3. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tab. 3: Setting up the payment method Credit card
+ Setting + + Explanation +
+ Minimum card validity in days + + Enter the required minimum card validity in days that a credit card must have to be accepted for the payment method. +
+ Credit card fields default style + + Default settings are saved for the colour, font size and font used for the data fields into which customers enter their credit card data in the online store. The values are editable. +
+ Credit card fields height in px + + The height of the data fields in px is set by default. The value is editable. +
+ Credit card fields width in px + + The width of the data fields in px is set by default. The value is editable. +
+ Allowed card types + + Activate the card types that should be accepted for the payment method. +
+ +**Note**: You need a separate **Portal ID** and **Key** for the payment method **Secure Invoice**. This Portal-ID and this key have to be deposited in the plugin while configuring it. You get the Portal ID and the Key via the PAYONE Merchant Interface in the **Configuration » Payment portals** menu. + +## Adjusting the Ceres checkout + +In the next step, an adjustment to your Ceres checkout settings is necessary. These adjustments need to be made so that customers using PAYONE for payment processes can enter their date of birth (for secure invoice only) correctly. + + + +##### Adjusting the Ceres checkout for secure invoice: + +1. Go to **Plugins » Plugin overview**.
+→ The plugin overview opens. +2. Click on **Ceres**.
+→ The plugin opens. +3. Click on **Configuration** in the directory tree. +4. Click on the **Checkout and My account** tab. +5. Open the **Show invoice address fields in the address form (DE)** area. +6. Use the check box to activate the option **Date of birth**. +7. **Save** the settings.
A field for entering the date of birth is now displayed for your customers in the checkout area. + +## Linking template containers + +You have multiple options to integrate the payment method PAYONE into your online store. For this purpose, the plentymarkets system offers containers at relevant places which can be filled with content to meet your needs. + +##### Linking template containers: + +1. Go to Plugins » Plugin set overview. +2. Open the plugin set you want to edit. +3. Open the Settings of the Payone plugin. +4. Click on Container links. +5. From the drop-down list, select the data provider you want to link. +6. Select the container you want to link the data provider to. Pay attention to the information provided in table 4. +7. Repeat steps 5 and 6 for all data providers you want to link. +8. Save the settings. + + + + + + + + + + + + + + + + + +
Tab. 4: Linking template containers
+ Content + + Explanation +
+ Payone Order Confirmation Page Payment Data + + Link this content to the container Order confirmation: Additional payment information to display the PAYONE payment methods on the order confirmation page in the online store. +
+ Payone Checkout JS + + Link this content to the container Script loader: After script loaded to display the PAYONE payment methods during the checkout process in the online store. +
+ +## Sending an automatic shipping confirmation to PAYONE + +Set up an event procedure to send an automatic shipping confirmation to PAYONE as soon as you have shipped the order. + +**Note:** Sending up the following event procedure is mandatory if you have selected the option **Preauthorisation** as **Authorisation method** (see table 1). This event procedure is not necessary and cannot be used if you have selected the option **Authorisation**. + +##### Setting up an event procedure: + +1. Go to **System » Orders » Events**. +2. Click on **Add event procedure**.
+→ The **Create new event procedure** window opens. +3. Enter a name. +4. Select the event according to table 5. +5. **Save** the settings.
+→ The event procedure is created. +6. Carry out the further settings according to table 5. +7. Place a check mark next to the option **Active**. +8. **Save** the settings.
+→ The event procedure is saved. + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tab. 5: Event procedure for sending an automatic shipping confirmation to PAYONE +
+ Setting + + Option + + Selection +
EventSelect the event after which an automatic shipping confirmation should be sent, e.g. Order change > Outgoing items booked
Filter 1Order > Payment methodPlugin: PAYONE +
ProcedurePlugins > Payone | Refund order
+ +## Automatically refunding PAYONE payments + +Set up an event procedure to automatically refund a PAYONE payment. + +##### Setting up an event procedure: + +1. Go to **System » Orders » Events**. +2. Click on **Add event procedure**.
+→ The **Create new event procedure** window opens. +3. Enter a name. +4. Select the event according to table 6. +5. **Save** the settings.
+→ The event procedure is created. +6. Carry out the further settings according to table 6. +7. Place a check mark next to the option **Active**. +8. **Save** the settings.
+→ The event procedure is saved. + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tab. 6: Event procedure for automatically refunding PAYONE payments +
+ Setting + + Option + + Selection +
EventSelect the event to trigger a refund.
Filter 1Order > Payment methodPlugin: PAYONE +
ProcedurePlugins > Payone | Refund order
diff --git a/meta/images/icon_author_md.png b/meta/images/icon_author_md.png old mode 100644 new mode 100755 index 7c3277b7..99a33d11 Binary files a/meta/images/icon_author_md.png and b/meta/images/icon_author_md.png differ diff --git a/meta/images/icon_author_sm.png b/meta/images/icon_author_sm.png old mode 100644 new mode 100755 index 7c3277b7..d94932fb Binary files a/meta/images/icon_author_sm.png and b/meta/images/icon_author_sm.png differ diff --git a/meta/images/icon_author_xs.png b/meta/images/icon_author_xs.png old mode 100644 new mode 100755 index 7c3277b7..fd433ff1 Binary files a/meta/images/icon_author_xs.png and b/meta/images/icon_author_xs.png differ diff --git a/meta/images/icon_plugin_md.png b/meta/images/icon_plugin_md.png index b403b32d..e3d9ea86 100644 Binary files a/meta/images/icon_plugin_md.png and b/meta/images/icon_plugin_md.png differ diff --git a/meta/images/icon_plugin_sm.png b/meta/images/icon_plugin_sm.png index 34fb3075..cc77f3e3 100644 Binary files a/meta/images/icon_plugin_sm.png and b/meta/images/icon_plugin_sm.png differ diff --git a/meta/images/icon_plugin_xs.png b/meta/images/icon_plugin_xs.png index 1df41e41..cf8ba97d 100644 Binary files a/meta/images/icon_plugin_xs.png and b/meta/images/icon_plugin_xs.png differ diff --git a/meta/images/logos/payone_payone_amazon_pay_backend_icon.svg b/meta/images/logos/payone_payone_amazon_pay_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_amazon_pay_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_cash_on_delivery_backend_icon.svg b/meta/images/logos/payone_payone_cash_on_delivery_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_cash_on_delivery_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_credit_card_backend_icon.svg b/meta/images/logos/payone_payone_credit_card_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_credit_card_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_direct_debit_backend_icon.svg b/meta/images/logos/payone_payone_direct_debit_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_direct_debit_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_invoice_backend_icon.svg b/meta/images/logos/payone_payone_invoice_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_invoice_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_invoice_secure_backend_icon.svg b/meta/images/logos/payone_payone_invoice_secure_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_invoice_secure_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_pay_pal_backend_icon.svg b/meta/images/logos/payone_payone_pay_pal_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_pay_pal_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_paydirekt_backend_icon.svg b/meta/images/logos/payone_payone_paydirekt_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_paydirekt_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_payolution_installment_backend_icon.svg b/meta/images/logos/payone_payone_payolution_installment_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_payolution_installment_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_pre_payment_backend_icon.svg b/meta/images/logos/payone_payone_pre_payment_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_pre_payment_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_ratepay_installment_backend_icon.svg b/meta/images/logos/payone_payone_ratepay_installment_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_ratepay_installment_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/logos/payone_payone_sofort_backend_icon.svg b/meta/images/logos/payone_payone_sofort_backend_icon.svg new file mode 100644 index 00000000..0e047987 --- /dev/null +++ b/meta/images/logos/payone_payone_sofort_backend_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/meta/images/preview_0.png b/meta/images/preview_0.png index dfb3799b..dd72eb49 100644 Binary files a/meta/images/preview_0.png and b/meta/images/preview_0.png differ diff --git a/phpunit.ini.dist b/phpunit.ini.dist deleted file mode 100644 index 7fc9a4e9..00000000 --- a/phpunit.ini.dist +++ /dev/null @@ -1,5 +0,0 @@ -[api_context] -aid = ;your_account_id -mid = ;your_merchant_id -portalid = -key = \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 2ca8063f..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - ./resources/lib/Tests/* - - - - - src - - - - - - - - - - \ No newline at end of file diff --git a/plugin.json b/plugin.json index b2e35e01..df3f69f3 100644 --- a/plugin.json +++ b/plugin.json @@ -1,32 +1,36 @@ { - "version": "1.0.9", + "version": "1.1.14", "license":"MIT", "pluginIcon":"icon_plugin_xs.png", "price":0.0, "authorIcon":"icon_author_xs.png", "name": "Payone", - "marketplaceName" : {"de":"BS Payone","en":"BS Payone"}, + "marketplaceName" : {"de":"PAYONE","en":"PAYONE"}, "shortDescription": { - "de": "Das offizielle Payone plugin für Plentymarkets 7. Das Payone Plugin setzt einen Checkout-Prozess auf Basis von Ceres voraus.", - "en": "The official Payone plugin for plentymarkets" + "de": "Das offizielle Payone plugin für plentymarkets Webshops. Das Payone Plugin setzt einen Checkout-Prozess auf Basis von Ceres voraus.", + "en": "The official Payone plugin for plentymarkets online stores" }, "description": "The official Payone plugin for plentymarkets", - "author": "arvatis media GmbH", + "author": "plentysystems AG", + "email": "sales@plentymarkets.com", + "phone": "+49 561 98 681 100", "keywords": ["Payone", "plentymarkets", "payment"], - "email": "info@arvatis.com", - "phone": "+49 (0)211 - 63 55 31 60", "categories": [3519], "type": "payment", "namespace": "Payone", "javaScriptFiles": [], "containers": [], - "require": [], - "serviceProvider": "Payone\\Providers\\PayoneServiceProvider", + "require": ["IO"], "dependencies":{ - "arvatis/payone-php-api":"2.2.*" + "guzzlehttp/guzzle": "6.*", + "symfony/serializer": "3.2.7", + "symfony/property-access": "3.2.7", + "doctrine/common": "2.7.2" }, + "serviceProvider": "Payone\\Providers\\PayoneServiceProvider", "runOnBuild": [ - "Payone\\Migrations\\CreatePaymentMethods" + "Payone\\Migrations\\CreatePaymentMethods", + "Payone\\Migrations\\CreateAmazonPayPaymentMethod" ], "dataProviders": [ { diff --git a/resources/images/logos/PAYONE_PAYONE_CASH_ON_DELIVERY.png b/resources/images/logos/PAYONE_PAYONE_CASH_ON_DELIVERY.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_CASH_ON_DELIVERY.png and b/resources/images/logos/PAYONE_PAYONE_CASH_ON_DELIVERY.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_CREDIT_CARD.png b/resources/images/logos/PAYONE_PAYONE_CREDIT_CARD.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_CREDIT_CARD.png and b/resources/images/logos/PAYONE_PAYONE_CREDIT_CARD.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_DIRECT_DEBIT.png b/resources/images/logos/PAYONE_PAYONE_DIRECT_DEBIT.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_DIRECT_DEBIT.png and b/resources/images/logos/PAYONE_PAYONE_DIRECT_DEBIT.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_INVOICE.png b/resources/images/logos/PAYONE_PAYONE_INVOICE.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_INVOICE.png and b/resources/images/logos/PAYONE_PAYONE_INVOICE.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_INVOICE_SECURE.png b/resources/images/logos/PAYONE_PAYONE_INVOICE_SECURE.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_INVOICE_SECURE.png and b/resources/images/logos/PAYONE_PAYONE_INVOICE_SECURE.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_PAYDIREKT.png b/resources/images/logos/PAYONE_PAYONE_PAYDIREKT.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_PAYDIREKT.png and b/resources/images/logos/PAYONE_PAYONE_PAYDIREKT.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_PAY_PAL.png b/resources/images/logos/PAYONE_PAYONE_PAY_PAL.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_PAY_PAL.png and b/resources/images/logos/PAYONE_PAYONE_PAY_PAL.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_PRE_PAYMENT.png b/resources/images/logos/PAYONE_PAYONE_PRE_PAYMENT.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_PRE_PAYMENT.png and b/resources/images/logos/PAYONE_PAYONE_PRE_PAYMENT.png differ diff --git a/resources/images/logos/PAYONE_PAYONE_SOFORT.png b/resources/images/logos/PAYONE_PAYONE_SOFORT.png index 3a4d04e1..f7055f2c 100644 Binary files a/resources/images/logos/PAYONE_PAYONE_SOFORT.png and b/resources/images/logos/PAYONE_PAYONE_SOFORT.png differ diff --git a/resources/lang/de/Api.properties b/resources/lang/de/Api.properties index 404bfce8..14248731 100644 --- a/resources/lang/de/Api.properties +++ b/resources/lang/de/Api.properties @@ -5,3 +5,5 @@ doCapture = "doCapture" doRefund = "doRefund" doReAuth = "doReAuth" doCalculation = "doCalculation" +doAuth = "doAuth" +doGetInvoice = "doGetInvoice" diff --git a/resources/lang/de/Config.properties b/resources/lang/de/Config.properties index a33425d0..f2c87528 100644 --- a/resources/lang/de/Config.properties +++ b/resources/lang/de/Config.properties @@ -1,13 +1,14 @@ GrundeinstellungenTab=Grundeinstellungen -midLabel=Merchant-Id -portalidLabel=Portal-Id -aidLabel=Account-Id -keyLabel=Key +midLabel=Merchant ID +portalidLabel=Portal ID +aidLabel=Account ID +keyLabel=Schlüssel +userId=Benutzer ID für Notizen modeLabel=Modus modePossibleValue0=Test modePossibleValue1=Live -authTypeLabel=Autorisierungsmethode -authTypePossibleValue0=Preautorisierung +authTypeLabel=Art der Autorisierung +authTypePossibleValue0=Vorautorisierung authTypePossibleValue1=Autorisierung RechnungTab=Rechnung PAYONEPAYONEINVOICEActiveLabel=Aktiv @@ -17,7 +18,7 @@ PAYONEPAYONEINVOICENameLabel=Name PAYONEPAYONEINVOICEDescriptionLabel=Beschreibung PAYONEPAYONEINVOICEMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEINVOICEMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEINVOICEAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEINVOICEAllowedCountriesLabel=Erlaubte Lieferländer GesicherteRechnungTab=Gesicherte Rechnung PAYONEPAYONEINVOICESECUREActiveLabel=Aktiv PAYONEPAYONEINVOICESECUREActivePossibleValue0=Nein @@ -26,7 +27,7 @@ PAYONEPAYONEINVOICESECURENameLabel=Name PAYONEPAYONEINVOICESECUREDescriptionLabel=Beschreibung PAYONEPAYONEINVOICESECUREMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEINVOICESECUREMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=Erlaubte Lieferländer PaydirektTab=Paydirekt PAYONEPAYONEPAYDIREKTActiveLabel=Aktiv PAYONEPAYONEPAYDIREKTActivePossibleValue0=Nein @@ -35,7 +36,7 @@ PAYONEPAYONEPAYDIREKTNameLabel=Name PAYONEPAYONEPAYDIREKTDescriptionLabel=Beschreibung PAYONEPAYONEPAYDIREKTMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEPAYDIREKTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYDIREKTAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEPAYDIREKTAllowedCountriesLabel=Erlaubte Lieferländer PayolutionRatenzahlungTab=Payolution Ratenzahlung PAYONEPAYONEPAYOLUTIONINSTALLMENTActiveLabel=Aktiv PAYONEPAYONEPAYOLUTIONINSTALLMENTActivePossibleValue0=Nein @@ -43,7 +44,7 @@ PAYONEPAYONEPAYOLUTIONINSTALLMENTNameLabel=Name PAYONEPAYONEPAYOLUTIONINSTALLMENTDescriptionLabel=Beschreibung PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=Erlaubte Lieferländer PayPalTab=PayPal PAYONEPAYONEPAYPALActiveLabel=Aktiv PAYONEPAYONEPAYPALActivePossibleValue0=Nein @@ -52,7 +53,7 @@ PAYONEPAYONEPAYPALNameLabel=Name PAYONEPAYONEPAYPALDescriptionLabel=Beschreibung PAYONEPAYONEPAYPALMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEPAYPALMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYPALAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEPAYPALAllowedCountriesLabel=Erlaubte Lieferländer RatePayRatenzahlungTab=RatePay Ratenzahlung PAYONEPAYONERATEPAYINSTALLMENTActiveLabel=Aktiv PAYONEPAYONERATEPAYINSTALLMENTActivePossibleValue0=Nein @@ -60,7 +61,7 @@ PAYONEPAYONERATEPAYINSTALLMENTNameLabel=Name PAYONEPAYONERATEPAYINSTALLMENTDescriptionLabel=Beschreibung PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=Erlaubte Lieferländer SofortberweisungTab=Sofortüberweisung PAYONEPAYONESOFORTActiveLabel=Aktiv PAYONEPAYONESOFORTActivePossibleValue0=Nein @@ -69,7 +70,7 @@ PAYONEPAYONESOFORTNameLabel=Name PAYONEPAYONESOFORTDescriptionLabel=Beschreibung PAYONEPAYONESOFORTMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONESOFORTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONESOFORTAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONESOFORTAllowedCountriesLabel=Erlaubte Lieferländer VorkasseTab=Vorkasse PAYONEPAYONEPREPAYMENTActiveLabel=Aktiv PAYONEPAYONEPREPAYMENTActivePossibleValue0=Nein @@ -78,7 +79,7 @@ PAYONEPAYONEPREPAYMENTNameLabel=Name PAYONEPAYONEPREPAYMENTDescriptionLabel=Beschreibung PAYONEPAYONEPREPAYMENTMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEPREPAYMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=Erlaubte Lieferländer KreditkarteTab=Kreditkarte PAYONEPAYONECREDITCARDActiveLabel=Aktiv PAYONEPAYONECREDITCARDActivePossibleValue0=Nein @@ -91,7 +92,7 @@ PAYONEPAYONECREDITCARDMinExpireTimeLabel=Minmiale Kartengültigkeit in Tagen PAYONEPAYONECREDITCARDDefaultStyleLabel=Kreditkartenfelder default style PAYONEPAYONECREDITCARDDefaultHeightInPxLabel=Kreditkartenfelder Höhe in px PAYONEPAYONECREDITCARDDefaultWidthInPxLabel=Kreditkartenfelder Breite in px -PAYONEPAYONECREDITCARDAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONECREDITCARDAllowedCountriesLabel=Erlaubte Lieferländer PAYONEPAYONECREDITCARDAllowedCardTypesLabel=Erlaubte Kartentypen PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesV=Visa PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesM=Mastercard @@ -111,7 +112,7 @@ PAYONEPAYONECASHONDELIVERYNameLabel=Name PAYONEPAYONECASHONDELIVERYDescriptionLabel=Beschreibung PAYONEPAYONECASHONDELIVERYMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=Erlaubte Lieferländer LastschriftTab=Lastschrift PAYONEPAYONEDIRECTDEBITActiveLabel=Aktiv PAYONEPAYONEDIRECTDEBITActivePossibleValue0=Nein @@ -120,7 +121,16 @@ PAYONEPAYONEDIRECTDEBITNameLabel=Name PAYONEPAYONEDIRECTDEBITDescriptionLabel=Beschreibung PAYONEPAYONEDIRECTDEBITMinCartAmountLabel=Minimaler Bestellwert PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=Erlaubte Länder +PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=Erlaubte Lieferländer +AmazonPayTab=Amazon Pay +PAYONEPAYONEAMAZONPAYActiveLabel=Aktiv +PAYONEPAYONEAMAZONPAYActivePossibleValue0=Nein +PAYONEPAYONEAMAZONPAYActivePossibleValue1=Ja +PAYONEPAYONEAMAZONPAYNameLabel=Name +PAYONEPAYONEAMAZONPAYDescriptionLabel=Beschreibung +PAYONEPAYONEAMAZONPAYMinCartAmountLabel=Minimaler Bestellwert +PAYONEPAYONEAMAZONPAYMaxCartAmountLabel=Maximaler Bestellwert +PAYONEPAYONEAMAZONPAYAllowedCountriesLabel=Erlaubte Lieferländer DebuggingTab=Debugging debuggingActiveLabel=Aktiv debuggingActivePossibleValue0=Nein @@ -130,4 +140,4 @@ get = "get" set = "set" prepend = "prepend" push = "push" -getPrefix = "getPrefix" \ No newline at end of file +getPrefix = "getPrefix" diff --git a/resources/lang/de/Controller.properties b/resources/lang/de/Controller.properties new file mode 100644 index 00000000..cda254fd --- /dev/null +++ b/resources/lang/de/Controller.properties @@ -0,0 +1,5 @@ +Status = "Status" +Success = "Success" +Checkout = "Checkout" +routeCalled = "route called" +redirecting = "redirecting" \ No newline at end of file diff --git a/resources/lang/de/General.properties b/resources/lang/de/General.properties new file mode 100644 index 00000000..af1b7ff7 --- /dev/null +++ b/resources/lang/de/General.properties @@ -0,0 +1 @@ +getPaymentsByOrderId = getPaymentsByOrderId \ No newline at end of file diff --git a/resources/lang/de/Payment.properties b/resources/lang/de/Payment.properties index ec946c63..d184c7f6 100644 --- a/resources/lang/de/Payment.properties +++ b/resources/lang/de/Payment.properties @@ -1,3 +1,7 @@ minCartAmount = "minCartAmount" maxCartAmount = "maxCartAmount" countryNotAllowed = "countryNotAllowed" +createPayment = "createPayment" +updatePayment = "updatePayment" +updatingPayment = "updatingPayment" +createRefundPayment = "createRefundPayment" diff --git a/resources/lang/de/Template.properties b/resources/lang/de/Template.properties index 8337628c..cff23813 100755 --- a/resources/lang/de/Template.properties +++ b/resources/lang/de/Template.properties @@ -13,4 +13,6 @@ sepaMandateConsent = "Hiermit erteile ich ein elektronisches Sepamandat." yourBankAccount = "Ihre Bankverbindung" accountHolder = "Konto Inhaber" -mandateTitle = "Um eine SEPA-Basislastschrift durchzuführen, benötigen wir ein SEPA Mandat vom Kontoinhaber." \ No newline at end of file +mandateTitle = "Um eine SEPA-Basislastschrift durchzuführen, benötigen wir ein SEPA Mandat vom Kontoinhaber." + +missingDateOfBirth = "Bitte geben Sie ein Geburtsdatum an." \ No newline at end of file diff --git a/resources/lang/en/Api.properties b/resources/lang/en/Api.properties index 404bfce8..14248731 100644 --- a/resources/lang/en/Api.properties +++ b/resources/lang/en/Api.properties @@ -5,3 +5,5 @@ doCapture = "doCapture" doRefund = "doRefund" doReAuth = "doReAuth" doCalculation = "doCalculation" +doAuth = "doAuth" +doGetInvoice = "doGetInvoice" diff --git a/resources/lang/en/Config.properties b/resources/lang/en/Config.properties index de89d5d5..a69b57b0 100644 --- a/resources/lang/en/Config.properties +++ b/resources/lang/en/Config.properties @@ -1,98 +1,99 @@ -GrundeinstellungenTab=Basesettings -midLabel=Merchant-Id -portalidLabel=Portal-Id -aidLabel=Account-Id +GrundeinstellungenTab=Basic settings +midLabel=Merchant ID +portalidLabel=Portal ID +aidLabel=Account ID keyLabel=Key -modeLabel=Modus +modeLabel=Mode +userId=User ID for order notes modePossibleValue0=Test modePossibleValue1=Live -authTypeLabel=authorization method -authTypePossibleValue0=Preauthorization -authTypePossibleValue1=authorization +authTypeLabel=Authorisation method +authTypePossibleValue0=Preauthorisation +authTypePossibleValue1=Authorisation RechnungTab=Invoice -PAYONEPAYONEINVOICEActiveLabel=Activ +PAYONEPAYONEINVOICEActiveLabel=Active PAYONEPAYONEINVOICEActivePossibleValue0=No PAYONEPAYONEINVOICEActivePossibleValue1=Yes PAYONEPAYONEINVOICENameLabel=Name PAYONEPAYONEINVOICEDescriptionLabel=Description -PAYONEPAYONEINVOICEMinCartAmountLabel=Min Order amount -PAYONEPAYONEINVOICEMaxCartAmountLabel=Max Order amount -PAYONEPAYONEINVOICEAllowedCountriesLabel=allowed Countries +PAYONEPAYONEINVOICEMinCartAmountLabel=Minimum order value +PAYONEPAYONEINVOICEMaxCartAmountLabel=Maximum order value +PAYONEPAYONEINVOICEAllowedCountriesLabel=Allowed countries of delivery GesicherteRechnungTab=Secured invoice -PAYONEPAYONEINVOICESECUREActiveLabel=Activ +PAYONEPAYONEINVOICESECUREActiveLabel=Active PAYONEPAYONEINVOICESECUREActivePossibleValue0=No PAYONEPAYONEINVOICESECUREActivePossibleValue1=Yes PAYONEPAYONEINVOICESECURENameLabel=Name PAYONEPAYONEINVOICESECUREDescriptionLabel=Description -PAYONEPAYONEINVOICESECUREMinCartAmountLabel=Min Order amount -PAYONEPAYONEINVOICESECUREMaxCartAmountLabel=Max Order amount -PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=allowed Countries -PaydirektTab=Paydirect -PAYONEPAYONEPAYDIREKTActiveLabel=Activ +PAYONEPAYONEINVOICESECUREMinCartAmountLabel=Minimum order value +PAYONEPAYONEINVOICESECUREMaxCartAmountLabel=Maximum order value +PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=Allowed countries of delivery +PaydirektTab=Paydirekt +PAYONEPAYONEPAYDIREKTActiveLabel=Active PAYONEPAYONEPAYDIREKTActivePossibleValue0=No PAYONEPAYONEPAYDIREKTActivePossibleValue1=Yes PAYONEPAYONEPAYDIREKTNameLabel=Name PAYONEPAYONEPAYDIREKTDescriptionLabel=Description -PAYONEPAYONEPAYDIREKTMinCartAmountLabel=Min Order amount -PAYONEPAYONEPAYDIREKTMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPAYDIREKTAllowedCountriesLabel=allowed Countries -PayolutionRatenzahlungTab=Payolution payment by installments -PAYONEPAYONEPAYOLUTIONINSTALLMENTActiveLabel=Activ +PAYONEPAYONEPAYDIREKTMinCartAmountLabel=Minimum order value +PAYONEPAYONEPAYDIREKTMaxCartAmountLabel=Maximum order value +PAYONEPAYONEPAYDIREKTAllowedCountriesLabel=Allowed countries of delivery +PayolutionRatenzahlungTab=Payolution payment in installments +PAYONEPAYONEPAYOLUTIONINSTALLMENTActiveLabel=Active PAYONEPAYONEPAYOLUTIONINSTALLMENTActivePossibleValue0=No PAYONEPAYONEPAYOLUTIONINSTALLMENTNameLabel=Name PAYONEPAYONEPAYOLUTIONINSTALLMENTDescriptionLabel=Description -PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=allowed Countries +PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel=Minimum order value +PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel=Maximum order value +PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=Allowed countries of delivery PayPalTab=PayPal -PAYONEPAYONEPAYPALActiveLabel=Activ +PAYONEPAYONEPAYPALActiveLabel=Active PAYONEPAYONEPAYPALActivePossibleValue0=No PAYONEPAYONEPAYPALActivePossibleValue1=Yes PAYONEPAYONEPAYPALNameLabel=Name PAYONEPAYONEPAYPALDescriptionLabel=Description -PAYONEPAYONEPAYPALMinCartAmountLabel=Min Order amount -PAYONEPAYONEPAYPALMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPAYPALAllowedCountriesLabel=allowed Countries -RatePayRatenzahlungTab=RatePay payment by installments -PAYONEPAYONERATEPAYINSTALLMENTActiveLabel=Activ +PAYONEPAYONEPAYPALMinCartAmountLabel=Minimum order value +PAYONEPAYONEPAYPALMaxCartAmountLabel=Maximum order value +PAYONEPAYONEPAYPALAllowedCountriesLabel=Allowed countries of delivery +RatePayRatenzahlungTab=RatePay payment in installments +PAYONEPAYONERATEPAYINSTALLMENTActiveLabel=Active PAYONEPAYONERATEPAYINSTALLMENTActivePossibleValue0=No PAYONEPAYONERATEPAYINSTALLMENTNameLabel=Name PAYONEPAYONERATEPAYINSTALLMENTDescriptionLabel=Description -PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=allowed Countries +PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel=Minimum order value +PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel=Maximum order value +PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=Allowed countries of delivery SofortberweisungTab=Sofortüberweisung -PAYONEPAYONESOFORTActiveLabel=Activ +PAYONEPAYONESOFORTActiveLabel=Active PAYONEPAYONESOFORTActivePossibleValue0=No PAYONEPAYONESOFORTActivePossibleValue1=Yes PAYONEPAYONESOFORTNameLabel=Name PAYONEPAYONESOFORTDescriptionLabel=Description -PAYONEPAYONESOFORTMinCartAmountLabel=Min Order amount -PAYONEPAYONESOFORTMaxCartAmountLabel=Max Order amount -PAYONEPAYONESOFORTAllowedCountriesLabel=allowed Countries -VorkasseTab=Payment in advance -PAYONEPAYONEPREPAYMENTActiveLabel=Activ +PAYONEPAYONESOFORTMinCartAmountLabel=Minimum order value +PAYONEPAYONESOFORTMaxCartAmountLabel=Maximum order value +PAYONEPAYONESOFORTAllowedCountriesLabel=Allowed countries of delivery +VorkasseTab=Cash in advance +PAYONEPAYONEPREPAYMENTActiveLabel=Active PAYONEPAYONEPREPAYMENTActivePossibleValue0=No PAYONEPAYONEPREPAYMENTActivePossibleValue1=Yes PAYONEPAYONEPREPAYMENTNameLabel=Name PAYONEPAYONEPREPAYMENTDescriptionLabel=Description -PAYONEPAYONEPREPAYMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONEPREPAYMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=allowed Countries -KreditkarteTab=Creditcard -PAYONEPAYONECREDITCARDActiveLabel=Activ +PAYONEPAYONEPREPAYMENTMinCartAmountLabel=Minimum order value +PAYONEPAYONEPREPAYMENTMaxCartAmountLabel=Maximum order value +PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=Allowed countries of delivery +KreditkarteTab=Credit card +PAYONEPAYONECREDITCARDActiveLabel=Active PAYONEPAYONECREDITCARDActivePossibleValue0=No PAYONEPAYONECREDITCARDActivePossibleValue1=Yes PAYONEPAYONECREDITCARDNameLabel=Name PAYONEPAYONECREDITCARDDescriptionLabel=Description -PAYONEPAYONECREDITCARDMinCartAmountLabel=Min Order amount -PAYONEPAYONECREDITCARDMaxCartAmountLabel=Max Order amount -PAYONEPAYONECREDITCARDMinExpireTimeLabel=Minmiale card validity in days -PAYONEPAYONECREDITCARDDefaultStyleLabel=Creditcard Fields default style -PAYONEPAYONECREDITCARDDefaultHeightInPxLabel=Creditcard Fields height in px -PAYONEPAYONECREDITCARDDefaultWidthInPxLabel=Creditcard Fields width in px -PAYONEPAYONECREDITCARDAllowedCountriesLabel=allowed Countries -PAYONEPAYONECREDITCARDAllowedCardTypesLabel=Erlaubte Kartentypen +PAYONEPAYONECREDITCARDMinCartAmountLabel=Minimum order amount +PAYONEPAYONECREDITCARDMaxCartAmountLabel=Maximum order amount +PAYONEPAYONECREDITCARDMinExpireTimeLabel=Minimum card validity in days +PAYONEPAYONECREDITCARDDefaultStyleLabel=Credit card fields default style +PAYONEPAYONECREDITCARDDefaultHeightInPxLabel=Credit card fields height in px +PAYONEPAYONECREDITCARDDefaultWidthInPxLabel=Credit card fields width in px +PAYONEPAYONECREDITCARDAllowedCountriesLabel=Allowed countries of delivery +PAYONEPAYONECREDITCARDAllowedCardTypesLabel=Allowed card types PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesV=Visa PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesM=Mastercard PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesA=Amex @@ -104,25 +105,34 @@ PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowed PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesJ=JCB PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesP=China Union Pay NachnahmeTab=Cash on delivery -PAYONEPAYONECASHONDELIVERYActiveLabel=Activ +PAYONEPAYONECASHONDELIVERYActiveLabel=Active PAYONEPAYONECASHONDELIVERYActivePossibleValue0=No PAYONEPAYONECASHONDELIVERYActivePossibleValue1=Yes PAYONEPAYONECASHONDELIVERYNameLabel=Name PAYONEPAYONECASHONDELIVERYDescriptionLabel=Description -PAYONEPAYONECASHONDELIVERYMinCartAmountLabel=Min Order amount -PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel=Max Order amount -PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=allowed Countries +PAYONEPAYONECASHONDELIVERYMinCartAmountLabel=Minimum order value +PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel=Maximum order value +PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=Allowed countries of delivery LastschriftTab=Debit -PAYONEPAYONEDIRECTDEBITActiveLabel=Activ +PAYONEPAYONEDIRECTDEBITActiveLabel=Active PAYONEPAYONEDIRECTDEBITActivePossibleValue0=No PAYONEPAYONEDIRECTDEBITActivePossibleValue1=Yes PAYONEPAYONEDIRECTDEBITNameLabel=Name PAYONEPAYONEDIRECTDEBITDescriptionLabel=Description -PAYONEPAYONEDIRECTDEBITMinCartAmountLabel=Min Order amount -PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel=Max Order amount -PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=allowed Countries +PAYONEPAYONEDIRECTDEBITMinCartAmountLabel=Minimum order value +PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel=Maximum order value +PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=Allowed countries of delivery +AmazonPayTab=Amazon Pay +PAYONEPAYONEAMAZONPAYActiveLabel=Active +PAYONEPAYONEAMAZONPAYActivePossibleValue0=No +PAYONEPAYONEAMAZONPAYActivePossibleValue1=Yes +PAYONEPAYONEAMAZONPAYNameLabel=Name +PAYONEPAYONEAMAZONPAYDescriptionLabel=Description +PAYONEPAYONEAMAZONPAYMinCartAmountLabel=Minimum order value +PAYONEPAYONEAMAZONPAYMaxCartAmountLabel=Maximum order value +PAYONEPAYONEAMAZONPAYAllowedCountriesLabel=Allowed countries of delivery DebuggingTab=Debugging -debuggingActiveLabel=Activ +debuggingActiveLabel=Active debuggingActivePossibleValue0=No debuggingActivePossibleValue1=Yes has = "has" @@ -130,4 +140,4 @@ get = "get" set = "set" prepend = "prepend" push = "push" -getPrefix = "getPrefix" \ No newline at end of file +getPrefix = "getPrefix" diff --git a/resources/lang/en/Controller.properties b/resources/lang/en/Controller.properties new file mode 100644 index 00000000..cda254fd --- /dev/null +++ b/resources/lang/en/Controller.properties @@ -0,0 +1,5 @@ +Status = "Status" +Success = "Success" +Checkout = "Checkout" +routeCalled = "route called" +redirecting = "redirecting" \ No newline at end of file diff --git a/resources/lang/en/General.properties b/resources/lang/en/General.properties new file mode 100644 index 00000000..af1b7ff7 --- /dev/null +++ b/resources/lang/en/General.properties @@ -0,0 +1 @@ +getPaymentsByOrderId = getPaymentsByOrderId \ No newline at end of file diff --git a/resources/lang/en/Payment.properties b/resources/lang/en/Payment.properties index ec946c63..d184c7f6 100644 --- a/resources/lang/en/Payment.properties +++ b/resources/lang/en/Payment.properties @@ -1,3 +1,7 @@ minCartAmount = "minCartAmount" maxCartAmount = "maxCartAmount" countryNotAllowed = "countryNotAllowed" +createPayment = "createPayment" +updatePayment = "updatePayment" +updatingPayment = "updatingPayment" +createRefundPayment = "createRefundPayment" diff --git a/resources/lang/en/Template.properties b/resources/lang/en/Template.properties index 5a2aa66d..52817a04 100755 --- a/resources/lang/en/Template.properties +++ b/resources/lang/en/Template.properties @@ -14,4 +14,6 @@ sepaMandateConsent = "I wish to grant the mandate through electronic submission" yourBankAccount = "Your bank account" accountHolder = "Account holder -mandateTitle = "In order to perform a SEPA Core Direct Debit, we need a mandate from the account holder." \ No newline at end of file +mandateTitle = "In order to perform a SEPA Core Direct Debit, we need a mandate from the account holder." + +missingDateOfBirth = "Please enter a date of birth." \ No newline at end of file diff --git a/resources/lib/PayoneApi/Api/Client.php b/resources/lib/PayoneApi/Api/Client.php new file mode 100644 index 00000000..a54a797c --- /dev/null +++ b/resources/lib/PayoneApi/Api/Client.php @@ -0,0 +1,137 @@ +client = new \GuzzleHttp\Client(); + } + + /** + * @return \GuzzleHttp\Client + */ + public function getClient() + { + return $this->client; + } + + /** + * @param \GuzzleHttp\Client $client + * + * @return Client + */ + public function setClient(\GuzzleHttp\Client $client) + { + $this->client = $client; + + return $this; + } + + /** + * @return string + */ + public function getHttpMethod() + { + return $this->httpMethod; + } + + /** + * @param string $httpMethod + * + * @return Client + */ + public function setHttpMethod($httpMethod) + { + $this->httpMethod = $httpMethod; + + return $this; + } + + /** + * @return string + */ + public function getEndpointUrl() + { + return $this->url; + } + + /** + * @param string $url + * + * @return Client + */ + public function setEndpointUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @param array $data + * + * @return string + */ + public function doRequest($data) + { + $res = $this->client->request( + $this->getHttpMethod(), + $this->getEndpointUrl(), + [ + 'form_params' => $data, + 'headers' => $this->headers, + ] + ); + + return (string) $res->getBody(); + } + + /** + * @param string $method + * + * @return $this + */ + public function setMethod($method) + { + $this->httpMethod = $method; + + return $this; + } + + /** + * @param string $key + * @param string $value + */ + public function addHeader($key, $value) + { + if (!$this->headers) { + $this->headers = []; + } + $this->headers[$key] = $value; + } +} diff --git a/resources/lib/PayoneApi/Api/ClientContract.php b/resources/lib/PayoneApi/Api/ClientContract.php new file mode 100644 index 00000000..90e93ea8 --- /dev/null +++ b/resources/lib/PayoneApi/Api/ClientContract.php @@ -0,0 +1,32 @@ +client = $client; + $this->serializer = $serializer; + $client->setEndpointUrl($this->getEndPointUrl()); + $client->setMethod('POST'); + $client->addHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'); + } + + /** + * @return ClientContract + */ + public function getClient(): ClientContract + { + return $this->client; + } + + /** + * @param ClientContract $client + * + * @return PostApi + */ + public function setClient(ClientContract $client) + { + $this->client = $client; + + return $this; + } + + /** + * @param object $entity + * + * @return ResponseContract + */ + public function doRequest($entity) + { + $this->requestData = $this->serializer->serialize($entity); + try { + $responseBody = $this->client->doRequest($this->requestData); + + return ResponseFactory::create($responseBody); + } catch (\Exception $e) { + } + + return new ClientErrorResponse($e->getMessage()); + } + + /** + * @return string + */ + protected function getEndPointUrl() + { + return $this::PAYONE_SERVER_API_URL; + } + + /** + * @return array + */ + public function getLastRequestData(){ + return $this->requestData; + } +} diff --git a/resources/lib/PayoneApi/Lib/Version.php b/resources/lib/PayoneApi/Lib/Version.php new file mode 100644 index 00000000..ec0b8a1f --- /dev/null +++ b/resources/lib/PayoneApi/Lib/Version.php @@ -0,0 +1,17 @@ +jsonSerialize(); + asort($result); + return $result; + } + + $oClass = new \ReflectionClass(get_class($object)); + $result = []; + foreach ($oClass->getMethods() as $method) { + if (substr($method->name, 0, 3) != 'get') { + continue; + } + $propName = $this->camelCaseToUnderscore(substr($method->name, 3)); + + $value = $method->invoke($object); + if (is_object($value)) { + $result += $this->serialize($value); + continue; + } + if ($value !== null && $value !== '') { + $result[$propName] = $value; + } + } + + asort($result); + + return $result; + } + + /** + * @param string $string + * + * @return string + */ + private function camelCaseToUnderscore($string) + { + return strtolower(preg_replace('/(?authorizationRequest = $authorizationRequest; + $this->urls = $urls; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } + + /** + * Getter for Wallettype + * + * @return string + */ + public function getWallettype() + { + return $this->wallettype; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/CashOnDelivery.php b/resources/lib/PayoneApi/Request/Authorization/CashOnDelivery.php new file mode 100644 index 00000000..bb957f58 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/CashOnDelivery.php @@ -0,0 +1,47 @@ +authorizationRequest = $authorizationRequest; + $this->shippingprovider = $shippingprovider; + } + + /** + * Getter for Shippingprovider + * + * @return mixed + */ + public function getShippingprovider() + { + return $this->shippingprovider; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/Creditcard.php b/resources/lib/PayoneApi/Request/Authorization/Creditcard.php new file mode 100644 index 00000000..b173ca40 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/Creditcard.php @@ -0,0 +1,65 @@ +authorizationRequest = $authorizationRequest; + $this->pseudocardpan = $pseudocardPan; + $this->urls = $urls; + } + + /** + * Getter for Pseudocardpan + * + * @return string + */ + public function getPseudocardpan() + { + return $this->pseudocardpan; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/DirectDebit.php b/resources/lib/PayoneApi/Request/Authorization/DirectDebit.php new file mode 100644 index 00000000..e690f845 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/DirectDebit.php @@ -0,0 +1,47 @@ +authorizationRequest = $authorizationRequest; + $this->sepaMandate = $sepaMandate; + } + + /** + * Getter for SepaMandate + * + * @return SepaMandate + */ + public function getSepaMandate() + { + return $this->sepaMandate; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/Invoice.php b/resources/lib/PayoneApi/Request/Authorization/Invoice.php new file mode 100644 index 00000000..b49301d1 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/Invoice.php @@ -0,0 +1,26 @@ +authorizationRequest = $authorizationRequest; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/InvoiceSecure.php b/resources/lib/PayoneApi/Request/Authorization/InvoiceSecure.php new file mode 100644 index 00000000..4235085d --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/InvoiceSecure.php @@ -0,0 +1,57 @@ +authorizationRequest = $authorizationRequest; + $this->cart = $cart; + } + + /** + * Getter for clearingsubtype + * + * @return string + */ + public function getClearingsubtype() + { + return $this->clearingsubtype; + } + + /** + * Getter for Cart + * @return Cart + */ + public function getCart() + { + return $this->cart; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/OnlineBankTransfer.php b/resources/lib/PayoneApi/Request/Authorization/OnlineBankTransfer.php new file mode 100644 index 00000000..b2652dfd --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/OnlineBankTransfer.php @@ -0,0 +1,76 @@ +authorizationRequest = $authorizationRequest; + $this->urls = $urls; + $this->bankAccount = $bankAccount; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } + + /** + * Getter for Onlinebanktransfertype + * + * @return string + */ + public function getOnlinebanktransfertype() + { + return $this->onlinebanktransfertype; + } + + /** + * Getter for BankAccount + * + * @return BankAccount + */ + public function getBankAccount() + { + return $this->bankAccount; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/PayPal.php b/resources/lib/PayoneApi/Request/Authorization/PayPal.php new file mode 100644 index 00000000..6f9c5bde --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/PayPal.php @@ -0,0 +1,61 @@ +authorizationRequest = $authorizationRequest; + $this->urls = $urls; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } + + /** + * Getter for Wallettype + * + * @return string + */ + public function getWallettype() + { + return $this->wallettype; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/Paydirekt.php b/resources/lib/PayoneApi/Request/Authorization/Paydirekt.php new file mode 100644 index 00000000..ee5a7bca --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/Paydirekt.php @@ -0,0 +1,80 @@ +authorizationRequest = $authorizationRequest; + $this->urls = $urls; + $this->shippingAddress = $shippingAddress; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } + + /** + * Getter for Wallettype + * + * @return string + */ + public function getWallettype() + { + return $this->wallettype; + } + + /** + * Getter for ShippingAddress + * + * @return ShippingAddress + */ + public function getShippingAddress() + { + return $this->shippingAddress; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/PrePayment.php b/resources/lib/PayoneApi/Request/Authorization/PrePayment.php new file mode 100644 index 00000000..719db833 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/PrePayment.php @@ -0,0 +1,25 @@ +authorizationRequest = $authorizationRequest; + } +} diff --git a/resources/lib/PayoneApi/Request/Authorization/RequestFactory.php b/resources/lib/PayoneApi/Request/Authorization/RequestFactory.php new file mode 100644 index 00000000..f9fdd88e --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/RequestFactory.php @@ -0,0 +1,136 @@ +authorizationRequest = $authorizationRequest; + $this->urls = $urls; + $this->bankAccount = $bankAccount; + } + + /** + * Getter for Urls + * + * @return RedirectUrls + */ + public function getUrls() + { + return $this->urls; + } + + /** + * Getter for Onlinebanktransfertype + * + * @return string + */ + public function getOnlinebanktransfertype() + { + return $this->onlinebanktransfertype; + } + + /** + * Getter for BankAccount + * + * @return BankAccount + */ + public function getBankAccount() + { + return $this->bankAccount; + } +} diff --git a/resources/lib/PayoneApi/Request/AuthorizationRequestAbstract.php b/resources/lib/PayoneApi/Request/AuthorizationRequestAbstract.php new file mode 100644 index 00000000..67b2c85b --- /dev/null +++ b/resources/lib/PayoneApi/Request/AuthorizationRequestAbstract.php @@ -0,0 +1,37 @@ +authorizationRequest; + } + + /** + * Getter for Clearingtype + * + * @return string + */ + public function getClearingtype() + { + return $this->clearingtype; + } +} diff --git a/resources/lib/PayoneApi/Request/AuthorizationRequestContract.php b/resources/lib/PayoneApi/Request/AuthorizationRequestContract.php new file mode 100644 index 00000000..d231f433 --- /dev/null +++ b/resources/lib/PayoneApi/Request/AuthorizationRequestContract.php @@ -0,0 +1,42 @@ +request = $request; + $this->txid = $txid; + $this->capturemode = $capturemode; + $this->cart = $cart; + $this->settleaccount = $settleaccount; + } + + /** + * Getter for Cart + * @return Cart + */ + public function getCart() + { + return $this->cart; + } + + /** + * Getter for Txid + * + * @return string + */ + public function getTxid() + { + return $this->txid; + } + + /** + * Getter for Capturemode + * + * @return string + */ + public function getCapturemode() + { + return $this->capturemode; + } + + /** + * Getter for Request + * + * @return GenericRequest + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for Settleaccount + * @return mixed + */ + public function getSettleaccount() + { + return $this->settleaccount; + } + + +} diff --git a/resources/lib/PayoneApi/Request/Capture/CaptureModes.php b/resources/lib/PayoneApi/Request/Capture/CaptureModes.php new file mode 100644 index 00000000..c148f3e5 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Capture/CaptureModes.php @@ -0,0 +1,12 @@ +txid = $txid; + $this->request = $request; + $this->cart = $cart; + } + + /** + * Getter for Request + * + * @return GenericRequest + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for Txid + * + * @return string + */ + public function getTxid() + { + return $this->txid; + } + + /** + * Getter for Cart + * @return Cart + */ + public function getCart() + { + return $this->cart; + } +} diff --git a/resources/lib/PayoneApi/Request/Debit/RequestFactory.php b/resources/lib/PayoneApi/Request/Debit/RequestFactory.php new file mode 100644 index 00000000..7b91784e --- /dev/null +++ b/resources/lib/PayoneApi/Request/Debit/RequestFactory.php @@ -0,0 +1,30 @@ +customer = $customer; + $this->reference = $reference; + $this->genericRequest = $genericRequest; + } + + /** + * Getter for Reference + */ + public function getReference() + { + return $this->reference; + } + + /** + * Getter for Customer + * + * @return Customer + */ + public function getCustomer(): Customer + { + return $this->customer; + } + + /** + * Getter for GenericRequestrequest + * + * @return GenericRequest + */ + public function getGenericRequest() + { + return $this->genericRequest; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericRequest.php b/resources/lib/PayoneApi/Request/GenericRequest.php new file mode 100644 index 00000000..1fff4117 --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericRequest.php @@ -0,0 +1,120 @@ +config = $config; + $this->request = $request; + $this->amount = $amount; + $this->currency = $currency; + $this->sequencenumber = $sequencenumber; + $this->info = $info; + } + + /** + * Getter for Sequencenumber + */ + public function getSequencenumber() + { + return $this->sequencenumber; + } + + /** + * Getter for Amount + * + * @return int + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Getter for Currency + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Getter for Config + * + * @return Config + */ + public function getConfig(): Config + { + return $this->config; + } + + /** + * @return string + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for Info + * + * @return SystemInfo + */ + public function getInfo() + { + return $this->info; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericRequestFactory.php b/resources/lib/PayoneApi/Request/GenericRequestFactory.php new file mode 100644 index 00000000..dd193d53 --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericRequestFactory.php @@ -0,0 +1,47 @@ +config = $config; + $this->invoiceTitle = $invoiceTitle; + $this->info = $info; + } + + /** + * Getter for Request + * + * @return string + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for Config + * + * @return Config + */ + public function getConfig() + { + return $this->config; + } + + /** + * Getter for Info + * + * @return SystemInfo + */ + public function getInfo() + { + return $this->info; + } + + /** + * Getter for InvoiceTitle + * + * @return string + */ + public function getInvoiceTitle() + { + return $this->invoiceTitle; + } +} diff --git a/resources/lib/PayoneApi/Request/GetInvoice/RequestFactory.php b/resources/lib/PayoneApi/Request/GetInvoice/RequestFactory.php new file mode 100644 index 00000000..deac6130 --- /dev/null +++ b/resources/lib/PayoneApi/Request/GetInvoice/RequestFactory.php @@ -0,0 +1,46 @@ +config = $config; + $this->currency = $currency; + $this->customer = $customer; + $this->info = $info; + $this->bankAccount = $bankAccount; + $this->mandateIdentification = $mandateIdentification; + } + + /** + * Getter for Clearingtype + * + * @return string + */ + public function getClearingtype() + { + return $this->clearingtype; + } + + /** + * Getter for MandateIdentification + * + * @return mixed + */ + public function getMandateIdentification() + { + return $this->mandateIdentification; + } + + /** + * Getter for Currency + * + * @return mixed + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Getter for Request + * + * @return string + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for BankAccount + * + * @return BankAccount + */ + public function getBankAccount() + { + return $this->bankAccount; + } + + /** + * Getter for Customer + * + * @return Customer + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * Getter for Config + * + * @return Config + */ + public function getConfig() + { + return $this->config; + } + + /** + * Getter for Info + * + * @return SystemInfo + */ + public function getInfo() + { + return $this->info; + } + + /** + * Getter for Sequencenumber + */ + public function getSequencenumber() + { + return null; + } + + /** + * Getter for Amount + * + * @return int + */ + public function getAmount() + { + return null; + } +} diff --git a/resources/lib/PayoneApi/Request/Managemandate/ManageMandateRequestFactory.php b/resources/lib/PayoneApi/Request/Managemandate/ManageMandateRequestFactory.php new file mode 100644 index 00000000..c037ad94 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Managemandate/ManageMandateRequestFactory.php @@ -0,0 +1,74 @@ +bankcountry = $bankcountry; + $this->iban = $iban; + $this->bic = $bic; + $holderNames = explode(' ', $holder); + $this->firstname = $holderNames[0] ?? ''; + $this->lastname = $holderNames[1] ?? ''; + } + + /** + * Getter for Bankcountry + * + * @return mixed + */ + public function getBankcountry() + { + return $this->bankcountry; + } + + /** + * Getter for Iban + * + * @return mixed + */ + public function getIban() + { + return $this->iban; + } + + /** + * Getter for Bic + * + * @return mixed + */ + public function getBic() + { + return $this->bic; + } + + /** + * Getter for Firstname + * + * @return mixed + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * Getter for Lastname + * + * @return mixed + */ + public function getLastname() + { + return $this->lastname; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/Cart.php b/resources/lib/PayoneApi/Request/Parts/Cart.php new file mode 100644 index 00000000..ef0f36f2 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/Cart.php @@ -0,0 +1,46 @@ +cartItems; + } + + /** + * @return array + */ + public function jsonSerialize() + { + $cartItems = $this->getCartItems(); + if (!$cartItems) { + return []; + } + $itemsArray = array_map( + function (CartItem $cartItem) { + return $cartItem->jsonSerialize(); + }, + $cartItems + ); + return call_user_func_array('array_merge', $itemsArray); + } + + /** + * @param CartItem $cartItem + */ + public function add(CartItem $cartItem) + { + $this->cartItems[] = $cartItem; + } +} \ No newline at end of file diff --git a/resources/lib/PayoneApi/Request/Parts/CartFactory.php b/resources/lib/PayoneApi/Request/Parts/CartFactory.php new file mode 100644 index 00000000..b423f7ee --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/CartFactory.php @@ -0,0 +1,54 @@ + $cartItemData) { + $cartItem = new CartItem( + ($i+1), + $cartItemData['itemId'], + CartItem::TYPE_GOODS, + $cartItemData['quantity'] ?? '', + $cartItemData['price'], + $cartItemData['vat'], + $cartItemData['name'] ?? '' + ); + $cart->add($cartItem); + } + $cart->add(self::calculateShipping($requestData, $cart)); + return $cart; + } + + /** + * @param array $requestData + * @param $cart + * @return CartItem + */ + private static function calculateShipping(array $requestData, Cart $cart) + { + $taxRate = 0; + $basket = $requestData['basket']; + if ($basket['shippingAmountNet'] > 0) { + $taxRate = (int)round((($basket['shippingAmount'] / $basket['shippingAmountNet']) - 1) * 100); + } + $shippingCost = new CartItem( + (count($cart->getCartItems())+1), + '-', + CartItem::TYPE_SHIPMENt, + 1, + $basket['shippingAmount'], + $taxRate, + 'Porto & Versand' + ); + return $shippingCost; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/CartItem.php b/resources/lib/PayoneApi/Request/Parts/CartItem.php new file mode 100644 index 00000000..64075430 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/CartItem.php @@ -0,0 +1,174 @@ + 99 = basis points (e.g. 1900 = 19%) + * + * @var int + */ + private $va; + + /** + * CartItem constructor. + * + * @param int $position + * @param string $sku + * @param string $type + * @param int $qty + * @param int $price in cent + * @param string $description ='' + * @param int $taxRate + */ + public function __construct( + $position, + $sku, + $type, + $qty, + $price, + $taxRate, + $description = '' + ) { + $this->position = $position; + $this->id = $sku; + $this->it = $type; + $this->no = $qty; + $this->pr = $price; + $this->de = $description; + $this->va = $taxRate; + } + + /** + * Getter for Position + * + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * Getter for Id + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Getter for It + * + * @return string + */ + public function getIt() + { + return $this->it; + } + + /** + * Getter for No + * + * @return int + */ + public function getNo() + { + return $this->no; + } + + /** + * Getter for Pr + * + * @return int + */ + public function getPr() + { + return $this->pr; + } + + /** + * Getter for De + * + * @return string + */ + public function getDe() + { + return $this->de; + } + + /** + * Getter for Va + * + * @return int + */ + public function getVa() + { + return $this->va; + } + + public function jsonSerialize() + { + return [ + 'id[' . $this->getPosition().']' => $this->getId(), + 'it[' . $this->getPosition().']' => $this->getIt(), + 'no[' . $this->getPosition().']' => $this->getNo(), + 'pr[' . $this->getPosition().']' => $this->getPr(), + 'de[' . $this->getPosition().']' => $this->getDe(), + 'va[' . $this->getPosition().']' => $this->getva(), + ]; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/Config.php b/resources/lib/PayoneApi/Request/Parts/Config.php new file mode 100644 index 00000000..b59af208 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/Config.php @@ -0,0 +1,102 @@ +aid = $aid; + $this->mid = $mid; + $this->portalid = $portalid; + $this->key = hash('md5', $key); + $this->mode = $mode; + } + + /** + * Getter for Aid + * + * @return mixed + */ + public function getAid() + { + return $this->aid; + } + + /** + * Getter for Mid + * + * @return mixed + */ + public function getMid() + { + return $this->mid; + } + + /** + * Getter for Portalid + * + * @return mixed + */ + public function getPortalid() + { + return $this->portalid; + } + + /** + * Getter for Key + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Getter for Mode + * + * @return string + */ + public function getMode() + { + return $this->mode; + } + + /** + * Getter for Encoding + * + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Getter for ApiVersion + * + * @return string + */ + public function getApiVersion() + { + return $this->apiVersion; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/Customer.php b/resources/lib/PayoneApi/Request/Parts/Customer.php new file mode 100644 index 00000000..0287205e --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/Customer.php @@ -0,0 +1,180 @@ +salutation = $gender == 'm' ? 'Herr' : 'Frau'; + $this->title = $title; + $this->firstname = $firstname; + $this->lastname = $lastname; + $this->address = $address; + $this->email = $email; + $this->telephonenumber = $telephonenumber; + $this->birthday = $birthday; + $this->language = $language; + $this->gender = $gender; + $this->ip = $ip; + $this->businessrelation = $businessrelation; + } + + /** + * Getter for Salutation + * + * @return string + */ + public function getSalutation() + { + return $this->salutation; + } + + /** + * Getter for Title + * + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * Getter for Firstname + * + * @return mixed + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * Getter for Lastname + * + * @return mixed + */ + public function getLastname() + { + return $this->lastname; + } + + /** + * Getter for Address + * + * @return CustomerAddress + */ + public function getAddress() + { + return $this->address; + } + + /** + * Getter for Email + * + * @return mixed + */ + public function getEmail() + { + return $this->email; + } + + /** + * Getter for Telephonenumber + * + * @return mixed + */ + public function getTelephonenumber() + { + return $this->telephonenumber; + } + + /** + * Getter for Birthday + * + * @return string + */ + public function getBirthday() + { + return str_replace('-', '', $this->birthday); + } + + /** + * Getter for Language + * + * @return mixed + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Getter for Gender + * + * @return mixed + */ + public function getGender() + { + return $this->gender; + } + + /** + * Getter for Ip + * + * @return mixed + */ + public function getIp() + { + return $this->ip; + } + + /** + * @return string + */ + public function getBusinessrelation() + { + return $this->businessrelation; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/CustomerAddress.php b/resources/lib/PayoneApi/Request/Parts/CustomerAddress.php new file mode 100644 index 00000000..f4001db0 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/CustomerAddress.php @@ -0,0 +1,80 @@ +street = $street; + $this->addressaddition = $addressaddition; + $this->zip = $zip; + $this->city = $city; + $this->country = $country; + } + + /** + * Getter for Street + * + * @return mixed + */ + public function getStreet() + { + return $this->street; + } + + /** + * Getter for Addressaddition + * + * @return mixed + */ + public function getAddressaddition() + { + return $this->addressaddition; + } + + /** + * Getter for Zip + * + * @return mixed + */ + public function getZip() + { + return $this->zip; + } + + /** + * Getter for City + * + * @return mixed + */ + public function getCity() + { + return $this->city; + } + + /** + * Getter for Country + * + * @return mixed + */ + public function getCountry() + { + return $this->country; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/RedirectUrls.php b/resources/lib/PayoneApi/Request/Parts/RedirectUrls.php new file mode 100644 index 00000000..f0466851 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/RedirectUrls.php @@ -0,0 +1,64 @@ +success = $success; + $this->error = $error; + $this->back = $back; + } + + /** + * Getter for Success + * + * @return string + */ + public function getSuccessurl() + { + return $this->success; + } + + /** + * Getter for Error + * + * @return string + */ + public function getErrorurl() + { + return $this->error; + } + + /** + * Getter for Back + * + * @return string + */ + public function getBackurl() + { + return $this->back; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/SepaMandate.php b/resources/lib/PayoneApi/Request/Parts/SepaMandate.php new file mode 100644 index 00000000..99cd3919 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/SepaMandate.php @@ -0,0 +1,85 @@ +mandateIdentification = $mandateIdentification; + $this->mandateDateofsignature = $mandateDateofsignature; + $this->iban = $iban; + $this->bic = $bic; + $this->bankcountry = $bankcountry; + } + + /** + * Getter for MandateIdentification + * + * @return string + */ + public function getMandateIdentification() + { + return $this->mandateIdentification; + } + + /** + * Getter for MandateDateofsignature + * + * @return string + */ + public function getMandateDateofsignature() + { + return $this->mandateDateofsignature; + } + + /** + * Getter for Iban + * + * @return string + */ + public function getIban() + { + return $this->iban; + } + + /** + * Getter for Bic + * + * @return string + */ + public function getBic() + { + return $this->bic; + } + + /** + * Getter for Bankcountry + * + * @return mixed + */ + public function getBankcountry() + { + return $this->bankcountry; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/ShippingAddress.php b/resources/lib/PayoneApi/Request/Parts/ShippingAddress.php new file mode 100644 index 00000000..c0a5e003 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/ShippingAddress.php @@ -0,0 +1,92 @@ +firstname = $firstname; + $this->lastname = $lastname; + $this->street = $street; + $this->addressaddition = $addressaddition; + $this->zip = $zip; + $this->city = $city; + $this->country = $country; + } + + /** + * @return mixed + */ + public function getShippingFirstname() + { + return $this->firstname; + } + + /** + * @return mixed + */ + public function getShippingLastname() + { + return $this->lastname; + } + + /** + * @return mixed + */ + public function getShippingStreet() + { + return $this->street; + } + + /** + * @return mixed + */ + public function getShippingAddressaddition() + { + return $this->addressaddition; + } + + /** + * @return mixed + */ + public function getShippingZip() + { + return $this->zip; + } + + /** + * @return mixed + */ + public function getShippingCity() + { + return $this->city; + } + + /** + * @return mixed + */ + public function getShippingCountry() + { + return $this->country; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/SystemInfo.php b/resources/lib/PayoneApi/Request/Parts/SystemInfo.php new file mode 100644 index 00000000..81770a04 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/SystemInfo.php @@ -0,0 +1,78 @@ +integratorName = $integratorName; + $this->integratorVersion = $integratorVersion; + $this->solutionName = $solutionName; + $this->solutionVersion = $solutionVersion; + } + + /** + * Getter for IntegratorName + * + * @return string + */ + public function getIntegratorName() + { + return $this->integratorName; + } + + /** + * Getter for IntegratorVersion + * + * @return string + */ + public function getIntegratorVersion() + { + return $this->integratorVersion; + } + + /** + * Getter for SolutionName + * + * @return string + */ + public function getSolutionName() + { + return $this->solutionName; + } + + /** + * Getter for SolutionVersion + * + * @return string + */ + public function getSolutionVersion() + { + return $this->solutionVersion; + } +} diff --git a/resources/lib/PayoneApi/Request/PaymentTypes.php b/resources/lib/PayoneApi/Request/PaymentTypes.php new file mode 100644 index 00000000..0f7ceda7 --- /dev/null +++ b/resources/lib/PayoneApi/Request/PaymentTypes.php @@ -0,0 +1,31 @@ +getConstants(); + } +} diff --git a/resources/lib/PayoneApi/Request/PreAuthorization/RequestFactory.php b/resources/lib/PayoneApi/Request/PreAuthorization/RequestFactory.php new file mode 100644 index 00000000..09534848 --- /dev/null +++ b/resources/lib/PayoneApi/Request/PreAuthorization/RequestFactory.php @@ -0,0 +1,14 @@ +txid = $txid; + $this->request = $request; + } + + /** + * Getter for Request + * + * @return GenericRequest + */ + public function getRequest() + { + return $this->request; + } + + /** + * Getter for Txid + * + * @return string + */ + public function getTxid() + { + return $this->txid; + } +} diff --git a/resources/lib/PayoneApi/Request/Refund/RequestFactory.php b/resources/lib/PayoneApi/Request/Refund/RequestFactory.php new file mode 100644 index 00000000..0d34e866 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Refund/RequestFactory.php @@ -0,0 +1,24 @@ +getConstants(); + } +} diff --git a/resources/lib/PayoneApi/Response/Clearing.php b/resources/lib/PayoneApi/Response/Clearing.php new file mode 100644 index 00000000..82132e89 --- /dev/null +++ b/resources/lib/PayoneApi/Response/Clearing.php @@ -0,0 +1,139 @@ +bankaccount = $responseData['clearing_bankaccount'] ?? ''; + $this->bankcode = $responseData['clearing_bankcode'] ?? ''; + $this->bankcountry = $responseData['clearing_bankcountry'] ?? ''; + $this->bankname = $responseData['clearing_bankname'] ?? ''; + $this->bankaccountholder = $responseData['clearing_bankaccountholder'] ?? ''; + $this->bankcity = $responseData['clearing_bankcity'] ?? ''; + $this->bankiban = $responseData['clearing_bankiban'] ?? ''; + $this->bankbic = $responseData['clearing_bankbic'] ?? ''; + } + + /** + * Getter for Bankaccount + * + * @return string + */ + public function getBankaccount() + { + return $this->bankaccount; + } + + /** + * Getter for Bankcode + * + * @return string + */ + public function getBankcode() + { + return $this->bankcode; + } + + /** + * Getter for Bankcountry + * + * @return string + */ + public function getBankcountry() + { + return $this->bankcountry; + } + + /** + * Getter for Bankname + * + * @return string + */ + public function getBankname() + { + return $this->bankname; + } + + /** + * Getter for Bankaccountholder + * + * @return string + */ + public function getBankaccountholder() + { + return $this->bankaccountholder; + } + + /** + * Getter for Bankcity + * + * @return string + */ + public function getBankcity() + { + return $this->bankcity; + } + + /** + * Getter for Bankiban + * + * @return string + */ + public function getBankiban() + { + return $this->bankiban; + } + + /** + * Getter for Bankbic + * + * @return string + */ + public function getBankbic() + { + return $this->bankbic; + } +} diff --git a/resources/lib/PayoneApi/Response/ClientErrorResponse.php b/resources/lib/PayoneApi/Response/ClientErrorResponse.php new file mode 100644 index 00000000..ca1bcdaf --- /dev/null +++ b/resources/lib/PayoneApi/Response/ClientErrorResponse.php @@ -0,0 +1,54 @@ +errorMessage = $errorMessage; + } + + /** + * @return bool + */ + public function getSuccess() + { + return false; + } + + /** + * @return string + */ + public function getErrorMessage() + { + return $this->errorMessage; + } + + /** + * @return string + */ + public function getStatus() + { + return ''; + } + + /** + * @return string + */ + public function getTransactionID() + { + return ''; + } +} diff --git a/resources/lib/PayoneApi/Response/GenericResponse.php b/resources/lib/PayoneApi/Response/GenericResponse.php new file mode 100644 index 00000000..ccf6ae88 --- /dev/null +++ b/resources/lib/PayoneApi/Response/GenericResponse.php @@ -0,0 +1,103 @@ +responseData = $responseData; + } + + /** + * Request success + * + * @return bool + */ + public function getSuccess() + { + if (!$this->responseData || $this->getStatus() == 'ERROR') { + return false; + } + + return true; + } + + /** + * Get full error description from response + * + * @return string + */ + public function getErrorMessage() + { + if ($this->getSuccess()) { + return ''; + } + + $response = 'empty response'; + if ($this->responseData) { + $response = print_r($this->responseData, true); + } + + return 'Payone returned an error: ' . $response; + } + + /** + * Get the transaction id + * + * @return string + */ + public function getTransactionID() + { + if (!isset($this->responseData['txid'])) { + return ''; + } + + return (string) $this->responseData['txid']; + } + + /** + * Getter for ResponseData + * + * @return array + */ + public function getResponseData() + { + return $this->responseData; + } + + /** + * @return string + */ + public function getStatus() + { + if (!isset($this->responseData['status'])) { + return ''; + } + + return (string) $this->responseData['status']; + } + + /** + * @return string + */ + public function getLibVersion() + { + return Version::getVersion(); + } +} diff --git a/resources/lib/PayoneApi/Response/ResponseContract.php b/resources/lib/PayoneApi/Response/ResponseContract.php new file mode 100644 index 00000000..02d307aa --- /dev/null +++ b/resources/lib/PayoneApi/Response/ResponseContract.php @@ -0,0 +1,40 @@ +getMethods() as $method) { + if (substr($method->name, 0, 3) != 'get') { + continue; + } + $propertyName = strtolower(substr($method->name, 3, 1)) . substr($method->name, 4); + + $value = $method->invoke($this); + if (method_exists($value, 'jsonSerialize') + && is_callable([$value, 'jsonSerialize'])) { + $value = $value->jsonSerialize(); + } + $result[$propertyName] = $value; + } + + return $result; + } +} diff --git a/resources/lib/PayoneApi/Response/ResponseDataContract.php b/resources/lib/PayoneApi/Response/ResponseDataContract.php new file mode 100644 index 00000000..c0890f92 --- /dev/null +++ b/resources/lib/PayoneApi/Response/ResponseDataContract.php @@ -0,0 +1,11 @@ + base64_encode($response)]); + } + $responseData = self::parseResponse($response); + if (strpos($response, 'clearing') !== false) { + $authResponse = new ResponseWithClearing($responseData); + + $clearing = new Clearing($authResponse->getResponseData()); + $authResponse->setClearing($clearing); + + return $authResponse; + } + + return new GenericResponse($responseData); + } + + /** + * @param string $response + * + * @return array + */ + private static function parseResponse($response) + { + $responseData = []; + $separator = "\n\t"; + $line = strtok($response, $separator); + + while ($line !== false) { + $responseData += self::parseLine($line); + $line = strtok($separator); + } + + return $responseData; + } + + /** + * @param $line + * + * @return array + */ + private static function parseLine($line) + { + if (!trim($line)) { + return []; + } + list($key, $value) = explode('=', $line, 2); + + return [trim($key) => trim($value)]; + } +} diff --git a/resources/lib/PayoneApi/Response/ResponseWithClearing.php b/resources/lib/PayoneApi/Response/ResponseWithClearing.php new file mode 100644 index 00000000..34090247 --- /dev/null +++ b/resources/lib/PayoneApi/Response/ResponseWithClearing.php @@ -0,0 +1,29 @@ +clearing = $clearing; + } + + /** + * Getter for Clearing + * + * @return Clearing + */ + public function getClearing() + { + return $this->clearing; + } +} diff --git a/resources/lib/PayoneApi/Response/Status.php b/resources/lib/PayoneApi/Response/Status.php new file mode 100644 index 00000000..de025ee5 --- /dev/null +++ b/resources/lib/PayoneApi/Response/Status.php @@ -0,0 +1,13 @@ +doRequest($request); diff --git a/resources/lib/doCapture.php b/resources/lib/doCapture.php index c3c113ba..21fc8deb 100644 --- a/resources/lib/doCapture.php +++ b/resources/lib/doCapture.php @@ -1,11 +1,12 @@ doRequest($request); +} catch (Exception $e) { + $errorResponse = new ClientErrorResponse( + 'SdkRestApi error: ' . $e->getMessage() . PHP_EOL . + 'Lib version: ' . Version::getVersion() . PHP_EOL . + $e->getTraceAsString() + ); + + return $errorResponse->jsonSerialize(); +} + +if (!$response->getSuccess()) { + $errorResponse = new ClientErrorResponse( + 'Request successful but response invalid. ' . PHP_EOL . + 'Lib version: ' . Version::getVersion() . PHP_EOL . + 'Message: ' . $response->getErrorMessage() . PHP_EOL . + 'Request was : ' . json_encode($serializer->serialize($request), JSON_PRETTY_PRINT) . PHP_EOL . + 'Response was: ' . json_encode($serializer->serialize($response), JSON_PRETTY_PRINT) + ); + return $errorResponse->jsonSerialize(); +} + +return $response->jsonSerialize(); diff --git a/resources/lib/doManagemandate.php b/resources/lib/doManagemandate.php index 1e856d5e..d1a5bb4d 100644 --- a/resources/lib/doManagemandate.php +++ b/resources/lib/doManagemandate.php @@ -1,11 +1,12 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/resources/lib/vendor/composer/LICENSE b/resources/lib/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/resources/lib/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/resources/lib/vendor/composer/autoload_classmap.php b/resources/lib/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..7a91153b --- /dev/null +++ b/resources/lib/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($baseDir . '/PayoneApi'), +); diff --git a/resources/lib/vendor/composer/autoload_real.php b/resources/lib/vendor/composer/autoload_real.php new file mode 100644 index 00000000..bac53af1 --- /dev/null +++ b/resources/lib/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInite0e92804b3676dcad52f71f8933f242a::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/resources/lib/vendor/composer/autoload_static.php b/resources/lib/vendor/composer/autoload_static.php new file mode 100644 index 00000000..e5a0ebfc --- /dev/null +++ b/resources/lib/vendor/composer/autoload_static.php @@ -0,0 +1,31 @@ + + array ( + 'PayoneApi\\' => 10, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'PayoneApi\\' => + array ( + 0 => __DIR__ . '/../..' . '/PayoneApi', + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInite0e92804b3676dcad52f71f8933f242a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInite0e92804b3676dcad52f71f8933f242a::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/resources/views/Partials/Error.twig b/resources/views/Partials/Error.twig index 0296dadd..cd534712 100755 --- a/resources/views/Partials/Error.twig +++ b/resources/views/Partials/Error.twig @@ -1,5 +1 @@ -{% if isDebugModeEnabled %} - {{ trans(errorMessage) }} -{% else %} - {{ trans('Payone::Template.orderErrorMessage') }} -{% endif %} \ No newline at end of file +{{ trans('Payone::Template.orderErrorMessage') }} \ No newline at end of file diff --git a/resources/views/Partials/Javascript.twig b/resources/views/Partials/Javascript.twig index 21922857..e547b0c4 100644 --- a/resources/views/Partials/Javascript.twig +++ b/resources/views/Partials/Javascript.twig @@ -1,3 +1,4 @@ +{% if (services.template.isCurrentTemplate('tpl.checkout') or services.template.isCurrentTemplate('tpl.my-account') or services.template.isCurrentTemplate('tpl.confirmation')) %} + +{% endif %} \ No newline at end of file diff --git a/resources/views/Partials/PaymentForm/PAYONE_PAYONE_CREDIT_CARD.twig b/resources/views/Partials/PaymentForm/PAYONE_PAYONE_CREDIT_CARD.twig index ca378c97..0908ae8d 100644 --- a/resources/views/Partials/PaymentForm/PAYONE_PAYONE_CREDIT_CARD.twig +++ b/resources/views/Partials/PaymentForm/PAYONE_PAYONE_CREDIT_CARD.twig @@ -28,21 +28,20 @@
-
- -
-
-
-
-
-
+
+
+
+ +
+
+
diff --git a/src/Adapter/Logger.php b/src/Adapter/Logger.php index b4932158..85a77c11 100644 --- a/src/Adapter/Logger.php +++ b/src/Adapter/Logger.php @@ -38,8 +38,8 @@ class Logger //implements LoggerContract * * @param ShopHelper $shopHelper */ - public function __construct(ShopHelper $shopHelper - ) { + public function __construct(ShopHelper $shopHelper) + { $this->shopHelper = $shopHelper; $this->identifier = __CLASS__; $this->logger = $this->getLogger($this->identifier); @@ -53,8 +53,7 @@ public function __construct(ShopHelper $shopHelper public function setIdentifier(string $identifier) { $this->logger = $this->getLogger($identifier); - $this->logger->setReferenceType($this->referenceType); - $this->logger->setReferenceValue($this->referenceValue); + $this->addReference($this->referenceType, $this->referenceValue); return $this; } @@ -69,12 +68,7 @@ public function debug( string $code, $additionalInfo = null ) { - if ($this->shopHelper->isDebugModeActive()) { - return $this->critical($code, $additionalInfo); - } - $this->getPlentyLogger()->debug(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -88,12 +82,7 @@ public function info( string $code, $additionalInfo = null ) { - if ($this->shopHelper->isDebugModeActive()) { - return $this->critical($code, $additionalInfo); - } - $this->getPlentyLogger()->info(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -107,12 +96,7 @@ public function notice( string $code, $additionalInfo = null ) { - if ($this->shopHelper->isDebugModeActive()) { - return $this->critical($code, $additionalInfo); - } - $this->getPlentyLogger()->notice(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -126,12 +110,7 @@ public function warning( string $code, $additionalInfo = null ) { - if ($this->shopHelper->isDebugModeActive()) { - return $this->critical($code, $additionalInfo); - } - $this->getPlentyLogger()->warning(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -146,7 +125,6 @@ public function error( $additionalInfo = null ) { $this->getPlentyLogger()->error(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -161,7 +139,6 @@ public function critical( $additionalInfo = null ) { $this->getPlentyLogger()->critical(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -176,7 +153,6 @@ public function alert( $additionalInfo = null ) { $this->getPlentyLogger()->alert(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -191,7 +167,6 @@ public function emergency( $additionalInfo = null ) { $this->getPlentyLogger()->emergency(PluginConstants::NAME . '::' . $code, $additionalInfo); - return $this; } @@ -205,35 +180,19 @@ public function logException( \Exception $exception ) { $this->getPlentyLogger()->logException($exception); - return $this; } - - /** - * @param string $referenceType - * - * @return Logger - */ - public function setReferenceType( - string $referenceType - ) { - $this->referenceType = $referenceType; - $this->logger->setReferenceType($referenceType); - - return $this; - } - + /** - * @param $referenceValue + * Adds a reference to the current logger instance, for a more understanding log message. * - * @return Logger + * @param string $referenceType The reference type to be added to the log (e.g. orderId) + * @param string $referenceValue The reference value for the current log message. + * @return $this */ - public function setReferenceValue( - $referenceValue - ) { - $this->referenceValue = $referenceValue; - $this->logger->setReferenceValue($referenceValue); - + public function addReference($referenceType, $referenceValue) + { + $this->logger->addReference($referenceType, $referenceValue); return $this; } diff --git a/src/Controllers/CheckoutController.php b/src/Controllers/CheckoutController.php index a2ce968b..9aacf3b3 100644 --- a/src/Controllers/CheckoutController.php +++ b/src/Controllers/CheckoutController.php @@ -11,6 +11,7 @@ use Payone\Models\BankAccountCache; use Payone\Models\CreditCardCheckResponse; use Payone\Models\CreditCardCheckResponseRepository; +use Payone\Models\PaymentCache; use Payone\Models\SepaMandateCache; use Payone\PluginConstants; use Payone\Services\PaymentService; @@ -81,7 +82,7 @@ public function doAuth( BasketRepositoryContract $basket ) { $this->logger->setIdentifier(__METHOD__) - ->debug('CheckoutController', $this->request->all()); + ->debug('Controller.Checkout', $this->request->all()); if (!$this->sessionHelper->isLoggedIn()) { return $this->getJsonErrors([ 'message' => 'Your session expired. Please login and start a new purchase.', @@ -109,7 +110,7 @@ public function storeCCCheckResponse( CardExpireDate $validator ) { $this->logger->setIdentifier(__METHOD__) - ->debug('CheckoutController', $this->request->all()); + ->debug('Controller.Checkout', $this->request->all()); if (!$this->sessionHelper->isLoggedIn()) { return $this->getJsonErrors(['message' => 'Your session expired. Please login and start a new purchase.']); } @@ -165,7 +166,7 @@ public function storeAccountData( 'iban' => $this->request->get('iban'), 'bic' => $this->request->get('bic'), ]; - $this->logger->setIdentifier(__METHOD__)->debug('Router.routeCalled', $this->request->all()); + $this->logger->setIdentifier(__METHOD__)->debug('Controller.routeCalled', $this->request->all()); foreach ($formData as $key => $value) { if (empty($formData[$key])) { @@ -245,16 +246,30 @@ public function getSepaMandateStep(Twig $twig, SepaMandateCache $sepaMandateCach * * @return string */ - public function checkoutSuccess(BasketRepositoryContract $basketReopo, PaymentHelper $helper) + public function checkoutSuccess(BasketRepositoryContract $basketReopo, PaymentHelper $helper, PaymentCache $paymentCache) { $this->logger->setIdentifier(__METHOD__); $this->logger->debug('Controller.Success', $this->request->all()); + $transactionBasketId = $this->request->get('transactionBasketId'); + if(strlen($transactionBasketId)){ + $storedBasketId = $paymentCache->getActiveBasketId(); + if($storedBasketId === null){ + return $this->response->redirectTo('confirmation'); + } + if($storedBasketId != $transactionBasketId){ + return $this->response->redirectTo('payone/error'); + } + } + else{ + return $this->response->redirectTo('payone/error'); + } $basket = $basketReopo->load(); if (!$helper->isPayonePayment($basket->methodOfPaymentId)) { return $this->response->redirectTo('payone/error'); } + $paymentCache->resetActiveBasketId(); return $this->response->redirectTo('place-order'); } @@ -269,7 +284,7 @@ public function redirectWithNotice( ErrorMessageRenderer $messageRenderer ) { $this->logger->setIdentifier(__METHOD__); - $this->logger->debug('redirecting'); + $this->logger->debug('Controller.redirecting'); //info would be enought but is not shown in frontend $notificationService->error($messageRenderer->render('Payone::Template.orderErrorMessage')); diff --git a/src/Controllers/ConfigController.php b/src/Controllers/ConfigController.php deleted file mode 100644 index 6eba0b5e..00000000 --- a/src/Controllers/ConfigController.php +++ /dev/null @@ -1,267 +0,0 @@ -configRepo = $configRepo; - $this->paymentMethodRepo = $paymentMethodRepo; - $this->paymentHelper = $paymentHelper; - $this->shopHelper = $shopHelper; - } - - /** - * @param Request $request - */ - public function printConfig(Request $request) - { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - - try { - return json_encode($this->configRepo->get(PluginConstants::NAME), JSON_PRETTY_PRINT) . - PHP_EOL . $request->get('configPath') . PHP_EOL . - json_encode($this->configRepo->get($request->get('configPath')), - JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - public function migrate(CreatePaymentMethods $migration) - { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - $migration->run(); - - return __METHOD__; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - public function printAllPaymentMethods() - { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - $paymentMethods = $this->paymentMethodRepo->all(); - - $text = ''; - foreach ($paymentMethods as $paymentMethod) { - $text .= $paymentMethod->id . ': ' . $paymentMethod->paymentKey . PHP_EOL; - } - - return $text; - } - - /** - * @param Request $request - * @param Api $api - * @param PreAuthDataProvider $provider - * @param BasketRepositoryContract $basket - * - * @return string|void - */ - public function doPreCheck( - Request $request, - Api $api, - PreAuthDataProvider $provider, - BasketRepositoryContract $basket - ) { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - $paymentCode = $request->get('paymentCode'); - $response = $api->doPreAuth( - $provider->getDataFromBasket($paymentCode, $basket->load()) - ); - - return json_encode($response, JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return PHP_EOL . - $e->getCode() . PHP_EOL . - $e->getMessage() . PHP_EOL . - $e->getTraceAsString(); - } - } - - /** - * @param Request $request - * @param PreAuthDataProvider $provider - * @param BasketRepositoryContract $basket - * - * @return string|void - */ - public function testRequestData( - Request $request, - PreAuthDataProvider $provider, - BasketRepositoryContract $basket - ) { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - return json_encode($provider->getDataFromBasket($request->get('paymentCode'), $basket->load()), - JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return PHP_EOL . - $e->getCode() . PHP_EOL . - $e->getMessage() . PHP_EOL . - $e->getTraceAsString(); - } - } - - /** - * @param Request $request - * @param ShippingProfileRepositoryContract $shippingProfileRepositoryContract - * - * @return string|void - */ - public function printShippingProfiles( - Request $request, - ShippingProfileRepositoryContract $shippingProfileRepositoryContract - ) { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - $shippingProviderId = $request->get('id'); - - /** @var \Plenty\Modules\Authorization\Services\AuthHelper $authHelper */ - $authHelper = pluginApp(AuthHelper::class); - $response = $authHelper->processUnguarded( - function () use ($shippingProfileRepositoryContract, $shippingProviderId) { - return $shippingProfileRepositoryContract->get($shippingProviderId); - } - ); - - return json_encode($response, JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return PHP_EOL . - $e->getCode() . PHP_EOL . - $e->getMessage() . PHP_EOL . - $e->getTraceAsString(); - } - } - - /** - * @param Request $request - * @param ItemShippingProfilesRepositoryContract $shippingProfileRepositoryContract - * - * @return string|void - */ - public function printItemShippingProfiles( - Request $request, - ItemShippingProfilesRepositoryContract $shippingProfileRepositoryContract - ) { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - $shippingProviderId = $request->get('id'); - - /** @var \Plenty\Modules\Authorization\Services\AuthHelper $authHelper */ - $authHelper = pluginApp(AuthHelper::class); - $response = $authHelper->processUnguarded( - function () use ($shippingProfileRepositoryContract, $shippingProviderId) { - return $shippingProfileRepositoryContract->find($shippingProviderId); - } - ); - - return json_encode($response, JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return PHP_EOL . - $e->getCode() . PHP_EOL . - $e->getMessage() . PHP_EOL . - $e->getTraceAsString(); - } - } - - /** - * @param Request $request - * @param ParcelServicePresetRepositoryContract $shippingProfileRepositoryContract - * - * @return string|void - */ - public function printParcelServicePreset( - Request $request, - ParcelServicePresetRepositoryContract $shippingProfileRepositoryContract - ) { - if (!$this->shopHelper->isDebugModeActive()) { - return; - } - try { - $shippingProviderId = $request->get('id'); - - /** @var \Plenty\Modules\Authorization\Services\AuthHelper $authHelper */ - $authHelper = pluginApp(AuthHelper::class); - $response = $authHelper->processUnguarded( - function () use ($shippingProfileRepositoryContract, $shippingProviderId) { - return $shippingProfileRepositoryContract->getPresetById($shippingProviderId); - } - ); - - return json_encode($response, JSON_PRETTY_PRINT); - } catch (\Exception $e) { - return PHP_EOL . - $e->getCode() . PHP_EOL . - $e->getMessage() . PHP_EOL . - $e->getTraceAsString(); - } - } -} diff --git a/src/Controllers/StatusController.php b/src/Controllers/StatusController.php index e1ea3e08..0d979865 100644 --- a/src/Controllers/StatusController.php +++ b/src/Controllers/StatusController.php @@ -4,13 +4,15 @@ use Payone\Adapter\Config as ConfigAdapter; use Payone\Adapter\Logger; +use Payone\Methods\PayoneInvoiceSecurePaymentMethod; use Payone\Migrations\CreatePaymentMethods; use Payone\Services\PaymentCreation; +use Payone\Services\PaymentDocuments; use Plenty\Plugin\Controller; use Plenty\Plugin\Http\Request; /** - * Class ConfigController + * Class StatusController */ class StatusController extends Controller { @@ -32,6 +34,12 @@ class StatusController extends Controller * @var CreatePaymentMethods */ private $paymentMigration; + + /** + * @var PaymentDocuments + */ + private $paymentDocument; + /** * @var Logger */ @@ -43,6 +51,7 @@ class StatusController extends Controller * @param Request $request * @param ConfigAdapter $config * @param PaymentCreation $paymentCreation + * @param PaymentDocuments $paymentDocument * @param CreatePaymentMethods $paymentMigration * @param Logger $logger */ @@ -50,12 +59,15 @@ public function __construct( Request $request, ConfigAdapter $config, PaymentCreation $paymentCreation, + PaymentDocuments $paymentDocument, CreatePaymentMethods $paymentMigration, Logger $logger - ) { + ) + { $this->request = $request; $this->config = $config; $this->paymentCreation = $paymentCreation; + $this->paymentDocument = $paymentDocument; $this->paymentMigration = $paymentMigration; $this->logger = $logger; } @@ -71,15 +83,24 @@ public function index() } $this->logger->setIdentifier(__METHOD__); - $this->logger->setReferenceType(Logger::PAYONE_REQUEST_REFERENCE); - $this->logger->setReferenceValue($txid); - $this->logger->critical('Controller.Status', $this->request->all()); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $txid); + $this->logger->debug('Controller.Status', $this->request->all()); - if ($this->request->get('key') != md5($this->config->get('key'))) { + if ($this->request->get('key') != md5($this->config->get(PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE . '.key')) && + $this->request->get('key') != md5($this->config->get('key'))) { return; } - $this->paymentCreation->updatePaymentStatus($txid, $txaction, $sequenceNumber); + if ($txaction === 'invoice') { + $this + ->paymentDocument + ->addInvoiceToOrder($txid, + $this->request->get('invoiceid'), + $this->request->get('invoice_date'), + $this->request->get('invoice_grossamount')); + } else { + $this->paymentCreation->updatePaymentStatus($txid, $txaction, $sequenceNumber); + } return 'TSOK'; } diff --git a/src/Helpers/OrderHelper.php b/src/Helpers/OrderHelper.php index 8e8845e4..734369c6 100644 --- a/src/Helpers/OrderHelper.php +++ b/src/Helpers/OrderHelper.php @@ -2,12 +2,18 @@ namespace Payone\Helpers; +use Payone\PluginConstants; +use Plenty\Modules\Authorization\Services\AuthHelper; +use Plenty\Modules\Comment\Contracts\CommentRepositoryContract; use Plenty\Modules\Order\Models\Order; use Plenty\Modules\Order\Property\Models\OrderProperty; use Plenty\Modules\Order\Property\Models\OrderPropertyType; +use Plenty\Plugin\ConfigRepository; +use Plenty\Plugin\Log\Loggable; class OrderHelper { + use Loggable; /** * @param Order $order * @@ -24,4 +30,45 @@ public function getLang(Order $order) return 'DE'; } + + /** + * Adds a note to an order + * + * @param $refValue + * @param $msg + * @param null $backendUserId + * @throws \Throwable + * + */ + public function addOrderComment($refValue, $msg) + { + /** @var ConfigRepository $configRepository */ + $configRepository = pluginApp(ConfigRepository::class); + $backendUserId = $configRepository->get(PluginConstants::NAME . '.userId', null); + + if (isset($backendUserId)) + { + $commentData = []; + $commentData['referenceType'] = 'order'; + $commentData['referenceValue'] = $refValue; + $commentData['text'] = $msg; + $commentData['isVisibleForContact'] = false; + $commentData['userId'] = (int) $backendUserId; + + try + { + /** @var AuthHelper $authHelper */ + $authHelper = pluginApp(AuthHelper::class); + + $authHelper->processUnguarded( + function () use ($commentData) { + /** @var CommentRepositoryContract $commentRepo */ + $commentRepo = pluginApp(CommentRepositoryContract::class); + //unguarded + $commentRepo->createComment($commentData); + } + ); + } catch (\Exception $e) {} + } + } } diff --git a/src/Helpers/PaymentHelper.php b/src/Helpers/PaymentHelper.php index 6b7d6435..8a80f7ab 100644 --- a/src/Helpers/PaymentHelper.php +++ b/src/Helpers/PaymentHelper.php @@ -4,6 +4,7 @@ namespace Payone\Helpers; +use Payone\Methods\PayoneAmazonPayPaymentMethod; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Methods\PayoneCODPaymentMethod; use Payone\Methods\PayoneDirectDebitPaymentMethod; @@ -130,6 +131,7 @@ public function getPaymentCodes() PayoneCCPaymentMethod::PAYMENT_CODE, PayoneDirectDebitPaymentMethod::PAYMENT_CODE, PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::PAYMENT_CODE ]; } @@ -177,4 +179,65 @@ public function getPaymentPropertyValue($payment, $propertyTypeConstant) return ''; } + + public function raiseSequenceNumber(Payment $payment) + { + foreach ($payment->properties as $property) { + if($property->typeId == PaymentProperty::TYPE_TRANSACTION_CODE) { + $property->value++; + return $payment; + } + } + + $properties = $payment->properties; + $properties[] = $this->createPaymentProperty(PaymentProperty::TYPE_TRANSACTION_CODE, 1); + $payment->properties = $properties; + + return $payment; + } + + + /** + * @param Payment $payment + * @param int $pamentPropertyTypeId + * @param string $value + * + * @return Payment + */ + public function createOrUpdatePaymentProperty($payment, $pamentPropertyTypeId, $value) + { + foreach ($payment->properties as $property) { + if (!($property instanceof PaymentProperty)) { + continue; + } + if ($property->typeId === $pamentPropertyTypeId) { + $property->value = $value; + return $payment; + } + } + + $paymentProperties = $payment->properties; + $paymentProperties[] = $this->createPaymentProperty($pamentPropertyTypeId, $value); + + return $payment; + } + + /** + * Returns a PaymentProperty with the given params + * + * @param int $typeId + * @param string $value + * + * @return PaymentProperty + */ + protected function createPaymentProperty($typeId, $value) + { + /** @var PaymentProperty $paymentProperty */ + $paymentProperty = pluginApp(PaymentProperty::class); + + $paymentProperty->typeId = $typeId; + $paymentProperty->value = $value . ''; + + return $paymentProperty; + } } diff --git a/src/Helpers/ShopHelper.php b/src/Helpers/ShopHelper.php index 778ff845..36f395e9 100644 --- a/src/Helpers/ShopHelper.php +++ b/src/Helpers/ShopHelper.php @@ -79,17 +79,6 @@ public function getCurrentCurrency() return $config['currency'] ?? $this->getDefaultCurrency(); } - /** - * @return bool - */ - public function isDebugModeActive() - { - /** @var ConfigRepository $config */ - $config = pluginApp(ConfigRepository::class); - - return (bool) $config->get(PluginConstants::NAME . '.debugging.active'); - } - /** * @return string */ diff --git a/src/Methods/PaymentAbstract.php b/src/Methods/PaymentAbstract.php index c5bef321..c57f321e 100644 --- a/src/Methods/PaymentAbstract.php +++ b/src/Methods/PaymentAbstract.php @@ -4,10 +4,10 @@ use Payone\Adapter\Config as ConfigAdapter; use Payone\PluginConstants; -use Plenty\Modules\Payment\Method\Contracts\PaymentMethodService; +use Plenty\Modules\Payment\Method\Services\PaymentMethodBaseService; use Plenty\Plugin\Application; -abstract class PaymentAbstract extends PaymentMethodService +abstract class PaymentAbstract extends PaymentMethodBaseService { const PAYMENT_CODE = 'Payone'; @@ -45,18 +45,19 @@ public function __construct( /** * @return bool */ - public function isActive() + public function isActive(): bool { return (bool) $this->configRepo->get($this::PAYMENT_CODE . '.active') - && $this->paymentValidator->validate($this); + && $this->paymentValidator->validate($this, $this->configRepo); } /** * Get shown name * + * @param string $lang * @return string */ - public function getName(): string + public function getName(string $lang = 'de'): string { $name = $this->configRepo->get($this::PAYMENT_CODE . '.name'); @@ -72,9 +73,10 @@ public function getFee(): float } /** + * @param string $lang * @return string */ - public function getIcon(): string + public function getIcon(string $lang = 'de'): string { $pluginPath = $this->app->getUrlPath(PluginConstants::NAME); @@ -82,9 +84,10 @@ public function getIcon(): string } /** + * @param string $lang * @return string */ - public function getDescription(): string + public function getDescription(string $lang = 'de'): string { $description = $this->configRepo->get($this::PAYMENT_CODE . '.description'); @@ -131,4 +134,89 @@ public function getAllowedCountries() return $countries; } + + /** + * Check if this payment method should be searchable in the backend + * + * @return bool + */ + public function isBackendSearchable():bool + { + return true; + } + + /** + * Check if this payment method should be active in the backend + * + * @return bool + */ + public function isBackendActive():bool + { + return false; + } + + /** + * Get name for the backend + * + * @param string $lang + * @return string + */ + public function getBackendName(string $lang = 'de'):string + { + return $this->getName(); + } + + /** + * Check if this payment method can handle subscriptions + * + * @return bool + */ + public function canHandleSubscriptions():bool + { + return false; + } + + /** + * Get the url for the backend icon + * + * @return string + */ + public function getBackendIcon(): string + { + $app = pluginApp(Application::class); + $icon = $app->getUrlPath(PluginConstants::NAME).'/images/logos/'.strtolower($this::PAYMENT_CODE).'_backend_icon.svg'; + return $icon; + } + + /** + * Can the delivery address be different from the invoice address? + * + * @return bool + */ + public function canHandleDifferingDeliveryAddress(): bool + { + return true; + } + + /** + * Check if all settings for the payment method are set. + * + * @param ConfigAdapter $configRepo + * @return bool + */ + public function validateSettings(ConfigAdapter $configRepo): bool + { + return true; + } + + /** + * Is the payment method active for the given currency? + * + * @param $currency + * @return bool + */ + public function isActiveForCurrency($currency): bool + { + return true; + } } diff --git a/src/Methods/PaymentMethodServiceFactory.php b/src/Methods/PaymentMethodServiceFactory.php index 0b3d49f9..c0fa6ecf 100644 --- a/src/Methods/PaymentMethodServiceFactory.php +++ b/src/Methods/PaymentMethodServiceFactory.php @@ -37,6 +37,8 @@ public static function create($paymentCode) return pluginApp(PayoneDirectDebitPaymentMethod::class); case PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE; return pluginApp(PayoneInvoiceSecurePaymentMethod::class); + case PayoneAmazonPayPaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneAmazonPayPaymentMethod::PAYMENT_CODE); } throw new \InvalidArgumentException('Unknown payment method ' . $paymentCode); } diff --git a/src/Methods/PaymentValidator.php b/src/Methods/PaymentValidator.php index 3065a59c..be0f4a22 100644 --- a/src/Methods/PaymentValidator.php +++ b/src/Methods/PaymentValidator.php @@ -6,6 +6,7 @@ use Payone\Helpers\AddressHelper; use Plenty\Modules\Basket\Contracts\BasketRepositoryContract; use Plenty\Modules\Basket\Models\Basket; +use Payone\Adapter\Config as ConfigAdapter; class PaymentValidator { @@ -42,7 +43,7 @@ public function __construct(BasketRepositoryContract $basket, AddressHelper $add * * @return bool */ - public function validate(PaymentAbstract $payment) + public function validate(PaymentAbstract $payment, ConfigAdapter $configRepo) { $basketAmount = $this->basket->basketAmount; if ($payment->getMinCartAmount() && $basketAmount < $payment->getMinCartAmount()) { @@ -58,8 +59,9 @@ public function validate(PaymentAbstract $payment) } $billingAddress = $this->addressHelper->getBasketBillingAddress($this->basket); - $shippingAddress = $this->addressHelper->getBasketShippingAddress($this->basket); + $deliveryAddress = $this->addressHelper->getBasketShippingAddress($this->basket); if (!$billingAddress) { + // TODO: shouldn't this be 'return false'? return true; } @@ -69,6 +71,18 @@ public function validate(PaymentAbstract $payment) return false; } + + if (!$payment->canHandleDifferingDeliveryAddress() && $deliveryAddress && $billingAddress->id != $deliveryAddress->id) { + return false; + } + + if (!$payment->validateSettings($configRepo)) { + return false; + } + + if (!$payment->isActiveForCurrency($this->basket->currency)) { + return false; + } return true; } diff --git a/src/Methods/PayoneAmazonPayPaymentMethod.php b/src/Methods/PayoneAmazonPayPaymentMethod.php new file mode 100644 index 00000000..5979e569 --- /dev/null +++ b/src/Methods/PayoneAmazonPayPaymentMethod.php @@ -0,0 +1,8 @@ +get(self::PAYMENT_CODE . '.portalid'); + $key = $configRepo->get(self::PAYMENT_CODE . '.key'); + + // A separate portal ID and key must be set for this payment method + return (!empty($portalId) && !empty($key)); + } + + /** + * Is the payment method active for the given currency? + * + * @param $currency + * @return bool + */ + public function isActiveForCurrency($currency): bool + { + return $currency == 'EUR'; + } } diff --git a/src/Migrations/CreateAmazonPayPaymentMethod.php b/src/Migrations/CreateAmazonPayPaymentMethod.php new file mode 100644 index 00000000..cd35d3e6 --- /dev/null +++ b/src/Migrations/CreateAmazonPayPaymentMethod.php @@ -0,0 +1,68 @@ +paymentMethodRepo = $paymentMethodRepo; + $this->paymentHelper = $paymentHelper; + $this->logger = $logger; + } + + /** + * Run on plugin build + * + * Create Payone payment methods + */ + public function run() + { + $paymentCode = PayoneAmazonPayPaymentMethod::PAYMENT_CODE; + if ($this->paymentHelper->getMopId($paymentCode) != 'no_paymentmethod_found') { + $this->logger->debug(' Skipping payment method creation of ' . $paymentCode); + return true; + } + $this->logger->debug(' Creating payment method ' . $paymentCode); + $this->paymentMethodRepo->createPaymentMethod([ + 'pluginKey' => PluginConstants::NAME, + 'paymentKey' => $paymentCode, + 'name' => $paymentCode, + ]); + } +} diff --git a/src/Models/Api/GetInvoiceResponse.php b/src/Models/Api/GetInvoiceResponse.php new file mode 100644 index 00000000..2edf5766 --- /dev/null +++ b/src/Models/Api/GetInvoiceResponse.php @@ -0,0 +1,46 @@ +success = $success; + $this->errorMessage = $errorMessage; + $this->base64 = $base64; + return $this; + } + + public function jsonSerialize(): array + { + return parent::jsonSerialize() + + [ + 'document' => $this->base64 + ]; + } + + /** + * Getter for Base64 + * + * @return string + */ + public function getBase64(): string + { + return $this->base64; + } +} diff --git a/src/Models/Api/GetInvoiceResponseFactory.php b/src/Models/Api/GetInvoiceResponseFactory.php new file mode 100644 index 00000000..d519247c --- /dev/null +++ b/src/Models/Api/GetInvoiceResponseFactory.php @@ -0,0 +1,26 @@ +init( + $responseData['success'] ?? false, + $responseData['errormessage'] ?? '', + $responseData['responseData']['document'] ?? '' + ); + } +} diff --git a/src/Models/CreditcardTypes.php b/src/Models/CreditcardTypes.php index 4a413c1f..23896fbd 100644 --- a/src/Models/CreditcardTypes.php +++ b/src/Models/CreditcardTypes.php @@ -51,7 +51,10 @@ public function getAllowedTypes(): array $allowedTypesFromConfig = explode(', ', $allowedTypesFromConfigString); - return array_intersect($this->getCreditCardTypes(), $allowedTypesFromConfig); + return $allowedTypesFromConfig; + + //do not intersect this, it will break the cardtype selection (visa, maestro) + //return array_intersect($this->getCreditCardTypes(), $allowedTypesFromConfig); } /** diff --git a/src/Models/PaymentCache.php b/src/Models/PaymentCache.php index 5b2c132d..1966dc6f 100644 --- a/src/Models/PaymentCache.php +++ b/src/Models/PaymentCache.php @@ -56,6 +56,24 @@ public function deletePayment(string $paymentCode) ); } + public function setActiveBasketId($transactionBasketId){ + $this->sessionStorage->setSessionValue( + $this->getStorageKey('activeTransactionBasketId'), + $transactionBasketId + ); + } + + public function getActiveBasketId(){ + return $this->sessionStorage->getSessionValue($this->getStorageKey('activeTransactionBasketId')); + } + + public function resetActiveBasketId(){ + $this->sessionStorage->setSessionValue( + $this->getStorageKey('activeTransactionBasketId'), + null + ); + } + /** * @param string $paymentCode * diff --git a/src/Models/PaymentConfig/ApiCredentials.php b/src/Models/PaymentConfig/ApiCredentials.php index bccb6e94..3f4568b8 100644 --- a/src/Models/PaymentConfig/ApiCredentials.php +++ b/src/Models/PaymentConfig/ApiCredentials.php @@ -22,17 +22,25 @@ public function __construct( } /** + * @param int|null $paymentCode * @return string */ - public function getKey(): string + public function getKey($paymentCode = null) { + if ($paymentCode !== null) { + $key = $this->configRepo->get($paymentCode . '.key'); + if (!empty($key)) { + return $key; + } + } + return $this->configRepo->get('key'); } /** * @return string */ - public function getAid(): string + public function getAid() { return $this->configRepo->get('aid'); } @@ -40,23 +48,31 @@ public function getAid(): string /** * @return string */ - public function getMid(): string + public function getMid() { return $this->configRepo->get('mid'); } /** + * @param int|null $paymentCode * @return string */ - public function getPortalid(): string + public function getPortalid($paymentCode = null) { + if ($paymentCode !== null) { + $portalId = $this->configRepo->get($paymentCode . '.portalid'); + if (!empty($portalId)) { + return $portalId; + } + } + return $this->configRepo->get('portalid'); } /** * @return string */ - public function getMode(): string + public function getMode() { $mode = $this->configRepo->get('mode'); @@ -64,15 +80,16 @@ public function getMode(): string } /** + * @param int|null $paymentCode * @return array */ - public function getApiCredentials() + public function getApiCredentials($paymentCode = null) { $apiContextParams = []; $apiContextParams['aid'] = $this->getAid(); $apiContextParams['mid'] = $this->getMid(); - $apiContextParams['portalid'] = $this->getPortalid(); - $apiContextParams['key'] = $this->getKey(); + $apiContextParams['portalid'] = $this->getPortalid($paymentCode); + $apiContextParams['key'] = $this->getKey($paymentCode); $apiContextParams['mode'] = $this->getMode(); return $apiContextParams; diff --git a/src/PluginConstants.php b/src/PluginConstants.php index 4bc1cb8e..16ae108c 100644 --- a/src/PluginConstants.php +++ b/src/PluginConstants.php @@ -5,5 +5,5 @@ class PluginConstants { const NAME = 'Payone'; - const VERSION = '1.0.6'; + const VERSION = '1.1.3'; } diff --git a/src/Providers/Api/Request/AuthDataProvider.php b/src/Providers/Api/Request/AuthDataProvider.php index bf466239..2f65eb30 100644 --- a/src/Providers/Api/Request/AuthDataProvider.php +++ b/src/Providers/Api/Request/AuthDataProvider.php @@ -42,7 +42,7 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r } if ($this->paymentHasRedirect($paymentCode)) { - $requestParams['redirect'] = $this->getRedirectUrls(); + $requestParams['redirect'] = $this->getRedirectUrls($basket->id); } if ($paymentCode == PayoneCCPaymentMethod::PAYMENT_CODE) { $requestParams['ccCheck'] = $this->getCreditCardData()->jsonSerialize(); diff --git a/src/Providers/Api/Request/CaptureDataProvider.php b/src/Providers/Api/Request/CaptureDataProvider.php index 2a7816a9..06c9df9b 100644 --- a/src/Providers/Api/Request/CaptureDataProvider.php +++ b/src/Providers/Api/Request/CaptureDataProvider.php @@ -66,7 +66,6 @@ private function getSettleaccount(string $paymentCode) in_array( $paymentCode, [ - PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, PayoneInvoicePaymentMethod::PAYMENT_CODE, PayonePrePaymentPaymentMethod::PAYMENT_CODE, PayoneSofortPaymentMethod::PAYMENT_CODE, diff --git a/src/Providers/Api/Request/DataProviderAbstract.php b/src/Providers/Api/Request/DataProviderAbstract.php index 98df58ec..abe3f5eb 100644 --- a/src/Providers/Api/Request/DataProviderAbstract.php +++ b/src/Providers/Api/Request/DataProviderAbstract.php @@ -172,10 +172,12 @@ protected function getCartItemData(Basket $basket) /** @var ItemText $itemText */ $itemText = $item->texts; - $basketItem = $basketItem->toArray(); - $basketItem['name'] = $itemText->first()->name1; + $basketItemArr = $basketItem->toArray(); + $basketItemArr['name'] = $itemText->first()->name1; + $basketItemArr['price'] = (int)round($basketItem->price * 100); + $basketItemArr['vat'] = (int)$basketItem->vat; - $items[] = $basketItem; + $items[] = $basketItemArr; } return $items; @@ -200,7 +202,7 @@ protected function getOrderItemData(Order $order) } $orderItemData = $orderItem->toArray(); $amount = $orderItemData['amounts'][0]; - $orderItemData['vat'] = $orderItemData['vatRate']; + $orderItemData['vat'] = (int)$orderItemData['vatRate']; $orderItemData['price'] = (int)round($amount['priceGross'] * 100); $orderItemData['name'] = $orderItemData['orderItemName']; $orderItemData['itemId'] = $orderItemData['id']; @@ -228,17 +230,32 @@ protected function getCustomerData(Address $addressObj, $customerId) 'firstname' => (string)$addressObj->firstName, 'lastname' => (string)$addressObj->lastName, 'title' => '', // (string)$addressObj->title: '', - 'birthday' => $this->getBirthDay($addressObj), 'ip' => (string)$this->shopHelper->getIpAddress(), 'customerId' => (string)$customerId, - 'registrationDate' => '1970-01-01', + //'registrationDate' => '1970-01-01', // what the ... is this? 'group' => 'default', 'company' => (string)$addressObj->companyName, 'telephonenumber' => (string)$addressObj->phone, 'language' => $this->shopHelper->getCurrentLanguage(), ]; - //TODO: Check format + + $dateOfBirth = $this->getBirthDay($addressObj); + $customerData['birthday'] = ''; + if(isset($dateOfBirth)) { + $customerData['birthday'] = $dateOfBirth; + } + $customerData['gender'] = 'm'; + if($addressObj->gender == 'female') { + $customerData['gender'] = 'f'; + } + + $taxIdNumber = $addressObj->taxIdNumber; + if (!empty($taxIdNumber)) { + $customerData['businessrelation'] = 'b2b'; + } else { + $customerData['businessrelation'] = 'b2c'; + } return $customerData; } @@ -253,30 +270,30 @@ protected function getDefaultRequestData($paymentCode) return [ 'paymentMethod' => $this->mapPaymentCode($paymentCode), 'systemInfo' => $this->getSystemInfo(), - 'context' => $this->getApiContextParams(), + 'context' => $this->getApiContextParams($paymentCode), ]; } /** + * @param int $paymentCode * @return array */ - protected function getApiContextParams() + protected function getApiContextParams($paymentCode) { - return $this->config->getApiCredentials(); + return $this->config->getApiCredentials($paymentCode); } /** * @param Address $addressObj - * - * @return string + * @return false|string|null */ - protected function getBirthDay(Address $addressObj): string + protected function getBirthDay(Address $addressObj) { - if (!$addressObj->birthday) { - return '1970-01-01'; + if(!isset($addressObj->birthday) || !strlen($addressObj->birthday)) { + return null; } - - return date('Y-m-d', $addressObj->birthday); + $dateOfBirth = strtotime($addressObj->birthday); + return date('Y-m-d', $dateOfBirth); } /** @@ -299,6 +316,16 @@ protected function getInvoiceData() */ protected function getBasketData(Basket $basket) { + /** @var \Plenty\Modules\Frontend\Services\VatService $vatService */ + $vatService = pluginApp(\Plenty\Modules\Frontend\Services\VatService::class); + + //we have to manipulate the basket because its stupid and doesnt know if its netto or gross + if(!count($vatService->getCurrentTotalVats())) { + $basket->itemSum = $basket->itemSumNet; + $basket->shippingAmount = $basket->shippingAmountNet; + $basket->basketAmount = $basket->basketAmountNet; + } + $requestParams = $basket->toArray(); $requestParams['currency'] = (bool)$basket->currency ? $basket->currency : ShopHelper::DEFAULT_CURRENCY; $requestParams['grandTotal'] = (int)round($basket->basketAmount * 100); @@ -329,6 +356,11 @@ protected function getBasketDataFromOrder(Order $order) $requestParams['shippingAmountNet'] = (int)round($this->getShippingAmountNetFromOrder($order) * 100); $requestParams['currency'] = $requestParams['amounts'][0]['currency']; + if($order->amount->isNet){ + $requestParams['basketAmount'] = $requestParams['basketAmountNet']; + $requestParams['shippingAmount'] = $requestParams['shippingAmountNet']; + } + return $requestParams; } @@ -356,7 +388,7 @@ protected function mapPaymentCode($paymentCode) protected function getSystemInfo() { return [ - 'vendor' => 'arvatis media GmbH', + 'vendor' => 'plentysystems AG', 'version' => 7, 'type' => 'Webshop', 'url' => $this->shopHelper->getPlentyDomain(), @@ -447,10 +479,14 @@ protected function paymentHasRedirect($paymentCode) /** * @return array */ - protected function getRedirectUrls() + protected function getRedirectUrls($transactionBasketId = "") { + $successParam = ''; + if(strlen($transactionBasketId)){ + $successParam = '?transactionBasketId='.$transactionBasketId; + } return [ - 'success' => $this->shopHelper->getPlentyDomain() . '/payment/payone/checkoutSuccess', + 'success' => $this->shopHelper->getPlentyDomain() . '/payment/payone/checkoutSuccess'.$successParam, 'error' => $this->shopHelper->getPlentyDomain() . '/payment/payone/error', 'back' => $this->shopHelper->getPlentyDomain() . '/checkout', ]; @@ -520,11 +556,10 @@ private function getShippingAmountNetFromOrder(Order $order) } $orderItemData = $orderItem->toArray(); $amount = $orderItemData['amounts'][0]; - $priceGross = $amount['priceGross']; - return $priceGross * 100 / ($orderItem['vatRate'] + 100.); + return $amount['priceNet']; } - return 0.; + return 0; } } diff --git a/src/Providers/Api/Request/DebitDataProvider.php b/src/Providers/Api/Request/DebitDataProvider.php index 1026f614..6831a061 100644 --- a/src/Providers/Api/Request/DebitDataProvider.php +++ b/src/Providers/Api/Request/DebitDataProvider.php @@ -9,21 +9,10 @@ */ class DebitDataProvider extends DataProviderAbstract implements DataProviderOrder { - /** - * {@inheritdoc} - */ public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) { - $requestParams = $this->getDefaultRequestData($paymentCode); - $requestParams['context']['sequencenumber'] = $this->getSequenceNumber($order); - $requestParams['basket'] = $this->getBasketDataFromOrder($order); - $requestParams['basketItems'] = $this->getOrderItemData($order); - $requestParams['order'] = $this->getOrderData($order); - $requestParams['referenceId'] = $requestReference; - - $this->validator->validate($requestParams); - - return $requestParams; + // TODO: Implement getDataFromOrder() method. + return []; } /** @@ -36,9 +25,12 @@ public function getDataFromOrder(string $paymentCode, Order $order, string $requ */ public function getPartialRefundData($paymentCode, Order $order, Order $refund, $preAuthUniqueId) { - $requestParams = $this->getDataFromOrder($paymentCode, $order, $preAuthUniqueId); - + $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams['context']['sequencenumber'] = $this->getSequenceNumber($order); + $requestParams['basket'] = $this->getBasketDataFromOrder($refund); + $requestParams['basketItems'] = $this->getOrderItemData($order); $requestParams['order'] = $this->getOrderData($refund); + $requestParams['referenceId'] = $preAuthUniqueId; $this->validator->validate($requestParams); diff --git a/src/Providers/Api/Request/GetInvoiceDataProvider.php b/src/Providers/Api/Request/GetInvoiceDataProvider.php new file mode 100644 index 00000000..39f6ee70 --- /dev/null +++ b/src/Providers/Api/Request/GetInvoiceDataProvider.php @@ -0,0 +1,19 @@ +getDefaultRequestData($paymentCode); + $requestParams['context']['documentNumber'] = $documentNumber; + $this->validator->validate($requestParams); + return $requestParams; + } +} diff --git a/src/Providers/Api/Request/PreAuthDataProvider.php b/src/Providers/Api/Request/PreAuthDataProvider.php index c2d57a24..630a309f 100644 --- a/src/Providers/Api/Request/PreAuthDataProvider.php +++ b/src/Providers/Api/Request/PreAuthDataProvider.php @@ -40,7 +40,7 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r $requestParams['bankAccount'] = $this->getBankAccount(); } if ($this->paymentHasRedirect($paymentCode)) { - $requestParams['redirect'] = $this->getRedirectUrls(); + $requestParams['redirect'] = $this->getRedirectUrls($basket->id); } if ($paymentCode == PayoneCCPaymentMethod::PAYMENT_CODE) { $requestParams['ccCheck'] = $this->getCreditCardData()->jsonSerialize(); diff --git a/src/Providers/DataProviders/Javascript.php b/src/Providers/DataProviders/Javascript.php index 091e77d8..18888038 100644 --- a/src/Providers/DataProviders/Javascript.php +++ b/src/Providers/DataProviders/Javascript.php @@ -38,7 +38,6 @@ public function call( PluginConstants::NAME . '::Partials.Javascript', [ 'locale' => $helper->getCurrentLanguage(), - 'isDebugModeEnabled' => $helper->isDebugModeActive(), 'creditcardcheck' => $creditCardCheck, 'allowedCCTypes' => $creditcardTypes->getAllowedTypes(), 'defaultWidthInPx' => $style->getDefaultWidthInPx(), diff --git a/src/Providers/PayoneRouteServiceProvider.php b/src/Providers/PayoneRouteServiceProvider.php index 55bebfa5..d7dda8b6 100644 --- a/src/Providers/PayoneRouteServiceProvider.php +++ b/src/Providers/PayoneRouteServiceProvider.php @@ -16,8 +16,6 @@ class PayoneRouteServiceProvider extends RouteServiceProvider public function map(Router $router) { - $router->get('payment/payone/migrate/', 'Payone\Controllers\ConfigController@migrate'); - $router->post('payment/payone/status/', 'Payone\Controllers\StatusController@index'); $router->post('payment/payone/checkout/doAuth', 'Payone\Controllers\CheckoutController@doAuth'); diff --git a/src/Providers/PayoneServiceProvider.php b/src/Providers/PayoneServiceProvider.php old mode 100644 new mode 100755 index 00a07a7f..d14a3f46 --- a/src/Providers/PayoneServiceProvider.php +++ b/src/Providers/PayoneServiceProvider.php @@ -3,10 +3,13 @@ namespace Payone\Providers; use Payone\Adapter\Logger; +use Payone\Helpers\AddressHelper; use Payone\Helpers\OrderHelper; use Payone\Helpers\PaymentHelper; +use Payone\Helpers\ShopHelper; use Payone\Methods\PaymentAbstract; use Payone\Methods\PaymentMethodServiceFactory; +use Payone\Methods\PayoneAmazonPayPaymentMethod; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Methods\PayoneCODPaymentMethod; use Payone\Methods\PayoneDirectDebitPaymentMethod; @@ -36,9 +39,11 @@ use Plenty\Modules\Document\Models\Document; use Plenty\Modules\EventProcedures\Services\Entries\ProcedureEntry; use Plenty\Modules\EventProcedures\Services\EventProceduresService; +use Plenty\Modules\Order\Contracts\OrderRepositoryContract; use Plenty\Modules\Order\Events\OrderCreated; use Plenty\Modules\Order\Models\OrderType; use Plenty\Modules\Payment\Contracts\PaymentRepositoryContract; +use Plenty\Modules\Payment\Events\Checkout\ExecutePayment; use Plenty\Modules\Payment\Events\Checkout\GetPaymentMethodContent; use Plenty\Modules\Payment\Method\Contracts\PaymentMethodContainer; use Plenty\Modules\Payment\Models\Payment; @@ -58,62 +63,28 @@ public function register() /** * @param Dispatcher $eventDispatcher - * @param PaymentHelper $paymentHelper - * @param PaymentService $paymentService * @param BasketRepositoryContract $basket * @param PaymentMethodContainer $payContainer - * @param PaymentRenderer $paymentRenderer - * @param PaymentMethodContent $content - * @param Logger $logger * @param EventProceduresService $eventProceduresService - * @param ErrorMessageRenderer $errorMessageRenderer - * @param PaymentCreation $paymentCreationService - * @param PaymentCache $paymentCache - * @param ReferenceContainer $referenceContainer - * @param OrderPdf $orderPdf - * @param OrderHelper $orderHelper */ public function boot( Dispatcher $eventDispatcher, - PaymentHelper $paymentHelper, - PaymentService $paymentService, BasketRepositoryContract $basket, PaymentMethodContainer $payContainer, - PaymentRenderer $paymentRenderer, - PaymentMethodContent $content, - Logger $logger, - EventProceduresService $eventProceduresService, - ErrorMessageRenderer $errorMessageRenderer, - PaymentCreation $paymentCreationService, - PaymentCache $paymentCache, - ReferenceContainer $referenceContainer, - OrderPdf $orderPdf, - OrderHelper $orderHelper + EventProceduresService $eventProceduresService ) { $this->registerPaymentMethods($payContainer); $this->registerPaymentRendering( $eventDispatcher, - $paymentHelper, - $paymentService, - $paymentRenderer, - $content, - $logger, - $basket, - $errorMessageRenderer + $basket ); - $this->registerOrderCreationEvents( - $eventDispatcher, - $paymentHelper, - $logger, - $paymentCreationService, - $paymentCache - ); + $this->registerPaymentExecute($eventDispatcher); $captureProcedureTitle = [ - 'de' => PluginConstants::NAME . ' | Bestellung erfassen', - 'en' => PluginConstants::NAME . ' | Capture order', + 'de' => 'Versandbestätigung an ' . PluginConstants::NAME, + 'en' => 'Send shipping confirmation to ' . PluginConstants::NAME, ]; $eventProceduresService->registerProcedure( PluginConstants::NAME, @@ -123,7 +94,7 @@ public function boot( ); $refundProcedureTitle = [ - 'de' => PluginConstants::NAME . ' | Gutschrift erstellen', + 'de' => PluginConstants::NAME . ' | Rückerstattung senden', 'en' => PluginConstants::NAME . ' | Refund order', ]; $eventProceduresService->registerProcedure( @@ -133,9 +104,7 @@ public function boot( '\Payone\Procedures\RefundEventProcedure@run' ); - $this->registerReferenceTypesForLogging($referenceContainer); - $this->registerInvoicePdfGeneration($eventDispatcher, $paymentHelper, $logger, $orderPdf, $orderHelper); - + $this->registerInvoicePdfGeneration($eventDispatcher); } /** @@ -201,6 +170,12 @@ protected function registerPaymentMethods(PaymentMethodContainer $payContainer) PayoneInvoiceSecurePaymentMethod::class, $events ); + + $payContainer->register( + 'Payone::' . PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::class, + $events + ); } /** @@ -211,28 +186,20 @@ protected function registerPaymentMethods(PaymentMethodContainer $payContainer) * @param PaymentMethodContent $content * @param Logger $logger */ - private function registerPaymentRendering( + protected function registerPaymentRendering( Dispatcher $eventDispatcher, - PaymentHelper $paymentHelper, - PaymentService $paymentService, - PaymentRenderer $paymentRenderer, - PaymentMethodContent $content, - Logger $logger, - BasketRepositoryContract $basketRepository, - ErrorMessageRenderer $errorMessageRenderer + BasketRepositoryContract $basketRepository ) { - $logger = $logger->setIdentifier(__METHOD__); $eventDispatcher->listen( GetPaymentMethodContent::class, - function (GetPaymentMethodContent $event) use ( - $paymentService, - $paymentHelper, - $paymentRenderer, - $content, - $logger, - $basketRepository, - $errorMessageRenderer - ) { + function (GetPaymentMethodContent $event) use ($basketRepository) { + /** @var PaymentService $paymentService */ + $paymentService = pluginApp(PaymentService::class); + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); + /** @var PaymentHelper $paymentHelper */ + $paymentHelper = pluginApp(PaymentHelper::class); + $logger->setIdentifier(__METHOD__)->info('Event.getPaymentMethodContent'); $selectedPaymentMopId = $event->getMop(); if (!$selectedPaymentMopId || !$paymentHelper->isPayonePayment($selectedPaymentMopId)) { @@ -242,16 +209,42 @@ function (GetPaymentMethodContent $event) use ( /** @var PaymentAbstract $payment */ $payment = PaymentMethodServiceFactory::create($paymentCode); - $renderingType = $content->getPaymentContentType($paymentCode); + $basket = $basketRepository->load(); + /** @var AddressHelper $addressHelper */ + $addressHelper = pluginApp(AddressHelper::class); + $billingAddress = $addressHelper->getBasketBillingAddress($basket); + if( $paymentCode == PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE && + (!isset($billingAddress->birthday) || !strlen($billingAddress->birthday)) ) { + + /** @var \Plenty\Plugin\Translation\Translator $translator */ + $translator = pluginApp(\Plenty\Plugin\Translation\Translator::class); + /** @var ShopHelper $shopHelper */ + $shopHelper = pluginApp(ShopHelper::class); + $lang = $shopHelper->getCurrentLanguage(); + + $dateOfBirthMissingMessage = $translator->trans('Payone::Template.missingDateOfBirth', [], $lang); + + $event->setValue($dateOfBirthMissingMessage); + $event->setType(GetPaymentMethodContent::RETURN_TYPE_ERROR); + return; + } + try { + /** @var PaymentMethodContent $content */ + $content = pluginApp(PaymentMethodContent::class); + $renderingType = $content->getPaymentContentType($paymentCode); + + /** @var PaymentRenderer $paymentRenderer */ + $paymentRenderer = pluginApp(PaymentRenderer::class); + $event->setType($renderingType); switch ($renderingType) { case GetPaymentMethodContent::RETURN_TYPE_REDIRECT_URL: - $auth = $paymentService->openTransaction($basketRepository->load()); + $auth = $paymentService->openTransaction($basket); $event->setValue($auth->getRedirecturl()); break; case GetPaymentMethodContent::RETURN_TYPE_CONTINUE: - $paymentService->openTransaction($basketRepository->load()); + $paymentService->openTransaction($basket); break; case GetPaymentMethodContent::RETURN_TYPE_HTML: $event->setValue($paymentRenderer->render($payment, '')); @@ -260,6 +253,9 @@ function (GetPaymentMethodContent $event) use ( } catch (\Exception $e) { $errorMessage = $e->getMessage(); $logger->logException($e); + + /** @var ErrorMessageRenderer $errorMessageRenderer */ + $errorMessageRenderer = pluginApp(ErrorMessageRenderer::class); $event->setValue($errorMessageRenderer->render($errorMessage)); $event->setType(GetPaymentMethodContent::RETURN_TYPE_ERROR); } @@ -267,81 +263,57 @@ function (GetPaymentMethodContent $event) use ( ); } - /** - * @param Dispatcher $eventDispatcher - * @param PaymentHelper $paymentHelper - * @param Logger $logger - * @param Capture $captureService - * @param PaymentCreation $paymentCreationService - */ - private function registerOrderCreationEvents( - Dispatcher $eventDispatcher, - PaymentHelper $paymentHelper, - Logger $logger, - PaymentCreation $paymentCreationService, - PaymentCache $paymentCache - ) { - $logger = $logger->setIdentifier(__METHOD__); - $eventDispatcher->listen(OrderCreated::class, - function (OrderCreated $event) use ( - $paymentHelper, - $logger, - $paymentCreationService, - $paymentCache - ) { - $order = $event->getOrder(); - $logger->info('Event.orderCreated', [$order, $order->id]); - if ($order->typeId != OrderType::TYPE_SALES_ORDER) { - return; - } - $selectedPaymentId = $order->methodOfPaymentId; - if (!$selectedPaymentId || !$paymentHelper->isPayonePayment($selectedPaymentId)) { - return; - } - $payment = $paymentCache->loadPayment($selectedPaymentId); + protected function registerPaymentExecute(Dispatcher $dispatcher) + { + $dispatcher->listen(ExecutePayment::class, function (ExecutePayment $event) { + /** @var PaymentHelper $paymentHelper */ + $paymentHelper = pluginApp(PaymentHelper::class); + if($paymentHelper->isPayonePayment($event->getMop())) { + /** @var OrderRepositoryContract $orderRepository */ + $orderRepository = pluginApp(OrderRepositoryContract::class); + /** @var PaymentCache $paymentCache */ + $paymentCache = pluginApp(PaymentCache::class); + + $order = $orderRepository->findOrderById($event->getOrderId()); + $payment = $paymentCache->loadPayment($event->getMop()); if (!($payment instanceof Payment)) { $message = 'Payment could not be assigned to order.'; + + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); $logger->error($message, $payment); - throw new \Exception($message); + return; } + + /** @var PaymentCreation $paymentCreationService */ + $paymentCreationService = pluginApp(PaymentCreation::class); $paymentCreationService->assignPaymentToOrder($payment, $order); - $paymentCache->deletePayment($selectedPaymentId); + $paymentCache->deletePayment($event->getMop()); } - ); - } + }); - /** - * @param ReferenceContainer $referenceContainer - */ - private function registerReferenceTypesForLogging(ReferenceContainer $referenceContainer) - { - try { - $referenceContainer->add([Logger::PAYONE_REQUEST_REFERENCE => Logger::PAYONE_REQUEST_REFERENCE]); - } catch (ReferenceTypeException $ex) { - // already registered - } } /** * @param Dispatcher $eventDispatcher - * @param PaymentHelper $paymentHelper - * @param Logger $logger - * @param OrderPdf $orderPdf - * @param OrderHelper $orderHelper */ - private function registerInvoicePdfGeneration( - Dispatcher $eventDispatcher, - PaymentHelper $paymentHelper, - Logger $logger, - OrderPdf $orderPdf, - OrderHelper $orderHelper - ) { + protected function registerInvoicePdfGeneration(Dispatcher $eventDispatcher) + { // Listen for the document generation event $eventDispatcher->listen(OrderPdfGenerationEvent::class, - function (OrderPdfGenerationEvent $event) use ($paymentHelper, $logger, $orderPdf, $orderHelper) { - /** @var Order $order */ + function (OrderPdfGenerationEvent $event) { + + /** @var PaymentHelper $paymentHelper */ + $paymentHelper = pluginApp(PaymentHelper::class); + + /** @var OrderHelper $orderHelper */ + $orderHelper = pluginApp(OrderHelper::class); + + /** @var \Order $order */ $order = $event->getOrder(); + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); $logger->setIdentifier(__METHOD__)->info( 'Event.orderPdfGeneration', ['order' => $order->id, 'documentType' => $event->getDocType()] @@ -364,6 +336,8 @@ function (OrderPdfGenerationEvent $event) use ($paymentHelper, $logger, $orderPd } $lang = $orderHelper->getLang($order); try { + /** @var OrderPdf $orderPdf */ + $orderPdf = pluginApp(OrderPdf::class); $orderPdfGenerationModel = $orderPdf->createPdfNote($payments[0], $lang); } catch (\Exception $e) { $logger->error('Adding PDF comment failed for order ' diff --git a/src/Services/Api.php b/src/Services/Api.php index 4599c876..1233bbf2 100644 --- a/src/Services/Api.php +++ b/src/Services/Api.php @@ -5,6 +5,8 @@ use Payone\Adapter\Logger; use Payone\Models\Api\AuthResponse; use Payone\Models\Api\AuthResponseFactory; +use Payone\Models\Api\GetInvoiceResponse; +use Payone\Models\Api\GetInvoiceResponseFactory; use Payone\Models\Api\ManagemandateResponse; use Payone\Models\Api\ManagemandateResponseFactory; use Payone\Models\Api\PreAuthResponse; @@ -31,6 +33,7 @@ class Api const REQUEST_TYPE_CALCULATION = 'Calculation'; const REQUEST_TYPE_DEBIT = 'Debit'; const REQUEST_TYPE_MANAGEMANDATE = 'Managemandate'; + const REQUEST_TYPE_INVOICE = 'GetDocument'; /** * @var LibraryCallContract @@ -67,10 +70,11 @@ public function doAuth($requestParams): AuthResponse { $this->logger->setIdentifier(__METHOD__); $response = $this->doLibCall((self::REQUEST_TYPE_AUTH), $requestParams); + $responseObject = AuthResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); return $responseObject; } @@ -88,8 +92,8 @@ public function doPreAuth($requestParams): PreAuthResponse $response = $this->doLibCall((self::REQUEST_TYPE_PRE_AUTH), $requestParams); $responseObject = PreAuthResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_PRE_AUTH), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_PRE_AUTH), $response); return $responseObject; } @@ -108,8 +112,8 @@ public function doReversal($requestParams): Response $responseObject = ResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_REVERSAL), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_REVERSAL), $response); return $responseObject; } @@ -128,8 +132,8 @@ public function doCapture($requestParams): Response $responseObject = ResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_CAPTURE), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_CAPTURE), $response); return $responseObject; } @@ -148,8 +152,8 @@ public function doRefund($requestParams): Response $responseObject = ResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); return $responseObject; } @@ -166,8 +170,8 @@ public function doReAuth($requestParams): Response $responseObject = ResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); return $responseObject; } @@ -184,8 +188,8 @@ public function doDebit($requestParams): Response $responseObject = ResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_AUTH), $response); return $responseObject; } @@ -202,9 +206,24 @@ public function doManagemandate($requestParams): ManagemandateResponse $responseObject = ManagemandateResponseFactory::create($response); - $this->logger->setReferenceValue($responseObject->getTransactionID()); - $this->logger->critical('Api.' . $this->getCallAction(self::REQUEST_TYPE_MANAGEMANDATE), $response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_MANAGEMANDATE), $response); + + return $responseObject; + } + /** + * @param $requestParams + * + * @return Response + */ + public function doGetInvoice($requestParams): GetInvoiceResponse + { + $this->logger->setIdentifier(__METHOD__); + $response = $this->doLibCall((self::REQUEST_TYPE_INVOICE), $requestParams); + $responseObject = GetInvoiceResponseFactory::create($response); + $this->logger->addReference(Logger::PAYONE_REQUEST_REFERENCE, $responseObject->getTransactionID()); + $this->logger->debug('Api.' . $this->getCallAction(self::REQUEST_TYPE_INVOICE), $response); return $responseObject; } @@ -216,8 +235,7 @@ public function doManagemandate($requestParams): ManagemandateResponse */ public function doLibCall($call, $requestParams): array { - $this->logger->setReferenceType(Logger::PAYONE_REQUEST_REFERENCE); - $this->logger->critical('Api.' . $this->getCallAction($call), $requestParams); + $this->logger->debug('Api.' . $this->getCallAction($call), $requestParams); try { $response = $this->libCall->call( diff --git a/src/Services/Auth.php b/src/Services/Auth.php index b10e5e88..b73b8a60 100644 --- a/src/Services/Auth.php +++ b/src/Services/Auth.php @@ -92,6 +92,7 @@ public function executeAuth(Basket $basket) $payment = $this->createPayment($selectedPaymentId, $authResponse, $basket); $this->paymentCache->storePayment((string) $selectedPaymentId, $payment); + $this->paymentCache->setActiveBasketId($basket->id); return $authResponse; } @@ -142,6 +143,10 @@ private function doAuthFromBasket(Basket $basket) ); $requestData = $this->authDataProvider->getDataFromBasket($paymentCode, $basket, ''); + $this->logger->setIdentifier(__METHOD__)->debug( + 'Api.doAuth', + ['requestData' => $requestData] + ); try { $authResponse = $this->api->doAuth($requestData); } catch (\Exception $e) { diff --git a/src/Services/PaymentCreation.php b/src/Services/PaymentCreation.php index b8c15fe3..cc63373b 100644 --- a/src/Services/PaymentCreation.php +++ b/src/Services/PaymentCreation.php @@ -90,8 +90,18 @@ public function __construct( */ public function createPayment($mopId, ResponseAbstract $response, Basket $basket, ClearingAbstract $account = null) { + /** @var \Plenty\Modules\Frontend\Services\VatService $vatService */ + $vatService = pluginApp(\Plenty\Modules\Frontend\Services\VatService::class); + + //we have to manipulate the basket because its stupid and doesnt know if its netto or gross + if(!count($vatService->getCurrentTotalVats())) { + $basket->itemSum = $basket->itemSumNet; + $basket->shippingAmount = $basket->shippingAmountNet; + $basket->basketAmount = $basket->basketAmountNet; + } + $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.createPayment', + 'Payment.createPayment', [ 'paymentId' => $mopId, 'response' => $response, @@ -132,10 +142,15 @@ public function createPayment($mopId, ResponseAbstract $response, Basket $basket $transactionID ); + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_TRANSACTION_CODE, + 0 + ); + $paymentProperties[] = $this->createPaymentProperty(PaymentProperty::TYPE_ORIGIN, '' . Payment::ORIGIN_PLUGIN); $paymentProperties[] = $this->createPaymentProperty( - PaymentProperty::TYPE_ACCOUNT_OF_RECEIVER, - $basket->customerId); + PaymentProperty::TYPE_INVOICE_ADDRESS_ID, + $basket->customerInvoiceAddressId); $paymentText = [ 'Request type' => 'PreAuth', @@ -147,22 +162,30 @@ public function createPayment($mopId, ResponseAbstract $response, Basket $basket 'TransactionID ' . $transactionID ); if ($account instanceof Bank) { - $paymentProperties[] = $this->createPaymentProperty( - PaymentProperty::TYPE_NAME_OF_RECEIVER, - json_encode($account->getAccountholder()) - ); - $paymentProperties[] = $this->createPaymentProperty( - PaymentProperty::TYPE_IBAN_OF_RECEIVER, - json_encode($account->getIban()) - ); - $paymentProperties[] = $this->createPaymentProperty( - PaymentProperty::TYPE_BIC_OF_RECEIVER, - json_encode($account->getIban()) - ); - $paymentProperties[] = $this->createPaymentProperty( - PaymentProperty::TYPE_ACCOUNT_OF_RECEIVER, - json_encode($account->getAccount()) - ); + if(strlen(json_encode($account->getAccountholder()))){ + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_NAME_OF_RECEIVER, + json_encode($account->getAccountholder()) + ); + } + if(strlen(json_encode($account->getIban()))){ + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_IBAN_OF_RECEIVER, + json_encode($account->getIban()) + ); + } + if(strlen(json_encode($account->getBic()))){ + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_BIC_OF_RECEIVER, + json_encode($account->getBic()) + ); + } + if(strlen(json_encode($account->getAccount()))){ + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_ACCOUNT_OF_RECEIVER, + json_encode($account->getAccount()) + ); + } $paymentText['accountHolder'] = $account->getAccountholder(); $paymentText['iban'] = $account->getIban(); @@ -199,7 +222,7 @@ public function createPayment($mopId, ResponseAbstract $response, Basket $basket public function capturePayment(Payment $payment, Order $order) { $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.updatePayment', + 'Payment.updatePayment', [ 'payment' => $payment, 'order' => $order, @@ -227,7 +250,7 @@ public function capturePayment(Payment $payment, Order $order) public function reAuthorizePayment(Payment $payment, Response $response, Order $order) { $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.updatePayment', + 'Payment.updatePayment', [ 'payment' => $payment, 'response' => $response, @@ -274,10 +297,10 @@ public function reAuthorizePayment(Payment $payment, Response $response, Order $ * * @return Payment */ - public function createRefundPayment($paymentId, $response, $currency, $grandTotal, $parentPaymentId) + public function createRefundPayment($paymentId, $response, $currency, $grandTotal, $parentPaymentId, $refundId=0) { $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.createRefundPayment', + 'Payment.createRefundPayment', [ 'paymentId' => $paymentId, 'response' => $response, @@ -287,7 +310,7 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota ] ); - $transactionID = $response->getTransactionID(); + $transactionID = $response->getTransactionID() . '_' . $refundId; /** @var Payment $payment */ $payment = pluginApp(Payment::class); @@ -300,7 +323,6 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota $payment->receivedAt = date('Y-m-d H:i:s'); $payment->type = 'debit'; $payment->parentId = $parentPaymentId; - $payment->regenerateHash = true; $payment->unaccountable = 0; $paymentProperties = []; @@ -309,6 +331,15 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota $transactionID ); + /* + * Sequence Number + * First number have to be 0 + */ + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_TRANSACTION_CODE, + 0 + ); + $paymentProperties[] = $this->createPaymentProperty(PaymentProperty::TYPE_ORIGIN, '' . Payment::ORIGIN_PLUGIN); $paymentText = [ @@ -321,11 +352,17 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota json_encode($paymentText) ); + $paymentProperties[] = $this->createPaymentProperty( + PaymentProperty::TYPE_BOOKING_TEXT, + 'Refund ('.$refundId.') Transaction: ('.$transactionID.')' + ); + $payment->properties = $paymentProperties; try { $payment = $this->paymentRepository->createPayment($payment); } catch (\Exception $e) { + $this->logger->logException($e); $storedPayment = $this->paymentRepository->getPaymentById($payment->id); if ($storedPayment) { return $storedPayment; @@ -344,7 +381,7 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota public function assignPaymentToOrder(Payment $payment, Order $order) { $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.assignPaymentToOrder', + 'Payment.assignPaymentToOrder', [ 'payment' => $payment, 'orderId' => $order->id, @@ -395,7 +432,7 @@ public function findLastPayment($ownerId, $selectedPaymentId) public function updatePaymentStatus($txid, $txaction, $sequenceNumber) { $this->logger->setIdentifier(__METHOD__)->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', [ 'txid' => $txid, 'txaction' => $txaction, @@ -411,7 +448,7 @@ public function updatePaymentStatus($txid, $txaction, $sequenceNumber) $this->logger->debug('PaymentCreation.updatingPayment', ['payments' => $payments]); if (!count($payments)) { $this->logger->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', 'No payments found for txid' ); @@ -421,7 +458,7 @@ public function updatePaymentStatus($txid, $txaction, $sequenceNumber) foreach ($payments as $payment) { $newStatus = PayonePaymentStatus::getPlentyStatus($txaction); $this->logger->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', [ 'payment' => $payment, 'oldStatus' => $payment->status, @@ -474,7 +511,7 @@ private function createOrUpdatePaymentProperty($payment, $pamentPropertyTypeId, } if ($property->typeId === $pamentPropertyTypeId) { $this->logger->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', [ 'property' => $pamentPropertyTypeId, 'oldValue' => $property->value, @@ -487,7 +524,7 @@ private function createOrUpdatePaymentProperty($payment, $pamentPropertyTypeId, } $this->logger->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', [ 'property' => $pamentPropertyTypeId, 'newValue' => $value, diff --git a/src/Services/PaymentDocuments.php b/src/Services/PaymentDocuments.php new file mode 100644 index 00000000..be3ac0e7 --- /dev/null +++ b/src/Services/PaymentDocuments.php @@ -0,0 +1,219 @@ +paymentRepository = $paymentRepository; + $this->paymentHelper = $paymentHelper; + $this->api = $api; + $this->getInvoiceDataProvider = $getInvoiceDataProvider; + $this->logger = $logger; + } + + /** + * This function loads the invoice / credit documents from payone. The OrderId is determined over the taxid. + * + * @param string $txid + * @param string $invoiceId + * @param string $invoiceDate + * @param float $invoiceTotal + * @throws \Exception + */ + public function addInvoiceToOrder($txid, $invoiceId, $invoiceDate, $invoiceTotal) + { + $this->logger->setIdentifier(__METHOD__); + + $payments = $this->paymentRepository->getPaymentsByPropertyTypeAndValue( + PaymentProperty::TYPE_TRANSACTION_ID, + $txid, + 1 + ); + + if (count($payments) !== 1) { + //payment not found + $this->logger->debug( + 'Api.doGetInvoice', + 'No payments found for txid (' . $txid . ')' + ); + throw new \Exception('Payment not found.'); + } + + /* @var $payment Payment */ + $payment = $payments->shift(); + + $this->logger->debug('Api.doGetInvoice', + [ + 'taxid' => $txid, + 'invoiceId' => $invoiceId, 'invoiceDate' => $invoiceDate, 'invoiceTotal' => $invoiceTotal, + 'payment' => $payment + ] + ); + + //only for secure invoice + if ($this->paymentHelper->getMopId(PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE) != + $payment->mopId) { + return; + } + + $orderId = $payment->order->orderId; + + if ((int)$orderId <= 0) { + return; + } + + if (substr($invoiceId, 0, 2) == 'GT') { + //this is a credit note + $authHelper = pluginApp(AuthHelper::class); + $refundId = $authHelper->processUnguarded( + function () use ($orderId, $invoiceTotal) { + $orderRepository = pluginApp(OrderRepositoryContract::class); + $order = $orderRepository->findOrderById($orderId); + foreach ($order->childOrders as $childOrder) { + if ($childOrder->typeId == OrderType::TYPE_CREDIT_NOTE && + $childOrder->amount->invoiceTotal == (-$invoiceTotal)) { + return $childOrder->id; + } + } + } + ); + if ((int)$refundId == 0) { + $this->logger->debug( + 'Api.doGetInvoice', + 'No credit-note found for invoiceId (' . $invoiceId . ')' + ); + return; + } + $orderId = $refundId; + } + + $requestData = $this->getInvoiceDataProvider + ->getRequestData(PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, $invoiceId); + + $getInvoiceResult = $this->api->doGetInvoice($requestData); + + if (!$getInvoiceResult->getSuccess()) { + $this->logger->error('Api.doGetInvoice', + [ + 'invoiceId' => $invoiceId, + 'payment' => $payment, + 'errorMessage' => $getInvoiceResult->getErrorMessage(), + ] + ); + return; + } + + $this->importInvoice($orderId, $invoiceId, $getInvoiceResult->getBase64(), $invoiceDate); + } + + /** + * @param int $orderId + * @param string $invoiceNumber + * @param string $content + * @param string $invoiceDate + */ + private function importInvoice(int $orderId, string $invoiceNumber, string $content, string $invoiceDate) + { + /** @var DocumentRepositoryContract $documentRepository */ + $documentRepository = pluginApp(DocumentRepositoryContract::class); + + // check if the document is already imported + $documentRepository->setFilters([ + 'numberWithPrefix' => $invoiceNumber, + 'orderId' => $orderId + ]); + + /** @var PaginatedResult $result */ + $result = $documentRepository->find(); + + if ($result->getTotalCount() > 0) { + //document exists + return; + } + + $documentType = Document::INVOICE_EXTERNAL; + if (substr($invoiceNumber, 0, 2) == 'GT') { + $documentType = Document::CREDIT_NOTE_EXTERNAL; + } + + $date = Carbon::now()->toW3cString(); + if (strlen($invoiceDate) == 8) { + $date = Carbon::createFromFormat('Ymd', $invoiceDate)->format(\DateTime::W3C); + } + + $data = [ + 'documents' => [ + [ + 'content' => $content, + 'numberWithPrefix' => $invoiceNumber, + 'displayDate' => $date + ] + ] + ]; + + $authHelper = pluginApp(AuthHelper::class); + $authHelper->processUnguarded( + function () use ($documentRepository, $orderId, $documentType, $data) { + $documentRepository->uploadOrderDocuments($orderId, $documentType, $data); + } + ); + } +} diff --git a/src/Services/PaymentService.php b/src/Services/PaymentService.php index b7495105..754db670 100644 --- a/src/Services/PaymentService.php +++ b/src/Services/PaymentService.php @@ -88,7 +88,7 @@ public function openTransaction(Basket $basket) } if (!$authResponse->getSuccess()) { throw new \Exception( - $authResponse->getErrorMessage() ?? 'Could not initialize payment. Please choose another payment and retry' + $authResponse->getErrorMessage() ?? 'Could not initialize payment. Please choose another payment method and retry' ); } $this->responseCache->storeAuth($selectedPaymentMopId, $authResponse); diff --git a/src/Services/PreAuth.php b/src/Services/PreAuth.php index 1697733b..061632a9 100644 --- a/src/Services/PreAuth.php +++ b/src/Services/PreAuth.php @@ -85,6 +85,7 @@ public function executePreAuth(Basket $basket) $payment = $this->createPayment($selectedPaymentId, $preAuthResponse, $basket); $this->paymentCache->storePayment((string) $selectedPaymentId, $payment); + $this->paymentCache->setActiveBasketId($basket->id); return $preAuthResponse; } diff --git a/src/Services/Refund.php b/src/Services/Refund.php index c236775a..033336e4 100644 --- a/src/Services/Refund.php +++ b/src/Services/Refund.php @@ -4,6 +4,7 @@ use Payone\Adapter\Logger; use Payone\Adapter\PaymentHistory; +use Payone\Helpers\OrderHelper; use Payone\Helpers\PaymentHelper; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Models\Api\Response; @@ -57,6 +58,11 @@ class Refund */ private $captureDataProvider; + /** + * @var OrderHelper + */ + protected $orderHelper; + /** * Refund constructor. * @@ -69,6 +75,7 @@ class Refund * @param DebitDataProvider $refundDataProvider * @param Api $api * @param CaptureDataProvider $captureDataProvider + * @param OrderHelper $orderHelper */ public function __construct( PaymentRepositoryContract $paymentRepository, @@ -79,7 +86,8 @@ public function __construct( OrderRepositoryContract $orderRepo, DebitDataProvider $refundDataProvider, Api $api, - CaptureDataProvider $captureDataProvider + CaptureDataProvider $captureDataProvider, + OrderHelper $orderHelper ) { $this->paymentRepository = $paymentRepository; $this->paymentHelper = $paymentHelper; @@ -90,36 +98,41 @@ public function __construct( $this->refundDataProvider = $refundDataProvider; $this->api = $api; $this->captureDataProvider = $captureDataProvider; + $this->orderHelper = $orderHelper; } /** - * @param Order $order + * @param Order $refund */ - public function executeRefund(Order $order) + public function executeRefund(Order $refund) { - $this->logger->setIdentifier(__METHOD__)->info('EventProcedure.triggerFunction', ['order' => $order->id]); - if (!in_array($order->typeId, $this->getAllowedOrderTypes())) { - $this->logger->error('Invalid order type ' . $order->typeId . ' for order ' . $order->id); + $orderNote = ''; + + $this->logger->setIdentifier(__METHOD__)->info('EventProcedure.triggerFunction', ['order' => $refund->id]); + if (!in_array($refund->typeId, $this->getAllowedOrderTypes())) { + $this->logger->error('Invalid order type ' . $refund->typeId . ' for order ' . $refund->id); return; } try { - $originalOrder = $this->getOriginalOrder($order); + $originalOrder = $this->getOriginalOrder($refund); } catch (\Exception $e) { - $this->logger->error('Error loading original order for order ' . $order->id, $e->getMessage()); + $this->logger->error('Error loading original order for order ' . $refund->id, $e->getMessage()); return; } if (!$originalOrder) { $this->logger->error('Refunding payment failed! The given order is invalid!'); - + $orderNote = 'Refunding payment failed! The given order is invalid!'; + $this->orderHelper->addOrderComment($refund->id, $orderNote); return; } try { $payments = $this->paymentRepository->getPaymentsByOrderId($originalOrder->id); } catch (\Exception $e) { $this->logger->error('Error loading payment', $e->getMessage()); - + $orderNote = 'Error loading payment'; + $this->orderHelper->addOrderComment($refund->id, $orderNote); return; } $this->logger->debug( @@ -137,24 +150,25 @@ public function executeRefund(Order $order) $text = 'No Auth reference found in payment.'; $this->logger->error('Api.doRefund', [ - 'order' => $order->id, + 'order' => $refund->id, 'payment' => $payment, 'errorMessage' => $text, ] ); + $orderNote = $text . ' Order-ID: ' . $refund->id .' Payment-ID: '.$payment->id; $this->paymentHistory->addPaymentHistoryEntry($payment, $text); continue; } - if ($order->typeId != OrderType::TYPE_SALES_ORDER) { + if ($refund->typeId != OrderType::TYPE_SALES_ORDER) { $refundPaymentResult = $this->refundCreditMemo( $payment, $originalOrder, - $order, + $refund, $preAuth ); } else { - $refundPaymentResult = $this->refundOrder($payment, $order, $preAuth); + $refundPaymentResult = $this->refundOrder($payment, $refund, $preAuth); } $paymentCode = $this->paymentHelper->getPaymentCodeByMop($payment->mopId); @@ -168,33 +182,37 @@ public function executeRefund(Order $order) } } - $refundPayment = $this->createRefundPayment($payment->mopId, $payment, $originalOrder, - $refundPaymentResult); - if (!$refundPaymentResult->getSuccess()) { $this->logger->error('Api.doRefund', [ - 'order' => $order->id, + 'order' => $refund->id, 'payment' => $payment, 'authReference' => $preAuth, 'errorMessage' => $refundPaymentResult->getErrorMessage(), ] ); $text = 'Refund von event procedure fehlgeschlagen. Meldung: ' . $refundPaymentResult->getErrorMessage(); - $this->paymentHistory->addPaymentHistoryEntry($payment, $text); + $orderNote = $text . ' Meldung: ' . $refundPaymentResult->getErrorMessage() . ' Order-ID: ' . $refund->id .' Payment-ID: '.$payment->id; continue; } + $refundPayment = $this->createRefundPayment($payment->mopId, $payment, $refund, + $refundPaymentResult); + $payment->status = $this->getNewPaymentStatus($payment, $refundPayment); - $payment->updateOrderPaymentStatus = true; + $payment = $this->paymentHelper->raiseSequenceNumber($payment); + $orderNote ='Refund Successful Order-ID: ' . $refund->id .' Payment-ID: '.$payment->id; $this->paymentRepository->updatePayment($payment); + $this->paymentHistory->addPaymentHistoryEntry($payment, $orderNote); } + + $this->orderHelper->addOrderComment($refund->id, $orderNote); } /** * @param $mopId * @param $payment - * @param $order + * @param $refund * @param Response $transaction * * @return Payment @@ -202,7 +220,7 @@ public function executeRefund(Order $order) private function createRefundPayment( $mopId, $payment, - Order $order, + Order $refund, $transaction ) { /* @var Payment $debitPayment */ @@ -210,17 +228,18 @@ private function createRefundPayment( $mopId, $transaction, $payment->currency, - $this->getOrderAmount($order, $payment), - $payment->id + $this->getOrderAmount($refund, $payment), + $payment->id, + $refund->id ); if (isset($debitPayment) && $debitPayment instanceof Payment) { - $this->paymentCreation->assignPaymentToOrder($debitPayment, $order); + $this->paymentCreation->assignPaymentToOrder($debitPayment, $refund); } $this->logger->debug( 'General.createRefundPayment', - ['orderId' => $order->id, 'payment' => $debitPayment] + ['orderId' => $refund->id, 'payment' => $debitPayment] ); return $debitPayment; @@ -228,12 +247,12 @@ private function createRefundPayment( /** * @param Payment $payment - * @param Order $order + * @param Order $refund * @param $preAuthUniqueId * * @return Response */ - private function refundOrder($payment, Order $order, $preAuthUniqueId) + private function refundOrder($payment, Order $refund, $preAuthUniqueId) { $paymentCode = $this->paymentHelper->getPaymentCodeByMop($payment->mopId); @@ -241,18 +260,18 @@ private function refundOrder($payment, Order $order, $preAuthUniqueId) 'Api.doRefund', [ 'paymentCode' => $paymentCode, - 'order' => $order->toArray(), + 'order' => $refund->toArray(), 'authUniqueId' => $preAuthUniqueId, ] ); if ($paymentCode == PayoneCCPaymentMethod::PAYMENT_CODE) { if (!$payment->amount) {// not captured yet? - return $this->reverseAuth($order, $payment, $preAuthUniqueId); + return $this->reverseAuth($refund, $payment, $preAuthUniqueId); } } - $requestData = $this->refundDataProvider->getDataFromOrder($paymentCode, $order, $preAuthUniqueId); + $requestData = $this->refundDataProvider->getDataFromOrder($paymentCode, $refund, $preAuthUniqueId); return $this->api->doDebit($requestData); } diff --git a/src/Views/ErrorMessageRenderer.php b/src/Views/ErrorMessageRenderer.php index 7f897104..68256333 100644 --- a/src/Views/ErrorMessageRenderer.php +++ b/src/Views/ErrorMessageRenderer.php @@ -46,8 +46,7 @@ public function render($errorMessage) return $this->twig->render( PluginConstants::NAME . '::Partials.Error', [ - 'errorMessage' => $errorMessage, - 'isDebugModeEnabled' => $this->shopHelper->isDebugModeActive(), + 'errorMessage' => $errorMessage ] ); } diff --git a/src/Views/PaymentRenderer.php b/src/Views/PaymentRenderer.php index 0cf7e3b7..1700ea6d 100644 --- a/src/Views/PaymentRenderer.php +++ b/src/Views/PaymentRenderer.php @@ -85,8 +85,7 @@ public function render(PaymentAbstract $payment, $message) 'ccTypes' => $this->creditcardTypes->getAllowedTypes(), 'defaultWidthInPx' => $this->style->getDefaultWidthInPx(), 'defaultHeightInPx' => $this->style->getDefaultHeightInPx(), - 'defaultStyle' => $this->style->getDefaultStyle(), - 'isDebugModeEnabled' => $this->shopHelper->isDebugModeActive(), + 'defaultStyle' => $this->style->getDefaultStyle() ] ); }