From 97160c6a381e7e599857667562cd200a4f76e352 Mon Sep 17 00:00:00 2001 From: Novalnet-Technic Date: Fri, 15 Sep 2023 12:53:11 +0530 Subject: [PATCH] first commit --- Api/NNRepositoryInterface.php | 146 + Block/Adminhtml/Button/Control.php | 178 ++ .../Sales/Order/View/Tab/Instalment.php | 263 ++ .../Order/View/Tab/ZeroAmountBooking.php | 198 ++ Block/Checkout/Cart/Shortcut.php | 99 + Block/Checkout/Cart/ShortcutButtonsConfig.php | 99 + Block/Form/Cashpayment.php | 91 + Block/Form/Cc.php | 178 ++ Block/Form/Invoice.php | 91 + Block/Form/InvoiceGuarantee.php | 109 + Block/Form/InvoiceInstalment.php | 179 ++ Block/Form/Multibanco.php | 91 + Block/Form/Prepayment.php | 91 + Block/Form/Sepa.php | 119 + Block/Form/SepaGuarantee.php | 109 + Block/Form/SepaInstalment.php | 179 ++ Block/Info/Alipay.php | 98 + Block/Info/Applepay.php | 98 + Block/Info/Bancontact.php | 98 + Block/Info/Banktransfer.php | 98 + Block/Info/Blik.php | 98 + Block/Info/Cashpayment.php | 108 + Block/Info/Cc.php | 98 + Block/Info/Eps.php | 98 + Block/Info/Giropay.php | 98 + Block/Info/Googlepay.php | 98 + Block/Info/Ideal.php | 98 + Block/Info/Invoice.php | 108 + Block/Info/InvoiceGuarantee.php | 108 + Block/Info/InvoiceInstalment.php | 127 + Block/Info/Multibanco.php | 108 + Block/Info/OnlineBanktransfer.php | 98 + Block/Info/Paypal.php | 98 + Block/Info/PostFinance.php | 98 + Block/Info/PostFinanceCard.php | 94 + Block/Info/Prepayment.php | 108 + Block/Info/Przelewy.php | 98 + Block/Info/Sepa.php | 98 + Block/Info/SepaGuarantee.php | 98 + Block/Info/SepaInstalment.php | 117 + Block/Info/Trustly.php | 98 + Block/Info/Wechatpay.php | 98 + Block/Onepage/Success/Message.php | 115 + .../Config/Form/Field/CreditcardStyle.php | 105 + Block/System/Config/Form/Field/Disabled.php | 52 + .../Config/Form/Field/Guaranteeforce.php | 51 + .../Config/Form/Field/ModuleVersion.php | 70 + .../System/Config/Form/Field/Notification.php | 110 + .../Config/Form/Field/VendorAutoConfig.php | 72 + Block/System/Config/Form/Field/WebhookURL.php | 170 ++ Block/VendorAutoConfig.php | 117 + Controller/Adminhtml/Sales/Instalment.php | 97 + Controller/Adminhtml/Sales/OrderCapture.php | 181 ++ Controller/Adminhtml/Sales/Refund.php | 209 ++ .../Adminhtml/Sales/ZeroAmountBookingTab.php | 97 + .../Adminhtml/Sales/ZeroAmountUpdate.php | 352 +++ Controller/Redirect/Failure.php | 175 ++ Controller/Redirect/Success.php | 189 ++ Gateway/Config/CanInitializeHandler.php | 61 + .../Config/OrderPlaceRedirectUrlHandler.php | 63 + Gateway/Config/PaymentActionHandler.php | 75 + Gateway/Http/Client/TransactionAuthorize.php | 118 + Gateway/Http/Client/TransactionCapture.php | 104 + Gateway/Http/Client/TransactionInitialize.php | 108 + Gateway/Http/Client/TransactionRedirect.php | 37 + Gateway/Http/Client/TransactionRefund.php | 98 + Gateway/Http/Client/TransactionVoid.php | 101 + Gateway/Http/TransferFactory.php | 55 + Gateway/Request/AbstractDataBuilder.php | 504 ++++ Gateway/Request/AuthorizationDataBuilder.php | 60 + Gateway/Request/CaptureDataBuilder.php | 73 + Gateway/Request/InitializeDataBuilder.php | 34 + .../Request/RedirectAuthorizeDataBuilder.php | 34 + Gateway/Request/RefundDataBuilder.php | 34 + Gateway/Request/VoidDataBuilder.php | 47 + Gateway/Response/CcPaymentHandler.php | 140 + Gateway/Response/PaymentHandler.php | 286 ++ Gateway/Response/RedirectAuthorizeHandler.php | 73 + Gateway/Response/RefundHandler.php | 124 + Gateway/Response/VoidHandler.php | 106 + Gateway/Validator/ResponseCodeValidator.php | 48 + Helper/Request.php | 1265 ++++++++ LICENSE.txt | 52 + Logger/Handler/NovalnetDebug.php | 37 + Logger/Handler/NovalnetError.php | 40 + Logger/Handler/NovalnetNotice.php | 37 + Logger/NovalnetLogger.php | 26 + Model/Adminhtml/Source/Activemethods.php | 100 + .../Adminhtml/Source/ApplepayButtonStyle.php | 85 + .../Adminhtml/Source/ApplepayButtonTheme.php | 49 + .../Adminhtml/Source/ApplepayEnabledPages.php | 53 + Model/Adminhtml/Source/CcCardTypes.php | 77 + Model/Adminhtml/Source/CustomerGroups.php | 46 + .../Adminhtml/Source/GooglepayButtonTheme.php | 46 + .../Adminhtml/Source/GooglepayButtonType.php | 66 + .../Source/GooglepayEnabledPages.php | 53 + Model/Adminhtml/Source/InstalmentCycles.php | 51 + Model/Adminhtml/Source/PaymentAction.php | 44 + .../Source/PaymentActionWithZeroAmount.php | 49 + Model/Callback.php | 63 + Model/NNConfig.php | 324 +++ Model/NNRepository.php | 2545 +++++++++++++++++ Model/ResourceModel/Callback.php | 36 + Model/ResourceModel/Callback/Collection.php | 36 + Model/ResourceModel/TransactionStatus.php | 36 + .../TransactionStatus/Collection.php | 36 + Model/TransactionStatus.php | 67 + Model/Ui/ConfigProvider.php | 571 ++++ Observer/DataAssignObserver.php | 406 +++ Observer/OrderPlacebefore.php | 74 + Observer/PaymentMethodIsActive.php | 198 ++ Observer/ProcessCaptureAction.php | 164 ++ Observer/ProcessNovalnetPayment.php | 160 ++ Observer/SavePaymentDataForRecurring.php | 118 + Observer/SetPaymentDataForRecurring.php | 88 + Observer/SetVoidStatus.php | 60 + Observer/ShortcutButtons.php | 57 + Observer/SubscriptionSupportedPayments.php | 60 + Plugin/Checkout/LayoutProcessor.php | 71 + Setup/Patch/Data/RemoveAccessKey.php | 234 ++ composer.json | 16 + etc/adminhtml/di.xml | 26 + etc/adminhtml/routes.xml | 28 + etc/adminhtml/system.xml | 65 + etc/adminhtml/system/novalnet_alipay.xml | 90 + etc/adminhtml/system/novalnet_applepay.xml | 109 + etc/adminhtml/system/novalnet_bancontact.xml | 90 + .../system/novalnet_banktransfer.xml | 90 + etc/adminhtml/system/novalnet_blik.xml | 90 + etc/adminhtml/system/novalnet_cashpayment.xml | 101 + etc/adminhtml/system/novalnet_cc.xml | 135 + .../system/novalnet_documentation.xml | 33 + etc/adminhtml/system/novalnet_eps.xml | 90 + etc/adminhtml/system/novalnet_giropay.xml | 90 + .../system/novalnet_global_config.xml | 104 + etc/adminhtml/system/novalnet_googlepay.xml | 119 + etc/adminhtml/system/novalnet_ideal.xml | 90 + etc/adminhtml/system/novalnet_invoice.xml | 115 + .../system/novalnet_invoice_guarantee.xml | 125 + .../system/novalnet_invoice_instalment.xml | 125 + etc/adminhtml/system/novalnet_multibanco.xml | 95 + .../system/novalnet_online_banktransfer.xml | 90 + .../system/novalnet_payment_notice.xml | 27 + etc/adminhtml/system/novalnet_paypal.xml | 112 + etc/adminhtml/system/novalnet_postfinance.xml | 90 + .../system/novalnet_postfinance_card.xml | 90 + etc/adminhtml/system/novalnet_prepayment.xml | 101 + etc/adminhtml/system/novalnet_przelewy.xml | 90 + etc/adminhtml/system/novalnet_sepa.xml | 116 + .../system/novalnet_sepa_guarantee.xml | 134 + .../system/novalnet_sepa_instalment.xml | 137 + etc/adminhtml/system/novalnet_trustly.xml | 90 + etc/adminhtml/system/novalnet_wechatpay.xml | 90 + etc/config.xml | 538 ++++ etc/csp_whitelist.xml | 39 + etc/db_schema.xml | 58 + etc/di.xml | 2250 +++++++++++++++ etc/email_templates.xml | 25 + etc/events.xml | 53 + etc/frontend/di.xml | 33 + etc/frontend/routes.xml | 28 + etc/module.xml | 30 + etc/webapi.xml | 101 + i18n/de_DE.csv | 358 +++ i18n/en_US.csv | 354 +++ registration.php | 24 + .../layout/adminhtml_system_config_edit.xml | 31 + .../layout/sales_order_create_index.xml | 26 + view/adminhtml/layout/sales_order_view.xml | 37 + view/adminhtml/requirejs-config.js | 28 + .../config/webhooks_configuration.phtml | 90 + .../templates/form/Cashpayment.phtml | 50 + view/adminhtml/templates/form/Cc.phtml | 135 + view/adminhtml/templates/form/Invoice.phtml | 53 + .../templates/form/InvoiceGuarantee.phtml | 77 + .../templates/form/InvoiceInstalment.phtml | 106 + .../adminhtml/templates/form/Multibanco.phtml | 50 + .../adminhtml/templates/form/Prepayment.phtml | 53 + view/adminhtml/templates/form/Sepa.phtml | 103 + .../templates/form/SepaGuarantee.phtml | 117 + .../templates/form/SepaInstalment.phtml | 146 + view/adminhtml/templates/info/Alipay.phtml | 63 + view/adminhtml/templates/info/Applepay.phtml | 75 + .../adminhtml/templates/info/Bancontact.phtml | 63 + .../templates/info/Banktransfer.phtml | 63 + view/adminhtml/templates/info/Blik.phtml | 63 + .../templates/info/Cashpayment.phtml | 90 + view/adminhtml/templates/info/Cc.phtml | 87 + view/adminhtml/templates/info/Eps.phtml | 63 + view/adminhtml/templates/info/Giropay.phtml | 63 + view/adminhtml/templates/info/Googlepay.phtml | 75 + view/adminhtml/templates/info/Ideal.phtml | 63 + view/adminhtml/templates/info/Invoice.phtml | 120 + .../templates/info/InvoiceGuarantee.phtml | 106 + .../templates/info/InvoiceInstalment.phtml | 116 + .../adminhtml/templates/info/Multibanco.phtml | 49 + .../templates/info/OnlineBanktransfer.phtml | 63 + view/adminhtml/templates/info/Paypal.phtml | 75 + .../templates/info/PostFinance.phtml | 75 + .../templates/info/PostFinanceCard.phtml | 75 + .../adminhtml/templates/info/Prepayment.phtml | 106 + view/adminhtml/templates/info/Przelewy.phtml | 63 + view/adminhtml/templates/info/Sepa.phtml | 97 + .../templates/info/SepaGuarantee.phtml | 81 + .../templates/info/SepaInstalment.phtml | 87 + view/adminhtml/templates/info/Trustly.phtml | 63 + view/adminhtml/templates/info/Wechatpay.phtml | 63 + .../templates/payment/vendorConfig.phtml | 61 + view/adminhtml/templates/pdf/Alipay.phtml | 63 + view/adminhtml/templates/pdf/Applepay.phtml | 75 + view/adminhtml/templates/pdf/Bancontact.phtml | 63 + .../templates/pdf/Banktransfer.phtml | 63 + view/adminhtml/templates/pdf/Blik.phtml | 63 + .../adminhtml/templates/pdf/Cashpayment.phtml | 90 + view/adminhtml/templates/pdf/Cc.phtml | 88 + view/adminhtml/templates/pdf/Eps.phtml | 63 + view/adminhtml/templates/pdf/Giropay.phtml | 63 + view/adminhtml/templates/pdf/Googlepay.phtml | 75 + view/adminhtml/templates/pdf/Ideal.phtml | 63 + view/adminhtml/templates/pdf/Invoice.phtml | 122 + .../templates/pdf/InvoiceGuarantee.phtml | 105 + .../templates/pdf/InvoiceInstalment.phtml | 115 + view/adminhtml/templates/pdf/Multibanco.phtml | 49 + .../templates/pdf/OnlineBanktransfer.phtml | 63 + view/adminhtml/templates/pdf/Paypal.phtml | 75 + .../adminhtml/templates/pdf/PostFinance.phtml | 75 + .../templates/pdf/PostFinanceCard.phtml | 75 + view/adminhtml/templates/pdf/Prepayment.phtml | 106 + view/adminhtml/templates/pdf/Przelewy.phtml | 63 + view/adminhtml/templates/pdf/Sepa.phtml | 100 + .../templates/pdf/SepaGuarantee.phtml | 81 + .../templates/pdf/SepaInstalment.phtml | 87 + view/adminhtml/templates/pdf/Trustly.phtml | 63 + view/adminhtml/templates/pdf/Wechatpay.phtml | 63 + .../sales/order/view/tab/instalment.phtml | 194 ++ .../order/view/tab/zeroamountbooking.phtml | 57 + .../config/form/field/AvailablePayments.phtml | 30 + .../config/form/field/Guaranteeforce.phtml | 57 + .../config/form/field/VendorAutoConfig.phtml | 185 ++ .../config/form/field/creditcardStyle.phtml | 93 + view/adminhtml/web/css/novalnet_payment.css | 145 + view/adminhtml/web/js/novalnetCc.js | 222 ++ view/adminhtml/web/js/novalnetInvoice.js | 183 ++ view/adminhtml/web/js/novalnetSepa.js | 237 ++ view/base/web/images/novalnet-logo.svg | 1 + view/base/web/images/novalnetalipay.png | Bin 0 -> 957 bytes view/base/web/images/novalnetamex.png | Bin 0 -> 1777 bytes view/base/web/images/novalnetapplepay.png | Bin 0 -> 1231 bytes view/base/web/images/novalnetbancontact.png | Bin 0 -> 2763 bytes view/base/web/images/novalnetbanktransfer.png | Bin 0 -> 1947 bytes view/base/web/images/novalnetblik.png | Bin 0 -> 1095 bytes view/base/web/images/novalnetcartasi.png | Bin 0 -> 1460 bytes view/base/web/images/novalnetcartebleue.png | Bin 0 -> 2791 bytes view/base/web/images/novalnetcashpayment.png | Bin 0 -> 1636 bytes view/base/web/images/novalnetcb.png | Bin 0 -> 2181 bytes view/base/web/images/novalnetdiners.png | Bin 0 -> 2044 bytes view/base/web/images/novalnetdiscover.png | Bin 0 -> 1940 bytes view/base/web/images/novalneteps.png | Bin 0 -> 1064 bytes view/base/web/images/novalnetgiropay.png | Bin 0 -> 1223 bytes view/base/web/images/novalnetgooglepay.png | Bin 0 -> 2216 bytes view/base/web/images/novalnetideal.png | Bin 0 -> 1481 bytes view/base/web/images/novalnetinvoice.png | Bin 0 -> 591 bytes .../web/images/novalnetinvoiceguarantee.png | Bin 0 -> 591 bytes .../web/images/novalnetinvoiceinstalment.png | Bin 0 -> 591 bytes view/base/web/images/novalnetjcb.png | Bin 0 -> 2198 bytes view/base/web/images/novalnetmaestro.png | Bin 0 -> 1337 bytes view/base/web/images/novalnetmastercard.png | Bin 0 -> 1384 bytes view/base/web/images/novalnetmultibanco.png | Bin 0 -> 2104 bytes .../web/images/novalnetonlinebanktransfer.png | Bin 0 -> 5405 bytes view/base/web/images/novalnetpaypal.png | Bin 0 -> 1976 bytes view/base/web/images/novalnetpostfinance.png | Bin 0 -> 1986 bytes .../web/images/novalnetpostfinancecard.png | Bin 0 -> 2351 bytes view/base/web/images/novalnetprepayment.png | Bin 0 -> 978 bytes view/base/web/images/novalnetprzelewy.png | Bin 0 -> 2180 bytes view/base/web/images/novalnetsepa.png | Bin 0 -> 1152 bytes .../base/web/images/novalnetsepaguarantee.png | Bin 0 -> 1152 bytes .../web/images/novalnetsepainstalment.png | Bin 0 -> 1152 bytes view/base/web/images/novalnettrustly.png | Bin 0 -> 1122 bytes view/base/web/images/novalnetunionpay.png | Bin 0 -> 2654 bytes view/base/web/images/novalnetvisa.png | Bin 0 -> 1610 bytes view/base/web/images/novalnetwechatpay.png | Bin 0 -> 1224 bytes .../email/novalnet_callback_email.html | 38 + .../novalnet_callback_instalment_email.html | 40 + view/frontend/layout/catalog_product_view.xml | 34 + view/frontend/layout/checkout_index_index.xml | 152 + .../layout/checkout_onepage_failure.xml | 26 + .../layout/checkout_onepage_success.xml | 32 + view/frontend/layout/default.xml | 26 + view/frontend/requirejs-config.js | 27 + .../templates/checkout/CartPageShortcut.phtml | 47 + .../templates/checkout/MinicartShortcut.phtml | 92 + .../checkout/ProductPageShortcut.phtml | 72 + view/frontend/templates/info/Alipay.phtml | 63 + view/frontend/templates/info/Applepay.phtml | 75 + view/frontend/templates/info/Bancontact.phtml | 63 + .../templates/info/Banktransfer.phtml | 63 + view/frontend/templates/info/Blik.phtml | 63 + .../frontend/templates/info/Cashpayment.phtml | 90 + view/frontend/templates/info/Cc.phtml | 87 + view/frontend/templates/info/Eps.phtml | 63 + view/frontend/templates/info/Giropay.phtml | 63 + view/frontend/templates/info/Googlepay.phtml | 75 + view/frontend/templates/info/Ideal.phtml | 63 + view/frontend/templates/info/Invoice.phtml | 118 + .../templates/info/InvoiceGuarantee.phtml | 106 + .../templates/info/InvoiceInstalment.phtml | 139 + view/frontend/templates/info/Multibanco.phtml | 49 + .../templates/info/OnlineBanktransfer.phtml | 63 + view/frontend/templates/info/Paypal.phtml | 75 + .../frontend/templates/info/PostFinance.phtml | 75 + .../templates/info/PostFinanceCard.phtml | 75 + view/frontend/templates/info/Prepayment.phtml | 106 + view/frontend/templates/info/Przelewy.phtml | 63 + view/frontend/templates/info/Sepa.phtml | 97 + .../templates/info/SepaGuarantee.phtml | 81 + .../templates/info/SepaInstalment.phtml | 110 + view/frontend/templates/info/Trustly.phtml | 63 + view/frontend/templates/info/Wechatpay.phtml | 63 + .../success/expresscheckoutmessage.phtml | 35 + .../templates/onepage/success/message.phtml | 39 + .../product/view/instalmentsinfo.phtml | 209 ++ .../frontend/templates/removeTokenPopup.phtml | 27 + view/frontend/web/css/novalnet_payment.css | 262 ++ .../web/js/action/get-redirect-url.js | 40 + .../web/js/checkout/novalnetGuestCheckout.js | 554 ++++ .../frontend/web/js/novalnetCheckoutHelper.js | 612 ++++ .../web/js/novalnetRefreshMinicart.js | 27 + .../payment/method-renderer/novalnetAlipay.js | 83 + .../method-renderer/novalnetApplepay.js | 361 +++ .../method-renderer/novalnetBancontact.js | 83 + .../method-renderer/novalnetBanktransfer.js | 83 + .../payment/method-renderer/novalnetBlik.js | 83 + .../method-renderer/novalnetCashpayment.js | 52 + .../payment/method-renderer/novalnetCc.js | 516 ++++ .../payment/method-renderer/novalnetEps.js | 83 + .../method-renderer/novalnetGiropay.js | 83 + .../method-renderer/novalnetGooglepay.js | 359 +++ .../payment/method-renderer/novalnetIdeal.js | 83 + .../method-renderer/novalnetInvoice.js | 108 + .../novalnetInvoiceGuarantee.js | 164 ++ .../novalnetInvoiceInstalment.js | 189 ++ .../method-renderer/novalnetMultibanco.js | 52 + .../novalnetOnlineBanktransfer.js | 83 + .../payment/method-renderer/novalnetPaypal.js | 243 ++ .../method-renderer/novalnetPostFinance.js | 83 + .../novalnetPostFinanceCard.js | 83 + .../method-renderer/novalnetPrepayment.js | 52 + .../method-renderer/novalnetPrzelewy.js | 83 + .../payment/method-renderer/novalnetSepa.js | 302 ++ .../method-renderer/novalnetSepaGuarantee.js | 332 +++ .../method-renderer/novalnetSepaInstalment.js | 362 +++ .../method-renderer/novalnetTrustly.js | 83 + .../method-renderer/novalnetWechatpay.js | 83 + .../web/js/view/payment/novalnet-payment.js | 280 ++ .../checkout/novalnetGuestCheckout.html | 25 + .../web/template/payment/novalnetAlipay.html | 81 + .../template/payment/novalnetApplepay.html | 77 + .../template/payment/novalnetBancontact.html | 80 + .../payment/novalnetBanktransfer.html | 81 + .../web/template/payment/novalnetBlik.html | 81 + .../template/payment/novalnetCashpayment.html | 80 + .../web/template/payment/novalnetCc.html | 181 ++ .../web/template/payment/novalnetEps.html | 81 + .../web/template/payment/novalnetGiropay.html | 81 + .../template/payment/novalnetGooglepay.html | 77 + .../web/template/payment/novalnetIdeal.html | 81 + .../web/template/payment/novalnetInvoice.html | 80 + .../payment/novalnetInvoiceGuarantee.html | 107 + .../payment/novalnetInvoiceInstalment.html | 132 + .../template/payment/novalnetMultibanco.html | 80 + .../payment/novalnetOnlineBanktransfer.html | 81 + .../web/template/payment/novalnetPaypal.html | 126 + .../template/payment/novalnetPostFinance.html | 81 + .../payment/novalnetPostFinanceCard.html | 81 + .../template/payment/novalnetPrepayment.html | 80 + .../template/payment/novalnetPrzelewy.html | 81 + .../web/template/payment/novalnetSepa.html | 194 ++ .../payment/novalnetSepaGuarantee.html | 212 ++ .../payment/novalnetSepaInstalment.html | 233 ++ .../web/template/payment/novalnetTrustly.html | 81 + .../template/payment/novalnetWechatpay.html | 81 + 381 files changed, 42085 insertions(+) create mode 100755 Api/NNRepositoryInterface.php create mode 100755 Block/Adminhtml/Button/Control.php create mode 100755 Block/Adminhtml/Sales/Order/View/Tab/Instalment.php create mode 100755 Block/Adminhtml/Sales/Order/View/Tab/ZeroAmountBooking.php create mode 100755 Block/Checkout/Cart/Shortcut.php create mode 100755 Block/Checkout/Cart/ShortcutButtonsConfig.php create mode 100755 Block/Form/Cashpayment.php create mode 100755 Block/Form/Cc.php create mode 100755 Block/Form/Invoice.php create mode 100755 Block/Form/InvoiceGuarantee.php create mode 100755 Block/Form/InvoiceInstalment.php create mode 100755 Block/Form/Multibanco.php create mode 100755 Block/Form/Prepayment.php create mode 100755 Block/Form/Sepa.php create mode 100755 Block/Form/SepaGuarantee.php create mode 100755 Block/Form/SepaInstalment.php create mode 100755 Block/Info/Alipay.php create mode 100755 Block/Info/Applepay.php create mode 100755 Block/Info/Bancontact.php create mode 100755 Block/Info/Banktransfer.php create mode 100755 Block/Info/Blik.php create mode 100755 Block/Info/Cashpayment.php create mode 100755 Block/Info/Cc.php create mode 100755 Block/Info/Eps.php create mode 100755 Block/Info/Giropay.php create mode 100755 Block/Info/Googlepay.php create mode 100755 Block/Info/Ideal.php create mode 100755 Block/Info/Invoice.php create mode 100755 Block/Info/InvoiceGuarantee.php create mode 100755 Block/Info/InvoiceInstalment.php create mode 100755 Block/Info/Multibanco.php create mode 100755 Block/Info/OnlineBanktransfer.php create mode 100755 Block/Info/Paypal.php create mode 100755 Block/Info/PostFinance.php create mode 100755 Block/Info/PostFinanceCard.php create mode 100755 Block/Info/Prepayment.php create mode 100755 Block/Info/Przelewy.php create mode 100755 Block/Info/Sepa.php create mode 100755 Block/Info/SepaGuarantee.php create mode 100755 Block/Info/SepaInstalment.php create mode 100755 Block/Info/Trustly.php create mode 100755 Block/Info/Wechatpay.php create mode 100755 Block/Onepage/Success/Message.php create mode 100755 Block/System/Config/Form/Field/CreditcardStyle.php create mode 100755 Block/System/Config/Form/Field/Disabled.php create mode 100755 Block/System/Config/Form/Field/Guaranteeforce.php create mode 100755 Block/System/Config/Form/Field/ModuleVersion.php create mode 100755 Block/System/Config/Form/Field/Notification.php create mode 100755 Block/System/Config/Form/Field/VendorAutoConfig.php create mode 100755 Block/System/Config/Form/Field/WebhookURL.php create mode 100755 Block/VendorAutoConfig.php create mode 100755 Controller/Adminhtml/Sales/Instalment.php create mode 100755 Controller/Adminhtml/Sales/OrderCapture.php create mode 100755 Controller/Adminhtml/Sales/Refund.php create mode 100755 Controller/Adminhtml/Sales/ZeroAmountBookingTab.php create mode 100755 Controller/Adminhtml/Sales/ZeroAmountUpdate.php create mode 100755 Controller/Redirect/Failure.php create mode 100755 Controller/Redirect/Success.php create mode 100755 Gateway/Config/CanInitializeHandler.php create mode 100755 Gateway/Config/OrderPlaceRedirectUrlHandler.php create mode 100755 Gateway/Config/PaymentActionHandler.php create mode 100755 Gateway/Http/Client/TransactionAuthorize.php create mode 100755 Gateway/Http/Client/TransactionCapture.php create mode 100755 Gateway/Http/Client/TransactionInitialize.php create mode 100755 Gateway/Http/Client/TransactionRedirect.php create mode 100755 Gateway/Http/Client/TransactionRefund.php create mode 100755 Gateway/Http/Client/TransactionVoid.php create mode 100755 Gateway/Http/TransferFactory.php create mode 100755 Gateway/Request/AbstractDataBuilder.php create mode 100755 Gateway/Request/AuthorizationDataBuilder.php create mode 100755 Gateway/Request/CaptureDataBuilder.php create mode 100755 Gateway/Request/InitializeDataBuilder.php create mode 100755 Gateway/Request/RedirectAuthorizeDataBuilder.php create mode 100755 Gateway/Request/RefundDataBuilder.php create mode 100755 Gateway/Request/VoidDataBuilder.php create mode 100755 Gateway/Response/CcPaymentHandler.php create mode 100755 Gateway/Response/PaymentHandler.php create mode 100755 Gateway/Response/RedirectAuthorizeHandler.php create mode 100755 Gateway/Response/RefundHandler.php create mode 100755 Gateway/Response/VoidHandler.php create mode 100755 Gateway/Validator/ResponseCodeValidator.php create mode 100755 Helper/Request.php create mode 100755 LICENSE.txt create mode 100755 Logger/Handler/NovalnetDebug.php create mode 100755 Logger/Handler/NovalnetError.php create mode 100755 Logger/Handler/NovalnetNotice.php create mode 100755 Logger/NovalnetLogger.php create mode 100755 Model/Adminhtml/Source/Activemethods.php create mode 100755 Model/Adminhtml/Source/ApplepayButtonStyle.php create mode 100755 Model/Adminhtml/Source/ApplepayButtonTheme.php create mode 100755 Model/Adminhtml/Source/ApplepayEnabledPages.php create mode 100755 Model/Adminhtml/Source/CcCardTypes.php create mode 100755 Model/Adminhtml/Source/CustomerGroups.php create mode 100755 Model/Adminhtml/Source/GooglepayButtonTheme.php create mode 100755 Model/Adminhtml/Source/GooglepayButtonType.php create mode 100755 Model/Adminhtml/Source/GooglepayEnabledPages.php create mode 100755 Model/Adminhtml/Source/InstalmentCycles.php create mode 100755 Model/Adminhtml/Source/PaymentAction.php create mode 100755 Model/Adminhtml/Source/PaymentActionWithZeroAmount.php create mode 100755 Model/Callback.php create mode 100755 Model/NNConfig.php create mode 100755 Model/NNRepository.php create mode 100755 Model/ResourceModel/Callback.php create mode 100755 Model/ResourceModel/Callback/Collection.php create mode 100755 Model/ResourceModel/TransactionStatus.php create mode 100755 Model/ResourceModel/TransactionStatus/Collection.php create mode 100755 Model/TransactionStatus.php create mode 100755 Model/Ui/ConfigProvider.php create mode 100755 Observer/DataAssignObserver.php create mode 100755 Observer/OrderPlacebefore.php create mode 100755 Observer/PaymentMethodIsActive.php create mode 100755 Observer/ProcessCaptureAction.php create mode 100755 Observer/ProcessNovalnetPayment.php create mode 100755 Observer/SavePaymentDataForRecurring.php create mode 100755 Observer/SetPaymentDataForRecurring.php create mode 100755 Observer/SetVoidStatus.php create mode 100755 Observer/ShortcutButtons.php create mode 100755 Observer/SubscriptionSupportedPayments.php create mode 100755 Plugin/Checkout/LayoutProcessor.php create mode 100755 Setup/Patch/Data/RemoveAccessKey.php create mode 100755 composer.json create mode 100755 etc/adminhtml/di.xml create mode 100755 etc/adminhtml/routes.xml create mode 100755 etc/adminhtml/system.xml create mode 100755 etc/adminhtml/system/novalnet_alipay.xml create mode 100755 etc/adminhtml/system/novalnet_applepay.xml create mode 100755 etc/adminhtml/system/novalnet_bancontact.xml create mode 100755 etc/adminhtml/system/novalnet_banktransfer.xml create mode 100755 etc/adminhtml/system/novalnet_blik.xml create mode 100755 etc/adminhtml/system/novalnet_cashpayment.xml create mode 100755 etc/adminhtml/system/novalnet_cc.xml create mode 100755 etc/adminhtml/system/novalnet_documentation.xml create mode 100755 etc/adminhtml/system/novalnet_eps.xml create mode 100755 etc/adminhtml/system/novalnet_giropay.xml create mode 100755 etc/adminhtml/system/novalnet_global_config.xml create mode 100755 etc/adminhtml/system/novalnet_googlepay.xml create mode 100755 etc/adminhtml/system/novalnet_ideal.xml create mode 100755 etc/adminhtml/system/novalnet_invoice.xml create mode 100755 etc/adminhtml/system/novalnet_invoice_guarantee.xml create mode 100755 etc/adminhtml/system/novalnet_invoice_instalment.xml create mode 100755 etc/adminhtml/system/novalnet_multibanco.xml create mode 100755 etc/adminhtml/system/novalnet_online_banktransfer.xml create mode 100755 etc/adminhtml/system/novalnet_payment_notice.xml create mode 100755 etc/adminhtml/system/novalnet_paypal.xml create mode 100755 etc/adminhtml/system/novalnet_postfinance.xml create mode 100755 etc/adminhtml/system/novalnet_postfinance_card.xml create mode 100755 etc/adminhtml/system/novalnet_prepayment.xml create mode 100755 etc/adminhtml/system/novalnet_przelewy.xml create mode 100755 etc/adminhtml/system/novalnet_sepa.xml create mode 100755 etc/adminhtml/system/novalnet_sepa_guarantee.xml create mode 100755 etc/adminhtml/system/novalnet_sepa_instalment.xml create mode 100755 etc/adminhtml/system/novalnet_trustly.xml create mode 100755 etc/adminhtml/system/novalnet_wechatpay.xml create mode 100755 etc/config.xml create mode 100755 etc/csp_whitelist.xml create mode 100755 etc/db_schema.xml create mode 100755 etc/di.xml create mode 100755 etc/email_templates.xml create mode 100755 etc/events.xml create mode 100755 etc/frontend/di.xml create mode 100755 etc/frontend/routes.xml create mode 100755 etc/module.xml create mode 100755 etc/webapi.xml create mode 100755 i18n/de_DE.csv create mode 100755 i18n/en_US.csv create mode 100755 registration.php create mode 100755 view/adminhtml/layout/adminhtml_system_config_edit.xml create mode 100755 view/adminhtml/layout/sales_order_create_index.xml create mode 100755 view/adminhtml/layout/sales_order_view.xml create mode 100755 view/adminhtml/requirejs-config.js create mode 100755 view/adminhtml/templates/config/webhooks_configuration.phtml create mode 100755 view/adminhtml/templates/form/Cashpayment.phtml create mode 100755 view/adminhtml/templates/form/Cc.phtml create mode 100755 view/adminhtml/templates/form/Invoice.phtml create mode 100755 view/adminhtml/templates/form/InvoiceGuarantee.phtml create mode 100755 view/adminhtml/templates/form/InvoiceInstalment.phtml create mode 100755 view/adminhtml/templates/form/Multibanco.phtml create mode 100755 view/adminhtml/templates/form/Prepayment.phtml create mode 100755 view/adminhtml/templates/form/Sepa.phtml create mode 100755 view/adminhtml/templates/form/SepaGuarantee.phtml create mode 100755 view/adminhtml/templates/form/SepaInstalment.phtml create mode 100755 view/adminhtml/templates/info/Alipay.phtml create mode 100755 view/adminhtml/templates/info/Applepay.phtml create mode 100755 view/adminhtml/templates/info/Bancontact.phtml create mode 100755 view/adminhtml/templates/info/Banktransfer.phtml create mode 100755 view/adminhtml/templates/info/Blik.phtml create mode 100755 view/adminhtml/templates/info/Cashpayment.phtml create mode 100755 view/adminhtml/templates/info/Cc.phtml create mode 100755 view/adminhtml/templates/info/Eps.phtml create mode 100755 view/adminhtml/templates/info/Giropay.phtml create mode 100755 view/adminhtml/templates/info/Googlepay.phtml create mode 100755 view/adminhtml/templates/info/Ideal.phtml create mode 100755 view/adminhtml/templates/info/Invoice.phtml create mode 100755 view/adminhtml/templates/info/InvoiceGuarantee.phtml create mode 100755 view/adminhtml/templates/info/InvoiceInstalment.phtml create mode 100755 view/adminhtml/templates/info/Multibanco.phtml create mode 100755 view/adminhtml/templates/info/OnlineBanktransfer.phtml create mode 100755 view/adminhtml/templates/info/Paypal.phtml create mode 100755 view/adminhtml/templates/info/PostFinance.phtml create mode 100755 view/adminhtml/templates/info/PostFinanceCard.phtml create mode 100755 view/adminhtml/templates/info/Prepayment.phtml create mode 100755 view/adminhtml/templates/info/Przelewy.phtml create mode 100755 view/adminhtml/templates/info/Sepa.phtml create mode 100755 view/adminhtml/templates/info/SepaGuarantee.phtml create mode 100755 view/adminhtml/templates/info/SepaInstalment.phtml create mode 100755 view/adminhtml/templates/info/Trustly.phtml create mode 100755 view/adminhtml/templates/info/Wechatpay.phtml create mode 100755 view/adminhtml/templates/payment/vendorConfig.phtml create mode 100755 view/adminhtml/templates/pdf/Alipay.phtml create mode 100755 view/adminhtml/templates/pdf/Applepay.phtml create mode 100755 view/adminhtml/templates/pdf/Bancontact.phtml create mode 100755 view/adminhtml/templates/pdf/Banktransfer.phtml create mode 100755 view/adminhtml/templates/pdf/Blik.phtml create mode 100755 view/adminhtml/templates/pdf/Cashpayment.phtml create mode 100755 view/adminhtml/templates/pdf/Cc.phtml create mode 100755 view/adminhtml/templates/pdf/Eps.phtml create mode 100755 view/adminhtml/templates/pdf/Giropay.phtml create mode 100755 view/adminhtml/templates/pdf/Googlepay.phtml create mode 100755 view/adminhtml/templates/pdf/Ideal.phtml create mode 100755 view/adminhtml/templates/pdf/Invoice.phtml create mode 100755 view/adminhtml/templates/pdf/InvoiceGuarantee.phtml create mode 100755 view/adminhtml/templates/pdf/InvoiceInstalment.phtml create mode 100755 view/adminhtml/templates/pdf/Multibanco.phtml create mode 100755 view/adminhtml/templates/pdf/OnlineBanktransfer.phtml create mode 100755 view/adminhtml/templates/pdf/Paypal.phtml create mode 100755 view/adminhtml/templates/pdf/PostFinance.phtml create mode 100755 view/adminhtml/templates/pdf/PostFinanceCard.phtml create mode 100755 view/adminhtml/templates/pdf/Prepayment.phtml create mode 100755 view/adminhtml/templates/pdf/Przelewy.phtml create mode 100755 view/adminhtml/templates/pdf/Sepa.phtml create mode 100755 view/adminhtml/templates/pdf/SepaGuarantee.phtml create mode 100755 view/adminhtml/templates/pdf/SepaInstalment.phtml create mode 100755 view/adminhtml/templates/pdf/Trustly.phtml create mode 100755 view/adminhtml/templates/pdf/Wechatpay.phtml create mode 100755 view/adminhtml/templates/sales/order/view/tab/instalment.phtml create mode 100755 view/adminhtml/templates/sales/order/view/tab/zeroamountbooking.phtml create mode 100755 view/adminhtml/templates/system/config/form/field/AvailablePayments.phtml create mode 100755 view/adminhtml/templates/system/config/form/field/Guaranteeforce.phtml create mode 100755 view/adminhtml/templates/system/config/form/field/VendorAutoConfig.phtml create mode 100755 view/adminhtml/templates/system/config/form/field/creditcardStyle.phtml create mode 100755 view/adminhtml/web/css/novalnet_payment.css create mode 100755 view/adminhtml/web/js/novalnetCc.js create mode 100755 view/adminhtml/web/js/novalnetInvoice.js create mode 100755 view/adminhtml/web/js/novalnetSepa.js create mode 100755 view/base/web/images/novalnet-logo.svg create mode 100755 view/base/web/images/novalnetalipay.png create mode 100755 view/base/web/images/novalnetamex.png create mode 100755 view/base/web/images/novalnetapplepay.png create mode 100755 view/base/web/images/novalnetbancontact.png create mode 100755 view/base/web/images/novalnetbanktransfer.png create mode 100644 view/base/web/images/novalnetblik.png create mode 100755 view/base/web/images/novalnetcartasi.png create mode 100755 view/base/web/images/novalnetcartebleue.png create mode 100755 view/base/web/images/novalnetcashpayment.png create mode 100755 view/base/web/images/novalnetcb.png create mode 100755 view/base/web/images/novalnetdiners.png create mode 100755 view/base/web/images/novalnetdiscover.png create mode 100755 view/base/web/images/novalneteps.png create mode 100755 view/base/web/images/novalnetgiropay.png create mode 100755 view/base/web/images/novalnetgooglepay.png create mode 100755 view/base/web/images/novalnetideal.png create mode 100755 view/base/web/images/novalnetinvoice.png create mode 100755 view/base/web/images/novalnetinvoiceguarantee.png create mode 100755 view/base/web/images/novalnetinvoiceinstalment.png create mode 100755 view/base/web/images/novalnetjcb.png create mode 100755 view/base/web/images/novalnetmaestro.png create mode 100755 view/base/web/images/novalnetmastercard.png create mode 100755 view/base/web/images/novalnetmultibanco.png create mode 100755 view/base/web/images/novalnetonlinebanktransfer.png create mode 100755 view/base/web/images/novalnetpaypal.png create mode 100755 view/base/web/images/novalnetpostfinance.png create mode 100755 view/base/web/images/novalnetpostfinancecard.png create mode 100755 view/base/web/images/novalnetprepayment.png create mode 100755 view/base/web/images/novalnetprzelewy.png create mode 100755 view/base/web/images/novalnetsepa.png create mode 100755 view/base/web/images/novalnetsepaguarantee.png create mode 100755 view/base/web/images/novalnetsepainstalment.png create mode 100755 view/base/web/images/novalnettrustly.png create mode 100755 view/base/web/images/novalnetunionpay.png create mode 100755 view/base/web/images/novalnetvisa.png create mode 100755 view/base/web/images/novalnetwechatpay.png create mode 100755 view/frontend/email/novalnet_callback_email.html create mode 100755 view/frontend/email/novalnet_callback_instalment_email.html create mode 100755 view/frontend/layout/catalog_product_view.xml create mode 100755 view/frontend/layout/checkout_index_index.xml create mode 100755 view/frontend/layout/checkout_onepage_failure.xml create mode 100755 view/frontend/layout/checkout_onepage_success.xml create mode 100755 view/frontend/layout/default.xml create mode 100755 view/frontend/requirejs-config.js create mode 100755 view/frontend/templates/checkout/CartPageShortcut.phtml create mode 100755 view/frontend/templates/checkout/MinicartShortcut.phtml create mode 100755 view/frontend/templates/checkout/ProductPageShortcut.phtml create mode 100755 view/frontend/templates/info/Alipay.phtml create mode 100755 view/frontend/templates/info/Applepay.phtml create mode 100755 view/frontend/templates/info/Bancontact.phtml create mode 100755 view/frontend/templates/info/Banktransfer.phtml create mode 100755 view/frontend/templates/info/Blik.phtml create mode 100755 view/frontend/templates/info/Cashpayment.phtml create mode 100755 view/frontend/templates/info/Cc.phtml create mode 100755 view/frontend/templates/info/Eps.phtml create mode 100755 view/frontend/templates/info/Giropay.phtml create mode 100755 view/frontend/templates/info/Googlepay.phtml create mode 100755 view/frontend/templates/info/Ideal.phtml create mode 100755 view/frontend/templates/info/Invoice.phtml create mode 100755 view/frontend/templates/info/InvoiceGuarantee.phtml create mode 100755 view/frontend/templates/info/InvoiceInstalment.phtml create mode 100755 view/frontend/templates/info/Multibanco.phtml create mode 100755 view/frontend/templates/info/OnlineBanktransfer.phtml create mode 100755 view/frontend/templates/info/Paypal.phtml create mode 100755 view/frontend/templates/info/PostFinance.phtml create mode 100755 view/frontend/templates/info/PostFinanceCard.phtml create mode 100755 view/frontend/templates/info/Prepayment.phtml create mode 100755 view/frontend/templates/info/Przelewy.phtml create mode 100755 view/frontend/templates/info/Sepa.phtml create mode 100755 view/frontend/templates/info/SepaGuarantee.phtml create mode 100755 view/frontend/templates/info/SepaInstalment.phtml create mode 100755 view/frontend/templates/info/Trustly.phtml create mode 100755 view/frontend/templates/info/Wechatpay.phtml create mode 100755 view/frontend/templates/onepage/success/expresscheckoutmessage.phtml create mode 100755 view/frontend/templates/onepage/success/message.phtml create mode 100755 view/frontend/templates/product/view/instalmentsinfo.phtml create mode 100755 view/frontend/templates/removeTokenPopup.phtml create mode 100755 view/frontend/web/css/novalnet_payment.css create mode 100755 view/frontend/web/js/action/get-redirect-url.js create mode 100755 view/frontend/web/js/checkout/novalnetGuestCheckout.js create mode 100755 view/frontend/web/js/novalnetCheckoutHelper.js create mode 100755 view/frontend/web/js/novalnetRefreshMinicart.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetAlipay.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetApplepay.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetBancontact.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetBanktransfer.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetBlik.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetCashpayment.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetCc.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetEps.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetGiropay.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetGooglepay.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetIdeal.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetInvoice.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetInvoiceGuarantee.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetInvoiceInstalment.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetMultibanco.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetOnlineBanktransfer.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetPaypal.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetPostFinance.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetPostFinanceCard.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetPrepayment.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetPrzelewy.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetSepa.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetSepaGuarantee.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetSepaInstalment.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetTrustly.js create mode 100755 view/frontend/web/js/view/payment/method-renderer/novalnetWechatpay.js create mode 100755 view/frontend/web/js/view/payment/novalnet-payment.js create mode 100755 view/frontend/web/template/checkout/novalnetGuestCheckout.html create mode 100755 view/frontend/web/template/payment/novalnetAlipay.html create mode 100755 view/frontend/web/template/payment/novalnetApplepay.html create mode 100755 view/frontend/web/template/payment/novalnetBancontact.html create mode 100755 view/frontend/web/template/payment/novalnetBanktransfer.html create mode 100755 view/frontend/web/template/payment/novalnetBlik.html create mode 100755 view/frontend/web/template/payment/novalnetCashpayment.html create mode 100755 view/frontend/web/template/payment/novalnetCc.html create mode 100755 view/frontend/web/template/payment/novalnetEps.html create mode 100755 view/frontend/web/template/payment/novalnetGiropay.html create mode 100755 view/frontend/web/template/payment/novalnetGooglepay.html create mode 100755 view/frontend/web/template/payment/novalnetIdeal.html create mode 100755 view/frontend/web/template/payment/novalnetInvoice.html create mode 100755 view/frontend/web/template/payment/novalnetInvoiceGuarantee.html create mode 100755 view/frontend/web/template/payment/novalnetInvoiceInstalment.html create mode 100755 view/frontend/web/template/payment/novalnetMultibanco.html create mode 100755 view/frontend/web/template/payment/novalnetOnlineBanktransfer.html create mode 100755 view/frontend/web/template/payment/novalnetPaypal.html create mode 100755 view/frontend/web/template/payment/novalnetPostFinance.html create mode 100755 view/frontend/web/template/payment/novalnetPostFinanceCard.html create mode 100755 view/frontend/web/template/payment/novalnetPrepayment.html create mode 100755 view/frontend/web/template/payment/novalnetPrzelewy.html create mode 100755 view/frontend/web/template/payment/novalnetSepa.html create mode 100755 view/frontend/web/template/payment/novalnetSepaGuarantee.html create mode 100755 view/frontend/web/template/payment/novalnetSepaInstalment.html create mode 100755 view/frontend/web/template/payment/novalnetTrustly.html create mode 100755 view/frontend/web/template/payment/novalnetWechatpay.html diff --git a/Api/NNRepositoryInterface.php b/Api/NNRepositoryInterface.php new file mode 100755 index 0000000..609970b --- /dev/null +++ b/Api/NNRepositoryInterface.php @@ -0,0 +1,146 @@ +coreRegistry = $registry; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + } + + /** + * Before push buttons + * + * @param ToolbarContext $toolbar + * @param AbstractBlock $context + * @param ButtonList $buttonList + * @return mixed + */ + public function beforePushButtons( + ToolbarContext $toolbar, + \Magento\Framework\View\Element\AbstractBlock $context, + \Magento\Backend\Block\Widget\Button\ButtonList $buttonList + ) { + if ($context instanceof \Magento\Sales\Block\Adminhtml\Order\Invoice\View) { + $orderPayment = $context->getInvoice()->getOrder()->getPayment(); + if ($orderPayment->getMethodInstance()->getCode() == ConfigProvider::NOVALNET_INVOICE) { + $buttonList->remove('capture'); + } + return [$context, $buttonList]; + } + + if (!$context instanceof \Magento\Sales\Block\Adminhtml\Order\View) { + return [$context, $buttonList]; + } + + $order = $this->getOrder(); + $payment = $order->getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + if (!empty($paymentMethodCode) && preg_match('/novalnet/i', $paymentMethodCode)) { + + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + $transactionStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $order) : ''; + + if ($transactionStatus) { + // remove Capture button + $buttonList->update('order_invoice', 'label', __('Capture')); + + if (in_array($transactionStatus, ['PENDING', 'DEACTIVATED']) || !empty($additionalData['NnZeroAmountBooking'])) { + $buttonList->remove('order_invoice'); + } + + if ($order->canInvoice() && $transactionStatus == 'ON_HOLD' && + $paymentMethodCode == ConfigProvider::NOVALNET_INVOICE + ) { + $buttonList->remove('order_invoice'); + $message = __('Are you sure you want to capture the payment?'); + $capturePaymentUrl = $context->getUrl( + 'novalnetpayment/sales/ordercapture', + ['order_id' => $order->getId()] + ); + + $buttonList->add( + 'novalnet_confirm', + [ + 'label' => __('Novalnet Capture'), + 'onclick' => "confirmSetLocation('{$message}', '{$capturePaymentUrl}')" + ] + ); + } + + if ($transactionStatus == 'ON_HOLD') { + $buttonList->remove('void_payment'); + $message = __('Are you sure you want to cancel the payment?'); + $voidPaymentUrl = $context->getUrl( + 'sales/*/voidPayment', + ['order_id' => $order->getId()] + ); + $buttonList->add( + 'void_payment', + [ + 'label' => __('Void'), + 'onclick' => "confirmSetLocation('{$message}', '{$voidPaymentUrl}')" + ] + ); + } + + if ($transactionStatus == 'PENDING' && $this->novalnetConfig->isRedirectPayment($paymentMethodCode) || + in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_PREPAYMENT, + ConfigProvider::NOVALNET_CASHPAYMENT, + ConfigProvider::NOVALNET_MULTIBANCO + ] + ) + ) { + $buttonList->remove('order_cancel'); // remove Cancel button + $buttonList->remove('void_payment'); // remove Void button + } + } + } + + return [$context, $buttonList]; + } + + /** + * Retrieve order model object + * + * @return \Magento\Sales\Model\Order + */ + public function getOrder() + { + return $this->coreRegistry->registry('sales_order'); + } +} diff --git a/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php b/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php new file mode 100755 index 0000000..7ee028d --- /dev/null +++ b/Block/Adminhtml/Sales/Order/View/Tab/Instalment.php @@ -0,0 +1,263 @@ +coreRegistry = $registry; + $this->pricingHelper = $pricingHelper; + $this->datetime = $datetime; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Retrieve order model instance + * + * @return \Magento\Sales\Model\Order + */ + public function getOrder() + { + return $this->coreRegistry->registry('current_order'); + } + + /** + * @inheritdoc + */ + public function getTabLabel() + { + return __('Instalment'); + } + + /** + * @inheritdoc + */ + public function getTabTitle() + { + return __('Instalment'); + } + + /** + * @inheritdoc + */ + public function canShowTab() + { + $payment = $this->getOrder()->getPayment(); + if (in_array( + $payment->getMethodInstance()->getCode(), + [ + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + )) { + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + $paymentStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $this->getOrder()) : ''; + return (bool) ($paymentStatus == 'CONFIRMED'); + } + + return false; + } + + /** + * @inheritdoc + */ + public function isHidden() + { + return false; + } + + /** + * Get Tab Class + * + * @return string + */ + public function getTabClass() + { + return 'ajax only'; + } + + /** + * Get Class + * + * @return string + */ + public function getClass() + { + return $this->getTabClass(); + } + + /** + * Get Tab Url + * + * @return string + */ + public function getTabUrl() + { + return $this->getUrl('novalnetpayment/sales/instalment', ['_current' => true]); + } + + /** + * Get URL to edit the customer. + * + * @return string + */ + public function getCustomerViewUrl() + { + if ($this->getOrder()->getCustomerIsGuest() || !$this->getOrder()->getCustomerId()) { + return ''; + } + + return $this->getUrl('customer/index/edit', ['id' => $this->getOrder()->getCustomerId()]); + } + + /** + * Check if is single store mode + * + * @return bool + */ + public function isSingleStoreMode() + { + return $this->_storeManager->isSingleStoreMode(); + } + + /** + * Get order store name + * + * @return null|string + */ + public function getOrderStoreName() + { + if ($this->getOrder()) { + $storeId = $this->getOrder()->getStoreId(); + if ($storeId === null) { + $deleted = __(' [deleted]'); + return nl2br($this->getOrder()->getStoreName()) . $deleted; + } + $store = $this->_storeManager->getStore($storeId); + $name = [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()]; + return (!empty($name)) ? implode('
', $name) : ''; + } + + return null; + } + + /** + * Get payment additional data + * + * @param string $key + * @return null|string + */ + public function getAdditionalData($key) + { + $payment = $this->getOrder()->getPayment(); + $details = []; + if (!empty($payment->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && !empty($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get Formated Date + * + * @param string $date + * @return string + */ + public function getFormatedDate($date) + { + return $this->datetime->formatDate($date, \IntlDateFormatter::LONG); + } + + /** + * Update Currency + * + * @param string $amount + * @return float|string + */ + public function updateCurrency($amount) + { + return $this->pricingHelper->currency($amount); + } +} diff --git a/Block/Adminhtml/Sales/Order/View/Tab/ZeroAmountBooking.php b/Block/Adminhtml/Sales/Order/View/Tab/ZeroAmountBooking.php new file mode 100755 index 0000000..80c4c29 --- /dev/null +++ b/Block/Adminhtml/Sales/Order/View/Tab/ZeroAmountBooking.php @@ -0,0 +1,198 @@ +coreRegistry = $registry; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Retrieve order model instance + * + * @return \Magento\Sales\Model\Order + */ + public function getOrder() + { + return $this->coreRegistry->registry('current_order'); + } + + /** + * @inheritdoc + */ + public function getTabLabel() + { + return __('Zero amount booking'); + } + + /** + * @inheritdoc + */ + public function getTabTitle() + { + return __('Zero amount booking'); + } + + /** + * @inheritdoc + */ + public function canShowTab() + { + $payment = $this->getOrder()->getPayment(); + + if ($this->getOrder()->getStatus() == \Magento\Sales\Model\Order::STATE_CANCELED) { + return false; + } + + if (in_array( + $payment->getMethodInstance()->getCode(), + [ + ConfigProvider::NOVALNET_SEPA, + ConfigProvider::NOVALNET_CC + ] + )) { + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + $paymentStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $this->getOrder()) : ''; + return (bool) ($paymentStatus == 'CONFIRMED' && !empty($additionalData['NnZeroAmountBooking']) && empty($additionalData['NnZeroAmountDone'])); + } + + return false; + } + + /** + * @inheritdoc + */ + public function isHidden() + { + return false; + } + + /** + * Get Tab Class + * + * @return string + */ + public function getTabClass() + { + return 'ajax only'; + } + + /** + * Get Class + * + * @return string + */ + public function getClass() + { + return $this->getTabClass(); + } + + /** + * Get Tab Url + * + * @return string + */ + public function getTabUrl() + { + return $this->getUrl('novalnetpayment/sales/zeroamountbookingTab', ['_current' => true]); + } + + /** + * Get payment additional data + * + * @param string $key + * + * @return null|string + */ + public function getAdditionalData($key) + { + $payment = $this->getOrder()->getPayment(); + $details = []; + if (!empty($payment->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get the formated amount in cents/euro + * + * @param float $amount + * @param string $type + * @return int + */ + public function getFormattedAmount($amount, $type = 'CENT') + { + return $this->novalnetRequestHelper->getFormattedAmount($amount, $type); + } +} diff --git a/Block/Checkout/Cart/Shortcut.php b/Block/Checkout/Cart/Shortcut.php new file mode 100755 index 0000000..6ad6297 --- /dev/null +++ b/Block/Checkout/Cart/Shortcut.php @@ -0,0 +1,99 @@ +getData(self::ALIAS_ELEMENT_INDEX); + } + + /** + * Set is in catalog product + * + * @param bool $isCatalog + * + * @return $this + */ + public function setIsInCatalogProduct($isCatalog) + { + $this->isMiniCart = !$isCatalog; + return $this; + } + + /** + * Set is in shopping cart + * + * @param bool $isShoppingCart + * @return void + */ + public function setIsShoppingCart($isShoppingCart) + { + $this->isShoppingCart = $isShoppingCart; + + if ($isShoppingCart) { + $this->_template = 'Novalnet_Payment::checkout/CartPageShortcut.phtml'; + } else { + $this->_template = 'Novalnet_Payment::checkout/MinicartShortcut.phtml'; + } + } + + /** + * Is Should Rendered + * + * @return bool + */ + protected function shouldRender() + { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $session = $objectManager->create(\Magento\Checkout\Model\Session::class); + + if ($this->isShoppingCart) { + return true; + } + + return $this->isMiniCart; + } + + /** + * Render the block if needed + * + * @return string + */ + protected function _toHtml() + { + if (!$this->shouldRender()) { + return ''; + } + + return parent::_toHtml(); + } +} diff --git a/Block/Checkout/Cart/ShortcutButtonsConfig.php b/Block/Checkout/Cart/ShortcutButtonsConfig.php new file mode 100755 index 0000000..856357e --- /dev/null +++ b/Block/Checkout/Cart/ShortcutButtonsConfig.php @@ -0,0 +1,99 @@ +productFactory = $productFactory; + $this->registry = $registry; + $this->novalnetRequestHelper = $novalnetRequestHelper; + parent::__construct($context, $data); + } + + /** + * Get Payment method active status + * + * @param string $page + * @return array + */ + public function isPageEnabledForExpressCheckout($page) + { + return $this->novalnetRequestHelper->isPageEnabledForExpressCheckout($page); + } + + /** + * Get Product Id + * + * @return int + */ + public function getProductId() + { + $product = $this->registry->registry('product'); + return $product->getId(); + } + + /** + * Get Product Type + * + * @return array + */ + public function loadProductById() + { + $productId = $this->getProductId(); + $model = $this->productFactory->create(); + $product = $model->load($productId); + return [ + 'productId' => $product->getId(), + 'isVirtual' => (in_array($product->getTypeId(), [ProductType::TYPE_VIRTUAL, DownloadableProduct::TYPE_DOWNLOADABLE])) ? true : false + ]; + } +} diff --git a/Block/Form/Cashpayment.php b/Block/Form/Cashpayment.php new file mode 100755 index 0000000..f91f66e --- /dev/null +++ b/Block/Form/Cashpayment.php @@ -0,0 +1,91 @@ +setTemplate('Novalnet_Payment::form/Cashpayment.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Form/Cc.php b/Block/Form/Cc.php new file mode 100755 index 0000000..a119094 --- /dev/null +++ b/Block/Form/Cc.php @@ -0,0 +1,178 @@ +setTemplate('Novalnet_Payment::form/Cc.phtml'); // Sets form template + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Get Credit Card logos + * + * @param string $paymentMethodcode + * @return array|bool + */ + public function getCreditCardLogos($paymentMethodcode) + { + return $this->novalnetConfigProvider->getCcAvailableTypes($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get instructions text from config + * + * @return string|null + */ + public function isInlineForm() + { + return $this->getMethod()->getConfigData('inline_form'); + } + + /** + * Retrieve Credit Card iframe params + * + * @return array + */ + public function getCcIframeParams() + { + return $this->novalnetConfigProvider->getCcIframeParams(); + } + + /** + * Get form style configuration + * + * @param string $param + * @return string|null + */ + public function getStyleConfig($param) + { + $creditCardStyle = $this->novalnetConfigProvider->getCcStyleConfig(); + if (isset($creditCardStyle[$param])) { + return $creditCardStyle[$param]; + } + + return ''; + } + + /** + * Retrieve Credit Card configs + * + * @param string $paymentMethodcode + * @return array + */ + public function getConfig($paymentMethodcode) + { + $config = $this->novalnetConfigProvider->getConfig(); + return $config['payment'][$paymentMethodcode]; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } + + /** + * To get is zero amount booking + * + * @return bool + */ + public function isZeroAmountBooking() + { + return ($this->novalnetConfig->getPaymentConfig(\Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CC, 'payment_action') == \Novalnet\Payment\Model\NNConfig::ACTION_ZERO_AMOUNT_BOOKING); + } +} diff --git a/Block/Form/Invoice.php b/Block/Form/Invoice.php new file mode 100755 index 0000000..c86792f --- /dev/null +++ b/Block/Form/Invoice.php @@ -0,0 +1,91 @@ +setTemplate('Novalnet_Payment::form/Invoice.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Form/InvoiceGuarantee.php b/Block/Form/InvoiceGuarantee.php new file mode 100755 index 0000000..8867839 --- /dev/null +++ b/Block/Form/InvoiceGuarantee.php @@ -0,0 +1,109 @@ +setTemplate('Novalnet_Payment::form/InvoiceGuarantee.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } +} diff --git a/Block/Form/InvoiceInstalment.php b/Block/Form/InvoiceInstalment.php new file mode 100755 index 0000000..8b1ca6c --- /dev/null +++ b/Block/Form/InvoiceInstalment.php @@ -0,0 +1,179 @@ +setTemplate('Novalnet_Payment::form/InvoiceInstalment.phtml'); + $this->priceHelper = $priceHelper; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + $this->currency = $currency; + $this->storeManager = $storeManager; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get Novalnet Guarantee instalment cycles + * + * @return null|string + */ + public function getInstalmentCycles() + { + return $this->novalnetConfig->getPaymentConfig($this->getMethodCode(), 'instalment_cycles'); + } + + /** + * Get amount with currency + * + * @param int $amount + * @return null|string + */ + public function updateCurrency($amount) + { + return $this->priceHelper->currency($amount, true, false); + } + + /** + * Returns Instalment cycle details api URL for the Novalnet module + * + * @return string + */ + public function getInstalmentCycleDetailUrl() + { + $baseUrl = $this->_storeManager->getStore()->getBaseUrl(); + return str_replace('index.php/', '', $baseUrl) . 'rest/V1/novalnet/payment/instalment_cycle/'; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } + + /** + * Get currency symbol for current locale and currency code + * + * @return string|null + */ + public function getCurrentCurrencySymbol() + { + $store = $this->storeManager->getStore(); + $currencyCode = $store->getCurrentCurrencyCode(); + $currentCurrency = trim($currencyCode); + $currency = $this->currency->load($currentCurrency); + return $currency->getCurrencySymbol(); + } +} diff --git a/Block/Form/Multibanco.php b/Block/Form/Multibanco.php new file mode 100755 index 0000000..148327e --- /dev/null +++ b/Block/Form/Multibanco.php @@ -0,0 +1,91 @@ +setTemplate('Novalnet_Payment::form/Multibanco.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Form/Prepayment.php b/Block/Form/Prepayment.php new file mode 100755 index 0000000..4782576 --- /dev/null +++ b/Block/Form/Prepayment.php @@ -0,0 +1,91 @@ +setTemplate('Novalnet_Payment::form/Prepayment.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Form/Sepa.php b/Block/Form/Sepa.php new file mode 100755 index 0000000..324326f --- /dev/null +++ b/Block/Form/Sepa.php @@ -0,0 +1,119 @@ +setTemplate('Novalnet_Payment::form/Sepa.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } + + /** + * To get is zero amount booking + * + * @return bool + */ + public function isZeroAmountBooking() + { + return ($this->novalnetConfig->getPaymentConfig(\Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CC, 'payment_action') == \Novalnet\Payment\Model\NNConfig::ACTION_ZERO_AMOUNT_BOOKING); + } +} diff --git a/Block/Form/SepaGuarantee.php b/Block/Form/SepaGuarantee.php new file mode 100755 index 0000000..43d0c57 --- /dev/null +++ b/Block/Form/SepaGuarantee.php @@ -0,0 +1,109 @@ +setTemplate('Novalnet_Payment::form/SepaGuarantee.phtml'); + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } +} diff --git a/Block/Form/SepaInstalment.php b/Block/Form/SepaInstalment.php new file mode 100755 index 0000000..b856200 --- /dev/null +++ b/Block/Form/SepaInstalment.php @@ -0,0 +1,179 @@ +setTemplate('Novalnet_Payment::form/SepaInstalment.phtml'); + $this->priceHelper = $priceHelper; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetConfigProvider = $novalnetConfigProvider; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelperRequest = $jsonHelperRequest; + $this->currency = $currency; + $this->storeManager = $storeManager; + } + + /** + * Get payment logo enabled status + * + * @param string $paymentMethodcode + * @return string + */ + public function getPaymentLogo($paymentMethodcode) + { + return $this->novalnetConfigProvider->getPaymentLogo($paymentMethodcode); + } + + /** + * Verify whether the payment is in Test mode + * + * @param string $paymentMethodcode + * @return int + */ + public function getTestMode($paymentMethodcode) + { + return $this->novalnetConfig->getTestMode($paymentMethodcode); + } + + /** + * Get Novalnet Guarantee instalment cycles + * + * @return null|string + */ + public function getInstalmentCycles() + { + return $this->novalnetConfig->getPaymentConfig($this->getMethodCode(), 'instalment_cycles'); + } + + /** + * Get amount with currency + * + * @param int $amount + * @return null|string + */ + public function updateCurrency($amount) + { + return $this->priceHelper->currency($amount, true, false); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Returns Instalment cycle details api URL for the Novalnet module + * + * @return string + */ + public function getInstalmentCycleDetailUrl() + { + $baseUrl = $this->_storeManager->getStore()->getBaseUrl(); + return str_replace('index.php/', '', $baseUrl) . 'rest/V1/novalnet/payment/instalment_cycle/'; + } + + /** + * Get json helper request + * + * @return mixed + */ + public function jsonHelper() + { + return $this->jsonHelperRequest; + } + + /** + * Get currency symbol for current locale and currency code + * + * @return string|null + */ + public function getCurrentCurrencySymbol() + { + $store = $this->storeManager->getStore(); + $currencyCode = $store->getCurrentCurrencyCode(); + $currentCurrency = trim($currencyCode); + $currency = $this->currency->load($currentCurrency); + return $currency->getCurrencySymbol(); + } +} diff --git a/Block/Info/Alipay.php b/Block/Info/Alipay.php new file mode 100755 index 0000000..9e1c006 --- /dev/null +++ b/Block/Info/Alipay.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Alipay.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Applepay.php b/Block/Info/Applepay.php new file mode 100755 index 0000000..10b5328 --- /dev/null +++ b/Block/Info/Applepay.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Applepay.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Bancontact.php b/Block/Info/Bancontact.php new file mode 100755 index 0000000..36dd5a9 --- /dev/null +++ b/Block/Info/Bancontact.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Bancontact.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Banktransfer.php b/Block/Info/Banktransfer.php new file mode 100755 index 0000000..50d82c9 --- /dev/null +++ b/Block/Info/Banktransfer.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Banktransfer.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Blik.php b/Block/Info/Blik.php new file mode 100755 index 0000000..29a1094 --- /dev/null +++ b/Block/Info/Blik.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Blik.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Cashpayment.php b/Block/Info/Cashpayment.php new file mode 100755 index 0000000..89a0f8a --- /dev/null +++ b/Block/Info/Cashpayment.php @@ -0,0 +1,108 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Cashpayment.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/Cc.php b/Block/Info/Cc.php new file mode 100755 index 0000000..ae8cef2 --- /dev/null +++ b/Block/Info/Cc.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Cc.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Eps.php b/Block/Info/Eps.php new file mode 100755 index 0000000..072e689 --- /dev/null +++ b/Block/Info/Eps.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Eps.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Giropay.php b/Block/Info/Giropay.php new file mode 100755 index 0000000..73a65cc --- /dev/null +++ b/Block/Info/Giropay.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Giropay.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Googlepay.php b/Block/Info/Googlepay.php new file mode 100755 index 0000000..4b84bd3 --- /dev/null +++ b/Block/Info/Googlepay.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Googlepay.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Ideal.php b/Block/Info/Ideal.php new file mode 100755 index 0000000..b9d8ed3 --- /dev/null +++ b/Block/Info/Ideal.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Ideal.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Invoice.php b/Block/Info/Invoice.php new file mode 100755 index 0000000..32fb049 --- /dev/null +++ b/Block/Info/Invoice.php @@ -0,0 +1,108 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Invoice.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/InvoiceGuarantee.php b/Block/Info/InvoiceGuarantee.php new file mode 100755 index 0000000..f09f200 --- /dev/null +++ b/Block/Info/InvoiceGuarantee.php @@ -0,0 +1,108 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/InvoiceGuarantee.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/InvoiceInstalment.php b/Block/Info/InvoiceInstalment.php new file mode 100755 index 0000000..7ae8067 --- /dev/null +++ b/Block/Info/InvoiceInstalment.php @@ -0,0 +1,127 @@ +priceHelper = $priceHelper; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/InvoiceInstalment.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get amount with currency + * + * @param int $amount + * @return null|string + */ + public function updateCurrency($amount) + { + return $this->priceHelper->currency($amount, true, false); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/Multibanco.php b/Block/Info/Multibanco.php new file mode 100755 index 0000000..9b17177 --- /dev/null +++ b/Block/Info/Multibanco.php @@ -0,0 +1,108 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Multibanco.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/OnlineBanktransfer.php b/Block/Info/OnlineBanktransfer.php new file mode 100755 index 0000000..bca9f1a --- /dev/null +++ b/Block/Info/OnlineBanktransfer.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/OnlineBanktransfer.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Paypal.php b/Block/Info/Paypal.php new file mode 100755 index 0000000..6438b57 --- /dev/null +++ b/Block/Info/Paypal.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Paypal.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/PostFinance.php b/Block/Info/PostFinance.php new file mode 100755 index 0000000..3553c19 --- /dev/null +++ b/Block/Info/PostFinance.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/PostFinance.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/PostFinanceCard.php b/Block/Info/PostFinanceCard.php new file mode 100755 index 0000000..036be3e --- /dev/null +++ b/Block/Info/PostFinanceCard.php @@ -0,0 +1,94 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/PostFinanceCard.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = (!empty($this->getInfo()->getAdditionalData())) ? ($this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true)) : []; + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Prepayment.php b/Block/Info/Prepayment.php new file mode 100755 index 0000000..b6fc4eb --- /dev/null +++ b/Block/Info/Prepayment.php @@ -0,0 +1,108 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Prepayment.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } + + /** + * Get GrandTotal + * + * @return mixed + */ + public function getGrandTotal() + { + return $this->novalnetRequestHelper->getAmountWithSymbol($this->getInfo()->getOrder()->getGrandTotal(), $this->getInfo()->getOrder()->getStoreId()); + } +} diff --git a/Block/Info/Przelewy.php b/Block/Info/Przelewy.php new file mode 100755 index 0000000..1154fcc --- /dev/null +++ b/Block/Info/Przelewy.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Przelewy.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Sepa.php b/Block/Info/Sepa.php new file mode 100755 index 0000000..3248eef --- /dev/null +++ b/Block/Info/Sepa.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Sepa.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/SepaGuarantee.php b/Block/Info/SepaGuarantee.php new file mode 100755 index 0000000..4ad298f --- /dev/null +++ b/Block/Info/SepaGuarantee.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/SepaGuarantee.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/SepaInstalment.php b/Block/Info/SepaInstalment.php new file mode 100755 index 0000000..3eaedf6 --- /dev/null +++ b/Block/Info/SepaInstalment.php @@ -0,0 +1,117 @@ +priceHelper = $priceHelper; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + } + + /** + * Set template forPdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/SepaInstalment.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get amount with currency + * + * @param int $amount + * @return float|string + */ + public function updateCurrency($amount) + { + return $this->priceHelper->currency($amount, true, false); + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Trustly.php b/Block/Info/Trustly.php new file mode 100755 index 0000000..a05b0bf --- /dev/null +++ b/Block/Info/Trustly.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Trustly.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Info/Wechatpay.php b/Block/Info/Wechatpay.php new file mode 100755 index 0000000..7be5bf9 --- /dev/null +++ b/Block/Info/Wechatpay.php @@ -0,0 +1,98 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context, $data); + } + + /** + * Set template for Pdf + * + * @return string + */ + public function toPdf() + { + $this->setTemplate('Novalnet_Payment::pdf/Wechatpay.phtml'); + return $this->toHtml(); + } + + /** + * Get additional information for the payment + * + * @param string $key + * @return string|null + */ + public function getAdditionalData($key) + { + $details = []; + if (!empty($this->getInfo()->getAdditionalData())) { + $details = $this->novalnetRequestHelper->isSerialized($this->getInfo()->getAdditionalData()) + ? $this->serializer->unserialize($this->getInfo()->getAdditionalData()) + : json_decode($this->getInfo()->getAdditionalData(), true); + } + + if (is_array($details)) { + return (!empty($key) && isset($details[$key])) ? $details[$key] : ''; + } + + return null; + } + + /** + * Get novalnet helper + * + * @return mixed + */ + public function novalnetHelper() + { + return $this->novalnetRequestHelper; + } +} diff --git a/Block/Onepage/Success/Message.php b/Block/Onepage/Success/Message.php new file mode 100755 index 0000000..4c66d5c --- /dev/null +++ b/Block/Onepage/Success/Message.php @@ -0,0 +1,115 @@ +checkoutSession = $checkoutSession; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + parent::__construct($context); + } + + /** + * Return Novalnet Cashpayment additional data + * + * @return mixed + */ + public function getCpAdditionalData() + { + $additionalData = false; + $order = $this->checkoutSession->getLastRealOrder(); + if ($order->getId()) { + $payment = $order->getPayment(); + if ($payment->getMethodInstance()->getCode() == ConfigProvider::NOVALNET_CASHPAYMENT) { + $additionalData = (!empty($payment->getAdditionalData())) ? json_decode($payment->getAdditionalData(), true) : []; + } + } + + return $additionalData; + } + + /** + * Return Novalnet Googlepay additional data + * + * @return mixed + */ + public function getGpayAdditionalData() + { + $additionalData = false; + $order = $this->checkoutSession->getLastRealOrder(); + if ($order->getId()) { + $payment = $order->getPayment(); + if ($payment->getMethodInstance()->getCode() == ConfigProvider::NOVALNET_GOOGLEPAY) { + $additionalData = (!empty($payment->getAdditionalData())) ? json_decode($payment->getAdditionalData(), true) : []; + } + } + + return $additionalData; + } + + /** + * Return Novalnet Applepay additional data + * + * @return mixed + */ + public function getApplepayAdditionalData() + { + $additionalData = false; + $order = $this->checkoutSession->getLastRealOrder(); + if ($order->getId()) { + $payment = $order->getPayment(); + if ($payment->getMethodInstance()->getCode() == ConfigProvider::NOVALNET_APPLEPAY) { + $additionalData = (!empty($payment->getAdditionalData())) ? json_decode($payment->getAdditionalData(), true) : []; + } + } + + return $additionalData; + } +} diff --git a/Block/System/Config/Form/Field/CreditcardStyle.php b/Block/System/Config/Form/Field/CreditcardStyle.php new file mode 100755 index 0000000..01888a2 --- /dev/null +++ b/Block/System/Config/Form/Field/CreditcardStyle.php @@ -0,0 +1,105 @@ + 'font-family: Raleway,Helvetica Neue,Verdana,Arial,sans-serif;font-size: 13px;font-weight: 600;color: #636363;line-height: 1.5;', + 'standard_style_input' => 'color: #636363;font-family: Helvetica Neue,Verdana,Arial,sans-serif;font-size: 14px;', + 'standard_style_css' => '' + ]; + + /** + * Set template to itself + * + * @return $this + */ + protected function _prepareLayout() + { + parent::_prepareLayout(); + if (!$this->getTemplate()) { + $this->setTemplate('Novalnet_Payment::system/config/form/field/creditcardStyle.phtml'); + } + return $this; + } + + /** + * Remove scope label + * + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return string + */ + public function render(AbstractElement $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Return element html + * + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + $this->setElements($element); + return $this->_toHtml(); + } + + /** + * Return element value + * + * @return mixed + */ + public function getElement() + { + return $this->getElements(); + } + + /** + * Retrieve Novalnet Credit Card form style + * + * @param string $param + * @return string|null + */ + public function getElementValue($param) + { + $values = $this->getElements()->getValue($param); + if (!empty($values)) { + return $values; + } elseif (isset($this->ccLocalFormConfig[$param])) { + return $this->ccLocalFormConfig[$param]; + } + + return ''; + } +} diff --git a/Block/System/Config/Form/Field/Disabled.php b/Block/System/Config/Form/Field/Disabled.php new file mode 100755 index 0000000..e5fadb9 --- /dev/null +++ b/Block/System/Config/Form/Field/Disabled.php @@ -0,0 +1,52 @@ +unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Return element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + $element->setReadonly(true); + return parent::_getElementHtml($element); + } +} diff --git a/Block/System/Config/Form/Field/Guaranteeforce.php b/Block/System/Config/Form/Field/Guaranteeforce.php new file mode 100755 index 0000000..f5274b7 --- /dev/null +++ b/Block/System/Config/Form/Field/Guaranteeforce.php @@ -0,0 +1,51 @@ +setTemplate('Novalnet_Payment::system/config/form/field/Guaranteeforce.phtml'); + return $this; + } + + /** + * Return element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + return $this->_toHtml(); + } +} diff --git a/Block/System/Config/Form/Field/ModuleVersion.php b/Block/System/Config/Form/Field/ModuleVersion.php new file mode 100755 index 0000000..6cc9fd9 --- /dev/null +++ b/Block/System/Config/Form/Field/ModuleVersion.php @@ -0,0 +1,70 @@ +novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Returns element + * + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return string + */ + public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Returns element html + * + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return mixed + */ + protected function _getElementHtml(AbstractElement $element) + { + return $this->novalnetRequestHelper->getNovalnetVersion(); + } +} diff --git a/Block/System/Config/Form/Field/Notification.php b/Block/System/Config/Form/Field/Notification.php new file mode 100755 index 0000000..7880e40 --- /dev/null +++ b/Block/System/Config/Form/Field/Notification.php @@ -0,0 +1,110 @@ +backendUrl = $backendUrl; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Set template to itself + * + * @return $this + */ + protected function _prepareLayout() + { + parent::_prepareLayout(); + if (!$this->getTemplate()) { + $this->setTemplate('Novalnet_Payment::system/config/form/field/AvailablePayments.phtml'); + } + return $this; + } + + /** + * Returns element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + return $this->_toHtml(); + } + + /** + * Activate Global configuration + * + * @return bool + */ + public function activateGlobalConfiguration() + { + return !($this->novalnetConfig->getGlobalConfig('signature') && + $this->novalnetConfig->getGlobalConfig('payment_access_key') && + $this->novalnetRequestHelper->checkIsNumeric($this->novalnetConfig->getGlobalConfig('tariff_id'))); + } + + /** + * Get Global configuration URL + * + * @return string + */ + public function getGlobalConfigUrl() + { + return $this->backendUrl->getUrl('*/*/*', ['_current' => true, 'section' => 'payment']); + } +} diff --git a/Block/System/Config/Form/Field/VendorAutoConfig.php b/Block/System/Config/Form/Field/VendorAutoConfig.php new file mode 100755 index 0000000..5b29b86 --- /dev/null +++ b/Block/System/Config/Form/Field/VendorAutoConfig.php @@ -0,0 +1,72 @@ +getTemplate()) { + $this->setTemplate('Novalnet_Payment::system/config/form/field/VendorAutoConfig.phtml'); + } + return $this; + } + + /** + * Remove scope label + * + * @param AbstractElement $element + * @return string + */ + public function render(AbstractElement $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Return element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + $this->addData( + [ + 'button_label' => __($element->getOriginalData('button_label')), + 'html_id' => $element->getHtmlId(), + ] + ); + + return $this->_toHtml(); + } +} diff --git a/Block/System/Config/Form/Field/WebhookURL.php b/Block/System/Config/Form/Field/WebhookURL.php new file mode 100755 index 0000000..4a95ff7 --- /dev/null +++ b/Block/System/Config/Form/Field/WebhookURL.php @@ -0,0 +1,170 @@ +storeManager = $storeManager; + $this->config = $config; + $this->storeManager = $context->getStoreManager(); + $this->request = $request; + $this->storeId = $this->getAdminConfigStoreId(); + } + + /** + * Render element html + * + * @param AbstractElement $element + * @return string + */ + public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Returns storeId + * + * @return int + */ + public function getAdminConfigStoreId() + { + $storeId = (int)$this->request->getParam('store', 0); + $websiteId = (int)$this->request->getParam('website', 0); + + if ($storeId) { + return $storeId; + } elseif ($websiteId) { + return $this->storeManager->getWebsite($websiteId)->getDefaultStore()->getId(); + } + + return 0; // Default store + } + + /** + * Returns Button html + * + * @return string + */ + public function getButtonHtml() + { + $button = $this->getLayout()->createBlock( + \Magento\Backend\Block\Widget\Button::class + )->setData( + [ + 'id' => 'novalnet_configure_webhooks', + 'label' => __('Configure'), + ] + ); + + return $button->toHtml(); + } + + /** + * Returns Ajax URL + * + * @return string + */ + public function getAjaxUrl() + { + $storeBaseUrl = $this->storeManager->getStore()->getBaseUrl(); + return str_replace('index.php/', '', $storeBaseUrl) . 'rest/V1/novalnet/config_webhook_url/'; + } + + /** + * Returns Webhook URL + * + * @return string + */ + public function getWebHookUrl() + { + $webhookUrl = $this->config->getMerchantScriptConfig('vendor_script_url'); + $storeBaseUrl = $this->storeManager->getStore()->getBaseUrl(); + return !empty($webhookUrl) ? $webhookUrl : str_replace('index.php/', '', $storeBaseUrl) . 'rest/V1/novalnet/callback'; + } + + /** + * Returns element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + $this->setElements($element); + return $this->_toHtml(); + } + + /** + * Return element value + * + * @return object + */ + public function getElement() + { + return $this->getElements(); + } +} diff --git a/Block/VendorAutoConfig.php b/Block/VendorAutoConfig.php new file mode 100755 index 0000000..b839f06 --- /dev/null +++ b/Block/VendorAutoConfig.php @@ -0,0 +1,117 @@ +scopeConfig = $context->getScopeConfig(); + $this->_storeManager = $storeManager; + $this->uriParser = $uriParser; + } + + /** + * Returns vendor auto config url for the Novalnet module + * + * @return string + */ + public function getVendorAutoConfigUrl() + { + $baseUrl = $this->_storeManager->getStore()->getBaseUrl(); + return str_replace('index.php/', '', $baseUrl) . 'rest/V1/novalnet/activate_product_key/'; + } + + /** + * Gets request section value + * + * @return string|null + */ + public function getSectionParam() + { + return ($this->getRequest()->getParam('section') ? $this->getRequest()->getParam('section') : ''); + } + + /** + * Retrieves Store configuration values + * + * @param string $path + * @return string + */ + public function getConfigValue($path) + { + $scope = ''; + $id = ''; + if ($this->getRequest()->getParam('website', 0)) { + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE; + $id = $this->getRequest()->getParam('website', 0); + } elseif ($this->getRequest()->getParam('store', 0)) { + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; + $id = $this->getRequest()->getParam('store', 0); + } + + if ($scope && $id) { + return $this->scopeConfig->getValue($path, $scope, $id); + } else { + return $this->scopeConfig->getValue($path); + } + } + + /** + * Returns shop host URL + * + * @return string + */ + public function getShopHostName() + { + $storeBaseUrl = $this->_storeManager->getStore()->getBaseUrl(); + $url = $this->uriParser->parse($storeBaseUrl); + + return !empty($url->getHost()) ? $url->getHost() : ''; + } +} diff --git a/Controller/Adminhtml/Sales/Instalment.php b/Controller/Adminhtml/Sales/Instalment.php new file mode 100755 index 0000000..d0b9d07 --- /dev/null +++ b/Controller/Adminhtml/Sales/Instalment.php @@ -0,0 +1,97 @@ +layoutFactory = $layoutFactory; + parent::__construct( + $context, + $coreRegistry, + $fileFactory, + $translateInline, + $resultPageFactory, + $resultJsonFactory, + $resultLayoutFactory, + $resultRawFactory, + $orderManagement, + $orderRepository, + $logger + ); + } + + /** + * Instalment tab for Novalnet payments + * + * @return mixed + */ + public function execute() + { + $this->_initOrder(); + $layout = $this->layoutFactory->create(); + $html = $layout->createBlock(\Novalnet\Payment\Block\Adminhtml\Sales\Order\View\Tab\Instalment::class) + ->toHtml(); + $this->_translateInline->processResponseBody($html); + $resultRaw = $this->resultRawFactory->create(); + $resultRaw->setContents($html); + return $resultRaw; + } +} diff --git a/Controller/Adminhtml/Sales/OrderCapture.php b/Controller/Adminhtml/Sales/OrderCapture.php new file mode 100755 index 0000000..385f1cf --- /dev/null +++ b/Controller/Adminhtml/Sales/OrderCapture.php @@ -0,0 +1,181 @@ +transactionStatusModel = $transactionStatusModel; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + $this->novalnetLogger = $novalnetLogger; + parent::__construct( + $context, + $coreRegistry, + $fileFactory, + $translateInline, + $resultPageFactory, + $resultJsonFactory, + $resultLayoutFactory, + $resultRawFactory, + $orderManagement, + $orderRepository, + $logger + ); + } + + /** + * Order confirmation process for Novalnet payments (Invoice) + * + * @return mixed + */ + public function execute() + { + $order = $this->_initOrder(); + $resultRedirect = $this->resultRedirectFactory->create(); + try { + if ($order) { + $payment = $order->getPayment(); + $storeId = $order->getStoreId(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $transactionId = preg_replace('/[^0-9]+/', '', $payment->getLastTransId()); + + if ($order->canInvoice() && $paymentMethodCode == ConfigProvider::NOVALNET_INVOICE) { + $invoice = $order->prepareInvoice(); + $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::CAPTURE_ONLINE) + ->register(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (!empty($additionalData['NnGuarantee'])) { + $state = \Magento\Sales\Model\Order\Invoice::STATE_PAID; + } else { + $state = \Magento\Sales\Model\Order\Invoice::STATE_OPEN; + } + + $invoice->setState($state) + ->setTransactionId($transactionId) + ->save(); + + $transactionStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $order) : ''; + $this->transactionStatusModel->loadByAttribute($order->getIncrementId(), 'order_id') + ->setStatus($transactionStatus)->save(); + + $orderStatus = $this->novalnetConfig->getPaymentConfig( + $paymentMethodCode, + 'order_status', + $storeId + ); + + $orderStatus = $orderStatus ? $orderStatus : \Magento\Sales\Model\Order::STATE_PROCESSING; + // Verifies and sets order status + $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING) + ->setStatus($orderStatus); + $order->save(); + + $this->messageManager->addSuccess(__('The invoice has been created.')); + $this->novalnetLogger->notice('The invoice has been created for order no: ' . $order->getIncrementId()); + } else { + $this->messageManager->addError(__('The order does not allow an invoice to be created.')); + $this->novalnetLogger->notice('The order does not allow an invoice to be created for order no: ' . $order->getIncrementId()); + } + + $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]); + return $resultRedirect; + } + } catch (\Exception $e) { + $error = __('The order does not allow an invoice to be created.') . ' ' . $e->getMessage(); + $this->messageManager->addError($error); + $this->novalnetLogger->error($error); + } + + $resultRedirect->setPath('sales/order/'); + return $resultRedirect; + } +} diff --git a/Controller/Adminhtml/Sales/Refund.php b/Controller/Adminhtml/Sales/Refund.php new file mode 100755 index 0000000..0730e04 --- /dev/null +++ b/Controller/Adminhtml/Sales/Refund.php @@ -0,0 +1,209 @@ +pricingHelper = $pricingHelper; + $this->clientFactory = $clientFactory; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + $this->novalnetLogger = $novalnetLogger; + parent::__construct( + $context, + $coreRegistry, + $fileFactory, + $translateInline, + $resultPageFactory, + $resultJsonFactory, + $resultLayoutFactory, + $resultRawFactory, + $orderManagement, + $orderRepository, + $logger + ); + } + + /** + * Order refund process for Novalnet payments + * + * @return mixed + */ + public function execute() + { + $refundAmount = $this->getRequest()->getParam('nn-refund-amount'); + $refundTid = $this->getRequest()->getParam('nn-refund-tid'); + $refundTid = $this->novalnetRequestHelper->makeValidNumber($refundTid); + $instalmentCancel = $this->getRequest()->getParam('nn-instalment-cancel'); + $order = $this->_initOrder(); + $payment = $order->getPayment(); + $storeId = $order->getStoreId(); + $resultRedirect = $this->resultRedirectFactory->create(); + + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (!empty($additionalData['NnZeroAmountBooking']) && !empty($additionalData['NnZeroAmountDone'])) { + $refundTid = $additionalData['NnZeroAmountRefTid']; + } + + if ((!$refundAmount && !$instalmentCancel) || !$refundTid) { + $this->messageManager->addError(__('The Amount should be in future')); + $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]); + return $resultRedirect; + } + + if ($order) { + if (!empty($instalmentCancel)) { + $this->novalnetLogger->notice('Intiated instalment cancel for Novalnet ID: ' . $refundTid); + $url = NNConfig::NOVALNET_INSTALMENT_CANCEL; + $requestData = [ + 'instalment' => [ + 'tid' => $refundTid, + ] + ]; + } else { + $this->novalnetLogger->notice('Intiated instalment refund for Novalnet ID: ' . $refundTid); + $url = NNConfig::NOVALNET_REFUND_URL; + $requestData = [ + 'transaction' => [ + 'tid' => $refundTid, + 'amount' => $refundAmount + ], + 'custom' => ['lang' => $this->novalnetRequestHelper->getDefaultLanguage()] + ]; + } + + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post($url, $this->jsonHelper->jsonEncode($requestData)); + $response = new \Magento\Framework\DataObject(); + $responseBody = ($this->clientFactory->getBody()) ? json_decode($this->clientFactory->getBody(), true) : []; + $response->setData($responseBody); + + if ($response->getData('result/status') == 'SUCCESS') { + $refundKey = $this->getRequest()->getParam('nn-refund-key'); + $newRefundTid = $response->getData('transaction/refund/tid') + ? $response->getData('transaction/refund/tid') : $refundTid; + + if (empty($refundAmount)) { + $refundAmount = $response->getData('transaction/refund/amount'); + $additionalData['InstalmentCancel'] = 1; + } + $additionalData['InstalmentDetails'][$refundKey]['Refund'][] = [ + 'tid' => $newRefundTid, + 'amount' => $refundAmount / 100 + ]; + + $refundAmountwithCurrency = $this->pricingHelper->currency(($refundAmount / 100), true, false); + $additionalData['NnRefunded'][$newRefundTid]['reftid'] = $newRefundTid; + $additionalData['NnRefunded'][$newRefundTid]['refamount'] = $refundAmountwithCurrency; + $additionalData['NnRefunded'][$newRefundTid]['reqtid'] = $refundTid; + + $payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $this->messageManager->addSuccess(__('The Refund executed properly')); + $this->novalnetLogger->notice('The Refund executed properly for order id ' . $order->getId()); + } elseif ($response->getData('result/status_text')) { + $this->messageManager->addError($response->getData('result/status_text')); + $this->novalnetLogger->notice('The Refund not working for order id: ' . $order->getId()); + } + + $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]); + return $resultRedirect; + } + + $resultRedirect->setPath('sales/order/'); + return $resultRedirect; + } +} diff --git a/Controller/Adminhtml/Sales/ZeroAmountBookingTab.php b/Controller/Adminhtml/Sales/ZeroAmountBookingTab.php new file mode 100755 index 0000000..e98045e --- /dev/null +++ b/Controller/Adminhtml/Sales/ZeroAmountBookingTab.php @@ -0,0 +1,97 @@ +layoutFactory = $layoutFactory; + parent::__construct( + $context, + $coreRegistry, + $fileFactory, + $translateInline, + $resultPageFactory, + $resultJsonFactory, + $resultLayoutFactory, + $resultRawFactory, + $orderManagement, + $orderRepository, + $logger + ); + } + + /** + * Zero Amount Booking tab for Novalnet payments + * + * @return mixed + */ + public function execute() + { + $this->_initOrder(); + $layout = $this->layoutFactory->create(); + $html = $layout->createBlock(\Novalnet\Payment\Block\Adminhtml\Sales\Order\View\Tab\ZeroAmountBooking::class) + ->toHtml(); + $this->_translateInline->processResponseBody($html); + $resultRaw = $this->resultRawFactory->create(); + $resultRaw->setContents($html); + return $resultRaw; + } +} diff --git a/Controller/Adminhtml/Sales/ZeroAmountUpdate.php b/Controller/Adminhtml/Sales/ZeroAmountUpdate.php new file mode 100755 index 0000000..576c8e0 --- /dev/null +++ b/Controller/Adminhtml/Sales/ZeroAmountUpdate.php @@ -0,0 +1,352 @@ +pricingHelper = $pricingHelper; + $this->clientFactory = $clientFactory; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + $this->novalnetLogger = $novalnetLogger; + $this->novalnetConfig = $novalnetConfig; + $this->storeManager = $storeManager; + $this->transactionStatusModel = $transactionStatusModel; + $this->invoiceSender = $invoiceSender; + $this->dbTransaction = $dbTransaction; + } + + /** + * Zero amount booking process + * + * @return mixed + */ + public function execute() + { + $order = $this->_initOrder(); + $resultRedirect = $this->resultRedirectFactory->create(); + ($order->getId()) ? $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]) : $resultRedirect->setPath('sales/order/'); + + try { + $amountToUpdate = $this->getRequest()->getParam('nn-amount-to-update'); + $storeId = $order->getStoreId(); + $payment = $order->getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $billingAddress = $order->getBillingAddress(); + $billingStreet = $this->getStreet($billingAddress); + $shippingAddress = $order->getShippingAddress(); + $paymentToken = $this->getPaymentToken($order->getIncrementId()); + + $data = []; + + $data['merchant'] = [ + 'signature' => $this->novalnetConfig->getGlobalConfig('signature', $storeId), + 'tariff' => $this->novalnetConfig->getGlobalConfig('tariff_id', $storeId), + ]; + + $data['customer'] = [ + 'first_name' => $billingAddress->getFirstname(), + 'last_name' => $billingAddress->getLastname(), + 'email' => $billingAddress->getEmail(), + 'tel' => $billingAddress->getTelephone(), + 'customer_ip' => $this->novalnetRequestHelper->getRequestIp(), + 'customer_no' => $order->getCustomerId(), + ]; + + $data['customer']['billing'] = [ + 'street' => $billingStreet, + 'city' => $billingAddress->getCity(), + 'zip' => $billingAddress->getPostcode(), + 'country_code' => $billingAddress->getCountryId(), + 'state' => $this->novalnetRequestHelper->getRegionNameByCode($billingAddress->getRegionCode(), $billingAddress->getCountryId()) + ]; + + if (!empty($shippingAddress)) { + if ($billingAddress->getFirstname() == $shippingAddress->getFirstname() && + $billingAddress->getLastname() == $shippingAddress->getLastname() && + $billingStreet == $this->getStreet($shippingAddress) && + $billingAddress->getCity() == $shippingAddress->getCity() && + $billingAddress->getCountryId() ==$shippingAddress->getCountryId() && + $billingAddress->getPostcode() == $shippingAddress->getPostcode() + ) { + $data['customer']['shipping']['same_as_billing'] = 1; + } else { + $data['customer']['shipping'] = [ + 'first_name' => $shippingAddress->getFirstname(), + 'last_name' => $shippingAddress->getLastname(), + 'email' => $shippingAddress->getEmail(), + 'tel' => $shippingAddress->getTelephone(), + 'street' => $this->getStreet($shippingAddress), + 'city' => $shippingAddress->getCity(), + 'zip' => $shippingAddress->getPostcode(), + 'country_code' => $shippingAddress->getCountryId(), + 'state' => $this->novalnetRequestHelper->getRegionNameByCode($shippingAddress->getRegionCode(), $shippingAddress->getCountryId()) + ]; + + if (!empty($shippingAddress->getCompany())) { + $data['customer']['shipping']['company'] = $shippingAddress->getCompany(); + } + } + } + + $data['transaction'] = [ + 'payment_type' => $this->novalnetConfig->getPaymentType($paymentMethodCode), + 'amount' => $amountToUpdate, + 'currency' => $order->getBaseCurrencyCode(), + 'test_mode' => $this->novalnetConfig->getTestMode($paymentMethodCode), + 'order_no' => $order->getIncrementId(), + 'system_ip' => $this->novalnetRequestHelper->getServerAddr(), + 'system_name' => 'Magento', + 'system_version' => $this->novalnetRequestHelper->getMagentoVersion() . '-' . $this->novalnetRequestHelper->getNovalnetVersion(), + 'system_url' => $this->storeManager->getStore()->getBaseUrl(), + 'payment_data' => [ + 'token' => $paymentToken + ] + ]; + + $data['custom'] = [ + 'lang' => $this->novalnetRequestHelper->getDefaultLanguage(), + ]; + + $endPointURL = NNConfig::NOVALNET_PAYMENT_URL; + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post($endPointURL, $this->jsonHelper->jsonEncode($data)); + $response = new \Magento\Framework\DataObject(); + $responseBody = ($this->clientFactory->getBody()) ? json_decode($this->clientFactory->getBody(), true) : []; + $response->setData($responseBody); + + if ($response->getData('result/status') == 'SUCCESS') { + $zeroAmountRefTid = $response->getData('transaction/tid'); + $updatedAmount = $this->novalnetRequestHelper->getFormattedAmount($response->getData('transaction/amount'), 'RAW'); + + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + $updatedAmountwithCurrency = $this->pricingHelper->currency($updatedAmount, true, false); + $additionalData['NnZeroAmountDone'] = 1; + $additionalData['NnUpdatedZeroAmount'] = $updatedAmountwithCurrency; + $additionalData['NnZeroAmountRefTid'] = $zeroAmountRefTid; + $additionalData['NnZeroAmountCapture'] = 1; + $payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)); + + $payment->setTransactionId($zeroAmountRefTid . '-zeroamount') + ->setLastTransId($zeroAmountRefTid) + ->capture(); + + $orderStatus = $this->novalnetConfig->getPaymentConfig( + $paymentMethodCode, + 'order_status', + $storeId + ); + + if ($response->getData('transaction/status') == 'CONFIRMED') { + $order->setStatus($orderStatus)->save(); + } + + $invoice = current($order->getInvoiceCollection()->getItems()); + $this->dbTransaction->create()->addObject($payment)->addObject($invoice)->addObject($order)->save(); + $this->invoiceSender->send($invoice); + + $order->addStatusHistoryComment(__('Zero Amount has been updated successfully'), false)->save(); + $this->messageManager->addSuccess(__('Amount has been booked successfully')); + $this->novalnetLogger->notice('Zero Amount has been updated successfully for order id: ' . $order->getId()); + } elseif ($response->getData('result/status_text')) { + $this->messageManager->addError($response->getData('result/status_text')); + $order->addStatusHistoryComment(__('Zero Amount update has been failed'), false)->save(); + $this->novalnetLogger->notice('Zero Amount update has been failed for order id: ' . $order->getId()); + } + + return $resultRedirect; + } catch (\Exception $e) { + $this->messageManager->addError($e->getMessage()); + return $resultRedirect; + } + } + + /** + * Get Street from address + * + * @param object $address + * @return string + */ + public function getStreet($address) + { + try { + if (method_exists($address, 'getStreetFull')) { + $street = $address->getStreetFull(); + } else { + if ($address->getStreetLine1()) { + $street = implode(' ', [$address->getStreetLine1(), $address->getStreetLine2()]); + } else { + $street = (!empty($address->getStreet())) ? implode(' ', $address->getStreet()) : ''; + } + } + + return $street; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get payment token for the order + * + * @param mixed $orderIncrementId + * @return string|null + */ + protected function getPaymentToken($orderIncrementId) + { + try { + $tokenInfo = $this->transactionStatusModel->getCollection()->addFieldToFilter('order_id', ['eq' => $orderIncrementId])->getFirstItem(); + + if (!empty($tokenInfo['token'])) { + return $tokenInfo['token']; + } + + return null; + } catch (\Exception $e) { + throw $e; + } + } +} diff --git a/Controller/Redirect/Failure.php b/Controller/Redirect/Failure.php new file mode 100755 index 0000000..beed954 --- /dev/null +++ b/Controller/Redirect/Failure.php @@ -0,0 +1,175 @@ +salesModel = $salesModel; + $this->checkoutSession = $checkoutSession; + $this->clientFactory = $clientFactory; + $this->messageManager = $messageManager; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Handles Novalnet redirect failure process + * + * @return mixed + */ + public function execute() + { + $resultRedirect = $this->resultRedirectFactory->create(); + $checkSumResponse = $this->getRequest()->getParams(); + + // Loads order model by loading the Increment Id + $order = $this->salesModel->loadByIncrementId($checkSumResponse['order_no']); + $storeId = ''; + if ($order) { + $storeId = $order->getStoreId(); + } + $payment = $order->getPayment(); + $lastTransId = $payment->getLastTransId(); + if (!empty($lastTransId)) { + $this->novalnetLogger->notice('Callback already executed for ' . $order->getIncrementId()); + $resultRedirect->setPath('checkout/onepage/failure'); + return $resultRedirect; + } + + if (isset($checkSumResponse['tid'])) { + $this->novalnetLogger->notice('Customer return from Novalnet to shop (Novalnet redirect failure controller). Novalnet transaction ID: ' . $checkSumResponse['tid']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post( + NNConfig::NOVALNET_TRANSACTION_DETAIL_URL, + $this->jsonHelper->jsonEncode( + [ + 'transaction' => ['tid' => $checkSumResponse['tid']], + 'custom' => ['lang' => $this->novalnetRequestHelper->getDefaultLanguage()] + ] + ) + ); + } + + $response = new \Magento\Framework\DataObject(); + $responseBody = ($this->clientFactory->getBody()) ? json_decode($this->clientFactory->getBody(), true) : []; + $response->setData($responseBody); + + // Loads order model by loading the Increment Id + $orderId = !empty($checkSumResponse['order_no']) ? $checkSumResponse['order_no'] : $response->getData('transaction/order_no'); + $this->novalnetLogger->notice('Get order no' . $orderId); + $order = $this->salesModel->loadByIncrementId($orderId); + + $this->novalnetLogger->notice('Order loaded successfully ' . $order->getIncrementId()); + $this->novalnetRequestHelper->saveCanceledOrder($response, $order); + $errorMessage = !empty($checkSumResponse['status_text']) ? $checkSumResponse['status_text'] : $response->getData('result/status_text'); + $this->messageManager->addErrorMessage(__($errorMessage)); + + // Restore the cart items + if ($this->novalnetConfig->getGlobalConfig('restore_cart')) { + $this->novalnetRequestHelper->restoreQuote($orderId); + $this->novalnetLogger->notice('Successfully restored the cart items' . $order->getIncrementId()); + $resultRedirect->setPath('checkout/cart'); + } else { + $resultRedirect->setPath('checkout/onepage/failure'); + } + + return $resultRedirect; + } +} diff --git a/Controller/Redirect/Success.php b/Controller/Redirect/Success.php new file mode 100755 index 0000000..d196ea7 --- /dev/null +++ b/Controller/Redirect/Success.php @@ -0,0 +1,189 @@ +salesModel = $salesModel; + $this->clientFactory = $clientFactory; + $this->checkoutSession = $checkoutSession; + $this->messageManager = $messageManager; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Handles Novalnet redirect success process + * + * @return mixed + */ + public function execute() + { + $resultRedirect = $this->resultRedirectFactory->create(); + $checkSumResponse = $this->getRequest()->getParams(); + // Loads order model by loading the Increment Id + $order = $this->salesModel->loadByIncrementId($checkSumResponse['order_no']); + $storeId = ''; + if ($order) { + $storeId = $order->getStoreId(); + } + $this->novalnetLogger->notice('Customer return from Novalnet to shop (Novalnet redirect success controller). Novalnet transaction ID: ' . $checkSumResponse['tid']); + $payment = $order->getPayment(); + $lastTransId = $payment->getLastTransId(); + if (!empty($lastTransId)) { + $this->novalnetLogger->notice('Callback already executed for ' . $order->getIncrementId()); + $resultRedirect->setPath('checkout/onepage/success'); + return $resultRedirect; + } + + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post( + NNConfig::NOVALNET_TRANSACTION_DETAIL_URL, + $this->jsonHelper->jsonEncode( + [ + 'transaction' => ['tid' => $checkSumResponse['tid']], + 'custom' => ['lang' => $this->novalnetRequestHelper->getDefaultLanguage()] + ] + ) + ); + + $response = new \Magento\Framework\DataObject(); + $responseBody = ($this->clientFactory->getBody()) ? json_decode($this->clientFactory->getBody(), true) : []; + $response->setData($responseBody); + + // Loads order model by loading the Increment Id + $order = $this->salesModel->loadByIncrementId($response->getData('transaction/order_no')); + + $this->novalnetLogger->notice('Order loaded successfully ' . $order->getIncrementId()); + + $payment = $order->getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $additionalData = (!empty($payment->getAdditionalData())) ? json_decode($payment->getAdditionalData(), true) : []; + + // Checks payment hash on return + if (!$this->novalnetRequestHelper->checkPaymentHash($checkSumResponse, $additionalData)) { + if ($this->novalnetConfig->getGlobalConfig('restore_cart')) { + $this->novalnetRequestHelper->restoreQuote($order->getIncrementId()); + $this->novalnetLogger->notice('Successfully restored the cart items' . $order->getIncrementId()); + $resultRedirect->setPath('checkout/cart'); + } else { + $resultRedirect->setPath('checkout/onepage/failure'); + } + $errorMessage = 'While redirecting some data has been changed. The hash check failed.'; + $this->messageManager->addErrorMessage(__($errorMessage)); + $this->novalnetLogger->notice($errorMessage); + + return $resultRedirect; + } + + // Process in handling on redirect payment return success + if (!$this->novalnetRequestHelper->checkReturnedData($response, $order, $payment)) { + if ($this->novalnetConfig->getGlobalConfig('restore_cart')) { + $this->novalnetRequestHelper->restoreQuote($order->getIncrementId()); + $this->novalnetLogger->notice('Successfully restored the cart items' . $order->getIncrementId()); + $resultRedirect->setPath('checkout/cart'); + } else { + $resultRedirect->setPath('checkout/onepage/failure'); + } + $this->messageManager->addErrorMessage(__($response->getData('result/status_text'))); + $this->novalnetLogger->notice('Failure for check returned data. The status text is: ' . $response->getData('result/status_text')); + + return $resultRedirect; + } + + // Store payment data if token exist + if ($response->getData('transaction/payment_data/token')) { + $this->novalnetRequestHelper->savePaymentToken($order, $paymentMethodCode, $response); + $this->novalnetLogger->notice('Stored payment data'); + } + + $resultRedirect->setPath('checkout/onepage/success'); + + return $resultRedirect; + } +} diff --git a/Gateway/Config/CanInitializeHandler.php b/Gateway/Config/CanInitializeHandler.php new file mode 100755 index 0000000..3c5a8f1 --- /dev/null +++ b/Gateway/Config/CanInitializeHandler.php @@ -0,0 +1,61 @@ +novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Initialize Novalnet Credit Card payment only if do_redirect is 1 + * + * @param array $subject + * @param int|null $storeId + * @return bool + */ + public function handle(array $subject, $storeId = null) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($subject); + $paymentMethodCode = $paymentDataObject->getPayment()->getMethodInstance()->getCode(); + if ($paymentMethodCode == ConfigProvider::NOVALNET_CC || $paymentMethodCode == ConfigProvider::NOVALNET_GOOGLEPAY) { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + if ($methodSession->getData($paymentMethodCode . '_do_redirect')) { + return true; + } + } + + return false; + } +} diff --git a/Gateway/Config/OrderPlaceRedirectUrlHandler.php b/Gateway/Config/OrderPlaceRedirectUrlHandler.php new file mode 100755 index 0000000..a7853bc --- /dev/null +++ b/Gateway/Config/OrderPlaceRedirectUrlHandler.php @@ -0,0 +1,63 @@ +novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Initialize Mail for Credit Card payment only if do_rediret is 1 + * + * @param array $subject + * @param int|null $storeId + * @return bool + */ + public function handle(array $subject, $storeId = null) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($subject); + $paymentMethodCode = $paymentDataObject->getPayment()->getMethodInstance()->getCode(); + if ($paymentMethodCode == ConfigProvider::NOVALNET_CC || $paymentMethodCode == ConfigProvider::NOVALNET_GOOGLEPAY) { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + if ($methodSession->getData($paymentMethodCode . '_do_redirect') != 0) { + return true; + } else { + return false; + } + } + + return true; + } +} diff --git a/Gateway/Config/PaymentActionHandler.php b/Gateway/Config/PaymentActionHandler.php new file mode 100755 index 0000000..78f3aeb --- /dev/null +++ b/Gateway/Config/PaymentActionHandler.php @@ -0,0 +1,75 @@ +novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Validate minimum limit for authorization + * + * @param array $subject + * @param int|null $storeId + * @return bool + */ + public function handle(array $subject, $storeId = null) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($subject); + $orderTotalAmount = $paymentDataObject->getOrder()->getGrandTotalAmount(); + $paymentMethodCode = $paymentDataObject->getPayment()->getMethodInstance()->getCode(); + $paymentAction = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action'); + $minAuthAmount = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'manual_checking_amount'); + + if ($paymentAction == AbstractMethod::ACTION_AUTHORIZE && + (string) $this->novalnetRequestHelper->getFormattedAmount($orderTotalAmount) >= (string) $minAuthAmount + ) { + return AbstractMethod::ACTION_AUTHORIZE; + } elseif ($this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING) { + return AbstractMethod::ACTION_AUTHORIZE; + } else { + return AbstractMethod::ACTION_AUTHORIZE_CAPTURE; + } + } +} diff --git a/Gateway/Http/Client/TransactionAuthorize.php b/Gateway/Http/Client/TransactionAuthorize.php new file mode 100755 index 0000000..8c58c6a --- /dev/null +++ b/Gateway/Http/Client/TransactionAuthorize.php @@ -0,0 +1,118 @@ +clientFactory = $clientFactory; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->coreSession = $coreSession; + } + + /** + * Send request to gateway. Returns result as ENV array + * + * @param TransferInterface $transferObject + * @return array + */ + public function placeRequest(TransferInterface $transferObject) + { + $requestData = $transferObject->getBody(); + if (!empty($requestData['action'])) { + return $requestData; + } + + $storeId = $requestData['storeId']; + unset($requestData['storeId']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $paymentMethodCode = $this->novalnetConfig->getPaymentCodeByType($requestData['transaction']['payment_type']); + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_PREPAYMENT, + ConfigProvider::NOVALNET_CASHPAYMENT, + ConfigProvider::NOVALNET_MULTIBANCO + ] + ) || $this->coreSession->getRecurringProcess()) { + $this->clientFactory->post(NNConfig::NOVALNET_PAYMENT_URL, $this->jsonHelper->jsonEncode($requestData)); + } else { + $this->clientFactory->post(NNConfig::NOVALNET_AUTHORIZE_URL, $this->jsonHelper->jsonEncode($requestData)); + } + + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + if (!empty($response['result']['status']) && $response['result']['status'] == 'SUCCESS') { + return $response; + } elseif (!empty($response['result']['status_text'])) { + throw new \Magento\Framework\Exception\LocalizedException(__($response['result']['status_text'])); + } + } +} diff --git a/Gateway/Http/Client/TransactionCapture.php b/Gateway/Http/Client/TransactionCapture.php new file mode 100755 index 0000000..ec0a2b4 --- /dev/null +++ b/Gateway/Http/Client/TransactionCapture.php @@ -0,0 +1,104 @@ +clientFactory = $clientFactory; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Send request to gateway. Returns result as ENV array + * + * @param TransferInterface $transferObject + * @return array + */ + public function placeRequest(TransferInterface $transferObject) + { + $requestData = $transferObject->getBody(); + if (isset($requestData['action'])) { + return $requestData; + } + + $storeId = $requestData['storeId']; + unset($requestData['storeId']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + if (empty($requestData['transaction']['tid'])) { + $this->clientFactory->post(NNConfig::NOVALNET_PAYMENT_URL, $this->jsonHelper->jsonEncode($requestData)); + } else { + $this->novalnetLogger->notice('Capture has been initiated for the TID: ' . $requestData['transaction']['tid']); + $this->clientFactory->post(NNConfig::NOVALNET_CAPTURE_URL, $this->jsonHelper->jsonEncode($requestData)); + } + + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + if (!empty($response['result']['status']) && $response['result']['status'] == 'SUCCESS') { + $this->novalnetLogger->notice('The transaction has been confirmed successfully'); + return $response; + } elseif (!empty($response['result']['status_text'])) { + $this->novalnetLogger->notice('The transaction capture not working. The status text: ' . $response['result']['status_text']); + throw new \Magento\Framework\Exception\LocalizedException(__($response['result']['status_text'])); + } + } +} diff --git a/Gateway/Http/Client/TransactionInitialize.php b/Gateway/Http/Client/TransactionInitialize.php new file mode 100755 index 0000000..7a0ff98 --- /dev/null +++ b/Gateway/Http/Client/TransactionInitialize.php @@ -0,0 +1,108 @@ +clientFactory = $clientFactory; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->coreSession = $coreSession; + } + + /** + * Send request to gateway. Returns result as ENV array + * + * @param TransferInterface $transferObject + * @return array + */ + public function placeRequest(TransferInterface $transferObject) + { + $requestData = $transferObject->getBody(); + $storeId = $requestData['storeId']; + unset($requestData['storeId']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $paymentMethodCode = $this->novalnetConfig->getPaymentCodeByType($requestData['transaction']['payment_type']); + $minAuthAmount = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'manual_checking_amount'); + + if ($this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action') == 'authorize' && ($requestData['transaction']['amount'] >= $minAuthAmount) && !$this->coreSession->getRecurringProcess()) { + $this->clientFactory->post(NNConfig::NOVALNET_AUTHORIZE_URL, $this->jsonHelper->jsonEncode($requestData)); + } else { + $this->clientFactory->post(NNConfig::NOVALNET_PAYMENT_URL, $this->jsonHelper->jsonEncode($requestData)); + } + + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + if (!empty($response['result']['status']) && $response['result']['status'] == 'SUCCESS') { + return $response; + } elseif (!empty($response['result']['status_text'])) { + throw new \Magento\Framework\Exception\LocalizedException(__($response['result']['status_text'])); + } + } +} diff --git a/Gateway/Http/Client/TransactionRedirect.php b/Gateway/Http/Client/TransactionRedirect.php new file mode 100755 index 0000000..d723b88 --- /dev/null +++ b/Gateway/Http/Client/TransactionRedirect.php @@ -0,0 +1,37 @@ +clientFactory = $clientFactory; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Send request to gateway. Returns result as ENV array + * + * @param TransferInterface $transferObject + * @return array + */ + public function placeRequest(TransferInterface $transferObject) + { + $requestData = $transferObject->getBody(); + $storeId = $requestData['storeId']; + unset($requestData['storeId']); + $this->novalnetLogger->notice('Refund has been initiated for the TID: ' . $requestData['transaction']['tid']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post( + NNConfig::NOVALNET_REFUND_URL, + $this->jsonHelper->jsonEncode($requestData) + ); + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + if (!empty($response['result']['status']) && $response['result']['status'] == 'SUCCESS') { + $this->novalnetLogger->notice('The refund has been successfully'); + return $response; + } elseif (!empty($response['result']['status_text'])) { + $this->novalnetLogger->notice('The refund not working. The status text: ' . $response['result']['status_text']); + throw new \Magento\Framework\Exception\LocalizedException(__($response['result']['status_text'])); + } + } +} diff --git a/Gateway/Http/Client/TransactionVoid.php b/Gateway/Http/Client/TransactionVoid.php new file mode 100755 index 0000000..e83858d --- /dev/null +++ b/Gateway/Http/Client/TransactionVoid.php @@ -0,0 +1,101 @@ +clientFactory = $clientFactory; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Send request to gateway. Returns result as ENV array + * + * @param TransferInterface $transferObject + * @return array + */ + public function placeRequest(TransferInterface $transferObject) + { + $requestData = $transferObject->getBody(); + if (isset($requestData['action'])) { + return $requestData; + } + $storeId = $requestData['storeId']; + unset($requestData['storeId']); + $this->novalnetLogger->notice('Cancellation/void has been initiated for the TID: ' . $requestData['transaction']['tid']); + $this->clientFactory->setHeaders($this->novalnetRequestHelper->getRequestHeaders(false, $storeId)); + $this->clientFactory->post( + NNConfig::NOVALNET_CANCEL_URL, + $this->jsonHelper->jsonEncode($requestData) + ); + $response = ($this->clientFactory->getBody()) ? json_decode($this->clientFactory->getBody(), true) : []; + + if (!empty($response['result']['status']) && $response['result']['status'] == 'SUCCESS') { + $this->novalnetLogger->notice('The transaction has been canceled successfully'); + return $response; + } elseif (!empty($response['result']['status_text'])) { + $this->novalnetLogger->notice('The transaction cancellation not working. The status text: ' . $response['result']['status_text']); + throw new \Magento\Framework\Exception\LocalizedException(__($response['result']['status_text'])); + } + } +} diff --git a/Gateway/Http/TransferFactory.php b/Gateway/Http/TransferFactory.php new file mode 100755 index 0000000..4302342 --- /dev/null +++ b/Gateway/Http/TransferFactory.php @@ -0,0 +1,55 @@ +transferBuilder = $transferBuilder; + } + + /** + * Builds gateway transfer object + * + * @param array $request + * @return TransferInterface + */ + public function create(array $request) + { + return $this->transferBuilder + ->setBody($request) + ->setMethod('POST') + ->build(); + } +} diff --git a/Gateway/Request/AbstractDataBuilder.php b/Gateway/Request/AbstractDataBuilder.php new file mode 100755 index 0000000..718dfc7 --- /dev/null +++ b/Gateway/Request/AbstractDataBuilder.php @@ -0,0 +1,504 @@ +urlInterface = $urlInterface; + $this->storeManager = $storeManager; + $this->datetime = $datetime; + $this->authSession = $authSession; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->novalnetConfig = $novalnetConfig; + $this->config = $config; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + $this->cart = $cart; + } + + /** + * Build request for Payment action + * + * @param array $buildSubject + * @return array + */ + public function build(array $buildSubject) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); + $order = $paymentDataObject->getOrder(); + $paymentMethodCode = $paymentDataObject->getPayment()->getMethodInstance()->getCode(); + + $merchantParams = $this->buildMerchantParams($order); + $customerParams = $this->buildCustomerParams($order, $paymentMethodCode); + $transactionParams = $this->buildTransactionParams($order, $paymentMethodCode); + $customParams = $this->buildCustomParams($paymentMethodCode); + $cartInfoParams = $this->buildCartInfoParams($paymentMethodCode); + $data = array_merge($merchantParams, $customerParams, $transactionParams, $customParams); + $data['storeId'] = $paymentDataObject->getPayment()->getOrder()->getStoreId(); + $data = $this->filterStandardParameter($data); + $data = array_merge($data, $cartInfoParams); + return $data; + } + + /** + * Build Merchant params + * + * @param mixed $order + * @return array + */ + public function buildMerchantParams($order) + { + $storeId = $order->getStoreId(); + // Build Merchant Data + $data['merchant'] = [ + 'signature' => $this->novalnetConfig->getGlobalConfig('signature', $storeId), + 'tariff' => $this->novalnetConfig->getGlobalConfig('tariff_id', $storeId), + ]; + + return $data; + } + + /** + * Build Customer params + * + * @param mixed $order + * @param string $paymentMethodCode + * @return array + */ + public function buildCustomerParams($order, $paymentMethodCode) + { + $billingAddress = $order->getBillingAddress(); + $shippingAddress = $order->getShippingAddress(); + $billingStreet = $this->getStreet($billingAddress); + + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + + $shopperIp = $order->getRemoteIp(); + + if (!$this->novalnetRequestHelper->isAdmin() && empty($shopperIp)) { + $shopperIp = $order->getXForwardedFor(); + } + $requestIp = $this->novalnetRequestHelper->getRequestIp(); + $data = []; + + // Forming billing data + if ($billingAddress) { + $data['customer'] = [ + 'first_name' => $billingAddress->getFirstname(), + 'last_name' => $billingAddress->getLastname(), + 'email' => $billingAddress->getEmail(), + 'tel' => $billingAddress->getTelephone(), + 'customer_ip' => ($shopperIp != $requestIp) ? $this->novalnetRequestHelper->getRequestIp() : $shopperIp, + 'customer_no' => $this->novalnetRequestHelper->getCustomerId(), + ]; + + $data['customer']['billing'] = [ + 'street' => $billingStreet, + 'city' => $billingAddress->getCity(), + 'zip' => $billingAddress->getPostcode(), + 'country_code' => $billingAddress->getCountryId(), + 'state' => $this->novalnetRequestHelper->getRegionNameByCode($billingAddress->getRegionCode(), $billingAddress->getCountryId()) + ]; + + if ($methodSession->getData($paymentMethodCode . '_dob')) { + $data['customer']['birth_date'] = $this->datetime->date( + 'Y-m-d', + $methodSession->getData($paymentMethodCode . '_dob') + ); + } + + if (empty($data['customer']['birth_date']) && !empty($billingAddress->getCompany())) { + $data['customer']['billing']['company'] = $billingAddress->getCompany(); + } + } + + // Forming shipping data + if (!empty($shippingAddress)) { + if ($billingAddress->getFirstname() == $shippingAddress->getFirstname() && + $billingAddress->getLastname() == $shippingAddress->getLastname() && + $billingStreet == $this->getStreet($shippingAddress) && + $billingAddress->getCity() == $shippingAddress->getCity() && + $billingAddress->getCountryId() ==$shippingAddress->getCountryId() && + $billingAddress->getPostcode() == $shippingAddress->getPostcode() + ) { + $data['customer']['shipping']['same_as_billing'] = 1; + } else { + $data['customer']['shipping'] = [ + 'first_name' => $shippingAddress->getFirstname(), + 'last_name' => $shippingAddress->getLastname(), + 'email' => $shippingAddress->getEmail(), + 'tel' => $shippingAddress->getTelephone(), + 'street' => $this->getStreet($shippingAddress), + 'city' => $shippingAddress->getCity(), + 'zip' => $shippingAddress->getPostcode(), + 'country_code' => $shippingAddress->getCountryId(), + 'state' => $this->novalnetRequestHelper->getRegionNameByCode($shippingAddress->getRegionCode(), $shippingAddress->getCountryId()) + ]; + if (!empty($shippingAddress->getCompany())) { + $data['customer']['shipping']['company'] = $shippingAddress->getCompany(); + } + } + } + + return $data; + } + + /** + * Build Transaction params + * + * @param mixed $order + * @param string $paymentMethodCode + * @return array + */ + public function buildTransactionParams($order, $paymentMethodCode) + { + $billingAddress = $order->getBillingAddress(); + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + + $data['transaction'] = [ + 'payment_type' => $this->novalnetConfig->getPaymentType($paymentMethodCode), + 'amount' => $this->novalnetRequestHelper->getFormattedAmount($order->getGrandTotalAmount()), + 'currency' => $order->getCurrencyCode(), + 'test_mode' => $this->novalnetConfig->getTestMode($paymentMethodCode), + 'order_no' => $order->getOrderIncrementId(), + 'system_ip' => $this->novalnetRequestHelper->getServerAddr(), + 'system_name' => 'Magento', + 'system_version' => $this->novalnetRequestHelper->getMagentoVersion() . '-' . + $this->novalnetRequestHelper->getNovalnetVersion(), + 'system_url' => $this->storeManager->getStore()->getBaseUrl() + ]; + + $paymentDatas = ['token', 'pan_hash', 'unique_id', 'iban', 'wallet_token', 'bic']; + + foreach ($paymentDatas as $paymentData) { + if ($methodSession->getData($paymentMethodCode . '_' . $paymentData)) { + $data['transaction']['payment_data'][$paymentData] = preg_replace('/\s+/', '', $methodSession->getData($paymentMethodCode . '_' . $paymentData)); + } + } + + if ($this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'shop_type') && $methodSession->getData($paymentMethodCode . '_create_token') && empty($methodSession->getData($paymentMethodCode . '_token'))) { + $data['transaction']['create_token'] = $methodSession->getData($paymentMethodCode . '_create_token'); + } + + if ($this->novalnetConfig->isZeroAmountBookingSupported($paymentMethodCode) && + $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING + ) { + $data['transaction']['create_token'] = 1; + $data['transaction']['amount'] = 0; + } + + $paymentDueDate = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'due_date'); + $paymentDueDate = (!empty($paymentDueDate)) ? ltrim($paymentDueDate, '0') : ''; + if ($paymentDueDate) { + $data['transaction']['due_date'] = date('Y-m-d', strtotime('+' . $paymentDueDate . ' days')); + } + + if ($methodSession->getData($paymentMethodCode . '_cycle')) { + $data['instalment']['cycles'] = $methodSession->getData($paymentMethodCode . '_cycle'); + $data['instalment']['interval'] = '1m'; + } + + if ($this->novalnetConfig->isRedirectPayment($paymentMethodCode) || $methodSession->getData($paymentMethodCode . '_do_redirect')) { + $data['transaction']['return_url'] = $this->urlInterface->getUrl('novalnet/redirect/success', ['order_no' => $order->getOrderIncrementId()]); + $data['transaction']['error_return_url'] = $this->urlInterface->getUrl('novalnet/redirect/failure', ['order_no' => $order->getOrderIncrementId()]); + } + + if ($this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'enforce_3d')) { + $data['transaction']['enforce_3d'] = 1; + } + + // check if Order has subscription item + $subscription = false; + foreach ($order->getItems() as $item) { + $additionalData = []; + if (!empty($item->getAdditionalData())) { + $additionalData = json_decode($item->getAdditionalData(), true); + } + + if (!empty($additionalData['period_unit']) && !empty($additionalData['billing_frequency'])) { + $subscription = true; + break; + } + } + + //If subscription order then set create_token default + if ($subscription) { + if (!isset($data['transaction']['create_token']) && !isset($data['transaction']['payment_data']['token'])) { + $data['transaction']['create_token'] = 1; + } + } + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $coreSession = $objectManager->create(\Magento\Framework\Session\SessionManagerInterface::class); + + if ($coreSession->getRecurringProcess()) { + if (in_array($paymentMethodCode, [ConfigProvider::NOVALNET_CC, ConfigProvider::NOVALNET_PAYPAL])) { + unset($data['transaction']['return_url']); + unset($data['transaction']['error_return_url']); + } + } + + return $data; + } + + /** + * Build Custom params + * + * @param string $paymentMethodCode + * @return array + */ + public function buildCustomParams($paymentMethodCode) + { + $data['custom'] = [ + 'lang' => $this->novalnetRequestHelper->getDefaultLanguage(), + ]; + + if ($this->novalnetRequestHelper->isAdmin()) { + $data['custom']['input1'] = 'admin_user'; + $data['custom']['inputval1'] = $this->authSession->getUser()->getID(); + } + + if ($this->novalnetRequestHelper->getMethodSession($paymentMethodCode)->getData($paymentMethodCode . '_create_token') == '1') { + $data['custom']['input2'] = 'create_token'; + $data['custom']['inputval2'] = 1; + } + + return $data; + } + + /** + * Build cart info params + * + * @param string $paymentMethodCode + * @return array + */ + public function buildCartInfoParams($paymentMethodCode) + { + $data['cart_info'] = []; + if ($paymentMethodCode == ConfigProvider::NOVALNET_PAYPAL) { + $quote = $this->cart->getQuote(); + $discount = $quote->getBaseSubtotal() - $quote->getBaseSubtotalWithDiscount(); + $discount = ($discount > 0) ? $this->novalnetRequestHelper->getFormattedAmount($discount) : 0; + $taxAmount = !empty($quote->getTotals()['tax']->getValue()) ? $quote->getTotals()['tax']->getValue() : 0; + $data['cart_info'] = [ + 'items_shipping_price' => ($quote->getShippingAddress()->getBaseShippingAmount() > 0) ? $this->novalnetRequestHelper->getFormattedAmount($quote->getShippingAddress()->getBaseShippingAmount()) : 0, + 'items_tax_price' => ($taxAmount > 0) ? $this->novalnetRequestHelper->getFormattedAmount($taxAmount) : 0 + ]; + + $lineItems = []; + foreach ($quote->getAllVisibleItems() as $item) { + array_push($lineItems, [ + 'category' => ($item->getTypeId() == DownloadableProduct::TYPE_DOWNLOADABLE || $item->getTypeId() == ProductType::TYPE_VIRTUAL) ? 'virtual' : 'physical', + 'description' => '', + 'name' => $item->getName(), + 'price' => $this->novalnetRequestHelper->getFormattedAmount($item->getPrice()), + 'quantity' => $item->getQty() + ]); + } + + if ($discount) { + array_push($lineItems, [ + 'category' => '', + 'description' => '', + 'name' => 'Discount', + 'price' => '-' . $discount, + 'quantity' => 1 + ]); + } + + $data['cart_info']['line_items'] = $lineItems; + } + + return $data; + } + + /** + * Build Extension params + * + * @param array $buildSubject + * @param string|bool $refundAction + * @return array + */ + public function buildExtensionParams($buildSubject, $refundAction = false) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); + $additionalData = $paymentDataObject->getPayment()->getAdditionalData(); + $storeId = $paymentDataObject->getPayment()->getOrder()->getStoreId(); + + if ($additionalData) { + $additionalData = $this->novalnetRequestHelper->isSerialized($additionalData) + ? $this->serializer->unserialize($additionalData) + : json_decode($additionalData, true); + + $data['transaction'] = [ + 'tid' => $additionalData['NnTid'] + ]; + + if ($refundAction) { + $refundAmount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject); + + $data['transaction']['amount'] = $this->novalnetRequestHelper->getFormattedAmount($refundAmount); + + if (!empty($additionalData['NnZeroAmountBooking']) && !empty($additionalData['NnZeroAmountDone'])) { + $data['transaction']['tid'] = $additionalData['NnZeroAmountRefTid']; + } + } + + $data['custom'] = [ + 'lang' => $this->novalnetRequestHelper->getDefaultLanguage(), + 'shop_invoked' => 1 + ]; + $data['storeId'] = $storeId; + return $data; + } + } + + /** + * Get Street from address + * + * @param object $address + * @return string + */ + public function getStreet($address) + { + if (method_exists($address, 'getStreetFull')) { + $street = $address->getStreetFull(); + } else { + if ($address->getStreetLine1()) { + $street = implode(' ', [$address->getStreetLine1(), $address->getStreetLine2()]); + } else { + $street = (!empty($address->getStreet())) ? implode(' ', $address->getStreet()) : ''; + } + } + + return $street; + } + + /** + * Get filter standard param + * + * @param array $requestData + * + * @return array + */ + protected function filterStandardParameter($requestData) + { + $excludedParams = ['test_mode', 'enforce_3d', 'amount', 'storeId']; + + foreach ($requestData as $key => $value) { + if (is_array($value)) { + $requestData[$key] = $this->filterStandardParameter($requestData[$key]); + } + + if (!in_array($key, $excludedParams) && empty($requestData[$key])) { + unset($requestData[$key]); + } + } + + return $requestData; + } +} diff --git a/Gateway/Request/AuthorizationDataBuilder.php b/Gateway/Request/AuthorizationDataBuilder.php new file mode 100755 index 0000000..60cebec --- /dev/null +++ b/Gateway/Request/AuthorizationDataBuilder.php @@ -0,0 +1,60 @@ +getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (!empty($additionalData['NnTxnSecret']) || + in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + ) + ) { + return ['action' => 'NN_Authorize']; + } + + return parent::build($buildSubject); + } +} diff --git a/Gateway/Request/CaptureDataBuilder.php b/Gateway/Request/CaptureDataBuilder.php new file mode 100755 index 0000000..565973b --- /dev/null +++ b/Gateway/Request/CaptureDataBuilder.php @@ -0,0 +1,73 @@ +getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + $order = $payment->getOrder(); + $transactionStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $order) : ''; + + if ($transactionStatus == 'ON_HOLD' && !empty($this->urlInterface->getCurrentUrl()) && + !preg_match('/callback/i', $this->urlInterface->getCurrentUrl()) + ) { + return parent::buildExtensionParams($buildSubject); + } elseif (!empty($this->urlInterface->getCurrentUrl()) && preg_match('/callback/i', $this->urlInterface->getCurrentUrl())) { + return ['action' => 'NN_Capture', 'Async' => 'callback']; + } elseif (!empty($additionalData['NnZeroAmountCapture']) || !empty($additionalData['NnZeroAmountBooking'])) { + return ['action' => 'NN_ZeroCapture']; + } elseif (!empty($additionalData['NnTxnSecret']) || + (!empty($this->urlInterface->getCurrentUrl()) && preg_match('/callback/i', $this->urlInterface->getCurrentUrl())) || + (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + ) && $transactionStatus == 'CONFIRMED') + ) { + return ['action' => 'NN_Capture']; + } + + return parent::build($buildSubject); + } +} diff --git a/Gateway/Request/InitializeDataBuilder.php b/Gateway/Request/InitializeDataBuilder.php new file mode 100755 index 0000000..ee8cd23 --- /dev/null +++ b/Gateway/Request/InitializeDataBuilder.php @@ -0,0 +1,34 @@ +getPayment(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + if (!empty($additionalData['NnZeroAmountBooking'])) { + return ['action' => 'NN_ZeroVoid']; + } + + return parent::buildExtensionParams($buildSubject); + } +} diff --git a/Gateway/Response/CcPaymentHandler.php b/Gateway/Response/CcPaymentHandler.php new file mode 100755 index 0000000..d30f102 --- /dev/null +++ b/Gateway/Response/CcPaymentHandler.php @@ -0,0 +1,140 @@ +dateTime = $dateTime; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + } + + /** + * Handles transaction authorize and capture for Credit Card payment + * + * @param array $handlingSubject + * @param array $paymentResponse + * @return void + */ + public function handle(array $handlingSubject, array $paymentResponse) + { + $response = new \Magento\Framework\DataObject(); + $response->setData($paymentResponse); + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); + $order = $paymentDataObject->getOrder(); + $payment = $paymentDataObject->getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $additionalData = $payment->getAdditionalData() + ? ($this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true)) : []; + $transactionStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $order) : ''; + + if ($response->getData('action') == 'NN_ZeroCapture') { + $payment->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + } elseif (in_array($response->getData('action'), ['NN_Authorize', 'NN_Capture']) && + isset($additionalData['NnTid']) + ) { + // Authorize or Capture CC3d initial transaction + $payment->setTransactionId($additionalData['NnTid']) + ->setAmount($order->getGrandTotalAmount()) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + + if ($transactionStatus == 'ON_HOLD') { + $payment->setTransactionId($additionalData['NnTid']); + } + + if ($response->getData('Async') == 'callback') { + $payment->setTransactionId($additionalData['NnTid'] . '-capture'); + } + } elseif (!empty($response->getData())) { + if ($response->getData('result/redirect_url')) { + $payment->setAdditionalData( + $this->jsonHelper->jsonEncode($this->novalnetRequestHelper->buildRedirectAdditionalData($response)) + ); + } else { + if ($transactionStatus == 'ON_HOLD') { + $additionalData['ApiProcess'] = 'capture'; + $additionalData['ApiProcessedAt'] = $this->dateTime->date('d-m-Y H:i:s'); + $additionalData['NnStatus'] = $response->getData('transaction/status'); + // Capture the Authorized transaction + $payment->setTransactionId($response->getData('transaction/tid') . '-capture') + ->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + } else { + // Authorize or Capture the CC transaction + $payment->setTransactionId($response->getData('transaction/tid')) + ->setAmount($order->getGrandTotalAmount()) + ->setAdditionalData( + $this->jsonHelper->jsonEncode( + $this->novalnetRequestHelper->buildAdditionalData($response, $payment) + ) + ) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + + // Store payment data if token exist + if ($response->getData('result/status') == 'SUCCESS' && $response->getData('transaction/payment_data/token')) { + $this->novalnetRequestHelper->savePaymentToken($order, $paymentMethodCode, $response); + } + } + } + } + } +} diff --git a/Gateway/Response/PaymentHandler.php b/Gateway/Response/PaymentHandler.php new file mode 100755 index 0000000..8a7c6d4 --- /dev/null +++ b/Gateway/Response/PaymentHandler.php @@ -0,0 +1,286 @@ +dateTime = $dateTime; + $this->timeZone = $timeZone; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + } + + /** + * Handles transaction authorize and capture + * + * @param array $handlingSubject + * @param array $paymentResponse + * @return void + */ + public function handle(array $handlingSubject, array $paymentResponse) + { + $response = new \Magento\Framework\DataObject(); + $response->setData($paymentResponse); + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); + $order = $paymentDataObject->getOrder(); + $payment = $paymentDataObject->getPayment(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + if ($this->novalnetRequestHelper->isSerialized($payment->getAdditionalData())) { + $additionalData = $this->serializer->unserialize($payment->getAdditionalData()); + } else { + $additionalData = json_decode($payment->getAdditionalData(), true); + } + } + + $transactionStatus = ''; + if (!empty($additionalData['NnStatus'])) { + $transactionStatus = $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $order); + } + + if ($response->getData('action') == 'NN_ZeroCapture') { + $payment->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + } elseif (in_array($response->getData('action'), ['NN_Authorize', 'NN_Capture']) && + isset($additionalData['NnTid']) + ) { + // Authorize or Capture the initial redirect transaction + $payment->setTransactionId($additionalData['NnTid']) + ->setAmount($order->getGrandTotalAmount()) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + + if ($transactionStatus == 'ON_HOLD') { + $payment->setTransactionId($additionalData['NnTid']); + } + + if ($response->getData('Async') == 'callback') { // Capture from Novalnet admin portal through callback + $payment->setTransactionId($additionalData['NnTid'] . '-capture'); + } + } elseif (!empty($response->getData())) { + if (!empty($response->getData('result/redirect_url'))) { + $payment->setAdditionalData( + $this->jsonHelper->jsonEncode($this->novalnetRequestHelper->buildRedirectAdditionalData($response)) + ); + } else { + if ($transactionStatus == 'ON_HOLD') { + $additionalData = $this->handleOnHold($additionalData, $response, $paymentMethodCode); + // Capture the Authorized transaction + $payment->setTransactionId($response->getData('transaction/tid') . '-capture') + ->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + // update Paypal Token information if null available + if ($paymentMethodCode == ConfigProvider::NOVALNET_PAYPAL) { + $this->savePaymentToken($response, $order); + } + } else { + // Authorize or Capture the transaction + $payment->setTransactionId($response->getData('transaction/tid')) + ->setAmount($order->getGrandTotalAmount()) + ->setAdditionalData( + $this->jsonHelper->jsonEncode($this->novalnetRequestHelper->buildAdditionalData($response, $payment)) + )->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + )) { + $amount = $this->novalnetRequestHelper->getFormattedAmount($response->getData('transaction/amount'), 'RAW'); + if (in_array($response->getData('transaction/status'), ['PENDING', 'ON_HOLD'])) { + $payment->authorize(true, $amount); + } elseif ($response->getData('transaction/status') == 'CONFIRMED') { + $payment->setTransactionId($response->getData('transaction/tid')) + ->setLastTransId($response->getData('transaction/tid')) + ->capture(null) + ->setAmount($amount) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + } + } + } + } + } + + // Store payment data if token exist + if ($response->getData('result/status') == 'SUCCESS' && $response->getData('transaction/payment_data/token')) { + $this->novalnetRequestHelper->savePaymentToken($order, $paymentMethodCode, $response); + } + } + + /** + * Handles save paypal payment token + * + * @param object $response + * @param object $order + * @return void + */ + private function savePaymentToken($response, $order) + { + $transactionStatus = $this->transactionStatusModel->getCollection()->setPageSize(1) + ->addFieldToFilter('order_id', $order->getOrderIncrementId()) + ->getFirstItem(); + if ($transactionStatus->getId()) { + $tokenInfo = $transactionStatus->getTokenInfo(); + if (!empty($tokenInfo)) { + $tokenInfo = json_decode($tokenInfo, true); + } + if ($response->getData('transaction/payment_data/paypal_account')) { + $tokenInfo['NnPaypalAccount'] = $response->getData('transaction/payment_data/paypal_account'); + } + if ($response->getData('transaction/payment_data/paypal_transaction_id')) { + $tokenInfo['NnPaypalTransactionId'] = $response->getData('transaction/payment_data/paypal_transaction_id'); + } + if (!empty($tokenInfo)) { + $transactionStatus->setTokenInfo($this->jsonHelper->jsonEncode($tokenInfo))->save(); + } + } + } + + /** + * Handles On Hold actions + * + * @param array $additionalData + * @param object $response + * @param string $paymentMethodCode + * @return array + */ + private function handleOnHold($additionalData, $response, $paymentMethodCode) + { + $additionalData['ApiProcess'] = 'capture'; + $additionalData['ApiProcessedAt'] = $this->dateTime->date('d-m-Y H:i:s'); + $additionalData['NnStatus'] = $response->getData('transaction/status'); + + $this->transactionStatusModel->loadByAttribute($response->getData('transaction/order_no'), 'order_id') + ->setStatus($response->getData('transaction/status'))->save(); + + // Due date update for Invoice payment + if (in_array( + $paymentMethodCode, + [ConfigProvider::NOVALNET_INVOICE, ConfigProvider::NOVALNET_INVOICE_GUARANTEE, ConfigProvider::NOVALNET_INVOICE_INSTALMENT] + )) { + $formatDate = $this->timeZone->formatDate( + $response->getData('transaction/due_date'), + \IntlDateFormatter::LONG + ); + $note = (!empty($additionalData['NnInvoiceComments'])) ? explode('|', $additionalData['NnInvoiceComments']) : []; + $additionalData['NnInvoiceComments'] = (!empty($note)) ? implode('|', $note) : ''; + $additionalData['NnDueDate'] = $formatDate; + } + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + )) { + $instalmentCycleAmount = $this->novalnetRequestHelper->getFormattedAmount( + $response->getData('instalment/cycle_amount'), + 'RAW' + ); + $additionalData['InstallPaidAmount'] = $instalmentCycleAmount; + $additionalData['PaidInstall'] = $response->getData('instalment/cycles_executed'); + $additionalData['DueInstall'] = $response->getData('instalment/pending_cycles'); + $additionalData['NextCycle'] = $response->getData('instalment/next_cycle_date'); + $additionalData['InstallCycleAmount'] = $instalmentCycleAmount; + + if ($futureInstalmentDates = $response->getData('instalment/cycle_dates')) { + foreach ($futureInstalmentDates as $cycle => $futureInstalmentDate) { + $additionalData['InstalmentDetails'][$cycle] = [ + 'amount' => $instalmentCycleAmount, + 'nextCycle' => $futureInstalmentDate ? date('Y-m-d', strtotime($futureInstalmentDate)) : '', + 'paidDate' => ($cycle == 1) ? date('Y-m-d') : '', + 'status' => ($cycle == 1) ? 'Paid' : 'Pending', + 'reference' => ($cycle == 1) ? $response->getData('transaction/tid') : '' + ]; + } + } + + $additionalData['InstalmentDetails'][1] = [ + 'amount' => $instalmentCycleAmount, + 'nextCycle' => $response->getData('instalment/next_cycle_date'), + 'paidDate' => date('Y-m-d'), + 'status' => 'Paid', + 'reference' => $response->getData('transaction/tid') + ]; + } + + return $additionalData; + } +} diff --git a/Gateway/Response/RedirectAuthorizeHandler.php b/Gateway/Response/RedirectAuthorizeHandler.php new file mode 100755 index 0000000..0c4775f --- /dev/null +++ b/Gateway/Response/RedirectAuthorizeHandler.php @@ -0,0 +1,73 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + } + + /** + * Handles transaction authorize for Redirect payments + * + * @param array $handlingSubject + * @param array $response + * @return void + */ + public function handle(array $handlingSubject, array $response) + { + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); + $order = $paymentDataObject->getOrder(); + $payment = $paymentDataObject->getPayment(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + + // Authorize initial transaction + $payment->setTransactionId($additionalData['NnTid']) + ->setAmount($order->getGrandTotalAmount()) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false); + } +} diff --git a/Gateway/Response/RefundHandler.php b/Gateway/Response/RefundHandler.php new file mode 100755 index 0000000..eb76199 --- /dev/null +++ b/Gateway/Response/RefundHandler.php @@ -0,0 +1,124 @@ +pricingHelper = $pricingHelper; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + } + + /** + * Handles transaction refund + * + * @param array $handlingSubject + * @param array $paymentResponse + * @return void + */ + public function handle(array $handlingSubject, array $paymentResponse) + { + $response = new \Magento\Framework\DataObject(); + $response->setData($paymentResponse); + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); + $refundAmount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($handlingSubject); + + $payment = $paymentDataObject->getPayment(); + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + $parentTid = $additionalData['NnTid']; + $lastTransid = !empty($payment->getLastTransId()) ? $payment->getLastTransId() : $additionalData['NnTid']; + if (!empty($additionalData['NnZeroAmountBooking']) && !empty($additionalData['NnZeroAmountDone'])) { + $parentTid = $additionalData['NnZeroAmountRefTid']; + $lastTransid = !empty($payment->getLastTransId()) ? $payment->getLastTransId() : $additionalData['NnZeroAmountRefTid']; + $lastTransid = (strpos($lastTransid, '-zeroamount') !== false) ? $this->novalnetRequestHelper->makeValidNumber($lastTransid) : $lastTransid; + } + + $additionalData['NnStatus'] = $response->getData('transaction/status'); + $noOfRefunds = empty($additionalData['NnRefundsOccured']) ? 1 : $additionalData['NnRefundsOccured'] + 1; + $additionalData['NnRefundsOccured'] = $noOfRefunds; + + $refundTid = $response->getData('transaction/refund/tid') ? $response->getData('transaction/refund/tid') : ( + (strpos($lastTransid, '-refund') !== false) ? + $this->novalnetRequestHelper->makeValidNumber($lastTransid) . '-refund' . $noOfRefunds + : $lastTransid . '-refund'); + + $refundAmount = $this->pricingHelper->currency($refundAmount, true, false); + $additionalData['NnRefunded'][$refundTid]['reftid'] = $refundTid; + $additionalData['NnRefunded'][$refundTid]['refamount'] = $refundAmount; + $additionalData['NnRefunded'][$refundTid]['reqtid'] = $parentTid; + + $this->transactionStatusModel->loadByAttribute($response->getData('transaction/order_no'), 'order_id') + ->setStatus($response->getData('transaction/status'))->save(); + $payment->setTransactionId($refundTid) + ->setLastTransId($refundTid) + ->setParentTransactionId($parentTid) + ->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->setIsTransactionClosed(true) + ->setShouldCloseParentTransaction(!$payment->getCreditmemo()->getInvoice()->canRefund()); + } +} diff --git a/Gateway/Response/VoidHandler.php b/Gateway/Response/VoidHandler.php new file mode 100755 index 0000000..c0042e4 --- /dev/null +++ b/Gateway/Response/VoidHandler.php @@ -0,0 +1,106 @@ +dateTime = $dateTime; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + } + + /** + * Handles transaction void + * + * @param array $handlingSubject + * @param array $paymentResponse + * @return void + */ + public function handle(array $handlingSubject, array $paymentResponse) + { + $response = new \Magento\Framework\DataObject(); + $response->setData($paymentResponse); + $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject); + $payment = $paymentDataObject->getPayment(); + $additionalData = []; + + if ($response->getData('action') !== 'NN_ZeroVoid') { + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + } + $additionalData['ApiProcess'] = 'void'; + $additionalData['ApiProcessedAt'] = $this->dateTime->date('d-m-Y H:i:s'); + $additionalData['NnStatus'] = $response->getData('transaction/status'); + $additionalData['NnComments'] = '
' . __('Payment Failed') . ' - ' + . $response->getData('transaction/status') . ''; + $this->transactionStatusModel->loadByAttribute($response->getData('transaction/order_no'), 'order_id') + ->setStatus($response->getData('transaction/status'))->save(); + + $payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->setIsTransactionClosed(true) + ->setShouldCloseParentTransaction(true); + } + } +} diff --git a/Gateway/Validator/ResponseCodeValidator.php b/Gateway/Validator/ResponseCodeValidator.php new file mode 100755 index 0000000..9bec07e --- /dev/null +++ b/Gateway/Validator/ResponseCodeValidator.php @@ -0,0 +1,48 @@ +setData(SubjectReader::readResponse($validationSubject)); + $isValid = true; + $msg = []; + + if (empty($response->getData('action')) && $response->getData('result/status') != 'SUCCESS') { + $isValid = false; + $msg = [__($response->getData('result/status_text'))]; + } + + return $this->createResult($isValid, $msg); + } +} diff --git a/Helper/Request.php b/Helper/Request.php new file mode 100755 index 0000000..38945c8 --- /dev/null +++ b/Helper/Request.php @@ -0,0 +1,1265 @@ +appState = $appState; + $this->pricingHelper = $pricingHelper; + $this->productMetadata = $productMetadata; + $this->moduleList = $moduleList; + $this->requestInterface = $requestInterface; + $this->resolverInterface = $resolverInterface; + $this->serializer = $serializer; + $this->jsonHelper = $jsonHelper; + $this->countryFactory = $countryFactory; + $this->customerSession = $customerSession; + $this->checkoutSession = $checkoutSession; + $this->adminCheckoutSession = $adminCheckoutSession; + $this->checkoutSessionFactory = $checkoutSessionFactory; + $this->dateTime = $dateTime; + $this->invoiceSender = $invoiceSender; + $this->orderEmailSender = $orderEmailSender; + $this->transactionBuilder = $transactionBuilder; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetConfig = $novalnetConfig; + $this->serverAddress = $serverAddress; + $this->novalnetLogger = $novalnetLogger; + $this->directoryHelper = $directoryHelper; + $this->scopeConfig = $scopeConfig; + $this->storeManager = $storeManager; + $this->taxHelper = $taxHelper; + $this->coreSession = $coreSession; + $this->regionModel = $regionModel; + } + + /** + * Get request headers + * + * @param string|bool $payment_access_key + * @param int|null $storeId + * @return array + */ + public function getRequestHeaders($payment_access_key = false, $storeId = null) + { + if (!$payment_access_key) { + $payment_access_key = $this->novalnetConfig->getGlobalConfig('payment_access_key', $storeId); + } + + $encoded_data = base64_encode($payment_access_key); + return [ + 'Content-Type' => 'application/json', + 'Charset' => 'utf-8', + 'Accept' => 'application/json', + 'X-NN-Access-Key' => $encoded_data, + ]; + } + + /** + * Build addtional data for redirect payment + * + * @param mixed $response + * @return array + */ + public function buildRedirectAdditionalData($response) + { + if ($response->getData('transaction/txn_secret')) { + $additionalData['NnRedirectURL'] = $response->getData('result/redirect_url'); + $additionalData['NnTxnSecret'] = $response->getData('transaction/txn_secret'); + return $additionalData; + } + + return []; + } + + /** + * Build addtional data for payment + * + * @param mixed $response + * @param mixed $payment + * @return array + */ + public function buildAdditionalData($response, $payment) + { + $additionalData = []; + if (!empty($payment->getAdditionalData())) { + $additionalData = $this->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true); + + if (isset($additionalData['NnRedirectURL'])) { + unset($additionalData['NnRedirectURL']); + } + } + + $paymentMethodCode = $this->novalnetConfig->getPaymentCodeByType($response->getData('transaction/payment_type')); + + $dataToStore = ['transaction/test_mode', 'transaction/status', 'transaction/tid', 'custom/lang', 'transaction/due_date', 'transaction/partner_payment_reference', 'transaction/payment_data/cc_3d', 'transaction/checkout_js', 'transaction/checkout_token']; + + foreach ($dataToStore as $responseData) { + if ($response->getData($responseData)) { + $responseDataFormatted = preg_replace('/(?:.*)\/(.*)/', ucwords('$1'), $responseData); + $responseDataFormatted = str_replace('_', '', ucwords($responseDataFormatted, '_')); + $additionalData['Nn' . $responseDataFormatted] = $response->getData($responseData); + } + } + + $invoiceAmount = $this->pricingHelper->currency( + $this->getFormattedAmount(($response->getData('instalment/cycle_amount') ? $response->getData('instalment/cycle_amount') + : $response->getData('transaction/amount')), 'RAW'), + true, + false + ); + $additionalData['NnAmount'] = $invoiceAmount; + + if (!empty($additionalData['NnDueDate'])) { + $additionalData['NnDueDate'] = $this->dateTime->formatDate( + $additionalData['NnDueDate'], + \IntlDateFormatter::LONG + ); + } + + if ($response->getData('transaction/bank_details')) { + $additionalData['NnInvoiceComments'] = $this->getInvoiceComments($response); + } + + if ($paymentMethodCode == ConfigProvider::NOVALNET_CASHPAYMENT) { + $additionalData['CpDueDate'] = $this->dateTime->formatDate( + $response->getData('transaction/due_date'), + \IntlDateFormatter::LONG + ); + + $cashPaymentStores = []; + foreach ($response->getData('transaction/nearest_stores') as $key => $cashPaymentStore) { + $cashPaymentStores[] = [ + 'title' => $cashPaymentStore['store_name'], + 'street' => $cashPaymentStore['street'], + 'city' => $cashPaymentStore['city'], + 'zipcode' => $cashPaymentStore['zip'], + 'country' => $this->countryFactory->create()->loadByCode($cashPaymentStore['country_code']) + ->getName() + ]; + } + + $additionalData['CashpaymentStores'] = $cashPaymentStores; + } + + if ($response->getData('instalment')) { + $instalmentCycleAmount = $this->getFormattedAmount( + $response->getData('instalment/cycle_amount'), + 'RAW' + ); + $additionalData['InstallPaidAmount'] = $instalmentCycleAmount; + $additionalData['PaidInstall'] = $response->getData('instalment/cycles_executed'); + $additionalData['DueInstall'] = $response->getData('instalment/pending_cycles'); + $additionalData['NextCycle'] = $response->getData('instalment/next_cycle_date'); + $additionalData['InstallCycleAmount'] = $instalmentCycleAmount; + + if ($futureInstalmentDates = $response->getData('instalment/cycle_dates')) { + foreach (array_keys($futureInstalmentDates) as $cycle) { + $additionalData['InstalmentDetails'][$cycle] = [ + 'amount' => $instalmentCycleAmount, + 'nextCycle' => !empty($futureInstalmentDates[$cycle + 1]) ? date('Y-m-d', strtotime($futureInstalmentDates[$cycle + 1])) : '', + 'paidDate' => ($cycle == 1) ? date('Y-m-d') : '', + 'status' => ($cycle == 1) ? 'Paid' : 'Pending', + 'reference' => ($cycle == 1) ? $response->getData('transaction/tid') : '' + ]; + } + } + + } + + if ($this->novalnetConfig->isZeroAmountBookingSupported($paymentMethodCode) && + $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING + ) { + $additionalData['NnZeroAmountBooking'] = 1; + } + + $order = $payment->getOrder(); + $this->saveTransactionDetails($response, $paymentMethodCode); + + return $additionalData; + } + + /** + * Retrieves Novalnet Invoice Comments + * + * @param mixed $response + * @return string + */ + public function getInvoiceComments($response) + { + $invoicePaymentsNote = 'Account holder: ' . $response->getData('transaction/bank_details/account_holder'); + $invoicePaymentsNote .= '|IBAN: ' . $response->getData('transaction/bank_details/iban'); + $invoicePaymentsNote .= '|BIC: ' . $response->getData('transaction/bank_details/bic'); + $invoicePaymentsNote .= '|Bank: ' . $response->getData('transaction/bank_details/bank_name') + . ' ' . $response->getData('transaction/bank_details/bank_place'); + + $invoicePaymentsNote .= '|Payment References description:'; + if ($response->getData('instalment/cycle_amount')) { + $invoicePaymentsNote .= '|Payment Reference:' . $response->getData('transaction/tid'); + } else { + $invoicePaymentsNote .= '|Payment reference 1:' . $response->getData('transaction/tid'); + $invoicePaymentsNote .= '|Payment reference 2:' . $response->getData('transaction/invoice_ref'); + } + + return $invoicePaymentsNote; + } + + /** + * Saves transaction details into Novalnet table + * + * @param mixed $response + * @param string $paymentMethodCode + * @return void + */ + public function saveTransactionDetails($response, $paymentMethodCode) + { + $this->transactionStatusModel->setOrderId($response->getData('transaction/order_no')) + ->setTid($response->getData('transaction/tid')) + ->setStatus($response->getData('transaction/status')) + ->setCustomerId($this->getCustomerId()) + ->setPaymentMethod($paymentMethodCode) + ->save(); + } + + /** + * Check payment hash for redirect payments + * + * @param array $response + * @param array $additionalData + * @return bool + */ + public function checkPaymentHash($response, $additionalData) + { + $accessKey = (!empty($this->novalnetConfig->getGlobalConfig('payment_access_key'))) ? trim($this->novalnetConfig->getGlobalConfig('payment_access_key')) : ''; + $checksumString = $response['tid'] . $additionalData['NnTxnSecret'] . $response['status'] + . strrev($accessKey); + $generatedChecksum = (!empty($checksumString)) ? hash('sha256', $checksumString) : ''; + + if ($generatedChecksum !== $response['checksum']) { + return false; + } + + return true; + } + + /** + * Check return data for redirect payments and update order accordingly + * + * @param mixed $response + * @param mixed $order + * @param mixed $payment + * @return bool + */ + public function checkReturnedData($response, $order, $payment) + { + if ($response->getData('transaction/status') == 'FAILURE') { + $this->saveCanceledOrder($response, $order); + return false; + } + $storeId = $order->getStoreId(); + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + // Retrieves additional payment data for the order + $additionalData = $this->buildAdditionalData($response, $payment); + $amount = $this->getFormattedAmount($response->getData('transaction/amount'), 'RAW'); + $payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $setOrderStatus = $this->novalnetConfig->getGlobalOnholdStatus($storeId); + + if ($response->getData('transaction/status') == 'CONFIRMED' && empty($additionalData['NnZeroAmountBooking'])) { + // capture transaction + $payment->setTransactionId($additionalData['NnTid']) + ->setLastTransId($additionalData['NnTid']) + ->capture(null) + ->setAmount($amount) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false) + ->save(); + + $setOrderStatus = $this->novalnetConfig->getPaymentConfig( + $paymentMethodCode, + 'order_status', + $storeId + ); + } else { + // authorize transaction + if (!empty($additionalData['NnZeroAmountBooking'])) { + $payment->authorize(true, $order->getBaseGrandTotal())->save(); + } else { + $payment->authorize(true, $amount)->save(); + } + + if ($response->getData('transaction/status') == 'PENDING') { + $setOrderStatus = 'pending'; + } + } + + $order->setState(Order::STATE_PROCESSING) + ->setStatus($setOrderStatus) + ->save(); + $order->addStatusHistoryComment(__('Customer successfully returned from Novalnet'), false) + ->save(); + + // Order Confirmation and Invoice email + if ($order->getCanSendNewEmailFlag()) { + try { + $this->orderEmailSender->send($order); + $invoice = current($order->getInvoiceCollection()->getItems()); + if ($invoice) { + $this->invoiceSender->send($invoice); + } + } catch (\Exception $e) { + $this->_logger->critical($e); + $this->novalnetLogger->error($e); + } + } + + //update payment token + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + + $subscription = false; + if (!empty($order->getItems())) { + foreach ($order->getItems() as $item) { + $additionalData = []; + if (!empty($item->getAdditionalData())) { + $additionalData = json_decode($item->getAdditionalData(), true); + } + + if (!empty($additionalData['period_unit']) && !empty($additionalData['billing_frequency'])) { + $subscription = true; + break; + } + } + if ($subscription) { + if (in_array($paymentMethodCode, [ConfigProvider::NOVALNET_CC, ConfigProvider::NOVALNET_PAYPAL])) { + $token = !empty($response->getData('transaction/payment_data/token')) ? $response->getData('transaction/payment_data/token') : ''; + if (!empty($token)) { + $subscriptionModel = $objectManager->create(\Novalnet\Subscription\Model\SubscriptionDetails::class); + $subscriptionModel = $subscriptionModel->getCollection()->addFieldToFilter('order_id', $order->getIncrementId())->getFirstItem(); + $subscriptionModel->setToken($token)->save(); + } + + } + } + } + + return true; + } + + /** + * Save canceled payment transaction + * + * @param mixed $response + * @param mixed $order + * @param string|bool $statusText + * @return void + */ + public function saveCanceledOrder($response, $order, $statusText = false) + { + $payment = $order->getPayment(); + // Get payment transaction status message + $statusMessage = ($statusText) + ? $statusText : $response->getData('result/status_text'); + + $additionalData = $payment->getAdditionalData() ? ($this->isSerialized($payment->getAdditionalData()) + ? $this->serializer->unserialize($payment->getAdditionalData()) + : json_decode($payment->getAdditionalData(), true)) : []; + + $nnAmount = $this->pricingHelper->currency( + $this->getFormattedAmount(($response->getData('instalment/cycle_amount') ? $response->getData('instalment/cycle_amount') + : $response->getData('transaction/amount')), 'RAW'), + true, + false + ); + + $additionalData['NnTid'] = $response->getData('transaction/tid'); + $additionalData['NnStatus'] = $response->getData('transaction/status'); + $additionalData['NnTestMode'] = $response->getData('transaction/test_mode'); + $additionalData['NnAmount'] = $nnAmount; + $additionalData['NnComments'] = '' . __('Payment Failed') . ' - ' + . $statusMessage . ''; + $payment->setLastTransId($additionalData['NnTid']) + ->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->save(); + + // UnHold and Cancel the order with the cancel text + if ($order->canUnhold()) { + $order->unhold(); + } + + //Cancel subscription if exist + $paymentMethodCode = $payment->getMethodInstance()->getCode(); + $subscription = false; + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + if (!empty($order->getItems())) { + foreach ($order->getItems() as $item) { + $additionalData = (!empty($item->getAdditionalData())) ? json_decode($item->getAdditionalData(), true) : []; + if (!empty($additionalData['period_unit']) && !empty($additionalData['billing_frequency'])) { + $subscription = true; + break; + } + } + } + if ($subscription) { + if (in_array($paymentMethodCode, [ConfigProvider::NOVALNET_CC, ConfigProvider::NOVALNET_PAYPAL])) { + $subscriptionModel = $objectManager->create(\Novalnet\Subscription\Model\SubscriptionItems::class); + $subscriptionitems = $subscriptionModel->getCollection()->addFieldToFilter('order_id', $order->getIncrementId()); + if (!empty($subscriptionitems)) { + foreach ($subscriptionitems as $subscriptionitem) { + $subscriptionitem->setState('CANCELED')->save(); + } + } + } + } + + $order->registerCancellation($statusMessage)->save(); + } + + /** + * Save payment token + * + * @param mixed $order + * @param string $paymentMethodCode + * @param mixed $response + * @return void + */ + public function savePaymentToken($order, $paymentMethodCode, $response) + { + if ($this->novalnetConfig->isOneClickPayment($paymentMethodCode)) { + if (strpos($paymentMethodCode, ConfigProvider::NOVALNET_SEPA) !== false) { + $paymentMethodCode = ConfigProvider::NOVALNET_SEPA; + } + $transactionStatusCollection = $this->transactionStatusModel->getCollection() + ->setPageSize(2) + ->setOrder('id', 'DESC') + ->addFieldToFilter('token', ['null' => false]) + ->addFieldToFilter('customer_id', $order->getCustomerId()) + ->addFieldToFilter('payment_method', ['like' => $paymentMethodCode . '%']); + // Override the old token if two tokens already exist + if ($transactionStatusCollection->count() >= 2) { + $this->transactionStatusModel->setEntityId($transactionStatusCollection->getFirstItem()->getId()); + } + + $responseTokens = ['transaction/payment_data/card_brand', 'transaction/payment_data/card_holder', 'transaction/payment_data/card_expiry_month', 'transaction/payment_data/card_expiry_year', 'transaction/payment_data/card_number', 'transaction/payment_data/iban', 'transaction/payment_data/account_holder', 'transaction/payment_data/paypal_account', 'transaction/payment_data/paypal_transaction_id']; + + foreach ($responseTokens as $responseToken) { + if ($response->getData($responseToken)) { + $responseTokenFormatted = preg_replace('/(?:transaction\/payment_data)\/(.*)/', ucwords('$1'), $responseToken); + $responseTokenFormatted = str_replace('_', '', ucwords($responseTokenFormatted, '_')); + $tokenInfo['Nn' . $responseTokenFormatted] = $response->getData($responseToken); + } + } + + $this->transactionStatusModel->setToken($response->getData('transaction/payment_data/token')); + if (!empty($tokenInfo) && $response->getData('custom/create_token') == '1') { + $this->transactionStatusModel->setTokenInfo($this->jsonHelper->jsonEncode($tokenInfo)); + } + $this->transactionStatusModel->save(); + } + } + + /** + * Restore cart items + * + * @param string $orderId + * @return void + */ + public function restoreQuote($orderId) + { + $this->checkoutSession->restoreQuote(); + $this->checkoutSession->setLastRealOrderId($orderId); + } + + /** + * Retrieve Magento version + * + * @return string + */ + public function getMagentoVersion() + { + return $this->productMetadata->getVersion(); + } + + /** + * Retrieve Novalnet version + * + * @return int + */ + public function getNovalnetVersion() + { + return $this->moduleList->getOne('Novalnet_Payment')['setup_version']; + } + + /** + * Get shop default language + * + * @return string + */ + public function getDefaultLanguage() + { + $defaultLocale = (!empty($this->resolverInterface->getDefaultLocale())) ? explode('_', $this->resolverInterface->getDefaultLocale()) : []; + return (is_array($defaultLocale) && !empty($defaultLocale)) ? $defaultLocale[0] : 'en'; + } + + /** + * Retrieves customer session model + * + * @return mixed + */ + public function getCustomerSession() + { + return $this->customerSession; + } + + /** + * Retrieve customer id from current session + * + * @return int|string + */ + public function getCustomerId() + { + if ($this->coreSession->getRecurringProcess()) { + return $this->coreSession->getCustomerId(); + } + + if ($this->customerSession->isLoggedIn()) { + return $this->customerSession->getCustomer()->getId(); + } elseif ($this->isAdmin()) { + $adminSession = $this->getAdminCheckoutSession(); + return $adminSession->getCustomerId() ? $adminSession->getCustomerId() : 'guest'; + } else { + return 'guest'; + } + } + + /** + * Check if the payment area is admin + * + * @return boolean + */ + public function isAdmin() + { + return (bool)($this->appState->getAreaCode() == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + } + + /** + * Retrieves admin checkout session model + * + * @return mixed + */ + public function getAdminCheckoutSession() + { + return $this->adminCheckoutSession; + } + + /** + * Retrieves Order Amount + * + * @return int + */ + public function getAmount() + { + $quote = (!$this->isAdmin()) + ? $this->checkoutSession->getQuote() + : $this->adminCheckoutSession->getQuote(); + return $this->getFormattedAmount($quote->getGrandTotal()); + } + + /** + * Retrieves Retrieves Billing Address from checkout session model + * + * @return array + */ + public function getBillingAddress() + { + $quote = (!$this->isAdmin()) + ? $this->checkoutSession->getQuote() + : $this->adminCheckoutSession->getQuote(); + $billingAddress = $quote->getBillingAddress(); + $firstName = ($billingAddress->getFirstname()) + ? $billingAddress->getFirstname() + : (($quote->getCustomerFirstname()) + ? $quote->getCustomerFirstname() + : ""); + $lastName = ($billingAddress->getLastname()) + ? $billingAddress->getLastname() + : (($quote->getCustomerLastname()) + ? $quote->getCustomerLastname() + : ""); + $billing = ['firstname' => $firstName, + 'lastname' => $lastName, + 'street' => $billingAddress->getStreet(), + 'city' => $billingAddress->getCity(), + 'country_id' => $billingAddress->getCountryId(), + 'email' => $billingAddress->getEmail(), + 'postcode' => $billingAddress->getPostcode(), + ]; + return $billing; + } + + /** + * Retrieves Shipping Address from checkout session model + * + * @return array + */ + public function getShippingAddress() + { + $quote = (!$this->isAdmin()) + ? $this->checkoutSession->getQuote() + : $this->adminCheckoutSession->getQuote(); + $shippingAddress = $quote->getShippingAddress(); + $firstName = ($shippingAddress->getFirstname()) + ? $shippingAddress->getFirstname() + : (($quote->getCustomerFirstname()) + ? $quote->getCustomerFirstname() + : ""); + $lastName = ($shippingAddress->getLastname()) + ? $shippingAddress->getLastname() + : (($quote->getCustomerLastname()) + ? $quote->getCustomerLastname() + : ""); + $shipping = ['firstname' => $firstName, + 'lastname' => $lastName, + 'street' => $shippingAddress->getStreet(), + 'city' => $shippingAddress->getCity(), + 'country_id' => $shippingAddress->getCountryId(), + 'email' => $shippingAddress->getEmail(), + 'postcode' => $shippingAddress->getPostcode(), + 'same_as_billing' => $shippingAddress->getSameAsBilling(), + ]; + return $shipping; + } + + /** + * Retrieves account holder name from the billing address + * + * @return string + */ + public function getAccountHolder() + { + $quote = (!$this->isAdmin()) + ? $this->checkoutSession->getQuote() + : $this->adminCheckoutSession->getQuote(); + $billingAddress = $quote->getBillingAddress(); + + if ($billingAddress->getFirstname() && $billingAddress->getLastname()) { + return $billingAddress->getFirstname() .' '. $billingAddress->getLastname(); + } elseif ($quote->getCustomerFirstname() && $quote->getCustomerLastname()) { + return $quote->getCustomerFirstname() .' '. $quote->getCustomerLastname(); + } else { + return ''; + } + } + + /** + * Retrieves Company from the billing address + * + * @return string + */ + public function getCustomerCompany() + { + $billingaddress = (!$this->isAdmin()) + ? $this->checkoutSession->getQuote()->getBillingAddress() + : $this->adminCheckoutSession->getQuote()->getBillingAddress(); + + return $billingaddress->getCompany(); + } + + /** + * Get IP address from request + * + * @return mixed + */ + public function getRequestIp() + { + $serverVariables = $this->requestInterface->getServer(); + $remoteAddrHeaders = ['HTTP_X_FORWARDED_HOST', 'HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', + 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; + + foreach ($remoteAddrHeaders as $header) { + if (property_exists($serverVariables, $header) === true) { + if (in_array($header, ['HTTP_X_FORWARDED_HOST', 'HTTP_X_FORWARDED_FOR'])) { + $forwardedIps = (!empty($serverVariables[$header])) ? explode(",", $serverVariables[$header]) : []; + $serverVariables[$header] = trim(end($forwardedIps)); + } + + return $serverVariables[$header]; + } + } + } + + /** + * Get Server IP address + * + * @return mixed + */ + public function getServerAddr() + { + return $this->serverAddress->getServerAddress(); + } + + /** + * Get the formated amount in cents/euro + * + * @param mixed $amount + * @param string $type + * @return mixed + */ + public function getFormattedAmount($amount, $type = 'CENT') + { + if (!empty($amount)) { + return ($type == 'RAW') ? number_format($amount / 100, 2, '.', '') : round($amount, 2) * 100; + } + + return null; + } + + /** + * Get the Amount with symbol + * + * @param mixed $amount + * @param int $storeId + * @return float|string + */ + public function getAmountWithSymbol($amount, $storeId) + { + return $this->pricingHelper->currencyByStore($amount, $storeId); + } + + /** + * Get payment method session + * + * @param string $paymentMethodCode + * @param bool $unset + * @return mixed + */ + public function getMethodSession($paymentMethodCode, $unset = false) + { + $checkoutSession = $this->checkoutSessionFactory->create(); + if (!$checkoutSession->hasData($paymentMethodCode) || $unset) { + $checkoutSession->setData($paymentMethodCode, new \Magento\Framework\DataObject([])); + } + + return $checkoutSession->getData($paymentMethodCode); + } + + /** + * Replace strings from the tid passed + * + * @param mixed $tid + * @return mixed + */ + public function makeValidNumber($tid) + { + return preg_replace('/[^0-9]+/', '', $tid); + } + + /** + * Check the value is numeric + * + * @param mixed $value + * @return bool + */ + public function checkIsNumeric($value) + { + if (!empty($value)) { + return (bool) preg_match('/^\d+$/', $value); + } + + return false; + } + + /** + * Check whether string is serialized + * + * @param mixed $data + * @return boolean + */ + public function isSerialized($data) + { + if (!empty($data)) { + $data = trim($data); + if ($data == 'N;') { + return true; + } + + $lastChar = substr($data, -1); + if (!is_string($data) || strlen($data) < 4 || $data[1] !== ':' + || ($lastChar !== ';' && $lastChar !== '}')) { + return false; + } + + $token = $data[0]; + switch ($token) { + case 's': + if (substr($data, -2, 1) !== '"') { + return false; + } + + // no break + case 'a': + case 'O': + return (bool) preg_match("/^{$token}:[0-9]+:/s", $data); + case 'b': + case 'i': + case 'd': + return (bool) preg_match("/^{$token}:[0-9.E-]+;$/", $data); + } + } + + return false; + } + + /** + * Get proper Status Text + * + * @param mixed $status + * @param mixed $order + * @return string + */ + public function getStatus($status, $order) + { + if ($this->checkIsNumeric($status) == true) { + if (in_array($status, $this->onholdStatus)) { + $status = 'ON_HOLD'; + } elseif (in_array($status, $this->pendingStatus)) { + $status = 'PENDING'; + } elseif ($status == '100') { + $payment = $order->getPayment(); + $paymentCode = $payment->getMethodInstance()->getCode(); + if (in_array( + $paymentCode, + [ + ConfigProvider::NOVALNET_INVOICE, + ConfigProvider::NOVALNET_PREPAYMENT, + ConfigProvider::NOVALNET_CASHPAYMENT + ] + )) { + $invoice_id = ''; + $invoice = []; + foreach ($order->getInvoiceCollection() as $invoice) { + $invoice_id = $invoice->getIncrementId(); + $invoice = $invoice->getData(); + } + if (!empty($invoice_id) && (in_array($paymentCode, [ConfigProvider::NOVALNET_PREPAYMENT, ConfigProvider::NOVALNET_CASHPAYMENT]) + || ($paymentCode == ConfigProvider::NOVALNET_INVOICE && $invoice['state'] == 2))) { + $status = 'CONFIRMED'; + } else { + $status = 'PENDING'; + } + } else { + $status = 'CONFIRMED'; + } + } elseif ($status == '103') { + $status = 'DEACTIVATED'; + } else { + $status = 'FAILURE'; + } + } + + return $status; + } + + /** + * Validate Customer Company param + * + * @param string $paymentMethod + * @return boolean + */ + public function validateCompany($paymentMethod) + { + $company = $this->getCustomerCompany(); + if (!empty($company) && $this->novalnetConfig->getPaymentConfig($paymentMethod, 'allow_b2b_customer')) { + if (preg_match('/^(?:\d+|(?:)\.?|[^a-zA-Z0-9]+|[a-zA-Z]{1})$|^(herr|frau|jahr|mr|miss|mrs|others|andere|anrede|salutation|null|none|keine|company|firma|no|na|n\/a|test|private|privat)$/i', $company)) { + return true; + } else { + return false; + } + } + return true; + } + + /** + * Get Country Code + * + * @param int $store + * @return string + */ + public function getCountryCode($store = null) + { + return $this->directoryHelper->getDefaultCountry($store); + } + + /** + * Get express checkout Enabled pages + * + * @param string $page + * @return array + */ + public function isPageEnabledForExpressCheckout($page) + { + $isApplePayEnabled = $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'active'); + $applePayEnabledPages = $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'enabled_pages'); + $applePayEnabledPages = (!empty($applePayEnabledPages)) ? explode(',', $applePayEnabledPages) : []; + + $isGooglePayEnabled = $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'active'); + $googlePayEnabledPages = $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'enabled_pages'); + $googlePayEnabledPages = (!empty($googlePayEnabledPages)) ? explode(',', $googlePayEnabledPages) : []; + + return [ + ConfigProvider::NOVALNET_APPLEPAY => (bool) ($isApplePayEnabled && $this->validateBasicParams() && in_array($page, $applePayEnabledPages) && $this->canUseForGuestCheckout()), + ConfigProvider::NOVALNET_GOOGLEPAY => (bool) ($isGooglePayEnabled && $this->validateBasicParams() && in_array($page, $googlePayEnabledPages) && $this->canUseForGuestCheckout()) + ]; + } + + /** + * Validate Novalnet basic params + * + * @return bool + */ + public function validateBasicParams() + { + return ($this->novalnetConfig->getGlobalConfig('signature') && + $this->novalnetConfig->getGlobalConfig('payment_access_key') && + $this->checkIsNumeric($this->novalnetConfig->getGlobalConfig('tariff_id'))); + } + + /** + * Can payment used for guest checkout + * + * @return bool + */ + public function canUseForGuestCheckout() + { + if ($this->getCustomerSession()->isLoggedIn()) { + return true; + }; + + return $this->scopeConfig->getValue( + 'checkout/options/guest_checkout', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->storeManager->getStore()->getId() + ); + } + + /** + * Get Configuration + * + * @param string $field + * @return mixed + */ + public function getSystemConfig($field) + { + return $this->scopeConfig->getValue( + $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->storeManager->getStore()->getId() + ); + } + + /** + * Get Payment sheet Configuration values + * + * @return array + */ + public function paymentSheetConfigurations() + { + return [ + ConfigProvider::NOVALNET_APPLEPAY => [ + 'btnType' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'button_style'), + 'btnTheme' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'button_theme'), + 'btnHeight' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'button_height'), + 'btnRadius' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'button_corner_radius'), + 'sellerName' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_APPLEPAY, 'seller_name'), + 'environment' => ($this->novalnetConfig->getTestMode(ConfigProvider::NOVALNET_APPLEPAY, $this->storeManager->getStore()->getId())) ? 'SANDBOX' : 'PRODUCTION' + ], + ConfigProvider::NOVALNET_GOOGLEPAY => [ + 'btnType' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'button_type'), + 'btnTheme' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'button_theme'), + 'btnHeight' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'button_height'), + 'sellerName' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'seller_name'), + 'environment' => ($this->novalnetConfig->getTestMode(ConfigProvider::NOVALNET_GOOGLEPAY, $this->storeManager->getStore()->getId())) ? 'SANDBOX' : 'PRODUCTION', + 'partnerId' => $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'merchant_id'), + 'enforce3d' => ($this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'enforce_3d')) ? $this->novalnetConfig->getPaymentConfig(ConfigProvider::NOVALNET_GOOGLEPAY, 'enforce_3d') : 0 + ], + 'countryCode' => $this->getCountryCode(), + 'currencyCode' => $this->storeManager->getStore()->getBaseCurrencyCode(), + 'langCode' => $this->getLanguageCodeForPaymentSheet(), + 'clientKey' => $this->novalnetConfig->getGlobalConfig('client_key') + ]; + } + + /** + * To get formatted language code for payment sheet + * + * @return string + */ + public function getLanguageCodeForPaymentSheet() + { + $defaultLocale = (!empty($this->resolverInterface->getDefaultLocale())) ? explode('_', $this->resolverInterface->getDefaultLocale()) : []; + return (is_array($defaultLocale) && !empty($defaultLocale[0]) && !empty($defaultLocale[1])) ? $defaultLocale[0] . '-' . $defaultLocale[1] : 'en-US'; + } + + /** + * Get tax calculation settings and set apple pay amount type + * + * @return bool + */ + public function isAmountPendingForExpressCheckout() + { + return ($this->taxHelper->getTaxBasedOn() == 'billing') ? true : false; + } + + /** + * Get region name by code + * + * @param string $regionCode + * @param string $countryCode + * @return string + */ + public function getRegionNameByCode($regionCode, $countryCode) + { + try { + $regionName = $this->regionModel->loadByCode($regionCode, $countryCode)->getName(); + + if (!empty($regionName)) { + return $regionName; + } + + return $regionCode; + } catch (\Exception $e) { + return $regionCode; + } + } +} diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 0000000..2731214 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,52 @@ +Freeware-Lizenzvereinbarung + +Deutsch: + +Präambel: +Die nachfolgende Vereinbarung regelt die Rechte und die Haftung zwischen Ihnen (im Folgenden „Partner“) und der Novalnet AG (im Folgenden „Novalnet“) in Bezug auf die von Novalnet kostenlos bereitgestellten Softwarelösungen zur Anbindung von eCommerce-Systemen an die Payment Plattform von Novalnet. Von dieser Regelung ausdrücklich nicht betroffen sind die Leistungen, die Novalnet gemäß dem zwischen den Parteien geschlossenen Dienstleistungsvertrag gegenüber dem Partner erbringt. Mit der Installation und der Benutzung der Software bestätigen Sie automatisch, dass Sie diese Freeware-Lizenzvereinbarung gelesen haben und mit ihr einverstanden sind. Wenn Sie als Partner mit diesen Bedingungen nicht einverstanden sind, installieren und nutzen Sie die Software nicht. + +Lizenz: +Für die von Novalnet unentgeltlich bereitgestellten Payment Module sowie alle weiteren Module, die Novalnet anderweitig veröffentlicht, räumt Novalnet ein zeitlich auf die Dauer des zwischen den Parteien geschlossenen Dienstleistungsvertrages begrenztes, nicht ausschließliches, unentgeltliches Nutzungsrecht ein. Die Lizenzvereinbarung berechtigt Sie, die Software auf einem oder mehreren Rechnern zu installieren und zu nutzen. Die Lizenz für die Software ist kostenlos. Der Partner verpflichtet sich, die Payment Module und/oder Teile der Module ausschließlich für die Nutzung der von Novalnet gemäß dem Vertrag bereitgestellten Leistungen zu nutzen. Der Partner hat keinen Anspruch auf technische Unterstützung irgendwelcher Art. Novalnet ist insbesondere nicht verpflichtet, eine Wartung oder Überarbeitung der Software zu gewährleisten. + +Copyright: +Alle Rechtsansprüche, Besitzrechte und geistigen Eigentumsrechte an und auf die Software sowie alle Kopien davon und jede damit im Zusammenhang stehende Dokumentation sind Eigentum von Novalnet (www.novalnet.de). Alle Rechte sind vorbehalten. Novalnet behält sich rechtliche Schritte im Falle einer Verletzung dieser Lizenzvereinbarung vor. + +Gewährleistung und Haftung: +Die Payment Module werden ausdrücklich „so wie sie sind“ zur Verfügung gestellt. Für die fehlerfreie Funktion der Payment Module und/oder Teile der Payment Module übernimmt Novalnet keine Gewähr. Ebenso übernimmt Novalnet keine Haftung für Schäden und/oder Folgeschäden, die mittelbar oder unmittelbar mit dem Gebrauch und/oder der Nutzung der von Novalnet unentgeltlich zur Verfügung gestellten Payment Module in Verbindung gebracht werden können, es sei denn, dass der Schaden auf Vorsatz oder auf grobe Fahrlässigkeit beruht. Von diesem Haftungsausschluss nicht umfasst sind Schäden aus der Verletzung von Leib, Leben oder der Gesundheit. + +Rechtsansprüche und salvatorische Klausel: +Es gilt das Recht der Bundesrepublik Deutschland. Gerichtsstand ist München. Sollte eine gegenwärtige oder zukünftige Bestimmung der Vereinbarung ganz oder teilweise aus anderen Gründen als den §§ 305-310 des Bürgerlichen Gesetzbuchs (BGB) unwirksam/nichtig oder nicht durchführbar sein oder werden, so wird hiervon die Gültigkeit der übrigen Bestimmungen des Vereinbarung nicht berührt. Die Parteien werden die unwirksame/nichtige oder nicht durchführbare Bestimmung durch eine wirksame ersetzen, die in ihrem rechtlichen und wirtschaftlichen Gehalt der unwirksamen/nichtigen oder nicht durchführbaren Bestimmung und dem Gesamtzweck der Vereinbarung entspricht. Das gleiche gilt, wenn sich nach Abschluss der Vereinbarung eine ergänzungsbedürftige Lücke ergibt. Die Bestimmung des § 139 BGB (Teilnichtigkeit) wird ausdrücklich ausgeschlossen. + +Sollten Sie weitere Informationen benötigen, steht Ihnen der Technik-Service der Novalnet AG gerne zur Verfügung: + +Novalnet AG +Tel.: +49 89 9230683-19 +Fax: +49 89 9230683-11 +E-Mail: technic@novalnet.de + + +English: + +Preamble: +The following agreement governs the rights and responsibilities between you (the "Partner") and the Novalnet AG ("Novalnet") in relation to the cost-free software solutions Service and Support provided by Novalnet, by connecting your e-commerce systems to the payment platform of Novalnet. Services, which Novalnet offers in accordance with a service contract to its partners, are not affected explicitly by this agreement. From this particular agreement, is not explicitly affected the services Novalnet under the contract between the parties to the service contract partners are providing. By installing and using the software, you automatically confirm that you have read this freeware license agreement and agree with it. If you do not agree to these conditions, as a partner, please do not install and use the software. + +License: +For the payment module provided by Novalnet for each individual version, Novalnet grants a limited, non-exclusive, right of use for a service agreement concluded between the parties. The license agreement authorises you to install and use the software on one or more computers. The Partner undertakes to use the Payment Modules and / or parts of the Modules exclusively for the use of the services provided by Novalnet in accordance with the Agreement. The Partner is not entitled to technical support of any kind whatsoever. In particular, Novalnet is not obliged to ensure the maintenance, repair or revision of the Software. + +Copyright: +All title, ownership rights and intellectual property rights to and from the Software, as well as all copies of the software, and any related documentation, are the property of Novalnet (www.novalnet.de). All rights are reserved. Novalnet reserves legal measures in case of a breach of this Agreement. + +Guarantee and Liability: +Novalnet shall only be liable to the extent that Novalnet, its legal representatives, employees and / or vicarious agents are guilty of intentional or gross negligent conduct. The liability is however limited to the foreseeable losses that are typical of the contract, of which Novalnet would have to be typically reckoned with given the known circumstances at the time the contract was concluded. + +The limitation of liability does not apply to the extent of breach of essential contractual obligations by Novalnet, its vicarious agents, employees and / or legal representatives. Cardinal contractual obligations refer to those obligations that one contracting party has to grant to the other contracting party in accordance with the sense and purpose of the agreement or whose fulfilment is essential for the due and proper implementation of the contract in the first place and the observance of which the other contracting party can regularly rely upon. In this case, liability is however is limited to the damage that is typically predictable at the time of conclusion of the contract. In a statutorily prescribed no-fault liability- in particular any potential liability under the Product Liability Act or due to legal guarantee liability - shall remain unaffected by the above limitations of liability. The same applies to the liability of Novalnet in the case of negligent injury to life, body or health. + +Legal claims and severability clause: +The laws of the Federal Republic of Germany will be applicable. The place for court of law or going to court will be Munich. Should any present or future provision of the Agreement, in whole or in part, become invalid, for reasons other than the § § 305-310 of the Civil Code (BGB), the validity of the remaining provisions of the agreement will not be affected. The parties shall replace the ineffective, invalid or unenforceable provision by a valid one that will be void in its legal and economic substance, of the ineffective or not feasible provision, and also in compliance with the overall purpose of the agreement. The same applies, if after the conclusion of the agreement, there are gaps or loopholes found in the agreement. The provision of § 139 BGB (severability) is totally excluded. + +If you need further information, kindly contact our Technical service Team: + +Novalnet AG +Tel.: +49 89 9230683-19 +Fax: +49 89 9230683-11 +E-Mail: technic@novalnet.de diff --git a/Logger/Handler/NovalnetDebug.php b/Logger/Handler/NovalnetDebug.php new file mode 100755 index 0000000..6eca371 --- /dev/null +++ b/Logger/Handler/NovalnetDebug.php @@ -0,0 +1,37 @@ +request = $request; + $this->scopeConfig = $scopeConfig; + $this->novalnetConfig = $novalnetConfig; + } + + /** + * Options getter (Active Payment methods) + * + * @return array + */ + public function toOptionArray() + { + $methods = []; + $activePayment = false; + $storeId = (int) $this->request->getParam('store'); + $websiteId = (int) $this->request->getParam('website'); + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; + $scopeValue = null; + + if ($storeId) { + $scopeValue = $storeId; + } + + if ($websiteId) { + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE; + $scopeValue = $websiteId; + } + + foreach ($this->novalnetConfig->getPaymentMethodCodes() as $paymentCode) { + $paymentActive = $this->scopeConfig->getValue('payment/' . $paymentCode . '/active', $scope, $scopeValue); + + if ($paymentActive == true) { + $paymentTitle = $this->scopeConfig->getValue( + 'payment/' . $paymentCode . '/title', + $scope, + $scopeValue + ); + $methods[$paymentCode] = ['value' => $paymentCode, 'label' => $paymentTitle]; + $activePayment = true; + } + } + + if (!$activePayment) { + $methods[$paymentCode] = ['value' => '', 'label' => __('No active payment method for this store')]; + } + + return $methods; + } +} diff --git a/Model/Adminhtml/Source/ApplepayButtonStyle.php b/Model/Adminhtml/Source/ApplepayButtonStyle.php new file mode 100755 index 0000000..2fbbf74 --- /dev/null +++ b/Model/Adminhtml/Source/ApplepayButtonStyle.php @@ -0,0 +1,85 @@ + 'plain', + 'label' => __('Default') + ], + [ + 'value' => 'buy', + 'label' => __('Buy') + ], + [ + 'value' => 'donate', + 'label' => __('Donate') + ], + [ + 'value' => 'book', + 'label' => __('Book') + ], + [ + 'value' => 'contribute', + 'label' => __('Contribute') + ], + [ + 'value' => 'check-out', + 'label' => __('Check out') + ], + [ + 'value' => 'order', + 'label' => __('Order') + ], + [ + 'value' => 'subscribe', + 'label' => __('Subscribe') + ], + [ + 'value' => 'tip', + 'label' => __('Tip') + ], + [ + 'value' => 'rent', + 'label' => __('Rent') + ], + [ + 'value' => 'reload', + 'label' => __('Reload') + ], + [ + 'value' => 'support', + 'label' => __('Support') + ], + ]; + } +} diff --git a/Model/Adminhtml/Source/ApplepayButtonTheme.php b/Model/Adminhtml/Source/ApplepayButtonTheme.php new file mode 100755 index 0000000..9e16419 --- /dev/null +++ b/Model/Adminhtml/Source/ApplepayButtonTheme.php @@ -0,0 +1,49 @@ + 'black', + 'label' => __('Dark') + ], + [ + 'value' => 'white', + 'label' => __('Light') + ], + [ + 'value' => 'white-outline', + 'label' => __('Light-Outline') + ], + ]; + } +} diff --git a/Model/Adminhtml/Source/ApplepayEnabledPages.php b/Model/Adminhtml/Source/ApplepayEnabledPages.php new file mode 100755 index 0000000..3a50e64 --- /dev/null +++ b/Model/Adminhtml/Source/ApplepayEnabledPages.php @@ -0,0 +1,53 @@ + 'shopping_cart_page', + 'label' => __('Shopping cart page') + ], + [ + 'value' => 'mini_cart_page', + 'label' => __('Mini cart page') + ], + [ + 'value' => 'product_page', + 'label' => __('Product page') + ], + [ + 'value' => 'guest_checkout_page', + 'label' => __('Guest checkout page') + ], + ]; + } +} diff --git a/Model/Adminhtml/Source/CcCardTypes.php b/Model/Adminhtml/Source/CcCardTypes.php new file mode 100755 index 0000000..1357951 --- /dev/null +++ b/Model/Adminhtml/Source/CcCardTypes.php @@ -0,0 +1,77 @@ + 'VI', + 'label' => __('Visa') + ], + [ + 'value' => 'MC', + 'label' => __('MasterCard') + ], + [ + 'value' => 'AE', + 'label' => __('American Express') + ], + [ + 'value' => 'MA', + 'label' => __('Maestro') + ], + [ + 'value' => 'CI', + 'label' => __('Cartasi') + ], + [ + 'value' => 'UP', + 'label' => __('Union Pay') + ], + [ + 'value' => 'DC', + 'label' => __('Discover') + ], + [ + 'value' => 'DI', + 'label' => __('Diners') + ], + [ + 'value' => 'JCB', + 'label' => __('Jcb') + ], + [ + 'value' => 'CB', + 'label' => __('Carte Bleue') + ], + ]; + } +} diff --git a/Model/Adminhtml/Source/CustomerGroups.php b/Model/Adminhtml/Source/CustomerGroups.php new file mode 100755 index 0000000..d57aee1 --- /dev/null +++ b/Model/Adminhtml/Source/CustomerGroups.php @@ -0,0 +1,46 @@ +customerGroupColl = $customerGroupColl; + } + + /** + * Options getter (Customer Groups) + * + * @return array + */ + public function toOptionArray() + { + return $this->customerGroupColl->toOptionArray(); + } +} diff --git a/Model/Adminhtml/Source/GooglepayButtonTheme.php b/Model/Adminhtml/Source/GooglepayButtonTheme.php new file mode 100755 index 0000000..8d23404 --- /dev/null +++ b/Model/Adminhtml/Source/GooglepayButtonTheme.php @@ -0,0 +1,46 @@ + 'default', + 'label' => __('Default') + ], + [ + 'value' => 'black', + 'label' => __('Black') + ], + [ + 'value' => 'white', + 'label' => __('White') + ] + ]; + } +} diff --git a/Model/Adminhtml/Source/GooglepayButtonType.php b/Model/Adminhtml/Source/GooglepayButtonType.php new file mode 100755 index 0000000..7bdddc7 --- /dev/null +++ b/Model/Adminhtml/Source/GooglepayButtonType.php @@ -0,0 +1,66 @@ + 'book', + 'label' => __('Book') + ], + [ + 'value' => 'buy', + 'label' => __('Buy') + ], + [ + 'value' => 'checkout', + 'label' => __('Checkout') + ], + [ + 'value' => 'donate', + 'label' => __('Donate') + ], + [ + 'value' => 'order', + 'label' => __('Order') + ], + [ + 'value' => 'pay', + 'label' => __('Pay') + ], + [ + 'value' => 'plain', + 'label' => __('Plain') + ], + [ + 'value' => 'subscribe', + 'label' => __('Subscribe') + ] + ]; + } +} diff --git a/Model/Adminhtml/Source/GooglepayEnabledPages.php b/Model/Adminhtml/Source/GooglepayEnabledPages.php new file mode 100755 index 0000000..d96a9af --- /dev/null +++ b/Model/Adminhtml/Source/GooglepayEnabledPages.php @@ -0,0 +1,53 @@ + 'shopping_cart_page', + 'label' => __('Shopping cart page') + ], + [ + 'value' => 'mini_cart_page', + 'label' => __('Mini cart page') + ], + [ + 'value' => 'product_page', + 'label' => __('Product page') + ], + [ + 'value' => 'guest_checkout_page', + 'label' => __('Guest checkout page') + ], + ]; + } +} diff --git a/Model/Adminhtml/Source/InstalmentCycles.php b/Model/Adminhtml/Source/InstalmentCycles.php new file mode 100755 index 0000000..090a3c1 --- /dev/null +++ b/Model/Adminhtml/Source/InstalmentCycles.php @@ -0,0 +1,51 @@ + 2 . __(' cycles'), + 3 => 3 . __(' cycles'), + 4 => 4 . __(' cycles'), + 6 => 6 . __(' cycles'), + 8 => 8 . __(' cycles'), + 9 => 9 . __(' cycles'), + 10 => 10 . __(' cycles'), + 12 => 12 . __(' cycles'), + 15 => 15 . __(' cycles'), + 18 => 18 . __(' cycles'), + 24 => 24 . __(' cycles') + ]; + + foreach ($allCycles as $key => $value) { + $methods[$key] = ['value' => $key, 'label' => $value]; + } + + return $methods; + } +} diff --git a/Model/Adminhtml/Source/PaymentAction.php b/Model/Adminhtml/Source/PaymentAction.php new file mode 100755 index 0000000..ab75690 --- /dev/null +++ b/Model/Adminhtml/Source/PaymentAction.php @@ -0,0 +1,44 @@ + AbstractMethod::ACTION_AUTHORIZE, + 'label' => __('Authorize') + ], + [ + 'value' => AbstractMethod::ACTION_AUTHORIZE_CAPTURE, + 'label' => __('Capture') + ] + ]; + } +} diff --git a/Model/Adminhtml/Source/PaymentActionWithZeroAmount.php b/Model/Adminhtml/Source/PaymentActionWithZeroAmount.php new file mode 100755 index 0000000..af13566 --- /dev/null +++ b/Model/Adminhtml/Source/PaymentActionWithZeroAmount.php @@ -0,0 +1,49 @@ + AbstractMethod::ACTION_AUTHORIZE, + 'label' => __('Authorize') + ], + [ + 'value' => AbstractMethod::ACTION_AUTHORIZE_CAPTURE, + 'label' => __('Capture') + ], + [ + 'value' => NNConfig::ACTION_ZERO_AMOUNT_BOOKING, + 'label' => __('Authorize with zero amount') + ] + ]; + } +} diff --git a/Model/Callback.php b/Model/Callback.php new file mode 100755 index 0000000..4059c85 --- /dev/null +++ b/Model/Callback.php @@ -0,0 +1,63 @@ +_init(\Novalnet\Payment\Model\ResourceModel\Callback::class); + } + + /** + * Load order callback status by order id + * + * @param mixed $orderId + * @return mixed + */ + public function loadLogByOrderId($orderId) + { + $this->load($orderId, 'order_id'); + return $this; + } +} diff --git a/Model/NNConfig.php b/Model/NNConfig.php new file mode 100755 index 0000000..9e672f9 --- /dev/null +++ b/Model/NNConfig.php @@ -0,0 +1,324 @@ + 'DIRECT_DEBIT_SEPA', + ConfigProvider::NOVALNET_CC => 'CREDITCARD', + ConfigProvider::NOVALNET_APPLEPAY => 'APPLEPAY', + ConfigProvider::NOVALNET_GOOGLEPAY => 'GOOGLEPAY', + ConfigProvider::NOVALNET_INVOICE => 'INVOICE', + ConfigProvider::NOVALNET_PREPAYMENT => 'PREPAYMENT', + ConfigProvider::NOVALNET_INVOICE_GUARANTEE => 'GUARANTEED_INVOICE', + ConfigProvider::NOVALNET_SEPA_GUARANTEE => 'GUARANTEED_DIRECT_DEBIT_SEPA', + ConfigProvider::NOVALNET_INVOICE_INSTALMENT => 'INSTALMENT_INVOICE', + ConfigProvider::NOVALNET_SEPA_INSTALMENT => 'INSTALMENT_DIRECT_DEBIT_SEPA', + ConfigProvider::NOVALNET_IDEAL => 'IDEAL', + ConfigProvider::NOVALNET_BANKTRANSFER => 'ONLINE_TRANSFER', + ConfigProvider::NOVALNET_ONLINEBANKTRANSFER => 'ONLINE_BANK_TRANSFER', + ConfigProvider::NOVALNET_GIROPAY => 'GIROPAY', + ConfigProvider::NOVALNET_CASHPAYMENT => 'CASHPAYMENT', + ConfigProvider::NOVALNET_PRZELEWY => 'PRZELEWY24', + ConfigProvider::NOVALNET_EPS => 'EPS', + ConfigProvider::NOVALNET_PAYPAL => 'PAYPAL', + ConfigProvider::NOVALNET_POSTFINANCE_CARD => 'POSTFINANCE_CARD', + ConfigProvider::NOVALNET_POSTFINANCE => 'POSTFINANCE', + ConfigProvider::NOVALNET_BANCONTACT => 'BANCONTACT', + ConfigProvider::NOVALNET_MULTIBANCO => 'MULTIBANCO', + ConfigProvider::NOVALNET_ALIPAY => 'ALIPAY', + ConfigProvider::NOVALNET_WECHATPAY => 'WECHATPAY', + ConfigProvider::NOVALNET_TRUSTLY => 'TRUSTLY', + ConfigProvider::NOVALNET_BLIK => 'BLIK' + ]; + + /** + * @var array + */ + public $oneClickPayments = [ + ConfigProvider::NOVALNET_CC, + ConfigProvider::NOVALNET_SEPA, + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_PAYPAL, + ]; + + /** + * @var array + */ + protected $zeroAmountPayments = [ + ConfigProvider::NOVALNET_CC, + ConfigProvider::NOVALNET_SEPA + ]; + + /** + * @var array + */ + protected $redirectPayments = [ + ConfigProvider::NOVALNET_PAYPAL, + ConfigProvider::NOVALNET_BANKTRANSFER, + ConfigProvider::NOVALNET_ONLINEBANKTRANSFER, + ConfigProvider::NOVALNET_IDEAL, + ConfigProvider::NOVALNET_BANCONTACT, + ConfigProvider::NOVALNET_EPS, + ConfigProvider::NOVALNET_GIROPAY, + ConfigProvider::NOVALNET_PRZELEWY, + ConfigProvider::NOVALNET_POSTFINANCE_CARD, + ConfigProvider::NOVALNET_POSTFINANCE, + ConfigProvider::NOVALNET_ALIPAY, + ConfigProvider::NOVALNET_WECHATPAY, + ConfigProvider::NOVALNET_TRUSTLY, + ConfigProvider::NOVALNET_BLIK, + ]; + + /** + * @var array + */ + public $subscriptionSupportedPayments = [ + ConfigProvider::NOVALNET_SEPA, + ConfigProvider::NOVALNET_CC, + ConfigProvider::NOVALNET_INVOICE, + ConfigProvider::NOVALNET_PREPAYMENT, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_PAYPAL + ]; + + /** + * @var array + */ + protected $allowedCountry = [ 'AT', 'DE', 'CH' ]; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + */ + public function __construct( + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + ) { + $this->scopeConfig = $scopeConfig; + } + + /** + * Get Payment methods + * + * @return array + */ + public function getPaymentMethodCodes() + { + return array_keys($this->paymentTypes); + } + + /** + * Get Payment Type by method code + * + * @param string $code + * @return string + */ + public function getPaymentType($code) + { + return $this->paymentTypes[$code]; + } + + /** + * Get Payment method code by Type + * + * @param string $paymentType + * @return mixed + */ + public function getPaymentCodeByType($paymentType) + { + return array_search($paymentType, $this->paymentTypes); + } + + /** + * Check is one click Payment method by code + * + * @param string $code + * @return bool + */ + public function isOneClickPayment($code) + { + return (bool) (in_array($code, $this->oneClickPayments)); + } + + /** + * Check is zero amount booking supported + * + * @param string $code + * @return bool + */ + public function isZeroAmountBookingSupported($code) + { + return (bool) (in_array($code, $this->zeroAmountPayments)); + } + + /** + * Check is one Subscription Supported Payment method by code + * + * @param string $code + * @return bool + */ + public function isSubscriptionSupported($code) + { + return (bool) (in_array($code, $this->subscriptionSupportedPayments)); + } + + /** + * Check is redirect Payment method by code + * + * @param string $code + * @return bool + */ + public function isRedirectPayment($code) + { + return (bool) (in_array($code, $this->redirectPayments)); + } + + /** + * Check Allowed country + * + * @param string $county + * @param bool $b2b + * @return bool + */ + public function isAllowedCountry($county, $b2b = false) + { + if ($b2b) { + $allowedCountryB2B = $this->scopeConfig->getValue( + 'general/country/eu_countries', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + $allowedCountryB2B = (!empty($allowedCountryB2B)) ? explode(",", $allowedCountryB2B) : []; + array_push($allowedCountryB2B, 'CH'); + } + + return (bool) (($b2b && in_array($county, $allowedCountryB2B)) || in_array($county, $this->allowedCountry)); + } + + /** + * Get Novalnet Global Configuration values + * + * @param string $field + * @param int|null $storeId + * @return string + */ + public function getGlobalConfig($field, $storeId = null) + { + return $this->scopeConfig->getValue( + 'payment/novalnet/' . $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Get Novalnet Global on-hold status + * + * @param int|null $storeId + * @return string + */ + public function getGlobalOnholdStatus($storeId = null) + { + return $this->scopeConfig->getValue( + 'novalnet_global/novalnet/onhold_status', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Get Novalnet Global Merchant Script Configuration values + * + * @param string $field + * @param int $storeId + * @return string + */ + public function getMerchantScriptConfig($field, $storeId = null) + { + return $this->scopeConfig->getValue( + 'payment/merchant_script/' . $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Get Novalnet Payment Configuration values + * + * @param string $code + * @param string $field + * @param int $storeId + * @return string + */ + public function getPaymentConfig($code, $field, $storeId = null) + { + return $this->scopeConfig->getValue( + 'payment/' . $code . '/' . $field, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Get Novalnet Payment Test Mode + * + * @param string $paymentMethodCode + * @param int $storeId + * @return int + */ + public function getTestMode($paymentMethodCode, $storeId = null) + { + if ($paymentMethodCode) { + $livePaymentMethods = $this->scopeConfig->getValue( + 'payment/novalnet/live_mode', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + + $livePaymentMethods = (!empty($livePaymentMethods)) ? explode(',', $livePaymentMethods) : []; + + return (in_array($paymentMethodCode, $livePaymentMethods) === false) ? 1 : 0; + } + + return 1; + } +} diff --git a/Model/NNRepository.php b/Model/NNRepository.php new file mode 100755 index 0000000..a1a4fd8 --- /dev/null +++ b/Model/NNRepository.php @@ -0,0 +1,2545 @@ + [ + 'type', + 'checksum', + 'tid' + ], + 'merchant' => [ + 'vendor', + 'project' + ], + 'transaction' => [ + 'tid', + 'payment_type', + 'status', + ], + 'result' => [ + 'status' + ], + ]; + + /** + * @var mixed + */ + private $response; + + /** + * @var mixed + */ + private $order; + + /** + * @var array + */ + private $eventData; + + /** + * @var string + */ + private $eventType; + + /** + * @var int + */ + private $eventTid; + + /** + * @var int + */ + private $parentTid; + + /** + * @var \Magento\Sales\Model\Order + */ + private $salesOrderModel; + + /** + * @var \Magento\Framework\UrlInterface + */ + private $urlInterface; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + private $requestInterface; + + /** + * @var \Magento\Sales\Model\Order\Payment\Transaction + */ + private $transactionModel; + + /** + * @var \Magento\Framework\Pricing\Helper\Data + */ + private $pricingHelper; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime + */ + private $dateTime; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + */ + private $timeZone; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @var \Magento\Framework\Mail\Template\TransportBuilder + */ + private $transportBuilder; + + /** + * @var \Magento\Framework\Translate\Inline\StateInterface + */ + private $inlineTranslation; + + /** + * @var \Magento\Sales\Model\Order\Email\Sender\OrderSender + */ + private $orderEmailSender; + + /** + * @var \Magento\Sales\Model\Order\Address\Renderer + */ + private $salesOrderAddressRenderer; + + /** + * @var \Magento\Payment\Helper\Data + */ + private $paymentHelper; + + /** + * @var \Magento\Framework\HTTP\Client\Curl + */ + private $clientFactory; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoFactory + */ + private $creditMemoFacory; + + /** + * @var \Magento\Sales\Model\Service\CreditmemoService + */ + private $creditmemoService; + + /** + * @var \Novalnet\Payment\Model\Callback + */ + private $callbackModel; + + /** + * @var \Novalnet\Payment\Model\TransactionStatus + */ + private $transactionStatusModel; + + /** + * @var \Novalnet\Payment\Helper\Request + */ + private $novalnetRequestHelper; + + /** + * @var \Novalnet\Payment\Model\NNConfig + */ + private $novalnetConfig; + + /** + * @var \Magento\Quote\Model\QuoteIdMaskFactory + */ + private $quoteIdMaskFactory; + + /** + * @var \Magento\Checkout\Model\Session + */ + private $checkoutSession; + + /** + * @var \Magento\Customer\Model\Session + */ + private $customerSession; + + /** + * @var mixed + */ + private $additionalMessage; + + /** + * @var mixed + */ + private $callbackMessage; + + /** + * @var \Magento\Framework\Json\Helper\Data + */ + private $jsonHelper; + + /** + * @var \Magento\Framework\Serialize\Serializer\Serialize + */ + private $serializer; + + /** + * @var \Novalnet\Payment\Logger\NovalnetLogger + */ + private $novalnetLogger; + + /** + * @var \Magento\Sales\Model\Order\Email\Sender\InvoiceSender + */ + private $invoiceSender; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader + */ + private $creditmemoLoader; + + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + private $eventManager; + + /** + * @var \Magento\Checkout\Model\Cart + */ + private $cart; + + /** + * @var \Magento\Checkout\Helper\Data + */ + private $checkoutHelper; + + /** + * @var \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory + */ + private $estimatedAddressFactory; + + /** + * @var \Magento\Quote\Api\ShippingMethodManagementInterface + */ + private $shippingMethodManager; + + /** + * @var \Magento\Quote\Api\CartManagementInterface + */ + private $quoteManagement; + + /** + * @var \Magento\Catalog\Api\ProductRepositoryInterface + */ + private $productRepository; + + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface + */ + private $priceCurrency; + + /** + * @var \Magento\Tax\Helper\Data + */ + private $taxHelper; + + /** + * @var \Magento\Directory\Model\CountryFactory + */ + private $countryFactory; + + /** + * @var \Magento\Catalog\Model\ProductFactory + */ + private $productFactory; + + /** + * @var \Magento\Tax\Api\TaxCalculationInterface + */ + private $taxCalculation; + + /** + * @var \Zend\Uri\Uri + */ + private $zendUri; + + /** + * @var \Magento\Directory\Model\Currency + */ + private $currencyModel; + + /** + * @var string + */ + private $currentTime; + + /** + * @var mixed + */ + private $orderNo; + + /** + * @var mixed + */ + private $testMode; + + /** + * @var mixed + */ + private $emailBody; + + /** + * @var mixed + */ + private $storeId; + + /** + * @var string + */ + private $paymentAccessKey; + + /** + * @var mixed + */ + private $payment; + + /** + * @var string + */ + private $code; + + /** + * @var mixed + */ + private $paymentTxnId; + + /** + * @var string + */ + private $currency; + + /** + * @var string + */ + private $emailFromAddr; + + /** + * @var string + */ + private $emailFromName; + + /** + * @var string + */ + private $emailToName; + + /** + * @var string + */ + private $emailToAddr; + + /** + * @var string + */ + private $emailSubject; + + /** + * @var string + */ + private $storeFrontendName; + + /** + * @param \Magento\Sales\Model\Order $salesOrderModel + * @param \Magento\Framework\UrlInterface $urlInterface + * @param \Magento\Framework\App\RequestInterface $requestInterface + * @param \Magento\Sales\Model\Order\Payment\Transaction $transactionModel + * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper + * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timeZone + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder + * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation + * @param \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderEmailSender + * @param \Magento\Sales\Model\Order\Address\Renderer $salesOrderAddressRenderer + * @param \Magento\Payment\Helper\Data $paymentHelper + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Framework\HTTP\Client\Curl $clientFactory + * @param \Magento\Sales\Model\Order\CreditmemoFactory $creditMemoFacory + * @param \Magento\Sales\Model\Service\CreditmemoService $creditmemoService + * @param \Novalnet\Payment\Model\Callback $callbackModel + * @param \Novalnet\Payment\Model\TransactionStatus $transactionStatusModel + * @param \Novalnet\Payment\Helper\Request $novalnetRequestHelper + * @param \Magento\Framework\Json\Helper\Data $jsonHelper + * @param \Magento\Framework\Serialize\Serializer\Serialize $serializer + * @param \Novalnet\Payment\Model\NNConfig $novalnetConfig + * @param \Novalnet\Payment\Logger\NovalnetLogger $novalnetLogger + * @param \Magento\Sales\Model\Order\Email\Sender\InvoiceSender $invoiceSender + * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Checkout\Model\Cart $cart + * @param \Magento\Checkout\Helper\Data $checkoutHelper + * @param \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory + * @param \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager + * @param \Magento\Quote\Api\CartManagementInterface $quoteManagement + * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository + * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency + * @param \Magento\Tax\Helper\Data $taxHelper + * @param \Magento\Directory\Model\CountryFactory $countryFactory + * @param \Magento\Catalog\Model\ProductFactory $productFactory + * @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculation + * @param \Zend\Uri\Uri $zendUri + * @param \Magento\Directory\Model\Currency $currencyModel + */ + public function __construct( + Order $salesOrderModel, + \Magento\Framework\UrlInterface $urlInterface, + \Magento\Framework\App\RequestInterface $requestInterface, + \Magento\Sales\Model\Order\Payment\Transaction $transactionModel, + \Magento\Framework\Pricing\Helper\Data $pricingHelper, + \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timeZone, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, + \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, + \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderEmailSender, + \Magento\Sales\Model\Order\Address\Renderer $salesOrderAddressRenderer, + \Magento\Payment\Helper\Data $paymentHelper, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Customer\Model\Session $customerSession, + \Magento\Framework\HTTP\Client\Curl $clientFactory, + \Magento\Sales\Model\Order\CreditmemoFactory $creditMemoFacory, + \Magento\Sales\Model\Service\CreditmemoService $creditmemoService, + \Novalnet\Payment\Model\Callback $callbackModel, + \Novalnet\Payment\Model\TransactionStatus $transactionStatusModel, + \Novalnet\Payment\Helper\Request $novalnetRequestHelper, + \Magento\Framework\Json\Helper\Data $jsonHelper, + \Magento\Framework\Serialize\Serializer\Serialize $serializer, + \Novalnet\Payment\Model\NNConfig $novalnetConfig, + \Novalnet\Payment\Logger\NovalnetLogger $novalnetLogger, + \Magento\Sales\Model\Order\Email\Sender\InvoiceSender $invoiceSender, + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Checkout\Model\Cart $cart, + \Magento\Checkout\Helper\Data $checkoutHelper, + \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory, + \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager, + \Magento\Quote\Api\CartManagementInterface $quoteManagement, + \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, + \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, + \Magento\Tax\Helper\Data $taxHelper, + \Magento\Directory\Model\CountryFactory $countryFactory, + \Magento\Catalog\Model\ProductFactory $productFactory, + \Magento\Tax\Api\TaxCalculationInterface $taxCalculation, + \Zend\Uri\Uri $zendUri, + \Magento\Directory\Model\Currency $currencyModel + ) { + $this->salesOrderModel = $salesOrderModel; + $this->urlInterface = $urlInterface; + $this->requestInterface = $requestInterface; + $this->transactionModel = $transactionModel; + $this->pricingHelper = $pricingHelper; + $this->dateTime = $dateTime; + $this->storeManager = $storeManager; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->timeZone = $timeZone; + $this->scopeConfig = $scopeConfig; + $this->transportBuilder = $transportBuilder; + $this->inlineTranslation = $inlineTranslation; + $this->orderEmailSender = $orderEmailSender; + $this->paymentHelper = $paymentHelper; + $this->salesOrderAddressRenderer = $salesOrderAddressRenderer; + $this->checkoutSession = $checkoutSession; + $this->customerSession = $customerSession; + $this->clientFactory = $clientFactory; + $this->creditMemoFacory = $creditMemoFacory; + $this->creditmemoService = $creditmemoService; + $this->callbackModel = $callbackModel; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetLogger = $novalnetLogger; + $this->invoiceSender = $invoiceSender; + $this->creditmemoLoader = $creditmemoLoader; + $this->eventManager = $eventManager; + $this->cart = $cart; + $this->checkoutHelper = $checkoutHelper; + $this->estimatedAddressFactory = $estimatedAddressFactory; + $this->shippingMethodManager = $shippingMethodManager; + $this->quoteManagement = $quoteManagement; + $this->productRepository = $productRepository; + $this->priceCurrency = $priceCurrency; + $this->taxHelper = $taxHelper; + $this->countryFactory = $countryFactory; + $this->productFactory = $productFactory; + $this->taxCalculation = $taxCalculation; + $this->zendUri = $zendUri; + $this->currencyModel = $currencyModel; + } + + /** + * Novalnet product activation key auto config + * + * @api + * @param string $signature + * @param string $payment_access_key + * @return string + */ + public function activateProductKey($signature, $payment_access_key) + { + $data['merchant'] = ['signature' => $signature]; + $data['custom'] = ['lang' => $this->novalnetRequestHelper->getDefaultLanguage()]; + $this->clientFactory->setHeaders( + $this->novalnetRequestHelper->getRequestHeaders($payment_access_key) + ); + $this->clientFactory->post(NNConfig::NOVALNET_MERCHANT_DETAIL_URL, $this->jsonHelper->jsonEncode($data)); + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + return $this->clientFactory->getBody(); + } + + /** + * Novalnet Webhook URL configuration + * + * @api + * @param string $signature + * @param string $payment_access_key + * @return string + */ + public function configWebhookUrl($signature, $payment_access_key) + { + $webhook_url = $this->requestInterface->getParam('webhookurl'); + if (filter_var($webhook_url, FILTER_VALIDATE_URL) === false) { + $data['result'] = ['status' => 'failure', 'status_text' => __('Please enter valid URL')]; + return $this->jsonHelper->jsonEncode($data); + } + $data['merchant'] = ['signature' => $signature]; + $data['custom'] = ['lang' => $this->novalnetRequestHelper->getDefaultLanguage()]; + $data['webhook'] = ['url' => $webhook_url]; + $this->clientFactory->setHeaders( + $this->novalnetRequestHelper->getRequestHeaders($payment_access_key) + ); + $this->clientFactory->post(NNConfig::NOVALNET_WEBHOOK_CONFIG_URL, $this->jsonHelper->jsonEncode($data)); + $response = (!empty($this->clientFactory->getBody())) ? json_decode($this->clientFactory->getBody(), true) : []; + + return $this->clientFactory->getBody(); + } + + /** + * Get redirect URL + * + * @api + * @param string[] $data + * @return string + */ + public function getRedirectURL($data) + { + $quoteId = $data['quote_id']; + $this->novalnetLogger->notice('Redirect from checkout to redirect_url webapi'); + if (!$this->customerSession->isLoggedIn()) { + $quoteMaskData = $this->quoteIdMaskFactory->create()->load($quoteId, 'masked_id'); + $quoteId = $quoteMaskData->getQuoteId(); + } + + $this->novalnetLogger->notice('quote_id retrieved ' . $quoteId); + + // Loads session quote from checkout + $sessionQuoteId = $this->checkoutSession->getLastQuoteId(); + $orderId = $this->checkoutSession->getLastOrderId(); + + $this->novalnetLogger->notice('order_id retrieved ' . $orderId); + + if ($quoteId != $sessionQuoteId) { + $orderId = $this->salesOrderModel->getCollection()->addFieldToFilter('quote_id', $quoteId) + ->getFirstItem()->getId(); + } + + $order = $this->salesOrderModel->load($orderId); + + $this->novalnetLogger->notice('Order loaded successfully ' . $order->getIncrementId()); + $payment = $order->getPayment(); + $additionalData = (!empty($payment->getAdditionalData())) ? json_decode($payment->getAdditionalData(), true) : []; + + if (!empty($additionalData['NnRedirectURL'])) { + // set the order status to pending_payment before redirect to novalnet + $order->setState(Order::STATE_PENDING_PAYMENT) + ->setStatus(Order::STATE_PENDING_PAYMENT) + ->save(); + $order->addStatusHistoryComment(__('Customer was redirected to Novalnet')) + ->save(); + + $this->novalnetLogger->notice('Order status and comments updated successfully'); + + return $additionalData['NnRedirectURL']; + } else { + return $this->urlInterface->getUrl('checkout/cart'); + } + } + + /** + * Remove Novalnet payment token + * + * @api + * @param int $transactionRowId + * @return bool + */ + public function removeToken($transactionRowId) + { + $transactionStatus = $this->transactionStatusModel->load($transactionRowId); + if ($transactionStatus->getTokenInfo()) { + $transactionStatus->setTokenInfo(null)->save(); + return true; + } + + return false; + } + + /** + * Get Instalment payment options + * + * @api + * @param string $code + * @param float $total + * @return string + */ + public function getInstalmentOptions($code, $total) + { + $instalmentCycles = $this->novalnetConfig->getPaymentConfig($code, 'instalment_cycles'); + $instalmentCycles = (!empty($instalmentCycles)) ? explode(',', $instalmentCycles) : []; + $storeId = $this->storeManager->getStore()->getId(); + $allCycles = []; + $i =1; + foreach ($instalmentCycles as $cycle) { + if (($total/$cycle) >= 9.99) { + $formattedAmount = strip_tags($this->novalnetRequestHelper->getAmountWithSymbol(sprintf('%0.2f', $total / $cycle), $storeId)); + $allCycles[$i] = ['instalment_key' => $cycle.' X ' . $formattedAmount . '(' .(__(' per month'). ')'), 'instalment_value' => $cycle]; + $i++; + } + } + return $this->jsonHelper->jsonEncode($allCycles); + } + + /** + * Get Instalment payment cycle details + * + * @api + * @param float $amount + * @param int $period + * @return string + */ + public function getInstalmentCycleAmount($amount, $period) + { + $cycleAmount = sprintf('%0.2f', $amount / $period); + $splitedAmount = $cycleAmount * ( $period - 1 ); + $lastCycle = (sprintf('%0.2f', $amount - $splitedAmount) * 100)/100; + $data = ['cycle_amount' => $cycleAmount, 'last_cycle' => $lastCycle, 'amount' => $amount]; + return $this->jsonHelper->jsonEncode($data); + } + + /** + * Novalnet payment callback + * + * @api + * @return string + */ + public function callback() + { + if ($this->assignGlobalParams()) { + if ($this->eventType == 'PAYMENT') { + if (empty($this->paymentTxnId)) { + $this->handleCommunicationFailure(); + } else { + $this->displayMessage('Novalnet Callback executed. The Transaction ID already existed'); + } + } elseif ($this->eventType == 'TRANSACTION_CAPTURE') { + $this->transactionCapture(); + } elseif ($this->eventType == 'TRANSACTION_CANCEL') { + $this->transactionCancellation(); + } elseif ($this->eventType == 'TRANSACTION_REFUND') { + $this->refundProcess(); + } elseif ($this->eventType == 'TRANSACTION_UPDATE') { + $this->transactionUpdate(); + } elseif ($this->eventType == 'CREDIT') { + $this->creditProcess(); + } elseif ($this->eventType == 'INSTALMENT') { + $this->instalmentProcess(); + } elseif ($this->eventType == 'INSTALMENT_CANCEL') { + $this->instalmentCancelProcess(); + } elseif (in_array($this->eventType, ['CHARGEBACK', 'RETURN_DEBIT', 'REVERSAL'])) { + $this->chargebackProcess(); + } elseif (in_array($this->eventType, ['PAYMENT_REMINDER_1', 'PAYMENT_REMINDER_2'])) { + $this->paymentReminderProcess(); + } elseif ($this->eventType == 'SUBMISSION_TO_COLLECTION_AGENCY') { + $this->collectionProcess(); + } else { + $this->displayMessage("The webhook notification has been received for the unhandled EVENT type($this->eventType)"); + } + } + + return $this->additionalMessage . $this->callbackMessage; + } + + /** + * Assign Global params for callback process + * + * @return boolean + */ + private function assignGlobalParams() + { + try { + $this->eventData = (!empty($this->requestInterface->getContent())) ? json_decode($this->requestInterface->getContent(), true) : []; + } catch (\Exception $e) { + $this->novalnetLogger->error("Received data is not in the JSON format $e"); + $this->displayMessage("Received data is not in the JSON format $e"); + } + + // Get callback setting params (from shop admin) + $this->testMode = $this->novalnetConfig->getMerchantScriptConfig('test_mode'); + $this->emailBody = ''; + + // Check whether the IP address is authorized + if (!$this->checkIP()) { + return false; + } + + if (empty($this->eventData)) { + $this->displayMessage('No params passed over!'); + return false; + } + + $this->response = new DataObject(); + $this->response->setData($this->eventData); // Assign response params to object data + + // Set Event data + $this->eventType = $this->response->getData('event/type'); + $this->parentTid = !empty($this->response->getData('event/parent_tid')) + ? $this->response->getData('event/parent_tid') : $this->response->getData('event/tid'); + $this->eventTid = $this->response->getData('event/tid'); + $this->orderNo = $this->response->getData('transaction/order_no'); + $this->order = $this->getOrder(); + if ($this->order === false) { + return false; + } + $this->currentTime = $this->dateTime->date('d-m-Y H:i:s'); + $this->storeId = $this->order->getStoreId(); // Get order store id + + $this->paymentAccessKey = $this->novalnetConfig->getGlobalConfig('payment_access_key', $this->storeId); + $this->payment = $this->order->getPayment(); // Get payment object + $this->code = $this->payment->getMethodInstance()->getCode(); // Get payment method code + $this->paymentTxnId = $this->payment->getLastTransId(); // Get payment last transaction id + $this->currency = $this->order->getOrderCurrencyCode(); // Get order currency + if (!$this->validateEventData()) { + return false; + } + + return true; + } + + /** + * Check whether the ip address is authorised + * + * @return boolean + */ + private function checkIP() + { + // Authenticating the server request based on IP. + $requestReceivedIp = $this->novalnetRequestHelper->getRequestIp(); + $novalnetHostIp = gethostbyname('pay-nn.de'); + + if (!empty($novalnetHostIp) && !empty($requestReceivedIp)) { + if ($novalnetHostIp !== $requestReceivedIp && !$this->testMode) { + $this->displayMessage( + __('Unauthorised access from the IP [ %1 ]', $requestReceivedIp) + ); + + return false; + } + } else { + $this->displayMessage('Unauthorised access from the IP'); + return false; + } + + return true; + } + + /** + * Validate required parameter from the server request + * + * @return bool + */ + private function validateEventData() + { + foreach ($this->mandatoryParams as $category => $parameters) { + if (empty($this->response->getData($category))) { + // Could be a possible manipulation in the notification data + $this->displayMessage('Required parameter category(' . $category . ') not received'); + + return false; + } else { + foreach ($parameters as $parameter) { + if (empty($this->response->getData($category .'/'. $parameter))) { + // Could be a possible manipulation in the notification data + $this->displayMessage( + 'Required parameter(' . $parameter . ') in the category(' . $category . ') not received' + ); + + return false; + } + } + } + } + + // Validate the received checksum. + if (!$this->validateChecksum()) { + return false; + } + + // Validate TID's from the event data + if (!empty($this->parentTid) && !preg_match('/^\d{17}$/', $this->parentTid) + ) { + $this->displayMessage( + 'Invalid TID[' . $this->parentTid + . '] for Order :' . $this->response->getData('transaction/order_no') + ); + + return false; + } elseif (!empty($this->eventTid) && !preg_match('/^\d{17}$/', $this->eventTid)) { + $this->displayMessage( + 'Invalid TID[' . $this->eventTid + . '] for Order :' . $this->response->getData('transaction/order_no') + ); + + return false; + } + + return true; + } + + /** + * Validate checksum in response + * + * @return bool + */ + private function validateChecksum() + { + $checksumString = $this->response->getData('event/tid') . $this->response->getData('event/type') + . $this->response->getData('result/status'); + + if (isset($this->response->getData('transaction')['amount'])) { + $checksumString .= $this->response->getData('transaction/amount'); + } + + if ($this->response->getData('transaction/currency')) { + $checksumString .= $this->response->getData('transaction/currency'); + } + + $accessKey = trim($this->paymentAccessKey); + if (!empty($accessKey)) { + $checksumString .= strrev($accessKey); + } + + $generatedChecksum = hash('sha256', $checksumString); + if ($generatedChecksum !== $this->response->getData('event/checksum')) { + $this->displayMessage('While notifying some data has been changed. The hash check failed'); + + return false; + } + + return true; + } + + /** + * Get order reference. + * + * @return mixed + */ + private function getOrder() + { + if ($this->orderNo) { + $order = $this->salesOrderModel->loadByIncrementId($this->orderNo); + } + + if (!isset($order) || empty($order->getIncrementId())) { + $orderCollection = $this->transactionModel->getCollection()->addFieldToFilter('txn_id', $this->parentTid); + if (!empty($orderCollection)) { + $order = $orderCollection->getFirstItem()->getOrder(); + } + } + + if (empty($order) || empty($order->getIncrementId())) { + $this->displayMessage('Required (Transaction ID) not Found!'); + return false; + } + + return $order; + } + + /** + * Complete the order in-case response failure from Novalnet server + * + * @return bool + */ + private function handleCommunicationFailure() + { + if ($this->novalnetConfig->getPaymentType($this->code) != $this->response->getData('transaction/payment_type')) { + $this->displayMessage( + 'Novalnet callback received. Payment type ( ' . $this->response->getData('transaction/payment_type') + . ' ) is not matched with ' . $this->code . '!' + ); + return false; + } + // Unhold order if it is being held + if ($this->order->canUnhold()) { + $this->order->unhold()->save(); + } + + // update and save the payment additional data + $additionalData = $this->novalnetRequestHelper->buildAdditionalData($this->response, $this->payment); + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + $amount = $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('transaction/amount'), + 'RAW' + ); + + // Set order status based on Novalnet transaction status + if ($this->response->getData('result/status') == 'SUCCESS' && + in_array($this->response->getData('transaction/status'), ['PENDING', 'ON_HOLD', 'CONFIRMED']) + ) { + if ($this->order->canInvoice() && $this->response->getData('transaction/status') == 'CONFIRMED') { + // capture transaction + $this->payment->setTransactionId($additionalData['NnTid']) + ->setLastTransId($additionalData['NnTid']) + ->capture(null) + ->setAmount($amount) + ->setIsTransactionClosed(false) + ->setShouldCloseParentTransaction(false) + ->save(); + } else { + // authorize transaction + $this->payment->authorize(true, $amount)->save(); + } + + $orderStatus = $this->getOrderStatus(); + $this->order->setState(Order::STATE_PROCESSING) + ->addStatusToHistory($orderStatus, __('Customer successfully returned from Novalnet')) + ->save(); + if (!empty($this->response->getData('transaction/payment_data/token'))) { + $this->novalnetRequestHelper->savePaymentToken($this->order, $this->code, $this->response); + } + + // Order email + if ($this->order->getCanSendNewEmailFlag()) { + try { + $this->orderEmailSender->send($this->order); + $invoice = current($this->order->getInvoiceCollection()->getItems()); + if ($invoice) { + $this->invoiceSender->send($invoice); + } + } catch (\Exception $e) { + $this->novalnetLogger->error($e); + } + } + } else { + // Cancel the order based on Novalnet transaction status + $this->novalnetRequestHelper->saveCanceledOrder($this->response, $this->order); + $this->displayMessage('Payment cancelled for the transaction ' . $this->eventTid); + } + + $this->displayMessage('Novalnet Callback Script executed successfully on ' . $this->currentTime); + } + + /** + * Log callback transaction information + * + * @param \Novalnet\Payment\Model\Callback $callbackModel + * @param float $amount + * @param string $orderNo + * @return void + */ + private function logCallbackInfo($callbackModel, $amount, $orderNo) + { + // Get the original/parent transaction id + $callbackModel->setOrderId($orderNo) + ->setCallbackAmount($amount) + ->setReferenceTid($this->eventTid) + ->setCallbackTid($this->parentTid) + ->setCallbackDatetime($this->currentTime) + ->save(); + } + + /** + * Get payment order status for CREDIT Event + * + * @return void + */ + private function getOrderStatusforCreditEvent() + { + if ($this->response->getData('transaction/status') == 'CONFIRMED') { + $orderStatus = $this->novalnetConfig->getPaymentConfig($this->code, 'order_status_after_payment', $this->storeId); + } + + $orderStatus = !empty($orderStatus) ? $orderStatus : Order::STATE_PROCESSING; + $orderState = Order::STATE_PROCESSING; + $this->order->setState( + $orderState, + true, + __('Novalnet webhook set status (%1) for Order ID = %2', $orderState, $this->orderNo) + ); + $this->order->addStatusToHistory( + $orderStatus, + __('Novalnet webhook added order status %1', $orderStatus) + ); + $this->order->save(); + } + + /** + * Get payment order status + * + * @return string + */ + private function getOrderStatus() + { + $orderStatus = 'pending'; + if ($this->response->getData('transaction/status') == 'ON_HOLD') { + $orderStatus = $this->novalnetConfig->getGlobalOnholdStatus($this->storeId); + } elseif ($this->response->getData('transaction/status') == 'CONFIRMED' || $this->response->getData('transaction/status') == 'PENDING' && !$this->novalnetConfig->isRedirectPayment($this->code) + && !in_array( + $this->code, + [ + ConfigProvider::NOVALNET_INVOICE_INSTALMENT, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE + ] + ) + ) { + $orderStatus = $this->novalnetConfig->getPaymentConfig($this->code, 'order_status', $this->storeId); + } + + return !empty($orderStatus) ? $orderStatus : Order::STATE_PROCESSING; + } + + /** + * Show callback process transaction comments + * + * @param string $text + * @param boolean $pullOut + * @return void + */ + private function displayMessage($text, $pullOut = true) + { + if ($pullOut === false) { + $this->additionalMessage = $text; + } else { + $this->callbackMessage = $text; + } + + $this->novalnetLogger->notice($text); + } + + /** + * Send callback notification E-mail + * + * @return bool + */ + private function sendCallbackMail() + { + // Get email configuration settings + $this->getEmailConfig(); + + if ($this->emailBody && $this->emailFromAddr && $this->emailToAddr) { + if (!$this->sendEmailMagento()) { + $this->displayMessage('Mailing failed!' . '
', false); + return false; + } + } + } + + /** + * Get email config + * + * @return void + */ + private function getEmailConfig() + { + $this->storeFrontendName = $this->storeManager->getStore()->getFrontendName(); + $this->emailFromAddr = $this->getConfigValue('trans_email/ident_general/email'); + $this->emailFromName = $this->getConfigValue('trans_email/ident_general/name'); + $this->emailToAddr = $this->novalnetConfig->getMerchantScriptConfig('mail_to_addr'); + $this->emailToName = 'store admin'; // Adapt for your need + $this->emailSubject = 'Novalnet Callback Script Access Report - ' . $this->storeFrontendName; + } + + /** + * Send callback notification E-mail (with callback template) + * + * @return boolean + */ + private function sendEmailMagento() + { + try { + $emailToAddrs = str_replace(' ', '', $this->emailToAddr); + $emailToAddrs = (!empty($emailToAddrs)) ? explode(',', $emailToAddrs) : []; + $templateVars = [ + 'fromName' => $this->emailFromName, + 'fromEmail' => $this->emailFromAddr, + 'toName' => $this->emailToName, + 'toEmail' => $this->emailToAddr, + 'subject' => $this->emailSubject + ]; + + if (!empty($this->emailBody) && + is_object($this->emailBody) && + $this->emailBody instanceof \Magento\Framework\Phrase + ) { + $templateVars['body'] = $this->emailBody->render(); + } else { + $templateVars['body'] = $this->emailBody; + } + + $from = ['email' => $this->emailFromAddr, 'name' => $this->emailFromName]; + $this->inlineTranslation->suspend(); + + $storeId = $this->storeManager->getStore()->getId(); + $templateOptions = [ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => $storeId + ]; + $transport = $this->transportBuilder->setTemplateIdentifier( + 'novalnet_callback_email_template', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->setTemplateOptions($templateOptions) + ->setTemplateVars($templateVars) + ->setFrom($from) + ->addTo($emailToAddrs) + ->getTransport(); + + $transport->sendMessage(); + $this->inlineTranslation->resume(); + $this->displayMessage(__FUNCTION__ . ': Sending Email succeeded!
', false); + } catch (\Exception $e) { + $this->novalnetLogger->error("Email sending failed: $e"); + $this->displayMessage('Email sending failed: ', false); + return false; + } + + return true; + } + + /** + * Retrieves Novalnet configuration values + * + * @param string $path + * @return string + */ + private function getConfigValue($path) + { + return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + } + + /** + * Capture transaction + * + * @return void + */ + private function transactionCapture() + { + $invoiceDuedate = $this->response->getData('transaction/due_date'); + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $transactionStatus = !empty($additionalData['NnStatus']) + ? $this->novalnetRequestHelper->getStatus($additionalData['NnStatus'], $this->order) : ''; + + if ($this->order->canInvoice() && + in_array($transactionStatus, ['ON_HOLD', 'PENDING']) + ) { + if ($invoiceDuedate && $this->response->getData('result/status') == 'SUCCESS') { + $formatDate = $this->timeZone->formatDate($invoiceDuedate, \IntlDateFormatter::LONG); + if (isset($additionalData['NnInvoiceComments'])) { + $note = (!empty($additionalData['NnInvoiceComments'])) ? explode('|', $additionalData['NnInvoiceComments']) : []; + $additionalData['NnInvoiceComments'] = (!empty($note)) ? implode('|', $note) : ''; + $additionalData['NnDueDate'] = $formatDate; + } + if ($this->code == ConfigProvider::NOVALNET_CASHPAYMENT) { + $additionalData['CpDueDate'] = $formatDate; + } + $additionalData['dueDateUpdateAt'] = $this->dateTime->date('d-m-Y H:i:s'); + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } + + $this->emailBody = $message = __( + 'The transaction has been confirmed on %1', + $this->currentTime + ); + $additionalData['NnStatus'] = $this->response->getData('transaction/status'); + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? + '
'. $message . '
' : $additionalData['NnComments'] . '
' . $message . '
'; + + if (in_array( + $this->payment->getMethod(), + [ConfigProvider::NOVALNET_INVOICE_INSTALMENT, ConfigProvider::NOVALNET_SEPA_INSTALMENT] + )) { + $additionalData = $this->getInstalmentAdditionalData($additionalData); + } + + $transactionStatus = $this->transactionStatusModel->loadByAttribute($this->parentTid, 'tid'); + $transactionStatus->setStatus($additionalData['NnStatus'])->save(); + // Capture the Authorized transaction + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData)) + ->capture(null)->save(); + + $orderStatus = $this->getOrderStatus(); + $this->order->setState(Order::STATE_PROCESSING) + ->addStatusToHistory($orderStatus, 'The transaction has been confirmed') + ->save(); + $invoice = current($this->order->getInvoiceCollection()->getItems()); + if ($invoice) { + $this->invoiceSender->send($invoice); + } + } else { + // transaction already captured or transaction not been authorized. + $message = 'Order already captured.'; + } + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Get Instalment payment Additional data + * + * @param array $additionalData + * @return array $additionalData + */ + private function getInstalmentAdditionalData($additionalData) + { + $additionalData['PaidInstall'] = $this->response->getData('instalment/cycles_executed'); + $additionalData['DueInstall'] = $this->response->getData('instalment/pending_cycles'); + $additionalData['NextCycle'] = $this->response->getData('instalment/next_cycle_date'); + if ($futureInstalmentDates = $this->response->getData('instalment/cycle_dates')) { + foreach (array_keys($futureInstalmentDates) as $cycle) { + $additionalData['InstalmentDetails'][$cycle] = ['amount' => $additionalData['InstallPaidAmount'], + 'nextCycle' => !empty($futureInstalmentDates[$cycle + 1]) ? date('Y-m-d', strtotime($futureInstalmentDates[$cycle + 1])) : '', + 'paidDate' => ($cycle == 1) ? date('Y-m-d') : '', + 'status' => ($cycle == 1) ? 'Paid' : 'Pending', + 'reference' => ($cycle == 1) ? $this->response->getData('transaction/tid') : '']; + } + } + return $additionalData; + } + + /** + * Check transaction cancellation + * + * @return void + */ + private function transactionCancellation() + { + $transactionStatus = $this->transactionStatusModel->loadByAttribute($this->parentTid, 'tid'); + + $this->novalnetRequestHelper->saveCanceledOrder($this->response, $this->order, $this->response->getData('transaction/status')); + $this->emailBody = $message = __( + 'The transaction has been canceled on %1', + $this->currentTime + ); + + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnComments'] = empty($additionalData['NnComments']) + ? '
' . $message : $additionalData['NnComments'] . '

' . $message; + $additionalData['NnStatus'] = $this->response->getData('transaction/status'); + $transactionStatus->setStatus($additionalData['NnStatus'])->save(); + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle payment refund/bookback process + * + * @return void + */ + private function refundProcess() + { + $refundTid = empty($this->response->getData('transaction/refund/tid')) + ? $this->response->getData('transaction/tid') : $this->response->getData('transaction/refund/tid'); + $refundAmount = empty($this->response->getData('transaction/refund/amount')) + ? $this->response->getData('transaction/amount') : $this->response->getData('transaction/refund/amount'); + $this->emailBody = $message = __( + 'Refund has been initiated for the TID: %1 with the amount %2. New TID:%3', + $this->parentTid, + $this->novalnetRequestHelper->getFormattedAmount($refundAmount, 'RAW') . ' ' . $this->currency, + $refundTid + ); + $shopInvoked = !empty($this->response->getData('custom/shop_invoked')) + ? $this->response->getData('custom/shop_invoked') : 0; + + if (!$shopInvoked) { + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message : + $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } + + if ($this->order->getState() != Order::STATE_CLOSED && $this->order->canCreditmemo() && !$shopInvoked) { + $refundData = []; + $grandTotal = $this->novalnetRequestHelper->getFormattedAmount($this->order->getGrandTotal()); + $totalRefunded = $this->novalnetRequestHelper->getFormattedAmount($this->order->getTotalOnlineRefunded()); + $totalRefundNow = $totalRefunded + $refundAmount; + if ($totalRefunded >= $grandTotal || $refundAmount >= $grandTotal) { + $adjustmentNegative = $grandTotal - $refundAmount; + $refundData['adjustment_negative'] = $this->novalnetRequestHelper->getFormattedAmount($adjustmentNegative, 'RAW'); + $creditmemo = $this->creditMemoFacory->createByOrder($this->order, $refundData); + $this->creditmemoService->refund($creditmemo); + } elseif ($totalRefunded < $grandTotal && $totalRefundNow <= $grandTotal) { + $refundData['adjustment_positive'] = ($this->novalnetRequestHelper->getFormattedAmount($refundAmount, 'RAW')); + $itemToCredit = []; + foreach ($this->order->getAllItems() as $item) { + $itemToCredit[$item->getId()] = ['qty'=> 0]; + } + $refundData['adjustment_negative'] = 0; + $refundData['shipping_amount'] = 0; + $refundData['items'] = $itemToCredit; + $this->creditmemoLoader->setOrderId($this->order->getId()); //pass order id + $this->creditmemoLoader->setCreditmemo($refundData); + $creditmemo = $this->creditmemoLoader->load(); + $this->creditmemoService->refund($creditmemo); + } + } + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle transaction update + * + * @return void + */ + private function transactionUpdate() + { + $invoiceDuedate = $this->response->getData('transaction/due_date'); + $transactionPaymentType = $this->response->getData('transaction/payment_type'); + $transaction = $this->transactionStatusModel->loadByAttribute($this->parentTid, 'tid'); + $message = "Novalnet callback received for the unhandled transaction type($transactionPaymentType) for $this->eventType EVENT"; + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + $transactionStatus = $this->novalnetRequestHelper->getStatus($transaction->getStatus(), $this->order); + + if ($invoiceDuedate && $this->response->getData('result/status') == 'SUCCESS') { + $formatDate = $this->timeZone->formatDate($invoiceDuedate, \IntlDateFormatter::LONG); + $nnAmount = $this->pricingHelper->currency( + $this->novalnetRequestHelper->getFormattedAmount(($this->response->getData('instalment/cycle_amount') ? $this->response->getData('instalment/cycle_amount') + : $this->response->getData('transaction/amount')), 'RAW'), + true, + false + ); + $additionalData['NnAmount'] = $nnAmount; + $this->emailBody = $message = __( + 'The transaction has been updated with amount %1 and due date with %2', + $additionalData['NnAmount'], + $formatDate + ); + if (isset($additionalData['NnInvoiceComments'])) { + $note = (!empty($additionalData['NnInvoiceComments'])) ? explode('|', $additionalData['NnInvoiceComments']) : []; + $additionalData['NnInvoiceComments'] = (!empty($note)) ? implode('|', $note) : ''; + $additionalData['NnDueDate'] = $formatDate; + } + if ($this->code == ConfigProvider::NOVALNET_CASHPAYMENT) { + $additionalData['CpDueDate'] = $formatDate; + $this->emailBody = $message = __( + 'The transaction has been updated with amount %1 and slip expiry date with %2', + $additionalData['NnAmount'], + $formatDate + ); + } + $additionalData['dueDateUpdateAt'] = $this->dateTime->date('d-m-Y H:i:s'); + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } + + if ($transactionStatus == 'PENDING') { + if ($this->response->getData('transaction/status') == 'ON_HOLD') { + $orderStatus = $this->novalnetConfig->getGlobalOnholdStatus($this->storeId); + $this->emailBody = $message = __( + 'The transaction status has been changed from pending to on hold for the TID: %1 on %2.', + $this->parentTid, + $this->currentTime + ); + $additionalData['NnStatus'] = $this->response->getData('transaction/status'); + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? + '
' . $message . '
' : $additionalData['NnComments'] . '
' . $message . '
'; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } elseif ($this->response->getData('transaction/status') == 'CONFIRMED') { + if (in_array( + $this->payment->getMethod(), + [ConfigProvider::NOVALNET_INVOICE_INSTALMENT, ConfigProvider::NOVALNET_SEPA_INSTALMENT] + )) { + $additionalData = $this->getInstalmentAdditionalData($additionalData); + } + $this->emailBody = $message = __( + 'Transaction updated successfully for the TID: %1 with the amount %2 on %3', + $this->eventTid, + $amount = $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('transaction/amount'), + 'RAW' + ).' '.$this->currency, + $this->currentTime + ); + + $additionalData['NnStatus'] = $this->response->getData('transaction/status'); + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? + '
' . $message . '
' : $additionalData['NnComments'] . '
' . $message . '
'; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $this->payment->setTransactionId($this->parentTid . '-capture') + ->setIsTransactionClosed(true) + ->capture(null)->save(); + $orderStatus = $this->novalnetConfig->getPaymentConfig($this->code, 'order_status', $this->storeId); + } + + $transaction->setStatus($this->response->getData('transaction/status'))->save(); + if (!empty($orderStatus)) { + $this->order->setState(Order::STATE_PROCESSING) + ->setStatus($orderStatus) + ->save(); + } + $invoice = current($this->order->getInvoiceCollection()->getItems()); + if ($invoice && $this->response->getData('transaction/status') == 'CONFIRMED') { + $this->invoiceSender->send($invoice); + } + } elseif ($transactionStatus == 'ON_HOLD' && $this->response->getData('transaction/status') == 'ON_HOLD' && + in_array($this->code, [ConfigProvider::NOVALNET_SEPA, ConfigProvider::NOVALNET_SEPA_GUARANTEE, ConfigProvider::NOVALNET_INVOICE_GUARANTEE, ConfigProvider::NOVALNET_PREPAYMENT])) { + $this->emailBody = $message = __( + 'Transaction updated successfully for the TID: %1 with the amount %2 on %3', + $this->eventTid, + $amount = $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('transaction/amount'), + 'RAW' + ).' '.$this->currency, + $this->currentTime + ); + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? + '
' . $message . '
' : $additionalData['NnComments'] . '
' . $message . '
'; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle payment credit process + * + * @return void + */ + private function creditProcess() + { + $transactionPaymentType = $this->response->getData('transaction/payment_type'); + $message = "Novalnet callback received for the unhandled transaction type($transactionPaymentType) for $this->eventType EVENT"; + $amount = $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('transaction/amount'), + 'RAW' + ); + + if (in_array( + $transactionPaymentType, + ['INVOICE_CREDIT', 'ONLINE_TRANSFER_CREDIT', 'CASHPAYMENT_CREDIT', 'MULTIBANCO_CREDIT'] + )) { + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + $updatedAmount = str_replace(',', '.', $this->currencyModel->format($additionalData['NnAmount'], ['display' => \Magento\Framework\Currency::NO_SYMBOL], false)); + $updatedAmount = $this->novalnetRequestHelper->getFormattedAmount($updatedAmount); + // Loads callback model using the Increment ID + $callbackInfo = $this->callbackModel->loadLogByOrderId($this->orderNo); + $transactionStatus = $this->transactionStatusModel->loadByAttribute($this->parentTid, 'tid'); + $totalAmount = $this->response->getData('transaction/amount') + $callbackInfo->getCallbackAmount(); + // Get original order amount + $grandTotal = $this->novalnetRequestHelper->getFormattedAmount($this->order->getGrandTotal()); + $totalAmountRefunded = $this->novalnetRequestHelper->getFormattedAmount($this->order->getTotalRefunded()); + // Log callback data for reference + $this->logCallbackInfo($callbackInfo, $totalAmount, $this->orderNo); + $message = __( + 'Credit has been successfully received for the TID: %1 with amount %2 on %3. Please refer PAID order details in our Novalnet Admin Portal for the TID: %4', + $this->parentTid, + $amount . ' ' . $this->currency, + $this->currentTime, + $this->eventTid + ); + + $additionalData['NnStatus'] = ($this->response->getData('transaction/status')) + ? $this->response->getData('transaction/status') : ''; + $transactionStatus->setStatus($this->response->getData('transaction/status'))->save(); + $currentGrandTotal = 0; + if ($totalAmountRefunded) { + $currentGrandTotal = $grandTotal - $totalAmountRefunded; + if ($totalAmount >= $currentGrandTotal) { + $additionalData['NnPaid'] = 1; + } + } elseif ($totalAmount >= $grandTotal) { + $additionalData['NnPaid'] = 1; + } + if (($totalAmount < $grandTotal) || + $transactionPaymentType == 'ONLINE_TRANSFER_CREDIT' + ) { + if ($transactionPaymentType == 'ONLINE_TRANSFER_CREDIT' && ($totalAmount > $grandTotal)) { + $message = $message . '
' . __( + 'Credit has been successfully received for the TID: %1 with amount %2 on %3. Please refer PAID order details in our Novalnet Admin Portal for the TID: %4', + $this->parentTid, + $amount . ' ' . $this->currency, + $this->currentTime, + $this->eventTid + ); + } + + $this->emailBody = $message; + $additionalData['NnComments'] = empty($additionalData['NnComments']) + ? '
' . $message + : $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + if ($totalAmountRefunded) { + if (($totalAmount >= $currentGrandTotal)) { + $this->getOrderStatusforCreditEvent(); // Set order status + } + } elseif ($updatedAmount) { + if (($totalAmount >= $updatedAmount)) { + $this->getOrderStatusforCreditEvent(); // Set order status + } + } + } elseif ($this->order->canInvoice()) { + $this->emailBody = $message; + $additionalData['NnComments'] = empty($additionalData['NnComments']) + ? '
' . $message + : $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + // Save payment information with invoice for Novalnet successful transaction + $this->payment->setTransactionId($this->parentTid . '-capture') + ->setIsTransactionClosed(true) + ->capture(null)->save(); + $this->order->save(); + $this->order->setPayment($this->payment)->save(); + $invoice = $this->order->getInvoiceCollection()->getFirstItem(); + if ($invoice) { + $this->invoiceSender->send($invoice); + } + $this->getOrderStatusforCreditEvent(); // Set order status + } elseif ($this->payment->getAdditionalInformation($this->code . '_callbackSuccess') != 1) { + $this->emailBody = $message; + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message + : $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalInformation($this->code + . '_callbackSuccess', 1); + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $orderStatus = $this->getOrderStatusforCreditEvent(); // Set order status + $this->order->setPayment($this->payment)->save(); + + $invoice = $this->order->getInvoiceCollection()->getFirstItem(); + $invoice->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); + $invoice->save(); + } else { + $message = 'Callback Script executed already. Refer Order :' . $this->orderNo; + } + } else { + $message = __( + 'Credit has been successfully received for the TID: %1 with amount %2 on %3. Please refer PAID order details in our Novalnet Admin Portal for the TID: %4', + $this->parentTid, + $amount . ' ' . $this->currency, + $this->currentTime, + $this->eventTid + ); + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + $this->emailBody = $message; + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message + : $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + } + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle payment INSTALMENT process + * + * @return void + */ + private function instalmentProcess() + { + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnTid'] = $this->response->getData('transaction/tid'); + $instalmentTransactionAmount = $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('instalment/cycle_amount'), + 'RAW' + ); + $paidAmount = $additionalData['InstallPaidAmount'] + $instalmentTransactionAmount; + $additionalData['InstallPaidAmount'] = $paidAmount; + $additionalData['PaidInstall'] = $this->response->getData('instalment/cycles_executed'); + $additionalData['DueInstall'] = $this->response->getData('instalment/pending_cycles'); + $additionalData['NextCycle'] = $this->response->getData('instalment/next_cycle_date'); + if ($this->response->getData('instalment/prepaid')) { + $additionalData['prepaid'] = $this->response->getData('instalment/prepaid'); + } else { + if (isset($additionalData['prepaid'])) { + unset($additionalData['prepaid']); + } + } + $additionalData['InstallCycleAmount'] = $instalmentTransactionAmount; + $additionalData['NnAmount'] = $this->pricingHelper->currencyByStore($instalmentTransactionAmount, $this->order->getStore()->getStoreId(), true, false); + + if ($this->response->getData('transaction/payment_type') == 'INSTALMENT_INVOICE') { + $note = (!empty($additionalData['NnInvoiceComments'])) ? explode('|', $additionalData['NnInvoiceComments']) : []; + if ($this->response->getData('transaction/due_date')) { + $formatDate = $this->timeZone->formatDate( + $this->response->getData('transaction/due_date'), + \IntlDateFormatter::LONG + ); + $additionalData['NnDueDate'] = $formatDate; + } + + $note[5] = 'InvoiceAmount:' . $this->pricingHelper->currencyByStore( + $instalmentTransactionAmount, + $this->order->getStore()->getStoreId(), + true, + false + ); + + $note[6] = 'Payment Reference:' . $this->response->getData('transaction/tid'); + if (isset($note[7])) { + unset($note[7]); + } + $additionalData['NnInvoiceComments'] = (!empty($note)) ? implode('|', $note) : ''; + } + + $additionalData['InstalmentDetails'][$this->response->getData('instalment/cycles_executed')] = [ + 'amount' => $instalmentTransactionAmount, + 'nextCycle' => $this->response->getData('instalment/next_cycle_date'), + 'paidDate' => date('Y-m-d'), + 'status' => 'Paid', + 'reference' => $this->response->getData('transaction/tid') + ]; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + // Send instalment email to end customer + if (!$this->novalnetConfig->getGlobalConfig('instalment_mail', $this->storeId)) { + $this->sendInstalmentmail(); + } + + $this->displayMessage('Novalnet Callbackscript received. Instalment payment executed properly'); + } + + /** + * Handle payment INSTALMENT process + * + * @return void + */ + private function instalmentCancelProcess() + { + $this->emailBody = $message = __( + 'Instalment has been cancelled for the TID %1 on %2', + $this->parentTid, + $this->currentTime + ); + + $additionalData = (!empty($this->payment->getAdditionalData())) ? ($this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true)) : [] ; + + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message : + $additionalData['NnComments'] . '

' . $message; + $additionalData['InstalmentCancel'] = 1; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + $this->order->setState(Order::STATE_CLOSED)->setStatus(Order::STATE_CLOSED)->save(); + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Send Instalment mail + * + * @return mixed + */ + private function sendInstalmentmail() + { + $this->getEmailConfig(); + $from = ['email' => $this->emailFromAddr, 'name' => $this->emailFromName]; + $additionalData = $this->order->getPayment()->getAdditionalData(); + if (!empty($additionalData)) { + $additionalData = $this->novalnetRequestHelper->isSerialized($additionalData) + ? $this->serializer->unserialize($additionalData) + : json_decode($additionalData, true); + } + + $templateVars = [ + 'order' => $this->order, + 'orderNo' => $this->orderNo, + 'storeName' => $this->storeFrontendName, + 'order_id' => $this->order->getId(), + 'customer_name' => $this->order->getCustomerName(), + 'cycleAmount' => $this->novalnetRequestHelper->getFormattedAmount($this->response->getData('instalment/cycle_amount'), 'RAW'), + 'currency' => $this->currency, + 'formattedShippingAddress' => !empty($this->order->getShippingAddress()) ? $this->salesOrderAddressRenderer->format($this->order->getShippingAddress(), 'html') : '', + 'formattedBillingAddress' => $this->salesOrderAddressRenderer->format($this->order->getBillingAddress(), 'html'), + 'store' => $this->order->getStore(), + 'payment_html' => $this->paymentHelper->getInfoBlockHtml( + $this->order->getPayment(), + $this->order->getStore()->getStoreId() + ), + 'sepaPayment' => ((!isset($additionalData['prepaid']) || empty($additionalData['prepaid'])) && ($this->response->getData('transaction/payment_type') == 'INSTALMENT_DIRECT_DEBIT_SEPA')) ? 1 : "" + ]; + + try { + $this->inlineTranslation->suspend(); + $templateOptions = [ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => $this->order->getStore()->getStoreId() + ]; + + $transport = $this->transportBuilder->setTemplateIdentifier( + 'novalnet_callback_instalment_email_template', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->setTemplateOptions($templateOptions) + ->setTemplateVars($templateVars) + ->setFrom($from) + ->addTo($this->order->getCustomerEmail()) + ->getTransport(); + + $transport->sendMessage(); + $this->inlineTranslation->resume(); + $this->displayMessage(__FUNCTION__ . ': Sending Email succeeded!'.'
', false); + } catch (\Exception $e) { + $this->novalnetLogger->error("Email sending failed: $e"); + $this->displayMessage('Email sending failed: ', false); + return false; + } + } + + /** + * Handle payment CHARGEBACK/RETURN_DEBIT/REVERSAL process + * + * @return void + */ + private function chargebackProcess() + { + // Update callback comments for Chargebacks + $this->emailBody = $message = __( + 'Chargeback executed successfully for the TID: %1 amount: %2 on %3. The subsequent TID: %4', + $this->parentTid, + $this->novalnetRequestHelper->getFormattedAmount( + $this->response->getData('transaction/amount'), + 'RAW' + ) . ' ' . $this->currency, + $this->currentTime, + $this->response->getData('transaction/tid') + ); + + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message : + $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle payment reminder process + * + * @return void + */ + private function paymentReminderProcess() + { + $reminderCount = explode('_', $this->response->getData('event/type')); + $reminderCount = end($reminderCount); + $this->emailBody = $message = __( + 'Payment Reminder %1 has been sent to the customer.', + $reminderCount + ); + + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message : + $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Handle collection process + * + * @return void + */ + private function collectionProcess() + { + $this->emailBody = $message = __( + 'The transaction has been submitted to the collection agency. Collection Reference: %1', + $this->response->getData('collection/reference') + ); + + $additionalData = []; + if (!empty($this->payment->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($this->payment->getAdditionalData()) + ? $this->serializer->unserialize($this->payment->getAdditionalData()) + : json_decode($this->payment->getAdditionalData(), true); + } + + $additionalData['NnComments'] = empty($additionalData['NnComments']) ? '
' . $message : + $additionalData['NnComments'] . '

' . $message; + $this->payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + $this->sendCallbackMail(); + $this->displayMessage($message); + } + + /** + * Get Cart Contents + * + * @api + * @return string + */ + public function getCart() + { + $quote = $this->cart->getQuote(); + + try { + $result = $this->getCartItems($quote); + return $this->jsonHelper->jsonEncode($result); + } catch (\Exception $e) { + throw new CouldNotSaveException(__($e->getMessage()), $e); + } + } + + /** + * Get express checkout request params for Product page + * + * @api + * @param string[] $data + * @return string + */ + public function getProductPageParams($data) + { + $product = $this->loadProductById($data['product_id']); + + if (!$product || !$product->getId()) { + return []; + } + + $quote = $this->cart->getQuote(); + $updateRequired = true; + if ($quote->getItemsCount()) { + $items = $quote->getAllVisibleItems(); + foreach ($items as $item) { + if ($item->getProduct()->getId() == $product->getId()) { + $updateRequired = false; + } + } + } + + $params = $this->getCartItems($quote, 'product_page'); + $amount = $params['total']['amount']; + $items = $params['displayItems']; + + if ($updateRequired) { + $shouldInclTax = $this->shouldCartPriceInclTax($quote->getStore()); + $price = $this->getProductDataPrice( + $product, + $product->getFinalPrice(), + $shouldInclTax, + $quote->getCustomerId(), + $quote->getStore()->getStoreId() + ); + + $productTotal = $this->novalnetRequestHelper->getFormattedAmount($price); + $productTotal = ($productTotal) ? $productTotal : 0; + $amount += $productTotal; + + $productLabel = $product->getName(); + $formattedPrice = $this->priceCurrency->format($price, false); + $productLabel .= sprintf(' (%s x %s)', '1', $formattedPrice); + + $items[] = [ + 'label' => $productLabel, + 'type' => 'SUBTOTAL', + 'amount' => (string) $productTotal + ]; + } + + $result = [ + 'total' => [ + 'amount' => (string) $amount + ], + 'displayItems' => $items, + 'isEnabled' => $params['isEnabled'], + 'is_pending' => $params['is_pending'], + 'sheetConfig' => $params['sheetConfig'], + 'isVirtual' => ($quote->getItemsCount()) ? $quote->getIsVirtual() : null + ]; + + return $this->jsonHelper->jsonEncode($result); + } + + /** + * Add to Cart + * + * @api + * @param string $data + * @return string + */ + public function addToCart($data) + { + try { + $this->zendUri->setQuery($data); + $productInfo = $this->zendUri->getQueryAsArray(); + $productId = $productInfo['product']; + $relatedProduct = $productInfo['related_product']; + + if (isset($productInfo['qty'])) { + $filter = new \Magento\Framework\Filter\LocalizedToNormalized( + ['locale' => $this->novalnetRequestHelper->getDefaultLanguage()] + ); + $productInfo['qty'] = $filter->filter($productInfo['qty']); + } + + $quote = $this->cart->getQuote(); + + $storeId = $this->storeManager->getStore()->getId(); + $product = $this->productRepository->getById($productId, false, $storeId); + $isNewItem = true; + + foreach ($quote->getAllItems() as $item) { + if ($item->getProductId() == $productId) { + // update existing item in cart + $item = $this->cart->updateItem($item->getId(), $productInfo); + if ($item->getHasError()) { + throw new LocalizedException(__($item->getMessage())); + } + + $isNewItem = false; + break; + } + } + + if ($isNewItem) { + // add new item to cart + $item = $this->cart->addProduct($product, $productInfo); + if ($item->getHasError()) { + throw new LocalizedException(__($item->getMessage())); + } + + if (!empty($relatedProduct)) { + $this->cart->addProductsByIds(explode(',', $relatedProduct)); + } + } + + $this->cart->save(); + $quote->setTotalsCollectedFlag(false)->collectTotals()->save(); + + return $this->jsonHelper->jsonEncode([]); + + } catch (\Exception $e) { + throw new CouldNotSaveException(__($e->getMessage()), $e); + } + } + + /** + * Estimate Shipping by Address + * + * @api + * @param string[] $address + * @return string + */ + public function estimateShippingMethod($address) + { + try { + $quote = $this->cart->getQuote(); + $needConversion = ($this->storeManager->getStore()->getCurrentCurrencyCode() == $this->storeManager->getStore()->getBaseCurrencyCode()) ? false : true; + $methods = []; + + if (!$quote->isVirtual()) { + $shippingAddress = $quote->getShippingAddress() + ->addData($this->getFormattedAddress($address)) + ->save(); + + $estimatedAddress = $this->estimatedAddressFactory->create() + ->setCountryId($shippingAddress->getCountryId()) + ->setPostcode($shippingAddress->getPostcode()) + ->setRegion((string) $shippingAddress->getRegion()) + ->setRegionId($shippingAddress->getRegionId()); + + $availableShippingMethods = $this->shippingMethodManager->estimateByAddress($quote->getId(), $estimatedAddress); + $shouldInclTax = $this->shouldCartPriceInclTax($quote->getStore()); + + if ($availableShippingMethods) { + foreach ($availableShippingMethods as $rate) { + if ($rate->getErrorMessage()) { + continue; + } + + $methodRate = $shouldInclTax ? $rate->getPriceInclTax() : $rate->getPriceExclTax(); + $methodRate = ($methodRate && $needConversion) ? $methodRate / $quote->getBaseToQuoteRate() : $methodRate; + array_push($methods, [ + 'label' => $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(), + 'amount' => (string) ($methodRate > 0) ? $this->novalnetRequestHelper->getFormattedAmount($methodRate) : $methodRate, + 'identifier' => $rate->getCarrierCode() . '_' . $rate->getMethodCode() + ]); + } + } + + if ($methods) { + $shippingAddress->setShippingMethod($methods[0]['identifier'])->setCollectShippingRates(true); + } + } + + $quote->collectTotals(); + $result = $this->getCartItems($quote); + $result['methods'] = $methods; + return $this->jsonHelper->jsonEncode($result); + } catch (\Exception $e) { + throw new CouldNotSaveException(__($e->getMessage()), $e); + } + } + + /** + * Apply shipping method and calculate totals + * + * @api + * @param string[] $shippingMethod + * @return string + */ + public function applyShippingMethod($shippingMethod) + { + $quote = $this->cart->getQuote(); + try { + if (!$quote->isVirtual()) { + $shippingAddress = $quote->getShippingAddress(); + $quote->setShippingAddress($shippingAddress); + $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod($shippingMethod['identifier']); + $quote->setTotalsCollectedFlag(false)->collectTotals()->save(); + } + + return $this->jsonHelper->jsonEncode( + $this->getCartItems($quote) + ); + } catch (\Exception $e) { + throw new CouldNotSaveException(__($e->getMessage()), $e); + } + } + + /** + * Get Cart items + * + * @param \Magento\Quote\Model\Quote $quote + * @param string $page + * @return array + */ + public function getCartItems($quote, $page = 'mini_cart_page') + { + $currency = $quote->getBaseCurrencyCode(); + if (empty($currency)) { + $currency = $quote->getStore()->getBaseCurrencyCode(); + } + $discount = $quote->getBaseSubtotal() - $quote->getBaseSubtotalWithDiscount(); + $needConversion = ($this->storeManager->getStore()->getCurrentCurrencyCode() == $this->storeManager->getStore()->getBaseCurrencyCode()) ? false : true; + $taxAmount = $quote->getTotals()['tax']->getValue(); + $shouldInclTax = $this->shouldCartPriceInclTax($quote->getStore()); + $displayItems = []; + $items = $quote->getAllVisibleItems(); + $getQuoteFormat = $quote->getIsVirtual(); + foreach ($items as $item) { + + if ($item->getParentItem()) { + continue; + } + + $rowTotal = $shouldInclTax ? $item->getBaseRowTotalInclTax() : $item->getBaseRowTotal(); + $rowTotal = $this->novalnetRequestHelper->getFormattedAmount($rowTotal); + $rowTotal = ($rowTotal) ? $rowTotal : 0; + + $price = $shouldInclTax ? $item->getBasePriceInclTax() : $item->getBasePrice(); + + $label = $item->getName(); + if ($item->getQty() > 0) { + $formattedPrice = $this->priceCurrency->format($price, false, PriceCurrencyInterface::DEFAULT_PRECISION, null, $currency); + $label .= sprintf(' (%s x %s)', $item->getQty(), $formattedPrice); + } + + $displayItems[] = [ + 'label' => $label, + 'type' => 'SUBTOTAL', + 'amount' => (string) $rowTotal + ]; + } + + if ($discount) { + $displayItems[] = [ + 'label' => __('Discount'), + 'type' => 'SUBTOTAL', + 'amount' => (string) '-' . $this->novalnetRequestHelper->getFormattedAmount($discount) + ]; + } + + if ($taxAmount) { + $taxAmount = $needConversion ? $this->deltaRounding($taxAmount / $quote->getBaseToQuoteRate()) : $taxAmount; + $displayItems[] = [ + 'label' => __('Tax'), + 'type' => 'SUBTOTAL', + 'amount' => (string) $this->novalnetRequestHelper->getFormattedAmount($taxAmount) + ]; + } + + if ($quote->getItemsCount() && !$quote->getIsVirtual()) { + $shippingAmount = $quote->getShippingAmount(); + if ($shippingAmount && $needConversion) { + $shippingAmount = $shippingAmount / $quote->getBaseToQuoteRate(); + } + + if ($shippingAmount !== null) { + $displayItems[] = [ + 'label' => (!empty($quote->getShippingDescription())) ? $quote->getShippingDescription() : __('Shipping'), + 'type' => 'SUBTOTAL', + 'amount' => (string) ($shippingAmount > 0) ? $this->novalnetRequestHelper->getFormattedAmount($shippingAmount) : $shippingAmount + ]; + } + } + + $baseGrandTotal = $this->novalnetRequestHelper->getFormattedAmount($quote->getBaseGrandTotal()); + $baseGrandTotal = ($baseGrandTotal) ? $baseGrandTotal : 0; + return [ + 'currency' => (!empty($currency)) ? strtoupper($currency) : '', + 'total' => [ + 'amount' => (string) $baseGrandTotal + ], + 'displayItems' => $displayItems, + 'isVirtual' => $getQuoteFormat, + 'isEnabled' => $this->novalnetRequestHelper->isPageEnabledForExpressCheckout($page), + 'is_pending' => $this->novalnetRequestHelper->isAmountPendingForExpressCheckout(), + 'sheetConfig' => $this->novalnetRequestHelper->paymentSheetConfigurations() + ]; + } + + /** + * Place Order + * + * @api + * @param string[] $paymentData + * @param string[] $billingAddress + * @param string[] $shippingAddress + * @param string[] $shippingMethod + * @param bool $isPaymentPage + * @return string + */ + public function placeOrder($paymentData, $billingAddress, $shippingAddress = [], $shippingMethod = [], $isPaymentPage = false) + { + try { + $quote = $this->cart->getQuote(); + $quote->reserveOrderId()->save(); + $walletToken = $paymentData['token']; + $paymentMethodCode = $paymentData['methodCode']; + + if (empty($billingAddress['email']) && !empty($shippingAddress['email'])) { + $billingAddress['email'] = $shippingAddress['email']; + } + + if (empty($billingAddress['phoneNumber']) && !empty($shippingAddress['phoneNumber'])) { + $billingAddress['phoneNumber'] = $shippingAddress['phoneNumber']; + } + + // set billing address + $quote->getBillingAddress()->addData($this->getFormattedAddress($billingAddress)); + + if (!$isPaymentPage && !$quote->isVirtual()) { + + if (empty($shippingAddress['email']) && !empty($billingAddress['email'])) { + $shippingAddress['email'] = $billingAddress['email']; + } + + if (empty($shippingAddress['phoneNumber']) && !empty($billingAddress['phoneNumber'])) { + $shippingAddress['phoneNumber'] = $billingAddress['phoneNumber']; + } + + $shippingIdentifier = $shippingMethod['identifier']; + + // set shipping address and shipping method + $quote->getShippingAddress() + ->addData($this->getFormattedAddress($shippingAddress)) + ->setShippingMethod($shippingIdentifier) + ->setCollectShippingRates(true); + } + + $quote->setTotalsCollectedFlag(false)->collectTotals(); + $this->storeManager->setCurrentStore($quote->getStoreId()); + + if (!$this->customerSession->isLoggedIn()) { + $quote->setCheckoutMethod(Onepage::METHOD_GUEST) + ->setCustomerId(null) + ->setCustomerEmail($billingAddress['email']) + ->setCustomerIsGuest(true) + ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); + + //set customer name for guest user (account information) + if ($quote->getCustomerFirstname() === null && $quote->getCustomerLastname() === null) { + $quote->setCustomerFirstname($quote->getBillingAddress()->getFirstname()) + ->setCustomerLastname($quote->getBillingAddress()->getLastname()); + if ($quote->getBillingAddress()->getMiddlename() === null) { + $quote->setCustomerMiddlename($quote->getBillingAddress()->getMiddlename()); + } + } + } else { + $quote->setCheckoutMethod(Onepage::METHOD_CUSTOMER); + } + + $transactionData = [ + 'method' => $paymentMethodCode, + 'additional_data' => [ + $paymentMethodCode . '_wallet_token' => $walletToken + ] + ]; + + if (!empty($paymentData['doRedirect'])) { + $transactionData['additional_data'][$paymentMethodCode . '_do_redirect'] = $paymentData['doRedirect']; + } + + //set payment additional data + $quote->getPayment()->importData($transactionData); + + $quote->collectTotals()->save(); + + $this->eventManager->dispatch( + 'checkout_submit_before', + ['quote' => $quote] + ); + + //submit current quote to place order + $order = $this->quoteManagement->submit($quote); + + $payment = $order->getPayment(); + $additionalData = (!empty($payment->getAdditionalData())) ? $this->jsonHelper->jsonDecode($payment->getAdditionalData(), true) : []; + + if ($paymentMethodCode == ConfigProvider::NOVALNET_GOOGLEPAY) { + $additionalData['NnGpaysuccesstext'] = " (" . $paymentData['cardBrand'] . " **** ". $paymentData['lastFour'] .")"; + } elseif ($paymentMethodCode == ConfigProvider::NOVALNET_APPLEPAY) { + $additionalData['NnApplepaysuccesstext'] = " (" . $paymentData['cardBrand'] . " **** ". $paymentData['lastFour'] .")"; + } + + $payment->setAdditionalData($this->jsonHelper->jsonEncode($additionalData))->save(); + + if (!$order || !$order->getId()) { + throw new LocalizedException( + __('A server error stopped your order from being placed. Please try to place your order again.') + ); + } else { + $this->eventManager->dispatch( + 'checkout_type_onepage_save_order_after', + ['order' => $order, 'quote' => $quote] + ); + + $this->checkoutSession->setLastQuoteId($quote->getId()) + ->setLastSuccessQuoteId($quote->getId()) + ->setLastOrderId($order->getId()) + ->setLastRealOrderId($order->getIncrementId()) + ->setLastOrderStatus($order->getStatus()); + } + + $this->eventManager->dispatch( + 'checkout_submit_all_after', + [ + 'order' => $order, + 'quote' => $quote + ] + ); + + $redirectURL = $this->urlInterface->getUrl('checkout/onepage/success'); + if (!empty($additionalData['NnRedirectURL'])) { + $order->setState(Order::STATE_PENDING_PAYMENT) + ->setStatus(Order::STATE_PENDING_PAYMENT) + ->save(); + $order->addStatusHistoryComment(__('Customer was redirected to Novalnet')) + ->save(); + + $this->novalnetLogger->notice('Order status and comments updated successfully'); + $redirectURL = $additionalData['NnRedirectURL']; + } + + return $this->jsonHelper->jsonEncode([ + 'redirectUrl' => $redirectURL + ]); + + } catch (\Exception $e) { + throw new CouldNotSaveException(__($e->getMessage()), $e); + } + } + + /** + * Format Tax Amount to Magento Rounding + * + * @param float $amount + * @return double + */ + public function deltaRounding($amount) + { + $temp = 0; + $deltaValue = 0.000001; + $sum = $amount + $deltaValue; + $rounded = $this->priceCurrency->round($sum, 2); + $temp = $rounded - $sum; + + return $this->priceCurrency->round($amount - $temp, 2); + } + + /** + * Get Quote + * + * @return \Magento\Quote\Model\Quote + */ + public function getQuote() + { + $quote = $this->checkoutHelper->getCheckout()->getQuote(); + if (!$quote->getId()) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $quote = $objectManager->create(\Magento\Checkout\Model\Session::class)->getQuote(); + } + + return $quote; + } + + /** + * Should Cart Price Include Tax + * + * @param null|int|string|Store $store + * @return bool + */ + public function shouldCartPriceInclTax($store = null) + { + if ($this->taxHelper->displayCartBothPrices($store)) { + return true; + } elseif ($this->taxHelper->displayCartPriceInclTax($store)) { + return true; + } + + return false; + } + + /** + * Get Formatted shipping Address + * + * @param array $info + * @return array + */ + public function getFormattedAddress($info) + { + $regionName = (!empty($info['administrativeArea'])) ? $info['administrativeArea'] : $info['locality']; + $countryName = (!empty($info['countryCode'])) ? $info['countryCode'] : ''; + $regionId = $this->getRegionIdByName($regionName, $countryName); + + return [ + 'firstname' => !empty($info['firstName']) ? $info['firstName'] : '', + 'lastname' => !empty($info['lastName']) ? $info['lastName'] : '', + 'company' => '', + 'email' => !empty($info['email']) ? $info['email'] : '', + 'street' => !empty($info['addressLines']) ? $info['addressLines'] : 'Unspecified Street', + 'city' => !empty($info['locality']) ? $info['locality'] : '', + 'region_id' => $regionId, + 'region' => $regionName, + 'postcode' => !empty($info['postalCode']) ? $info['postalCode'] : '', + 'country_id' => $countryName, + 'telephone' => !empty($info['phoneNumber']) ? $info['phoneNumber'] : 'Unspecified Telephone', + 'fax' => '' + ]; + } + + /** + * Get regions from country code + * + * @param mixed $countryCode + * @return mixed + */ + public function getRegionsForCountry($countryCode) + { + $values = []; + + $country = $this->countryFactory->create()->loadByCode($countryCode); + + if (empty($country)) { + return $values; + } + + $regions = $country->getRegions(); + + foreach ($regions as $region) { + if ($region) { + $values['byCode'][strtolower(trim($region->getCode()))] = $region->getId(); + $values['byName'][strtolower(trim($region->getName()))] = $region->getId(); + } + } + + return $values; + } + + /** + * Get Region id with region name + * + * @param mixed $regionName + * @param mixed $regionCountry + * @return string + */ + public function getRegionIdByName($regionName, $regionCountry) + { + $regions = $this->getRegionsForCountry($regionCountry); + + $regionName = (!empty($regionName)) ? strtolower(trim($regionName)) : ''; + + if (isset($regions['byName'][$regionName])) { + return $regions['byName'][$regionName]; + } elseif (isset($regions['byCode'][$regionName])) { + return $regions['byCode'][$regionName]; + } + + return ''; + } + + /** + * Load product model with product id + * + * @param mixed $productId + * @return mixed + */ + public function loadProductById($productId) + { + $model = $this->productFactory->create(); + return $model->load($productId); + } + + /** + * Get Product Price with(without) Taxes + * + * @param \Magento\Catalog\Model\Product $product + * @param float|null $price + * @param bool $inclTax + * @param int|null $customerId + * @param int|null $storeId + * + * @return float + */ + public function getProductDataPrice($product, $price = null, $inclTax = false, $customerId = null, $storeId = null) + { + if (!($taxAttribute = $product->getCustomAttribute('tax_class_id'))) { + return $price; + } + + if (!$price) { + $price = $product->getPrice(); + } + + $productRateId = $taxAttribute->getValue(); + $rate = $this->taxCalculation->getCalculatedRate($productRateId, $customerId, $storeId); + if ((int) $this->scopeConfig->getValue( + 'tax/calculation/price_includes_tax', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ) === 1 + ) { + $priceExclTax = $price / (1 + ($rate / 100)); + } else { + $priceExclTax = $price; + } + + $priceInclTax = $priceExclTax + ($priceExclTax * ($rate / 100)); + $productPrice = $inclTax ? $priceInclTax : $priceExclTax; + + return $this->priceCurrency->round($productPrice, PriceCurrencyInterface::DEFAULT_PRECISION); + } +} diff --git a/Model/ResourceModel/Callback.php b/Model/ResourceModel/Callback.php new file mode 100755 index 0000000..941c713 --- /dev/null +++ b/Model/ResourceModel/Callback.php @@ -0,0 +1,36 @@ +_init('novalnet_payment_callback', 'id'); + } +} diff --git a/Model/ResourceModel/Callback/Collection.php b/Model/ResourceModel/Callback/Collection.php new file mode 100755 index 0000000..a455c01 --- /dev/null +++ b/Model/ResourceModel/Callback/Collection.php @@ -0,0 +1,36 @@ +_init( + \Novalnet\Payment\Model\Callback::class, + \Novalnet\Payment\Model\ResourceModel\Callback::class + ); + } +} diff --git a/Model/ResourceModel/TransactionStatus.php b/Model/ResourceModel/TransactionStatus.php new file mode 100755 index 0000000..5b3d411 --- /dev/null +++ b/Model/ResourceModel/TransactionStatus.php @@ -0,0 +1,36 @@ +_init('novalnet_payment_transactionstatus', 'id'); + } +} diff --git a/Model/ResourceModel/TransactionStatus/Collection.php b/Model/ResourceModel/TransactionStatus/Collection.php new file mode 100755 index 0000000..cfea3d3 --- /dev/null +++ b/Model/ResourceModel/TransactionStatus/Collection.php @@ -0,0 +1,36 @@ +_init( + \Novalnet\Payment\Model\TransactionStatus::class, + \Novalnet\Payment\Model\ResourceModel\TransactionStatus::class + ); + } +} diff --git a/Model/TransactionStatus.php b/Model/TransactionStatus.php new file mode 100755 index 0000000..3c81ba7 --- /dev/null +++ b/Model/TransactionStatus.php @@ -0,0 +1,67 @@ +_init(\Novalnet\Payment\Model\ResourceModel\TransactionStatus::class); + } + + /** + * Load order transaction status by custom attribute value. Attribute value should be unique + * + * @param int $value + * @param string $attribute + * @return mixed + */ + public function loadByAttribute($value, $attribute) + { + $this->load($value, $attribute); + return $this; + } +} diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php new file mode 100755 index 0000000..bfb393e --- /dev/null +++ b/Model/Ui/ConfigProvider.php @@ -0,0 +1,571 @@ +filesystem = $filesystem; + $this->request = $request; + $this->checkoutSession = $checkoutSession; + $this->assetRepo = $assetRepo; + $this->storeManager = $storeManager; + $this->serverAddress = $serverAddress; + $this->transactionStatusModel = $transactionStatusModel; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->novalnetConfig = $novalnetConfig; + $this->jsonHelper = $jsonHelper; + $this->serializer = $serializer; + } + + /** + * Retrieve assoc array of checkout configuration + * + * @return array + */ + public function getConfig() + { + $novalnetCcStyles = $this->getCcStyleConfig(); + + return [ + 'payment' => [ + self::NOVALNET_CC => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_CC), + 'icon' => $this->getCcAvailableTypes(self::NOVALNET_CC), + 'cardLogoUrl' => $this->getCardLogoUrl(), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_CC), + 'storePayment' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'shop_type'), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'instructions'), + 'storedPayments' => $this->getOneClickToken(self::NOVALNET_CC), + 'tokenId' => $this->getOneClickToken(self::NOVALNET_CC, true), + 'iframeParams' => $this->getCcIframeParams(), + 'inlineForm' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'inline_form'), + 'enforce_3d' => ($this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'enforce_3d')) ? $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'enforce_3d') : 0, + 'labelStyle' => isset($novalnetCcStyles['standard_style_label']) ? $novalnetCcStyles['standard_style_label'] : '', + 'inputStyle' => isset($novalnetCcStyles['standard_style_input']) ? $novalnetCcStyles['standard_style_input'] : '', + 'styleText' => isset($novalnetCcStyles['standard_style_css']) ? $novalnetCcStyles['standard_style_css'] : '', + 'currencyCode' => $this->storeManager->getStore()->getBaseCurrencyCode(), + 'isZeroAmountBooking' => ($this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING) ? true : false + ], + self::NOVALNET_APPLEPAY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_APPLEPAY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_APPLEPAY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'instructions'), + 'sellerName' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'seller_name'), + 'btnType' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'button_style'), + 'btnTheme' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'button_theme'), + 'btnHeight' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'button_height'), + 'btnRadius' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_APPLEPAY, 'button_corner_radius'), + 'langCode' => $this->novalnetRequestHelper->getLanguageCodeForPaymentSheet(), + 'countryCode' => $this->novalnetRequestHelper->getCountryCode(), + 'currencyCode' => $this->storeManager->getStore()->getBaseCurrencyCode(), + 'clientKey' => $this->novalnetConfig->getGlobalConfig('client_key'), + 'is_pending' => $this->novalnetRequestHelper->isAmountPendingForExpressCheckout(), + 'guest_page' => $this->novalnetRequestHelper->isPageEnabledForExpressCheckout('guest_checkout_page') + ], + self::NOVALNET_GOOGLEPAY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_GOOGLEPAY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_GOOGLEPAY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'instructions'), + 'is_pending' => $this->novalnetRequestHelper->isAmountPendingForExpressCheckout(), + 'guest_page' => $this->novalnetRequestHelper->isPageEnabledForExpressCheckout('guest_checkout_page'), + 'sellerName' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'seller_name'), + 'btnType' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'button_type'), + 'btnTheme' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'button_theme'), + 'btnHeight' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'button_height'), + 'btnRadius' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'button_corner_radius'), + 'langCode' => $this->novalnetRequestHelper->getLanguageCodeForPaymentSheet(), + 'countryCode' => $this->novalnetRequestHelper->getCountryCode(), + 'currencyCode' => $this->storeManager->getStore()->getBaseCurrencyCode(), + 'clientKey' => $this->novalnetConfig->getGlobalConfig('client_key'), + 'partnerId' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'merchant_id'), + 'enforce3d' => ($this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'enforce_3d')) ? $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GOOGLEPAY, 'enforce_3d') : 0 + ], + self::NOVALNET_SEPA => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_SEPA), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_SEPA), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_SEPA, 'instructions'), + 'storePayment' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_SEPA, 'shop_type'), + 'storedPayments' => $this->getOneClickToken(self::NOVALNET_SEPA), + 'tokenId' => $this->getOneClickToken(self::NOVALNET_SEPA, true), + 'isZeroAmountBooking' => ($this->novalnetConfig->getPaymentConfig(self::NOVALNET_SEPA, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING) ? true : false + ], + self::NOVALNET_INVOICE => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_INVOICE), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_INVOICE), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_INVOICE, 'instructions') + ], + self::NOVALNET_PREPAYMENT => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_PREPAYMENT), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_PREPAYMENT), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_PREPAYMENT, 'instructions'), + ], + self::NOVALNET_INVOICE_GUARANTEE => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_INVOICE_GUARANTEE), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_INVOICE_GUARANTEE), + 'allow_b2b_customer' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_GUARANTEE, + 'allow_b2b_customer' + ), + 'payment_guarantee_force' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_GUARANTEE, + 'payment_guarantee_force' + ), + 'instructions' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_GUARANTEE, + 'instructions' + ), + ], + self::NOVALNET_SEPA_GUARANTEE => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_SEPA_GUARANTEE), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_SEPA_GUARANTEE), + 'allow_b2b_customer' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_GUARANTEE, + 'allow_b2b_customer' + ), + 'payment_guarantee_force' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_GUARANTEE, + 'payment_guarantee_force' + ), + 'instructions' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_GUARANTEE, + 'instructions' + ), + 'storePayment' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_SEPA_GUARANTEE, 'shop_type'), + 'storedPayments' => $this->getOneClickToken(self::NOVALNET_SEPA_GUARANTEE), + 'tokenId' => $this->getOneClickToken(self::NOVALNET_SEPA_GUARANTEE, true) + ], + self::NOVALNET_CASHPAYMENT => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_CASHPAYMENT), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_CASHPAYMENT), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CASHPAYMENT, 'instructions'), + ], + self::NOVALNET_MULTIBANCO => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_MULTIBANCO), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_MULTIBANCO), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_MULTIBANCO, 'instructions'), + ], + self::NOVALNET_PAYPAL => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_PAYPAL), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_PAYPAL), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_PAYPAL, 'instructions'), + 'storePayment' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_PAYPAL, 'shop_type'), + 'storedPayments' => $this->getOneClickToken(self::NOVALNET_PAYPAL), + 'tokenId' => $this->getOneClickToken(self::NOVALNET_PAYPAL, true) + ], + self::NOVALNET_BANKTRANSFER => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_BANKTRANSFER), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_BANKTRANSFER), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_BANKTRANSFER, 'instructions'), + ], + self::NOVALNET_ONLINEBANKTRANSFER => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_ONLINEBANKTRANSFER), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_ONLINEBANKTRANSFER), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_ONLINEBANKTRANSFER, 'instructions'), + ], + self::NOVALNET_ALIPAY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_ALIPAY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_ALIPAY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_ALIPAY, 'instructions'), + ], + self::NOVALNET_TRUSTLY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_TRUSTLY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_TRUSTLY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_TRUSTLY, 'instructions'), + ], + self::NOVALNET_WECHATPAY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_WECHATPAY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_WECHATPAY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_WECHATPAY, 'instructions'), + ], + self::NOVALNET_IDEAL => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_IDEAL), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_IDEAL), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_IDEAL, 'instructions'), + ], + self::NOVALNET_BLIK => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_BLIK), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_BLIK), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_BLIK, 'instructions') + ], + self::NOVALNET_BANCONTACT => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_BANCONTACT), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_BANCONTACT), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_BANCONTACT, 'instructions'), + ], + self::NOVALNET_EPS => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_EPS), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_EPS), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_EPS, 'instructions'), + ], + self::NOVALNET_GIROPAY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_GIROPAY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_GIROPAY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_GIROPAY, 'instructions'), + ], + self::NOVALNET_PRZELEWY => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_PRZELEWY), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_PRZELEWY), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_PRZELEWY, 'instructions'), + ], + self::NOVALNET_POSTFINANCE => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_POSTFINANCE), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_POSTFINANCE), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_POSTFINANCE, 'instructions'), + ], + self::NOVALNET_POSTFINANCE_CARD => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_POSTFINANCE_CARD), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_POSTFINANCE_CARD), + 'instructions' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_POSTFINANCE_CARD, 'instructions'), + ], + self::NOVALNET_INVOICE_INSTALMENT => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_INVOICE_INSTALMENT), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_INVOICE_INSTALMENT), + 'allow_b2b_customer' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_INSTALMENT, + 'allow_b2b_customer' + ), + 'instructions' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_INSTALMENT, + 'instructions' + ), + 'instalmentCycles' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_INVOICE_INSTALMENT, + 'instalment_cycles' + ) + ], + self::NOVALNET_SEPA_INSTALMENT => [ + 'logo' => $this->getPaymentLogo(self::NOVALNET_SEPA_INSTALMENT), + 'testmode' => $this->novalnetConfig->getTestMode(self::NOVALNET_SEPA_INSTALMENT), + 'allow_b2b_customer' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_INSTALMENT, + 'allow_b2b_customer' + ), + 'instructions' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_INSTALMENT, + 'instructions' + ), + 'instalmentCycles' => $this->novalnetConfig->getPaymentConfig( + self::NOVALNET_SEPA_INSTALMENT, + 'instalment_cycles' + ), + 'storePayment' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_SEPA_INSTALMENT, 'shop_type'), + 'storedPayments' => $this->getOneClickToken(self::NOVALNET_SEPA_INSTALMENT), + 'tokenId' => $this->getOneClickToken(self::NOVALNET_SEPA_INSTALMENT, true) + ], + ] + ]; + } + + /** + * Retrieve Credit Card iframe params + * + * @return array + */ + public function getCcIframeParams() + { + return [ + 'client_key' => $this->novalnetConfig->getGlobalConfig('client_key'), + 'lang' => $this->novalnetRequestHelper->getDefaultLanguage(), + 'cardHolderName' => $this->novalnetRequestHelper->getAccountHolder() + ]; + } + + /** + * Retrieve Credit Card style configuration + * + * @return array + */ + public function getCcStyleConfig() + { + $ccStyleConfig = $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'cc_style'); + if (!empty($ccStyleConfig)) { + return $this->novalnetRequestHelper->isSerialized($ccStyleConfig) + ? $this->serializer->unserialize($ccStyleConfig) + : json_decode($ccStyleConfig, true); + } + + return []; + } + + /** + * Retrieve availables Credit Card types + * + * @param string $code + * @return array|bool + */ + public function getCcAvailableTypes($code) + { + $availableTypes = $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'cc_types'); + $icons = []; + $ccIcons = []; + + if ($availableTypes && $this->novalnetConfig->getGlobalConfig('enable_payment_logo')) { + foreach ($this->getCreditcardAssetUrl($code, $availableTypes) as $icon) { + $icons = [ + 'src' => $icon, + 'title' => $this->novalnetConfig->getPaymentConfig(self::NOVALNET_CC, 'title') + ]; + $ccIcons[] = $icons; + } + + return $ccIcons; + } + + return false; + } + + /** + * Loads the Credit card images source asset path + * + * @param string $code + * @param string $availableTypes + * @return string|array + */ + public function getCreditcardAssetUrl($code, $availableTypes) + { + $cardTypes = ['VI' => 'novalnetvisa', 'MC' => 'novalnetmastercard', + 'AE' => 'novalnetamex', 'MA' => 'novalnetmaestro', 'CI' => 'novalnetcartasi', 'UP' => 'novalnetunionpay', + 'DC' => 'novalnetdiscover', 'DI' => 'novalnetdiners', 'JCB' => 'novalnetjcb', 'CB' => 'novalnetcartebleue']; + $asset = []; + $assetUrl = []; + $params = ['_secure' => $this->request->isSecure()]; + if ($availableTypes) { + $availableTypes = (!empty($availableTypes)) ? explode(',', $availableTypes) : []; + foreach ($cardTypes as $code => $value) { + if (in_array($code, $availableTypes)) { + $asset[$code] = $this->assetRepo->createAsset( + 'Novalnet_Payment::images/'. ($value) .'.png', + $params + ); + $assetUrl[] = $asset[$code]->getUrl(); + } + } + } + + return $assetUrl; + } + + /** + * Retrieve one click tokens + * + * @param string $paymentMethodCode + * @param string|bool $token + * @return array + */ + public function getOneClickToken($paymentMethodCode, $token = false) + { + $data = []; + $tokenId = 'new_account'; + $customerSession = $this->novalnetRequestHelper->getCustomerSession(); + if ($customerSession->isLoggedIn() && $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'shop_type')) { + if (strpos($paymentMethodCode, self::NOVALNET_SEPA) !== false) { + $paymentMethodCode = self::NOVALNET_SEPA; + } + $transactionStatusCollection = $this->transactionStatusModel->getCollection() + ->setOrder('order_id', 'DESC') + ->setPageSize(3) + ->addFieldToFilter('token_info', ['neq' => 'NULL']) + ->addFieldToFilter('customer_id', $customerSession->getCustomer()->getId()) + ->addFieldToFilter('payment_method', ['like' => $paymentMethodCode . '%']); + + foreach ($transactionStatusCollection as $key => $transactionStatus) { + if ($transactionStatus->getTokenInfo() && !empty(json_decode($transactionStatus->getTokenInfo(), true))) { + $text = ""; + if ($paymentMethodCode == self::NOVALNET_CC) { + $tokenInfo = json_decode($transactionStatus->getTokenInfo(), true); + if (empty($tokenInfo['NnCardNumber']) || empty($tokenInfo['NnCardExpiryMonth']) || empty($tokenInfo['NnCardExpiryYear'])) { + continue; + } + + $text = __( + "ending in %1 (expires %2/%3)", + substr($tokenInfo['NnCardNumber'], -4), + sprintf("%02d", $tokenInfo['NnCardExpiryMonth']), + substr($tokenInfo['NnCardExpiryYear'], 2) + ); + } + + if ($tokenId == 'new_account') { + $tokenId = $transactionStatus->getToken(); + } + + $data[] = [ + 'id' => $transactionStatus->getId(), + 'NnToken' => $transactionStatus->getToken(), + 'token_info' => json_decode($transactionStatus->getTokenInfo(), true), + 'text' => (!empty($text) ? $text : '') + ]; + + } + } + } + if ($token) { + return $tokenId; + } + return $data; + } + + /** + * Get Payment Logo + * + * @param string $paymentMethodCode + * @return mixed + */ + public function getPaymentLogo($paymentMethodCode) + { + $logoImageSrc = false; + if ($this->novalnetConfig->getGlobalConfig('enable_payment_logo') && !empty($paymentMethodCode)) { + $params = ['_secure' => $this->request->isSecure()]; + $asset = $this->assetRepo->createAsset( + 'Novalnet_Payment::images/'. strtolower($paymentMethodCode) .'.png', + $params + ); + $logoImageSrc = $asset->getUrl(); + } + + return $logoImageSrc; + } + + /** + * Get Payment Logo + * + * @return mixed + */ + public function getCardLogoUrl() + { + $logoImageSrc = false; + $params = ['_secure' => $this->request->isSecure()]; + $asset = $this->assetRepo->createAsset( + 'Novalnet_Payment::images/', + $params + ); + return $asset->getUrl(); + } +} diff --git a/Observer/DataAssignObserver.php b/Observer/DataAssignObserver.php new file mode 100755 index 0000000..8a0ed99 --- /dev/null +++ b/Observer/DataAssignObserver.php @@ -0,0 +1,406 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->datetime = $datetime; + $this->novalnetConfig = $novalnetConfig; + $this->backendQuoteSession = $backendQuoteSession; + $this->cart = $cart; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Get Quote + * + * @return object $quote + */ + public function getCartQuote() + { + $quote = (!$this->novalnetRequestHelper->isAdmin()) + ? $this->cart->getQuote() + : $this->backendQuoteSession->getQuote(); + return $quote; + } + + /** + * Execute + * + * @param Observer $observer + * @return void + */ + public function execute(Observer $observer) + { + $method = $this->readMethodArgument($observer); + $paymentMethodCode = $method->getCode(); + $this->novalnetRequestHelper->getMethodSession($paymentMethodCode, true); + + $parameters = [ + '_pan_hash', '_unique_id', '_do_redirect', '_iban', '_create_token', '_token', '_cycle', '_dob', '_wallet_token', '_bic' + ]; + $this->setMethodSession($observer, $paymentMethodCode, $parameters); + } + + /** + * Set method session + * + * @param \Magento\Framework\Event\Observer $observer + * @param string $paymentMethodCode + * @param array $parameters + * @return void + */ + private function setMethodSession($observer, $paymentMethodCode, $parameters) + { + $additionalData = $this->readDataArgument($observer)->getAdditionalData(); + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + $this->validateGuaranteePayment($paymentMethodCode); + $this->validateBillingShippingAddress($paymentMethodCode); + + foreach ($parameters as $parameter) { + if (!empty($additionalData[$paymentMethodCode . $parameter])) { + $methodSession->setData( + $paymentMethodCode . $parameter, + $additionalData[$paymentMethodCode . $parameter] + ); + } + } + + $forcedPayment = ''; + $birthDate = !empty($additionalData[$paymentMethodCode . '_dob']) ? $additionalData[$paymentMethodCode . '_dob'] : ''; + + if (!empty($paymentMethodCode) && preg_match('/(.*)Guarantee/', $paymentMethodCode, $reassignedPaymentMethodCode)) { + $forcedPayment = $reassignedPaymentMethodCode[1]; + } + + // validate DOB and address - if failed proceed as force (non gurantee payment) + if (in_array($paymentMethodCode, [ + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE + ]) && + (($birthDate && !$this->validateBirthDate($birthDate)) || !$this->checkBillingShippingAreSame() || !$this->checkGuaranteeConditions($paymentMethodCode) || !$this->validateSubscriptionConditions($paymentMethodCode)) + ) { + if ($this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_guarantee_force') && + $forcedPayment && $this->novalnetConfig->getPaymentConfig($forcedPayment, 'active') + ) { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + $forcedPaymentSession = $this->novalnetRequestHelper->getMethodSession($forcedPayment); + + if ($forcedPayment == ConfigProvider::NOVALNET_SEPA) { + $forcedPaymentSession->setData($forcedPayment.'_iban', $methodSession->getData($paymentMethodCode.'_iban')); + $forcedPaymentSession->setData($forcedPayment.'_bic', $methodSession->getData($paymentMethodCode.'_bic')); + } + + $forcedPaymentSession->setData($forcedPayment.'_token', $methodSession->getData($paymentMethodCode.'_token')); + $forcedPaymentSession->setData($forcedPayment.'_create_token', $methodSession->getData($paymentMethodCode.'_create_token')); + $forcedPaymentSession->setData($forcedPayment.'_dob', $methodSession->getData($paymentMethodCode.'_dob')); + $quote = $this->getCartQuote(); + $quote->getPayment()->setMethod($forcedPayment); + + if ($this->novalnetRequestHelper->isAdmin()) { + $methodSession->setData($paymentMethodCode.'_force', 1); + $methodSession->setData($paymentMethodCode.'_force_payment', $forcedPayment); + } + + $this->novalnetLogger->notice("Update payment method from $paymentMethodCode to $forcedPayment"); + } else { + throw new \Magento\Framework\Exception\LocalizedException(__('You need to be at least 18 years old')); + } + } + } + + /** + * To check billing and shipping address are same + * + * @return boolean + */ + public function checkBillingShippingAreSame() + { + $quote = $this->getCartQuote(); + if ($quote->getIsVirtual()) { + return true; + } + + $billingAddress = $quote->getBillingAddress(); + $shipingAddress = $quote->getShippingAddress(); + $billingStreet = $this->getStreet($billingAddress); + $shipingStreet = $this->getStreet($shipingAddress); + + if ($billingStreet == $shipingStreet && + $billingAddress->getCity() == $shipingAddress->getCity() && + $billingAddress->getCountryId() ==$shipingAddress->getCountryId() && + $billingAddress->getPostcode() == $shipingAddress->getPostcode() + ) { + return true; + } + + return false; + } + + /** + * To check guarantee conditions + * + * @param string $paymentMethodCode + * @return bool + */ + public function checkGuaranteeConditions($paymentMethodCode) + { + $quote = $this->getCartQuote(); + $orderAmount = $this->novalnetRequestHelper->getFormattedAmount($quote->getBaseGrandTotal()); + $countryCode = (!empty($quote->getBillingAddress()->getCountryId())) ? strtoupper($quote->getBillingAddress()->getCountryId()) : ''; // Get country code + $b2b = (bool) $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'allow_b2b_customer'); + + if ($quote->getBaseCurrencyCode() != 'EUR') { + return false; + } elseif ($orderAmount < 999) { + return false; + } elseif (!$this->novalnetConfig->isAllowedCountry($countryCode, $b2b)) { + return false; + } + + return true; + } + + /** + * Check customer DOB is valid + * + * @param string $birthDate + * @return boolean + */ + public function validateBirthDate($birthDate) + { + if (empty($birthDate)) { + return true; + } + $age = strtotime('+18 years', strtotime($birthDate)); + $currentDate = $this->datetime->gmtTimestamp(); + return ($currentDate < $age) ? false : true; + } + + /** + * To validate billing and shipping address + * + * @param string $paymentMethodCode + * @return void + */ + public function validateBillingShippingAddress($paymentMethodCode) + { + if (in_array($paymentMethodCode, [ + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ])) { + // throw error on (non forced gurantee || instalment) address check failed + if (!$this->checkBillingShippingAreSame() && + !$this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_guarantee_force') // non force + ) { + $errorPaymentName = in_array( + $paymentMethodCode, + [ConfigProvider::NOVALNET_SEPA_GUARANTEE, ConfigProvider::NOVALNET_INVOICE_GUARANTEE] + ) ? __('payment guarantee') : __('instalment payment'); + + throw new \Magento\Framework\Exception\LocalizedException(__( + "The payment cannot be processed, because the basic requirements for the %1 haven't been met (The shipping address must be the same as the billing address)", + $errorPaymentName + )); + } + } + } + + /** + * Check Allowed Country + * + * @param string $paymentMethodCode + * @return mixed + */ + public function validateGuaranteePayment($paymentMethodCode) + { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $coreSession = $objectManager->create(\Magento\Framework\Session\SessionManagerInterface::class); + + //skip conditions for recurring order + if ($coreSession->getRecurringProcess()) { + return true; + } + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + )) { + $quote = $this->getCartQuote(); + $orderAmount = $this->novalnetRequestHelper->getFormattedAmount($quote->getBaseGrandTotal()); + $countryCode = (!empty($quote->getBillingAddress()->getCountryId())) ? strtoupper($quote->getBillingAddress()->getCountryId()) : ''; // Get country code + $b2b = (bool) $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'allow_b2b_customer'); + $billingAddress = $quote->getBillingAddress(); + $errorPaymentName = in_array( + $paymentMethodCode, + [ConfigProvider::NOVALNET_SEPA_GUARANTEE, ConfigProvider::NOVALNET_INVOICE_GUARANTEE] + ) ? __('payment guarantee') : __('instalment payment'); + $errorText = ''; + if ($quote->getBaseCurrencyCode() != 'EUR') { + $errorText = __('Only EUR currency allowed %1', $errorPaymentName); + } elseif ($orderAmount < 999) { + $errorText = __('Minimum order amount should be %1', $errorPaymentName); + } elseif (!$this->novalnetConfig->isAllowedCountry($countryCode, $b2b)) { + $errorText = __('Only DE, AT, CH countries allowed %1', $errorPaymentName); + } + + if (!empty($errorText) && !$this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_guarantee_force')) { + throw new \Magento\Framework\Exception\LocalizedException(__( + $errorText + )); + } + } + } + + /** + * Validate subscription conditions for Guarantee payments + * + * @param string $paymentMethodCode + * @return bool + */ + public function validateSubscriptionConditions($paymentMethodCode) + { + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE + ] + )) { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $coreSession = $objectManager->create(\Magento\Framework\Session\SessionManagerInterface::class); + + //skip conditions for recurring order + if ($coreSession->getRecurringProcess()) { + return true; + } + + $errorText = ''; + $quote = $this->getCartQuote(); + $subscription = false; + if (!empty($quote->getItems())) { + foreach ($quote->getItems() as $item) { + $additionalData = (!empty($item->getAdditionalData())) ? json_decode($item->getAdditionalData(), true) : []; + if (!empty($additionalData['period_unit']) && !empty($additionalData['billing_frequency'])) { + $subscription = true; + break; + } + } + } + if ($subscription) { + if ($quote->getItemsCount() > 1) { + $errorText = __('Multi cart not supported for this payment'); + } elseif ($quote->getItemsCount() == 1) { + foreach ($quote->getAllItems() as $item) { + $orderAmount = $this->novalnetRequestHelper->getFormattedAmount($item->getBaseRowTotal()); + if ($orderAmount < 999) { + $errorText = __('Minimum order amount should be %1', 'payment guarantee'); + } + } + } + } + + if (!empty($errorText) && $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_guarantee_force')) { + return false; + } if (!empty($errorText)) { + throw new \Magento\Framework\Exception\LocalizedException(__( + $errorText + )); + } + } + + return true; + } + + /** + * Get Street from address + * + * @param object $address + * @return string + */ + public function getStreet($address) + { + if (method_exists($address, 'getStreetFull')) { + $street = $address->getStreetFull(); + } else { + $street = implode(' ', [$address->getStreetLine1(), $address->getStreetLine2()]); + } + + return $street; + } +} diff --git a/Observer/OrderPlacebefore.php b/Observer/OrderPlacebefore.php new file mode 100755 index 0000000..c345b75 --- /dev/null +++ b/Observer/OrderPlacebefore.php @@ -0,0 +1,74 @@ +novalnetRequestHelper = $novalnetRequestHelper; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * Execute + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $paymentMethodCode = $observer->getOrder()->getPayment()->getMethod(); + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_GUARANTEE + ] + ) && $this->novalnetRequestHelper->isAdmin()) { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + $forcedPayment = $methodSession->getData($paymentMethodCode.'_force_payment'); + if ($methodSession->getData($paymentMethodCode.'_force') && $forcedPayment) { + //set payment methode to proceed guarantee force + $observer->getOrder()->getPayment()->setMethod($forcedPayment); + $this->novalnetLogger->notice("Update payment method from $paymentMethodCode to $forcedPayment"); + } + } + } +} diff --git a/Observer/PaymentMethodIsActive.php b/Observer/PaymentMethodIsActive.php new file mode 100755 index 0000000..ed62457 --- /dev/null +++ b/Observer/PaymentMethodIsActive.php @@ -0,0 +1,198 @@ +salesOrderModel = $salesOrderModel; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + } + + /** + * Execute + * + * @param Observer $observer + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function execute(Observer $observer) + { + $event = $observer->getEvent(); + $methodInstance = $event->getData('method_instance'); + $quote = $event->getData('quote'); + $result = $event->getData('result'); + $paymentMethodCode = $methodInstance->getCode(); + + if ($quote && $result->getData('is_available') && strpos($paymentMethodCode, 'novalnet') === 0) { + + $available = $this->novalnetRequestHelper->validateBasicParams() + && $this->validateOrdersCount($paymentMethodCode) + && $this->validateCustomerGroup($paymentMethodCode); + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA_GUARANTEE, + ConfigProvider::NOVALNET_INVOICE_GUARANTEE, + ConfigProvider::NOVALNET_SEPA_INSTALMENT, + ConfigProvider::NOVALNET_INVOICE_INSTALMENT + ] + )) { + $orderAmount = $this->novalnetRequestHelper->getFormattedAmount($quote->getBaseGrandTotal()); + $countryCode = (!empty($quote->getBillingAddress()->getCountryId())) ? strtoupper($quote->getBillingAddress()->getCountryId()) : ''; // Get country code + $b2b = (bool) $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'allow_b2b_customer'); + $force = ""; + + if (in_array( + $paymentMethodCode, + [ConfigProvider::NOVALNET_SEPA_INSTALMENT, ConfigProvider::NOVALNET_INVOICE_INSTALMENT] + )) { + $allcycle = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'instalment_cycles'); + $allcycle = (!empty($allcycle)) ? explode(',', $allcycle) : []; + $orderAmount = isset($allcycle[0]) ? ($orderAmount / $allcycle[0]) : $orderAmount; + } else { + $force = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_guarantee_force'); + } + + if (!$force && ($orderAmount < 999 || $quote->getBaseCurrencyCode() != 'EUR' + || !$this->novalnetConfig->isAllowedCountry($countryCode, $b2b) || + ($this->novalnetRequestHelper->isAdmin() && !$this->checkBillingShippingAreSame($quote))) + ) { + $available = false; + } + } + + if (in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_SEPA, + ConfigProvider::NOVALNET_INVOICE, + ] + )) { + $paymentCode = (!empty($paymentMethodCode) && preg_match('/Sepa/', $paymentMethodCode)) ? ConfigProvider::NOVALNET_SEPA_GUARANTEE : ConfigProvider::NOVALNET_INVOICE_GUARANTEE; + $force = $this->novalnetConfig->getPaymentConfig($paymentCode, 'payment_guarantee_force'); + $active = $this->novalnetConfig->getPaymentConfig($paymentCode, 'active'); + if ($active && !$force) { + $available = false; + } + } + + $result->setData('is_available', $available); + } + } + + /** + * Check orders count by customer id + * + * @param string $paymentMethodCode + * @return bool + */ + public function validateOrdersCount($paymentMethodCode) + { + $minOrderCount = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'orders_count'); + if ($minOrderCount) { + if ($this->novalnetRequestHelper->getCustomerSession()->isLoggedIn()) { + $customerId = $this->novalnetRequestHelper->getCustomerSession()->getCustomer()->getId(); + } elseif ($this->novalnetRequestHelper->isAdmin()) { + $customerId = $this->novalnetRequestHelper->getAdminCheckoutSession()->getCustomerId(); + } else { + return false; + } + + // get orders by customer id + $ordersCount = $this->salesOrderModel->getCollection()->addFieldToFilter('customer_id', $customerId) + ->count(); + return ($ordersCount >= trim($minOrderCount)); + } else { + return true; + } + } + + /** + * Check whether the payment is available for current customer group + * + * @param string $paymentMethodCode + * @return boolean + */ + public function validateCustomerGroup($paymentMethodCode) + { + // Excluded customer groups from payment configuration + $excludedGroups = $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'user_group_excluded'); + if (!$this->novalnetRequestHelper->isAdmin() && !empty($excludedGroups) && strlen($excludedGroups)) { + $excludedGroups = (!empty($excludedGroups)) ? explode(',', $excludedGroups) : []; + $customerGroupId = $this->novalnetRequestHelper->getCustomerSession()->getCustomer()->getGroupId(); + if (!$this->novalnetRequestHelper->getCustomerSession()->isLoggedIn()) { + $customerGroupId = 0; + } + return !in_array($customerGroupId, $excludedGroups); + } + + return true; + } + + /** + * Check billing and shipping address are same for guarantee payments + * + * @param mixed $quote + * @return boolean + */ + public function checkBillingShippingAreSame($quote) + { + $billingAddress = $quote->getBillingAddress(); + $shippingAddress = !$quote->getIsVirtual() ? $quote->getShippingAddress() : ''; + $billingStreet = (!empty($billingAddress->getStreet())) ? implode(',', $billingAddress->getStreet()) : ''; + $shippingStreet = (!empty($shippingAddress->getStreet())) ? implode(',', $shippingAddress->getStreet()) : ''; + return ($shippingAddress == '' || (($billingAddress->getCity() == $shippingAddress->getCity()) + && ($billingStreet == $shippingStreet) + && ($billingAddress->getPostcode() == $shippingAddress->getPostcode()) + && ($billingAddress->getCountry() == $shippingAddress->getCountry())) + ); + } +} diff --git a/Observer/ProcessCaptureAction.php b/Observer/ProcessCaptureAction.php new file mode 100755 index 0000000..35a55cb --- /dev/null +++ b/Observer/ProcessCaptureAction.php @@ -0,0 +1,164 @@ +urlInterface = $urlInterface; + $this->dbTransaction = $dbTransaction; + $this->invoiceSender = $invoiceSender; + $this->logger = $logger; + $this->novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->novalnetLogger = $novalnetLogger; + $this->serializer = $serializer; + } + + /** + * Process capture Action + * + * @param \Magento\Framework\Event\Observer $observer + * @return mixed + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + try { + $invoice = $observer->getEvent()->getInvoice(); + $order = $invoice->getOrder(); + $storeId = $order->getStoreId(); + $paymentMethodCode = $order->getPayment()->getMethod(); + + if (!empty($paymentMethodCode) && preg_match('/novalnet/', $paymentMethodCode)) { + + if ($paymentMethodCode == ConfigProvider::NOVALNET_INVOICE) { + $additionalData = []; + if (!empty($order->getPayment()->getAdditionalData())) { + $additionalData = $this->novalnetRequestHelper->isSerialized($order->getPayment()->getAdditionalData()) + ? $this->serializer->unserialize($order->getPayment()->getAdditionalData()) + : json_decode($order->getPayment()->getAdditionalData(), true); + } + if (!empty($additionalData['NnGuarantee'])) { + $state = \Magento\Sales\Model\Order\Invoice::STATE_PAID; + } else { + $state = \Magento\Sales\Model\Order\Invoice::STATE_OPEN; + } + // set Invoice state as Open + $invoice->setState($state); + } + + $currentUrl = (!empty($this->urlInterface->getCurrentUrl())) ? $this->urlInterface->getCurrentUrl() : ''; + + if ($this->novalnetRequestHelper->isAdmin() && + !preg_match('/sales_order_create/i', $currentUrl) + ) { + $captureOrderStatus = $this->novalnetConfig->getPaymentConfig( + $paymentMethodCode, + 'order_status', + $storeId + ); + // Set capture status for Novalnet payments + $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING) + ->setStatus($captureOrderStatus) + ->save(); + + $order->addStatusHistoryComment(__('The transaction has been confirmed'), false) + ->save(); + } + + if ($this->novalnetRequestHelper->isAdmin() && (preg_match('/order_create/i', $currentUrl) || preg_match('/ordercapture/i', $currentUrl))) { + $this->dbTransaction->create()->addObject($invoice)->addObject($order)->save(); + $shopVersion = (string) $this->novalnetRequestHelper->getMagentoVersion(); + if (version_compare('2.4.0', $shopVersion) == 1) { + $this->invoiceSender->send($invoice); + } + } + } + } catch (\Exception $e) { + $this->logger->critical($e); + $this->novalnetLogger->error($e); + } + + return $this; + } +} diff --git a/Observer/ProcessNovalnetPayment.php b/Observer/ProcessNovalnetPayment.php new file mode 100755 index 0000000..1e0b01c --- /dev/null +++ b/Observer/ProcessNovalnetPayment.php @@ -0,0 +1,160 @@ +novalnetConfig = $novalnetConfig; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->serializer = $serializer; + $this->invoiceService = $invoiceService; + $this->transaction = $transaction; + $this->coreSession = $coreSession; + } + + /** + * If it's redrected to checkout onepage/multishipping success page - do this + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $order = $observer->getEvent()->getOrder(); + if ($order) { + $storeId = $order->getStoreId(); + $paymentMethodCode = $order->getPayment()->getMethod(); + + if (!empty($paymentMethodCode) && preg_match('/novalnet/', $paymentMethodCode) && $order->getPayment()->getAdditionalData()) { + + // unset session data after request formation + $subscription = false; + foreach ($order->getItems() as $item) { + $additionalData = []; + if (!empty($item->getAdditionalData())) { + $additionalData = json_decode($item->getAdditionalData(), true); + } + + if (!empty($additionalData['period_unit']) && !empty($additionalData['billing_frequency'])) { + $subscription = true; + break; + } + } + if ($subscription != true) { + $this->novalnetRequestHelper->getMethodSession($paymentMethodCode, true); + } + $additionalData = (!empty($order->getPayment()->getAdditionalData())) ? json_decode($order->getPayment()->getAdditionalData(), true) : []; + $transactionStatus = !empty($additionalData['NnStatus']) ? $additionalData['NnStatus'] : ''; + if (!isset($additionalData['NnRedirectURL'])) { + $orderStatus = 'pending'; + + if ($transactionStatus == 'ON_HOLD' || ($this->novalnetConfig->isZeroAmountBookingSupported($paymentMethodCode) && $this->novalnetConfig->getPaymentConfig($paymentMethodCode, 'payment_action') == NNConfig::ACTION_ZERO_AMOUNT_BOOKING)) { + $orderStatus = $this->novalnetConfig->getGlobalOnholdStatus($storeId); + } elseif ($transactionStatus == 'CONFIRMED' || ($transactionStatus == 'PENDING' && in_array( + $paymentMethodCode, + [ + ConfigProvider::NOVALNET_INVOICE, + ConfigProvider::NOVALNET_PREPAYMENT, + ConfigProvider::NOVALNET_CASHPAYMENT, + ConfigProvider::NOVALNET_MULTIBANCO + ] + ) + )) { + $orderStatus = $this->novalnetConfig->getPaymentConfig( + $paymentMethodCode, + 'order_status', + $storeId + ); + } + + if (($paymentMethodCode == ConfigProvider::NOVALNET_PAYPAL) && $this->coreSession->getRecurringProcess() && $transactionStatus == 'CONFIRMED') { + $invoice = $this->invoiceService->prepareInvoice($order); + $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::CAPTURE_OFFLINE); + $invoice->register(); + $invoice->save(); + $transactionSave = $this->transaction->addObject( + $invoice + )->addObject( + $invoice->getOrder() + ); + $transactionSave->save(); + } + + $orderStatus = $orderStatus ? $orderStatus : Order::STATE_PROCESSING; + // Verifies and sets order status + $order->setState(Order::STATE_PROCESSING) + ->setStatus($orderStatus); + $order->save(); + } + } + } + } +} diff --git a/Observer/SavePaymentDataForRecurring.php b/Observer/SavePaymentDataForRecurring.php new file mode 100755 index 0000000..baf503a --- /dev/null +++ b/Observer/SavePaymentDataForRecurring.php @@ -0,0 +1,118 @@ +date = $date; + $this->jsonHelper = $jsonHelper; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->transactionStatusModel = $transactionStatusModel; + } + + /** + * Save payment data for future recurring order + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $order = $observer->getOrder(); + $paymentMethodCode = $observer->getPaymentCode(); + if (!empty($paymentMethodCode) && preg_match('/novalnet/', $paymentMethodCode)) { + $token = $this->getToken($paymentMethodCode, $order->getIncrementId()); + $profileData = $observer->getItem(); + if (!empty($token)) { + $profileData->setToken($token); + } + + //Save date of birth and company for future recurring + if (in_array($paymentMethodCode, [ConfigProvider::NOVALNET_INVOICE_GUARANTEE, ConfigProvider::NOVALNET_SEPA_GUARANTEE])) { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + $recurringData = []; + if ($methodSession->getData($paymentMethodCode . '_dob')) { + $recurringData['dob'] = $this->date->date( + 'Y-m-d', + $methodSession->getData($paymentMethodCode . '_dob') + ); + } + $profileData->setAdditionalData($this->jsonHelper->jsonEncode($recurringData)); + } + // unset session data after request formation + $this->novalnetRequestHelper->getMethodSession($paymentMethodCode, true); + } + } + + /** + * Get Token + * + * @param string $paymentMethodCode + * @param int $orderId + * @return string + */ + public function getToken($paymentMethodCode, $orderId) + { + $methodSession = $this->novalnetRequestHelper->getMethodSession($paymentMethodCode); + $token = $methodSession->getData($paymentMethodCode . '_token'); + if (empty($token)) { + $transactionStatus = $this->transactionStatusModel->getCollection()->setPageSize(1) + ->addFieldToFilter('order_id', $orderId) + ->getFirstItem(); + $token = $transactionStatus->getToken(); + } + return $token; + } +} diff --git a/Observer/SetPaymentDataForRecurring.php b/Observer/SetPaymentDataForRecurring.php new file mode 100755 index 0000000..5d82847 --- /dev/null +++ b/Observer/SetPaymentDataForRecurring.php @@ -0,0 +1,88 @@ +date = $date; + $this->novalnetRequestHelper = $novalnetRequestHelper; + $this->transactionStatusModel = $transactionStatusModel; + } + + /** + * Save payment data for future recurring order + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $paymentData = $observer->getPaymentData()->getData(); + $paymentDataObject = $observer->getPaymentData(); + $profile = $observer->getProfile(); + $paymentCode = $observer->getPaymentCode(); + if (in_array($paymentCode, [ConfigProvider::NOVALNET_CC, ConfigProvider::NOVALNET_SEPA ,ConfigProvider::NOVALNET_PAYPAL])) { + $recurringDetails = $profile->getToken(); + + if (!empty($profile->getToken())) { + $paymentData['additional_data'][$paymentCode.'_token'] = $profile->getToken(); + } + } elseif (in_array($paymentCode, [ConfigProvider::NOVALNET_INVOICE_GUARANTEE, ConfigProvider::NOVALNET_SEPA_GUARANTEE])) { + if (!empty($profile->getAdditionalData())) { + $additionalData = json_decode($profile->getAdditionalData(), true); + if (isset($additionalData['dob'])) { + $paymentData['additional_data'][$paymentCode.'_dob'] = $additionalData['dob']; + } + if (!empty($profile->getToken())) { + $paymentData['additional_data'][$paymentCode.'_token'] = $profile->getToken(); + } + } + } + $paymentDataObject->setData($paymentData); + } +} diff --git a/Observer/SetVoidStatus.php b/Observer/SetVoidStatus.php new file mode 100755 index 0000000..b7248ed --- /dev/null +++ b/Observer/SetVoidStatus.php @@ -0,0 +1,60 @@ +novalnetConfig = $novalnetConfig; + } + + /** + * Set Canceled/Void status for Novalnet payments + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $payment = $observer->getEvent()->getPayment(); + if (!empty($payment->getMethodInstance()->getCode()) && preg_match('/novalnet/i', $payment->getMethodInstance()->getCode())) { + + $order = $payment->getOrder(); + $order->setState(Order::STATE_PROCESSING) + ->setStatus(Order::STATE_CANCELED) + ->save(); + $order->addStatusHistoryComment(__('The transaction has been canceled'), false) + ->save(); + } + } +} diff --git a/Observer/ShortcutButtons.php b/Observer/ShortcutButtons.php new file mode 100755 index 0000000..0f273d3 --- /dev/null +++ b/Observer/ShortcutButtons.php @@ -0,0 +1,57 @@ +getEvent()->getContainer(); + + /** @var \Magento\Framework\View\Element\Template $shortcut */ + $shortcut = $shortcutButtons->getLayout()->createBlock( + \Novalnet\Payment\Block\Checkout\Cart\Shortcut::class, + '', + [] + ); + + $shortcut->setIsInCatalogProduct( + $observer->getEvent()->getIsCatalogProduct() + )->setShowOrPosition( + $observer->getEvent()->getOrPosition() + ); + + $shortcut->setIsShoppingCart($observer->getEvent()->getIsShoppingCart()); + + $shortcut->setIsCart(get_class($shortcutButtons) == \Magento\Checkout\Block\QuoteShortcutButtons::class); + + $shortcutButtons->addShortcut($shortcut); + } +} diff --git a/Observer/SubscriptionSupportedPayments.php b/Observer/SubscriptionSupportedPayments.php new file mode 100755 index 0000000..36ad55e --- /dev/null +++ b/Observer/SubscriptionSupportedPayments.php @@ -0,0 +1,60 @@ +novalnetConfig = $novalnetConfig; + } + + /** + * Set Subscription Supported Novalnet payments + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + $paymentMethods = $observer->getPaymentMethods(); + if (!empty($paymentMethods)) { + $payments = $paymentMethods->getData(); + foreach ($payments as $paymentCode => $payment) { + if (!empty($paymentCode) && preg_match('/novalnet/i', $paymentCode) && !$this->novalnetConfig->isSubscriptionSupported($paymentCode)) { + unset($payments[$paymentCode]); + } + } + $paymentMethods->setData($payments); + } + } +} diff --git a/Plugin/Checkout/LayoutProcessor.php b/Plugin/Checkout/LayoutProcessor.php new file mode 100755 index 0000000..48689cc --- /dev/null +++ b/Plugin/Checkout/LayoutProcessor.php @@ -0,0 +1,71 @@ +novalnetHelper = $novalnetHelper; + $this->novalnetConfig = $NNConfig; + } + + /** + * After process + * + * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject + * @param array $jsLayout + * @return mixed + */ + public function afterProcess( + \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, + array $jsLayout + ) { + $isEnabled = $this->novalnetHelper->isPageEnabledForExpressCheckout('guest_checkout_page'); + + if ($this->novalnetHelper->getCustomerSession()->isLoggedIn() || (!$isEnabled['novalnetApplepay'] && !$isEnabled['novalnetGooglepay'])) { + if (isset($jsLayout['components']['checkout']['children']['steps'] + ['children']['shipping-step']['children']['novalnet-guest-checkout'])) { + unset($jsLayout['components']['checkout']['children']['steps'] + ['children']['shipping-step']['children']['novalnet-guest-checkout']); + } + } + + return $jsLayout; + } +} diff --git a/Setup/Patch/Data/RemoveAccessKey.php b/Setup/Patch/Data/RemoveAccessKey.php new file mode 100755 index 0000000..c69fdc3 --- /dev/null +++ b/Setup/Patch/Data/RemoveAccessKey.php @@ -0,0 +1,234 @@ +collectionFactory = $collectionFactory; + $this->configResource = $configResource; + $this->resourceConfig = $resourceConfig; + $this->novalnetLogger = $novalnetLogger; + } + + /** + * @inheritdoc + */ + public function apply() + { + $novalnetGlobalConfig = [ + 'novalnet_global/novalnet/payment_access_key', + 'novalnet_global/novalnet/signature', + 'payment/novalnet/payment_access_key', + 'payment/novalnet/signature' + ]; + + $novalnetMapping = [ + 'novalnet_global/novalnet/live_mode' => 'payment/novalnet/live_mode', + 'novalnet_global/novalnet/enable_payment_logo' => 'payment/novalnet/enable_payment_logo', + 'novalnet_global/novalnet/restore_cart' => 'payment/novalnet/restore_cart', + 'novalnet_global/merchant_script/test_mode' => 'payment/merchant_script/test_mode', + 'novalnet_global/merchant_script/mail_to_addr' => 'payment/merchant_script/mail_to_addr', + 'payment/novalnetSepa/enable_guarantee' => 'payment/novalnetSepaGuarantee/active', + 'payment/novalnetSepa/sepa_duedate' => 'payment/novalnetSepa/due_date', + 'payment/novalnetSepaInstalment/sepa_duedate' => 'payment/novalnetSepaInstalment/due_date', + 'payment/novalnetInvoice/enable_guarantee' => 'payment/novalnetInvoiceGuarantee/active', + 'payment/novalnetInvoice/payment_duration' => 'payment/novalnetInvoice/due_date', + 'payment/novalnetCashpayment/payment_duration' => 'payment/novalnetCashpayment/due_date', + 'payment/novalnetSepa/guarantee_min_order_total' => 'payment/novalnetSepaGuarantee/min_order_total', + 'payment/novalnetInvoice/guarantee_min_order_total' => 'payment/novalnetInvoiceGuarantee/min_order_total', + 'payment/novalnetSepa/payment_guarantee_force' => 'payment/novalnetSepaGuarantee/payment_guarantee_force', + 'payment/novalnetSepa/active' => 'payment/novalnetSepaGuarantee/payment_guarantee_force', + 'payment/novalnetInvoice/payment_guarantee_force' => 'payment/novalnetInvoiceGuarantee/payment_guarantee_force', + 'payment/novalnetInvoice/active' => 'payment/novalnetInvoiceGuarantee/payment_guarantee_force', + 'payment/novalnetInvoiceInstalment/min_order_total' => 'payment/novalnetInvoiceInstalment/min_order_total', + 'payment/novalnetSepaInstalment/min_order_total' => 'payment/novalnetSepaInstalment/min_order_total', + 'payment/novalnetInvoiceInstalment/instalment_total_period' => 'payment/novalnetInvoiceInstalment/instalment_cycles', + 'payment/novalnetSepaInstalment/instalment_total_period' => 'payment/novalnetSepaInstalment/instalment_cycles', + 'payment/novalnetCc/order_status_after_payment' => 'payment/novalnetCc/order_status', + 'payment/novalnetPaypal/order_status_after_payment' => 'payment/novalnetPaypal/order_status', + 'payment/novalnetBanktransfer/order_status_after_payment' => 'payment/novalnetBanktransfer/order_status', + 'payment/novalnetIdeal/order_status_after_payment' => 'payment/novalnetIdeal/order_status', + 'payment/novalnetEps/order_status_after_payment' => 'payment/novalnetEps/order_status', + 'payment/novalnetGiropay/order_status_after_payment' => 'payment/novalnetGiropay/order_status', + 'payment/novalnetPrzelewy/order_status_after_payment' => 'payment/novalnetPrzelewy/order_status', + ]; + + //set default value for enable payment logo option + $this->resourceConfig->saveConfig( + 'payment/novalnet/enable_payment_logo', + 1, + 'default', + 0 + ); + //set default value for restore cart + $this->resourceConfig->saveConfig( + 'payment/novalnet/restore_cart', + 1, + 'default', + 0 + ); + //set default value for ip control + $this->resourceConfig->saveConfig( + 'payment/merchant_script/test_mode', + 0, + 'default', + 0 + ); + + $novalnetConfigurations = $this->collectionFactory->create()->addFieldToFilter('path', [ + ['like' => '%novalnet_global%'], + ['like' => '%novalnetInvoice%'], + ['like' => '%novalnetSepa%'], + ['like' => '%novalnetCashpayment%'], + ['like' => '%order_status_after_payment'], + ['like' => '%paymentaction'], + ]); + + foreach ($novalnetConfigurations as $config) { + if (in_array($config->getPath(), $novalnetGlobalConfig)) { + //Remove payment access key and signature + $this->configResource->delete($config); + $this->novalnetLogger->notice('Removed Novalnet global configuration. The config path: ' . $config->getPath()); + } elseif (isset($novalnetMapping[$config->getPath()])) { + $value = $config->getValue(); + //update guarantee min order total into EUR + if (!empty($config->getPath()) && preg_match('/guarantee_min_order_total/', $config->getPath()) && !empty($config->getValue())) { + $value = $this->getFormattedAmount( + $config->getValue(), + 'RAW' + ); + } elseif (!empty($config->getPath()) && preg_match('/guarantee_min_order_total/', $config->getPath()) && empty($config->getValue())) { + $value = $this->getFormattedAmount( + 999, + 'RAW' + ); + } + + //update min order total for Instalment payments + if (!empty($config->getPath()) && preg_match('/Instalment\/min_order_total/', $config->getPath())) { + $value = '19.98'; + } + + //update Guarantee Force configuration + if (!empty($config->getPath()) && preg_match('/payment_guarantee_force/', $config->getPath())) { + $value = 0; + } + + $this->resourceConfig->saveConfig( + $novalnetMapping[$config->getPath()], + $value, + $config->getScope(), + $config->getScopeId() + ); + $this->novalnetLogger->notice( + 'Update Novalnet payment config path & value. Old path: ' . $config->getPath() . + ' New path: ' . $novalnetMapping[$config->getPath()] . ' Values is: ' . $value + ); + } else { + //update payment_action configuration + if (!empty($config->getPath()) && preg_match('/novalnet/', $config->getPath()) && preg_match('/paymentaction/', $config->getPath())) { + $path = preg_replace('/paymentaction/i', 'payment_action', $config->getPath()); + if ($config->getValue() == 1) { + $value = AbstractMethod::ACTION_AUTHORIZE; + } else { + $value = AbstractMethod::ACTION_AUTHORIZE_CAPTURE; + } + $this->resourceConfig->saveConfig( + $path, + $value, + $config->getScope(), + $config->getScopeId() + ); + $this->novalnetLogger->notice( + 'Update Novalnet payment config path & value. Old path: ' . $config->getPath() . + ' New path: ' . $path . ' Values is: ' . $value + ); + } + } + } + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return []; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } + + /** + * Get the formated amount in cents/euro + * + * @param mixed $amount + * @param string $type + * @return mixed + */ + public function getFormattedAmount($amount, $type = 'CENT') + { + if (!empty($amount)) { + return ($type == 'RAW') ? number_format($amount / 100, 2, '.', '') : round($amount, 2) * 100; + } + + return null; + } +} diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..b9ae91e --- /dev/null +++ b/composer.json @@ -0,0 +1,16 @@ +{ + "name": "novalnet/module-payment", + "description": "Demonstrates integration with payment gateway", + "type": "magento2-module", + "version": "12.4.5", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ "registration.php" ], + "psr-4": { + "Novalnet\\Payment\\": "" + } + } +} diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml new file mode 100755 index 0000000..b0692a2 --- /dev/null +++ b/etc/adminhtml/di.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml new file mode 100755 index 0000000..f29ea22 --- /dev/null +++ b/etc/adminhtml/routes.xml @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100755 index 0000000..42357dc --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,65 @@ + + + + +
+ +
Secured and trusted means of accepting all payment methods supported worldwide.
Novalnet provides the most convenient way to increase your sales and deliver seamless checkout experience for your customers.
]]>
+ novalnet-section + Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment + + + + novalnet-payment-section + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
diff --git a/etc/adminhtml/system/novalnet_alipay.xml b/etc/adminhtml/system/novalnet_alipay.xml new file mode 100755 index 0000000..6fcc8e4 --- /dev/null +++ b/etc/adminhtml/system/novalnet_alipay.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetAlipay/active + + + + payment/novalnetAlipay/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-number + validate-length maximum-length-5 + payment/novalnetAlipay/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetAlipay/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetAlipay/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetAlipay/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetAlipay/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetAlipay/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetAlipay/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetAlipay/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetAlipay/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_applepay.xml b/etc/adminhtml/system/novalnet_applepay.xml new file mode 100755 index 0000000..b17cd62 --- /dev/null +++ b/etc/adminhtml/system/novalnet_applepay.xml @@ -0,0 +1,109 @@ + + + + + + Your customers can checkout using Apple Pay from any page in your web store + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetApplepay/active + + + + payment/novalnetApplepay/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetApplepay/sort_order + + + + The business name is rendered in the Apple Pay payment sheet, and this text will appear as PAY 'BUSINESS NAME' so that the customer knows where he is paying to. + payment/novalnetApplepay/seller_name + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetApplepay/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetApplepay/manual_checking_amount + + authorize + + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetApplepay/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetApplepay/instructions + + + + Magento\Config\Block\System\Config\Form\Fieldset + + + Novalnet\Payment\Model\Adminhtml\Source\ApplepayButtonStyle + payment/novalnetApplepay/button_style + + + + Novalnet\Payment\Model\Adminhtml\Source\ApplepayButtonTheme + payment/novalnetApplepay/button_theme + + + + Range from 30 to 64 pixels + payment/novalnetApplepay/button_height + validate-digits validate-digits-range digits-range-30-64 + + + + Range from 0 to 10 pixels + payment/novalnetApplepay/button_corner_radius + validate-digits validate-digits-range digits-range-0-10 + + + + 1 + The selected pages will display the Apple pay button to pay instantly as an express checkout option + Novalnet\Payment\Model\Adminhtml\Source\ApplepayEnabledPages + payment/novalnetApplepay/enabled_pages + + + + diff --git a/etc/adminhtml/system/novalnet_bancontact.xml b/etc/adminhtml/system/novalnet_bancontact.xml new file mode 100755 index 0000000..55905a0 --- /dev/null +++ b/etc/adminhtml/system/novalnet_bancontact.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetBancontact/active + + + + payment/novalnetBancontact/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetBancontact/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetBancontact/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetBancontact/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetBancontact/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetBancontact/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetBancontact/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBancontact/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBancontact/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetBancontact/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_banktransfer.xml b/etc/adminhtml/system/novalnet_banktransfer.xml new file mode 100755 index 0000000..162041f --- /dev/null +++ b/etc/adminhtml/system/novalnet_banktransfer.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetBanktransfer/active + + + + payment/novalnetBanktransfer/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-number + validate-length maximum-length-5 + payment/novalnetBanktransfer/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetBanktransfer/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetBanktransfer/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetBanktransfer/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetBanktransfer/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetBanktransfer/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBanktransfer/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBanktransfer/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetBanktransfer/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_blik.xml b/etc/adminhtml/system/novalnet_blik.xml new file mode 100755 index 0000000..bc0822c --- /dev/null +++ b/etc/adminhtml/system/novalnet_blik.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetBlik/active + + + + payment/novalnetBlik/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetBlik/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetBlik/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetBlik/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetBlik/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetBlik/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetBlik/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBlik/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetBlik/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetBlik/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_cashpayment.xml b/etc/adminhtml/system/novalnet_cashpayment.xml new file mode 100755 index 0000000..3b1a4e0 --- /dev/null +++ b/etc/adminhtml/system/novalnet_cashpayment.xml @@ -0,0 +1,101 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetCashpayment/active + + + + payment/novalnetCashpayment/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetCashpayment/sort_order + + + + Enter the number of days to pay the amount at store near you. If the field is empty, 14 days will be set as default. + validate-digits + payment/novalnetCashpayment/due_date + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetCashpayment/order_status + + + + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetCashpayment/order_status_after_payment + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetCashpayment/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetCashpayment/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetCashpayment/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetCashpayment/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetCashpayment/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetCashpayment/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetCashpayment/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_cc.xml b/etc/adminhtml/system/novalnet_cc.xml new file mode 100755 index 0000000..3a12f93 --- /dev/null +++ b/etc/adminhtml/system/novalnet_cc.xml @@ -0,0 +1,135 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetCc/active + + + + payment/novalnetCc/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetCc/sort_order + + + + By enabling this option, all payments from cards issued outside the EU will be authenticated via 3DS 2.0 SCA. + Magento\Config\Model\Config\Source\Yesno + payment/novalnetCc/enforce_3d + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentActionWithZeroAmount + payment/novalnetCc/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetCc/manual_checking_amount + + authorize + + + + + Payment details stored during the checkout process can be used for future payments + Magento\Config\Model\Config\Source\Yesno + payment/novalnetCc/shop_type + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetCc/order_status + + + + Magento\Config\Model\Config\Source\Yesno + + payment/novalnetCc/inline_form + + + + Novalnet\Payment\Block\System\Config\Form\Field\CreditcardStyle + Magento\Config\Model\Config\Backend\Serialized + payment/novalnetCc/cc_style + + + + 1 + The selected card logos will be displayed on the checkout page + Novalnet\Payment\Model\Adminhtml\Source\CcCardTypes + payment/novalnetCc/cc_types + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetCc/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetCc/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetCc/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetCc/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetCc/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetCc/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetCc/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_documentation.xml b/etc/adminhtml/system/novalnet_documentation.xml new file mode 100755 index 0000000..4842201 --- /dev/null +++ b/etc/adminhtml/system/novalnet_documentation.xml @@ -0,0 +1,33 @@ + + + + + + Novalnet Admin Portal using your merchant account. To get a merchant account, mail to sales@novalnet.de or call +49 (089) 923068320]]> + + Novalnet\Payment\Block\System\Config\Form\Field\ModuleVersion + + payment/novalnet/version + + + diff --git a/etc/adminhtml/system/novalnet_eps.xml b/etc/adminhtml/system/novalnet_eps.xml new file mode 100755 index 0000000..0f836d7 --- /dev/null +++ b/etc/adminhtml/system/novalnet_eps.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetEps/active + + + + payment/novalnetEps/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetEps/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetEps/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetEps/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetEps/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetEps/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetEps/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetEps/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetEps/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetEps/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_giropay.xml b/etc/adminhtml/system/novalnet_giropay.xml new file mode 100755 index 0000000..5f5a7d4 --- /dev/null +++ b/etc/adminhtml/system/novalnet_giropay.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetGiropay/active + + + + payment/novalnetGiropay/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetGiropay/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetGiropay/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetGiropay/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetGiropay/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetGiropay/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetGiropay/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetGiropay/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetGiropay/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetGiropay/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_global_config.xml b/etc/adminhtml/system/novalnet_global_config.xml new file mode 100755 index 0000000..8649b9d --- /dev/null +++ b/etc/adminhtml/system/novalnet_global_config.xml @@ -0,0 +1,104 @@ + + + + + + + + payment/novalnet/signature + + + + payment/novalnet/payment_access_key + + + Activate + Novalnet\Payment\Block\System\Config\Form\Field\VendorAutoConfig + payment/novalnet/vendor_config + Novalnet Admin Portal: Projects > Choose your project > API credentials > API Signature (Product activation key)]]> + + + + payment/novalnet/client_key + Novalnet\Payment\Block\System\Config\Form\Field\Disabled + + + + payment/novalnet/tariff_id + Select a Tariff ID to match the preferred tariff plan you created at the Novalnet Admin Portal for this project + + + + Selected payment methods will be in Live Mode + Novalnet\Payment\Model\Adminhtml\Source\Activemethods + 1 + payment/novalnet/live_mode + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnet/restore_cart + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnet/instalment_mail + + + + Status to be used for on-hold orders until the transaction is confirmed or canceled + Magento\Sales\Model\Config\Source\Order\Status + novalnet_global/novalnet/onhold_status + + + + {Shop_url/rest/V1/novalnet/callback} in below Notification / Webhook URL field and click on Configure button to receive notification about transactions.]]> + + + Notification / Webhook URL is required to keep the merchant’s database/system synchronized with the Novalnet account (e.g. delivery status). Refer the Installation Guide for more information + Novalnet\Payment\Block\System\Config\Form\Field\WebhookURL + validate-url validate-no-html-tags + payment/merchant_script/vendor_script_url + + + + Enable this to test the Novalnet Notification / Webhook URL manually. Disable this before setting your shop live to block unauthorized calls from external parties + Magento\Config\Model\Config\Source\Yesno + payment/merchant_script/test_mode + + + + validate-no-html-tags validate-email + Notification / Webhook URL execution messages will be sent to this e-mail + payment/merchant_script/mail_to_addr + + + + + diff --git a/etc/adminhtml/system/novalnet_googlepay.xml b/etc/adminhtml/system/novalnet_googlepay.xml new file mode 100755 index 0000000..073e900 --- /dev/null +++ b/etc/adminhtml/system/novalnet_googlepay.xml @@ -0,0 +1,119 @@ + + + + + + Your customers can checkout using Google Pay from any page in your web store + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetGooglepay/active + + + + payment/novalnetGooglepay/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetGooglepay/sort_order + + + + By enabling this option, all payments from cards issued outside the EU will be authenticated via 3DS 2.0 SCA. + Magento\Config\Model\Config\Source\Yesno + payment/novalnetGooglepay/enforce_3d + + + + The business name is rendered in the Google Pay payment sheet, and this text will appear as PAY 'BUSINESS NAME' so that the customer knows where he is paying to. + payment/novalnetGooglepay/seller_name + + + + required-entry + Google Pay and Wallet Console. See Request production access for more information about the approval process and obtaining a Google merchant identifier. The registration also involves submitting the integration with sufficient screen-shots, so collect this information by enabling the payment method in test mode. To suppress the validation of this field while saving the configuration, use this test identifier BCR2DN4XXXTN7FSI for testing and submission of your integration to Google.]]> + payment/novalnetGooglepay/merchant_id + + 1 + + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetGooglepay/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetGooglepay/manual_checking_amount + + authorize + + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetGooglepay/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetGooglepay/instructions + + + + Magento\Config\Block\System\Config\Form\Fieldset + + + Novalnet\Payment\Model\Adminhtml\Source\GooglepayButtonType + payment/novalnetGooglepay/button_type + + + + Novalnet\Payment\Model\Adminhtml\Source\GooglepayButtonTheme + payment/novalnetGooglepay/button_theme + + + + Range from 40 to 100 pixels + payment/novalnetGooglepay/button_height + validate-digits validate-digits-range digits-range-40-100 + + + + 1 + The selected pages will display the Google Pay button to pay instantly as an express checkout option + Novalnet\Payment\Model\Adminhtml\Source\GooglepayEnabledPages + payment/novalnetGooglepay/enabled_pages + + + + + diff --git a/etc/adminhtml/system/novalnet_ideal.xml b/etc/adminhtml/system/novalnet_ideal.xml new file mode 100755 index 0000000..a1867ba --- /dev/null +++ b/etc/adminhtml/system/novalnet_ideal.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetIdeal/active + + + + payment/novalnetIdeal/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetIdeal/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetIdeal/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetIdeal/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetIdeal/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetIdeal/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetIdeal/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetIdeal/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetIdeal/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetIdeal/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_invoice.xml b/etc/adminhtml/system/novalnet_invoice.xml new file mode 100755 index 0000000..e92aa80 --- /dev/null +++ b/etc/adminhtml/system/novalnet_invoice.xml @@ -0,0 +1,115 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetInvoice/active + + + + payment/novalnetInvoice/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetInvoice/sort_order + + + + Enter the number of days to transfer the payment amount to Novalnet (must be greater than 7 days). In case if the field is empty, 14 days will be set as due date by default + validate-digits validate-greater-than-zero validate-digits-range digits-range-7-999999999 + payment/novalnetInvoice/due_date + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetInvoice/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetInvoice/manual_checking_amount + + authorize + + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetInvoice/order_status + + + + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetInvoice/order_status_after_payment + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetInvoice/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetInvoice/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetInvoice/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetInvoice/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetInvoice/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetInvoice/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetInvoice/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_invoice_guarantee.xml b/etc/adminhtml/system/novalnet_invoice_guarantee.xml new file mode 100755 index 0000000..2a83110 --- /dev/null +++ b/etc/adminhtml/system/novalnet_invoice_guarantee.xml @@ -0,0 +1,125 @@ + + + + + + Basic requirements for payment guarantee
Allowed B2C countries: DE, AT, CH
Allowed B2B countries: European Union
Allowed currency: EUR
Minimum order amount: 9.99 EUR or more
Age limit: 18 years or more
The billing address must be the same as the shipping address

]]>
+ + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetInvoiceGuarantee/active + + + + payment/novalnetInvoiceGuarantee/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetInvoiceGuarantee/sort_order + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetInvoiceGuarantee/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetInvoiceGuarantee/manual_checking_amount + + authorize + + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetInvoiceGuarantee/order_status + + + Novalnet\Payment\Block\System\Config\Form\Field\Guaranteeforce + + + + Even if payment guarantee is enabled, payments will still be processed as non-guarantee payments if the payment guarantee requirements are not met. Review the requirements under 'Enable Payment Guarantee' in the Installation Guide. + Magento\Config\Model\Config\Source\Yesno + validate-invoiceguarantee-force + payment/novalnetInvoiceGuarantee/payment_guarantee_force + + + + Allow B2B customers to place order + Magento\Config\Model\Config\Source\Yesno + payment/novalnetInvoiceGuarantee/allow_b2b_customer + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetInvoiceGuarantee/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetInvoiceGuarantee/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetInvoiceGuarantee/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetInvoiceGuarantee/specificcountry + + + + Minimum order amount: 9.99 EUR or more + validate-number validate-novalnet-guarantee-order-total validate-length maximum-length-15 + payment/novalnetInvoiceGuarantee/min_order_total + + 1 + + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetInvoiceGuarantee/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetInvoiceGuarantee/orders_count + +
+
diff --git a/etc/adminhtml/system/novalnet_invoice_instalment.xml b/etc/adminhtml/system/novalnet_invoice_instalment.xml new file mode 100755 index 0000000..c6edefc --- /dev/null +++ b/etc/adminhtml/system/novalnet_invoice_instalment.xml @@ -0,0 +1,125 @@ + + + + + + Basic requirements for the instalment payment
Allowed B2C countries: DE, AT, CH
Allowed B2B countries: European Union
Allowed currency: EUR
Minimum order amount: 19.98 EUR or more
Please note that the instalment cycle amount has to be a minimum of 9.99 EUR and the instalment cycles which do not meet this criteria will not be displayed in the instalment plan
Age limit: 18 years or more
The billing address must be the same as the shipping address

]]>
+ + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetInvoiceInstalment/active + + + + payment/novalnetInvoiceInstalment/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetInvoiceInstalment/sort_order + + + + Select the various instalment cycles that can be availed in the instalment plan + Novalnet\Payment\Model\Adminhtml\Source\InstalmentCycles + validate-select + payment/novalnetInvoiceInstalment/instalment_cycles + + 1 + + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetInvoiceInstalment/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetInvoiceInstalment/manual_checking_amount + + authorize + + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetInvoiceInstalment/order_status + + + + Allow B2B customers to place order + Magento\Config\Model\Config\Source\Yesno + payment/novalnetInvoiceInstalment/allow_b2b_customer + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetInvoiceInstalment/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetInvoiceInstalment/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetInvoiceInstalment/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetInvoiceInstalment/specificcountry + + + + Minimum order amount: 19.98 EUR or more + validate-number validate-novalnet-instalment-order-total validate-length maximum-length-15 + payment/novalnetInvoiceInstalment/min_order_total + + 1 + + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetInvoiceInstalment/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetInvoiceInstalment/orders_count + +
+
diff --git a/etc/adminhtml/system/novalnet_multibanco.xml b/etc/adminhtml/system/novalnet_multibanco.xml new file mode 100755 index 0000000..53c1e3c --- /dev/null +++ b/etc/adminhtml/system/novalnet_multibanco.xml @@ -0,0 +1,95 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetMultibanco/active + + + + payment/novalnetMultibanco/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetMultibanco/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetMultibanco/order_status + + + + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetMultibanco/order_status_after_payment + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetMultibanco/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetMultibanco/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetMultibanco/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetMultibanco/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetMultibanco/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetMultibanco/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetMultibanco/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_online_banktransfer.xml b/etc/adminhtml/system/novalnet_online_banktransfer.xml new file mode 100755 index 0000000..65fc680 --- /dev/null +++ b/etc/adminhtml/system/novalnet_online_banktransfer.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetOnlineBanktransfer/active + + + + payment/novalnetOnlineBanktransfer/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-number + validate-length maximum-length-5 + payment/novalnetOnlineBanktransfer/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetOnlineBanktransfer/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetOnlineBanktransfer/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetOnlineBanktransfer/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetOnlineBanktransfer/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetOnlineBanktransfer/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetOnlineBanktransfer/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetOnlineBanktransfer/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetOnlineBanktransfer/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_payment_notice.xml b/etc/adminhtml/system/novalnet_payment_notice.xml new file mode 100755 index 0000000..5e916eb --- /dev/null +++ b/etc/adminhtml/system/novalnet_payment_notice.xml @@ -0,0 +1,27 @@ + + + + + Novalnet\Payment\Block\System\Config\Form\Field\Notification + + diff --git a/etc/adminhtml/system/novalnet_paypal.xml b/etc/adminhtml/system/novalnet_paypal.xml new file mode 100755 index 0000000..547e47a --- /dev/null +++ b/etc/adminhtml/system/novalnet_paypal.xml @@ -0,0 +1,112 @@ + + + + + + Novalnet Admin Portal  > PROJECT > 'Project' Information > Payment Methods > Paypal > Configure.]]> + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPaypal/active + + + + payment/novalnetPaypal/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetPaypal/sort_order + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetPaypal/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetPaypal/manual_checking_amount + + authorize + + + + + Payment details stored during the checkout process can be used for future payments + In order to use this option you must have billing agreement option enabled in your PayPal account. Please contact your account manager at PayPal. + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPaypal/shop_type + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPaypal/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetPaypal/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetPaypal/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetPaypal/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetPaypal/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPaypal/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPaypal/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetPaypal/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_postfinance.xml b/etc/adminhtml/system/novalnet_postfinance.xml new file mode 100755 index 0000000..5a1e067 --- /dev/null +++ b/etc/adminhtml/system/novalnet_postfinance.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPostFinance/active + + + + payment/novalnetPostFinance/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetPostFinance/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPostFinance/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetPostFinance/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetPostFinance/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetPostFinance/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetPostFinance/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPostFinance/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPostFinance/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetPostFinance/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_postfinance_card.xml b/etc/adminhtml/system/novalnet_postfinance_card.xml new file mode 100755 index 0000000..678b45b --- /dev/null +++ b/etc/adminhtml/system/novalnet_postfinance_card.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPostFinanceCard/active + + + + payment/novalnetPostFinanceCard/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetPostFinanceCard/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPostFinanceCard/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetPostFinanceCard/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetPostFinanceCard/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetPostFinanceCard/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetPostFinanceCard/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPostFinanceCard/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPostFinanceCard/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetPostFinanceCard/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_prepayment.xml b/etc/adminhtml/system/novalnet_prepayment.xml new file mode 100755 index 0000000..1831ee7 --- /dev/null +++ b/etc/adminhtml/system/novalnet_prepayment.xml @@ -0,0 +1,101 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPrepayment/active + + + + payment/novalnetPrepayment/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetPrepayment/sort_order + + + + Enter the number of days after which the payment should be processed (must be between 7 and 28 days) + validate-digits validate-greater-than-zero validate-digits-range digits-range-7-28 + payment/novalnetPrepayment/due_date + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPrepayment/order_status + + + + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPrepayment/order_status_after_payment + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetPrepayment/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetPrepayment/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetPrepayment/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetPrepayment/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPrepayment/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPrepayment/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetPrepayment/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_przelewy.xml b/etc/adminhtml/system/novalnet_przelewy.xml new file mode 100755 index 0000000..0cdbf36 --- /dev/null +++ b/etc/adminhtml/system/novalnet_przelewy.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetPrzelewy/active + + + + payment/novalnetPrzelewy/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetPrzelewy/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetPrzelewy/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetPrzelewy/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetPrzelewy/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetPrzelewy/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetPrzelewy/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPrzelewy/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetPrzelewy/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetPrzelewy/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_sepa.xml b/etc/adminhtml/system/novalnet_sepa.xml new file mode 100755 index 0000000..44ee995 --- /dev/null +++ b/etc/adminhtml/system/novalnet_sepa.xml @@ -0,0 +1,116 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepa/active + + + + payment/novalnetSepa/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetSepa/sort_order + + + + Enter the number of days after which the payment should be processed (must be between 2 and 14 days) + validate-digits validate-greater-than-zero validate-digits-range digits-range-2-14 + payment/novalnetSepa/due_date + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentActionWithZeroAmount + payment/novalnetSepa/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetSepa/manual_checking_amount + + authorize + + + + + Payment details stored during the checkout process can be used for future payments + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepa/shop_type + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetSepa/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetSepa/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetSepa/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetSepa/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetSepa/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetSepa/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetSepa/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetSepa/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_sepa_guarantee.xml b/etc/adminhtml/system/novalnet_sepa_guarantee.xml new file mode 100755 index 0000000..7365e3e --- /dev/null +++ b/etc/adminhtml/system/novalnet_sepa_guarantee.xml @@ -0,0 +1,134 @@ + + + + + + Basic requirements for payment guarantee
Allowed B2C countries: DE, AT, CH
Allowed B2B countries: European Union
Allowed currency: EUR
Minimum order amount: 9.99 EUR or more
Age limit: 18 years or more
The billing address must be the same as the shipping address

]]>
+ + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaGuarantee/active + + + + payment/novalnetSepaGuarantee/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetSepaGuarantee/sort_order + + + + Enter the number of days after which the payment should be processed (must be between 2 and 14 days) + validate-digits validate-greater-than-zero validate-digits-range digits-range-2-14 + payment/novalnetSepaGuarantee/due_date + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetSepaGuarantee/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetSepaGuarantee/manual_checking_amount + + authorize + + + + + Payment details stored during the checkout process can be used for future payments + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaGuarantee/shop_type + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetSepaGuarantee/order_status + + + + Even if payment guarantee is enabled, payments will still be processed as non-guarantee payments if the payment guarantee requirements are not met. Review the requirements under 'Enable Payment Guarantee' in the Installation Guide. + Magento\Config\Model\Config\Source\Yesno + validate-sepaguarantee-force + payment/novalnetSepaGuarantee/payment_guarantee_force + + + + Allow B2B customers to place order + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaGuarantee/allow_b2b_customer + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetSepaGuarantee/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetSepaGuarantee/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetSepaGuarantee/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetSepaGuarantee/specificcountry + + + + Minimum order amount: 9.99 EUR or more + validate-number validate-novalnet-guarantee-order-total validate-length maximum-length-15 + payment/novalnetSepaGuarantee/min_order_total + + 1 + + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetSepaGuarantee/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetSepaGuarantee/orders_count + +
+
diff --git a/etc/adminhtml/system/novalnet_sepa_instalment.xml b/etc/adminhtml/system/novalnet_sepa_instalment.xml new file mode 100755 index 0000000..e6eb887 --- /dev/null +++ b/etc/adminhtml/system/novalnet_sepa_instalment.xml @@ -0,0 +1,137 @@ + + + + + + Basic requirements for the instalment payment
Allowed B2C countries: DE, AT, CH
Allowed B2B countries: European Union
Allowed currency: EUR
Minimum order amount: 19.98 EUR or more
Please note that the instalment cycle amount has to be a minimum of 9.99 EUR and the instalment cycles which do not meet this criteria will not be displayed in the instalment plan
Age limit: 18 years or more
The billing address must be the same as the shipping address

]]>
+ + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaInstalment/active + + + + payment/novalnetSepaInstalment/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-length maximum-length-5 + validate-number + payment/novalnetSepaInstalment/sort_order + + + + Enter the number of days after which the payment should be processed (must be between 2 and 14 days) + validate-digits validate-greater-than-zero validate-digits-range digits-range-2-14 + payment/novalnetSepaInstalment/due_date + + + + Select the various instalment cycles that can be availed in the instalment plan + Novalnet\Payment\Model\Adminhtml\Source\InstalmentCycles + validate-select + payment/novalnetSepaInstalment/instalment_cycles + + 1 + + + + + Choose whether or not the payment should be charged immediately. Capture completes the transaction by transferring the funds from buyer account to merchant account. Authorize verifies payment details and reserves funds to capture it later, giving time for the merchant to decide on the order. + Novalnet\Payment\Model\Adminhtml\Source\PaymentAction + payment/novalnetSepaInstalment/payment_action + + + + validate-greater-than-zero validate-digits validate-length maximum-length-15 + payment/novalnetSepaInstalment/manual_checking_amount + + authorize + + + + + Payment details stored during the checkout process can be used for future payments + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaInstalment/shop_type + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetSepaInstalment/order_status + + + + Allow B2B customers to place order + Magento\Config\Model\Config\Source\Yesno + payment/novalnetSepaInstalment/allow_b2b_customer + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetSepaInstalment/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetSepaInstalment/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetSepaInstalment/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetSepaInstalment/specificcountry + + + + Minimum order amount: 19.98 EUR or more + validate-number validate-novalnet-instalment-order-total validate-length maximum-length-15 + payment/novalnetSepaInstalment/min_order_total + + 1 + + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetSepaInstalment/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetSepaInstalment/orders_count + +
+
diff --git a/etc/adminhtml/system/novalnet_trustly.xml b/etc/adminhtml/system/novalnet_trustly.xml new file mode 100755 index 0000000..5a43a4b --- /dev/null +++ b/etc/adminhtml/system/novalnet_trustly.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetTrustly/active + + + + payment/novalnetTrustly/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-number + validate-length maximum-length-5 + payment/novalnetTrustly/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetTrustly/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetTrustly/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetTrustly/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetTrustly/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetTrustly/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetTrustly/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetTrustly/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetTrustly/orders_count + + + diff --git a/etc/adminhtml/system/novalnet_wechatpay.xml b/etc/adminhtml/system/novalnet_wechatpay.xml new file mode 100755 index 0000000..ad8e9ff --- /dev/null +++ b/etc/adminhtml/system/novalnet_wechatpay.xml @@ -0,0 +1,90 @@ + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/novalnetWechatpay/active + + + + payment/novalnetWechatpay/title + + + + This payment method will be sorted among others (in the ascending order) as per the given sort number + validate-number + validate-length maximum-length-5 + payment/novalnetWechatpay/sort_order + + + + Status to be used for successful orders + Magento\Sales\Model\Config\Source\Order\Status + payment/novalnetWechatpay/order_status + + + + The entered text will be displayed on the checkout page + validate-no-html-tags + payment/novalnetWechatpay/instructions + + + + 1 + Novalnet\Payment\Model\Adminhtml\Source\CustomerGroups + payment/novalnetWechatpay/user_group_excluded + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/novalnetWechatpay/allowspecific + + + + Magento\Directory\Model\Config\Source\Country + payment/novalnetWechatpay/specificcountry + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetWechatpay/min_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-15 + payment/novalnetWechatpay/max_order_total + + + + validate-number validate-zero-or-greater validate-length maximum-length-5 + Default: '0' for disabled check | Minimum count of orders (in the past) needed for the customer to use this payment method + payment/novalnetWechatpay/orders_count + + + diff --git a/etc/config.xml b/etc/config.xml new file mode 100755 index 0000000..ed95e49 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,538 @@ + + + + + + + holded + + + + + 0 + SEPA-Lastschrift + 1 + authorize_capture + 1 + processing + 0 + NovalnetSepaFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Kredit-/Debitkarte + 2 + VI,MC,AE,MA,CI,UP,DC,DI,JCB,CB + authorize_capture + 1 + 1 + processing + 0 + NovalnetCcFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Apple Pay + 3 + processing + 0 + shopping_cart_page,mini_cart_page,product_page,guest_checkout_page + apple-pay-button-text-buy + apple-pay-button-black-with-text + 50 + 0 + authorize_capture + NovalnetApplepayFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Google Pay + 4 + processing + 0 + shopping_cart_page,mini_cart_page,product_page,guest_checkout_page + buy + black + 50 + authorize_capture + NovalnetGooglepayFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Kauf auf Rechnung + 5 + authorize_capture + processing + complete + 0 + NovalnetInvoiceFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Vorkasse + 6 + authorize + pending + processing + 0 + NovalnetPrepaymentFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Rechnung mit Zahlungsgarantie + 7 + 1 + 0 + authorize_capture + processing + 0 + 9.99 + NovalnetInvoiceGuaranteeFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + SEPA-Lastschrift mit Zahlungsgarantie + 8 + 1 + 0 + authorize_capture + 1 + processing + 0 + 9.99 + NovalnetSepaGuaranteeFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Ratenzahlung per Rechnung + 9 + 2,3,4,6,8,9,10,12 + 1 + authorize_capture + processing + 0 + 19.98 + NovalnetInvoiceInstalmentFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Ratenzahlung per SEPA-Lastschrift + 10 + 2,3,4,6,8,9,10,12 + 1 + authorize_capture + 1 + processing + 0 + 19.98 + NovalnetSepaInstalmentFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + iDEAL + 11 + processing + 0 + NovalnetIdealFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Sofortüberweisung + 12 + processing + 0 + NovalnetBanktransferFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + giropay + 13 + processing + 0 + NovalnetGiropayFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Barzahlen/viacash + 14 + authorize + pending + processing + 0 + NovalnetCashpaymentFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Przelewy24 + 15 + processing + 0 + NovalnetPrzelewyFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + eps + 16 + processing + 0 + NovalnetEpsFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + PayPal + 17 + authorize_capture + 0 + processing + 0 + NovalnetPaypalFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + PostFinance Card + 18 + processing + 0 + NovalnetPostFinanceCardFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + PostFinance E-Finance + 19 + processing + 0 + NovalnetPostFinanceFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Bancontact + 20 + processing + 0 + NovalnetBancontactFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Multibanco + 21 + authorize + processing + complete + 0 + NovalnetMultibancoFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Onlineüberweisung + 22 + processing + 0 + NovalnetOnlineBanktransferFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Alipay + 23 + processing + 0 + NovalnetAlipayFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + WeChat Pay + 24 + processing + 0 + NovalnetWechatpayFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Trustly + 25 + processing + 0 + NovalnetTrustlyFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 0 + Blik + 11 + processing + 0 + NovalnetBlikFacade + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + + diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml new file mode 100755 index 0000000..27c53f7 --- /dev/null +++ b/etc/csp_whitelist.xml @@ -0,0 +1,39 @@ + + + + + + + secure.novalnet.de + customers.barzahlen.de + customers-sandbox.barzahlen.de + + + + + cdn.novalnet.de + cdn.barzahlen.de + + + + diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100755 index 0000000..1efcc63 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
diff --git a/etc/di.xml b/etc/di.xml new file mode 100755 index 0000000..3457eb5 --- /dev/null +++ b/etc/di.xml @@ -0,0 +1,2250 @@ + + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CC + Novalnet\Payment\Block\Form\Cc + Novalnet\Payment\Block\Info\Cc + NovalnetCcValueHandlerPool + NovalnetCcValidatorPool + NovalnetCcCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CC + + + + + + + NovalnetCcInitializeCommand + NovalnetCcAuthorizeCommand + NovalnetCcCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetCcConfig + + + + + + Novalnet\Payment\Gateway\Request\AuthorizationDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionAuthorize + + + + + + NovalnetCcConfig + + + + + + Novalnet\Payment\Gateway\Request\CaptureDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionCapture + + + + + + NovalnetCcConfig + + + + + + NovalnetCcConfig + + + + + + NovalnetCcConfig + + + + + + + NovalnetCcConfigValueHandler + Novalnet\Payment\Gateway\Config\CanInitializeHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + Novalnet\Payment\Gateway\Config\OrderPlaceRedirectUrlHandler + + + + + + NovalnetCcConfig + + + + + + + NovalnetCcCountryValidator + + + + + + NovalnetCcConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_APPLEPAY + Novalnet\Payment\Block\Form\Applepay + Novalnet\Payment\Block\Info\Applepay + NovalnetApplepayValueHandlerPool + NovalnetApplepayValidatorPool + NovalnetApplepayCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_APPLEPAY + + + + + + + NovalnetApplepayInitializeCommand + NovalnetApplepayAuthorizeCommand + NovalnetApplepayCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetApplepayConfig + + + + + + Novalnet\Payment\Gateway\Request\AuthorizationDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionAuthorize + + + + + + NovalnetApplepayConfig + + + + + + Novalnet\Payment\Gateway\Request\CaptureDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionCapture + + + + + + NovalnetApplepayConfig + + + + + + NovalnetApplepayConfig + + + + + + NovalnetApplepayConfig + + + + + + + NovalnetApplepayConfigValueHandler + Novalnet\Payment\Gateway\Config\CanInitializeHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetApplepayConfig + + + + + + + NovalnetApplepayCountryValidator + + + + + + NovalnetApplepayConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_GOOGLEPAY + Novalnet\Payment\Block\Form\Googlepay + Novalnet\Payment\Block\Info\Googlepay + NovalnetGooglepayValueHandlerPool + NovalnetGooglepayValidatorPool + NovalnetGooglepayCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_GOOGLEPAY + + + + + + + NovalnetGooglepayInitializeCommand + NovalnetGooglepayAuthorizeCommand + NovalnetGooglepayCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetGooglepayConfig + + + + + + Novalnet\Payment\Gateway\Request\AuthorizationDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionAuthorize + + + + + + NovalnetGooglepayConfig + + + + + + Novalnet\Payment\Gateway\Request\CaptureDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionCapture + + + + + + NovalnetGooglepayConfig + + + + + + NovalnetGooglepayConfig + + + + + + NovalnetGooglepayConfig + + + + + + + NovalnetGooglepayConfigValueHandler + Novalnet\Payment\Gateway\Config\CanInitializeHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetGooglepayConfig + + + + + + + NovalnetGooglepayCountryValidator + + + + + + NovalnetGooglepayConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA + Novalnet\Payment\Block\Form\Sepa + Novalnet\Payment\Block\Info\Sepa + NovalnetSepaValueHandlerPool + NovalnetSepaValidatorPool + NovalnetDirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA + + + + + + NovalnetSepaConfig + + + + + + NovalnetSepaConfig + + + + + + NovalnetSepaConfig + + + + + + NovalnetSepaConfig + + + + + + + NovalnetSepaConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetSepaConfig + + + + + + + NovalnetSepaCountryValidator + + + + + + NovalnetSepaConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE + Novalnet\Payment\Block\Form\Invoice + Novalnet\Payment\Block\Info\Invoice + NovalnetInvoiceValueHandlerPool + NovalnetInvoiceValidatorPool + NovalnetDirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE + + + + + + NovalnetInvoiceConfig + + + + + + NovalnetInvoiceConfig + + + + + + NovalnetInvoiceConfig + + + + + + NovalnetInvoiceConfig + + + + + + + NovalnetInvoiceConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetInvoiceConfig + + + + + + + NovalnetInvoiceCountryValidator + + + + + + NovalnetInvoiceConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE_GUARANTEE + Novalnet\Payment\Block\Form\InvoiceGuarantee + Novalnet\Payment\Block\Info\InvoiceGuarantee + NovalnetInvoiceGuaranteeValueHandlerPool + NovalnetInvoiceGuaranteeValidatorPool + NovalnetInvoiceGuaranteeCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE_GUARANTEE + + + + + + + NovalnetInitializeCommand + NovalnetDirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + + NovalnetInvoiceGuaranteeConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + + NovalnetInvoiceGuaranteeCountryValidator + + + + + + NovalnetInvoiceGuaranteeConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA_GUARANTEE + Novalnet\Payment\Block\Form\SepaGuarantee + Novalnet\Payment\Block\Info\SepaGuarantee + NovalnetSepaGuaranteeValueHandlerPool + NovalnetSepaGuaranteeValidatorPool + NovalnetSepaGuaranteeCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA_GUARANTEE + + + + + + + NovalnetInitializeCommand + NovalnetDirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetSepaGuaranteeConfig + + + + + + NovalnetSepaGuaranteeConfig + + + + + + NovalnetSepaGuaranteeConfig + + + + + + NovalnetSepaGuaranteeConfig + + + + + + NovalnetSepaGuaranteeConfig + + + + + + + NovalnetSepaGuaranteeConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetSepaGuaranteeConfig + + + + + + + NovalnetSepaGuaranteeCountryValidator + + + + + + NovalnetSepaGuaranteeConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PREPAYMENT + Novalnet\Payment\Block\Form\Prepayment + Novalnet\Payment\Block\Info\Prepayment + NovalnetPrepaymentValueHandlerPool + NovalnetPrepaymentValidatorPool + NovalnetDirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PREPAYMENT + + + + + + NovalnetPrepaymentConfig + + + + + + NovalnetPrepaymentConfig + + + + + + NovalnetPrepaymentConfig + + + + + + NovalnetPrepaymentConfig + + + + + + + NovalnetPrepaymentConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetPrepaymentConfig + + + + + + + NovalnetPrepaymentCountryValidator + + + + + + NovalnetPrepaymentConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CASHPAYMENT + Novalnet\Payment\Block\Form\Cashpayment + Novalnet\Payment\Block\Info\Cashpayment + NovalnetCashpaymentValueHandlerPool + NovalnetCashpaymentValidatorPool + NovalnetDirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_CASHPAYMENT + + + + + + NovalnetCashpaymentConfig + + + + + + NovalnetCashpaymentConfig + + + + + + NovalnetCashpaymentConfig + + + + + + NovalnetCashpaymentConfig + + + + + + + NovalnetCashpaymentConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetCashpaymentConfig + + + + + + + NovalnetCashpaymentCountryValidator + + + + + + NovalnetCashpaymentConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_MULTIBANCO + Novalnet\Payment\Block\Form\Multibanco + Novalnet\Payment\Block\Info\Multibanco + NovalnetMultibancoValueHandlerPool + NovalnetMultibancoValidatorPool + NovalnetDirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_MULTIBANCO + + + + + + NovalnetMultibancoConfig + + + + + + + NovalnetMultibancoConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetMultibancoConfig + + + + + + + NovalnetMultibancoCountryValidator + + + + + + NovalnetMultibancoConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PAYPAL + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Paypal + NovalnetPaypalValueHandlerPool + NovalnetPaypalValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PAYPAL + + + + + + NovalnetPaypalConfig + + + + + + NovalnetPaypalConfig + + + + + + NovalnetPaypalConfig + + + + + + NovalnetPaypalConfig + + + + + + NovalnetPaypalConfig + + + + + + + NovalnetPaypalConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetPaypalConfig + + + + + + + NovalnetPaypalCountryValidator + + + + + + NovalnetPaypalConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BANKTRANSFER + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Banktransfer + NovalnetBanktransferValueHandlerPool + NovalnetBanktransferValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BANKTRANSFER + + + + + + NovalnetBanktransferConfig + + + + + + NovalnetBanktransferConfig + + + + + + NovalnetBanktransferConfig + + + + + + NovalnetBanktransferConfig + + + + + + NovalnetBanktransferConfig + + + + + + + NovalnetBanktransferConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetBanktransferConfig + + + + + + + NovalnetBanktransferCountryValidator + + + + + + NovalnetBanktransferConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_ONLINEBANKTRANSFER + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\OnlineBanktransfer + NovalnetOnlineBanktransferValueHandlerPool + NovalnetOnlineBanktransferValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_ONLINEBANKTRANSFER + + + + + + NovalnetOnlineBanktransferConfig + + + + + + NovalnetOnlineBanktransferConfig + + + + + + NovalnetOnlineBanktransferConfig + + + + + + NovalnetOnlineBanktransferConfig + + + + + + NovalnetOnlineBanktransferConfig + + + + + + + NovalnetOnlineBanktransferConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetOnlineBanktransferConfig + + + + + + + NovalnetOnlineBanktransferCountryValidator + + + + + + NovalnetOnlineBanktransferConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_ALIPAY + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Alipay + NovalnetAlipayValueHandlerPool + NovalnetAlipayValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_ALIPAY + + + + + + NovalnetAlipayConfig + + + + + + NovalnetAlipayConfig + + + + + + NovalnetAlipayConfig + + + + + + NovalnetAlipayConfig + + + + + + NovalnetAlipayConfig + + + + + + + NovalnetAlipayConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetAlipayConfig + + + + + + + NovalnetAlipayCountryValidator + + + + + + NovalnetAlipayConfig + + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_WECHATPAY + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Wechatpay + NovalnetWechatpayValueHandlerPool + NovalnetWechatpayValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_WECHATPAY + + + + + + NovalnetWechatpayConfig + + + + + + NovalnetWechatpayConfig + + + + + + NovalnetWechatpayConfig + + + + + + NovalnetWechatpayConfig + + + + + + NovalnetWechatpayConfig + + + + + + + NovalnetWechatpayConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetWechatpayConfig + + + + + + + NovalnetWechatpayCountryValidator + + + + + + NovalnetWechatpayConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_TRUSTLY + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Trustly + NovalnetTrustlyValueHandlerPool + NovalnetTrustlyValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_TRUSTLY + + + + + + NovalnetTrustlyConfig + + + + + + NovalnetTrustlyConfig + + + + + + NovalnetTrustlyConfig + + + + + + NovalnetTrustlyConfig + + + + + + NovalnetTrustlyConfig + + + + + + + NovalnetTrustlyConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetTrustlyConfig + + + + + + + NovalnetTrustlyCountryValidator + + + + + + NovalnetTrustlyConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_IDEAL + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Ideal + NovalnetIdealValueHandlerPool + NovalnetIdealValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_IDEAL + + + + + + NovalnetIdealConfig + + + + + + NovalnetIdealConfig + + + + + + NovalnetIdealConfig + + + + + + NovalnetIdealConfig + + + + + + NovalnetIdealConfig + + + + + + + NovalnetIdealConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetIdealConfig + + + + + + + NovalnetIdealCountryValidator + + + + + + NovalnetIdealConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BLIK + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Blik + NovalnetBlikValueHandlerPool + NovalnetBlikValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BLIK + + + + + + NovalnetBlikConfig + + + + + + NovalnetBlikConfig + + + + + + NovalnetBlikConfig + + + + + + NovalnetBlikConfig + + + + + + NovalnetBlikConfig + + + + + + + NovalnetBlikConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetBlikConfig + + + + + + + NovalnetBlikCountryValidator + + + + + + NovalnetBlikConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BANCONTACT + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Bancontact + NovalnetBancontactValueHandlerPool + NovalnetBancontactValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_BANCONTACT + + + + + + NovalnetBancontactConfig + + + + + + NovalnetBancontactConfig + + + + + + NovalnetBancontactConfig + + + + + + NovalnetBancontactConfig + + + + + + NovalnetBancontactConfig + + + + + + + NovalnetBancontactConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetBancontactConfig + + + + + + + NovalnetBancontactCountryValidator + + + + + + NovalnetBancontactConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_EPS + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Eps + NovalnetEpsValueHandlerPool + NovalnetEpsValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_EPS + + + + + + NovalnetEpsConfig + + + + + + NovalnetEpsConfig + + + + + + NovalnetEpsConfig + + + + + + NovalnetEpsConfig + + + + + + NovalnetEpsConfig + + + + + + + NovalnetEpsConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetEpsConfig + + + + + + + NovalnetEpsCountryValidator + + + + + + NovalnetEpsConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_GIROPAY + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Giropay + NovalnetGiropayValueHandlerPool + NovalnetGiropayValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_GIROPAY + + + + + + NovalnetGiropayConfig + + + + + + NovalnetGiropayConfig + + + + + + NovalnetGiropayConfig + + + + + + NovalnetGiropayConfig + + + + + + NovalnetGiropayConfig + + + + + + + NovalnetGiropayConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetGiropayConfig + + + + + + + NovalnetGiropayCountryValidator + + + + + + NovalnetGiropayConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PRZELEWY + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\Przelewy + NovalnetPrzelewyValueHandlerPool + NovalnetPrzelewyValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_PRZELEWY + + + + + + NovalnetPrzelewyConfig + + + + + + NovalnetPrzelewyConfig + + + + + + NovalnetPrzelewyConfig + + + + + + NovalnetPrzelewyConfig + + + + + + NovalnetPrzelewyConfig + + + + + + + NovalnetPrzelewyConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetPrzelewyConfig + + + + + + + NovalnetPrzelewyCountryValidator + + + + + + NovalnetPrzelewyConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_POSTFINANCE + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\PostFinance + NovalnetPostFinanceValueHandlerPool + NovalnetPostFinanceValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_POSTFINANCE + + + + + + NovalnetPostFinanceConfig + + + + + + NovalnetPostFinanceConfig + + + + + + NovalnetPostFinanceConfig + + + + + + NovalnetPostFinanceConfig + + + + + + NovalnetPostFinanceConfig + + + + + + + NovalnetPostFinanceConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetPostFinanceConfig + + + + + + + NovalnetPostFinanceCountryValidator + + + + + + NovalnetPostFinanceConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_POSTFINANCE_CARD + Magento\Payment\Block\Form + Novalnet\Payment\Block\Info\PostFinanceCard + NovalnetPostFinanceCardValueHandlerPool + NovalnetPostFinanceCardValidatorPool + NovalnetRedirectPaymentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_POSTFINANCE_CARD + + + + + + NovalnetPostFinanceCardConfig + + + + + + NovalnetPostFinanceCardConfig + + + + + + NovalnetPostFinanceCardConfig + + + + + + NovalnetPostFinanceCardConfig + + + + + + NovalnetPostFinanceCardConfig + + + + + + + NovalnetPostFinanceCardConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetPostFinanceCardConfig + + + + + + + NovalnetPostFinanceCardCountryValidator + + + + + + NovalnetPostFinanceCardConfig + + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA_INSTALMENT + Novalnet\Payment\Block\Form\SepaInstalment + Novalnet\Payment\Block\Info\SepaInstalment + NovalnetSepaInstalmentValueHandlerPool + NovalnetSepaInstalmentValidatorPool + NovalnetSepaInstalmentCommandPool + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_SEPA_INSTALMENT + + + + + + + NovalnetInitializeCommand + NovalnetDirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetSepaInstalmentConfig + + + + + + NovalnetSepaInstalmentConfig + + + + + + NovalnetSepaInstalmentConfig + + + + + + NovalnetSepaInstalmentConfig + + + + + + NovalnetSepaInstalmentConfig + + + + + + + NovalnetSepaInstalmentConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetSepaInstalmentConfig + + + + + + + NovalnetSepaInstalmentCountryValidator + + + + + + NovalnetSepaInstalmentConfig + + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE_INSTALMENT + Novalnet\Payment\Block\Form\InvoiceInstalment + Novalnet\Payment\Block\Info\InvoiceInstalment + NovalnetInvoiceInstalmentValueHandlerPool + NovalnetInvoiceInstalmentValidatorPool + NovalnetInvoiceInstalmentCommandPool + + + + + \Novalnet\Payment\Model\Ui\ConfigProvider::NOVALNET_INVOICE_INSTALMENT + + + + + + + NovalnetInitializeCommand + NovalnetDirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\CcPaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + + NovalnetInvoiceInstalmentConfigValueHandler + Novalnet\Payment\Gateway\Config\PaymentActionHandler + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + + NovalnetInvoiceInstalmentCountryValidator + + + + + + NovalnetInvoiceInstalmentConfig + + + + + + + + NovalnetDirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + + NovalnetInitializeCommand + NovalnetRedirectPaymentAuthorizeCommand + NovalnetCaptureCommand + NovalnetRefundCommand + NovalnetVoidCommand + NovalnetVoidCommand + + + + + + + Novalnet\Payment\Gateway\Request\InitializeDataBuilder + Novalnet\Payment\Gateway\Response\PaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionInitialize + + + + + + Novalnet\Payment\Gateway\Request\AuthorizationDataBuilder + Novalnet\Payment\Gateway\Response\PaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionAuthorize + + + + + + Novalnet\Payment\Gateway\Request\RedirectAuthorizeDataBuilder + Novalnet\Payment\Gateway\Response\RedirectAuthorizeHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Http\Client\TransactionRedirect + + + + + + Novalnet\Payment\Gateway\Request\CaptureDataBuilder + Novalnet\Payment\Gateway\Response\PaymentHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionCapture + + + + + + Novalnet\Payment\Gateway\Request\VoidDataBuilder + Novalnet\Payment\Gateway\Response\VoidHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionVoid + + + + + + Novalnet\Payment\Gateway\Request\RefundDataBuilder + Novalnet\Payment\Gateway\Response\RefundHandler + Novalnet\Payment\Gateway\Http\TransferFactory + Novalnet\Payment\Gateway\Validator\ResponseCodeValidator + Novalnet\Payment\Gateway\Http\Client\TransactionRefund + + + + + + Magento\Framework\Filesystem\Driver\File + + + + + NovalnetLogger + + Novalnet\Payment\Logger\Handler\NovalnetNotice + Novalnet\Payment\Logger\Handler\NovalnetDebug + Novalnet\Payment\Logger\Handler\NovalnetError + + + + diff --git a/etc/email_templates.xml b/etc/email_templates.xml new file mode 100755 index 0000000..5713b40 --- /dev/null +++ b/etc/email_templates.xml @@ -0,0 +1,25 @@ + + + +