diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..93b83c4b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +### Description of the feature/fix: + + +### Requirements that must be fulfilled: +- [ ] New version in `plugin.json` updated +- [ ] Changelog entry added +- [ ] Plugin can be built (`build-set`) +- [ ] Tested by the author +- [ ] Tested by a second person + + +[Kanbanize Card](LINK) + +@plentymarkets/team-order-payment +____________________ +New version must be uploaded from PID 31920. + +Further information about the plugin can be found in the [Wiki](https://wiki.plentymarkets.com/display/OP/Payone). diff --git a/.gitignore b/.gitignore index 3b4c1b9b..21aa514f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock phpunit.ini /build/ /.phan/ +.legacySyncTrace 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 deleted file mode 100644 index 3ae6bb26..00000000 --- a/config.json +++ /dev/null @@ -1,838 +0,0 @@ -{ - "formatVersion": 1, - "menu": { - "Config.GrundeinstellungenTab": { - "label": "Config.GrundeinstellungenTab", - "formFields": { - "mid": { - "type": "inputText", - "required": false, - "label": "Config.midLabel", - "options": {} - }, - "portalid": { - "type": "inputText", - "required": false, - "label": "Config.portalidLabel", - "options": {} - }, - "aid": { - "type": "inputText", - "required": false, - "label": "Config.aidLabel", - "options": {} - }, - "key": { - "type": "inputText", - "required": false, - "label": "Config.keyLabel", - "options": {} - }, - "mode": { - "type": "selectBox", - "required": false, - "label": "Config.modeLabel", - "options": { - "defaultValue": "0", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.modePossibleValue0" - }, - { - "value": "1", - "caption": "Config.modePossibleValue1" - } - ] - } - }, - "authType": { - "type": "selectBox", - "required": false, - "label": "Config.authTypeLabel", - "options": { - "defaultValue": "0", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.authTypePossibleValue0" - }, - { - "value": "1", - "caption": "Config.authTypePossibleValue1" - } - ] - } - } - } - }, - "Config.RechnungTab": { - "label": "Config.RechnungTab", - "formFields": { - "PAYONE_PAYONE_INVOICE.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEINVOICEActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEINVOICEActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEINVOICEActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_INVOICE.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICENameLabel", - "options": { - "defaultValue": "Rechnung" - } - }, - "PAYONE_PAYONE_INVOICE.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICEDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_INVOICE.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICEMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_INVOICE.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICEMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_INVOICE.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICEAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.GesicherteRechnungTab": { - "label": "Config.GesicherteRechnungTab", - "formFields": { - "PAYONE_PAYONE_INVOICE_SECURE.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECUREActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEINVOICESECUREActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEINVOICESECUREActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_INVOICE_SECURE.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECURENameLabel", - "options": { - "defaultValue": "Rechnung" - } - }, - "PAYONE_PAYONE_INVOICE_SECURE.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECUREDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_INVOICE_SECURE.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECUREMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_INVOICE_SECURE.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECUREMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_INVOICE_SECURE.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEINVOICESECUREAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.PaydirektTab": { - "label": "Config.PaydirektTab", - "formFields": { - "PAYONE_PAYONE_PAYDIREKT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEPAYDIREKTActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEPAYDIREKTActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_PAYDIREKT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTNameLabel", - "options": { - "defaultValue": "Paydirekt" - } - }, - "PAYONE_PAYONE_PAYDIREKT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_PAYDIREKT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_PAYDIREKT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_PAYDIREKT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYDIREKTAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.PayolutionRatenzahlungTab": { - "label": "Config.PayolutionRatenzahlungTab", - "formFields": { - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTActiveLabel", - "options": { - "defaultValue": "0", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTActivePossibleValue0" - } - ] - } - }, - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTNameLabel", - "options": { - "defaultValue": "Payolution Ratenzahlung" - } - }, - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_PAYOLUTION_INSTALLMENT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.PayPalTab": { - "label": "Config.PayPalTab", - "formFields": { - "PAYONE_PAYONE_PAY_PAL.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEPAYPALActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEPAYPALActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_PAY_PAL.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALNameLabel", - "options": { - "defaultValue": "Payone PAY_PAL" - } - }, - "PAYONE_PAYONE_PAY_PAL.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_PAY_PAL.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_PAY_PAL.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_PAY_PAL.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPAYPALAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.RatePayRatenzahlungTab": { - "label": "Config.RatePayRatenzahlungTab", - "formFields": { - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTActiveLabel", - "options": { - "defaultValue": "0", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONERATEPAYINSTALLMENTActivePossibleValue0" - } - ] - } - }, - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTNameLabel", - "options": { - "defaultValue": "RatePay Ratenzahlung" - } - }, - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_RATEPAY_INSTALLMENT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.SofortberweisungTab": { - "label": "Config.SofortberweisungTab", - "formFields": { - "PAYONE_PAYONE_SOFORT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONESOFORTActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONESOFORTActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONESOFORTActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_SOFORT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONESOFORTNameLabel", - "options": { - "defaultValue": "Sofortüberweisung" - } - }, - "PAYONE_PAYONE_SOFORT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONESOFORTDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_SOFORT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONESOFORTMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_SOFORT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONESOFORTMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_SOFORT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONESOFORTAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.VorkasseTab": { - "label": "Config.VorkasseTab", - "formFields": { - "PAYONE_PAYONE_PRE_PAYMENT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEPREPAYMENTActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEPREPAYMENTActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_PRE_PAYMENT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTNameLabel", - "options": { - "defaultValue": "Vorkasse" - } - }, - "PAYONE_PAYONE_PRE_PAYMENT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_PRE_PAYMENT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_PRE_PAYMENT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_PRE_PAYMENT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEPREPAYMENTAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.KreditkarteTab": { - "label": "Config.KreditkarteTab", - "formFields": { - "PAYONE_PAYONE_CREDIT_CARD.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONECREDITCARDActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONECREDITCARDActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_CREDIT_CARD.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDNameLabel", - "options": { - "defaultValue": "Kreditkarte" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_CREDIT_CARD.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.minExpireTime": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDMinExpireTimeLabel", - "options": { - "defaultValue": "30" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.defaultStyle": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDDefaultStyleLabel", - "options": { - "defaultValue": "font-family: Helvetica; padding: 10.5px 21px; color: #7a7f7f; font-size: 17.5px; height:100%" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.defaultHeightInPx": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDDefaultHeightInPxLabel", - "options": { - "defaultValue": "44" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.defaultWidthInPx": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDDefaultWidthInPxLabel", - "options": { - "defaultValue": "644" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - }, - "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes": { - "type": "multiCheckBox", - "required": false, - "label": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesLabel", - "options": { - "defaultValue": "all", - "checkBoxValues": [ - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.V", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesV" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.M", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesM" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.A", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesA" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.O", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesO" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.U", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesU" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.D", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesD" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.B", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesB" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.C", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesC" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.J", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesJ" - }, - { - "value": "PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.P", - "caption": "Config.PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesP" - } - ] - } - } - } - }, - "Config.NachnahmeTab": { - "label": "Config.NachnahmeTab", - "formFields": { - "PAYONE_PAYONE_CASH_ON_DELIVERY.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONECASHONDELIVERYActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONECASHONDELIVERYActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_CASH_ON_DELIVERY.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYNameLabel", - "options": { - "defaultValue": "Nachnahme" - } - }, - "PAYONE_PAYONE_CASH_ON_DELIVERY.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_CASH_ON_DELIVERY.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_CASH_ON_DELIVERY.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_CASH_ON_DELIVERY.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "Config.LastschriftTab": { - "label": "Config.LastschriftTab", - "formFields": { - "PAYONE_PAYONE_DIRECT_DEBIT.active": { - "type": "selectBox", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITActiveLabel", - "options": { - "defaultValue": "1", - "selectBoxValues": [ - { - "value": "0", - "caption": "Config.PAYONEPAYONEDIRECTDEBITActivePossibleValue0" - }, - { - "value": "1", - "caption": "Config.PAYONEPAYONEDIRECTDEBITActivePossibleValue1" - } - ] - } - }, - "PAYONE_PAYONE_DIRECT_DEBIT.name": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITNameLabel", - "options": { - "defaultValue": "Lastschrift" - } - }, - "PAYONE_PAYONE_DIRECT_DEBIT.description": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITDescriptionLabel", - "options": {} - }, - "PAYONE_PAYONE_DIRECT_DEBIT.minCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITMinCartAmountLabel", - "options": { - "defaultValue": "0" - } - }, - "PAYONE_PAYONE_DIRECT_DEBIT.maxCartAmount": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel", - "options": { - "defaultValue": "2000" - } - }, - "PAYONE_PAYONE_DIRECT_DEBIT.allowedCountries": { - "type": "inputText", - "required": false, - "label": "Config.PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel", - "options": { - "defaultValue": "DE,AT,CH" - } - } - } - }, - "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..50254796 100644 --- a/meta/documents/changelog_de.md +++ b/meta/documents/changelog_de.md @@ -1,2 +1,232 @@ -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 + +## 2.3.0 + +### Hinzugefügt +- Die Auswahl der verfügbaren Lieferländer wurde erweitert. + +### Behoben +- Beim gesicherten Rechnungskauf werden die Artikeldaten nun korrekt übergeben. + +## 2.2.0 + +### Hinzugefügt +- Beim Kopieren eines Plugin Sets werden nun auch die Einstellungen des Assistenten mit kopiert. + +## 2.1.3 + +### Behoben +- Bei der Prüfung, ob eine Zahlungsart für die nachträgliche Bezahlung zur Verfügung steht, werden die entsprechenden Regeln angewendet, die auch für den Checkout gelten. +- Trailing Slash Einstellung aus dem Backend wird nun korrekt verarbeitet. + +## 2.1.2 + +### Behoben +- Die erlaubten Arten von Kreditkarten wurden nicht korrekt dargestellt. Dies wurde nun behoben. + +## 2.1.1 + +### Behoben +- Durch eine fehlerhafte Konfiguration des Plugins konnte es Fehler im Webshop geben, dies wurde behoben. + +## 2.1.0 + +### Hinzugefügt +- Bestelleigenschaften können nun korrekt verarbeitet werden. + +## 2.0.0 + +### TODO +- Der Assistent muss in jedem verknüpften Plugin-Set durchlaufen werden, um das Plugin zu konfigurieren. + +### Hinzugefügt +- Die Einstellungen für das Payone-Plugin wurden in einen Assistenten überführt. Es ist nun möglich das Plugin pro Plugin-Set und pro Mandant zu konfigurieren. + +## 1.3.0 + +### Hinzugefügt +- Die erlaubten Lieferländer können in der Konfiguration des Plugins nun per Checkbox ausgewählt werden. + +### Geändert +- Für Bestellungen mit gesichertem Rechnungskauf können keine Rechnungen erstellt werden. + +## 1.2.2 + +### Behoben +- Ein Fehler bei der Kaufabwicklung mit der Zahlungsart "Kreditkarte" wurde behoben. + +## 1.2.1 + +### Behoben +- Die Zahlung wird nun in der korrekten Fremdwährung gespeichert, wenn diese von der Systemwährung abweicht. + +## 1.2.0 + +### Hinzugefügt +- Zahlungsart "Amazon Pay" hinzugefügt + +## 1.1.14 + +### Hinzugefügt +- Zahlungsart "Secure Invoice" hinzugefügt + +## 1.1.13 + +### Geändert +- Icon für das Backend hinzugefügt +- User Guide aktualisiert + +## 1.1.12 + +### Geändert +- Logging des Datenaustausches zur Payone Schnittstelle optimiert. + +## 1.1.11 + +### Geändert +- Logos und Bilder getauscht +- Funktionalitäten hinzugefügt für Backend-Sichtbarkeiten und Backend-Name + +## 1.1.10 + +### Behoben +- Auftragsnotizen bei Rückerstattungen werden nun wieder korrekt geschrieben. + +## 1.1.9 + +### Behoben +- Teilrückerstattungen können nun auch mehrfach ausgeführt werden, dies führte unter bestimmten Konstelationen zu einem Fehler. + +## 1.1.8 + +### 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 + +### Hinzugefügt +- Rückzahlungen werden nun per Notiz am Auftrag hinterlegt. Dazu muss in der Konfiguration eine UserID hinterlegt werden. + +## 1.1.6 + +### Behoben +- Fehlerhafte Auftragsanlage behoben + +## 1.1.5 + +### 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 + +### 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 + +### Geändert +- Optimierungen für die Eingabe des Geburtsdatums im Bestellprozess. +- User Guide aktualisiert. + +## 1.1.2 + +### 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 + +### 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 + +### Geändert +- Supportübernahme durch plentysystems +- Icons getauscht und Beschreibungen aktualisiert +- Updates an den User Guides in deutscher und englischer Sprache + +## 1.0.9 + +### Geändert +- Hinweistext im User Guide ergänzt + +## 1.0.8 + +### Geändert +- Informationen im Support-Tab aktualisiert +- Changelog aktualisiert + +## 1.0.7 + +### 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 + +### 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 + +### Geändert +- Logos und Name des Plugins aktualisiert + +## 1.0.4 + +### Geändert +- Dokumentation aktualisiert + +## 1.0.3 + +### Hinzugefügt +- Dokumentation in englischer Sprache hinzugefügt + +### Geändert +- Die aktuelle Payone PHP API wird nun genutzt + +## 1.0.2 + +### Geändert +- Scriptloader wird nun genutzt, um Payone Skripte in Templates einzubinden + +## 1.0.1 + +### Geändert +- Plugin-Dokumentation aktualisiert + +## 1.0.1 +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..800b97aa 100644 --- a/meta/documents/changelog_en.md +++ b/meta/documents/changelog_en.md @@ -1 +1,232 @@ -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 + +## 2.3.0 + +### Added +- The selection of available delivery countries has been extended. + +### Fixed +- The item data is now transferred correctly when using the secure invoice method. + +## 2.2.0 + +### Added +- When copying a plugin set, the settings of the assistant are now also copied. + +## 2.1.3 + +### Fixed +- When checking whether a payment method is available for subsequent payment, the same rules that are applied to the checkout als apply here. +- Trailing slash setting from the backend is now processed correctly. + +## 2.1.2 + +### Fixed +- The allowed types of credit cards were not displayed correctly. This has now been fixed. + +## 2.1.1 + +### Fixed +- Due to a faulty configuration of the plugin there could be errors in the webshop, this has been fixed. + +## 2.1.0 + +### Added +- Order item order properties can now be processed correctly. + +## 2.0.0 + +### TODO +- To configure the plugin, it is necessary to complete the assistant in each linked plugin set. + +### Hinzugefügt +- The settings for the Payone plugin have been transferred to an assistant. It is now possible to configure the plugin per plugin set and per client. + +## 1.3.0 + +### Added +- The allowed delivery countries can now be selected in the configuration of the plugin via checkbox. + +### Changed +- No invoices can be created for orders paid with secure invoice. + +## 1.2.2 + +### Fixed +- An error in the checkout process with the payment method "credit card" was fixed. + +## 1.2.1 + +### Fixed +- Save payment amount in foreign currency if the system currency is not the same as the basket currency. + +## 1.2.0 + +### Added +- Payment method "Amazon Pay" added + +## 1.1.14 + +### Added +- Payment method "Secure Invoice" added + +## 1.1.13 + +### Changed +- Added Icon for the backend +- Updated user guide + +## 1.1.12 + +### Changed +- Optimized logging of the data transfer with the Payone Api. + +## 1.1.11 + +### Changed +- New logos and images +- Added methods for the backend visibility and backend name + +## 1.1.10 + +### Fixed +- Writing Order notes during a refund works properly again. + +## 1.1.9 + +### Fixed +- Partial refunds can now be executed more than once. Under certain constellations an error came up. + +## 1.1.8 + +### 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 + +### Added +- An order note will added for refunds. Please add an user ID in the plugin configurations. + +## 1.1.6 + +### Fixed +- Fix wrong order creation + +## 1.1.5 + +### Fixed +- External orders will be created correct without skipping by the plugin. + +## 1.1.4 + +### Changed +- The Payone SDK was relocated + +### Added +- The payment method Amazon Pay was added for the backend. + +### Fixed +- Some log messages + +## 1.1.3 + +### Changed +- Optimisation for Entering the date of birth in the checkout process. +- Updated user guide + +## 1.1.2 + +### 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 + +### 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 + +### Changed +- Support is now within the responsibility of plentysystems +- Added new icons and customised descriptions +- Updated German and English user guides + +## 1.0.9 + +### Changed +- Added alert text to user guide + +## 1.0.8 + +### Changed +- Updated information in the support tab +- Updated changelog + +## 1.0.7 + +### 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 + +### 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 + +### Changed +- Updated logos and plugin name + +## 1.0.4 + +### Changed +- Updated documentation + +## 1.0.3 + +### Added +- Added English documentation + +### Changed +- The current Payone PHP API is now used + +## 1.0.2 + +### Changed +- Scriptloader is now used to include Payone scripts in templates + +## 1.0.1 + +### Changed +- Update plugin documentation + +## 1.0.1 +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..c77aa9cc 100644 --- a/meta/documents/user_guide_de.md +++ b/meta/documents/user_guide_de.md @@ -1,34 +1,48 @@ -# BS PAYONE Payment für plentymarkets 7 +# User Guide Payone -**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/)** + -Payment mit BS PAYONE überzeugt +## Payone -Eine Lösung, ein Partner, ein Vertrag: Einfach & effizient. Technische Abwicklung und Finanzdienstleistungen aus einer Hand. + -* Internationale Zahlungsabwicklung: Zugang zu internationalen und lokalen Zahlungsarten on demand. +Das plentymarkets PAYONE-Plugin bietet Zugang zu internationalen und lokalen Zahlungsarten. Gleichzeitig hast du Zugriff auf ein integriertes Risikomanagement, automatisierte Gutschriften und schnelle Retourenabwicklung. -* Integriertes Risikomanagement: Minimierung von Zahlungsausfällen und Betrug. Für mehr Profitabilität. +Aktuell beinhaltet das Plugin die folgenden Zahlungsarten: -* Automatisches Debitorenmanagement: Effektive Entlastung der Buchhaltung durch Transaktionszuordnung und Kontenabgleich. +* 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 +* Paydirekt +* PayPal - Anbindung Ihres PayPal-Accounts +* Amazon Pay - Anbindung Ihres Amazon Pay-Accounts -* Zahlungsartenübergreifende Gutschriften: Schnelles Retourenmanagement. Mit automatisierten Gutschriften. +### Wie bekomme ich einen PAYONE Account? +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, muss dieser mit einer Servicevereinbarung erst beantragt werden. Die PSG Projektmanagement GmbH ist hier Dein Ansprechpartner: -* Beste Referenzen, langjährige Erfahrung: Ausgewiesene Experten. Persönlicher Kundenservice. Bei jedem E-Commerce-Projekt. +PSG Projektmanagement GmbH
+Meergässle 4
+89180 Berghülen
+Telefon: 07344-9592588
+E-Mail: plenty@psg-projektmanagement.de
+Internet: http://www.psg-projektmanagement.de -## Aktuell unterstützte Zahlarten +Nutze für deine Kontaktaufnahme gerne unser Kontaktformular, oder vereinbare im Kalender direkt einen Termin für nähere Informationen. -* Rechnung -* Vorkasse -* Nachnahme -* Lastschrift -* Kreditkarte -* Kreditkarte 3DS -* Gesicherte Rechnung -* PayPal -* Paydirekt -* Sofortüberweisung +Kontaktformular:
+https://www.psg-projektmanagement.de/payone-plentymarkets/ + +Termin vereinbaren: +hier klicken -## Installationsanleitung +Die PSG Projektmanagement GmbH ist ein langjähriger Partner der PAYONE, sowie ein langjähriger Partner von plentymarkets und ist somit Dein zentraler Ansprechpartner der optimal mit allen Partnern vernetzt ist. Bitte wende dich nicht direkt an PAYONE, um den reibungslosen Ablauf nicht zu gefährden. -[Hinweise zur Installation und Einrichtung](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/README.md) \ No newline at end of file +Hier der offizielle Link zur Partnerschaft mit PAYONE: [https://payone.com/DE-de/plentymarkets-payone-plugin](https://payone.com/DE-de/plentymarkets-payone-plugin) diff --git a/meta/documents/user_guide_en.md b/meta/documents/user_guide_en.md index cf13377e..2c0eeac5 100644 --- a/meta/documents/user_guide_en.md +++ b/meta/documents/user_guide_en.md @@ -1,35 +1,49 @@ -# BS PAYONE Payment for plentymarkets 7 +# User Guide Payone -**Hinweis: The Distribution in Plentymarkets system is controlled by PSG Projektmanagement GmbH. [Click here for Registration](https://www.psg-projektmanagement.de/bs-payone/)** + -Payment with BS PAYONE convinces + -One solution, one partner, one contract: simple & efficient. Technical handling and financial services from a single -source. +## Payone -* International payment processing: access to international and local payment methods on demand. +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. -* Integrated risk management: minimizing defaults and fraud. For more profitability. +The plugin currently offers the following payment methods: -* Automatic Debtor Management: Effectively relieving the bookkeeping through transaction assignment and account reconciliation. +* 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 +* Paydirekt +* PayPal - Integration of your PayPal account +* Amazon Pay - Integration of your Amazon Pay account -* Multi-payment refunds: Fast returns management. With automated refunds. +### How to get a PAYONE Account? -* Best references, many years of experience: proven experts. Personal customer service. For every e-commerce project. +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, you have to applied a service agreement first. PSG Projektmanagement GmbH is your contact person: -## Currently supported payment methods +PSG Projektmanagement GmbH
+Meergässle 4
+89180 Berghülen
+Telefon: 07344-9592588
+E-Mail: plenty@psg-projektmanagement.de
+Internet: http://www.psg-projektmanagement.de -* invoice -* pre payment -* cash on delivery -* debit payment -* credit card -* credit card 3DS -* invoice secure -* PayPal -* Paydirekt -* Sofortüberweisung +Please use our Registration form to get in contact, or make an appointment directly in the calendar for more information. + +Registration form:
+https://www.psg-projektmanagement.de/payone-plentymarkets/ -## Installation guide +Make an appointment: +click here -[Information for installation and setup](https://github.com/PAYONE-GmbH/plentymarkets-7/blob/master/README.md) \ No newline at end of file +PSG Projektmanagement GmbH is a long-term partner of PAYONE, as well as a long-term partner of plentymarkets and is therefore your central contact who is optimally networked with all partners. Please do not contact PAYONE directly in order not to endanger the smooth process.
+Here is the official link to the partnership with PAYONE: +https://payone.com/DE-de/plentymarkets-payone-plugin \ No newline at end of file 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..215d0508 100644 --- a/plugin.json +++ b/plugin.json @@ -1,43 +1,60 @@ { - "version": "1.0.9", - "license":"MIT", - "pluginIcon":"icon_plugin_xs.png", - "price":0.0, - "authorIcon":"icon_author_xs.png", + "version": "2.3.0", + "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", - "keywords": ["Payone", "plentymarkets", "payment"], - "email": "info@arvatis.com", - "phone": "+49 (0)211 - 63 55 31 60", - "categories": [3519], + "author": "plentysystems AG", + "email": "sales@plentymarkets.com", + "phone": "+49 561 98 681 100", + "keywords": [ + "Payone", + "plentymarkets", + "payment" + ], + "categories": [ + 4083 + ], "type": "payment", "namespace": "Payone", "javaScriptFiles": [], "containers": [], - "require": [], - "serviceProvider": "Payone\\Providers\\PayoneServiceProvider", - "dependencies":{ - "arvatis/payone-php-api":"2.2.*" + "require": { + "IO": ">=5.0.4", + "Ceres":">=5.0.4" }, + "dependencies": { + "guzzlehttp/guzzle": "6.*", + "symfony/serializer": "3.2.7", + "symfony/property-access": "3.2.7", + "doctrine/common": "2.7.2", + "viison/address-splitter": "0.3.4" + }, + "serviceProvider": "Payone\\Providers\\PayoneServiceProvider", "runOnBuild": [ - "Payone\\Migrations\\CreatePaymentMethods" + "Payone\\Migrations\\CreatePaymentMethods3", + "Payone\\Migrations\\CreateSettingsTable" ], "dataProviders": [ - { - "key":"Payone\\Providers\\DataProviders\\ConfirmationAdditionalPaymentData", - "name":"Payone Order Confirmation Page Payment Data", - "description": "Block to display additional payment data on order success page." - }, - { - "key":"Payone\\Providers\\DataProviders\\Javascript", - "name":"Payone Checkout JS", - "description": "Block to integrate the payone payments into checkout" - } -] + { + "key": "Payone\\Providers\\DataProviders\\ConfirmationAdditionalPaymentData", + "name": "Payone Order Confirmation Page Payment Data", + "description": "Block to display additional payment data on order success page." + }, + { + "key": "Payone\\Providers\\DataProviders\\Javascript", + "name": "Payone Checkout JS", + "description": "Block to integrate the payone payments into checkout" + } + ] } diff --git a/resources/css/payone-amazonpay.css b/resources/css/payone-amazonpay.css new file mode 100644 index 00000000..c64799ae --- /dev/null +++ b/resources/css/payone-amazonpay.css @@ -0,0 +1,45 @@ +/* +Include the min-width, max-width, min-height +and max-height if you plan to use a relative CSS unit +measurement to make sure the widget renders in the +optimal size allowed. +*/ + +.addressBookWidgetDiv { + min-width: 300px; + width: 100%; + max-width: 900px; + min-height: 228px; + height: 240px; + max-height: 400px; +} + +.walletWidgetDiv { + min-width: 300px; + width: 100%; + max-width: 900px; + min-height: 228px; + height: 240px; + max-height: 400px; +} + + +/* The following are required only when you use the read-only widgets: */ + +#readOnlyAddressBookWidgetDiv { + min-width: 266px; + width: 100%; + max-width: 900px; + min-height: 145px; + height: 165px; + max-height: 180px; +} + +#readOnlyWalletWidgetDiv { + min-width: 266px; + width: 100%; + max-width: 900px; + min-height: 145px; + height: 165px; + max-height: 180px; +} diff --git a/resources/images/logos/PAYONE_PAYONE_AMAZON_PAY.png b/resources/images/logos/PAYONE_PAYONE_AMAZON_PAY.png new file mode 100644 index 00000000..f7055f2c Binary files /dev/null and b/resources/images/logos/PAYONE_PAYONE_AMAZON_PAY.png differ 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/AmazonPay.properties b/resources/lang/de/AmazonPay.properties new file mode 100644 index 00000000..8ae449b3 --- /dev/null +++ b/resources/lang/de/AmazonPay.properties @@ -0,0 +1,10 @@ +apiCall=Aufruf der API +configLoginButton=Login-Button für die Anmeldung konfigurieren +renderLoginWidget=Rendern des Login-Buttons +renderWidgets=Rendern des Adressbuch- und Zahlungsarten-Widgets +getOrderReference=Laden der Auftragsreferenz +registerCustomer=Kundenadresse von Amazon laden +setOrderReference=Setzen der Auftragsreferenz +confirmOrderReference=Bestätigen der Auftragsreferenz +paymentMethodContent=Innerhalb des PaymentMethodContent-Events +paymentExecute=Innerhalb des PaymentExecute-Events 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/Assistant.properties b/resources/lang/de/Assistant.properties new file mode 100644 index 00000000..1f31f740 --- /dev/null +++ b/resources/lang/de/Assistant.properties @@ -0,0 +1,127 @@ +assistantTitle=Payone +assistantShortDescription=Assistent zum Einrichten des Payone Plugins. +clientId=Mandant + +## Account Step +titlePayoneAccountStep=Konto +descriptionPayoneAccountStep= +titlePayoneAccountStepAccount=Kontoeinrichtung +descriptionPayoneAccountStepAccount=In diesem Schritt richtest du die Schnittstelle zu Payone ein. Die dazu benötigten Daten erhältst du nach Eröffnung deines Payone Accounts im Payone Merchant Interface. Die hier ausgewählte Autorisierungsart wird als Standard genommen und auf die aktivierten Zahlungsarten übertragen, kann dort aber in den nächsten Schritten individuell angepasst werden. Wähle zwischen Vorautorisierung (Zahlungseinzug wird vorgemerkt, findet nicht sofort statt) und Autorisierung (Zahlungseinzug findet sofort statt). +mid=Merchant-ID +portalId=Portal-ID +aid=Account-ID +key=Schlüssel +mode=Modus +modeProductiveOption=Produktiv +modeTestingOption=Test +authType=Art der Autorisierung +authTypeAuthorization=Autorisierung +authTypePreAuthorization=Vorautorisierung +authTypeDefault=Standard-Autorisierungsart +userId=Benutzer-ID für Auftragsnotizen + +## Products Step +titlePayoneProductsStep=Produktauswahl +descriptionPayoneProductsStep=Wähle die von Payone angebotenen Zahlungsarten, die du verwenden möchtest. +titlePayoneProductsStepPAYONE_PAYONE_INVOICE=Rechnung +descriptionPayoneProductsStepPAYONE_PAYONE_INVOICE= + +titlePayoneProductsStepPAYONE_PAYONE_PAYDIREKT=Paydirekt +descriptionPayoneProductsStepPAYONE_PAYONE_PAYDIREKT= +titlePayoneProductsStepPAYONE_PAYONE_PAYOLUTION_INSTALLMENT=Payolution Ratenzahlung +descriptionPayoneProductsStepPAYONE_PAYONE_PAYOLUTION_INSTALLMENT= +titlePayoneProductsStepPAYONE_PAYONE_PAY_PAL=PayPal +descriptionPayoneProductsStepPAYONE_PAYONE_PAY_PAL= +titlePayoneProductsStepPAYONE_PAYONE_RATEPAY_INSTALLMENT=RatePay Ratenzahlung +descriptionPayoneProductsStepPAYONE_PAYONE_RATEPAY_INSTALLMENT= +titlePayoneProductsStepPAYONE_PAYONE_SOFORT=Sofortüberweisung +descriptionPayoneProductsStepPAYONE_PAYONE_SOFORT= +titlePayoneProductsStepPAYONE_PAYONE_CASH_ON_DELIVERY=Nachnahme +descriptionPayoneProductsStepPAYONE_PAYONE_CASH_ON_DELIVERY= +titlePayoneProductsStepPAYONE_PAYONE_PRE_PAYMENT=Vorkasse +descriptionPayoneProductsStepPAYONE_PAYONE_PRE_PAYMENT= +titlePayoneProductsStepPAYONE_PAYONE_CREDIT_CARD=Kreditkarte +descriptionPayoneProductsStepPAYONE_PAYONE_CREDIT_CARD= +titlePayoneProductsStepPAYONE_PAYONE_DIRECT_DEBIT=Lastschrift +descriptionPayoneProductsStepPAYONE_PAYONE_DIRECT_DEBIT= +titlePayoneProductsStepPAYONE_PAYONE_INVOICE_SECURE=Payone Gesicherte Rechnung +descriptionPayoneProductsStepPAYONE_PAYONE_INVOICE_SECURE= +titlePayoneProductsStepPAYONE_PAYONE_AMAZON_PAY=Amazon Pay +descriptionPayoneProductsStepPAYONE_PAYONE_AMAZON_PAY= + +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_BANK=Klarna Direct Bank Transfer +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_BANK= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_DEBIT=Klarna Direct Debit +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_DEBIT= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_INSTALLMENTS=Klarna Installments +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_INSTALLMENTS= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_INVOICE=Klarna Invoice Pay +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_INVOICE= +titlePayonePaymentSection=Konfiguration +descriptionPayonePaymentSection=Nimm die benötigten Konfigurationen für die Zahlungsart vor. Es sind Standardeinstellungen gesetzt, die sich jedoch anpassen lassen. Als Lieferländer sind deine aktuell im System aktivierten Lieferländer vorausgewählt. + +## Title products toggle +titlePAYONE_PAYONE_INVOICE_Toggle=Rechnung aktivieren. +titlePAYONE_PAYONE_PAYDIREKT_Toggle=Paydirekt aktivieren. +titlePAYONE_PAYONE_PAYOLUTION_INSTALLMENT_Toggle=Payolution Ratenzahlung aktivieren. +titlePAYONE_PAYONE_PAY_PAL_Toggle=PayPal aktivieren. +titlePAYONE_PAYONE_RATEPAY_INSTALLMENT_Toggle=Ratepay Ratenzahlung aktivieren. +titlePAYONE_PAYONE_SOFORT_Toggle=Sofortüberweisung aktivieren. +titlePAYONE_PAYONE_CASH_ON_DELIVERY_Toggle=Nachnahme aktivieren. +titlePAYONE_PAYONE_PRE_PAYMENT_Toggle=Vorkasse aktivieren. +titlePAYONE_PAYONE_CREDIT_CARD_Toggle=Kreditkarte aktivieren. +titlePAYONE_PAYONE_DIRECT_DEBIT_Toggle=Lastschrift aktivieren. +titlePAYONE_PAYONE_INVOICE_SECURE_Toggle=Gesicherte Rechnung aktivieren. +titlePAYONE_PAYONE_AMAZON_PAY_Toggle=Amazon Pay aktivieren. + +titlePAYONE_PAYONE_KLARNA_DIRECT_BANK_Toggle=Klarna Direct Bank aktivieren. +titlePAYONE_PAYONE_KLARNA_DIRECT_DEBIT_Toggle=Klarna Direct Debit aktivieren. +titlePAYONE_PAYONE_KLARNA_Toggle=Klarna Installments aktivieren. +titlePAYONE_PAYONE_KLARNA_INVOICE_Toggle=Klarna Invoice aktivieren. + +## Additional Secure Invoice configuration description +descriptionPayonePaymentSectionSecureInvoice=Nimm die benötigten Konfigurationen für die Zahlungsart vor. Es sind Standardeinstellungen gesetzt, die sich jedoch anpassen lassen. Als Lieferländer sind deine aktuell im System aktivierten Lieferländer vorausgewählt. Zudem sind eine eigene Portal-ID sowie ein eigener Schlüssel für die Zahlungsart Gesicherter Rechnungskauf notwendig. Diese müssen bei der Konfiguration separat hinterlegt werden. Die Portal-ID und den Schlüssel erhältst du im Menü Konfiguration » Zahlungsportale im Payone Merchant Interface. + +## Additional Amazon Pay Settings +Sandbox=Modus +sandboxProductiveOption=Produktiv +sandboxTestingOption=Test +descriptionPayonePaymentSectionAmazonPay=Um die Zahlungsart Amazon Pay nutzen zu können, musst du dein Amazon-Konto mit Payone verknüpfen. Wende dich dafür an den Payone Support. Nimm die benötigten Konfigurationen für die Zahlungsart vor. Es sind Standardeinstellungen gesetzt, die sich jedoch anpassen lassen. Als Lieferländer sind deine aktuell im System aktivierten Lieferländer vorausgewählt. Zudem kannst du die Einstellung Test aktivieren. Diese ermöglicht es dir mit Testkäufen die Zahlungsart zu testen. Wähle Produktiv, um Amazon Pay aktiv zu schalten. Beachte, dass Amazon Pay nicht genutzt werden kann, wenn du bereits PayPal in Mode 1 integriert hast. In diesem Mode überschreibt PayPal den gesamten Checkout mit der PayPal-Wall, daher stehen die für Amazon Pay benötigten Widgets nicht zur Verfügung. + +## General Configurations Settings +allowedDeliveryCountries=Lieferländer +MinimumAmount=Gib einen Mindestbetrag für Käufe mit dieser Zahlungsart ein. +MaximumAmount=Gib einen Maximalbetrag für Käufe mit dieser Zahlungsart ein. + +## Delivery Country names +deliveryCountryDE=Deutschland +deliveryCountryAT=Österreich +deliveryCountryCH=Schweiz +deliveryCountryFR=Frankreich +deliveryCountryIT=Italien +deliveryCountryES=Spanien +deliveryCountryLU=Luxemburg +deliveryCountryNL=Niederlande +deliveryCountrySE=Schweden +deliveryCountryPT=Portugal +deliveryCountryHU=Ungarn +deliveryCountryDK=Dänemark + +## Additional Credit Card Settings +minExpireTime=Minimale Kartengültigkeit in Tagen +defaultStyle=Standardform der Eingabefelder für Kreditkartendaten +defaultHeightInPx=Höhe der Eingabefelder in px +defaultWidthInPx=Breite der Eingabefelder in px +AllowedCardTypes=Erlaubte Kartentypen + +## Credit card types +creditCardTypeV=Visa +creditCardTypeM=Mastercard +creditCardTypeA=Amex +creditCardTypeO=Maestro (Int) +creditCardTypeU=Maestro (UK) +creditCardTypeD=Diners +creditCardTypeB=Carte Blue +creditCardTypeC=Discover +creditCardTypeJ=JCB +creditCardTypeP=China Union Pay diff --git a/resources/lang/de/Config.properties b/resources/lang/de/Config.properties deleted file mode 100644 index a33425d0..00000000 --- a/resources/lang/de/Config.properties +++ /dev/null @@ -1,133 +0,0 @@ -GrundeinstellungenTab=Grundeinstellungen -midLabel=Merchant-Id -portalidLabel=Portal-Id -aidLabel=Account-Id -keyLabel=Key -modeLabel=Modus -modePossibleValue0=Test -modePossibleValue1=Live -authTypeLabel=Autorisierungsmethode -authTypePossibleValue0=Preautorisierung -authTypePossibleValue1=Autorisierung -RechnungTab=Rechnung -PAYONEPAYONEINVOICEActiveLabel=Aktiv -PAYONEPAYONEINVOICEActivePossibleValue0=Nein -PAYONEPAYONEINVOICEActivePossibleValue1=Ja -PAYONEPAYONEINVOICENameLabel=Name -PAYONEPAYONEINVOICEDescriptionLabel=Beschreibung -PAYONEPAYONEINVOICEMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEINVOICEMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEINVOICEAllowedCountriesLabel=Erlaubte Länder -GesicherteRechnungTab=Gesicherte Rechnung -PAYONEPAYONEINVOICESECUREActiveLabel=Aktiv -PAYONEPAYONEINVOICESECUREActivePossibleValue0=Nein -PAYONEPAYONEINVOICESECUREActivePossibleValue1=Ja -PAYONEPAYONEINVOICESECURENameLabel=Name -PAYONEPAYONEINVOICESECUREDescriptionLabel=Beschreibung -PAYONEPAYONEINVOICESECUREMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEINVOICESECUREMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=Erlaubte Länder -PaydirektTab=Paydirekt -PAYONEPAYONEPAYDIREKTActiveLabel=Aktiv -PAYONEPAYONEPAYDIREKTActivePossibleValue0=Nein -PAYONEPAYONEPAYDIREKTActivePossibleValue1=Ja -PAYONEPAYONEPAYDIREKTNameLabel=Name -PAYONEPAYONEPAYDIREKTDescriptionLabel=Beschreibung -PAYONEPAYONEPAYDIREKTMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEPAYDIREKTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYDIREKTAllowedCountriesLabel=Erlaubte Länder -PayolutionRatenzahlungTab=Payolution Ratenzahlung -PAYONEPAYONEPAYOLUTIONINSTALLMENTActiveLabel=Aktiv -PAYONEPAYONEPAYOLUTIONINSTALLMENTActivePossibleValue0=Nein -PAYONEPAYONEPAYOLUTIONINSTALLMENTNameLabel=Name -PAYONEPAYONEPAYOLUTIONINSTALLMENTDescriptionLabel=Beschreibung -PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=Erlaubte Länder -PayPalTab=PayPal -PAYONEPAYONEPAYPALActiveLabel=Aktiv -PAYONEPAYONEPAYPALActivePossibleValue0=Nein -PAYONEPAYONEPAYPALActivePossibleValue1=Ja -PAYONEPAYONEPAYPALNameLabel=Name -PAYONEPAYONEPAYPALDescriptionLabel=Beschreibung -PAYONEPAYONEPAYPALMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEPAYPALMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPAYPALAllowedCountriesLabel=Erlaubte Länder -RatePayRatenzahlungTab=RatePay Ratenzahlung -PAYONEPAYONERATEPAYINSTALLMENTActiveLabel=Aktiv -PAYONEPAYONERATEPAYINSTALLMENTActivePossibleValue0=Nein -PAYONEPAYONERATEPAYINSTALLMENTNameLabel=Name -PAYONEPAYONERATEPAYINSTALLMENTDescriptionLabel=Beschreibung -PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=Erlaubte Länder -SofortberweisungTab=Sofortüberweisung -PAYONEPAYONESOFORTActiveLabel=Aktiv -PAYONEPAYONESOFORTActivePossibleValue0=Nein -PAYONEPAYONESOFORTActivePossibleValue1=Ja -PAYONEPAYONESOFORTNameLabel=Name -PAYONEPAYONESOFORTDescriptionLabel=Beschreibung -PAYONEPAYONESOFORTMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONESOFORTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONESOFORTAllowedCountriesLabel=Erlaubte Länder -VorkasseTab=Vorkasse -PAYONEPAYONEPREPAYMENTActiveLabel=Aktiv -PAYONEPAYONEPREPAYMENTActivePossibleValue0=Nein -PAYONEPAYONEPREPAYMENTActivePossibleValue1=Ja -PAYONEPAYONEPREPAYMENTNameLabel=Name -PAYONEPAYONEPREPAYMENTDescriptionLabel=Beschreibung -PAYONEPAYONEPREPAYMENTMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEPREPAYMENTMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=Erlaubte Länder -KreditkarteTab=Kreditkarte -PAYONEPAYONECREDITCARDActiveLabel=Aktiv -PAYONEPAYONECREDITCARDActivePossibleValue0=Nein -PAYONEPAYONECREDITCARDActivePossibleValue1=Ja -PAYONEPAYONECREDITCARDNameLabel=Name -PAYONEPAYONECREDITCARDDescriptionLabel=Beschreibung -PAYONEPAYONECREDITCARDMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONECREDITCARDMaxCartAmountLabel=Maximaler Bestellwert -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 -PAYONEPAYONECREDITCARDAllowedCardTypesLabel=Erlaubte Kartentypen -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesV=Visa -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesM=Mastercard -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesA=Amex -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesO=Maestro (Int) -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesU=Maestro (UK) -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesD=Diners -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesB=Carte Bleue -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesC=Discover -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesJ=JCB -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesP=China Union Pay -NachnahmeTab=Nachnahme -PAYONEPAYONECASHONDELIVERYActiveLabel=Aktiv -PAYONEPAYONECASHONDELIVERYActivePossibleValue0=Nein -PAYONEPAYONECASHONDELIVERYActivePossibleValue1=Ja -PAYONEPAYONECASHONDELIVERYNameLabel=Name -PAYONEPAYONECASHONDELIVERYDescriptionLabel=Beschreibung -PAYONEPAYONECASHONDELIVERYMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=Erlaubte Länder -LastschriftTab=Lastschrift -PAYONEPAYONEDIRECTDEBITActiveLabel=Aktiv -PAYONEPAYONEDIRECTDEBITActivePossibleValue0=Nein -PAYONEPAYONEDIRECTDEBITActivePossibleValue1=Ja -PAYONEPAYONEDIRECTDEBITNameLabel=Name -PAYONEPAYONEDIRECTDEBITDescriptionLabel=Beschreibung -PAYONEPAYONEDIRECTDEBITMinCartAmountLabel=Minimaler Bestellwert -PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel=Maximaler Bestellwert -PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=Erlaubte Länder -DebuggingTab=Debugging -debuggingActiveLabel=Aktiv -debuggingActivePossibleValue0=Nein -debuggingActivePossibleValue1=Ja -has = "has" -get = "get" -set = "set" -prepend = "prepend" -push = "push" -getPrefix = "getPrefix" \ No newline at end of file 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/MultilingualismConfig.properties b/resources/lang/de/MultilingualismConfig.properties new file mode 100644 index 00000000..3dccea4c --- /dev/null +++ b/resources/lang/de/MultilingualismConfig.properties @@ -0,0 +1,3 @@ +; sections +paymentMethod = "Zahlungsart" +template = "Mitteilungen" 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/PaymentMethods.properties b/resources/lang/de/PaymentMethods.properties new file mode 100644 index 00000000..e8b5275e --- /dev/null +++ b/resources/lang/de/PaymentMethods.properties @@ -0,0 +1,32 @@ +PAYONE_PAYONE_INVOICE=Rechnung +PAYONE_PAYONE_INVOICE_DESCRIPTION= +PAYONE_PAYONE_PAYDIREKT=Paydirekt +PAYONE_PAYONE_PAYDIREKT_DESCRIPTION= +PAYONE_PAYONE_PAYOLUTION_INSTALLMENT=Payolution Ratenzahlung +PAYONE_PAYONE_PAYOLUTION_INSTALLMENT_DESCRIPTION= +PAYONE_PAYONE_PAY_PAL=PayPal +PAYONE_PAYONE_PAY_PAL_DESCRIPTION= +PAYONE_PAYONE_RATEPAY_INSTALLMENT=Ratepay Ratenzahlung +PAYONE_PAYONE_RATEPAY_INSTALLMENT_DESCRIPTION= +PAYONE_PAYONE_SOFORT=Sofortüberweisung +PAYONE_PAYONE_SOFORT_DESCRIPTION= +PAYONE_PAYONE_CASH_ON_DELIVERY=Nachnahme +PAYONE_PAYONE_CASH_ON_DELIVERY_DESCRIPTION= +PAYONE_PAYONE_PRE_PAYMENT=Vorkasse +PAYONE_PAYONE_PRE_PAYMENT_DESCRIPTION= +PAYONE_PAYONE_CREDIT_CARD=Kreditkarte +PAYONE_PAYONE_CREDIT_CARD_DESCRIPTION= +PAYONE_PAYONE_DIRECT_DEBIT=Lastschrift +PAYONE_PAYONE_DIRECT_DEBIT_DESCRIPTION= +PAYONE_PAYONE_INVOICE_SECURE=Gesicherte Rechnung +PAYONE_PAYONE_INVOICE_SECURE_DESCRIPTION= +PAYONE_PAYONE_AMAZON_PAY=Amazon Pay +PAYONE_PAYONE_AMAZON_PAY_DESCRIPTION= +PAYONE_PAYONE_KLARNA_DIRECT_BANK=Direct Bank Transfer +PAYONE_PAYONE_KLARNA_DIRECT_BANK_DESCRIPTION= +PAYONE_PAYONE_KLARNA_DIRECT_DEBIT=Direct Debit Pay +PAYONE_PAYONE_KLARNA_DIRECT_DEBIT_DESCRIPTION= +PAYONE_PAYONE_KLARNA_INSTALLMENTS=Klarna Installments +PAYONE_PAYONE_KLARNA_INSTALLMENTS_DESCRIPTION= +PAYONE_PAYONE_KLARNA_INVOICE=Klarna Invoice +PAYONE_PAYONE_KLARNA_INVOICE_DESCRIPTION= diff --git a/resources/lang/de/Template.properties b/resources/lang/de/Template.properties index 8337628c..7d208996 100755 --- a/resources/lang/de/Template.properties +++ b/resources/lang/de/Template.properties @@ -1,5 +1,5 @@ -orderErrorTitle = "Bestellung nicht möglich" -orderErrorMessage = "Diese Zahlung konnte nicht durchgeführt werden. Dies kann unterschiedliche Gründe haben, wie etwa fehlerhafte Eingabedaten, eine unbekannte Adresse, oder ein vorübergehendes technisches Problem. Bitte überprüfen Sie die angegebenen Daten, oder wählen Sie ein anderes Zahlungsmittel." +orderErrorTitle = "Bestellung ist nicht möglich." +orderErrorMessage = "Diese Zahlung konnte nicht durchgeführt werden. Dies kann unterschiedliche Gründe haben, wie etwa fehlerhafte Eingabedaten, eine unbekannte Adresse oder ein vorübergehendes technisches Problem. Bitte überprüfen Sie die angegebenen Daten, oder wählen Sie ein anderes Zahlungsmittel." orderPlace= "Bestellung abschließen" orderCancel= "Abbrechen" continue= "Weiter" @@ -9,8 +9,10 @@ ccValidTo = "Gültig bis" firstName = "Vorname" lastName = "Nachname" -sepaMandateConsent = "Hiermit erteile ich ein elektronisches Sepamandat." +sepaMandateConsent = "Hiermit erteile ich ein elektronisches SEPA-Lastschriftmandat." yourBankAccount = "Ihre Bankverbindung" -accountHolder = "Konto Inhaber" +accountHolder = "Kontoinhaber" -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-Lastschriftmandat vom Kontoinhaber." + +missingDateOfBirth = "Bitte geben Sie ein Geburtsdatum an." diff --git a/resources/lang/en/AmazonPay.properties b/resources/lang/en/AmazonPay.properties new file mode 100644 index 00000000..69933c78 --- /dev/null +++ b/resources/lang/en/AmazonPay.properties @@ -0,0 +1,10 @@ +apiCall=Calling the API +configLoginButton=Config for login button +renderLoginWidget=Render login widget +renderWidgets=Render widgets +getOrderReference=Get order reference +registerCustomer=Customer addresses from Amazon +setOrderReference=Set order reference +confirmOrderReference=Confirm order reference on Amazon +paymentMethodContent=Within the paymentMethodContent-Event +paymentExecute=Within the paymentExecute-Event 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/Assistant.properties b/resources/lang/en/Assistant.properties new file mode 100644 index 00000000..eb164747 --- /dev/null +++ b/resources/lang/en/Assistant.properties @@ -0,0 +1,125 @@ +assistantTitle=Payone +assistantShortDescription=Assistant for setting up the Payone plugin. +clientId=Client + +## Account Step +titlePayoneAccountStep=Account +descriptionPayoneAccountStep= +titlePayoneAccountStepAccount=Account setup +descriptionPayoneAccountStepAccount=In this step, you set up the interface to Payone. For this, you need data which you get from the Payone Merchant Interface after you opened your Payone account. The authorisation method selected here is taken as default and transferred to the activated payment methods. Adaptations can be made individually in the next steps, if needed. Choose between Preauthorisation (payment collection is prepared and not executed immediately) or Authorisation (payment collection is executed immediately). +mid=Merchant ID +portalId=Portal ID +aid=Account ID +key=Key +mode=Mode +modeProductiveOption=Productive +modeTestingOption=Testing +authType=Authorisation method +authTypeAuthorization=Authorisation +authTypePreAuthorization=Preauthorisation +authTypeDefault=Default authorisation method +userId=User ID for order notes + +## Products Step +titlePayoneProductsStep=Products +descriptionPayoneProductsStep=Select the Payone payment methods you want to use. +titlePayoneProductsStepPAYONE_PAYONE_INVOICE=Invoice +descriptionPayoneProductsStepPAYONE_PAYONE_INVOICE= +titlePayoneProductsStepPAYONE_PAYONE_PAYDIREKT=Paydirekt +descriptionPayoneProductsStepPAYONE_PAYONE_PAYDIREKT= +titlePayoneProductsStepPAYONE_PAYONE_PAYOLUTION_INSTALLMENT=Payolution Installments +descriptionPayoneProductsStepPAYONE_PAYONE_PAYOLUTION_INSTALLMENT= +titlePayoneProductsStepPAYONE_PAYONE_PAY_PAL=PayPal +descriptionPayoneProductsStepPAYONE_PAYONE_PAY_PAL= +titlePayoneProductsStepPAYONE_PAYONE_RATEPAY_INSTALLMENT=RatePay Installments +descriptionPayoneProductsStepPAYONE_PAYONE_RATEPAY_INSTALLMENT= +titlePayoneProductsStepPAYONE_PAYONE_SOFORT=Online bank transfer +descriptionPayoneProductsStepPAYONE_PAYONE_SOFORT= +titlePayoneProductsStepPAYONE_PAYONE_CASH_ON_DELIVERY=Cash on delivery +descriptionPayoneProductsStepPAYONE_PAYONE_CASH_ON_DELIVERY= +titlePayoneProductsStepPAYONE_PAYONE_PRE_PAYMENT=Cash in advance +descriptionPayoneProductsStepPAYONE_PAYONE_PRE_PAYMENT= +titlePayoneProductsStepPAYONE_PAYONE_CREDIT_CARD=Credit card +descriptionPayoneProductsStepPAYONE_PAYONE_CREDIT_CARD= +titlePayoneProductsStepPAYONE_PAYONE_DIRECT_DEBIT=Debit +descriptionPayoneProductsStepPAYONE_PAYONE_DIRECT_DEBIT= +titlePayoneProductsStepPAYONE_PAYONE_INVOICE_SECURE=Payone Secure Invoice +descriptionPayoneProductsStepPAYONE_PAYONE_INVOICE_SECURE= +titlePayoneProductsStepPAYONE_PAYONE_AMAZON_PAY=Amazon Pay +descriptionPayoneProductsStepPAYONE_PAYONE_AMAZON_PAY= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_BANK=Klarna Direct Bank Transfer +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_BANK= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_DEBIT=Klarna Direct Debit +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_DIRECT_DEBIT= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_INSTALLMENTS=Klarna Installments +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_INSTALLMENTS= +titlePayoneProductsStepPAYONE_PAYONE_KLARNA_INVOICE=Klarna Invoice Pay +descriptionPayoneProductsStepPAYONE_PAYONE_KLARNA_INVOICE= +titlePayonePaymentSection=Configuration +descriptionPayonePaymentSection=Carry out the settings needed for this payment method. Default settings are preset, but they are adaptable. The preselected delivery countries are those currently activated in your system. + +## Title products toggle +titlePAYONE_PAYONE_INVOICE_Toggle=Activate Invoice. +titlePAYONE_PAYONE_PAYDIREKT_Toggle=Activate Paydirekt. +titlePAYONE_PAYONE_PAYOLUTION_INSTALLMENT_Toggle=Activate Payolution Installments. +titlePAYONE_PAYONE_PAY_PAL_Toggle=Activate PayPal. +titlePAYONE_PAYONE_RATEPAY_INSTALLMENT_Toggle=Activate Ratepay Installments. +titlePAYONE_PAYONE_SOFORT_Toggle=Activate Sofort. +titlePAYONE_PAYONE_CASH_ON_DELIVERY_Toggle=Activate Cash on delivery. +titlePAYONE_PAYONE_PRE_PAYMENT_Toggle=Activate Cash in advance. +titlePAYONE_PAYONE_CREDIT_CARD_Toggle=Activate Credit card. +titlePAYONE_PAYONE_DIRECT_DEBIT_Toggle=Activate Debit. +titlePAYONE_PAYONE_INVOICE_SECURE_Toggle=Activate Secure Invoice. +titlePAYONE_PAYONE_AMAZON_PAY_Toggle=Activate Amazon Pay. + +titlePAYONE_PAYONE_KLARNA_DIRECT_BANK_Toggle=Activate Klarna Direct Bank. +titlePAYONE_PAYONE_KLARNA_DIRECT_DEBIT_Toggle=Activate Klarna Direct Debit. +titlePAYONE_PAYONE_KLARNA_INSTALLMENTS_Toggle=Activate Klarna Installments. +titlePAYONE_PAYONE_KLARNA_INVOICE_Toggle=Activate Klarna Invoice. + +## Additional Secure Invoice configuration description +descriptionPayonePaymentSectionSecureInvoice=Carry out the settings needed for this payment method. Default settings are preset, but they are adaptable. The preselected delivery countries are those currently activated in your system. Moreover, you need a separate Portal ID and Key for the payment method Secure Invoice. These have to be entered separately in this configuration. You get the Portal ID and the Key in the Configuration » Payment portals menu in the Payone Merchant Interface. + +## Additional Amazon Pay Settings +Sandbox=Mode +sandboxProductiveOption=Productive +sandboxTestingOption=Testing +descriptionPayonePaymentSectionAmazonPay=In order to use the payment method Amazon Pay, you have to link your Amazon account with Payone. To do so, contact the Payone Support. Carry out the settings needed for this payment method. Default settings are preset, but they are adaptable. The preselected delivery countries are those currently activated in your system. Additionally, you can activate the mode Testing. This setting enables you to test the payment method first with test purchases. Select the mode Productive to activate Amazon Pay. Note that you cannot use Amazon Pay if you have already integrated PayPal in Mode 1. In this mode, PayPal overwrites the entire checkout with the PayPal-Wall so that the widgtes Amazon Pay needs are not available. + +## General Configurations Settings +allowedDeliveryCountries=Delivery countries +MinimumAmount=Enter a minimum amount for purchases with this payment method. +MaximumAmount=Enter a maximum amount for purchases with this payment method. + +## Delivery Country names +deliveryCountryDE=Germany +deliveryCountryAT=Austria +deliveryCountryCH=Switzerland +deliveryCountryFR=France +deliveryCountryIT=Italy +deliveryCountryES=Spain +deliveryCountryLU=Luxembourg +deliveryCountryNL=Netherlands +deliveryCountrySE=Sweden +deliveryCountryPT=Portugal +deliveryCountryHU=Hungary +deliveryCountryDK=Denmark + +## Additional Credit Card Settings +minExpireTime=Minimum card validity in days +defaultStyle=Standard style of input fields for credit card data +defaultHeightInPx=Credit card fields height in px +defaultWidthInPx=Credit card fields width in px +AllowedCardTypes=Allowed card types + +## Credit card types +creditCardTypeV=Visa +creditCardTypeM=Mastercard +creditCardTypeA=Amex +creditCardTypeO=Maestro (Int) +creditCardTypeU=Maestro (UK) +creditCardTypeD=Diners +creditCardTypeB=Carte Blue +creditCardTypeC=Discover +creditCardTypeJ=JCB +creditCardTypeP=China Union Pay diff --git a/resources/lang/en/Config.properties b/resources/lang/en/Config.properties deleted file mode 100644 index de89d5d5..00000000 --- a/resources/lang/en/Config.properties +++ /dev/null @@ -1,133 +0,0 @@ -GrundeinstellungenTab=Basesettings -midLabel=Merchant-Id -portalidLabel=Portal-Id -aidLabel=Account-Id -keyLabel=Key -modeLabel=Modus -modePossibleValue0=Test -modePossibleValue1=Live -authTypeLabel=authorization method -authTypePossibleValue0=Preauthorization -authTypePossibleValue1=authorization -RechnungTab=Invoice -PAYONEPAYONEINVOICEActiveLabel=Activ -PAYONEPAYONEINVOICEActivePossibleValue0=No -PAYONEPAYONEINVOICEActivePossibleValue1=Yes -PAYONEPAYONEINVOICENameLabel=Name -PAYONEPAYONEINVOICEDescriptionLabel=Description -PAYONEPAYONEINVOICEMinCartAmountLabel=Min Order amount -PAYONEPAYONEINVOICEMaxCartAmountLabel=Max Order amount -PAYONEPAYONEINVOICEAllowedCountriesLabel=allowed Countries -GesicherteRechnungTab=Secured invoice -PAYONEPAYONEINVOICESECUREActiveLabel=Activ -PAYONEPAYONEINVOICESECUREActivePossibleValue0=No -PAYONEPAYONEINVOICESECUREActivePossibleValue1=Yes -PAYONEPAYONEINVOICESECURENameLabel=Name -PAYONEPAYONEINVOICESECUREDescriptionLabel=Description -PAYONEPAYONEINVOICESECUREMinCartAmountLabel=Min Order amount -PAYONEPAYONEINVOICESECUREMaxCartAmountLabel=Max Order amount -PAYONEPAYONEINVOICESECUREAllowedCountriesLabel=allowed Countries -PaydirektTab=Paydirect -PAYONEPAYONEPAYDIREKTActiveLabel=Activ -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 -PAYONEPAYONEPAYOLUTIONINSTALLMENTActivePossibleValue0=No -PAYONEPAYONEPAYOLUTIONINSTALLMENTNameLabel=Name -PAYONEPAYONEPAYOLUTIONINSTALLMENTDescriptionLabel=Description -PAYONEPAYONEPAYOLUTIONINSTALLMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONEPAYOLUTIONINSTALLMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPAYOLUTIONINSTALLMENTAllowedCountriesLabel=allowed Countries -PayPalTab=PayPal -PAYONEPAYONEPAYPALActiveLabel=Activ -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 -PAYONEPAYONERATEPAYINSTALLMENTActivePossibleValue0=No -PAYONEPAYONERATEPAYINSTALLMENTNameLabel=Name -PAYONEPAYONERATEPAYINSTALLMENTDescriptionLabel=Description -PAYONEPAYONERATEPAYINSTALLMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONERATEPAYINSTALLMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONERATEPAYINSTALLMENTAllowedCountriesLabel=allowed Countries -SofortberweisungTab=Sofortüberweisung -PAYONEPAYONESOFORTActiveLabel=Activ -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 -PAYONEPAYONEPREPAYMENTActivePossibleValue0=No -PAYONEPAYONEPREPAYMENTActivePossibleValue1=Yes -PAYONEPAYONEPREPAYMENTNameLabel=Name -PAYONEPAYONEPREPAYMENTDescriptionLabel=Description -PAYONEPAYONEPREPAYMENTMinCartAmountLabel=Min Order amount -PAYONEPAYONEPREPAYMENTMaxCartAmountLabel=Max Order amount -PAYONEPAYONEPREPAYMENTAllowedCountriesLabel=allowed Countries -KreditkarteTab=Creditcard -PAYONEPAYONECREDITCARDActiveLabel=Activ -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 -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesV=Visa -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesM=Mastercard -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesA=Amex -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesO=Maestro (Int) -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesU=Maestro (UK) -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesD=Diners -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesB=Carte Bleue -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesC=Discover -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesJ=JCB -PAYONEPAYONECREDITCARDAllowedCardTypesPossibleValuePAYONEPAYONECREDITCARDAllowedCardTypesP=China Union Pay -NachnahmeTab=Cash on delivery -PAYONEPAYONECASHONDELIVERYActiveLabel=Activ -PAYONEPAYONECASHONDELIVERYActivePossibleValue0=No -PAYONEPAYONECASHONDELIVERYActivePossibleValue1=Yes -PAYONEPAYONECASHONDELIVERYNameLabel=Name -PAYONEPAYONECASHONDELIVERYDescriptionLabel=Description -PAYONEPAYONECASHONDELIVERYMinCartAmountLabel=Min Order amount -PAYONEPAYONECASHONDELIVERYMaxCartAmountLabel=Max Order amount -PAYONEPAYONECASHONDELIVERYAllowedCountriesLabel=allowed Countries -LastschriftTab=Debit -PAYONEPAYONEDIRECTDEBITActiveLabel=Activ -PAYONEPAYONEDIRECTDEBITActivePossibleValue0=No -PAYONEPAYONEDIRECTDEBITActivePossibleValue1=Yes -PAYONEPAYONEDIRECTDEBITNameLabel=Name -PAYONEPAYONEDIRECTDEBITDescriptionLabel=Description -PAYONEPAYONEDIRECTDEBITMinCartAmountLabel=Min Order amount -PAYONEPAYONEDIRECTDEBITMaxCartAmountLabel=Max Order amount -PAYONEPAYONEDIRECTDEBITAllowedCountriesLabel=allowed Countries -DebuggingTab=Debugging -debuggingActiveLabel=Activ -debuggingActivePossibleValue0=No -debuggingActivePossibleValue1=Yes -has = "has" -get = "get" -set = "set" -prepend = "prepend" -push = "push" -getPrefix = "getPrefix" \ No newline at end of file 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/MultilingualismConfig.properties b/resources/lang/en/MultilingualismConfig.properties new file mode 100644 index 00000000..86121c29 --- /dev/null +++ b/resources/lang/en/MultilingualismConfig.properties @@ -0,0 +1,3 @@ +; sections +paymentMethod = "Payment method" +template = "Notes" 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/PaymentMethods.properties b/resources/lang/en/PaymentMethods.properties new file mode 100644 index 00000000..a9013371 --- /dev/null +++ b/resources/lang/en/PaymentMethods.properties @@ -0,0 +1,32 @@ +PAYONE_PAYONE_INVOICE=Invoice +PAYONE_PAYONE_INVOICE_DESCRIPTION= +PAYONE_PAYONE_PAYDIREKT=Paydirekt +PAYONE_PAYONE_PAYDIREKT_DESCRIPTION= +PAYONE_PAYONE_PAYOLUTION_INSTALLMENT=Payolution Installments +PAYONE_PAYONE_PAYOLUTION_INSTALLMENT_DESCRIPTION= +PAYONE_PAYONE_PAY_PAL=PayPal +PAYONE_PAYONE_PAY_PAL_DESCRIPTION= +PAYONE_PAYONE_RATEPAY_INSTALLMENT=RatePay Installments +PAYONE_PAYONE_RATEPAY_INSTALLMENT_DESCRIPTION= +PAYONE_PAYONE_SOFORT=Online bank transfer +PAYONE_PAYONE_SOFORT_DESCRIPTION= +PAYONE_PAYONE_CASH_ON_DELIVERY=Cash on delivery +PAYONE_PAYONE_CASH_ON_DELIVERY_DESCRIPTION= +PAYONE_PAYONE_PRE_PAYMENT=Cash in advance +PAYONE_PAYONE_PRE_PAYMENT_DESCRIPTION= +PAYONE_PAYONE_CREDIT_CARD=Credit card +PAYONE_PAYONE_CREDIT_CARD_DESCRIPTION= +PAYONE_PAYONE_DIRECT_DEBIT=Debit +PAYONE_PAYONE_DIRECT_DEBIT_DESCRIPTION= +PAYONE_PAYONE_INVOICE_SECURE=Payone Secure Invoice +PAYONE_PAYONE_INVOICE_SECURE_DESCRIPTION= +PAYONE_PAYONE_AMAZON_PAY=Amazon Pay +PAYONE_PAYONE_AMAZON_PAY_DESCRIPTION= +PAYONE_PAYONE_KLARNA_DIRECT_BANK=Direct Bank Transfer +PAYONE_PAYONE_KLARNA_DIRECT_BANK_DESCRIPTION= +PAYONE_PAYONE_KLARNA_DIRECT_DEBIT=Direct Debit Pay +PAYONE_PAYONE_KLARNA_DIRECT_DEBIT_DESCRIPTION= +PAYONE_PAYONE_KLARNA_INSTALLMENTS=Klarna Installments +PAYONE_PAYONE_KLARNA_INSTALLMENTS_DESCRIPTION= +PAYONE_PAYONE_KLARNA_INVOICE=Klarna Invoice +PAYONE_PAYONE_KLARNA_INVOICE_DESCRIPTION= diff --git a/resources/lang/en/Template.properties b/resources/lang/en/Template.properties index 5a2aa66d..69de6550 100755 --- a/resources/lang/en/Template.properties +++ b/resources/lang/en/Template.properties @@ -1,17 +1,19 @@ -orderErrorTitle = "Order failed" -orderErrorMessage = "The payment has not been possible. This can be for a variety of reasons, such as incorrect input data, an unknown address, or a temporary technical problem. Please check your input data or choose a different payment method." -orderPlace= "Place Order" +orderErrorTitle = "Order has failed." +orderErrorMessage = "This payment could not be made. This can be for a variety of reasons, such as incorrect input data, an unknown address or a temporary technical problem. Please check your input data or choose a different payment method." +orderPlace= "Place order" orderCancel= "Cancel" continue= "Continue" -ccType = "Card Type" +ccType = "Card type" ccNumber = "Number" -ccValidTo = "Valid To" -firstName = "Firstname" -lastName = "Lastname" +ccValidTo = "Valid until" +firstName = "First name" +lastName = "Last name" -sepaMandateConsent = "I wish to grant the mandate through electronic submission" +sepaMandateConsent = "I wish to grant the electronic SEPA direct direct mandate." 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 SEPA direct direct mandate from the account holder." + +missingDateOfBirth = "Please enter a date of birth." 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('/(? '', + ]; + + /** + * @var RedirectUrls + */ + protected $urls; + + /** + * PayPal constructor. + * + * @param GenericAuthorizationRequest $authorizationRequest + * @param RedirectUrls $urls + * @param string $amount + * @param string $workOrderId + * @param string $reference + * @param string $currency + * @param string $amazonReferenceId + */ + public function __construct( + GenericAuthorizationRequest $authorizationRequest, + RedirectUrls $urls, + string $amount, + string $workOrderId, + string $reference, + string $currency, + string $amazonReferenceId + ) + { + $this->authorizationRequest = $authorizationRequest; + $this->urls = $urls; + + $this->amount = $amount; + $this->workorderid = $workOrderId; + $this->reference = $reference; + $this->currency = $currency; + $this->add_paydata['amazon_reference_id'] = $amazonReferenceId; + } + + /** + * @return string + */ + public function getWallettype(): string + { + return $this->wallettype; + } + + /** + * @return string + */ + public function getWorkorderid(): string + { + return $this->workorderid; + } + + /** + * @return string + */ + public function getReference(): string + { + return $this->reference; + } + + /** + * @return string + */ + public function getCurrency(): string + { + return $this->currency; + } + + /** + * @return string + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @return array + */ + public function getAddPaydata(): array + { + return $this->add_paydata; + } + + /** + * @return RedirectUrls + */ + public function getUrls(): RedirectUrls + { + return $this->urls; + } + +} 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..4cebebba --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/Creditcard.php @@ -0,0 +1,66 @@ +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..ab0ebd33 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/DirectDebit.php @@ -0,0 +1,48 @@ +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..0f999237 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/InvoiceSecure.php @@ -0,0 +1,62 @@ +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..77152943 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/OnlineBankTransfer.php @@ -0,0 +1,82 @@ +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..5afb2eba --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/PayPal.php @@ -0,0 +1,64 @@ +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..d34b4e06 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/Paydirekt.php @@ -0,0 +1,84 @@ +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..f22dd7b5 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/PrePayment.php @@ -0,0 +1,28 @@ +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..ff9f51e8 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Authorization/RequestFactory.php @@ -0,0 +1,142 @@ +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 string + */ + 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..8650aeed --- /dev/null +++ b/resources/lib/PayoneApi/Request/Capture/CaptureModes.php @@ -0,0 +1,13 @@ +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..846b4ba6 --- /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/GenericPayment/AmazonPayConfigurationRequest.php b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayConfigurationRequest.php new file mode 100644 index 00000000..38a3b282 --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayConfigurationRequest.php @@ -0,0 +1,32 @@ + 'getconfiguration' + ], + $config, + $info, + $currency + ); + } +} diff --git a/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayConfirmOrderReferenceRequest.php b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayConfirmOrderReferenceRequest.php new file mode 100644 index 00000000..f46a9c6c --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayConfirmOrderReferenceRequest.php @@ -0,0 +1,103 @@ + 'confirmorderreference', + 'reference' => $reference, + 'amazon_reference_id' => $amazonReferenceId, + ], + $config, + $info, + $currency + ); + + $this->workorderid = $workOrderId; + $this->amount = $amount; + $this->successurl = $successurl; + $this->errorurl = $errorurl; + } + + /** + * @return string + */ + public function getAmount(): string + { + return $this->amount; + } + + /** + * @return string + */ + public function getWorkorderid(): string + { + return $this->workorderid; + } + + /** + * @return string + */ + public function getSuccessurl(): string + { + return $this->successurl; + } + + /** + * @return string + */ + public function getErrorurl(): string + { + return $this->errorurl; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayGetOrderReferenceRequest.php b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayGetOrderReferenceRequest.php new file mode 100644 index 00000000..421837af --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPayGetOrderReferenceRequest.php @@ -0,0 +1,71 @@ + 'getorderreferencedetails', + 'amazon_reference_id' => $amazonReferenceId, + 'amazon_address_token' => $amazonAddressToken, + ], + $config, + $info, + $currency + ); + + $this->workorderid = $workOrderId; + $this->amount = $amount; + } + + /** + * @return mixed + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @return string + */ + public function getWorkorderid(): string + { + return $this->workorderid; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericPayment/AmazonPaySetOrderReferenceRequest.php b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPaySetOrderReferenceRequest.php new file mode 100644 index 00000000..a49c99ca --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/AmazonPaySetOrderReferenceRequest.php @@ -0,0 +1,68 @@ + 'setorderreferencedetails', + 'amazon_reference_id' => $amazonReferenceId, + ], + $config, + $info, + $currency + ); + + $this->workorderid = $workOrderId; + $this->amount = $amount; + } + + /** + * @return string + */ + public function getAmount(): string + { + return $this->amount; + } + + /** + * @return string + */ + public function getWorkorderid(): string + { + return $this->workorderid; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericPayment/GenericAmazonPayRequestBase.php b/resources/lib/PayoneApi/Request/GenericPayment/GenericAmazonPayRequestBase.php new file mode 100644 index 00000000..731182fa --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/GenericAmazonPayRequestBase.php @@ -0,0 +1,124 @@ +addPaydata = $payData; + $this->config = $config; + $this->info = $info; + $this->currency = $currency; + } + + /** + * @return string + */ + public function getWallettype(): string + { + return $this->wallettype; + } + + /** + * @return string + */ + public function getRequest(): string + { + return $this->request; + } + + /** + * @return string + */ + public function getClearingtype(): string + { + return $this->clearingtype; + } + + /** + * @return array + */ + public function getAddPaydata(): array + { + return $this->addPaydata; + } + + /** + * @return string + */ + public function getCurrency(): string + { + return $this->currency; + } + + /** + * @return Config + */ + public function getConfig(): Config + { + return $this->config; + } + + /** + * @return SystemInfo + */ + public function getInfo(): SystemInfo + { + return $this->info; + } +} diff --git a/resources/lib/PayoneApi/Request/GenericPayment/GenericPaymentRequestFactory.php b/resources/lib/PayoneApi/Request/GenericPayment/GenericPaymentRequestFactory.php new file mode 100644 index 00000000..db02d304 --- /dev/null +++ b/resources/lib/PayoneApi/Request/GenericPayment/GenericPaymentRequestFactory.php @@ -0,0 +1,79 @@ +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..def91c76 --- /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 string + */ + public function getMandateIdentification() + { + return $this->mandateIdentification; + } + + /** + * Getter for Currency + * + * @return string + */ + 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 + * @return null + */ + public function getSequencenumber() + { + return null; + } + + /** + * Getter for Amount + * + * @return null + */ + 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..680da890 --- /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 string + */ + public function getBankcountry() + { + return $this->bankcountry; + } + + /** + * Getter for Iban + * + * @return string + */ + public function getIban() + { + return $this->iban; + } + + /** + * Getter for Bic + * + * @return string + */ + public function getBic() + { + return $this->bic; + } + + /** + * Getter for Firstname + * + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * Getter for Lastname + * + * @return string + */ + 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..26bbe969 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/Cart.php @@ -0,0 +1,48 @@ +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; + } +} diff --git a/resources/lib/PayoneApi/Request/Parts/CartFactory.php b/resources/lib/PayoneApi/Request/Parts/CartFactory.php new file mode 100644 index 00000000..b637f365 --- /dev/null +++ b/resources/lib/PayoneApi/Request/Parts/CartFactory.php @@ -0,0 +1,57 @@ + $cartItemData) { + if(isset($cartItemData['itemId'])) { + $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..eed2837e --- /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..f6642388 --- /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..3e9ff04f --- /dev/null +++ b/resources/lib/PayoneApi/Request/Refund/RequestFactory.php @@ -0,0 +1,24 @@ +getConstants(); + } +} diff --git a/resources/lib/PayoneApi/Request/WalletTypes.php b/resources/lib/PayoneApi/Request/WalletTypes.php new file mode 100644 index 00000000..da04b81c --- /dev/null +++ b/resources/lib/PayoneApi/Request/WalletTypes.php @@ -0,0 +1,14 @@ +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..37253456 --- /dev/null +++ b/resources/lib/PayoneApi/Response/ClientErrorResponse.php @@ -0,0 +1,86 @@ +errorMessage = $errorMessage; + $this->requestData = $requestData; + $this->responseData = $responseData; + } + + /** + * @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 ''; + } + + /** + * @return mixed + */ + public function getRequestData() + { + return $this->requestData; + } + + /** + * @return mixed + */ + public function getResponseData() + { + return $this->responseData; + } +} diff --git a/resources/lib/PayoneApi/Response/GenericResponse.php b/resources/lib/PayoneApi/Response/GenericResponse.php new file mode 100644 index 00000000..54a0a8cf --- /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..3fa5978f --- /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 @@ +config[$confEntry->key] = $confEntry; - } - } - - /** - * Getter for Config - * - * @return mixed - */ - public function getConfig() - { - return $this->config; - } - - /** - * Get the specified configuration value. - */ - public function get( - string $key, - $default = null - ) { - $key = str_replace(self::getPrefix() . '.', '', $key); - if (!isset($default) && !$this->has($key)) { - throw new \InvalidArgumentException('No config for ' . $key); - } - - return $this->getValue($key, $default); - } - - /** - * @param string $key - * - * @return bool - */ - public function has( - string $key - ): bool { - return isset($this->config[$key]); - } - - /** - * @param string $key - * @param null $value - */ - public function set( - string $key, - $value = null - ) { - $this->config[$key] = $value; - } - - /** - * @param string $key - * @param $value - */ - public function prepend( - string $key, - $value - ) { - $this->config[$key] = $value; - } - - /** - * @param string $key - * @param $value - */ - public function push( - string $key, - $value - ) { - $this->config[$key] = $value; - } - - /** - * @return string - */ - public static function getPrefix(): string - { - return 'Payone'; - } - - /** - * @param string $key - * @param $default - * - * @return mixed - */ - private function getValue(string $key, $default) - { - $config = $this->config[$key]; - $configValue = null; - if ($config->type == 'text') { - $configValue = $config->default; - } - if ($config->type == 'dropdown') { - $configValue = $config->possibleValues->{(int) $config->default}; - } - - return isset($configValue) ? $configValue : $default; - } -} diff --git a/resources/lib/Tests/Plentymarkets/Models/CreditcardTypesTest.php b/resources/lib/Tests/Plentymarkets/Models/CreditcardTypesTest.php deleted file mode 100644 index f04b7a53..00000000 --- a/resources/lib/Tests/Plentymarkets/Models/CreditcardTypesTest.php +++ /dev/null @@ -1,63 +0,0 @@ -configRepo = self::createMock(Config::class); - $this->configRepo->expects($this->any())->method('get') - ->willReturn(''); - $this->ccTyoes = new CreditcardTypes($this->configRepo); - } - - public function testRetrievingTypesWithNoAllowedTypes() - { - self::assertSame( - [], - $this->ccTyoes->getAllowedTypes() - ); - } - - public function testRetrievingAllowedWithAllAllowedTypes() - { - $this->configRepo = self::createMock(Config::class); - $this->configRepo->expects($this->any()) - ->method('get') - ->willReturn('all'); - $this->ccTyoes = new CreditcardTypes($this->configRepo); - - self::assertSame( - $this->ccTyoes->getCreditCardTypes(), - $this->ccTyoes->getAllowedTypes() - ); - } - - public function testRetrievingAllowedWithTwoAllowedTypes() - { - $this->configRepo = self::createMock(Config::class); - $this->configRepo->expects($this->any()) - ->method('get') - ->willReturn('PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.V, PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.M'); - $this->ccTyoes = new CreditcardTypes($this->configRepo); - - self::assertSame( - ['V', 'M'], - $this->ccTyoes->getAllowedTypes() - ); - } -} diff --git a/resources/lib/addressParser.php b/resources/lib/addressParser.php new file mode 100644 index 00000000..976809be --- /dev/null +++ b/resources/lib/addressParser.php @@ -0,0 +1,17 @@ +splitAddress($address); +$houseNumber = $splitAddress['houseNumberParts']['base']; +if (isset($splitAddress['houseNumberParts']['extension'])) { + $houseNumber .= " " . $splitAddress['houseNumberParts']['extension']; +} +return [ + "address1" => $splitAddress['streetName'] . " " . $splitAddress['additionToAddress1'], + "address2" => $houseNumber, + "address3" => $splitAddress['additionToAddress2'], +]; diff --git a/resources/lib/composer.json b/resources/lib/composer.json new file mode 100644 index 00000000..c19c74d2 --- /dev/null +++ b/resources/lib/composer.json @@ -0,0 +1,7 @@ +{ + "autoload": { + "psr-4": { + "PayoneApi\\": "PayoneApi/" + } + } +} \ No newline at end of file diff --git a/resources/lib/doAuth.php b/resources/lib/doAuth.php index 4055482f..0b8a60d9 100644 --- a/resources/lib/doAuth.php +++ b/resources/lib/doAuth.php @@ -1,11 +1,12 @@ doRequest($request); diff --git a/resources/lib/doCapture.php b/resources/lib/doCapture.php index c3c113ba..44b2868c 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), + $request, + $response + ); + + return $errorResponse->jsonSerialize(); +} + +return $response->jsonSerialize(); diff --git a/resources/lib/doGetDocument.php b/resources/lib/doGetDocument.php new file mode 100644 index 00000000..7a7f70be --- /dev/null +++ b/resources/lib/doGetDocument.php @@ -0,0 +1,48 @@ +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..9f8a8c09 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..bee345f9 --- /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\ComposerStaticInit06768f1d3a106595ac0033464aae4c58::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..38f6f032 --- /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 = ComposerStaticInit06768f1d3a106595ac0033464aae4c58::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit06768f1d3a106595ac0033464aae4c58::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/resources/views/Checkout/AmazonPayAddressBookWidget.twig b/resources/views/Checkout/AmazonPayAddressBookWidget.twig new file mode 100644 index 00000000..e7bdacbb --- /dev/null +++ b/resources/views/Checkout/AmazonPayAddressBookWidget.twig @@ -0,0 +1 @@ + diff --git a/resources/views/Checkout/AmazonPayCheckout.twig b/resources/views/Checkout/AmazonPayCheckout.twig new file mode 100644 index 00000000..90b78279 --- /dev/null +++ b/resources/views/Checkout/AmazonPayCheckout.twig @@ -0,0 +1,121 @@ +{% if services.template.isCurrentTemplate('tpl.checkout') %} + + + {% if sandbox %} + + {% else %} + + {% endif %} + + +{% endif %} diff --git a/resources/views/Checkout/AmazonPayLogin.twig b/resources/views/Checkout/AmazonPayLogin.twig new file mode 100644 index 00000000..541e05fd --- /dev/null +++ b/resources/views/Checkout/AmazonPayLogin.twig @@ -0,0 +1,48 @@ + + diff --git a/resources/views/Checkout/AmazonPayWidgets.twig b/resources/views/Checkout/AmazonPayWidgets.twig new file mode 100644 index 00000000..263644a0 --- /dev/null +++ b/resources/views/Checkout/AmazonPayWidgets.twig @@ -0,0 +1,93 @@ + diff --git a/resources/views/Checkout/Confirmation.twig b/resources/views/Checkout/Confirmation.twig new file mode 100644 index 00000000..8d56f2e7 --- /dev/null +++ b/resources/views/Checkout/Confirmation.twig @@ -0,0 +1,11 @@ + 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/Config.php b/src/Adapter/Config.php deleted file mode 100644 index ce124f36..00000000 --- a/src/Adapter/Config.php +++ /dev/null @@ -1,116 +0,0 @@ -config = $config; - $this->logger = $logger; - } - - /** - * @param string $key - * - * @return bool - */ - public function has( - string $key - ): bool { - $this->logger->setIdentifier(__METHOD__)->debug('Config.has', ['key' => $key]); - - return $this->config->has(PluginConstants::NAME . '.' . $key); - } - - /** - * @param string $key - * @param null $default - * - * @return string - */ - public function get( - string $key, - $default = null - ) { - $value = $this->config->get(PluginConstants::NAME . '.' . $key); - $this->logger->setIdentifier(__METHOD__)->debug( - 'Config.get( ' . $key . ', ' . $default . ' )', - ['key' => $key, 'default' => $default, 'value' => $value] - ); - - return $value; - } - - /** - * @param string $key - * @param null $value - */ - public function set( - string $key, - $value = null - ) { - $this->logger->setIdentifier(__METHOD__)->debug('Config.set', ['key' => $key, 'value' => $value]); - $this->config->set(PluginConstants::NAME . '.' . $key, $value); - } - - /** - * @param string $key - * @param $value - */ - public function prepend( - string $key, - $value - ) { - $this->logger->setIdentifier(__METHOD__)->debug('Config.prepend', ['key' => $key, 'value' => $value]); - $this->config->prepend(PluginConstants::NAME . $key, $value); - } - - /** - * @param string $key - * @param $value - */ - public function push( - string $key, - $value - ) { - $this->logger->setIdentifier(__METHOD__)->debug('Config.push', ['key' => $key, 'value' => $value]); - $this->config->push(PluginConstants::NAME . $key, $value); - } - - /** - * @throws \Exception - * - * @return string - */ - public static function getPrefix(): string - { - $logger = pluginApp(Logger::class); - $logger->setIdentifier(__METHOD__)->debug('Config.getPrefix', []); - throw new \Exception('not implemented'); - return ''; - } -} 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/Assistants/DataSources/AssistantDataSource.php b/src/Assistants/DataSources/AssistantDataSource.php new file mode 100644 index 00000000..c7080bf9 --- /dev/null +++ b/src/Assistants/DataSources/AssistantDataSource.php @@ -0,0 +1,180 @@ +settingsService = $settingsService; + $this->pluginSetRepositoryContract = $pluginSetRepositoryContract; + } + + /** + * @return WizardData WizardData + */ + public function findData(): WizardData + { + /** @var WizardData $wizardData */ + $wizardData = pluginApp(WizardData::class); + $wizardData->data = ['default' => false]; + + return $wizardData; + } + + /** + * @return array + */ + public function getIdentifiers(): array + { + $optionIdentifiers = []; + + $settings = $this->settingsService->getAllAccountSettings(); + + foreach ($settings as $pid => $value) { + $optionIdentifiers[] = $pid; + } + + return $optionIdentifiers; + } + + /** + * @param array $steps + * @return array + */ + public function create(array $steps = []): array + { + return $this->dataStructure; + } + + /** + * @param array $properties + * @return array + */ + public function update(array $properties = []): array + { + return $properties; + } + + public function delete() + { + } + + /** + * @return array + */ + public function get(): array + { + $wizardData = $this->dataStructure; + + //Must be passed otherwise the tiles have no data. + $tileConfig = []; + + $settings = $this->settingsService->getAllAccountSettings(); + + if (is_array($settings)) { + foreach ($settings as $pid => $setting) { + $tileConfig[$pid] = [ + 'clientId' => $pid + ]; + } + } + $wizardData['data'] = $tileConfig; + + return $wizardData; + } + + + /** + * @param string $optionId + * @return array + * @throws \Exception + */ + public function getByOptionId(string $optionId = 'default'): array + { + $data = $this->dataStructure; + $assistant = []; + + if (!is_numeric($optionId)) { + $data['data'] = $assistant; + return $data; + } + + /** @var SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + $accountSettings = $settingsService->getSettings((int)$optionId, (int)$this->pluginSetRepositoryContract->getCurrentPluginSetId()); + $assistant['clientId'] = $optionId; + if(!is_null($accountSettings)) { + $assistant['mid'] = $accountSettings->value['mid'] ?? ""; + $assistant['portalId'] = $accountSettings->value['portalId'] ?? ""; + $assistant['aid'] = $accountSettings->value['aid'] ?? ""; + $assistant['key'] = $accountSettings->value['key'] ?? ""; + $assistant['mode'] = $accountSettings->value['mode'] ?? 1; + $assistant['authType'] = $accountSettings->value['authType'] ?? 1; + $assistant['userId'] = $accountSettings->value['userId'] ?? 0; + + //Payone Payment Methods + if($accountSettings->value['payoneMethods']) { + foreach ($accountSettings->value['payoneMethods'] as $paymentCode => $value) { + $assistant[$paymentCode . 'Toggle'] = (bool)($value['active'] ?? false); + $assistant[$paymentCode . 'MinimumAmount'] = $value['MinimumAmount'] ?? 0; + $assistant[$paymentCode . 'MaximumAmount'] = $value['MaximumAmount'] ?? 2000; + $assistant[$paymentCode . 'AllowedDeliveryCountries'] = is_array($value['AllowedDeliveryCountries']) ? $value['AllowedDeliveryCountries'] : []; + $assistant[$paymentCode . 'AuthType'] = $value['AuthType'] ?? -1; + + switch ($paymentCode) { + case 'PAYONE_PAYONE_INVOICE_SECURE': + $assistant[$paymentCode.'portalId'] = $value['portalId'] ?? ''; + $assistant[$paymentCode.'key'] = $value['key'] ?? ''; + break; + case 'PAYONE_PAYONE_CREDIT_CARD': + $assistant[$paymentCode.'minExpireTime'] = (int)($value['minExpireTime'] ?? 30); + $assistant[$paymentCode.'defaultStyle'] = $value['defaultStyle'] ?? 'font-family: Helvetica; padding: 10.5px 21px; color: #7a7f7f; font-size: 17.5px; height:100%'; + $assistant[$paymentCode.'defaultHeightInPx'] = (int)($value['defaultHeightInPx'] ?? 44); + $assistant[$paymentCode.'defaultWidthInPx'] = (int)($value['defaultWidthInPx'] ?? 644); + $assistant[$paymentCode.'AllowedCardTypes'] = is_array($value['AllowedCardTypes']) ? $value['AllowedCardTypes'] : []; + break; + case 'PAYONE_PAYONE_AMAZON_PAY': + $assistant[$paymentCode.'Sandbox'] = (int)($value['Sandbox'] ?? 0); + break; + } + } + } + } + + $data['data'] = $assistant; + return $data; + } + + /** + * @param string $optionId + * @throws \Exception + */ + public function deleteDataOption(string $optionId): void + { + $this->settingsService->deleteSettings($optionId, $this->pluginSetRepositoryContract->getCurrentPluginSetId()); + } +} \ No newline at end of file diff --git a/src/Assistants/PayoneAssistant.php b/src/Assistants/PayoneAssistant.php new file mode 100644 index 00000000..5f918952 --- /dev/null +++ b/src/Assistants/PayoneAssistant.php @@ -0,0 +1,713 @@ +paymentHelper = $paymentHelper; + } + + /** + * @return array + */ + protected function structure(): array + { + $config = [ + "title" => 'Assistant.assistantTitle', + "shortDescription" => 'Assistant.assistantShortDescription', + "iconPath" => $this->getIcon(), + "settingsHandlerClass" => AssistantSettingsHandler::class, + "dataSource" => AssistantDataSource::class, + "translationNamespace" => "Payone", + "key" => "payment-payone-assistant", + "topics" => ["payment"], + 'priority' => 990, + "options" => [ + "clientId" => [ + "type" => 'select', + 'defaultValue' => $this->getMainWebstore(), + "options" => [ + "name" => 'Assistant.clientId', + 'required' => true, + 'listBoxValues' => $this->getWebstoreValues(), + ], + ], + ], + "steps" => [ + ] + ]; + + $config = $this->createAccountStep($config); + + $config = $this->createProductsPageAndSteps($config); + + return $config; + } + + /** + * @param array $config + * @return array + */ + protected function createAccountStep(array $config): array + { + $backendUsers = $this->getBackendUsers(); + + $config['steps']['payoneAccountStep'] = [ + 'title' => 'Assistant.titlePayoneAccountStep', + 'description' => 'Assistant.descriptionPayoneAccountStep', + 'sections' => [ + [ + 'title' => 'Assistant.titlePayoneAccountStepAccount', + 'description' => 'Assistant.descriptionPayoneAccountStepAccount', + 'form' => [ + 'mid' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.mid', + 'required' => true + ] + ], + 'portalId' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.portalId', + 'required' => true + ] + ], + 'aid' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.aid', + 'required' => true + ] + ], + 'key' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.key', + 'required' => true + ] + ], + 'mode' => [ + 'type' => 'select', + "defaultValue" => 1, + 'options' => [ + 'name' => 'Assistant.mode', + 'listBoxValues' => [ + [ + "caption" => 'Assistant.modeProductiveOption', + "value" => 1 + ], + [ + "caption" => 'Assistant.modeTestingOption', + "value" => 0 + ] + ] + ] + ], + 'authType' => [ + 'type' => 'select', + "defaultValue" => 1, + 'options' => [ + 'name' => 'Assistant.authType', + 'listBoxValues' => [ + [ + "caption" => 'Assistant.authTypeAuthorization', + "value" => 1 + ], + [ + "caption" => 'Assistant.authTypePreAuthorization', + "value" => 0 + ] + ] + ] + ], + "userId" => [ + 'type' => 'select', + 'defaultValue' => $backendUsers[0]['value'], + 'options' => [ + 'name' => 'Assistant.userId', + 'required' => true, + 'listBoxValues' => $backendUsers + ] + ] + ] + ] + ] + ]; + + return $config; + } + + /** + * @param array $config + * @return array + */ + protected function createProductsPageAndSteps(array $config): array + { + $config['steps']['payoneProductsStep'] = [ + 'title' => 'Assistant.titlePayoneProductsStep', + 'description' => 'Assistant.descriptionPayoneProductsStep', + 'showFullDescription' => true, + 'sections' => [] + ]; + + foreach ($this->paymentHelper->getPaymentCodes() as $paymentCode) { + $config['steps']['payoneProductsStep']['sections'][] = [ + 'title' => 'Assistant.titlePayoneProductsStep'.$paymentCode, + 'description' => 'Assistant.descriptionPayoneProductsStep'.$paymentCode, + 'showFullDescription' => true, + 'form' => [ + $paymentCode.'Toggle' => [ + 'type' => 'toggle', + 'defaultValue' => false, + 'options' => [ + 'name' => 'Assistant.title'.$paymentCode.'_Toggle', + 'required' => false + ] + ] + ] + ]; + + if(in_array($paymentCode, [ + PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, + PayoneCCPaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::PAYMENT_CODE + ])) { + // We need some special configurations for this methods. + switch ($paymentCode) { + case PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE: + $config = $this->createSecureInvoiceStep($config, $paymentCode); + break; + case PayoneCCPaymentMethod::PAYMENT_CODE: + $config = $this->createCreditCardStep($config, $paymentCode); + break; + case PayoneAmazonPayPaymentMethod::PAYMENT_CODE: + $config = $this->createAmazonPayStep($config, $paymentCode); + break; + } + } else { + $config['steps']['payone'.$paymentCode.'Step'] = [ + 'title' => 'Assistant.titlePayoneProductsStep'.$paymentCode, + 'description' => 'Assistant.descriptionPayoneProductsStep'.$paymentCode, + 'showFullDescription' => true, + 'condition' => $paymentCode.'Toggle', + 'sections' => [ + [ + 'title' => 'Assistant.titlePayonePaymentSection', + 'description' => 'Assistant.descriptionPayonePaymentSection', + 'form' => + $this->getMinMaxAmountConfig($paymentCode) + + + $this->getDeliveryCountriesConfig($paymentCode) + + + $this->getAuthorizationConfig($paymentCode) + ] + ] + ]; + } + } + + return $config; + } + + /** + * @param array $config + * @param string $paymentCode + * @return array + */ + protected function createSecureInvoiceStep(array $config, string $paymentCode): array + { + $config['steps']['payone'.$paymentCode.'Step'] = [ + 'title' => 'Assistant.titlePayoneProductsStep'.$paymentCode, + 'description' => 'Assistant.descriptionPayoneProductsStep'.$paymentCode, + 'showFullDescription' => true, + 'condition' => $paymentCode.'Toggle', + 'sections' => [ + [ + 'title' => 'Assistant.titlePayonePaymentSection', + 'description' => 'Assistant.descriptionPayonePaymentSectionSecureInvoice', + 'form' => + $this->getMinMaxAmountConfig($paymentCode) + + + $this->getDeliveryCountriesConfig($paymentCode) + + + $this->getAuthorizationConfig($paymentCode) + + [ + $paymentCode.'portalId' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.portalId', + 'required' => true + ] + ], + $paymentCode.'key' => [ + 'type' => 'text', + 'options' => [ + 'name' => 'Assistant.key', + 'required' => true + ] + ] + ] + ] + ] + ]; + + return $config; + } + + /** + * @param array $config + * @param string $paymentCode + * @return array + */ + protected function createCreditCardStep(array $config, string $paymentCode): array + { + $config['steps']['payone'.$paymentCode.'Step'] = [ + 'title' => 'Assistant.titlePayoneProductsStep'.$paymentCode, + 'description' => 'Assistant.descriptionPayoneProductsStep'.$paymentCode, + 'showFullDescription' => true, + 'condition' => $paymentCode.'Toggle', + 'sections' => [ + [ + 'title' => 'Assistant.titlePayonePaymentSection', + 'description' => 'Assistant.descriptionPayonePaymentSection', + 'form' => + $this->getMinMaxAmountConfig($paymentCode) + + + $this->getDeliveryCountriesConfig($paymentCode) + + + $this->getAuthorizationConfig($paymentCode) + + [ + $paymentCode.'minExpireTime' => [ + 'type' => 'text', + 'defaultValue' => 30, + 'options' => [ + 'name' => 'Assistant.minExpireTime', + 'required' => true + ] + ], + $paymentCode.'defaultStyle' => [ + 'type' => 'text', + 'defaultValue' => 'font-family: Helvetica; padding: 10.5px 21px; color: #7a7f7f; font-size: 17.5px; height:100%', + 'options' => [ + 'name' => 'Assistant.defaultStyle', + 'required' => true + ] + ], + $paymentCode.'defaultHeightInPx' => [ + 'type' => 'text', + 'defaultValue' => '44', + 'options' => [ + 'name' => 'Assistant.defaultHeightInPx', + 'required' => true + ] + ], + $paymentCode.'defaultWidthInPx' => [ + 'type' => 'text', + 'defaultValue' => '644', + 'options' => [ + 'name' => 'Assistant.defaultWidthInPx', + 'required' => true + ] + ], + $paymentCode.'AllowedCardTypes' => [ + 'type' => 'checkboxGroup', + 'defaultValue' => ['V', 'M', 'A', 'O', 'U', 'D', 'B', 'C', 'J', 'P'], + 'options' => [ + 'name' => 'Assistant.AllowedCardTypes', + 'required' => true, + 'checkboxValues' => $this->getAllowedCreditCardTypes() + ] + ] + ] + ] + ] + ]; + + return $config; + } + + /** + * @param array $config + * @param string $paymentCode + * @return array + */ + protected function createAmazonPayStep(array $config, string $paymentCode): array + { + $config['steps']['payone'.$paymentCode.'Step'] = [ + 'title' => 'Assistant.titlePayoneProductsStep'.$paymentCode, + 'description' => 'Assistant.descriptionPayoneProductsStep'.$paymentCode, + 'showFullDescription' => true, + 'condition' => $paymentCode.'Toggle', + 'sections' => [ + [ + 'title' => 'Assistant.titlePayonePaymentSection', + 'description' => 'Assistant.descriptionPayonePaymentSectionAmazonPay', + 'form' => + $this->getMinMaxAmountConfig($paymentCode) + + + $this->getDeliveryCountriesConfig($paymentCode) + + + $this->getAuthorizationConfig($paymentCode) + + + [ + $paymentCode.'Sandbox' => [ + 'type' => 'select', + "defaultValue" => 0, + 'options' => [ + 'name' => 'Assistant.Sandbox', + 'listBoxValues' => [ + [ + "caption" => 'Assistant.sandboxProductiveOption', + "value" => 0 + ], + [ + "caption" => 'Assistant.sandboxTestingOption', + "value" => 1 + ] + ] + ] + ] + ] + ] + ] + ]; + + return $config; + } + + + /** + * @param string $paymentCode + * @return array + */ + protected function getMinMaxAmountConfig(string $paymentCode): array + { + return [ + $paymentCode.'MinimumAmount' => [ + 'type' => 'double', + 'defaultValue' => 0, + 'options' => [ + 'isPriceInput' => true, + 'decimalCount' => 2, + 'name' => 'Assistant.MinimumAmount' + ] + ], + $paymentCode.'MaximumAmount' => [ + 'type' => 'double', + 'defaultValue' => 0, + 'options' => [ + 'isPriceInput' => true, + 'decimalCount' => 2, + 'name' => 'Assistant.MaximumAmount' + ] + ] + ]; + } + + /** + * @param string $paymentCode + * @return array + */ + protected function getDeliveryCountriesConfig(string $paymentCode): array + { + $deliveryCountries = $this->getSpecificDeliveryCountries($paymentCode); + return [ + $paymentCode.'AllowedDeliveryCountries' => [ + 'type' => 'checkboxGroup', + 'defaultValue' => $this->getDefaultCountries($deliveryCountries), + 'options' => [ + 'name' => 'Assistant.allowedDeliveryCountries', + 'required' => true, + 'checkboxValues' => array_values($deliveryCountries) + ] + ] + ]; + } + + /** + * @param string $paymentCode + * @return array + */ + protected function getAuthorizationConfig(string $paymentCode): array + { + $listBoxValues = [ + [ + "caption" => 'Assistant.authTypeDefault', + "value" => -1 + ], + [ + "caption" => 'Assistant.authTypeAuthorization', + "value" => 1 + ], + [ + "caption" => 'Assistant.authTypePreAuthorization', + "value" => 0 + ] + ]; + + if($paymentCode == PayoneSofortPaymentMethod::PAYMENT_CODE) { + // Only this auth method available for SOFORT + $listBoxValues = [ + [ + "caption" => 'Assistant.authTypeAuthorization', + "value" => 1 + ] + ]; + } + + return [ + $paymentCode.'AuthType' => [ + 'type' => 'select', + "defaultValue" => -1, + 'options' => [ + 'name' => 'Assistant.authType', + 'listBoxValues' => $listBoxValues + ] + ] + ]; + } + + /** + * @return int + */ + protected function getMainWebstore(): int + { + /** @var WebstoreRepositoryContract $webstoreRepository */ + $webstoreRepository = pluginApp(WebstoreRepositoryContract::class); + $webstore = $webstoreRepository->findById(0); + return $webstore->storeIdentifier; + } + + /** + * @return array + */ + protected function getWebstoreValues(): array + { + /** @var WebstoreRepositoryContract $webstoreRepository */ + $webstoreRepository = pluginApp(WebstoreRepositoryContract::class); + $webstores = $webstoreRepository->loadAll(); + + $values = []; + + /** @var Webstore $webstore */ + foreach ($webstores as $webstore) { + $values[] = [ + 'caption' => $webstore->name, + 'value' => $webstore->storeIdentifier + ]; + } + return $values; + } + + /** + * @return string + */ + protected function getIcon(): string + { + $app = pluginApp(Application::class); + $icon = $app->getUrlPath('Payone').'/images/logos/PAYONE_PAYONE_CREDIT_CARD.png'; + + return $icon; + } + + /** + * @return array + */ + protected function getBackendUsers(): array + { + /** @var UserRepositoryContract $app */ + $userRepo = pluginApp(UserRepositoryContract::class); + + $allBackendUsers = $userRepo->getAll(); + $users = []; + /** @var User $backendUser */ + foreach ($allBackendUsers as $backendUser) { + $users[] = [ + 'caption' => $backendUser->realName, + 'value' => $backendUser->id + ]; + } + + return $users; + } + + /** + * @return array + */ + protected function getSpecificDeliveryCountries($paymentMethod): array + { + $deliveryCountries = []; + switch ($paymentMethod) { + case PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE: + case PayoneSofortPaymentMethod::PAYMENT_CODE: + $allowedCountries = [ + 1, // DE + 2, // AT + 4 // CH + ]; + break; + case PayoneDirectDebitPaymentMethod::PAYMENT_CODE: + $allowedCountries = [ + 1, //'DE', + 2, //'AT', + 3, // 'BE', + 5, //'CY', + 8, //'ES', + 9, //'EE', + 10, //'FR', + 11, //'FI', + 13, //'GR', + 15, //'IT', + 16, //'IE', + 17, //'LU', + 18, //'LV', + 19, //'MT', + 21, //'NL', + 22, //'PT', + 26, //'SK', + 27, //'SI' + 33, //'LT', + 35, //'MC', + 71, //'AD', + 131, //'GI', + 212, //'SM', + ]; + break; + case PayonePaydirektPaymentMethod::PAYMENT_CODE: + $allowedCountries = [ + 1, //DE + ]; + break; + case PayoneCCPaymentMethod::PAYMENT_CODE: + case PayoneCODPaymentMethod::PAYMENT_CODE: + case PayoneInvoicePaymentMethod::PAYMENT_CODE: + case PayonePayolutionInstallmentPaymentMethod::PAYMENT_CODE: + case PayonePayPalPaymentMethod::PAYMENT_CODE: + case PayonePrePaymentPaymentMethod::PAYMENT_CODE: + case PayoneRatePayInstallmentPaymentMethod::PAYMENT_CODE: + case PayoneAmazonPayPaymentMethod::PAYMENT_CODE: + default: + $allowedCountries = []; + break; + } + + /** @var CountryRepositoryContract $countryRepository */ + $countryRepository = pluginApp(CountryRepositoryContract::class); + $systemLanguage = $this->getLanguage(); + $countries = $countryRepository->getCountriesList(null, ['names']); + /** @var Country $country */ + foreach($countries as $country) { + if(count($allowedCountries) <= 0 || array_search($country->id, $allowedCountries) !== false ) { + $name = $country->names->where('lang', $systemLanguage)->first()->name; + $deliveryCountries[$country->id] = [ + 'caption' => $name ?? $country->name, + 'value' => $country->id + ]; + } + } + + return $deliveryCountries; + } + + /** + * Load the active country values + */ + protected function getDefaultCountries($availableCountries = array()) + { + if ($this->activeCountries === null) { + /** @var CountryRepositoryContract $countryRepository */ + $countryRepository = pluginApp(CountryRepositoryContract::class); + $activeCountries = $countryRepository->getActiveCountriesList(); + /** @var Country $country */ + foreach($activeCountries as $country){ + $this->activeCountries[$country->id] = $country->isoCode2; + } + } + + return array_column(array_intersect_key($availableCountries, $this->activeCountries), 'value'); + } + + /** + * @return array + */ + protected function getAllowedCreditCardTypes(): array + { + /** @var CreditcardTypes $creditCardTypes */ + $creditCardTypes = pluginApp(CreditcardTypes::class); + + $allowedCreditCards = []; + $cards = $creditCardTypes->getCreditCardTypes(); + foreach($cards as $card) { + $allowedCreditCards[] = [ + 'caption' => 'Assistant.creditCardType'.$card, + 'value' => $card + ]; + } + + return $allowedCreditCards; + } + + /** + * @return string + */ + protected function getLanguage() + { + if ($this->language === null) { + /** @var SystemInformationRepositoryContract $systemInformationRepository */ + $systemInformationRepository = pluginApp(SystemInformationRepositoryContract::class); + // TODO: this seems not be the log-in language. Where to get it? + $this->language = $systemInformationRepository->loadValue('systemLang'); + } + + return $this->language; + } +} diff --git a/src/Assistants/SettingsHandlers/AssistantSettingsHandler.php b/src/Assistants/SettingsHandlers/AssistantSettingsHandler.php new file mode 100644 index 00000000..3be461fb --- /dev/null +++ b/src/Assistants/SettingsHandlers/AssistantSettingsHandler.php @@ -0,0 +1,80 @@ +getCurrentPluginSetId(); + + $data = $parameter['data']; + + $settings = [ + 'mid' => $data['mid'] ?? '', + 'portalId' => $data['portalId'] ?? '', + 'aid' => $data['aid'] ?? '', + 'key' => $data['key'] ?? '', + 'mode' => $data['mode'] ?? 1, + 'authType' => $data['authType'] ?? 1, + 'userId' => $data['userId'] ?? null + ]; + + $payoneMethods = []; + foreach ($paymentHelper->getPaymentCodes() as $paymentCode) { + $payoneMethods[$paymentCode]['active'] = false; + if(isset($data[$paymentCode . 'Toggle'])) { + $payoneMethods[$paymentCode]['active'] = (int)$data[$paymentCode . 'Toggle']; + + switch ($paymentCode) { + case 'PAYONE_PAYONE_INVOICE_SECURE': + $payoneMethods[$paymentCode]['portalId'] = $data[$paymentCode.'portalId'] ?? ''; + $payoneMethods[$paymentCode]['key'] = $data[$paymentCode.'key'] ?? ''; + break; + case 'PAYONE_PAYONE_CREDIT_CARD': + $payoneMethods[$paymentCode]['minExpireTime'] = (int)($data[$paymentCode.'minExpireTime'] ?? 30); + $payoneMethods[$paymentCode]['defaultStyle'] = $data[$paymentCode.'defaultStyle'] ?? 'font-family: Helvetica; padding: 10.5px 21px; color: #7a7f7f; font-size: 17.5px; height:100%'; + $payoneMethods[$paymentCode]['defaultHeightInPx'] = (int)($data[$paymentCode.'defaultHeightInPx'] ?? 44); + $payoneMethods[$paymentCode]['defaultWidthInPx'] = (int)($data[$paymentCode.'defaultWidthInPx'] ?? 644); + $payoneMethods[$paymentCode]['AllowedCardTypes'] = is_array($data[$paymentCode.'AllowedCardTypes']) ? $data[$paymentCode.'AllowedCardTypes'] : []; + break; + case 'PAYONE_PAYONE_AMAZON_PAY': + $payoneMethods[$paymentCode]['Sandbox'] = (int)($data[$paymentCode.'Sandbox'] ?? 0); + break; + } + + $payoneMethods[$paymentCode]['MinimumAmount'] = (int)($data[$paymentCode.'MinimumAmount'] ?? 0); + $payoneMethods[$paymentCode]['MaximumAmount'] = (int)($data[$paymentCode.'MaximumAmount'] ?? 0); + $payoneMethods[$paymentCode]['AllowedDeliveryCountries'] = is_array($data[$paymentCode.'AllowedDeliveryCountries']) ? $data[$paymentCode.'AllowedDeliveryCountries'] : []; + $payoneMethods[$paymentCode]['AuthType'] = (int)($data[$paymentCode.'AuthType'] ?? -1); + } + } + + $settings['payoneMethods'] = $payoneMethods; + + /** @var SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + $settingsService->updateOrCreateSettings($settings, $clientId, $pluginSetId); + + return true; + } +} \ No newline at end of file diff --git a/src/Controllers/AmazonPayController.php b/src/Controllers/AmazonPayController.php new file mode 100644 index 00000000..0f935f99 --- /dev/null +++ b/src/Controllers/AmazonPayController.php @@ -0,0 +1,331 @@ +api = $api; + $this->dataProvider = $dataProvider; + $this->logger = $logger; + } + + /** + * Renders login button for the frontend. + * + * @param Twig $twig + * @param SessionStorage $sessionStorage + * @param BasketRepositoryContract $basketRepository + * @param PaymentHelper $paymentHelper + * @return string|Response + * @throws \Twig_Error_Loasder + * @throws \Twig_Error_Runtime + * @throws \Twig_Error_Syntax + */ + public function getAmazonPayLoginWidget(Twig $twig, + Response $response, + SessionStorage $sessionStorage, + BasketRepositoryContract $basketRepository, + PaymentHelper $paymentHelper) + { + $basket = $basketRepository->load(); + $selectedPaymentId = $basket->methodOfPaymentId; + $amazonPayMopId = $paymentHelper->getMopId(PayoneAmazonPayPaymentMethod::PAYMENT_CODE); + + $requestParams = $this->dataProvider->getGetConfigRequestData( + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + $basket->currency + ); + + $clientId = $sessionStorage->getSessionValue('clientId'); + $sellerId = $sessionStorage->getSessionValue('sellerId'); + $workOrderId = $sessionStorage->getSessionValue('workOrderId'); + + if(strlen($clientId) <= 0 || strlen($sellerId) <= 0 || strlen($workOrderId) <= 0) { + /** Only load the configuration data if not already stored within the session */ + /** @var GetConfigurationResponse $configResponse */ + $configResponse = $this->api->doGenericPayment(GenericPayment::ACTIONTYPE_GETCONFIGURATION, $requestParams); + + if(!$configResponse->getSuccess()) { + return $response->json([ + 'error' => [ + 'message' => $configResponse->getErrorMessage() + ] + ], 200); + } + + $clientId = $configResponse->getClientId(); + $sellerId = $configResponse->getSellerId(); + $workOrderId = $configResponse->getWorkOrderId(); + + $sessionStorage->setSessionValue('clientId', $clientId); + $sessionStorage->setSessionValue('sellerId', $sellerId); + $sessionStorage->setSessionValue('workOrderId', $workOrderId); + } + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.configLoginButton', [ + 'configResponse' => $configResponse + ]); + + /** @var LocalizationRepositoryContract $localizationRepositoryContract */ + $localizationRepositoryContract = pluginApp(LocalizationRepositoryContract::class); + $lang = $this->getLanguageCode($localizationRepositoryContract->getLanguage()); + + $content = [ + 'clientId' => $clientId, + 'sellerId' => $sellerId, + 'type' => "LwA", + 'color' => "Gold", + 'size' => "medium", + 'language' => $lang, + 'scopes' => "profile payments:widget payments:shipping_address payments:billing_address", + 'popup' => "true", + 'workOrderId' => $workOrderId + ]; + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.renderLoginWidget', [ + "content" => (array)$content + ]); + + return $twig->render(PluginConstants::NAME . '::Checkout.AmazonPayLogin', [ + 'selectedPaymentId' => $selectedPaymentId, + 'amazonPayMopId' => $amazonPayMopId, + 'content' => $content + ]); + } + + /** + * Renders the address book and wallet widget for the frontend. + * + * @param Twig $twig + * @param PaymentHelper $paymentHelper + * @param BasketRepositoryContract $basketRepository + * @param Request $request + * @param SessionStorage $sessionStorage + * @return string + * @throws \Twig_Error_Loader + * @throws \Twig_Error_Runtime + * @throws \Twig_Error_Syntax + */ + public function renderWidgets(Twig $twig, + PaymentHelper $paymentHelper, + BasketRepositoryContract $basketRepository, + Request $request, + SessionStorage $sessionStorage): string + { + $basket = $basketRepository->load(); + + // AccessToken in Request + $accessToken = $request->get('accessToken'); + $workdOrderId = $request->get('workOrderId'); + + $clientId = $sessionStorage->getSessionValue('clientId'); + $sellerId = $sessionStorage->getSessionValue('sellerId'); + + $sessionStorage->setSessionValue('accessToken', $accessToken); + $sessionStorage->setSessionValue('workOrderId', $workdOrderId); + + // SWAP containers here + $content = [ + 'clientId' => $clientId, + 'sellerId' => $sellerId, + 'addressBookScope' => "profile payments:widget payments:shipping_address payments:billing_address", + 'walletScope' => "profile payments:widget payments:shipping_address payments:billing_address", + 'currency' => $basket->currency + ]; + $amazonPayMopId = $paymentHelper->getMopId(PayoneAmazonPayPaymentMethod::PAYMENT_CODE); + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.renderWidgets', [ + "content" => (array)$content + ]); + + return $twig->render(PluginConstants::NAME . '::Checkout.AmazonPayWidgets', [ + 'content' => $content, + 'accessToken' => $accessToken, + 'workOrderId' => $workdOrderId, + 'amazonPayMopId' => $amazonPayMopId + ]); + } + + /** + * Loads the contact data via the selected address in the widget, + * maps it to our address structure and sets it in the checkout. + * + * @param Request $request + * @param Response $response + * @param BasketRepositoryContract $basketRepositoryContract + * @param Checkout $checkout + * @param SessionStorage $sessionStorage + * @return \Symfony\Component\HttpFoundation\Response + */ + public function getOrderReference(Request $request, + Response $response, + BasketRepositoryContract $basketRepositoryContract, + Checkout $checkout, + SessionStorage $sessionStorage): \Symfony\Component\HttpFoundation\Response + { + try { + $amazonReferenceId = $request->get('amazonReferenceId'); + $sessionStorage->setSessionValue('amazonReferenceId', $amazonReferenceId); + + $workOrderId = $sessionStorage->getSessionValue('workOrderId'); + $accessToken = $sessionStorage->getSessionValue('accessToken'); + + $basket = $basketRepositoryContract->load(); + + /** @var GenericPaymentDataProvider $genericPaymentDataProvider */ + $genericPaymentDataProvider = pluginApp(GenericPaymentDataProvider::class); + $requestParams = $genericPaymentDataProvider->getGetOrderReferenceDetailsRequestData( + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + $workOrderId, + $accessToken, + $amazonReferenceId, + $basket->currency, + $basket->basketAmount + ); + + /** @var GetOrderReferenceDetailsResponse $orderReferenceResponse */ + $orderReferenceResponse = $this->api->doGenericPayment(GenericPayment::ACTIONTYPE_GETORDERREFERENCEDETAILS, $requestParams); + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.getOrderReference', [ + "workOrderId" => $workOrderId, + "amazonReferenceId" => $amazonReferenceId, + "accessToken" => $accessToken, + "requestParams" => $requestParams, + "orderReferenceResponse" => (array)$orderReferenceResponse + ]); + + if(!$orderReferenceResponse->getSuccess()) { + return $response->json([ + 'error' => [ + 'message' => $orderReferenceResponse->getErrorMessage() + ] + ], 200); + } + + /** @var AmazonPayService $amazonPayService */ + $amazonPayService = pluginApp(AmazonPayService::class); + $shippingAddress = $amazonPayService->registerCustomerFromAmazonPay($orderReferenceResponse); + $billingAddress = $amazonPayService->registerCustomerFromAmazonPay($orderReferenceResponse, true); + + $checkout->setCustomerShippingAddressId($shippingAddress->id); + $checkout->setCustomerInvoiceAddressId($billingAddress->id); + + /** @var BasketService $basketService */ + $basketService = pluginApp(BasketService::class); + + /** @var ContactRepositoryContract $contactRepository */ + $contactRepository = pluginApp(ContactRepositoryContract::class); + + /** @var CheckoutService $checkoutService */ + $checkoutService = pluginApp(CheckoutService::class); + + $responseData['events']['AfterBasketChanged']['basket'] = $basketService->getBasketForTemplate(); + $responseData['events']['AfterBasketChanged']['showNetPrices'] = $contactRepository->showNetPrices(); + $responseData['events']['AfterBasketChanged']['basketItems'] = $basketService->getBasketItemsForTemplate( + '', + false + ); + $responseData['events']['CheckoutChanged']['checkout'] = $checkoutService->getCheckout(); + + $responseData['events']['CheckoutChanged']['AmazonPayAddress']['changed'] = true; + $responseData['events']['CheckoutChanged']['AmazonPayAddress']['shippingAddress'] = $shippingAddress; + $responseData['events']['CheckoutChanged']['AmazonPayAddress']['billingAddress'] = $billingAddress; + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.getOrderReference', [ + "shippingAddress" => (array)$shippingAddress, + "billingAddress" => (array)$billingAddress, + "checkout" => (array)$checkout, + "checkoutViaService" => (array)$checkoutService->getCheckout() + ]); + + return $response->json($responseData, 200); + } catch (\Exception $exception) { + $this->logger + ->setIdentifier(__METHOD__) + ->error('AmazonPay.getOrderReference', $exception); + } + } + + /** + * Maps our language key into the specified language key from Amazon + * + * @param string $lang + * @return string + */ + private function getLanguageCode(string $lang): string + { + switch ($lang) { + case 'de': + $lang = 'de-DE'; + break; + case 'en': + $lang = 'en-GB'; + break; + case 'es': + $lang = 'es-ES'; + break; + case 'fr': + $lang = 'fr-FR'; + break; + case 'it': + $lang = 'it-IT'; + break; + default: + $lang = "en-GB"; + } + return $lang; + } +} diff --git a/src/Controllers/CheckoutController.php b/src/Controllers/CheckoutController.php index a2ce968b..494f483b 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..9011aaf7 100644 --- a/src/Controllers/StatusController.php +++ b/src/Controllers/StatusController.php @@ -2,64 +2,71 @@ namespace Payone\Controllers; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Adapter\Logger; -use Payone\Migrations\CreatePaymentMethods; +use Payone\Methods\PayoneInvoiceSecurePaymentMethod; use Payone\Services\PaymentCreation; +use Payone\Services\PaymentDocuments; +use Payone\Services\SettingsService; use Plenty\Plugin\Controller; use Plenty\Plugin\Http\Request; /** - * Class ConfigController + * Class StatusController */ class StatusController extends Controller { /** * @var Request */ - private $request; + protected $request; /** - * @var ConfigAdapter + * @var SettingsService */ - private $config; + protected $settingsService; /** * @var PaymentCreation */ - private $paymentCreation; + protected $paymentCreation; + /** - * @var CreatePaymentMethods + * @var PaymentDocuments */ - private $paymentMigration; + protected $paymentDocument; + /** * @var Logger */ - private $logger; + protected $logger; /** * StatusController constructor. * * @param Request $request - * @param ConfigAdapter $config + * @param SettingsService $settingsService * @param PaymentCreation $paymentCreation - * @param CreatePaymentMethods $paymentMigration + * @param PaymentDocuments $paymentDocument * @param Logger $logger */ public function __construct( Request $request, - ConfigAdapter $config, + SettingsService $settingsService, PaymentCreation $paymentCreation, - CreatePaymentMethods $paymentMigration, + PaymentDocuments $paymentDocument, Logger $logger ) { $this->request = $request; - $this->config = $config; + $this->settingsService = $settingsService; $this->paymentCreation = $paymentCreation; - $this->paymentMigration = $paymentMigration; + $this->paymentDocument = $paymentDocument; $this->logger = $logger; } + /** + * @return string + * @throws \Exception + */ public function index() { $txid = $this->request->get('txid'); @@ -71,15 +78,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'))) { - return; + if ($this->request->get('key') != md5($this->settingsService->getPaymentSettingsValue('key', PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE)) && + $this->request->get('key') != md5($this->settingsService->getSettingsValue('key'))) { + return 'ERROR'; } - $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..a0ec10d1 100644 --- a/src/Helpers/OrderHelper.php +++ b/src/Helpers/OrderHelper.php @@ -2,18 +2,23 @@ namespace Payone\Helpers; +use Payone\Services\SettingsService; +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\Log\Loggable; class OrderHelper { + use Loggable; + /** * @param Order $order - * * @return string */ - public function getLang(Order $order) + public function getLang(Order $order): string { /** @var OrderProperty $property */ foreach ($order->properties as $property) { @@ -24,4 +29,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 SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + $backendUserId = $settingsService->getSettingsValue('userId'); + + 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..f2a5dced 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; @@ -21,6 +22,10 @@ use Plenty\Modules\Payment\Method\Models\PaymentMethod; use Plenty\Modules\Payment\Models\Payment; use Plenty\Modules\Payment\Models\PaymentProperty; +use Payone\Methods\PayoneKlarnaInvoicePaymentMethod; +use Payone\Methods\PayoneKlarnaInstallmentsPaymentMethod; +use Payone\Methods\PayoneKlarnaDirectDebitPaymentMethod; +use Payone\Methods\PayoneKlarnaDirectBankTransferPaymentMethod; /** * Class PaymentHelper @@ -119,17 +124,22 @@ public function getPaymentCodeByMop($mopId) public function getPaymentCodes() { return [ + PayonePayPalPaymentMethod::PAYMENT_CODE, + PayoneCCPaymentMethod::PAYMENT_CODE, PayoneInvoicePaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, + PayoneDirectDebitPaymentMethod::PAYMENT_CODE, + PayonePrePaymentPaymentMethod::PAYMENT_CODE, + PayoneSofortPaymentMethod::PAYMENT_CODE, PayonePaydirektPaymentMethod::PAYMENT_CODE, - PayonePayolutionInstallmentPaymentMethod::PAYMENT_CODE, - PayonePayPalPaymentMethod::PAYMENT_CODE, PayoneRatePayInstallmentPaymentMethod::PAYMENT_CODE, - PayoneSofortPaymentMethod::PAYMENT_CODE, + PayonePayolutionInstallmentPaymentMethod::PAYMENT_CODE, PayoneCODPaymentMethod::PAYMENT_CODE, - PayonePrePaymentPaymentMethod::PAYMENT_CODE, - PayoneCCPaymentMethod::PAYMENT_CODE, - PayoneDirectDebitPaymentMethod::PAYMENT_CODE, - PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, + PayoneKlarnaDirectBankTransferPaymentMethod::PAYMENT_CODE, + PayoneKlarnaDirectDebitPaymentMethod::PAYMENT_CODE, + PayoneKlarnaInstallmentsPaymentMethod::PAYMENT_CODE, + PayoneKlarnaInvoicePaymentMethod::PAYMENT_CODE ]; } @@ -156,10 +166,9 @@ public function isPayonePayment($mopId) /** * @param Payment $payment * @param int $propertyTypeConstant - * * @return string */ - public function getPaymentPropertyValue($payment, $propertyTypeConstant) + public function getPaymentPropertyValue(Payment $payment, $propertyTypeConstant): string { $properties = $payment->properties; if (!$properties) { @@ -177,4 +186,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..ec7e1271 100644 --- a/src/Helpers/ShopHelper.php +++ b/src/Helpers/ShopHelper.php @@ -1,14 +1,12 @@ getCurrentWebstoreConfiguration(); return $webstoreConfig->domainSsl; @@ -62,38 +62,25 @@ public function getPlentyDomain() /** * @return string */ - public function getCurrentLanguage() + public function getCurrentLanguage(): string { $config = $this->localeSettings->toArray(); - return $config['language'] ?? $this->getDefaultLanguage(); } /** * @return string */ - public function getCurrentCurrency() + public function getCurrentCurrency(): string { $config = $this->localeSettings->toArray(); - 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 */ - public function getIpAddress() + public function getIpAddress(): string { $ipKeys = [ 'HTTP_CLIENT_IP', @@ -122,7 +109,7 @@ public function getIpAddress() /** * @return string */ - public function getCurrentLocale() + public function getCurrentLocale(): string { return strtolower($this->getCurrentLanguage()) . '-' . strtoupper($this->getCurrentLanguage()); } @@ -131,11 +118,10 @@ public function getCurrentLocale() * Ensures an ip address is both a valid IP and does not fall within * a private network range. * - * @param $ip - * + * @param string $ip * @return bool */ - private function isIpValid($ip) + protected function isIpValid(string $ip): bool { if ( filter_var( @@ -152,20 +138,18 @@ private function isIpValid($ip) /** * @return string */ - private function getDefaultLanguage(): string + protected function getDefaultLanguage(): string { $config = $this->webstoreHelper->getCurrentWebstoreConfiguration()->toArray(); - return $config['defaultLanguage'] ?? self::DEFAULT_LANGUAGE; } /** * @return string */ - private function getDefaultCurrency(): string + protected function getDefaultCurrency(): string { $config = $this->webstoreHelper->getCurrentWebstoreConfiguration()->toArray(); - return $config['defaultCurrency'] ?? self::DEFAULT_CURRENCY; } } diff --git a/src/Hooks/CopyPluginSetHook.php b/src/Hooks/CopyPluginSetHook.php new file mode 100644 index 00000000..e56ce8e7 --- /dev/null +++ b/src/Hooks/CopyPluginSetHook.php @@ -0,0 +1,29 @@ +getAllSettingsForPluginSetId($copyPluginSet->getSourcePluginSetId()); + + if(is_array($availableSettings)) { + foreach ($availableSettings as $setting) { + if($setting instanceof Settings) { + $setting->id = null; + $setting->pluginSetId = $copyPluginSet->getTargetPluginSetId(); + $setting->save(); + } + } + } + } +} diff --git a/src/Methods/PaymentAbstract.php b/src/Methods/PaymentAbstract.php index c5bef321..2243c813 100644 --- a/src/Methods/PaymentAbstract.php +++ b/src/Methods/PaymentAbstract.php @@ -2,19 +2,21 @@ namespace Payone\Methods; -use Payone\Adapter\Config as ConfigAdapter; use Payone\PluginConstants; -use Plenty\Modules\Payment\Method\Contracts\PaymentMethodService; +use Payone\Services\SettingsService; +use Plenty\Modules\Payment\Method\Services\PaymentMethodBaseService; use Plenty\Plugin\Application; +use Plenty\Plugin\Translation\Translator; -abstract class PaymentAbstract extends PaymentMethodService +abstract class PaymentAbstract extends PaymentMethodBaseService { const PAYMENT_CODE = 'Payone'; /** - * @var ConfigAdapter + * @var SettingsService */ - private $configRepo; + protected $settingsService; + /** * @var PaymentValidator */ @@ -30,37 +32,39 @@ abstract class PaymentAbstract extends PaymentMethodService * * @param Application $application * @param PaymentValidator $paymentValidator - * @param ConfigAdapter $configRepo + * @param SettingsService $settingsService */ public function __construct( Application $application, PaymentValidator $paymentValidator, - ConfigAdapter $configRepo - ) { + SettingsService $settingsService + ) + { $this->paymentValidator = $paymentValidator; - $this->configRepo = $configRepo; $this->app = $app = $application; + $this->settingsService = $settingsService; } /** * @return bool */ - public function isActive() + public function isActive(): bool { - return (bool) $this->configRepo->get($this::PAYMENT_CODE . '.active') - && $this->paymentValidator->validate($this); + return (bool)$this->settingsService->getPaymentSettingsValue('active', $this::PAYMENT_CODE) + && $this->paymentValidator->validate($this, $this->settingsService); } /** * 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'); - - return $name ? (string) $name : ''; + /** @var Translator $translator */ + $translator = pluginApp(Translator::class); + return $translator->trans('Payone::PaymentMethods.' . $this::PAYMENT_CODE, [], $lang); } /** @@ -72,9 +76,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,19 +87,20 @@ 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'); - - return $description ? $description : ''; + /** @var Translator $translator */ + $translator = pluginApp(Translator::class); + return $translator->trans('Payone::PaymentMethods.' . $this::PAYMENT_CODE . '_DESCRIPTION', [], $lang); } /** * @return string */ - public function getCode() + public function getCode(): string { return $this::PAYMENT_CODE; } @@ -102,33 +108,130 @@ public function getCode() /** * @return float */ - public function getMaxCartAmount() + public function getMaxCartAmount(): float { - $amount = $this->configRepo->get($this::PAYMENT_CODE . '.maxCartAmount'); + $amount = $this->settingsService->getPaymentSettingsValue('MaximumAmount', $this::PAYMENT_CODE); - return $amount ? (float) $amount : 0.; + return $amount ? (float)$amount : 0.; } /** * @return float */ - public function getMinCartAmount() + public function getMinCartAmount(): float { - $amount = $this->configRepo->get($this::PAYMENT_CODE . '.minCartAmount'); + $amount = $this->settingsService->getPaymentSettingsValue('MinimumAmount', $this::PAYMENT_CODE); - return $amount ? (float) $amount : 0.; + return $amount ? (float)$amount : 0.; } /** * @return array */ - public function getAllowedCountries() + public function getAllowedCountries(): array + { + return (array)$this->settingsService->getPaymentSettingsValue('AllowedDeliveryCountries', $this::PAYMENT_CODE); + } + + /** + * 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 { - $countries = explode( - ',', - $this->configRepo->get($this::PAYMENT_CODE . '.allowedCountries') - ); + 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 SettingsService $settingsService + * @return bool + */ + public function validateSettings(SettingsService $settingsService): bool + { + return true; + } + + /** + * Is the payment method active for the given currency? + * + * @param $currency + * @return bool + */ + public function isActiveForCurrency($currency): bool + { + return true; + } + + /** + * @param int|null $orderId + * @return bool + */ + public function isSwitchableTo($orderId = null): bool + { + if($orderId > 0) { + /** @var PaymentOrderValidator $paymentOrderValidator */ + $paymentOrderValidator = pluginApp(PaymentOrderValidator::class); + + return (bool)$this->settingsService->getPaymentSettingsValue('active', $this::PAYMENT_CODE) + && $paymentOrderValidator->validate($this, $this->settingsService, $orderId); + } - return $countries; + return false; } } diff --git a/src/Methods/PaymentMethodServiceFactory.php b/src/Methods/PaymentMethodServiceFactory.php index 0b3d49f9..583b3c9e 100644 --- a/src/Methods/PaymentMethodServiceFactory.php +++ b/src/Methods/PaymentMethodServiceFactory.php @@ -37,6 +37,16 @@ public static function create($paymentCode) return pluginApp(PayoneDirectDebitPaymentMethod::class); case PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE; return pluginApp(PayoneInvoiceSecurePaymentMethod::class); + case PayoneAmazonPayPaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneAmazonPayPaymentMethod::class); + case PayoneKlarnaDirectBankTransferPaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneKlarnaDirectBankTransferPaymentMethod::class); + case PayoneKlarnaDirectDebitPaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneKlarnaDirectDebitPaymentMethod::class); + case PayoneKlarnaInvoicePaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneKlarnaInvoicePaymentMethod::class); + case PayoneKlarnaInstallmentsPaymentMethod::PAYMENT_CODE; + return pluginApp(PayoneKlarnaInstallmentsPaymentMethod::class); } throw new \InvalidArgumentException('Unknown payment method ' . $paymentCode); } diff --git a/src/Methods/PaymentOrderValidator.php b/src/Methods/PaymentOrderValidator.php new file mode 100644 index 00000000..21c04b8c --- /dev/null +++ b/src/Methods/PaymentOrderValidator.php @@ -0,0 +1,108 @@ +addressHelper = $addressHelper; + $this->logger = $logger; + } + + /** + * @param PaymentAbstract $payment + * + * @return bool + */ + public function validate(PaymentAbstract $payment, SettingsService $settingsService, int $orderId) + { + /** @var OrderRepositoryContract $orderRepositoryContract */ + $orderRepositoryContract = pluginApp(OrderRepositoryContract::class); + /** @var AuthHelper $authHelper */ + $authHelper = pluginApp(AuthHelper::class); + /** @var Order $order */ + $order = $authHelper->processUnguarded( + function () use ($orderRepositoryContract, $orderId) { + return $orderRepositoryContract->findById($orderId, ['amounts', 'addresses']); + } + ); + + $orderAmount = $order->amount->invoiceTotal; + if ($payment->getMinCartAmount() && $orderAmount < $payment->getMinCartAmount()) { + $this->log($payment->getName(), 'Payment.minCartAmount', $orderAmount); + return false; + } + + if ($payment->getMaxCartAmount() && $orderAmount > $payment->getMaxCartAmount()) { + $this->log($payment->getName(), 'Payment.maxCartAmount', $orderAmount); + return false; + } + + $billingAddress = $order->billingAddress; + $deliveryAddress = $order->deliveryAddress; + if (!$billingAddress) { + // TODO: shouldn't this be 'return false'? + return true; + } + + if (!in_array($billingAddress->countryId, $payment->getAllowedCountries())) { + $this->log($payment->getName(), 'Payment.countryNotAllowed', $billingAddress->countryId); + return false; + } + + if (!$payment->canHandleDifferingDeliveryAddress() && $deliveryAddress && $billingAddress->id != $deliveryAddress->id) { + return false; + } + + if (!$payment->validateSettings($settingsService)) { + return false; + } + + if (!$payment->isActiveForCurrency($order->amount->currency)) { + return false; + } + + return true; + } + + /** + * @param string $payment + * @param string $code + * @param string $value + */ + protected function log($payment, $code, $value) + { + $logger = $this->logger->setIdentifier(__METHOD__); + $logger->debug( + $code, + [ + 'payment' => $payment, + 'value' => $value, + ] + ); + } +} diff --git a/src/Methods/PaymentValidator.php b/src/Methods/PaymentValidator.php index 3065a59c..127fd1e6 100644 --- a/src/Methods/PaymentValidator.php +++ b/src/Methods/PaymentValidator.php @@ -4,6 +4,7 @@ use Payone\Adapter\Logger; use Payone\Helpers\AddressHelper; +use Payone\Services\SettingsService; use Plenty\Modules\Basket\Contracts\BasketRepositoryContract; use Plenty\Modules\Basket\Models\Basket; @@ -42,7 +43,7 @@ public function __construct(BasketRepositoryContract $basket, AddressHelper $add * * @return bool */ - public function validate(PaymentAbstract $payment) + public function validate(PaymentAbstract $payment, SettingsService $settingsService) { $basketAmount = $this->basket->basketAmount; if ($payment->getMinCartAmount() && $basketAmount < $payment->getMinCartAmount()) { @@ -58,17 +59,29 @@ 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; } - $country = $billingAddress->country->isoCode2; - if (!in_array($country, $payment->getAllowedCountries())) { - $this->log($payment->getName(), 'Payment.countryNotAllowed', $country); + if (!in_array($billingAddress->countryId, $payment->getAllowedCountries())) { + $this->log($payment->getName(), 'Payment.countryNotAllowed', $billingAddress->countryId); return false; } + + if (!$payment->canHandleDifferingDeliveryAddress() && $deliveryAddress && $billingAddress->id != $deliveryAddress->id) { + return false; + } + + if (!$payment->validateSettings($settingsService)) { + 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..89e29eb6 --- /dev/null +++ b/src/Methods/PayoneAmazonPayPaymentMethod.php @@ -0,0 +1,11 @@ +getPaymentSettingsValue('portalId', self::PAYMENT_CODE); + $key = $settingsService->getPaymentSettingsValue('key', self::PAYMENT_CODE); + + // 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/Methods/PayoneKlarnaDirectBankTransferPaymentMethod.php b/src/Methods/PayoneKlarnaDirectBankTransferPaymentMethod.php new file mode 100644 index 00000000..02c49bfe --- /dev/null +++ b/src/Methods/PayoneKlarnaDirectBankTransferPaymentMethod.php @@ -0,0 +1,9 @@ +paymentMethodRepo = $paymentMethodRepo; - $this->paymentHelper = $paymentHelper; - $this->logger = $logger; - } - - /** - * Run on plugin build - * - * Create Payone payment methods - */ - public function run() - { - foreach ($this->paymentHelper->getPaymentCodes() as $paymentCode) { - if ($this->paymentHelper->getMopId($paymentCode) != 'no_paymentmethod_found') { - $this->logger->debug(' Skipping payment method creation of ' . $paymentCode); - continue; - } - $this->logger->debug(' Creating payment method ' . $paymentCode); - $this->paymentMethodRepo->createPaymentMethod( - [ - 'pluginKey' => PluginConstants::NAME, - 'paymentKey' => $paymentCode, - 'name' => $paymentCode, - ] - ); - } - } -} diff --git a/src/Migrations/CreatePaymentMethods3.php b/src/Migrations/CreatePaymentMethods3.php new file mode 100644 index 00000000..26ab75c2 --- /dev/null +++ b/src/Migrations/CreatePaymentMethods3.php @@ -0,0 +1,55 @@ +paymentMethodRepo = $paymentMethodRepo; + $this->paymentHelper = $paymentHelper; + } + + public function run() + { + foreach ($this->paymentHelper->getPaymentCodes() as $paymentCode) { + // Check whether the ID of the PayPal payment method has been created + if ($this->paymentHelper->getMopId($paymentCode) == 'no_paymentmethod_found') { + $this->paymentMethodRepo->createPaymentMethod( + [ + 'pluginKey' => PluginConstants::NAME, + 'paymentKey' => $paymentCode, + 'name' => $paymentCode, + ] + ); + } + } + } +} diff --git a/src/Migrations/CreateSettingsTable.php b/src/Migrations/CreateSettingsTable.php new file mode 100644 index 00000000..ea281f0a --- /dev/null +++ b/src/Migrations/CreateSettingsTable.php @@ -0,0 +1,35 @@ +migrate = $migrate; + } + + /** + * + */ + public function run() + { + $this->migrate->createTable(Settings::class); + } +} \ No newline at end of file diff --git a/src/Models/Api/GenericPayment/ConfirmOrderReferenceResponse.php b/src/Models/Api/GenericPayment/ConfirmOrderReferenceResponse.php new file mode 100644 index 00000000..5f1ed71f --- /dev/null +++ b/src/Models/Api/GenericPayment/ConfirmOrderReferenceResponse.php @@ -0,0 +1,56 @@ +success = $success; + $this->errorMessage = $errorMessage; + $this->workOrderId = $workorderId; + return $this; + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + return parent::jsonSerialize() + + [ + 'workOrderId' => $this->workOrderId, + ]; + } + + /** + * @return string + */ + public function getWorkOrderId(): string + { + return $this->workOrderId; + } + + /** + * @return bool + */ + public function isSuccess(): bool + { + return $this->getSuccess(); + } +} diff --git a/src/Models/Api/GenericPayment/GenericPaymentResponseFactory.php b/src/Models/Api/GenericPayment/GenericPaymentResponseFactory.php new file mode 100644 index 00000000..5548fb22 --- /dev/null +++ b/src/Models/Api/GenericPayment/GenericPaymentResponseFactory.php @@ -0,0 +1,170 @@ +init( + false, + $customerErrorMessage + ); + } + + return $response->init( + $responseData['success'] ?? false, + $responseData['errormessage'] ?? '', + $responseData['responseData']['add_paydata[client_id]'] ?? '', + $responseData['responseData']['add_paydata[seller_id]'] ?? '', + $responseData['responseData']['currency'] ?? '', + $responseData['responseData']['workorderid'] ?? '' + ); + } + + /** + * @param array $responseData + * @return GetOrderReferenceDetailsResponse + */ + private static function makeGetOrderReferenceDetailsResponse(array $responseData): GetOrderReferenceDetailsResponse + { + /** @var GetOrderReferenceDetailsResponse $response */ + $response = pluginApp(GetOrderReferenceDetailsResponse::class); + + if(!$responseData['success']) { + $customerErrorMessage = ''; + if($responseData['responseData'] && $responseData['responseData']['responseData'] && $responseData['responseData']['responseData']['customermessage']) { + $customerErrorMessage = $responseData['responseData']['responseData']['customermessage']; + } + return $response->init( + false, + $customerErrorMessage + ); + } + + return $response->init( + $responseData['success'] ?? false, + $responseData['errormessage'] ?? '', + $responseData['responseData']['add_paydata[email]'] ?? '', + $responseData['responseData']['add_paydata[shipping_zip]'] ?? '', + $responseData['responseData']['add_paydata[shipping_street]'] ?? '', + $responseData['responseData']['add_paydata[shipping_company]'] ?? '', + $responseData['responseData']['add_paydata[shipping_city]'] ?? '', + $responseData['responseData']['add_paydata[shipping_type]'] ?? '', + $responseData['responseData']['add_paydata[shipping_country]'] ?? '', + $responseData['responseData']['add_paydata[shipping_district]'] ?? '', + $responseData['responseData']['add_paydata[shipping_telephonenumber]'] ?? '', + $responseData['responseData']['add_paydata[shipping_state]'] ?? '', + $responseData['responseData']['add_paydata[shipping_firstname]'] ?? '', + $responseData['responseData']['add_paydata[shipping_lastname]'] ?? '', + $responseData['responseData']['add_paydata[billing_zip]'] ?? '', + $responseData['responseData']['add_paydata[billing_street]'] ?? '', + $responseData['responseData']['add_paydata[billing_company]'] ?? '', + $responseData['responseData']['add_paydata[billing_city]'] ?? '', + $responseData['responseData']['add_paydata[billing_type]'] ?? '', + $responseData['responseData']['add_paydata[billing_country]'] ?? '', + $responseData['responseData']['add_paydata[billing_firstname]'] ?? '', + $responseData['responseData']['add_paydata[billing_lastname]'] ?? '', + $responseData['responseData']['add_paydata[billing_district]'] ?? '', + $responseData['responseData']['add_paydata[billing_telephonenumber]'] ?? '', + $responseData['responseData']['add_paydata[billing_state]'] ?? '', + $responseData['responseData']['add_paydata[storename]'] ?? '', + $responseData['responseData']['workorderid'] ?? '' + ); + } + + /** + * @param array $responseData + * @return SetOrderReferenceDetailsResponse + */ + private static function makeSetOrderReferenceDetailsResponse(array $responseData): SetOrderReferenceDetailsResponse + { + /** @var SetOrderReferenceDetailsResponse $response */ + $response = pluginApp(SetOrderReferenceDetailsResponse::class); + + if(!$responseData['success']) { + $customerErrorMessage = ''; + if($responseData['responseData'] && $responseData['responseData']['responseData'] && $responseData['responseData']['responseData']['customermessage']) { + $customerErrorMessage = $responseData['responseData']['responseData']['customermessage']; + } + return $response->init( + false, + $customerErrorMessage + ); + } + + return $response->init( + $responseData['success'] ?? false, + $responseData['errormessage'] ?? '', + $responseData['responseData']['add_paydata[amazonAddressToken]'] ?? '', + $responseData['responseData']['add_paydata[amazonReferenceId]'] ?? '', + $responseData['responseData']['add_paydata[storename]'] ?? '', + $responseData['responseData']['amount'] ?? '', + $responseData['responseData']['currency'] ?? '', + $responseData['responseData']['workorderid'] ?? '' + ); + } + + /** + * @param array $responseData + * @return ConfirmOrderReferenceResponse + */ + private static function makeConfirmOrderReferenceResponse(array $responseData) + { + /** @var ConfirmOrderReferenceResponse $response */ + $response = pluginApp(ConfirmOrderReferenceResponse::class); + + if(!$responseData['success']) { + $customerErrorMessage = ''; + if($responseData['responseData'] && $responseData['responseData']['responseData'] && $responseData['responseData']['responseData']['customermessage']) { + $customerErrorMessage = $responseData['responseData']['responseData']['customermessage']; + } + return $response->init( + false, + $customerErrorMessage + ); + } + + return $response->init( + $responseData['success'] ?? false, + $responseData['errormessage'] ?? '', + $responseData['responseData']['workorderid'] ?? '' + ); + } +} diff --git a/src/Models/Api/GenericPayment/GetConfigurationResponse.php b/src/Models/Api/GenericPayment/GetConfigurationResponse.php new file mode 100644 index 00000000..c9d2b8b5 --- /dev/null +++ b/src/Models/Api/GenericPayment/GetConfigurationResponse.php @@ -0,0 +1,113 @@ +success = $success; + $this->errorMessage = $errorMessage; + $this->clientId = $clientId; + $this->sellerId = $sellerId; + $this->currency = $currency; + $this->workOrderId = $workorderId; + return $this; + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + return parent::jsonSerialize() + + [ + 'clientId' => $this->clientId, + 'sellerId' => $this->sellerId, + 'currency' => $this->currency, + 'workOrderId' => $this->workOrderId, + ]; + } + + /** + * @return string + */ + public function getClientId(): string + { + return $this->clientId; + } + + /** + * @return string + */ + public function getSellerId(): string + { + return $this->sellerId; + } + + /** + * @return string + */ + public function getCurrency(): string + { + return $this->currency; + } + + /** + * @return string + */ + public function getWorkOrderId(): string + { + return $this->workOrderId; + } + + /** + * @return bool + */ + public function isSuccess(): bool + { + return $this->getSuccess(); + } +} diff --git a/src/Models/Api/GenericPayment/GetOrderReferenceDetailsResponse.php b/src/Models/Api/GenericPayment/GetOrderReferenceDetailsResponse.php new file mode 100644 index 00000000..cbcff416 --- /dev/null +++ b/src/Models/Api/GenericPayment/GetOrderReferenceDetailsResponse.php @@ -0,0 +1,372 @@ +success = $success; + $this->errorMessage = $errorMessage; + $this->email = $email; + $this->shippingZip = $shippingZip; + $this->shippingStreet = $shippingStreet; + $this->shippingCompany = $shippingCompany; + $this->shippingCity = $shippingCity; + $this->shippingType = $shippingType; + $this->shippingCountry = $shippingCountry; + $this->shippingDistrict = $shippingDistrict; + $this->shippingTelephonenumber = $shippingTelephonenumber; + $this->shippingState = $shippingState; + $this->shippingFirstname = $shippingFirstname; + $this->shippingLastname = $shippingLastname; + $this->billingZip = $billingZip; + $this->billingStreet = $billingStreet; + $this->billingCompany = $billingCompany; + $this->billingCity = $billingCity; + $this->billingType = $billingType; + $this->billingCountry = $billingCountry; + $this->billingFirstname = $billingFirstname; + $this->billingLastname = $billingLastname; + $this->billingDistrict = $billingDistrict; + $this->billingTelephonenumber = $billingTelephonenumber; + $this->billingState = $billingState; + $this->storename = $storename; + $this->workOrderId = $workOrderId; + + return $this; + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + return parent::jsonSerialize() + + [ + 'email' => $this->email, + 'shippingZip' => $this->shippingZip, + 'shippingStreet' => $this->shippingStreet, + 'shippingCompany' => $this->shippingCompany, + 'shippingCity' => $this->shippingCity, + 'shippingType' => $this->shippingType, + 'shippingCountry' => $this->shippingCountry, + 'shippingDistrict' => $this->shippingDistrict, + 'shippingTelephonenumber' => $this->shippingTelephonenumber, + 'shippingState' => $this->shippingState, + 'shippingFirstname' => $this->shippingFirstname, + 'shippingLastname' => $this->shippingLastname, + 'billingZip' => $this->billingZip, + 'billingStreet' => $this->billingStreet, + 'billingCompany' => $this->billingCompany, + 'billingCity' => $this->billingCity, + 'billingType' => $this->billingType, + 'billingCountry' => $this->billingCountry, + 'billingFirstname' => $this->billingFirstname, + 'billingLastname' => $this->billingLastname, + 'billingDistrict' => $this->billingDistrict, + 'billingTelephonenumber' => $this->billingTelephonenumber, + 'billingState' => $this->billingState, + 'storename' => $this->storename, + 'workOrderId' => $this->workOrderId + ]; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @return string + */ + public function getShippingZip(): string + { + return $this->shippingZip; + } + + /** + * @return string + */ + public function getShippingStreet(): string + { + return $this->shippingStreet; + } + + /** + * @return string + */ + public function getShippingCompany(): string + { + return $this->shippingCompany; + } + + /** + * @return string + */ + public function getShippingCity(): string + { + return $this->shippingCity; + } + + /** + * @return string + */ + public function getShippingType(): string + { + return $this->shippingType; + } + + /** + * @return string + */ + public function getShippingCountry(): string + { + return $this->shippingCountry; + } + + /** + * @return string + */ + public function getShippingDistrict(): string + { + return $this->shippingDistrict; + } + + /** + * @return string + */ + public function getShippingTelephonenumber(): string + { + return $this->shippingTelephonenumber; + } + + /** + * @return string + */ + public function getShippingState(): string + { + return $this->shippingState; + } + + /** + * @return string + */ + public function getShippingFirstname(): string + { + return $this->shippingFirstname; + } + + /** + * @return string + */ + public function getShippingLastname(): string + { + return $this->shippingLastname; + } + + /** + * @return string + */ + public function getBillingZip(): string + { + return $this->billingZip; + } + + /** + * @return string + */ + public function getBillingStreet(): string + { + return $this->billingStreet; + } + + /** + * @return string + */ + public function getBillingCompany(): string + { + return $this->billingCompany; + } + + /** + * @return string + */ + public function getBillingCity(): string + { + return $this->billingCity; + } + + /** + * @return string + */ + public function getBillingType(): string + { + return $this->billingType; + } + + /** + * @return string + */ + public function getBillingCountry(): string + { + return $this->billingCountry; + } + + /** + * @return string + */ + public function getBillingFirstname(): string + { + return $this->billingFirstname; + } + + /** + * @return string + */ + public function getBillingLastname(): string + { + return $this->billingLastname; + } + + /** + * @return string + */ + public function getBillingDistrict(): string + { + return $this->billingDistrict; + } + + /** + * @return string + */ + public function getBillingTelephonenumber(): string + { + return $this->billingTelephonenumber; + } + + /** + * @return string + */ + public function getBillingState(): string + { + return $this->billingState; + } + + /** + * @return string + */ + public function getStorename(): string + { + return $this->storename; + } + + /** + * @return string + */ + public function getWorkOrderId(): string + { + return $this->workOrderId; + } + + /** + * @return bool + */ + public function isSuccess(): bool + { + return $this->getSuccess(); + } +} diff --git a/src/Models/Api/GenericPayment/SetOrderReferenceDetailsResponse.php b/src/Models/Api/GenericPayment/SetOrderReferenceDetailsResponse.php new file mode 100644 index 00000000..77debe8e --- /dev/null +++ b/src/Models/Api/GenericPayment/SetOrderReferenceDetailsResponse.php @@ -0,0 +1,142 @@ +success = $success; + $this->errorMessage = $errorMessage; + $this->amazonAddressToken = $amazonAddressToken; + $this->amazonReferenceId = $amazonReferenceId; + $this->storename = $storename; + $this->amount = $amount; + $this->currency = $currency; + $this->workOrderId = $workOrderId; + + return $this; + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + return parent::jsonSerialize() + + [ + 'amazonAddressToken' => $this->amazonAddressToken, + 'amazonReferenceId' => $this->amazonReferenceId, + 'storename' => $this->storename, + 'amount' => $this->amount, + 'currency' => $this->currency, + 'workOrderId' => $this->workOrderId + ]; + } + + /** + * @return bool + */ + public function isSuccess(): bool + { + return $this->success; + } + + /** + * @return string + */ + public function getErrorMessage(): string + { + return $this->errorMessage; + } + + /** + * @return string + */ + public function getTransactionID(): string + { + return $this->transactionID; + } + + /** + * @return string + */ + public function getAmazonAddressToken(): string + { + return $this->amazonAddressToken; + } + + /** + * @return string + */ + public function getAmazonReferenceId(): string + { + return $this->amazonReferenceId; + } + + /** + * @return string + */ + public function getStorename(): string + { + return $this->storename; + } + + /** + * @return string + */ + public function getAmount(): string + { + return $this->amount; + } + + /** + * @return string + */ + public function getCurrency(): string + { + return $this->currency; + } + + /** + * @return string + */ + public function getWorkOrderId(): string + { + return $this->workOrderId; + } + + +} 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/CreditCardCheckRequestData.php b/src/Models/CreditCardCheckRequestData.php index e5890877..1d1b8300 100644 --- a/src/Models/CreditCardCheckRequestData.php +++ b/src/Models/CreditCardCheckRequestData.php @@ -14,9 +14,8 @@ class CreditCardCheckRequestData implements \JsonSerializable * * @param ApiCredentials $configRepo */ - public function __construct( - ApiCredentials $configRepo - ) { + public function __construct(ApiCredentials $configRepo) + { $this->configRepo = $configRepo; } diff --git a/src/Models/CreditCardStyle.php b/src/Models/CreditCardStyle.php index 9e8c9526..bc959ad1 100644 --- a/src/Models/CreditCardStyle.php +++ b/src/Models/CreditCardStyle.php @@ -2,24 +2,24 @@ namespace Payone\Models; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Methods\PayoneCCPaymentMethod; +use Payone\Services\SettingsService; class CreditCardStyle { - /** @var ConfigAdapter */ - private $configRepo; + /** + * @var SettingsService + */ + protected $settingsService; /** * Api constructor. * - * @param $paymentCode - * @param ConfigAdapter $configRepo + * @param SettingsService $settingsService */ - public function __construct( - ConfigAdapter $configRepo - ) { - $this->configRepo = $configRepo; + public function __construct(SettingsService $settingsService) + { + $this->settingsService = $settingsService; } /** @@ -27,7 +27,7 @@ public function __construct( */ public function getDefaultWidthInPx() { - return (float) $this->configRepo->get(PayoneCCPaymentMethod::PAYMENT_CODE . '.defaultWidthInPx'); + return (float)$this->settingsService->getPaymentSettingsValue('defaultWidthInPx',PayoneCCPaymentMethod::PAYMENT_CODE); } /** @@ -35,7 +35,7 @@ public function getDefaultWidthInPx() */ public function getDefaultHeightInPx() { - return (float) $this->configRepo->get(PayoneCCPaymentMethod::PAYMENT_CODE . '.defaultHeightInPx'); + return (float)$this->settingsService->getPaymentSettingsValue('defaultHeightInPx',PayoneCCPaymentMethod::PAYMENT_CODE); } /** @@ -43,6 +43,7 @@ public function getDefaultHeightInPx() */ public function getDefaultStyle(): string { - return $this->configRepo->get(PayoneCCPaymentMethod::PAYMENT_CODE . '.defaultStyle'); + return (string)$this->settingsService->getPaymentSettingsValue('defaultStyle',PayoneCCPaymentMethod::PAYMENT_CODE); } + } diff --git a/src/Models/CreditcardTypes.php b/src/Models/CreditcardTypes.php index 4a413c1f..69da7937 100644 --- a/src/Models/CreditcardTypes.php +++ b/src/Models/CreditcardTypes.php @@ -2,8 +2,8 @@ namespace Payone\Models; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Methods\PayoneCCPaymentMethod; +use Payone\Services\SettingsService; class CreditcardTypes { @@ -18,40 +18,31 @@ class CreditcardTypes const JCB = 'J'; const CHINA_UNION_PAY = 'P'; - /** @var ConfigAdapter */ - private $configRepo; + /** + * @var SettingsService + */ + protected $settingsService; /** * Api constructor. * - * @param $paymentCode - * @param ConfigAdapter $configRepo + * @param SettingsService $settingsService */ - public function __construct( - ConfigAdapter $configRepo - ) { - $this->configRepo = $configRepo; + public function __construct(SettingsService $settingsService) + { + $this->settingsService = $settingsService; } /** - * @return string[] + * @return array */ public function getAllowedTypes(): array { - $allowedTypesFromConfigString = $this->configRepo->get(PayoneCCPaymentMethod::PAYMENT_CODE . '.allowedCardTypes'); - if ($allowedTypesFromConfigString == ConfigAdapter::MULTI_SELECT_ALL) { - return $this->getCreditCardTypes(); + $allowedTypesFromConfig = $this->settingsService->getPaymentSettingsValue('AllowedCardTypes',PayoneCCPaymentMethod::PAYMENT_CODE); + if(is_array($allowedTypesFromConfig)) { + return $allowedTypesFromConfig; } - - $allowedTypesFromConfigString = str_replace( - 'PAYONE_PAYONE_CREDIT_CARD.allowedCardTypes.', - '', - $allowedTypesFromConfigString - ); - - $allowedTypesFromConfig = explode(', ', $allowedTypesFromConfigString); - - return array_intersect($this->getCreditCardTypes(), $allowedTypesFromConfig); + return []; } /** 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..1a857df6 100644 --- a/src/Models/PaymentConfig/ApiCredentials.php +++ b/src/Models/PaymentConfig/ApiCredentials.php @@ -2,78 +2,106 @@ namespace Payone\Models\PaymentConfig; -use Payone\Adapter\Config as ConfigAdapter; +use Payone\Services\SettingsService; class ApiCredentials { - /** @var ConfigAdapter */ - private $configRepo; + /** + * @var SettingsService + */ + protected $settingsService; /** * Api constructor. * - * @param $paymentCode - * @param ConfigAdapter $configRepo + * @param SettingsService $settingsService */ - public function __construct( - ConfigAdapter $configRepo - ) { - $this->configRepo = $configRepo; + public function __construct(SettingsService $settingsService) + { + $this->settingsService = $settingsService; } /** + * @param string|null $paymentCode + * @param int|null $clientId + * @param int|null $pluginSetId * @return string */ - public function getKey(): string + public function getKey(string $paymentCode = null, int $clientId = null, int $pluginSetId = null): string { - return $this->configRepo->get('key'); + if ($paymentCode !== null) { + $key = $this->settingsService->getPaymentSettingsValue('key', $paymentCode, $clientId, $pluginSetId); + if (!empty($key)) { + return $key; + } + } + + return $this->settingsService->getSettingsValue('key', $clientId, $pluginSetId); } /** + * @param int|null $clientId + * @param int|null $pluginSetId * @return string */ - public function getAid(): string + public function getAid(int $clientId = null, int $pluginSetId = null): string { - return $this->configRepo->get('aid'); + return $this->settingsService->getSettingsValue('aid', $clientId, $pluginSetId); } /** + * @param int|null $clientId + * @param int|null $pluginSetId * @return string */ - public function getMid(): string + public function getMid(int $clientId = null, int $pluginSetId = null): string { - return $this->configRepo->get('mid'); + return $this->settingsService->getSettingsValue('mid', $clientId, $pluginSetId); } /** + * @param string|null $paymentCode + * @param int|null $clientId + * @param int|null $pluginSetId * @return string */ - public function getPortalid(): string + public function getPortalid(string $paymentCode = null, int $clientId = null, int $pluginSetId = null): string { - return $this->configRepo->get('portalid'); + if ($paymentCode !== null) { + $portalId = $this->settingsService->getPaymentSettingsValue('portalId', $paymentCode, $clientId, $pluginSetId); + if (!empty($portalId)) { + return $portalId; + } + } + + return $this->settingsService->getSettingsValue('portalId'); } /** + * @param int|null $clientId + * @param int|null $pluginSetId * @return string */ - public function getMode(): string + public function getMode(int $clientId = null, int $pluginSetId = null): string { - $mode = $this->configRepo->get('mode'); - + $mode = $this->settingsService->getSettingsValue('mode', $clientId, $pluginSetId); return ($mode == 1) ? 'live' : 'test'; } /** + * @param string|null $paymentCode + * @param int|null $clientId + * @param int|null $pluginSetId * @return array */ - public function getApiCredentials() + public function getApiCredentials(string $paymentCode = null, int $clientId = null, int $pluginSetId = null): array { $apiContextParams = []; - $apiContextParams['aid'] = $this->getAid(); - $apiContextParams['mid'] = $this->getMid(); - $apiContextParams['portalid'] = $this->getPortalid(); - $apiContextParams['key'] = $this->getKey(); - $apiContextParams['mode'] = $this->getMode(); + $apiContextParams['aid'] = $this->getAid($clientId, $pluginSetId); + $apiContextParams['mid'] = $this->getMid($clientId, $pluginSetId); + $apiContextParams['portalid'] = $this->getPortalid($paymentCode, $clientId, $pluginSetId); + $apiContextParams['key'] = $this->getKey($paymentCode, $clientId, $pluginSetId); + $apiContextParams['mode'] = $this->getMode($clientId, $pluginSetId); return $apiContextParams; } diff --git a/src/Models/PaymentConfig/CreditCardExpiration.php b/src/Models/PaymentConfig/CreditCardExpiration.php index 4d002d49..19304fd8 100644 --- a/src/Models/PaymentConfig/CreditCardExpiration.php +++ b/src/Models/PaymentConfig/CreditCardExpiration.php @@ -2,30 +2,31 @@ namespace Payone\Models\PaymentConfig; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Methods\PayoneCCPaymentMethod; +use Payone\Services\SettingsService; class CreditCardExpiration { - /** @var ConfigAdapter */ - private $configRepo; + /** + * @var SettingsService + */ + protected $settingsService; /** * Api constructor. * - * @param $paymentCode - * @param ConfigAdapter $configRepo + * @param SettingsService $settingsService */ - public function __construct(ConfigAdapter $configRepo) + public function __construct(SettingsService $settingsService) { - $this->configRepo = $configRepo; + $this->settingsService = $settingsService; } /** * @return int */ - public function getMinExpireTimeInDays() + public function getMinExpireTimeInDays(): int { - return (int) $this->configRepo->get(PayoneCCPaymentMethod::PAYMENT_CODE . '.minExpireTime'); + return (int) $this->settingsService->getPaymentSettingsValue('minExpireTime', PayoneCCPaymentMethod::PAYMENT_CODE); } } diff --git a/src/Models/PaymentMethodContent.php b/src/Models/PaymentMethodContent.php index eb9dd599..6c1346f9 100644 --- a/src/Models/PaymentMethodContent.php +++ b/src/Models/PaymentMethodContent.php @@ -2,6 +2,7 @@ namespace Payone\Models; +use Payone\Methods\PayoneAmazonPayPaymentMethod; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Methods\PayoneDirectDebitPaymentMethod; use Payone\Methods\PayonePaydirektPaymentMethod; @@ -21,6 +22,7 @@ class PaymentMethodContent */ public function getPaymentContentType($paymentCode) { + switch ($paymentCode) { case 'none': case PayoneDirectDebitPaymentMethod::PAYMENT_CODE: @@ -30,6 +32,8 @@ public function getPaymentContentType($paymentCode) case PayonePaydirektPaymentMethod::PAYMENT_CODE: case PayoneSofortPaymentMethod::PAYMENT_CODE: return GetPaymentMethodContent::RETURN_TYPE_REDIRECT_URL; + case PayoneAmazonPayPaymentMethod::PAYMENT_CODE: + return GetPaymentMethodContent::RETURN_TYPE_HTML; } return GetPaymentMethodContent::RETURN_TYPE_CONTINUE; diff --git a/src/Models/Settings.php b/src/Models/Settings.php new file mode 100644 index 00000000..47519be7 --- /dev/null +++ b/src/Models/Settings.php @@ -0,0 +1,195 @@ +clientId = $data['clientId']; + $this->pluginSetId = $data['pluginSetId']; + $this->createdAt = (string)Carbon::now(); + + $this->value = [ + 'mid' => $data['mid'], + 'portalId' => $data['portalId'], + 'aid' => $data['aid'], + 'key' => $data['key'], + 'mode' => $data['mode'], + 'authType' => $data['authType'], + 'userId' => $data['userId'], + 'PAYONE_PAYONE_INVOICE' => $data['PAYONE_PAYONE_INVOICE'], + 'PAYONE_PAYONE_PAYDIREKT' => $data['PAYONE_PAYONE_PAYDIREKT'], + 'PAYONE_PAYONE_PAYOLUTION_INSTALLMENT' => $data['PAYONE_PAYONE_PAYOLUTION_INSTALLMENT'], + 'PAYONE_PAYONE_PAY_PAL' => $data['PAYONE_PAYONE_PAY_PAL'], + 'PAYONE_PAYONE_RATEPAY_INSTALLMENT' => $data['PAYONE_PAYONE_RATEPAY_INSTALLMENT'], + 'PAYONE_PAYONE_SOFORT' => $data['PAYONE_PAYONE_SOFORT'], + 'PAYONE_PAYONE_CASH_ON_DELIVERY' => $data['PAYONE_PAYONE_CASH_ON_DELIVERY'], + 'PAYONE_PAYONE_PRE_PAYMENT' => $data['PAYONE_PAYONE_PRE_PAYMENT'], + 'PAYONE_PAYONE_CREDIT_CARD' => $data['PAYONE_PAYONE_CREDIT_CARD'], + 'PAYONE_PAYONE_DIRECT_DEBIT' => $data['PAYONE_PAYONE_DIRECT_DEBIT'], + 'PAYONE_PAYONE_INVOICE_SECURE' => $data['PAYONE_PAYONE_INVOICE_SECURE'], + 'PAYONE_PAYONE_KLARNA_DIRECT_BANK' => $data['PAYONE_PAYONE_KLARNA_DIRECT_BANK'], + 'PAYONE_PAYONE_KLARNA_DIRECT_DEBIT' => $data['PAYONE_PAYONE_KLARNA_DIRECT_DEBIT'], + 'PAYONE_PAYONE_KLARNA_INSTALLMENTS' => $data['PAYONE_PAYONE_KLARNA_INSTALLMENTS'], + 'PAYONE_PAYONE_KLARNA_INVOICE' => $data['PAYONE_PAYONE_KLARNA_INVOICE'] + ]; + + return $this->save(); + } + + /** + * @param string $settingKey + * @return array|mixed|null + */ + public function getValue(string $settingKey = "") + { + if (!empty($settingKey)) { + return $this->value[$settingKey] ?? null; + } + + return $this->value; + } + + /** + * @param array $data + * @return Model + */ + public function updateValues(array $data): Model + { + if (isset($data['mid'])) { + $this->value['mid'] = $data['mid']; + } + if (isset($data['portalId'])) { + $this->value['portalId'] = $data['portalId']; + } + if (isset($data['aid'])) { + $this->value['aid'] = $data['aid']; + } + if (isset($data['key'])) { + $this->value['key'] = $data['key']; + } + if (isset($data['mode'])) { + $this->value['mode'] = $data['mode']; + } + if (isset($data['authType'])) { + $this->value['authType'] = $data['authType']; + } + if (isset($data['userId'])) { + $this->value['userId'] = $data['userId']; + } + if (isset($data['PAYONE_PAYONE_INVOICE'])) { + $this->value['PAYONE_PAYONE_INVOICE'] = $data['PAYONE_PAYONE_INVOICE']; + } + if (isset($data['PAYONE_PAYONE_PAYDIREKT'])) { + $this->value['PAYONE_PAYONE_PAYDIREKT'] = $data['PAYONE_PAYONE_PAYDIREKT']; + } + if (isset($data['PAYONE_PAYONE_PAYOLUTION_INSTALLMENT'])) { + $this->value['PAYONE_PAYONE_PAYOLUTION_INSTALLMENT'] = $data['PAYONE_PAYONE_PAYOLUTION_INSTALLMENT']; + } + if (isset($data['PAYONE_PAYONE_PAY_PAL'])) { + $this->value['PAYONE_PAYONE_PAY_PAL'] = $data['PAYONE_PAYONE_PAY_PAL']; + } + if (isset($data['PAYONE_PAYONE_RATEPAY_INSTALLMENT'])) { + $this->value['PAYONE_PAYONE_RATEPAY_INSTALLMENT'] = $data['PAYONE_PAYONE_RATEPAY_INSTALLMENT']; + } + if (isset($data['PAYONE_PAYONE_SOFORT'])) { + $this->value['PAYONE_PAYONE_SOFORT'] = $data['PAYONE_PAYONE_SOFORT']; + } + if (isset($data['PAYONE_PAYONE_CASH_ON_DELIVERY'])) { + $this->value['PAYONE_PAYONE_CASH_ON_DELIVERY'] = $data['PAYONE_PAYONE_CASH_ON_DELIVERY']; + } + if (isset($data['PAYONE_PAYONE_PRE_PAYMENT'])) { + $this->value['PAYONE_PAYONE_PRE_PAYMENT'] = $data['PAYONE_PAYONE_PRE_PAYMENT']; + } + if (isset($data['PAYONE_PAYONE_CREDIT_CARD'])) { + $this->value['PAYONE_PAYONE_CREDIT_CARD'] = $data['PAYONE_PAYONE_CREDIT_CARD']; + } + if (isset($data['PAYONE_PAYONE_DIRECT_DEBIT'])) { + $this->value['PAYONE_PAYONE_DIRECT_DEBIT'] = $data['PAYONE_PAYONE_DIRECT_DEBIT']; + } + if (isset($data['PAYONE_PAYONE_INVOICE_SECURE'])) { + $this->value['PAYONE_PAYONE_INVOICE_SECURE'] = $data['PAYONE_PAYONE_INVOICE_SECURE']; + } + if (isset($data['PAYONE_PAYONE_AMAZON_PAY'])) { + $this->value['PAYONE_PAYONE_AMAZON_PAY'] = $data['PAYONE_PAYONE_AMAZON_PAY']; + } + if (isset($data['PAYONE_PAYONE_KLARNA_DIRECT_BANK'])) { + $this->value['PAYONE_PAYONE_KLARNA_DIRECT_BANK'] = $data['PAYONE_PAYONE_KLARNA_DIRECT_BANK']; + } + if (isset($data['PAYONE_PAYONE_KLARNA_DIRECT_DEBIT'])) { + $this->value['PAYONE_PAYONE_KLARNA_DIRECT_DEBIT'] = $data['PAYONE_PAYONE_KLARNA_DIRECT_DEBIT']; + } + if (isset($data['PAYONE_PAYONE_KLARNA_INSTALLMENTS'])) { + $this->value['PAYONE_PAYONE_KLARNA_INSTALLMENTS'] = $data['PAYONE_PAYONE_KLARNA_INSTALLMENTS']; + } + if (isset($data['PAYONE_PAYONE_KLARNA_INVOICE'])) { + $this->value['PAYONE_PAYONE_KLARNA_INVOICE'] = $data['PAYONE_PAYONE_KLARNA_INVOICE']; + } + if (isset($data['payoneMethods'])) { + $this->value['payoneMethods'] = $data['payoneMethods']; + } + + return $this->save(); + } + + /** + * @param Settings $newModel + * @return Model + */ + public function save(): Model + { + /** @var DataBase $database */ + $database = pluginApp(DataBase::class); + $this->updatedAt = (string)Carbon::now(); + + return $database->save($this); + } + + /** + * @return bool + */ + public function delete(): bool + { + /** @var DataBase $database */ + $database = pluginApp(DataBase::class); + return $database->delete($this); + } +} diff --git a/src/PluginConstants.php b/src/PluginConstants.php index 4bc1cb8e..467a385c 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 = '2.3.0'; } diff --git a/src/Providers/Api/Request/AuthDataProvider.php b/src/Providers/Api/Request/AuthDataProvider.php index bf466239..aa85710c 100644 --- a/src/Providers/Api/Request/AuthDataProvider.php +++ b/src/Providers/Api/Request/AuthDataProvider.php @@ -2,6 +2,7 @@ namespace Payone\Providers\Api\Request; +use Payone\Methods\PayoneAmazonPayPaymentMethod; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Methods\PayoneDirectDebitPaymentMethod; use Payone\Methods\PayoneSofortPaymentMethod; @@ -14,11 +15,17 @@ class AuthDataProvider extends DataProviderAbstract implements DataProviderOrder, DataProviderBasket { /** - * {@inheritdoc} + * @param string $paymentCode + * @param Basket $basket + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromBasket(string $paymentCode, Basket $basket, string $requestReference = null) + public function getDataFromBasket(string $paymentCode, Basket $basket, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketData($basket); @@ -42,7 +49,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(); @@ -51,6 +58,10 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r if ($paymentCode == PayoneDirectDebitPaymentMethod::PAYMENT_CODE) { $requestParams['sepaMandate'] = $this->getSepaMandateData(); } + if ($paymentCode == PayoneAmazonPayPaymentMethod::PAYMENT_CODE) { + $requestParams['amazonPayAuth'] = $this->getAmazonPayData($basket->id, $basket->basketAmount, $basket->currency); + } + $requestParams['referenceId'] = $requestReference; $requestParams['shippingProvider'] = $this->getShippingProvider($basket->shippingProfileId); $this->validator->validate($requestParams); @@ -59,11 +70,17 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r } /** - * {@inheritdoc} + * @param string $paymentCode + * @param Order $order + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketDataFromOrder($order); diff --git a/src/Providers/Api/Request/CaptureDataProvider.php b/src/Providers/Api/Request/CaptureDataProvider.php index 2a7816a9..c1b3653d 100644 --- a/src/Providers/Api/Request/CaptureDataProvider.php +++ b/src/Providers/Api/Request/CaptureDataProvider.php @@ -15,11 +15,17 @@ class CaptureDataProvider extends DataProviderAbstract implements DataProviderOrder { /** - * {@inheritdoc} + * @param string $paymentCode + * @param Order $order + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketDataFromOrder($order); $requestParams['basketItems'] = $this->getOrderItemData($order); @@ -66,12 +72,10 @@ private function getSettleaccount(string $paymentCode) in_array( $paymentCode, [ - PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE, PayoneInvoicePaymentMethod::PAYMENT_CODE, PayonePrePaymentPaymentMethod::PAYMENT_CODE, PayoneSofortPaymentMethod::PAYMENT_CODE, PayoneCODPaymentMethod::PAYMENT_CODE, - ] ) ) { diff --git a/src/Providers/Api/Request/DataProviderAbstract.php b/src/Providers/Api/Request/DataProviderAbstract.php index 98df58ec..90d3a055 100644 --- a/src/Providers/Api/Request/DataProviderAbstract.php +++ b/src/Providers/Api/Request/DataProviderAbstract.php @@ -2,8 +2,10 @@ namespace Payone\Providers\Api\Request; +use Payone\Adapter\SessionStorage; use Payone\Helpers\AddressHelper; use Payone\Helpers\ShopHelper; +use Payone\Methods\PayoneAmazonPayPaymentMethod; use Payone\Methods\PayoneCCPaymentMethod; use Payone\Methods\PayonePaydirektPaymentMethod; use Payone\Methods\PayonePayPalPaymentMethod; @@ -23,6 +25,8 @@ use Plenty\Modules\Item\Item\Contracts\ItemRepositoryContract; use Plenty\Modules\Item\Item\Models\Item; use Plenty\Modules\Item\Item\Models\ItemText; +use Plenty\Modules\Item\Variation\Contracts\VariationRepositoryContract; +use Plenty\Modules\Item\Variation\Models\Variation; use Plenty\Modules\Order\Models\Order; use Plenty\Modules\Order\Models\OrderItem; use Plenty\Modules\Order\Models\OrderItemType; @@ -31,6 +35,9 @@ use Plenty\Modules\Payment\Contracts\PaymentRepositoryContract; use Plenty\Modules\Payment\Models\Payment; use Plenty\Modules\Payment\Models\PaymentProperty; +use Plenty\Modules\Webshop\Contracts\LocalizationRepositoryContract; +use Plenty\Modules\Webshop\Contracts\WebstoreConfigurationRepositoryContract; +use Plenty\Modules\Item\Property\Models\Property; /** * Class DataProviderAbstract @@ -165,17 +172,94 @@ protected function getCartItemData(Basket $basket) if (!$basket->basketItems) { return $items; } + + /** @var VariationRepositoryContract $variationContract */ + $variationContract = pluginApp(VariationRepositoryContract::class); + /** @var WebstoreConfigurationRepositoryContract $webstoreConfigurationRepository */ + $webstoreConfigurationRepository = pluginApp(WebstoreConfigurationRepositoryContract::class); + $webstoreConfiguration = $webstoreConfigurationRepository->getWebstoreConfiguration(); + + /** @var LocalizationRepositoryContract $localizationRepository */ + $localizationRepository = pluginApp(LocalizationRepositoryContract::class); + $language = $localizationRepository->getLanguage(); + /** @var BasketItem $basketItem */ foreach ($basket->basketItems as $basketItem) { - /** @var Item $item */ - $item = $this->itemRepo->show($basketItem->itemId); - /** @var ItemText $itemText */ - $itemText = $item->texts; - - $basketItem = $basketItem->toArray(); - $basketItem['name'] = $itemText->first()->name1; + if($basketItem->itemType != BasketItem::BASKET_ITEM_TYPE_VARIATION_ORDER_PROPERTY) { + /** @var Item $item */ + $item = $this->itemRepo->show($basketItem->itemId); + /** @var ItemText $itemText */ + $itemText = $item->texts; + + $basketItemArr = $basketItem->toArray(); + $basketItemArr['name'] = $itemText->first()->name1; + $basketItemArr['price'] = (int)round($basketItem->price * 100); + $basketItemArr['vat'] = (int)$basketItem->vat; + + $items[] = $basketItemArr; + } - $items[] = $basketItem; + if($webstoreConfiguration->useVariationOrderProperties) { + foreach ($basketItem->basketItemVariationProperties as $basketItemVariationProperty) { + if($basketItemVariationProperty instanceof BasketItem) { + $basketItemArr = []; + $reference = $basketItem->variationId; + $name = $itemText->first()->name1; + foreach ($basketItemVariationProperty->basketItemOrderParams as $basketItemOrderParam) { + $reference .= '_'.$basketItemOrderParam->basketItemId; + $name .= ' '.$basketItemOrderParam->value; + } + + $basketItemArr['itemId'] = $basketItem->variationId .'_'. $basketItemVariationProperty->id; + $basketItemArr['quantity'] = 1; + $basketItemArr['name'] = $name; + $basketItemArr['price'] = (int)round($basketItemVariationProperty->price * 100); + $basketItemArr['vat'] = (int)$basketItemVariationProperty->vat; + $items[] = $basketItemArr; + } + } + } else { + /** + * Item property handling for surcharges + * For example "Pfand" + */ + /** @var Variation $variation */ + $variation = $variationContract->findById($basketItem->variationId); + + $itemProperties = $variation->item->itemProperties; + if ($itemProperties && count($itemProperties) > 0) { + foreach ($itemProperties as $itemProperty) { + $basketItemArr = []; + $basketItemArr['itemId'] = $basketItem->variationId . '_' . $itemProperty->id; + $basketItemArr['quantity'] = 1; + $basketItemArr['name'] = $basketItem->variationId . '_' . $itemProperty->id; + + $price = $itemProperty->surcharge; + $property = $itemProperty->property; + if ($property instanceof Property) { + if(!$property->isOderProperty && $property->isShownAsAdditionalCosts) { + $name = $property->names->first()->name; + foreach ($property->names as $propertyName) { + if ($propertyName->lang == $language) { + $name = $propertyName->name; + } + } + $basketItemArr['name'] = $name; + + $markup = $property->surcharge; + if($property->propertyGroupId > 0 && $property->group->first()->isSurchargePercental) { + $markup = $price / 100 * $property->surcharge; + } + $price += $markup; + + $basketItemArr['price'] = (int)round($price * 100); + $basketItemArr['vat'] = (int)$basketItem->vat; + } + } + $items[] = $basketItemArr; + } + } + } } return $items; @@ -200,7 +284,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,55 +312,73 @@ 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; } /** - * @param $paymentCode - * + * @param string $paymentCode + * @param int|null $clientId + * @param int|null $pluginSetId * @return array */ - protected function getDefaultRequestData($paymentCode) + protected function getDefaultRequestData(string $paymentCode, int $clientId = null, int $pluginSetId = null): array { return [ 'paymentMethod' => $this->mapPaymentCode($paymentCode), 'systemInfo' => $this->getSystemInfo(), - 'context' => $this->getApiContextParams(), + 'context' => $this->getApiContextParams($paymentCode, $clientId, $pluginSetId), ]; } /** + * @param string $paymentCode + * @param int|null $clientId + * @param int|null $pluginSetId * @return array */ - protected function getApiContextParams() + protected function getApiContextParams(string $paymentCode, int $clientId = null, int $pluginSetId = null) { - return $this->config->getApiCredentials(); + return $this->config->getApiCredentials($paymentCode, $clientId, $pluginSetId); } /** * @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 +401,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 +441,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 +473,7 @@ protected function mapPaymentCode($paymentCode) protected function getSystemInfo() { return [ - 'vendor' => 'arvatis media GmbH', + 'vendor' => 'plentysystems AG', 'version' => 7, 'type' => 'Webshop', 'url' => $this->shopHelper->getPlentyDomain(), @@ -435,6 +552,7 @@ protected function paymentHasRedirect($paymentCode) PayonePayPalPaymentMethod::PAYMENT_CODE, PayonePaydirektPaymentMethod::PAYMENT_CODE, PayoneSofortPaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, ] ) ) { @@ -447,10 +565,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', ]; @@ -487,6 +609,28 @@ protected function getBankAccount() return $account->jsonSerialize(); } + /** + * @param string $basketId + * @param $basketAmount + * @param string $currency + * @return array + */ + protected function getAmazonPayData(string $basketId, $basketAmount, string $currency): array + { + /** @var SessionStorage $sessionStorage */ + $sessionStorage = pluginApp(SessionStorage::class); + $amazonAuthConfig = []; + $amazonAuthConfig['workOrderId'] = $sessionStorage->getSessionValue('workOrderId'); + $amazonAuthConfig['amazonReferenceId'] = $sessionStorage->getSessionValue('amazonReferenceId'); + $amazonAuthConfig['reference'] = $basketId; + + $amazonAuthConfig['currency'] = $currency; + // amount in smallest unit + $amazonAuthConfig['amount'] = $basketAmount * 100; + + return $amazonAuthConfig; + } + /** * @param Order $order * @return float @@ -520,11 +664,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/DataProviderOrder.php b/src/Providers/Api/Request/DataProviderOrder.php index 8b7f2188..fff39aa4 100644 --- a/src/Providers/Api/Request/DataProviderOrder.php +++ b/src/Providers/Api/Request/DataProviderOrder.php @@ -10,8 +10,9 @@ interface DataProviderOrder * @param string $paymentCode * @param Order $order * @param string|null $requestReference - * + * @param int|null $clientId + * @param int|null $pluginSetId * @return array */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null); + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null); } diff --git a/src/Providers/Api/Request/DebitDataProvider.php b/src/Providers/Api/Request/DebitDataProvider.php index 1026f614..999bebcd 100644 --- a/src/Providers/Api/Request/DebitDataProvider.php +++ b/src/Providers/Api/Request/DebitDataProvider.php @@ -10,20 +10,17 @@ class DebitDataProvider extends DataProviderAbstract implements DataProviderOrder { /** - * {@inheritdoc} + * @param string $paymentCode + * @param Order $order + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $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 []; } /** @@ -31,14 +28,19 @@ public function getDataFromOrder(string $paymentCode, Order $order, string $requ * @param Order $order * @param Order $refund * @param $preAuthUniqueId + * @param int|null $clientId + * @param int|null $pluginSetId * * @return array */ - public function getPartialRefundData($paymentCode, Order $order, Order $refund, $preAuthUniqueId) + public function getPartialRefundData($paymentCode, Order $order, Order $refund, $preAuthUniqueId, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDataFromOrder($paymentCode, $order, $preAuthUniqueId); - + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); + $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/GenericPaymentDataProvider.php b/src/Providers/Api/Request/GenericPaymentDataProvider.php new file mode 100644 index 00000000..34e14351 --- /dev/null +++ b/src/Providers/Api/Request/GenericPaymentDataProvider.php @@ -0,0 +1,178 @@ +getDefaultRequestData($paymentCode, $clientId, $pluginSetId); + $requestParams['request'] = GenericPayment::REQUEST_TYPE; + + if ($paymentCode == PayoneAmazonPayPaymentMethod::PAYMENT_CODE) { + $requestParams['clearingtype'] = PayoneAmazonPayPaymentMethod::CLEARING_TYPE; + $requestParams['wallettype'] = PayoneAmazonPayPaymentMethod::CLEARING_TYPE; + } + + return $requestParams; + } + + /** + * @param string $paymentCode + * @param string $currency + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception + */ + public function getGetConfigRequestData(string $paymentCode, string $currency, int $clientId = null, int $pluginSetId = null): array + { + $requestParams = $this->getDefaultPaymentRequestData($paymentCode, $clientId, $pluginSetId); + + // Currency not mentioned in API-Doc of Payone + $requestParams['currency'] = $currency; + + $requestParams['add_paydata']['action'] = GenericPayment::ACTIONTYPE_GETCONFIGURATION; + + $this->validator->validate($requestParams); + return $requestParams; + } + + /** + * @param string $paymentCode + * @param string $workOrderId + * @param string $amazonAddressToken + * @param string $amazonReferenceId + * @param string $currency + * @param string $amount + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception + */ + public function getGetOrderReferenceDetailsRequestData( + string $paymentCode, + string $workOrderId, + string $amazonAddressToken, + string $amazonReferenceId, + string $currency, + string $amount, + int $clientId = null, + int $pluginSetId = null + ): array { + $requestParams = $this->getDefaultPaymentRequestData($paymentCode, $clientId, $pluginSetId); + + // Currency not mentioned in API-Doc of Payone + $requestParams['currency'] = $currency; + // amount in smallest unit + $requestParams['amount'] = $amount * 100; + + + $requestParams['add_paydata']['action'] = GenericPayment::ACTIONTYPE_GETORDERREFERENCEDETAILS; + $requestParams['add_paydata']['amazon_address_token'] = $amazonAddressToken; + $requestParams['add_paydata']['amazon_reference_id'] = $amazonReferenceId; + $requestParams['workorderid'] = $workOrderId; + + $this->validator->validate($requestParams); + return $requestParams; + } + + /** + * @param string $paymentCode + * @param string $workOrderId + * @param string $amazonReferenceId + * @param string $amount + * @param string|null $currency + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception + */ + public function getSetOrderReferenceDetailsRequestData( + string $paymentCode, + string $workOrderId, + string $amazonReferenceId, + string $amount, + string $currency = null, + int $clientId = null, + int $pluginSetId = null + ): array { + $requestParams = $this->getDefaultPaymentRequestData($paymentCode, $clientId, $pluginSetId); + + if(!is_null($currency)) { + // Currency not mentioned in API-Doc of Payone + $requestParams['currency'] = $currency; + } + // amount in smallest unit + $requestParams['amount'] = $amount * 100; + + $requestParams['add_paydata']['action'] = GenericPayment::ACTIONTYPE_SETORDERREFERENCEDETAILS; + $requestParams['add_paydata']['amazon_reference_id'] = $amazonReferenceId; + $requestParams['workorderid'] = $workOrderId; + + $this->validator->validate($requestParams); + return $requestParams; + } + + /** + * @param string $paymentCode + * @param string $workOrderId + * @param string $reference + * @param string $amazonReferenceId + * @param string $amount + * @param string $currency + * @param string $basketId + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception + */ + public function getConfirmOrderReferenceRequestData( + string $paymentCode, + string $workOrderId, + string $reference, + string $amazonReferenceId, + string $amount, + string $currency, + string $basketId, + int $clientId = null, + int $pluginSetId = null + ): array { + $requestParams = $this->getDefaultPaymentRequestData($paymentCode, $clientId, $pluginSetId); + + // Currency not mentioned in API-Doc of Payone + $requestParams['currency'] = $currency; + // amount in smallest unit + $requestParams['amount'] = $amount * 100; + + $requestParams['add_paydata']['action'] = GenericPayment::ACTIONTYPE_CONFIRMORDERREFERENCE; + $requestParams['add_paydata']['reference'] = $reference; + $requestParams['add_paydata']['amazon_reference_id'] = $amazonReferenceId; + $requestParams['workorderid'] = $workOrderId; + + /** @var ShopHelper $shopHelper */ + $shopHelper = pluginApp(ShopHelper::class); + + $successParam = ''; + if (strlen($basketId)) { + $successParam = '?transactionBasketId=' . $basketId; + } + + $requestParams['successurl'] = $shopHelper->getPlentyDomain() . '/payment/payone/checkoutSuccess' . $successParam; + $requestParams['errorurl'] = $shopHelper->getPlentyDomain() . '/payment/payone/error'; + + $this->validator->validate($requestParams); + return $requestParams; + } +} diff --git a/src/Providers/Api/Request/GetInvoiceDataProvider.php b/src/Providers/Api/Request/GetInvoiceDataProvider.php new file mode 100644 index 00000000..c1a96ba3 --- /dev/null +++ b/src/Providers/Api/Request/GetInvoiceDataProvider.php @@ -0,0 +1,23 @@ +getDefaultRequestData($paymentCode, $clientId, $pluginSetId); + $requestParams['context']['documentNumber'] = $documentNumber; + $this->validator->validate($requestParams); + return $requestParams; + } +} diff --git a/src/Providers/Api/Request/ManagemandateDataProvider.php b/src/Providers/Api/Request/ManagemandateDataProvider.php index 56e321e1..6c0e97d7 100644 --- a/src/Providers/Api/Request/ManagemandateDataProvider.php +++ b/src/Providers/Api/Request/ManagemandateDataProvider.php @@ -7,11 +7,17 @@ class ManagemandateDataProvider extends DataProviderAbstract implements DataProviderBasket { /** - * {@inheritdoc} + * @param string $paymentCode + * @param Basket $basket + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromBasket(string $paymentCode, Basket $basket, string $requestReference = null) + public function getDataFromBasket(string $paymentCode, Basket $basket, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketData($basket); diff --git a/src/Providers/Api/Request/Models/GenericPayment.php b/src/Providers/Api/Request/Models/GenericPayment.php new file mode 100644 index 00000000..32c42763 --- /dev/null +++ b/src/Providers/Api/Request/Models/GenericPayment.php @@ -0,0 +1,15 @@ +getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketData($basket); @@ -40,7 +47,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(); @@ -49,6 +56,9 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r if ($paymentCode == PayoneDirectDebitPaymentMethod::PAYMENT_CODE) { $requestParams['sepaMandate'] = $this->getSepaMandateData(); } + if ($paymentCode == PayoneAmazonPayPaymentMethod::PAYMENT_CODE) { + $requestParams['amazonPayAuth'] = $this->getAmazonPayData($basket->id, $basket->basketAmount, $basket->currency); + } $requestParams['referenceId'] = $requestReference; $requestParams['shippingProvider'] = $this->getShippingProvider($basket->shippingProfileId); @@ -58,11 +68,17 @@ public function getDataFromBasket(string $paymentCode, Basket $basket, string $r } /** - * {@inheritdoc} + * @param string $paymentCode + * @param Order $order + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['basket'] = $this->getBasketDataFromOrder($order); diff --git a/src/Providers/Api/Request/RefundDataProvider.php b/src/Providers/Api/Request/RefundDataProvider.php index 52845425..08749f63 100644 --- a/src/Providers/Api/Request/RefundDataProvider.php +++ b/src/Providers/Api/Request/RefundDataProvider.php @@ -10,11 +10,17 @@ class RefundDataProvider extends DataProviderAbstract implements DataProviderOrder { /** - * {@inheritdoc} + * @param string $paymentCode + * @param Order $order + * @param string|null $requestReference + * @param int|null $clientId + * @param int|null $pluginSetId + * @return array + * @throws \Exception */ - public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null) + public function getDataFromOrder(string $paymentCode, Order $order, string $requestReference = null, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDefaultRequestData($paymentCode); + $requestParams = $this->getDefaultRequestData($paymentCode, $clientId, $pluginSetId); $requestParams['context']['sequencenumber'] = $this->getSequenceNumber($order); $requestParams['basket'] = $this->getBasketDataFromOrder($order); $requestParams['order'] = $this->getOrderData($order); @@ -31,12 +37,13 @@ public function getDataFromOrder(string $paymentCode, Order $order, string $requ * @param Order $order * @param Order $refund * @param $preAuthUniqueId - * + * @param int|null $clientId + * @param int|null $pluginSetId * @return array */ - public function getPartialRefundData($paymentCode, Order $order, Order $refund, $preAuthUniqueId) + public function getPartialRefundData($paymentCode, Order $order, Order $refund, $preAuthUniqueId, int $clientId = null, int $pluginSetId = null): array { - $requestParams = $this->getDataFromOrder($paymentCode, $order, $preAuthUniqueId); + $requestParams = $this->getDataFromOrder($paymentCode, $order, $preAuthUniqueId, $clientId, $pluginSetId); $requestParams['order'] = $this->getOrderData($refund); diff --git a/src/Providers/DataProviders/Javascript.php b/src/Providers/DataProviders/Javascript.php index 091e77d8..75a24307 100644 --- a/src/Providers/DataProviders/Javascript.php +++ b/src/Providers/DataProviders/Javascript.php @@ -21,7 +21,11 @@ class Javascript * @param CreditcardTypes $creditcardTypes * @param CreditCardStyle $style * @param PaymentHelper $paymentHelper + * @param BasketRepositoryContract $basketRepository * @return string + * @throws \Twig_Error_Loader + * @throws \Twig_Error_Runtime + * @throws \Twig_Error_Syntax */ public function call( Twig $twig, @@ -38,7 +42,6 @@ public function call( PluginConstants::NAME . '::Partials.Javascript', [ 'locale' => $helper->getCurrentLanguage(), - 'isDebugModeEnabled' => $helper->isDebugModeActive(), 'creditcardcheck' => $creditCardCheck, 'allowedCCTypes' => $creditcardTypes->getAllowedTypes(), 'defaultWidthInPx' => $style->getDefaultWidthInPx(), @@ -48,4 +51,4 @@ public function call( ] ); } -} \ No newline at end of file +} diff --git a/src/Providers/PayoneRouteServiceProvider.php b/src/Providers/PayoneRouteServiceProvider.php index 55bebfa5..b0a5a999 100644 --- a/src/Providers/PayoneRouteServiceProvider.php +++ b/src/Providers/PayoneRouteServiceProvider.php @@ -2,6 +2,7 @@ namespace Payone\Providers; +use Payone\Controllers\AmazonPayController; use Plenty\Plugin\RouteServiceProvider; use Plenty\Plugin\Routing\Router; @@ -15,16 +16,19 @@ class PayoneRouteServiceProvider extends RouteServiceProvider */ public function map(Router $router) { + $router->post('payment/payone/status/', 'Payone\Controllers\StatusController@index'); - $router->get('payment/payone/migrate/', 'Payone\Controllers\ConfigController@migrate'); + $router->post('payment/payone/checkout/doAuth/', 'Payone\Controllers\CheckoutController@doAuth'); + $router->post('payment/payone/checkout/storeCCCheckResponse/', 'Payone\Controllers\CheckoutController@storeCCCheckResponse'); + $router->post('payment/payone/checkout/storeAccountData/', 'Payone\Controllers\CheckoutController@storeAccountData'); - $router->post('payment/payone/status/', 'Payone\Controllers\StatusController@index'); + $router->get('payment/payone/checkout/amazonPay/loginButton/', 'Payone\Controllers\AmazonPayController@getAmazonPayLoginWidget'); + $router->post('payment/payone/checkout/amazonPay/renderWidgets/', 'Payone\Controllers\AmazonPayController@renderWidgets'); + $router->post('payment/payone/checkout/amazonPay/getOrderReference/', 'Payone\Controllers\AmazonPayController@getOrderReference'); + $router->get('payment/payone/checkout/amazonPay/placeOrder/', 'Payone\Controllers\AmazonPayController@placeOrder'); - $router->post('payment/payone/checkout/doAuth', 'Payone\Controllers\CheckoutController@doAuth'); - $router->post('payment/payone/checkout/storeCCCheckResponse', 'Payone\Controllers\CheckoutController@storeCCCheckResponse'); - $router->post('payment/payone/checkout/storeAccountData', 'Payone\Controllers\CheckoutController@storeAccountData'); - $router->get('payment/payone/error', 'Payone\Controllers\CheckoutController@redirectWithNotice'); - $router->get('payment/payone/checkoutSuccess', 'Payone\Controllers\CheckoutController@checkoutSuccess'); - $router->get('payment/payone/checkout/getSepaMandateStep', 'Payone\Controllers\CheckoutController@getSepaMandateStep'); + $router->get('payment/payone/error/', 'Payone\Controllers\CheckoutController@redirectWithNotice'); + $router->get('payment/payone/checkoutSuccess/', 'Payone\Controllers\CheckoutController@checkoutSuccess'); + $router->get('payment/payone/checkout/getSepaMandateStep/', 'Payone\Controllers\CheckoutController@getSepaMandateStep'); } } diff --git a/src/Providers/PayoneServiceProvider.php b/src/Providers/PayoneServiceProvider.php old mode 100644 new mode 100755 index 00a07a7f..a1d95fdf --- a/src/Providers/PayoneServiceProvider.php +++ b/src/Providers/PayoneServiceProvider.php @@ -2,11 +2,18 @@ namespace Payone\Providers; +use Ceres\Helper\LayoutContainer; use Payone\Adapter\Logger; +use Payone\Adapter\SessionStorage; +use Payone\Assistants\PayoneAssistant; +use Payone\Hooks\CopyPluginSetHook; +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; @@ -18,33 +25,45 @@ use Payone\Methods\PayonePrePaymentPaymentMethod; use Payone\Methods\PayoneRatePayInstallmentPaymentMethod; use Payone\Methods\PayoneSofortPaymentMethod; +use Payone\Models\Api\GenericPayment\ConfirmOrderReferenceResponse; +use Payone\Models\Api\GenericPayment\SetOrderReferenceDetailsResponse; use Payone\Models\PaymentCache; use Payone\Models\PaymentMethodContent; use Payone\PluginConstants; -use Payone\Services\Capture; +use Payone\Services\AmazonPayService; use Payone\Services\OrderPdf; use Payone\Services\PaymentCreation; use Payone\Services\PaymentService; +use Payone\Services\SettingsService; use Payone\Views\ErrorMessageRenderer; use Payone\Views\PaymentRenderer; -use Plenty\Log\Exceptions\ReferenceTypeException; -use Plenty\Log\Services\ReferenceContainer; use Plenty\Modules\Basket\Contracts\BasketRepositoryContract; use Plenty\Modules\Basket\Events\Basket\AfterBasketChanged; use Plenty\Modules\Basket\Events\Basket\AfterBasketCreate; use Plenty\Modules\Basket\Events\BasketItem\AfterBasketItemAdd; +use Plenty\Modules\Basket\Models\Basket; use Plenty\Modules\Document\Models\Document; use Plenty\Modules\EventProcedures\Services\Entries\ProcedureEntry; use Plenty\Modules\EventProcedures\Services\EventProceduresService; -use Plenty\Modules\Order\Events\OrderCreated; -use Plenty\Modules\Order\Models\OrderType; +use Plenty\Modules\Order\Models\Order; +use Plenty\Modules\Order\Contracts\OrderRepositoryContract; +use Plenty\Modules\Order\Property\Models\OrderPropertyType; 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; +use Plenty\Modules\Plugin\Events\CopyPluginSet; +use Plenty\Modules\Wizard\Contracts\WizardContainerContract; use Plenty\Plugin\Events\Dispatcher; use Plenty\Plugin\ServiceProvider; use Plenty\Modules\Order\Pdf\Events\OrderPdfGenerationEvent; +use Plenty\Plugin\Templates\Twig; +use Plenty\Plugin\Translation\Translator; +use Payone\Methods\PayoneKlarnaDirectBankTransferPaymentMethod; +use Payone\Methods\PayoneKlarnaDirectDebitPaymentMethod; +use Payone\Methods\PayoneKlarnaInstallmentsPaymentMethod; +use Payone\Methods\PayoneKlarnaInvoicePaymentMethod; class PayoneServiceProvider extends ServiceProvider { @@ -58,62 +77,25 @@ 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 - ); + $this->registerPaymentRendering($eventDispatcher, $basket); - $this->registerOrderCreationEvents( - $eventDispatcher, - $paymentHelper, - $logger, - $paymentCreationService, - $paymentCache - ); + $this->registerPaymentExecute($eventDispatcher, $basket); $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 +105,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 +115,13 @@ public function boot( '\Payone\Procedures\RefundEventProcedure@run' ); - $this->registerReferenceTypesForLogging($referenceContainer); - $this->registerInvoicePdfGeneration($eventDispatcher, $paymentHelper, $logger, $orderPdf, $orderHelper); + $this->registerInvoicePdfGeneration($eventDispatcher); + + $this->registerAmazonPayListener($eventDispatcher, $basket); + $eventDispatcher->listen(CopyPluginSet::class, CopyPluginSetHook::class); + + pluginApp(WizardContainerContract::class)->register('payment-payone-assistant', PayoneAssistant::class); } /** @@ -201,57 +187,109 @@ protected function registerPaymentMethods(PaymentMethodContainer $payContainer) PayoneInvoiceSecurePaymentMethod::class, $events ); + + $payContainer->register( + 'Payone::' . PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + PayoneAmazonPayPaymentMethod::class, + $events + ); + $payContainer->register( + 'Payone::' . PayoneKlarnaDirectBankTransferPaymentMethod::PAYMENT_CODE, + PayoneKlarnaDirectBankTransferPaymentMethod::class, + $events + ); + + $payContainer->register( + 'Payone::' . PayoneKlarnaDirectDebitPaymentMethod::PAYMENT_CODE, + PayoneKlarnaDirectDebitPaymentMethod::class, + $events + ); + + $payContainer->register( + 'Payone::' . PayoneKlarnaInstallmentsPaymentMethod::PAYMENT_CODE, + PayoneKlarnaInstallmentsPaymentMethod::class, + $events + ); + + $payContainer->register( + 'Payone::' . PayoneKlarnaInvoicePaymentMethod::PAYMENT_CODE, + PayoneKlarnaInvoicePaymentMethod::class, + $events + ); } /** * @param Dispatcher $eventDispatcher - * @param PaymentHelper $paymentHelper - * @param PaymentService $paymentService - * @param PaymentRenderer $paymentRenderer - * @param PaymentMethodContent $content - * @param Logger $logger + * @param BasketRepositoryContract $basketRepository */ - 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 SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); + /** @var PaymentHelper $paymentHelper */ + $paymentHelper = pluginApp(PaymentHelper::class); + + $basket = $basketRepository->load(); + $logger->setIdentifier(__METHOD__)->info('Event.getPaymentMethodContent'); - $selectedPaymentMopId = $event->getMop(); - if (!$selectedPaymentMopId || !$paymentHelper->isPayonePayment($selectedPaymentMopId)) { + if (!$event->getMop() || !$paymentHelper->isPayonePayment($event->getMop())) { + return; + } elseif ($event->getMop() == $paymentHelper->getMopId(PayoneAmazonPayPaymentMethod::PAYMENT_CODE)) { + $amazonPayActive = $settingsService->getPaymentSettingsValue('active', PayoneAmazonPayPaymentMethod::PAYMENT_CODE); + if (isset($amazonPayActive) && $amazonPayActive == 1) { + $this->registerAmazonPayIntegration($event, $basket); + } return; } - $paymentCode = $paymentHelper->getPaymentCodeByMop($selectedPaymentMopId); + + /** @var PaymentService $paymentService */ + $paymentService = pluginApp(PaymentService::class); + $paymentCode = $paymentHelper->getPaymentCodeByMop($event->getMop()); /** @var PaymentAbstract $payment */ $payment = PaymentMethodServiceFactory::create($paymentCode); + /** @var AddressHelper $addressHelper */ + $addressHelper = pluginApp(AddressHelper::class); + + $billingAddress = $addressHelper->getBasketBillingAddress($basket); + if( $paymentCode == PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE && + (!isset($billingAddress->birthday) || !strlen($billingAddress->birthday)) ) { + + /** @var Translator $translator */ + $translator = pluginApp(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; + } - $renderingType = $content->getPaymentContentType($paymentCode); 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 +298,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); } @@ -268,80 +309,101 @@ function (GetPaymentMethodContent $event) use ( } /** - * @param Dispatcher $eventDispatcher - * @param PaymentHelper $paymentHelper - * @param Logger $logger - * @param Capture $captureService - * @param PaymentCreation $paymentCreationService + * @param Dispatcher $dispatcher + * @param BasketRepositoryContract $basketRepository */ - 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); - if (!($payment instanceof Payment)) { - $message = 'Payment could not be assigned to order.'; - $logger->error($message, $payment); - throw new \Exception($message); + protected function registerPaymentExecute(Dispatcher $dispatcher, BasketRepositoryContract $basketRepository) + { + $dispatcher->listen(ExecutePayment::class, function (ExecutePayment $event) use ($basketRepository){ + /** @var PaymentHelper $paymentHelper */ + $paymentHelper = pluginApp(PaymentHelper::class); + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); + + if($paymentHelper->isPayonePayment($event->getMop())) { + try{ + if($event->getMop() == $paymentHelper->getMopId(PayoneAmazonPayPaymentMethod::PAYMENT_CODE)) { + /** @var PaymentService $paymentService */ + $paymentService = pluginApp(PaymentService::class); + $basket = $basketRepository->load(); + + $auth = $paymentService->openTransaction($basket); + $logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.paymentExecute', [ + "auth" => (array) $auth + ]); + /** @var SessionStorage $sessionStorage */ + $sessionStorage = pluginApp(SessionStorage::class); + $sessionStorage->setSessionValue('clientId', null); + $sessionStorage->setSessionValue('sellerId', null); + $sessionStorage->setSessionValue('workOrderId', null); + $sessionStorage->setSessionValue('accessToken', null); + } + /** @var OrderRepositoryContract $orderRepository */ + $orderRepository = pluginApp(OrderRepositoryContract::class); + /** @var PaymentCache $paymentCache */ + $paymentCache = pluginApp(PaymentCache::class); + + $order = $orderRepository->findOrderById($event->getOrderId()); + if($order instanceof Order) { + if($event->getMop() == $paymentHelper->getMopId(PayoneInvoiceSecurePaymentMethod::PAYMENT_CODE)) { + //Block the invoice generation for secure invoice because there will be an external invoice + $orderRepository->updateOrder([ + 'properties' => [ + [ + 'typeId' => OrderPropertyType::EXTERNAL_TAX_SERVICE, + 'value' => "1" + ] + ] + ], $order->id); + } + + $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); + return; + } + + /** @var PaymentCreation $paymentCreationService */ + $paymentCreationService = pluginApp(PaymentCreation::class); + $paymentCreationService->assignPaymentToOrder($payment, $order); + $paymentCache->deletePayment($event->getMop()); + } + } catch (\Exception $exception){ + $logger + ->setIdentifier(__METHOD__) + ->error('Error in paymentExecute-Event', $exception); } - $paymentCreationService->assignPaymentToOrder($payment, $order); - $paymentCache->deletePayment($selectedPaymentId); } - ); - } + }); - /** - * @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) { + 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 +426,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 ' @@ -382,4 +446,92 @@ function (OrderPdfGenerationEvent $event) use ($paymentHelper, $logger, $orderPd } ); } + + /** + * @param GetPaymentMethodContent $event + * @param Basket $basket + */ + protected function registerAmazonPayIntegration(GetPaymentMethodContent $event, Basket $basket) + { + /** @var AmazonPayService $amazonPayService */ + $amazonPayService = pluginApp(AmazonPayService::class); + /** @var Logger $logger */ + $logger = pluginApp(Logger::class); + /** @var Twig $twig */ + $twig = pluginApp(Twig::class); + /** @var SessionStorage $sessionStorage */ + $sessionStorage = pluginApp(SessionStorage::class); + /** @var PaymentCache $paymentCache */ + $paymentCache = pluginApp(PaymentCache::class); + + try { + $paymentCache->setActiveBasketId($basket->id); + + /** @var SetOrderReferenceDetailsResponse $setOrderRefResponse */ + $setOrderRefResponse = $amazonPayService->setOrderReference($basket); + /** @var ConfirmOrderReferenceResponse $confirmOrderRefResponse */ + $confirmOrderRefResponse = $amazonPayService->confirmOrderReference($basket); + + $event->setValue($twig->render( + PluginConstants::NAME . '::Checkout.Confirmation', + [ + 'success' => $confirmOrderRefResponse->getSuccess(), + 'sellerId' => $sessionStorage->getSessionValue('sellerId'), + 'amazonReferenceId' => $sessionStorage->getSessionValue('amazonReferenceId'), + ] + )); + $event->setType(GetPaymentMethodContent::RETURN_TYPE_HTML); + + $logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.paymentMethodContent', [ + "event" => (array)$event, + "setOrderRefResponse" => (array)$setOrderRefResponse, + "confirmOrderRefResponse" => (array)$confirmOrderRefResponse + ]); + + } catch (\Exception $exception) { + $logger + ->setIdentifier(__METHOD__) + ->error('AmazonPay.paymentMethodContent', $exception); + } + } + + /** + * @param Dispatcher $eventDispatcher + * @param BasketRepositoryContract $basket + */ + protected function registerAmazonPayListener(Dispatcher $eventDispatcher, BasketRepositoryContract $basket) + { + $eventDispatcher->listen( + 'IO.Resources.Import', function ($resourceContainer) use ($basket) { + /** @var SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + if($settingsService->getPaymentSettingsValue('active', PayoneAmazonPayPaymentMethod::PAYMENT_CODE)) { + /** @var PaymentHelper $twig */ + $paymentHelper = pluginApp(PaymentHelper::class); + $amazonPayMopId = $paymentHelper->getMopId(PayoneAmazonPayPaymentMethod::PAYMENT_CODE); + $basketData = $basket->load(); + $resourceContainer->addScriptTemplate( + PluginConstants::NAME . '::Checkout.AmazonPayCheckout', [ + 'selectedPaymentId' => $basketData->methodOfPaymentId, + 'amazonPayMopId' => $amazonPayMopId, + 'sandbox' => (bool)$settingsService->getPaymentSettingsValue('Sandbox', PayoneAmazonPayPaymentMethod::PAYMENT_CODE) + ]); + } + }); + + $eventDispatcher->listen( + "Ceres.LayoutContainer.Checkout.BeforeBillingAddress", + function (LayoutContainer $container) { + /** @var SettingsService $settingsService */ + $settingsService = pluginApp(SettingsService::class); + if($settingsService->getPaymentSettingsValue('active', PayoneAmazonPayPaymentMethod::PAYMENT_CODE)) { + /** @var Twig $twig */ + $twig = pluginApp(Twig::class); + $container->addContent($twig->render(PluginConstants::NAME . '::Checkout.AmazonPayAddressBookWidget')); + } + } + ); + } } diff --git a/src/Services/AmazonPayService.php b/src/Services/AmazonPayService.php new file mode 100644 index 00000000..768ae910 --- /dev/null +++ b/src/Services/AmazonPayService.php @@ -0,0 +1,246 @@ +api = $api; + $this->dataProvider = $dataProvider; + $this->logger = $logger; + } + + /** + * @param GetOrderReferenceDetailsResponse $orderRefDetails + * @param bool $billingAddress + * @return mixed + */ + public function registerCustomerFromAmazonPay(GetOrderReferenceDetailsResponse $orderRefDetails, $billingAddress = false) + { + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.registerCustomer', (array)$orderRefDetails); + + $addressData = []; + $addressData['email'] = $orderRefDetails->getEmail() ?? ""; + + if ($billingAddress) { + $addressData['company'] = $orderRefDetails->getBillingCompany() ?? ""; + $addressData['firstName'] = $orderRefDetails->getBillingFirstname() ?? ""; + $addressData['lastName'] = $orderRefDetails->getBillingLastname() ?? ""; + $addressData['streetAndNumber'] = $orderRefDetails->getBillingStreet() ?? ""; + $addressData['postalCode'] = $orderRefDetails->getBillingZip() ?? ""; + $addressData['city'] = $orderRefDetails->getBillingCity() ?? ""; + $addressData['state'] = $orderRefDetails->getBillingState() ?? ""; + $addressData['countryId'] = $orderRefDetails->getBillingCountry() ?? ""; + $addressData['telNo'] = $orderRefDetails->getBillingTelephonenumber() ?? ""; + } else { + $addressData['company'] = $orderRefDetails->getShippingCompany() ?? ""; + $addressData['firstName'] = $orderRefDetails->getShippingFirstname() ?? ""; + $addressData['lastName'] = $orderRefDetails->getShippingLastname() ?? ""; + $addressData['streetAndNumber'] = $orderRefDetails->getShippingStreet() ?? ""; + $addressData['postalCode'] = $orderRefDetails->getShippingZip() ?? ""; + $addressData['city'] = $orderRefDetails->getShippingCity() ?? ""; + $addressData['state'] = $orderRefDetails->getShippingState() ?? ""; + $addressData['countryId'] = $orderRefDetails->getShippingCountry() ?? ""; + $addressData['telNo'] = $orderRefDetails->getShippingTelephonenumber() ?? ""; + } + + $newAddress = $this->mapAmazonAddressToAddress($addressData); + + /** @var AddressRepositoryContract $contactAddressRepo */ + $addressRepo = pluginApp(AddressRepositoryContract::class); + $createdAddress = $addressRepo->createAddress($newAddress->toArray()); + + return $createdAddress; + } + + + /** + * @param array $amazonAddress + * @return Address + */ + private function mapAmazonAddressToAddress(array $amazonAddress) + { + /** @var Address $address */ + $address = pluginApp(Address::class); + + if (strlen($amazonAddress['company'])) { + $address->name1 = $amazonAddress['company']; + /** @var AddressOption $addressOption */ + $addressOption = pluginApp(AddressOption::class); + + $addressOption->typeId = AddressOption::TYPE_CONTACT_PERSON; + $addressOption->value = $amazonAddress['firstName'] . " " . $amazonAddress['lastName']; + + $address->options->push($addressOption->toArray()); + } + + $address->name2 = $amazonAddress['firstName']; + $address->name3 = $amazonAddress['lastName']; + + /** @var CountryRepositoryContract $countryContract */ + $countryContract = pluginApp(CountryRepositoryContract::class); + + /** @var Country $country */ + $country = $countryContract->getCountryByIso($amazonAddress['countryId'], 'isoCode2'); + + /** @var LibraryCallContract $libCall */ + $libCall = pluginApp(LibraryCallContract::class); + $parsedAddress = $libCall->call(PluginConstants::NAME .'::addressParser', [ + 'address' => $amazonAddress['streetAndNumber'] + ]); + + $address->address1 = $parsedAddress['address1']; + $address->address2 = $parsedAddress['address2']; + if (strlen($parsedAddress['address3'])) { + $address->address3 = $parsedAddress['address3']; + } + $address->town = $amazonAddress['city']; + $address->postalCode = $amazonAddress['postalCode']; + $address->countryId = $country->id; + + if (strlen($amazonAddress['state'])) { + /** @var CountryState $state */ + $state = $countryContract->getCountryStateByIso($country->id, $amazonAddress['state']); + $address->state = $state; + $address->stateId = $state->id; + } + + if (strlen($amazonAddress['telNo'])) { + /** @var AddressOption $addressOption */ + $addressOption = pluginApp(AddressOption::class); + + $addressOption->typeId = AddressOption::TYPE_TELEPHONE; + $addressOption->value = $amazonAddress['telNo']; + + $address->options->push($addressOption->toArray()); + } + if (strlen($amazonAddress['email'])) { + /** @var AddressOption $addressOption */ + $addressOption = pluginApp(AddressOption::class); + + $addressOption->typeId = AddressOption::TYPE_EMAIL; + $addressOption->value = $amazonAddress['email']; + + $address->options->push($addressOption->toArray()); + } + + return $address; + } + + /** + * @param Basket $basket + * @return mixed + */ + public function setOrderReference(Basket $basket) + { + /** @var SessionStorage $sessionStorage */ + $sessionStorage = pluginApp(SessionStorage::class); + $workOrderId = $sessionStorage->getSessionValue('workOrderId'); + $amazonReferenceId = $sessionStorage->getSessionValue('amazonReferenceId'); + + $requestParams = $this->dataProvider->getSetOrderReferenceDetailsRequestData( + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + $workOrderId, + $amazonReferenceId, + $basket->basketAmount, + $basket->currency + ); + + /** @var SetOrderReferenceDetailsResponse $orderReferenceResponse */ + $orderReferenceResponse = $this->api->doGenericPayment(GenericPayment::ACTIONTYPE_SETORDERREFERENCEDETAILS, $requestParams); + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.setOrderReference', [ + "workOrderId" => $workOrderId, + "amazonReferenceId" => $amazonReferenceId, + "requestParams" => $requestParams, + "setOrderReferenceResponse" => (array)$orderReferenceResponse + ]); + + return $orderReferenceResponse; + } + + /** + * @param Basket $basket + * @return mixed + */ + public function confirmOrderReference(Basket $basket) + { + try { + /** @var SessionStorage $sessionStorage */ + $sessionStorage = pluginApp(SessionStorage::class); + + $workOrderId = $sessionStorage->getSessionValue('workOrderId'); + $amazonReferenceId = $sessionStorage->getSessionValue('amazonReferenceId'); + + $requestParams = $this->dataProvider->getConfirmOrderReferenceRequestData( + PayoneAmazonPayPaymentMethod::PAYMENT_CODE, + $workOrderId, + $basket->id, + $amazonReferenceId, + $basket->basketAmount, + $basket->currency, + $basket->id + ); + + /** @var ConfirmOrderReferenceResponse $confirmOrderReferenceResponse */ + $confirmOrderReferenceResponse = $this->api->doGenericPayment(GenericPayment::ACTIONTYPE_CONFIRMORDERREFERENCE, $requestParams); + + $this->logger + ->setIdentifier(__METHOD__) + ->debug('AmazonPay.confirmOrderReference', [ + "workOrderId" => $workOrderId, + "amazonReferenceId" => $amazonReferenceId, + "requestParams" => $requestParams, + "confirmOrderReferenceResponse" => (array)$confirmOrderReferenceResponse + ]); + + return $confirmOrderReferenceResponse; + } catch (\Exception $exception) { + $this->logger + ->setIdentifier(__METHOD__) + ->error('AmazonPay.confirmOrderReference', $exception); + + return $exception; + } + } +} diff --git a/src/Services/Api.php b/src/Services/Api.php index 4599c876..7d4ea261 100644 --- a/src/Services/Api.php +++ b/src/Services/Api.php @@ -5,6 +5,10 @@ use Payone\Adapter\Logger; use Payone\Models\Api\AuthResponse; use Payone\Models\Api\AuthResponseFactory; +use Payone\Models\Api\GenericPayment\GenericPaymentResponseFactory; +use Payone\Models\Api\GenericPayment\GetConfigurationResponse; +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; @@ -12,6 +16,7 @@ use Payone\Models\Api\Response; use Payone\Models\Api\ResponseFactory; use Payone\PluginConstants; +use Payone\Providers\Api\Request\Models\GenericPayment; use Plenty\Modules\Plugin\Libs\Contracts\LibraryCallContract; /** @@ -31,6 +36,8 @@ class Api const REQUEST_TYPE_CALCULATION = 'Calculation'; const REQUEST_TYPE_DEBIT = 'Debit'; const REQUEST_TYPE_MANAGEMANDATE = 'Managemandate'; + const REQUEST_TYPE_INVOICE = 'GetDocument'; + const REQUEST_TYPE_GENERIC_PAYMENT = 'GenericPayment'; /** * @var LibraryCallContract @@ -67,10 +74,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 +96,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 +116,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 +136,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 +156,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 +174,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 +192,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,8 +210,46 @@ 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; + } + + /** + * @param string $actionType + * @param array $requestParams + * @return mixed + */ + public function doGenericPayment(string $actionType, array $requestParams) + { + $response = $this->doLibCall(self::REQUEST_TYPE_GENERIC_PAYMENT, $requestParams); + $responseObject = GenericPaymentResponseFactory::create($actionType, $response); + + $this->logger + ->setIdentifier(__METHOD__) + ->addReference('requestType', self::REQUEST_TYPE_GENERIC_PAYMENT) + ->debug('AmazonPay.apiCall', [ + 'actionType' => $actionType, + 'requestParams' => $requestParams, + 'response' => $response, + 'responseObject' => $responseObject + ]); return $responseObject; } @@ -216,8 +262,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..1dd24c1f 100644 --- a/src/Services/Auth.php +++ b/src/Services/Auth.php @@ -2,15 +2,12 @@ namespace Payone\Services; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Adapter\Logger; use Payone\Helpers\PaymentHelper; use Payone\Models\Api\AuthResponse; -use Payone\Models\Api\Response; use Payone\Models\PaymentCache; use Payone\Providers\Api\Request\AuthDataProvider; use Plenty\Modules\Basket\Models\Basket; -use Plenty\Modules\Order\Contracts\OrderRepositoryContract; use Plenty\Modules\Payment\Models\Payment; class Auth @@ -18,50 +15,52 @@ class Auth /** * @var PaymentHelper */ - private $paymentHelper; + protected $paymentHelper; + /** * @var Logger */ - private $logger; + protected $logger; /** * @var PaymentCreation */ - private $paymentCreationService; + protected $paymentCreationService; /** - * @var ConfigAdapter + * @var SettingsService */ - private $config; + protected $settingsService; + /** * @var PaymentCache */ - private $paymentCache; + protected $paymentCache; /** * @var AuthDataProvider */ - private $authDataProvider; + protected $authDataProvider; + /** * @var Api */ - private $api; + protected $api; /** - * ReAuth constructor. + * Auth constructor. * * @param PaymentHelper $paymentHelper * @param Logger $logger * @param PaymentCreation $paymentCreation - * @param OrderRepositoryContract $orderRepositoryContract - * @param ConfigAdapter $config * @param PaymentCache $paymentCache + * @param Api $api + * @param AuthDataProvider $authDataProvider */ public function __construct( PaymentHelper $paymentHelper, Logger $logger, PaymentCreation $paymentCreation, - ConfigAdapter $config, PaymentCache $paymentCache, Api $api, AuthDataProvider $authDataProvider @@ -69,7 +68,6 @@ public function __construct( $this->paymentHelper = $paymentHelper; $this->logger = $logger; $this->paymentCreationService = $paymentCreation; - $this->config = $config; $this->paymentCache = $paymentCache; $this->api = $api; $this->authDataProvider = $authDataProvider; @@ -77,10 +75,10 @@ public function __construct( /** * @param Basket $basket - * * @return AuthResponse + * @throws \Exception */ - public function executeAuth(Basket $basket) + public function executeAuth(Basket $basket): AuthResponse { $selectedPaymentId = $basket->methodOfPaymentId; @@ -92,6 +90,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; } @@ -99,10 +98,7 @@ public function executeAuth(Basket $basket) /** * @param $selectedPaymentId * @param AuthResponse $authResponse - * @param $orderId - * * @throws \Exception - * * @return Payment */ private function createPayment($selectedPaymentId, $authResponse, $basket): Payment @@ -127,12 +123,10 @@ private function createPayment($selectedPaymentId, $authResponse, $basket): Paym /** * @param Basket $basket - * * @throws \Exception - * * @return AuthResponse */ - private function doAuthFromBasket(Basket $basket) + private function doAuthFromBasket(Basket $basket): AuthResponse { $selectedPaymentId = $basket->methodOfPaymentId; $paymentCode = $this->paymentHelper->getPaymentCodeByMop($selectedPaymentId); @@ -142,6 +136,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/Capture.php b/src/Services/Capture.php index c6873569..ea7f4218 100644 --- a/src/Services/Capture.php +++ b/src/Services/Capture.php @@ -2,7 +2,6 @@ namespace Payone\Services; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Adapter\Logger; use Payone\Adapter\PaymentHistory; use Payone\Helpers\PaymentHelper; @@ -17,36 +16,37 @@ class Capture /** * @var PaymentRepositoryContract */ - private $paymentRepository; + protected $paymentRepository; + /** * @var PaymentHelper */ - private $paymentHelper; + protected $paymentHelper; + /** * @var Logger */ - private $logger; + protected $logger; + /** * @var PaymentHistory */ - private $paymentHistory; + protected $paymentHistory; - /** - * @var ConfigAdapter - */ - private $config; /** * @var CaptureDataProvider */ - private $captureDataProvider; + protected $captureDataProvider; + /** * @var Api */ - private $api; + protected $api; + /** * @var PaymentCreation */ - private $paymentCreation; + protected $paymentCreation; /** * Capture constructor. @@ -55,7 +55,6 @@ class Capture * @param PaymentHelper $paymentHelper * @param Logger $logger * @param PaymentHistory $paymentHistory - * @param ConfigAdapter $config * @param CaptureDataProvider $captureDataProvider * @param Api $api * @param PaymentCreation $paymentCreation @@ -65,7 +64,6 @@ public function __construct( PaymentHelper $paymentHelper, Logger $logger, PaymentHistory $paymentHistory, - ConfigAdapter $config, CaptureDataProvider $captureDataProvider, Api $api, PaymentCreation $paymentCreation @@ -74,7 +72,6 @@ public function __construct( $this->paymentHelper = $paymentHelper; $this->logger = $logger; $this->paymentHistory = $paymentHistory; - $this->config = $config; $this->captureDataProvider = $captureDataProvider; $this->api = $api; $this->paymentCreation = $paymentCreation; @@ -122,7 +119,7 @@ public function doCapture(Order $order) } $paymentCode = $this->paymentHelper->getPaymentCodeByMop($payment->mopId); - $requestData = $this->captureDataProvider->getDataFromOrder($paymentCode, $order, $preAuthReference); + $requestData = $this->captureDataProvider->getDataFromOrder($paymentCode, $order, $preAuthReference, $order->plentyId); $captureOrderResult = $this->api->doCapture($requestData); $text = 'Capture done. Transaction Id: ' . $captureOrderResult->getTransactionID(); diff --git a/src/Services/OrderPdf.php b/src/Services/OrderPdf.php index 2a2e3e62..a5f8dd76 100644 --- a/src/Services/OrderPdf.php +++ b/src/Services/OrderPdf.php @@ -2,7 +2,6 @@ namespace Payone\Services; -use Payone\Adapter\Config as ConfigAdapter; use Payone\Adapter\Translator; use Payone\Helpers\PaymentHelper; use Plenty\Modules\Order\Pdf\Models\OrderPdfGeneration; @@ -16,16 +15,12 @@ class OrderPdf /** * @var PaymentHelper */ - private $paymentHelper; + protected $paymentHelper; - /** - * @var ConfigAdapter - */ - private $configRepo; /** * @var Translator */ - private $translator; + protected $translator; /** * OrderPdf constructor. @@ -42,7 +37,6 @@ public function __construct(PaymentHelper $paymentHelper, Translator $translator /** * @param Payment $payment * @param string $lang - * * @return OrderPdfGeneration|void */ public function createPdfNote(Payment $payment, $lang = 'de') @@ -66,12 +60,10 @@ public function createPdfNote(Payment $payment, $lang = 'de') } /** - * @param string $currency - * @param string $lang - * + * @param Payment $payment * @return string */ - private function getPayoneBankAccount(Payment $payment) + private function getPayoneBankAccount(Payment $payment): string { $iban = $this->paymentHelper->getPaymentPropertyValue($payment, PaymentProperty::TYPE_IBAN_OF_RECEIVER);; @@ -90,11 +82,10 @@ private function getPayoneBankAccount(Payment $payment) /** - * @param $payment - * + * @param Payment $payment * @return string */ - private function getPaymentReferenceText($payment): string + private function getPaymentReferenceText(Payment $payment): string { $referenceNumber = $this->paymentHelper->getPaymentPropertyValue( $payment, diff --git a/src/Services/PaymentCreation.php b/src/Services/PaymentCreation.php index b8c15fe3..cdfea200 100644 --- a/src/Services/PaymentCreation.php +++ b/src/Services/PaymentCreation.php @@ -12,6 +12,7 @@ use Payone\Models\PayonePaymentStatus; use Payone\Providers\Api\Request\PreAuthDataProvider; use Plenty\Modules\Basket\Models\Basket; +use Plenty\Modules\Frontend\Contracts\CurrencyExchangeRepositoryContract; use Plenty\Modules\Order\Models\Order; use Plenty\Modules\Payment\Contracts\PaymentOrderRelationRepositoryContract; use Plenty\Modules\Payment\Contracts\PaymentRepositoryContract; @@ -90,8 +91,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, @@ -123,6 +134,19 @@ public function createPayment($mopId, ResponseAbstract $response, Basket $basket $payment->receivedAt = date('Y-m-d H:i:s'); } + + /** @var CurrencyExchangeRepositoryContract $currencyService */ + $currencyService = pluginApp(CurrencyExchangeRepositoryContract::class); + + $defaultCurrency = $currencyService->getDefaultCurrency(); + + //when a payment is placed in a foreign currency, we save the foreign amount, + // foreign currency sign, exchange ratio and isSystemCurrency set to 0 + if ($payment->currency != $defaultCurrency) { + $payment->exchangeRatio = $currencyService->getExchangeRatioByCurrency($payment->currency); + $payment->isSystemCurrency = 0; + } + $payment->type = 'credit'; $paymentProperties = []; @@ -132,10 +156,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 +176,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 +236,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, @@ -207,11 +244,20 @@ public function capturePayment(Payment $payment, Order $order) ); $payment->updateOrderPaymentStatus = true; - $orderData = $order->toArray(); - $payment->currency = $orderData['amounts'][0]['currency']; - $payment->amount = $orderData['amounts'][0]['grossTotal']; + $payment->currency = $order->amount->currency; + $payment->amount = $order->amount->invoiceTotal; $payment->receivedAt = date('Y-m-d H:i:s'); + /** @var CurrencyExchangeRepositoryContract $currencyService */ + $currencyService = pluginApp(CurrencyExchangeRepositoryContract::class); + + $defaultCurrency = $currencyService->getDefaultCurrency(); + + if ($payment->currency != $defaultCurrency) { + $payment->exchangeRatio = $order->amount->exchangeRate; + $payment->isSystemCurrency = $order->amount->isSystemCurrency; + } + $payment = $this->paymentRepository->updatePayment($payment); return $payment; @@ -227,7 +273,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 +320,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 +333,7 @@ public function createRefundPayment($paymentId, $response, $currency, $grandTota ] ); - $transactionID = $response->getTransactionID(); + $transactionID = $response->getTransactionID() . '_' . $refundId; /** @var Payment $payment */ $payment = pluginApp(Payment::class); @@ -300,7 +346,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 +354,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 +375,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 +404,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 +455,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 +471,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 +481,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 +534,7 @@ private function createOrUpdatePaymentProperty($payment, $pamentPropertyTypeId, } if ($property->typeId === $pamentPropertyTypeId) { $this->logger->debug( - 'PaymentCreation.updatingPayment', + 'Payment.updatingPayment', [ 'property' => $pamentPropertyTypeId, 'oldValue' => $property->value, @@ -487,7 +547,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..0ec57d91 100644 --- a/src/Services/PaymentService.php +++ b/src/Services/PaymentService.php @@ -1,10 +1,8 @@ authService = $authService; $this->preAuthService = $preAuthService; $this->responseCache = $responseCache; - $this->config = $config; + $this->settingsService = $settingsService; $this->paymentHelper = $paymentHelper; } /** * @param Basket $basket - * * @throws \Exception - * * @return AuthResponse|PreAuthResponse */ public function openTransaction(Basket $basket) { - $authType = $this->config->get('authType'); $selectedPaymentMopId = $basket->methodOfPaymentId; if (!$selectedPaymentMopId || !$this->paymentHelper->isPayonePayment($selectedPaymentMopId)) { throw new \Exception( 'Can no initialize payment. Not a Payone payment method' ); } + $authType = $this->settingsService->getPaymentSettingsValue('authType', $this->paymentHelper->getPaymentCodeByMop($selectedPaymentMopId)); + if(!isset($authType) || $authType == -1) { + $authType = $this->settingsService->getSettingsValue('authType'); + } if ($authType == self::AUTH_TYPE_AUTH) { $authResponse = $this->authService->executeAuth($basket); } else { @@ -88,7 +89,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..06850906 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,36 @@ 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 = 'Refund fehlgeschlagen. Fehler im Log'; 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 +219,7 @@ public function executeRefund(Order $order) private function createRefundPayment( $mopId, $payment, - Order $order, + Order $refund, $transaction ) { /* @var Payment $debitPayment */ @@ -210,17 +227,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 +246,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,19 +259,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, $refund->plentyId); } } - $requestData = $this->refundDataProvider->getDataFromOrder($paymentCode, $order, $preAuthUniqueId); - + $requestData = $this->refundDataProvider->getDataFromOrder($paymentCode, $refund, $preAuthUniqueId, $refund->plentyId); return $this->api->doDebit($requestData); } @@ -281,12 +298,11 @@ private function refundCreditMemo($payment, Order $order, Order $refund, $preAut if ($paymentCode == PayoneCCPaymentMethod::PAYMENT_CODE) { if (!$payment->amount) {// already captured? - return $this->reverseAuth($order, $payment, $preAuthUniqueId); + return $this->reverseAuth($order, $payment, $preAuthUniqueId, $order->plentyId); } } - $requestData = $this->refundDataProvider->getPartialRefundData($paymentCode, $order, $refund, $preAuthUniqueId); - + $requestData = $this->refundDataProvider->getPartialRefundData($paymentCode, $order, $refund, $preAuthUniqueId, $order->plentyId); return $this->api->doDebit($requestData); } @@ -376,12 +392,12 @@ private function getAllowedOrderTypes() * @param Order $order * @param Payment $payment * @param $authTransactionId - * - * @throws \Exception - * + * @param int|null $clientId + * @param int|null $pluginSetId * @return Response + * @throws \Exception */ - private function reverseAuth(Order $order, Payment $payment, $authTransactionId) + private function reverseAuth(Order $order, Payment $payment, $authTransactionId, int $clientId = null, int $pluginSetId = null) { $amount = $order->amounts[0]; $originalAmount = $amount->invoiceTotal; @@ -389,7 +405,7 @@ private function reverseAuth(Order $order, Payment $payment, $authTransactionId) $paymentCode = $this->paymentHelper->getPaymentCodeByMop($payment->mopId); - $requestData = $this->captureDataProvider->getDataFromOrder($paymentCode, $order, $authTransactionId); + $requestData = $this->captureDataProvider->getDataFromOrder($paymentCode, $order, $authTransactionId, $clientId, $pluginSetId); $amount->invoiceTotal = $originalAmount; return $this->api->doCapture($requestData); diff --git a/src/Services/SettingsService.php b/src/Services/SettingsService.php new file mode 100644 index 00000000..9e98b011 --- /dev/null +++ b/src/Services/SettingsService.php @@ -0,0 +1,174 @@ +database = $database; + $this->cachingRepository = $cachingRepository; + } + + /** + * @param int|null $clientId + * @param int|null $pluginSetId + * @return Settings|null + */ + public function getSettings(int $clientId = null, int $pluginSetId = null) + { + if (is_null($clientId)) { + /** @var Application $application */ + $application = pluginApp(Application::class); + $clientId = $application->getPlentyId(); + } + + if (is_null($pluginSetId)) { + /** @var PluginSetRepositoryContract $pluginSetRepositoryContract */ + $pluginSetRepositoryContract = pluginApp(PluginSetRepositoryContract::class); + $pluginSetId = $pluginSetRepositoryContract->getCurrentPluginSetId(); + } + + if (!$this->cachingRepository->has(self::CACHING_KEY_SETTINGS . '_' . $clientId . '_' . $pluginSetId)) { + /** @var Settings[] $setting */ + $setting = $this->database->query(Settings::class) + ->where('clientId', '=', $clientId) + ->where('pluginSetId', '=', $pluginSetId) + ->limit(1) + ->get(); + if(is_array($setting) && $setting[0] instanceof Settings) { + $this->cachingRepository->add(self::CACHING_KEY_SETTINGS . '_' . $clientId . '_' . $pluginSetId, $setting[0], 1440); //One day + return $setting[0]; + } + } + + return $this->cachingRepository->get(self::CACHING_KEY_SETTINGS . '_' . $clientId . '_' . $pluginSetId, null); + } + + /** + * @param string $settingsKey + * @param int|null $clientId + * @param int|null $pluginSetId + * @return mixed|null + */ + public function getSettingsValue(string $settingsKey, int $clientId = null, int $pluginSetId = null) + { + $settings = $this->getSettings($clientId, $pluginSetId); + if(!is_null($settings)) { + if(isset($settings->value[$settingsKey])) { + return $settings->value[$settingsKey]; + } + } + return null; + } + + /** + * @param string $settingsKey + * @param string $paymentKey + * @param int|null $clientId + * @param int|null $pluginSetId + * @return mixed|null + */ + public function getPaymentSettingsValue(string $settingsKey, string $paymentKey, int $clientId = null, int $pluginSetId = null) + { + $settings = $this->getSettingsValue('payoneMethods', $clientId, $pluginSetId); + if(!is_null($settings)) { + if(isset($settings[$paymentKey][$settingsKey])) { + return $settings[$paymentKey][$settingsKey]; + } + } + return null; + } + + /** + * @return array + */ + public function getAllAccountSettings(): array + { + /** @var Settings[] $setting */ + $settings = $this->database->query(Settings::class)->get(); + + $accountSettings = []; + /** @var Settings $setting */ + foreach ($settings as $setting) { + $accountSettings[$setting->clientId][$setting->pluginSetId] = $setting->value; + } + + return $accountSettings; + } + + /** + * @param array $data + * @param int|null $clientId + * @param int|null $pluginSetId + * @return \Plenty\Modules\Plugin\DataBase\Contracts\Model|Settings + */ + public function updateOrCreateSettings(array $data, int $clientId = null, int $pluginSetId = null) + { + /** @var Settings[] $settings */ + $settings = $this->getSettings($clientId, $pluginSetId); + + if (!$settings instanceof Settings) { + /** @var Settings $settings */ + $settings = pluginApp(Settings::class); + $settings->clientId = $clientId; + $settings->pluginSetId = $pluginSetId; + $settings->createdAt = (string)Carbon::now(); + } + + $settings = $settings->updateValues($data); + $this->cachingRepository->forget(self::CACHING_KEY_SETTINGS . '_' . $clientId . '_' . $pluginSetId); + return $settings; + } + + /** + * @param int $clientId + * @param int $pluginSetId + * @return bool + */ + public function deleteSettings(int $clientId, int $pluginSetId): bool + { + $settings = $this->getSettings($clientId, $pluginSetId); + + if ($settings instanceof Settings) { + $this->cachingRepository->forget(self::CACHING_KEY_SETTINGS . '_' . $clientId . '_' . $pluginSetId); + return $this->database->delete($settings); + } + + return false; + } + + /** + * @param int $pluginSetId + * @return Settings[]|array|\Plenty\Modules\Plugin\DataBase\Contracts\Model[] + */ + public function getAllSettingsForPluginSetId(int $pluginSetId) + { + return $this->database->query(Settings::class)->where('pluginSetId', $pluginSetId)->get(); + } +} 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() ] ); } diff --git a/translation.json b/translation.json new file mode 100644 index 00000000..8312a757 --- /dev/null +++ b/translation.json @@ -0,0 +1,26 @@ +{ + "sections": + [ + { + "name": "MultilingualismConfig.paymentMethod", + "prefix": "paymentMethod" + }, + { + "name": "MultilingualismConfig.template", + "prefix": "template" + } + ], + "ignoredTranslationFiles": + [ + "AmazonPay.properties", + "Api.properties", + "Assistant.properties", + "Controller.properties", + "Event.properties", + "EventProcedure.properties", + "General.properties", + "Invoice.properties", + "Payment.properties", + "MultilingualismConfig.properties" + ] +}