Version Notes
Download this release
Release Info
Developer | Sebastian Ertner |
Extension | Acceptance_ePayments |
Version | 16.05.26 |
Comparing to | |
See all releases |
Version 16.05.26
- app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Edit/Tab/Alias.php +169 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/PaymentMethod.php +20 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/State.php +21 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixo/Shipping/Edit.php +83 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/CategoryTree.php +99 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/Edit.php +58 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/Edit/Form.php +58 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/ClosedTransaction/Warning.php +33 -0
- app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Checkbox.php +33 -0
- app/code/community/Netresearch/OPS/Block/Alias/List.php +66 -0
- app/code/community/Netresearch/OPS/Block/Checkout/DeviceFingerprinting.php +79 -0
- app/code/community/Netresearch/OPS/Block/Checkout/SubscriptionNotice.php +193 -0
- app/code/community/Netresearch/OPS/Block/Form.php +216 -0
- app/code/community/Netresearch/OPS/Block/Form/Alias.php +55 -0
- app/code/community/Netresearch/OPS/Block/Form/Cc.php +268 -0
- app/code/community/Netresearch/OPS/Block/Form/DirectDebit.php +233 -0
- app/code/community/Netresearch/OPS/Block/Form/Flex.php +71 -0
- app/code/community/Netresearch/OPS/Block/Form/Ideal.php +33 -0
- app/code/community/Netresearch/OPS/Block/Form/InterSolve.php +52 -0
- app/code/community/Netresearch/OPS/Block/Form/Kwixo/ApresReception.php +26 -0
- app/code/community/Netresearch/OPS/Block/Form/Kwixo/Comptant.php +29 -0
- app/code/community/Netresearch/OPS/Block/Form/Kwixo/Credit.php +27 -0
- app/code/community/Netresearch/OPS/Block/Form/OpsId.php +17 -0
- app/code/community/Netresearch/OPS/Block/Form/RecurringCc.php +36 -0
- app/code/community/Netresearch/OPS/Block/Frauddetection.php +74 -0
- app/code/community/Netresearch/OPS/Block/Info/Alias.php +31 -0
- app/code/community/Netresearch/OPS/Block/Info/Cc.php +42 -0
- app/code/community/Netresearch/OPS/Block/Info/Flex.php +53 -0
- app/code/community/Netresearch/OPS/Block/Info/OpsId.php +42 -0
- app/code/community/Netresearch/OPS/Block/Info/RecurringCc.php +32 -0
- app/code/community/Netresearch/OPS/Block/Info/Redirect.php +41 -0
- app/code/community/Netresearch/OPS/Block/Paypage.php +41 -0
- app/code/community/Netresearch/OPS/Block/Placeform.php +167 -0
- app/code/community/Netresearch/OPS/Block/Placeform3dsecure.php +42 -0
- app/code/community/Netresearch/OPS/Block/RetryPayment.php +49 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Brand.php +49 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Method.php +53 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/RecurringActive.php +55 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Kwixoconfiguration.php +35 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Mode.php +31 -0
- app/code/community/Netresearch/OPS/Block/System/Config/Support.php +168 -0
- app/code/community/Netresearch/OPS/Controller/Abstract.php +172 -0
- app/code/community/Netresearch/OPS/Helper/Alias.php +491 -0
- app/code/community/Netresearch/OPS/Helper/Api.php +122 -0
- app/code/community/Netresearch/OPS/Helper/Creditcard.php +77 -0
- app/code/community/Netresearch/OPS/Helper/Data.php +194 -0
- app/code/community/Netresearch/OPS/Helper/Debitcard.php +21 -0
- app/code/community/Netresearch/OPS/Helper/DirectDebit.php +317 -0
- app/code/community/Netresearch/OPS/Helper/Directlink.php +268 -0
- app/code/community/Netresearch/OPS/Helper/Kwixo.php +173 -0
- app/code/community/Netresearch/OPS/Helper/Order.php +171 -0
- app/code/community/Netresearch/OPS/Helper/Order/Abstract.php +84 -0
- app/code/community/Netresearch/OPS/Helper/Order/Capture.php +79 -0
- app/code/community/Netresearch/OPS/Helper/Order/Refund.php +138 -0
- app/code/community/Netresearch/OPS/Helper/Payment.php +1174 -0
- app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/Request.php +330 -0
- app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/RequestInterface.php +115 -0
- app/code/community/Netresearch/OPS/Helper/Payment/Request.php +659 -0
- app/code/community/Netresearch/OPS/Helper/Quote.php +162 -0
- app/code/community/Netresearch/OPS/Helper/Subscription.php +148 -0
- app/code/community/Netresearch/OPS/Helper/Validation/Checkout/Step.php +77 -0
- app/code/community/Netresearch/OPS/Helper/Validation/Result.php +210 -0
- app/code/community/Netresearch/OPS/Helper/Version.php +66 -0
- app/code/community/Netresearch/OPS/Model/Alias.php +64 -0
- app/code/community/Netresearch/OPS/Model/Alias/State.php +34 -0
- app/code/community/Netresearch/OPS/Model/Api/Directlink.php +198 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Additional/OpenInvoiceNl.php +15 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Parameter.php +50 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter.php +69 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Abstract.php +131 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Additional/Interface.php +11 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Additional/OpenInvoiceNlAbstract.php +144 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Interface.php +17 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Additional/OpenInvoiceNl.php +141 -0
- app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Parameter.php +68 -0
- app/code/community/Netresearch/OPS/Model/Config.php +841 -0
- app/code/community/Netresearch/OPS/Model/Eci/Values.php +35 -0
- app/code/community/Netresearch/OPS/Model/File/Download.php +61 -0
- app/code/community/Netresearch/OPS/Model/Kwixo/Category/Mapping.php +56 -0
- app/code/community/Netresearch/OPS/Model/Kwixo/Shipping/Setting.php +25 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Alias.php +33 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Alias/Collection.php +29 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Category/Mapping.php +32 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Category/Mapping/Collection.php +28 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Shipping/Setting.php +21 -0
- app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Shipping/Setting/Collection.php +21 -0
- app/code/community/Netresearch/OPS/Model/Observer.php +699 -0
- app/code/community/Netresearch/OPS/Model/Payment/Abstract.php +1105 -0
- app/code/community/Netresearch/OPS/Model/Payment/Backend/OpsId.php +36 -0
- app/code/community/Netresearch/OPS/Model/Payment/Bancontact.php +48 -0
- app/code/community/Netresearch/OPS/Model/Payment/BankTransfer.php +46 -0
- app/code/community/Netresearch/OPS/Model/Payment/BelfiusDirectNet.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/CashU.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/CbcOnline.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/Cc.php +277 -0
- app/code/community/Netresearch/OPS/Model/Payment/ChinaUnionPay.php +58 -0
- app/code/community/Netresearch/OPS/Model/Payment/Debitcard.php +51 -0
- app/code/community/Netresearch/OPS/Model/Payment/DirectDebit.php +60 -0
- app/code/community/Netresearch/OPS/Model/Payment/DirectEbanking.php +74 -0
- app/code/community/Netresearch/OPS/Model/Payment/DirectLink.php +348 -0
- app/code/community/Netresearch/OPS/Model/Payment/EDankort.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/Eps.php +24 -0
- app/code/community/Netresearch/OPS/Model/Payment/Features/PaymentEmail.php +197 -0
- app/code/community/Netresearch/OPS/Model/Payment/Features/ZeroAmountAuth.php +40 -0
- app/code/community/Netresearch/OPS/Model/Payment/Flex.php +41 -0
- app/code/community/Netresearch/OPS/Model/Payment/FortisPayButton.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/GiroPay.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/IDeal.php +82 -0
- app/code/community/Netresearch/OPS/Model/Payment/IngHomePay.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/InterSolve.php +51 -0
- app/code/community/Netresearch/OPS/Model/Payment/KbcOnline.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/Kwixo/Abstract.php +613 -0
- app/code/community/Netresearch/OPS/Model/Payment/KwixoApresReception.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/KwixoComptant.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/KwixoCredit.php +27 -0
- app/code/community/Netresearch/OPS/Model/Payment/Masterpass.php +27 -0
- app/code/community/Netresearch/OPS/Model/Payment/Mpass.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/OpenInvoice/Abstract.php +66 -0
- app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceAt.php +98 -0
- app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceDe.php +95 -0
- app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceNl.php +146 -0
- app/code/community/Netresearch/OPS/Model/Payment/Paypal.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/Paysafecard.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/PingPing.php +26 -0
- app/code/community/Netresearch/OPS/Model/Payment/PostFinanceEFinance.php +25 -0
- app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc.php +382 -0
- app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc/ParameterBag.php +526 -0
- app/code/community/Netresearch/OPS/Model/Response/Handler.php +76 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Abstract.php +341 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Authorize.php +187 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Capture.php +117 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Refund.php +169 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Special.php +89 -0
- app/code/community/Netresearch/OPS/Model/Response/Type/Void.php +68 -0
- app/code/community/Netresearch/OPS/Model/Response/TypeInterface.php +51 -0
- app/code/community/Netresearch/OPS/Model/Source/BankTransfer/Countries.php +61 -0
- app/code/community/Netresearch/OPS/Model/Source/Cc/AliasInterfaceEnabledTypes.php +62 -0
- app/code/community/Netresearch/OPS/Model/Source/Cc/RecurringTypes.php +50 -0
- app/code/community/Netresearch/OPS/Model/Source/Cc/Types.php +52 -0
- app/code/community/Netresearch/OPS/Model/Source/DebitCard/AliasInterfaceEnabledTypes.php +61 -0
- app/code/community/Netresearch/OPS/Model/Source/DebitCard/Types.php +52 -0
- app/code/community/Netresearch/OPS/Model/Source/DirectDebit/Countries.php +59 -0
- app/code/community/Netresearch/OPS/Model/Source/DirectEbanking/Brands.php +67 -0
- app/code/community/Netresearch/OPS/Model/Source/Kwixo/ProductCategories.php +127 -0
- app/code/community/Netresearch/OPS/Model/Source/Kwixo/ShipMethodType.php +94 -0
- app/code/community/Netresearch/OPS/Model/Source/Mode.php +29 -0
- app/code/community/Netresearch/OPS/Model/Source/OrderReference.php +44 -0
- app/code/community/Netresearch/OPS/Model/Source/PaymentAction.php +44 -0
- app/code/community/Netresearch/OPS/Model/Source/Pmlist.php +45 -0
- app/code/community/Netresearch/OPS/Model/Source/Template.php +46 -0
- app/code/community/Netresearch/OPS/Model/Source/TemplateType.php +21 -0
- app/code/community/Netresearch/OPS/Model/Status.php +300 -0
- app/code/community/Netresearch/OPS/Model/Status/Feedback.php +33 -0
- app/code/community/Netresearch/OPS/Model/Status/Update.php +312 -0
- app/code/community/Netresearch/OPS/Model/Subscription/Manager.php +304 -0
- app/code/community/Netresearch/OPS/Model/System/Config/Backend/Flex/Methods.php +67 -0
- app/code/community/Netresearch/OPS/Model/System/Config/Backend/HashMethods.php +48 -0
- app/code/community/Netresearch/OPS/Model/System/Config/Backend/Intersolve/Brands.php +60 -0
- app/code/community/Netresearch/OPS/Model/System/Config/Mode.php +39 -0
- app/code/community/Netresearch/OPS/Model/System/Config/Template.php +63 -0
- app/code/community/Netresearch/OPS/Model/Validator/CompositeInterface.php +12 -0
- app/code/community/Netresearch/OPS/Model/Validator/Kwixo/Shipping/Setting.php +95 -0
- app/code/community/Netresearch/OPS/Model/Validator/Parameter/Factory.php +58 -0
- app/code/community/Netresearch/OPS/Model/Validator/Parameter/Length.php +90 -0
- app/code/community/Netresearch/OPS/Model/Validator/Parameter/Validator.php +56 -0
- app/code/community/Netresearch/OPS/Model/Validator/Payment/DirectDebit.php +250 -0
- app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Customer/Renderer/StateTest.php +23 -0
- app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Kwixo/Shipping/EditTest.php +81 -0
- app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Sales/Order/Creditmemo/Totals/CheckboxTest.php +11 -0
- app/code/community/Netresearch/OPS/Test/Block/Alias/ListTest.php +77 -0
- app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest.php +75 -0
- app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest/fixtures/fingerPrintingDisabled.yaml +3 -0
- app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest/fixtures/fingerPrintingEnabled.yaml +3 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/CcTest.php +459 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/CcTest/fixtures/aliases.yaml +92 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/DirectDebitTest.php +332 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/Field/MethodTest.php +42 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/FlexTest.php +89 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/Ideal.php +12 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/InterSolveTest.php +52 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/ApresReceptionTest.php +29 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/ComptantTest.php +30 -0
- app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/CreditTest.php +34 -0
- app/code/community/Netresearch/OPS/Test/Block/FormTest.php +133 -0
- app/code/community/Netresearch/OPS/Test/Block/FormTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Block/FrauddetectionTest.php +52 -0
- app/code/community/Netresearch/OPS/Test/Block/Info/FlexTest.php +50 -0
- app/code/community/Netresearch/OPS/Test/Block/PlaceFormShaTest.php +81 -0
- app/code/community/Netresearch/OPS/Test/Block/PlaceformTest.php +74 -0
- app/code/community/Netresearch/OPS/Test/Block/System/Config/KwixoconfigurationTest.php +24 -0
- app/code/community/Netresearch/OPS/Test/Block/System/Config/ModeTest.php +20 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/AdminControllerTest.php +80 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixocategoryControllerTest.php +45 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixocategoryControllerTest/fixtures/category_mapping.yaml +11 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixoshippingControllerTest.php +148 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixoshippingControllerTest/fixtures/shipping_settings.yaml +7 -0
- app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/OpsstatusControllerTest.php +71 -0
- app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest.php +106 -0
- app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest/fixtures/orders.yaml +595 -0
- app/code/community/Netresearch/OPS/Test/Controller/ApiControllerTest.php +165 -0
- app/code/community/Netresearch/OPS/Test/Controller/DeviceControllerTest.php +66 -0
- app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest.php +246 -0
- app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/AliasTest.php +733 -0
- app/code/community/Netresearch/OPS/Test/Helper/AliasTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/ApiTest.php +52 -0
- app/code/community/Netresearch/OPS/Test/Helper/DataTest.php +174 -0
- app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest.php +501 -0
- app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest.php +544 -0
- app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/KwixoTest.php +132 -0
- app/code/community/Netresearch/OPS/Test/Helper/KwixoTest/fixtures/category_mapping.yaml +11 -0
- app/code/community/Netresearch/OPS/Test/Helper/Order/CaptureTest.php +82 -0
- app/code/community/Netresearch/OPS/Test/Helper/Order/CaptureTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/Order/RefundTest.php +141 -0
- app/code/community/Netresearch/OPS/Test/Helper/Order/RefundTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/OrderTest.php +137 -0
- app/code/community/Netresearch/OPS/Test/Helper/OrderTest/fixtures/order.yaml +42 -0
- app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest.php +89 -0
- app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/Payment/RequestTest.php +320 -0
- app/code/community/Netresearch/OPS/Test/Helper/PaymentTest.php +777 -0
- app/code/community/Netresearch/OPS/Test/Helper/PaymentTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Helper/QuoteTest.php +176 -0
- app/code/community/Netresearch/OPS/Test/Helper/QuoteTest/fixtures/.gitkeep +1 -0
- app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest.php +115 -0
- app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest/fixtures/profile.yaml +11 -0
- app/code/community/Netresearch/OPS/Test/Helper/Validation/Checkout/StepTest.php +44 -0
- app/code/community/Netresearch/OPS/Test/Helper/Validation/ResultTest.php +94 -0
- app/code/community/Netresearch/OPS/Test/Helper/Validation/ResultTest/fixtures/quotes.yaml +42 -0
- app/code/community/Netresearch/OPS/Test/Helper/VersionTest.php +92 -0
- app/code/community/Netresearch/OPS/Test/Model/AliasTest/fixtures/.gitkeep +0 -0
- app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkShaTest.php +44 -0
- app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkTest.php +214 -0
app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Edit/Tab/Alias.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Block_Adminhtml_Customer_Edit_Tab_Alias
|
13 |
+
*
|
14 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
15 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
class Netresearch_OPS_Block_Adminhtml_Customer_Edit_Tab_Alias
|
20 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
21 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
22 |
+
{
|
23 |
+
public function _construct()
|
24 |
+
{
|
25 |
+
parent::_construct();
|
26 |
+
$this->setId('customer_edit_tab_ops_alias');
|
27 |
+
$this->setUseAjax(true);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Return Tab label
|
32 |
+
*
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getTabLabel()
|
36 |
+
{
|
37 |
+
return $this->__('Payment Information');
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Return Tab label
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getTabTitle()
|
46 |
+
{
|
47 |
+
return $this->__('Payment Information');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Can show tab in tabs
|
52 |
+
*
|
53 |
+
* @return boolean
|
54 |
+
*/
|
55 |
+
public function canShowTab()
|
56 |
+
{
|
57 |
+
$customer = Mage::registry('current_customer');
|
58 |
+
return (bool)$customer->getId();
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Tab is hidden
|
63 |
+
*
|
64 |
+
* @return boolean
|
65 |
+
*/
|
66 |
+
public function isHidden()
|
67 |
+
{
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Defines after which tab, this tab should be rendered
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function getAfter()
|
77 |
+
{
|
78 |
+
return 'orders';
|
79 |
+
}
|
80 |
+
|
81 |
+
/*
|
82 |
+
* Retrieves Grid Url
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function getGridUrl()
|
87 |
+
{
|
88 |
+
//return $this->getUrl('*/ops/customer', array('_current'=>true));
|
89 |
+
}
|
90 |
+
|
91 |
+
protected function _prepareCollection()
|
92 |
+
{
|
93 |
+
$customer = Mage::registry('current_customer');
|
94 |
+
|
95 |
+
$collection = Mage::getModel('ops/alias')
|
96 |
+
->getCollection()
|
97 |
+
->addFieldToFilter('customer_id', $customer->getId());
|
98 |
+
|
99 |
+
$this->setCollection($collection);
|
100 |
+
return parent::_prepareCollection();
|
101 |
+
}
|
102 |
+
|
103 |
+
protected function _prepareColumns()
|
104 |
+
{
|
105 |
+
$this->addColumn('alias', array(
|
106 |
+
'header' => Mage::helper('ops')->__('Alias'),
|
107 |
+
'align' => 'right',
|
108 |
+
'index' => 'alias',
|
109 |
+
));
|
110 |
+
|
111 |
+
$this->addColumn('payment_method', array(
|
112 |
+
'header' => Mage::helper('ops')->__('Payment method'),
|
113 |
+
'index' => 'payment_method',
|
114 |
+
'renderer' => 'Netresearch_OPS_Block_Adminhtml_Customer_Renderer_PaymentMethod'
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('brand', array(
|
118 |
+
'header' => Mage::helper('ops')->__('Credit Card Type'),
|
119 |
+
'index' => 'brand',
|
120 |
+
));
|
121 |
+
|
122 |
+
$this->addColumn('pseudo_account_or_cc_no', array(
|
123 |
+
'header' => Mage::helper('ops')->__('Card Number/Account Number'),
|
124 |
+
'index' => 'pseudo_account_or_cc_no',
|
125 |
+
));
|
126 |
+
|
127 |
+
$this->addColumn('expiration_date', array(
|
128 |
+
'header' => Mage::helper('ops')->__('Expiration Date'),
|
129 |
+
'index' => 'expiration_date',
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('card_holder', array(
|
133 |
+
'header' => Mage::helper('ops')->__('Card Holder'),
|
134 |
+
'index' => 'card_holder',
|
135 |
+
));
|
136 |
+
|
137 |
+
$this->addColumn('state', array(
|
138 |
+
'header' => Mage::helper('ops')->__('State'),
|
139 |
+
'index' => 'state',
|
140 |
+
'renderer' => 'Netresearch_OPS_Block_Adminhtml_Customer_Renderer_State',
|
141 |
+
));
|
142 |
+
|
143 |
+
$this->addColumn('action',
|
144 |
+
array(
|
145 |
+
'header' => Mage::helper('ops')->__('Action'),
|
146 |
+
'width' => '100',
|
147 |
+
'type' => 'action',
|
148 |
+
'getter' => 'getId',
|
149 |
+
'actions' => array(
|
150 |
+
array(
|
151 |
+
'caption' => Mage::helper('ops')->__('Delete'),
|
152 |
+
'url' => array('base' => 'adminhtml/alias/delete'),
|
153 |
+
'field' => 'id'
|
154 |
+
)
|
155 |
+
),
|
156 |
+
'filter' => false,
|
157 |
+
'sortable' => false,
|
158 |
+
'index' => 'stores',
|
159 |
+
'is_system' => true,
|
160 |
+
));
|
161 |
+
|
162 |
+
return parent::_prepareColumns();
|
163 |
+
}
|
164 |
+
|
165 |
+
public function getRowUrl($row)
|
166 |
+
{
|
167 |
+
//return $this->getUrl('*/customer/edit', array('id' => $row->getId()));
|
168 |
+
}
|
169 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/PaymentMethod.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* PaymentMethod.php
|
5 |
+
*
|
6 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
7 |
+
*/
|
8 |
+
class Netresearch_OPS_Block_Adminhtml_Customer_Renderer_PaymentMethod
|
9 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
public function render(Varien_Object $row)
|
13 |
+
{
|
14 |
+
$methodCode = $row->getData($this->getColumn()->getIndex());
|
15 |
+
$instance = Mage::helper('payment')->getMethodInstance($methodCode);
|
16 |
+
if ($instance) {
|
17 |
+
return $instance->getTitle();
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Customer/Renderer/State.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* To change this template, choose Tools | Templates
|
4 |
+
* and open the template in the editor.
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Description of State
|
9 |
+
*
|
10 |
+
* @author sebastian
|
11 |
+
*/
|
12 |
+
class Netresearch_OPS_Block_Adminhtml_Customer_Renderer_State extends
|
13 |
+
Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
public function render(Varien_Object $row)
|
17 |
+
{
|
18 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
19 |
+
return Mage::helper('ops')->__($value);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixo/Shipping/Edit.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Block_Adminhtml_Kwixo_Shipping_Edit
|
12 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
13 |
+
{
|
14 |
+
|
15 |
+
|
16 |
+
private $kwixoShippingModel = null;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* gets the form action url
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getFormActionUrl()
|
24 |
+
{
|
25 |
+
return $this->getUrl('adminhtml/kwixoshipping/save');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* gets the shipping types
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getShippingMethods()
|
34 |
+
{
|
35 |
+
$methods = Mage::getSingleton('shipping/config')->getAllCarriers();
|
36 |
+
$options = array();
|
37 |
+
|
38 |
+
foreach ($methods as $carrierCode => $carrier) {
|
39 |
+
if (!$title = Mage::getStoreConfig("carriers/$carrierCode/title")) {
|
40 |
+
$title = $carrierCode;
|
41 |
+
}
|
42 |
+
$values = $this->getValues($carrierCode);
|
43 |
+
$options[] = array('code' => $carrierCode, 'label' => $title, 'values' => $values);
|
44 |
+
}
|
45 |
+
|
46 |
+
return $options;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* returns the corresponding shipping method types
|
51 |
+
*
|
52 |
+
* @return array - the kwxixo Shipping method types
|
53 |
+
*/
|
54 |
+
public function getKwixoShippingTypes()
|
55 |
+
{
|
56 |
+
return Mage::getModel('ops/source_kwixo_shipMethodType')->toOptionArray();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getKwixoShippingSettingModel()
|
60 |
+
{
|
61 |
+
if (null === $this->kwxioShippingModel) {
|
62 |
+
$this->kwixoShippingModel = Mage::getModel('ops/kwixo_shipping_setting');
|
63 |
+
}
|
64 |
+
return $this->kwixoShippingModel;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
private function getValues($carrierCode)
|
69 |
+
{
|
70 |
+
$values = array(
|
71 |
+
'kwixo_shipping_type' => '',
|
72 |
+
'kwixo_shipping_speed' => '',
|
73 |
+
'kwixo_shipping_details' => ''
|
74 |
+
);
|
75 |
+
if (!is_null($this->getData('postData')) && array_key_exists($carrierCode, $this->getData('postData'))) {
|
76 |
+
$errorData = $this->getData('postData');
|
77 |
+
$values = $errorData[$carrierCode];
|
78 |
+
} else {
|
79 |
+
$values = $this->getKwixoShippingSettingModel()->load($carrierCode, 'shipping_code')->getData();
|
80 |
+
}
|
81 |
+
return $values;
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/CategoryTree.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Netresearch_OPS_Block_Adminhtml_Kwixocategory_CategoryTree
|
23 |
+
extends Mage_Adminhtml_Block_Catalog_Category_Tree
|
24 |
+
{
|
25 |
+
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->setTemplate('ops/categoriestree.phtml');
|
30 |
+
$this->setUseAjax(true);
|
31 |
+
$this->_withProductCount = false;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getSwitchTreeUrl()
|
35 |
+
{
|
36 |
+
return $this->getUrl("*/*/tree", array('_current' => true, 'store' => null, '_query' => false, 'id' => null, 'parent' => null));
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getNodesUrl()
|
40 |
+
{
|
41 |
+
return $this->getUrl('adminhtml/catalog_category/jsonTree');
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getEditUrl()
|
45 |
+
{
|
46 |
+
return $this->getUrl('*/*/edit', array('_current' => true, '_query' => false, 'id' => null, 'parent' => null));
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _getNodeJson($node, $level = 0)
|
50 |
+
{
|
51 |
+
$item = array();
|
52 |
+
$item['text'] = $this->buildNodeName($node);
|
53 |
+
//$rootForStores = in_array($node->getEntityId(), $this->getRootIds());
|
54 |
+
|
55 |
+
$item['id'] = $node->getId();
|
56 |
+
$item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
|
57 |
+
$item['store'] = (int) $this->getStore()->getId();
|
58 |
+
$item['path'] = $node->getData('path');
|
59 |
+
$item['allowDrop'] = false;
|
60 |
+
$item['allowDrag'] = false;
|
61 |
+
if ((int) $node->getChildrenCount() > 0) {
|
62 |
+
$item['children'] = array();
|
63 |
+
}
|
64 |
+
$isParent = $this->_isParentSelectedCategory($node);
|
65 |
+
if ($node->hasChildren()) {
|
66 |
+
$item['children'] = array();
|
67 |
+
if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
|
68 |
+
foreach ($node->getChildren() as $child) {
|
69 |
+
$item['children'][] = $this->_getNodeJson($child, $level + 1);
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
if ($isParent || $node->getLevel() < 2) {
|
75 |
+
$item['expanded'] = true;
|
76 |
+
}
|
77 |
+
return $item;
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _getProductTypeLabel($productTypeId)
|
81 |
+
{
|
82 |
+
$res = '';
|
83 |
+
$types = Mage::getModel('ops/source_kwixo_productCategories')->toOptionArray();
|
84 |
+
foreach ($types as $data) {
|
85 |
+
if ($data['value'] == $productTypeId) {
|
86 |
+
$res = $data['label'];
|
87 |
+
break;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
return $res;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function buildNodeName($node)
|
94 |
+
{
|
95 |
+
$result = $this->htmlEscape($node->getName());
|
96 |
+
return $result;
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/Edit.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Netresearch_OPS_Block_Adminhtml_Kwixocategory_Edit
|
28 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
29 |
+
{
|
30 |
+
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
parent::__construct();
|
34 |
+
$this->_objectId = 'id';
|
35 |
+
$this->_controller = 'adminhtml_kwixocategory';
|
36 |
+
$this->_blockGroup = 'ops';
|
37 |
+
$this->_mode = 'edit';
|
38 |
+
$this->_updateButton('save', 'label', $this->__('Save'));
|
39 |
+
$this->_updateButton('save', 'url', $this->getUrl('*/*/save'));
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getHeaderText()
|
44 |
+
{
|
45 |
+
$categoryId = (int) $this->getRequest()->getParam('id');
|
46 |
+
|
47 |
+
if ($categoryId <= 0) {
|
48 |
+
return Mage::helper('ops/data')->__('Categories configuration');
|
49 |
+
}
|
50 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
51 |
+
return Mage::helper('ops/data')->__("Categorie's %s configuration", $category->getName());
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getFormActionUrl()
|
55 |
+
{
|
56 |
+
return $this->getUrl('*/*/save');
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Kwixocategory/Edit/Form.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Block_Adminhtml_Kwixocategory_Edit_Form
|
3 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save'),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
));
|
13 |
+
|
14 |
+
$categoryId = (int) $this->getRequest()->getParam('id');
|
15 |
+
if ($categoryId <= 0) {
|
16 |
+
return parent::_prepareForm();
|
17 |
+
}
|
18 |
+
$kwixoCategoryMapping = Mage::getModel('ops/kwixo_category_mapping')->loadByCategoryId($categoryId);
|
19 |
+
$storeId = (int) $this->getRequest()->getParam('store');
|
20 |
+
|
21 |
+
$fieldset = $form->addFieldset('ops_form', array('legend' => Mage::helper('ops/data')->__('Categories configuration')));
|
22 |
+
|
23 |
+
$fieldset->addField('storeId', 'hidden', array(
|
24 |
+
'required' => true,
|
25 |
+
'name' => 'storeId',
|
26 |
+
'value' => $storeId,
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('id', 'hidden', array(
|
30 |
+
'required' => false,
|
31 |
+
'name' => 'id',
|
32 |
+
'value' => $kwixoCategoryMapping->getId(),
|
33 |
+
));
|
34 |
+
$fieldset->addField('category_id', 'hidden', array(
|
35 |
+
'required' => true,
|
36 |
+
'name' => 'category_id',
|
37 |
+
'value' => $categoryId,
|
38 |
+
));
|
39 |
+
|
40 |
+
$fieldset->addField('kwixoCategory_id', 'select', array(
|
41 |
+
'label' => Mage::Helper('ops/data')->__('Kwixo category'),
|
42 |
+
'class' => 'required-entry',
|
43 |
+
'required' => true,
|
44 |
+
'name' => 'kwixoCategory_id',
|
45 |
+
'value' => $kwixoCategoryMapping->getKwixoCategoryId(),
|
46 |
+
'values' => Mage::getModel('ops/source_kwixo_productCategories')->toOptionArray()
|
47 |
+
));
|
48 |
+
|
49 |
+
$fieldset->addField('applysubcat', 'checkbox', array(
|
50 |
+
'label' => Mage::Helper('ops/data')->__('Apply to sub-categories'),
|
51 |
+
'name' => 'applysubcat'
|
52 |
+
));
|
53 |
+
|
54 |
+
$form->setUseContainer(true);
|
55 |
+
$this->setForm($form);
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/ClosedTransaction/Warning.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Netresearch_OPS_Block_Adminhtml_Sales_Order_Creditmemo_Create_Adjustments_Checkbox
|
12 |
+
*
|
13 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
14 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Netresearch_OPS_Block_Adminhtml_Sales_Order_Creditmemo_ClosedTransaction_Warning
|
19 |
+
extends Mage_Core_Block_Template
|
20 |
+
{
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Internal constructor, that is called from real constructor.
|
24 |
+
*
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
parent::_construct();
|
30 |
+
$this->setTemplate('ops/sales/order/creditmemo/closed-transaction/warning.phtml');
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Netresearch/OPS/Block/Adminhtml/Sales/Order/Creditmemo/Totals/Checkbox.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Netresearch_OPS_Block_Adminhtml_Sales_Order_Creditmemo_Create_Adjustments_Checkbox
|
12 |
+
*
|
13 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
14 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Netresearch_OPS_Block_Adminhtml_Sales_Order_Creditmemo_Totals_Checkbox
|
19 |
+
extends Mage_Core_Block_Template
|
20 |
+
{
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Internal constructor, that is called from real constructor.
|
24 |
+
*
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
parent::_construct();
|
30 |
+
$this->setTemplate('ops/sales/order/creditmemo/totals/checkbox.phtml');
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Netresearch/OPS/Block/Alias/List.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Block_Alias_List
|
13 |
+
*
|
14 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
15 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
class Netresearch_OPS_Block_Alias_List
|
20 |
+
extends Mage_Core_Block_Template
|
21 |
+
{
|
22 |
+
public function getAliases()
|
23 |
+
{
|
24 |
+
$aliases = array();
|
25 |
+
$customer = Mage::helper('customer')->getCustomer();
|
26 |
+
if (0 < $customer->getId()) {
|
27 |
+
$aliasesCollection = Mage::helper('ops/alias')->getAliasesForCustomer($customer->getId());
|
28 |
+
foreach ($aliasesCollection as $alias) {
|
29 |
+
$aliases[] = $alias;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
return $aliases;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* get human readable name of payment method
|
37 |
+
*
|
38 |
+
* @param string $methodCode Code of payment method
|
39 |
+
* @return string Name of payment method
|
40 |
+
*/
|
41 |
+
public function getMethodName($methodCode)
|
42 |
+
{
|
43 |
+
$instance = Mage::helper('payment')->getMethodInstance($methodCode);
|
44 |
+
if ($instance) {
|
45 |
+
return $instance->getTitle();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* retrieves the url for deletion the alias
|
51 |
+
*
|
52 |
+
* @param $aliasId - the id of the alias
|
53 |
+
*
|
54 |
+
* @return string - the url for deleting the alias with the given id
|
55 |
+
*/
|
56 |
+
public function getAliasDeleteUrl($aliasId)
|
57 |
+
{
|
58 |
+
return Mage::getUrl(
|
59 |
+
'ops/customer/deleteAlias/',
|
60 |
+
array(
|
61 |
+
'id' => $aliasId,
|
62 |
+
'_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
|
63 |
+
)
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Netresearch/OPS/Block/Checkout/DeviceFingerprinting.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* PHP version 5
|
18 |
+
*
|
19 |
+
* @category Netresearch
|
20 |
+
* @package Netresearch_OPS
|
21 |
+
* @author Christoph Aßmann <christoph.assmann@netresearch.de>
|
22 |
+
* @copyright 2016 Netresearch GmbH & Co. KG
|
23 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
24 |
+
* @link http://www.netresearch.de/
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Netresearch_OPS_Block_Checkout_DeviceFingerprinting
|
29 |
+
*
|
30 |
+
* @category Netresearch
|
31 |
+
* @package Netresearch_OPS
|
32 |
+
* @author Christoph Aßmann <christoph.assmann@netresearch.de>
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
* @link http://www.netresearch.de/
|
35 |
+
*/
|
36 |
+
class Netresearch_OPS_Block_Checkout_DeviceFingerprinting
|
37 |
+
extends Mage_Core_Block_Template
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
protected $_template = 'ops/checkout/deviceFingerprinting.phtml';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return Mage_Core_Block_Abstract
|
46 |
+
*/
|
47 |
+
protected function _prepareLayout()
|
48 |
+
{
|
49 |
+
if (Mage::getModel('ops/config')->getDeviceFingerPrinting()) {
|
50 |
+
/** @var Mage_Page_Block_Html_Head $headBlock */
|
51 |
+
$headBlock = $this->getLayout()->getBlock('head');
|
52 |
+
if ($headBlock) {
|
53 |
+
$headBlock->addJs('netresearch/ops/deviceFingerprinting.js');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return parent::_prepareLayout();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
protected function _toHtml()
|
64 |
+
{
|
65 |
+
if (!Mage::getModel('ops/config')->getDeviceFingerPrinting()) {
|
66 |
+
return '';
|
67 |
+
}
|
68 |
+
|
69 |
+
return parent::_toHtml();
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function getConsentUrl()
|
76 |
+
{
|
77 |
+
return $this->getUrl('ops/device');
|
78 |
+
}
|
79 |
+
}
|
app/code/community/Netresearch/OPS/Block/Checkout/SubscriptionNotice.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* SubscriptionNotice.php
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*
|
29 |
+
*
|
30 |
+
* @method Netresearch_OPS_Block_Checkout_SubscriptionNotice setProfile(Mage_Catalog_Model_Product $product)
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
class Netresearch_OPS_Block_Checkout_SubscriptionNotice extends Mage_Core_Block_Template
|
34 |
+
{
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Returns the quotes nominal items product
|
38 |
+
*
|
39 |
+
* @return Mage_Sales_Model_Recurring_Profile
|
40 |
+
*/
|
41 |
+
public function getProfile()
|
42 |
+
{
|
43 |
+
if (!$this->hasData('profile')) {
|
44 |
+
/** @var Mage_Sales_Model_Quote_Item $item */
|
45 |
+
foreach ($this->getQuote()->getAllItems() as $item) {
|
46 |
+
$product = $item->getProduct();
|
47 |
+
if (is_object($product) && $product->isRecurring()
|
48 |
+
&& $profile = Mage::getModel('sales/recurring_profile')->importProduct($product)
|
49 |
+
) {
|
50 |
+
$profile->importQuote($this->getQuote());
|
51 |
+
$profile->importQuoteItem($item);
|
52 |
+
$this->setProfile($profile);
|
53 |
+
break;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->getData('profile');
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get checkout session quote
|
63 |
+
*
|
64 |
+
* @return Mage_Sales_Model_Quote
|
65 |
+
*/
|
66 |
+
public function getQuote()
|
67 |
+
{
|
68 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Checks wether the recurring profile has a trial period specified
|
73 |
+
*
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function hasTrial()
|
77 |
+
{
|
78 |
+
return (bool)$this->getProfile()->getTrialPeriodUnit();
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Checks wether the recurring profile has an initial fee specified
|
83 |
+
*
|
84 |
+
* @return bool
|
85 |
+
*/
|
86 |
+
public function hasInitialFee()
|
87 |
+
{
|
88 |
+
return $this->getProfile()->getInitAmount() > 0;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @return string
|
93 |
+
*/
|
94 |
+
public function getInitialFeeText()
|
95 |
+
{
|
96 |
+
return $this->__('You will be charged an initial amount of %s.',
|
97 |
+
$this->helper('checkout')->formatPrice($this->getProfile()->getInitAmount())
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
public function getTrialSubscriptionText()
|
105 |
+
{
|
106 |
+
$profile = $this->getProfile();
|
107 |
+
|
108 |
+
return $this->__('A trial subscription will be created. This will charge you %s every %s %s until %s.',
|
109 |
+
$this->helper('checkout')->formatPrice(
|
110 |
+
$profile->getTrialBillingAmount() + $profile->getShippingAmount()
|
111 |
+
),
|
112 |
+
$profile->getTrialPeriodFrequency(),
|
113 |
+
$profile->getPeriodUnitLabel($profile->getTrialPeriodUnit()),
|
114 |
+
$this->localizeDate($this->getTrialSubscriptionEndDate())
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public function getRegularSubscriptionText()
|
122 |
+
{
|
123 |
+
$profile = $this->getProfile();
|
124 |
+
|
125 |
+
$message = $this->__('A subscription will be created. This will charge you %s every %s %s.',
|
126 |
+
$this->helper('checkout')->formatPrice(
|
127 |
+
$profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount()
|
128 |
+
),
|
129 |
+
$profile->getPeriodFrequency(),
|
130 |
+
$profile->getPeriodUnitLabel($profile->getPeriodUnit())
|
131 |
+
);
|
132 |
+
|
133 |
+
if($this->getRegularSubscriptionEndDate()){
|
134 |
+
$message .= $this->__(' The subscription will end on %s.',
|
135 |
+
$this->localizeDate($this->getRegularSubscriptionEndDate()));
|
136 |
+
}
|
137 |
+
return $message;
|
138 |
+
}
|
139 |
+
|
140 |
+
public function getCancelInformationText()
|
141 |
+
{
|
142 |
+
return $this->__('To cancel the subscription, please send an email to the shop owner' .
|
143 |
+
' or request this by clicking the suspend button on the subscriptions detail view in your customer account.'
|
144 |
+
. ' A link to that page will be displayed on the checkout success page.'
|
145 |
+
);
|
146 |
+
}
|
147 |
+
|
148 |
+
public function displayNotice()
|
149 |
+
{
|
150 |
+
$result = true;
|
151 |
+
if (!$this->getProfile()
|
152 |
+
|| $this->getQuote()->getPayment()->getMethod() != Netresearch_OPS_Model_Payment_Recurring_Cc::CODE
|
153 |
+
) {
|
154 |
+
$result = false;
|
155 |
+
}
|
156 |
+
|
157 |
+
return $result;
|
158 |
+
}
|
159 |
+
|
160 |
+
protected function getTrialSubscriptionEndDate()
|
161 |
+
{
|
162 |
+
/** @var Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $parameterModel */
|
163 |
+
$parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
|
164 |
+
$enddate = null;
|
165 |
+
$startDate = new DateTime($this->getProfile()->getStartDatetime());
|
166 |
+
$enddate = $parameterModel->calculateEndDate($startDate, $this->getProfile()->getTrialPeriodUnit(),
|
167 |
+
$this->getProfile()->getTrialPeriodFrequency(), $this->getProfile()->getTrialPeriodMaxCycles()
|
168 |
+
);
|
169 |
+
|
170 |
+
return $enddate;
|
171 |
+
}
|
172 |
+
|
173 |
+
protected function getRegularSubscriptionEndDate()
|
174 |
+
{
|
175 |
+
$parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
|
176 |
+
$enddate = null;
|
177 |
+
if ($this->hasTrial()) {
|
178 |
+
$startDate = $this->getTrialSubscriptionEndDate();
|
179 |
+
} else {
|
180 |
+
$startDate = new DateTime($this->getProfile()->getStartDatetime());
|
181 |
+
}
|
182 |
+
$enddate = $parameterModel->calculateEndDate($startDate, $this->getProfile()->getPeriodUnit(),
|
183 |
+
$this->getProfile()->getPeriodFrequency(), $this->getProfile()->getPeriodMaxCycles()
|
184 |
+
);
|
185 |
+
|
186 |
+
return $enddate;
|
187 |
+
}
|
188 |
+
|
189 |
+
protected function localizeDate(DateTime $date){
|
190 |
+
$date = new Zend_Date($date->getTimestamp());
|
191 |
+
return Mage::helper('core')->formatDate($date);
|
192 |
+
}
|
193 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Netresearch_OPS_Block_Form extends Mage_Payment_Block_Form_Cc
|
28 |
+
{
|
29 |
+
|
30 |
+
protected $pmLogo = null;
|
31 |
+
|
32 |
+
protected $fieldMapping = array();
|
33 |
+
|
34 |
+
protected $config = null;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Frontend Payment Template
|
38 |
+
*/
|
39 |
+
const FRONTEND_TEMPLATE = 'ops/form.phtml';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Init OPS payment form
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
protected function _construct()
|
46 |
+
{
|
47 |
+
parent::_construct();
|
48 |
+
$this->setTemplate(self::FRONTEND_TEMPLATE);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* get OPS config
|
53 |
+
*
|
54 |
+
* @return Netresearch_Ops_Model_Config
|
55 |
+
*/
|
56 |
+
public function getConfig()
|
57 |
+
{
|
58 |
+
if (null === $this->config) {
|
59 |
+
$this->config = Mage::getSingleton('ops/config');
|
60 |
+
}
|
61 |
+
|
62 |
+
return $this->config;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param Netresearch_OPS_Model_Config $config
|
67 |
+
* @return $this
|
68 |
+
*/
|
69 |
+
public function setConfig(Netresearch_OPS_Model_Config $config)
|
70 |
+
{
|
71 |
+
$this->config = $config;
|
72 |
+
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return Mage_Sales_Model_Quote
|
78 |
+
*/
|
79 |
+
public function getQuote()
|
80 |
+
{
|
81 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
public function getDirectDebitCountryIds()
|
88 |
+
{
|
89 |
+
return explode(',', $this->getConfig()->getDirectDebitCountryIds());
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getBankTransferCountryIds()
|
93 |
+
{
|
94 |
+
return explode(',', $this->getConfig()->getBankTransferCountryIds());
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @param null $storeId
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function getPSPID($storeId = null)
|
102 |
+
{
|
103 |
+
return Mage::getModel('ops/config')->getPSPID($storeId);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param null $storeId
|
108 |
+
* @param bool $admin
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function getGenerateHashUrl($storeId = null, $admin = false)
|
112 |
+
{
|
113 |
+
return Mage::getModel('ops/config')->getGenerateHashUrl($storeId, $admin);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function getValidationUrl()
|
120 |
+
{
|
121 |
+
return Mage::getModel('ops/config')->getValidationUrl();
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @return array
|
126 |
+
*/
|
127 |
+
public function getDirectEbankingBrands()
|
128 |
+
{
|
129 |
+
return explode(',', $this->getConfig()->getDirectEbankingBrands());
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* wrapper for Netresearch_OPS_Helper_Data::checkIfUserRegistering
|
135 |
+
*
|
136 |
+
* @return type bool
|
137 |
+
*/
|
138 |
+
public function isUserRegistering()
|
139 |
+
{
|
140 |
+
return Mage::Helper('ops/data')->checkIfUserIsRegistering();
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* wrapper for Netresearch_OPS_Helper_Data::checkIfUserRegistering
|
145 |
+
*
|
146 |
+
* @return type bool
|
147 |
+
*/
|
148 |
+
public function isUserNotRegistering()
|
149 |
+
{
|
150 |
+
return Mage::Helper('ops/data')->checkIfUserIsNotRegistering();
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
public function getPmLogo()
|
157 |
+
{
|
158 |
+
return $this->pmLogo;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @return Simple_Xml
|
163 |
+
*/
|
164 |
+
protected function getFieldMapping()
|
165 |
+
{
|
166 |
+
return $this->getConfig()->getFrontendFieldMapping();
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* returns the corresponding fields for frontend validation if needed
|
171 |
+
*
|
172 |
+
* @return string - the json encoded fields
|
173 |
+
*/
|
174 |
+
public function getFrontendValidators()
|
175 |
+
{
|
176 |
+
$frontendFields = array();
|
177 |
+
if ($this->getConfig()->canSubmitExtraParameter($this->getQuote()->getStoreId())) {
|
178 |
+
$fieldsToValidate = $this->getConfig()->getParameterLengths();
|
179 |
+
$mappedFields = $this->getFieldMapping();
|
180 |
+
foreach ($fieldsToValidate as $key => $value) {
|
181 |
+
if (array_key_exists($key, $mappedFields)) {
|
182 |
+
$frontendFields = $this->getFrontendValidationFields($mappedFields, $key, $value, $frontendFields);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
return Mage::helper('core/data')->jsonEncode($frontendFields);
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @param $mappedFields
|
192 |
+
* @param $key
|
193 |
+
* @param $value
|
194 |
+
* @param $frontendFields
|
195 |
+
*
|
196 |
+
* @return mixed
|
197 |
+
*/
|
198 |
+
public function getFrontendValidationFields($mappedFields, $key, $value, $frontendFields)
|
199 |
+
{
|
200 |
+
if (!is_array($mappedFields[$key])) {
|
201 |
+
$frontendFields[$mappedFields[$key]] = $value;
|
202 |
+
} else {
|
203 |
+
foreach ($mappedFields[$key] as $mKey) {
|
204 |
+
$frontendFields[$mKey] = $value;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
return $frontendFields;
|
209 |
+
}
|
210 |
+
|
211 |
+
public function getImageForBrand($brand)
|
212 |
+
{
|
213 |
+
$brandName = str_replace(' ', '', $brand);
|
214 |
+
return $this->getSkinUrl('images/ops/alias/brands/'. $brandName .'.png');
|
215 |
+
}
|
216 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Alias.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Block_Form_Alias
|
13 |
+
*
|
14 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
15 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
class Netresearch_OPS_Block_Form_Alias extends Netresearch_OPS_Block_Form
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('ops/form/alias.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* get available aliases for current customer
|
29 |
+
* will return empty array if there is no current user
|
30 |
+
*
|
31 |
+
* @return array|Netresearch_OPS_Model_Mysql4_Alias_Collection
|
32 |
+
*/
|
33 |
+
public function getAvailableAliases()
|
34 |
+
{
|
35 |
+
$customer = Mage::helper('customer')->getCustomer();
|
36 |
+
if (0 < $customer->getId()) {
|
37 |
+
$quote = Mage::helper('ops/payment')->getQuote();
|
38 |
+
return Mage::helper('ops/payment')->getAliasesForCustomer($customer->getId(), $quote);
|
39 |
+
}
|
40 |
+
return array();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @param String $alias- the human readable alias
|
46 |
+
*/
|
47 |
+
protected function getHumanReadableAlias($alias)
|
48 |
+
{
|
49 |
+
$helper = Mage::helper('ops');
|
50 |
+
$aliasString = $helper->__('Credit Card Type') . ' ' . $helper->__($alias->getBrand());
|
51 |
+
$aliasString .= ' ' . $helper->__('AccountNo') . ' ' . $helper->__($alias->getPseudoAccountOrCCNo());
|
52 |
+
$aliasString .= ' ' . $helper->__('Expiration Date') . ' ' . $alias->getExpirationDate();
|
53 |
+
return $aliasString;
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Cc.php
ADDED
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Block_Form_OpsId
|
5 |
+
*
|
6 |
+
* @package OPS
|
7 |
+
* @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
|
8 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Block_Form_Cc extends Netresearch_OPS_Block_Form
|
12 |
+
{
|
13 |
+
|
14 |
+
private $aliasDataForCustomer = array();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* CC Payment Template
|
18 |
+
*/
|
19 |
+
const FRONTEND_TEMPLATE = 'ops/form/cc.phtml';
|
20 |
+
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate(self::FRONTEND_TEMPLATE);
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* gets all Alias CC brands
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getAliasBrands()
|
34 |
+
{
|
35 |
+
return Mage::getModel('ops/source_cc_aliasInterfaceEnabledTypes')
|
36 |
+
->getAliasInterfaceCompatibleTypes();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @param null $storeId
|
41 |
+
* @param bool $admin
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getAliasAcceptUrl($storeId = null, $admin = false)
|
46 |
+
{
|
47 |
+
return Mage::getModel('ops/config')->getAliasAcceptUrl($storeId, $admin);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param null $storeId
|
52 |
+
* @param bool $admin
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getAliasExceptionUrl($storeId = null, $admin = false)
|
57 |
+
{
|
58 |
+
return Mage::getModel('ops/config')->getAliasExceptionUrl($storeId, $admin);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param null $storeId
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getAliasGatewayUrl($storeId = null)
|
67 |
+
{
|
68 |
+
return Mage::getModel('ops/config')->getAliasGatewayUrl($storeId);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function getSaveCcBrandUrl()
|
75 |
+
{
|
76 |
+
return Mage::getModel('ops/config')->getSaveCcBrandUrl();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param null $storeId
|
81 |
+
* @param bool $admin
|
82 |
+
*
|
83 |
+
* @return mixed
|
84 |
+
*/
|
85 |
+
public function getCcSaveAliasUrl($storeId = null, $admin = false)
|
86 |
+
{
|
87 |
+
return Mage::getModel('ops/config')->getCcSaveAliasUrl($storeId, $admin);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* checks if the 'alias' payment method (!) is available
|
92 |
+
* no check for customer has aliases here
|
93 |
+
* just a passthrough of the isAvailable of Netresearch_OPS_Model_Payment_Abstract::isAvailable
|
94 |
+
*
|
95 |
+
* @return boolean
|
96 |
+
*/
|
97 |
+
public function isAliasPMEnabled()
|
98 |
+
{
|
99 |
+
return Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode());
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* retrieves the alias data for the logged in customer
|
105 |
+
*
|
106 |
+
* @return array | null - array the alias data or null if the customer
|
107 |
+
* is not logged in
|
108 |
+
*/
|
109 |
+
protected function getStoredAliasForCustomer()
|
110 |
+
{
|
111 |
+
if (Mage::helper('customer/data')->isLoggedIn()
|
112 |
+
&& Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode())
|
113 |
+
) {
|
114 |
+
$quote = $this->getQuote();
|
115 |
+
$aliases = Mage::helper('ops/alias')->getAliasesForAddresses(
|
116 |
+
$quote->getCustomer()->getId(), $quote->getBillingAddress(),
|
117 |
+
$quote->getShippingAddress(), $quote->getStoreId()
|
118 |
+
)
|
119 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
|
120 |
+
->addFieldToFilter('payment_method', $this->getMethodCode())
|
121 |
+
->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
|
122 |
+
|
123 |
+
|
124 |
+
foreach ($aliases as $key => $alias) {
|
125 |
+
$this->aliasDataForCustomer[$key] = $alias;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return $this->aliasDataForCustomer;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* retrieves single values to given keys from the alias data
|
135 |
+
*
|
136 |
+
* @param $aliasId
|
137 |
+
* @param $key - string the key for the alias data
|
138 |
+
*
|
139 |
+
* @return null|string - null if key is not set in the alias data, otherwise
|
140 |
+
* the value for the given key from the alias data
|
141 |
+
*/
|
142 |
+
protected function getStoredAliasDataForCustomer($aliasId, $key)
|
143 |
+
{
|
144 |
+
$returnValue = null;
|
145 |
+
$aliasData = array();
|
146 |
+
|
147 |
+
if (empty($this->aliasDataForCustomer)) {
|
148 |
+
$aliasData = $this->getStoredAliasForCustomer();
|
149 |
+
} else {
|
150 |
+
$aliasData = $this->aliasDataForCustomer;
|
151 |
+
}
|
152 |
+
|
153 |
+
if (array_key_exists($aliasId, $aliasData) && $aliasData[$aliasId]->hasData($key)) {
|
154 |
+
$returnValue = $aliasData[$aliasId]->getData($key);
|
155 |
+
}
|
156 |
+
|
157 |
+
return $returnValue;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* retrieves the given path (month or year) from stored expiration date
|
162 |
+
*
|
163 |
+
* @param $key - the requested path
|
164 |
+
*
|
165 |
+
* @return null | string the extracted part of the date
|
166 |
+
*/
|
167 |
+
public function getExpirationDatePart($aliasId, $key)
|
168 |
+
{
|
169 |
+
$returnValue = null;
|
170 |
+
$expirationDate = $this->getStoredAliasDataForCustomer($aliasId, 'expiration_date');
|
171 |
+
// set expiration date to actual date if no stored Alias is used
|
172 |
+
if ($expirationDate === null) {
|
173 |
+
$expirationDate = date('my');
|
174 |
+
}
|
175 |
+
|
176 |
+
if (0 < strlen(trim($expirationDate))
|
177 |
+
) {
|
178 |
+
$expirationDateValues = str_split($expirationDate, 2);
|
179 |
+
|
180 |
+
if ($key == 'month') {
|
181 |
+
$returnValue = $expirationDateValues[0];
|
182 |
+
}
|
183 |
+
if ($key == 'year') {
|
184 |
+
$returnValue = $expirationDateValues[1];
|
185 |
+
}
|
186 |
+
|
187 |
+
if ($key == 'complete') {
|
188 |
+
$returnValue = implode('/', $expirationDateValues);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
return $returnValue;
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* retrieves the masked alias card number and formats it in a card specific format
|
198 |
+
*
|
199 |
+
* @return null|string - null if no alias data were found,
|
200 |
+
* otherwise the formatted card number
|
201 |
+
*/
|
202 |
+
public function getAliasCardNumber($aliasId)
|
203 |
+
{
|
204 |
+
$aliasCardNumber = $this->getStoredAliasDataForCustomer($aliasId, 'pseudo_account_or_cc_no');
|
205 |
+
if (0 < strlen(trim($aliasCardNumber))) {
|
206 |
+
$aliasCardNumber = Mage::helper('ops/alias')->formatAliasCardNo(
|
207 |
+
$this->getStoredAliasDataForCustomer($aliasId, 'brand'), $aliasCardNumber
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
return $aliasCardNumber;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @return null|string - the card holder either from alias data or
|
216 |
+
* the name from the the user who is logged in, null otherwise
|
217 |
+
*/
|
218 |
+
public function getCardHolderName($aliasId)
|
219 |
+
{
|
220 |
+
$cardHolderName = $this->getStoredAliasDataForCustomer($aliasId, 'card_holder');
|
221 |
+
$customerHelper = Mage::helper('customer/data');
|
222 |
+
if ((is_null($cardHolderName) || 0 === strlen(trim($cardHolderName)))
|
223 |
+
&& $customerHelper->isLoggedIn()
|
224 |
+
&& Mage::getModel('ops/config')->isAliasManagerEnabled($this->getMethodCode())
|
225 |
+
) {
|
226 |
+
$cardHolderName = $customerHelper->getCustomerName();
|
227 |
+
}
|
228 |
+
|
229 |
+
return $cardHolderName;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* the brand of the stored card data
|
234 |
+
*
|
235 |
+
* @return null|string - string if stored card data were found, null otherwise
|
236 |
+
*/
|
237 |
+
public function getStoredAliasBrand($aliasId)
|
238 |
+
{
|
239 |
+
$storedBrand = $this->getStoredAliasDataForCustomer($aliasId, 'brand');
|
240 |
+
$methodCode = $this->getMethodCode();
|
241 |
+
if (in_array($storedBrand, Mage::getModel('ops/config')->getInlinePaymentCcTypes($methodCode))) {
|
242 |
+
return $storedBrand;
|
243 |
+
}
|
244 |
+
|
245 |
+
return '';
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* determines whether the alias hint is shown to guests or not
|
250 |
+
*
|
251 |
+
* @return bool true if alias feature is enabled and display the hint to
|
252 |
+
* guests is enabled
|
253 |
+
*/
|
254 |
+
public function isAliasInfoBlockEnabled()
|
255 |
+
{
|
256 |
+
return ($this->isAliasPMEnabled()
|
257 |
+
&& Mage::getModel('ops/config')->isAliasInfoBlockEnabled());
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @return string[]
|
262 |
+
*/
|
263 |
+
public function getCcBrands()
|
264 |
+
{
|
265 |
+
return explode(',', $this->getConfig()->getAcceptedCcTypes($this->getMethodCode()));
|
266 |
+
}
|
267 |
+
|
268 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/DirectDebit.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Block_Form_DirectDebit
|
4 |
+
*
|
5 |
+
* @package OPS
|
6 |
+
* @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
|
7 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Block_Form_DirectDebit extends Netresearch_OPS_Block_Form
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $previousParams = array();
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Backend Payment Template
|
17 |
+
*/
|
18 |
+
const TEMPLATE = 'ops/form/directDebit.phtml';
|
19 |
+
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
$this->setTemplate(self::TEMPLATE);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* get ids of supported countries
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
public function getDirectDebitCountryIds()
|
32 |
+
{
|
33 |
+
return explode(',', $this->getConfig()->getDirectDebitCountryIds());
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* get previously entred params for displaying them again in the backend
|
38 |
+
*
|
39 |
+
* @return array - the previously entred params
|
40 |
+
*/
|
41 |
+
public function getParams()
|
42 |
+
{
|
43 |
+
$params = Mage::getModel('adminhtml/session')->getData(
|
44 |
+
'ops_direct_debit_params'
|
45 |
+
);
|
46 |
+
|
47 |
+
Mage::getModel('adminhtml/session')->unsetData(
|
48 |
+
'ops_direct_debit_params'
|
49 |
+
);
|
50 |
+
if (!is_array($params)) {
|
51 |
+
$params = array(
|
52 |
+
'country' => '',
|
53 |
+
'CN' => '',
|
54 |
+
'iban' => '',
|
55 |
+
'bic' => '',
|
56 |
+
'account' => '',
|
57 |
+
'bankcode' => ''
|
58 |
+
);
|
59 |
+
}
|
60 |
+
$this->previousParams = $params;
|
61 |
+
|
62 |
+
return $this->previousParams;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* checks if the iban field is required
|
67 |
+
*
|
68 |
+
* @return bool - true if so, false otherwise
|
69 |
+
*/
|
70 |
+
public function isIbanFieldRequired()
|
71 |
+
{
|
72 |
+
return (count($this->previousParams) == 0
|
73 |
+
|| (array_key_exists(
|
74 |
+
'iban', $this->previousParams
|
75 |
+
)
|
76 |
+
&& 0 < strlen('iban')
|
77 |
+
|| array_key_exists('account', $this->previousParams)
|
78 |
+
&& 0 == strlen($this->previousParams['account'])));
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* checks if the account field is required
|
83 |
+
*
|
84 |
+
* @return bool - true if so, false otherwise
|
85 |
+
*/
|
86 |
+
public function isAccountFieldRequired()
|
87 |
+
{
|
88 |
+
return (count($this->previousParams) == 0
|
89 |
+
|| (array_key_exists(
|
90 |
+
'account', $this->previousParams
|
91 |
+
)
|
92 |
+
&& (!array_key_exists('iban', $this->previousParams)
|
93 |
+
|| 0 == strlen($this->previousParams['iban']))));
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* checks if the bankcode field is required
|
100 |
+
*
|
101 |
+
* @return bool - true if so, false otherwise
|
102 |
+
*/
|
103 |
+
public function isBankCodeFieldRequired()
|
104 |
+
{
|
105 |
+
return $this->isAccountFieldRequired()
|
106 |
+
&& array_key_exists(
|
107 |
+
'country', $this->previousParams
|
108 |
+
)
|
109 |
+
&& ('DE' == strtoupper(
|
110 |
+
$this->getCountry())
|
111 |
+
|| 'AT' == strtoupper($this->getCountry())
|
112 |
+
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* checks if the bankcode field is visible
|
118 |
+
*
|
119 |
+
* @return bool - true if so, false otherwise
|
120 |
+
*/
|
121 |
+
public function isBankCodeFieldVisible()
|
122 |
+
{
|
123 |
+
return array_key_exists('country', $this->previousParams)
|
124 |
+
&& ('DE' == strtoupper($this->getCountry())
|
125 |
+
|| 'AT' == strtoupper($this->getCountry()));
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* checks if the bic field is visible
|
130 |
+
*
|
131 |
+
* @return bool - true if so, false otherwise
|
132 |
+
*/
|
133 |
+
public function isBicFieldVisible()
|
134 |
+
{
|
135 |
+
return ('NL' == strtoupper($this->getCountry()));
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* gets the previously entered country (if any)
|
140 |
+
*
|
141 |
+
* @return string - empty string if no country is given, otherwise the country
|
142 |
+
*/
|
143 |
+
public function getCountry()
|
144 |
+
{
|
145 |
+
$country = '';
|
146 |
+
if (array_key_exists('country', $this->previousParams)) {
|
147 |
+
$country = $this->previousParams['country'];
|
148 |
+
}
|
149 |
+
|
150 |
+
return $country;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* gets the previously entered iban (if any)
|
155 |
+
*
|
156 |
+
* @return string - empty string if no iban is given, otherwise the iban
|
157 |
+
*/
|
158 |
+
public function getIban()
|
159 |
+
{
|
160 |
+
$iban = '';
|
161 |
+
if (array_key_exists('iban', $this->previousParams)) {
|
162 |
+
$iban = $this->previousParams['iban'];
|
163 |
+
}
|
164 |
+
|
165 |
+
return $iban;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* gets the previously entered bic (if any)
|
170 |
+
*
|
171 |
+
* @return string - empty string if no bic is given, otherwise the bic
|
172 |
+
*/
|
173 |
+
public function getBic()
|
174 |
+
{
|
175 |
+
$bic = '';
|
176 |
+
if (array_key_exists('bic', $this->previousParams)) {
|
177 |
+
$bic = $this->previousParams['bic'];
|
178 |
+
}
|
179 |
+
|
180 |
+
return $bic;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* gets the previously entered account (if any)
|
185 |
+
*
|
186 |
+
* @return string - empty string if no account is given, otherwise the account
|
187 |
+
*/
|
188 |
+
public function getAccount()
|
189 |
+
{
|
190 |
+
$account = '';
|
191 |
+
if (array_key_exists('account', $this->previousParams)) {
|
192 |
+
$account = $this->previousParams['account'];
|
193 |
+
}
|
194 |
+
|
195 |
+
return $account;
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* gets the previously entered bankcode (if any)
|
200 |
+
*
|
201 |
+
* @return string - empty string if no bankcode is given, otherwise the bankcode
|
202 |
+
*/
|
203 |
+
public function getBankcode()
|
204 |
+
{
|
205 |
+
$bankcode = '';
|
206 |
+
if (array_key_exists('bankcode', $this->previousParams)) {
|
207 |
+
$bankcode = $this->previousParams['bankcode'];
|
208 |
+
}
|
209 |
+
|
210 |
+
return $bankcode;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* gets the previously entered card holder (if any)
|
215 |
+
* @param $aliasId - not used, but required by parent methods
|
216 |
+
*
|
217 |
+
* @return string - empty string if no card holder is given, otherwise the card holder
|
218 |
+
*/
|
219 |
+
public function getCardholderName($aliasId = null)
|
220 |
+
{
|
221 |
+
$cardholder = '';
|
222 |
+
if (array_key_exists('CN', $this->previousParams)) {
|
223 |
+
$cardholder = $this->previousParams['CN'];
|
224 |
+
}
|
225 |
+
|
226 |
+
return $cardholder;
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getRegisterDirectDebitPaymentUrl()
|
230 |
+
{
|
231 |
+
return Mage::getModel('ops/config')->getRegisterDirectDebitPaymentUrl();
|
232 |
+
}
|
233 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Flex.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Flex.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Block_Form_Flex extends Netresearch_OPS_Block_Form
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* @inheritDoc
|
36 |
+
*/
|
37 |
+
protected function _construct()
|
38 |
+
{
|
39 |
+
parent::_construct();
|
40 |
+
$this->setTemplate('ops/form/flex.phtml');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* get configurable payment methods
|
45 |
+
*
|
46 |
+
* @return string[][]
|
47 |
+
*/
|
48 |
+
public function getFlexMethods()
|
49 |
+
{
|
50 |
+
|
51 |
+
$methods = $this->getMethod()->getConfigData('methods');
|
52 |
+
if(!is_array($methods)){
|
53 |
+
$methods = unserialize($methods);
|
54 |
+
}
|
55 |
+
|
56 |
+
return $methods;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return boolean
|
61 |
+
*/
|
62 |
+
public function isDefaultOptionActive()
|
63 |
+
{
|
64 |
+
return (bool) $this->getMethod()->getConfigData('default');
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getDefaultOptionTitle()
|
68 |
+
{
|
69 |
+
return $this->getMethod()->getConfigData('default_title');
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Ideal.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Block_Form_Ideal
|
11 |
+
extends Mage_Payment_Block_Form
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Init OPS payment form
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
$this->setTemplate('ops/form/ideal.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* return the ideal issuers
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
public function getIssuers()
|
30 |
+
{
|
31 |
+
return Mage::getModel('ops/payment_iDeal')->getIDealIssuers();
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/InterSolve.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* InterSolve.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Block_Form_InterSolve extends Netresearch_OPS_Block_Form
|
33 |
+
{
|
34 |
+
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->setTemplate('ops/form/intersolve.phtml');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @return array empty or intersolve Vouchers
|
44 |
+
*/
|
45 |
+
public function getInterSolveBrands()
|
46 |
+
{
|
47 |
+
$brands = Mage::getModel('ops/config')->getIntersolveBrands();
|
48 |
+
|
49 |
+
return $brands;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Kwixo/ApresReception.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Block_Form_Kwixo_ApresReception extends Netresearch_OPS_Block_Form
|
12 |
+
{
|
13 |
+
const FRONTEND_TEMPLATE = 'ops/form/kwixo/apres_reception.phtml';
|
14 |
+
|
15 |
+
protected $pmLogo = 'images/ops/kwixo/apres_reception.jpg';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Init OPS payment form
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate(self::FRONTEND_TEMPLATE);
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Kwixo/Comptant.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
class Netresearch_OPS_Block_Form_Kwixo_Comptant extends Netresearch_OPS_Block_Form
|
13 |
+
{
|
14 |
+
const FRONTEND_TEMPLATE = 'ops/form/kwixo/comptant.phtml';
|
15 |
+
|
16 |
+
protected $pmLogo = 'images/ops/kwixo/comptant.jpg';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Init OPS payment form
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->setTemplate(self::FRONTEND_TEMPLATE);
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/Kwixo/Credit.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
class Netresearch_OPS_Block_Form_Kwixo_Credit extends Netresearch_OPS_Block_Form
|
13 |
+
{
|
14 |
+
const FRONTEND_TEMPLATE = 'ops/form/kwixo/credit.phtml';
|
15 |
+
|
16 |
+
protected $pmLogo = 'images/ops/kwixo/credit.jpg';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Init OPS payment form
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->setTemplate(self::FRONTEND_TEMPLATE);
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/OpsId.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Block_Form_OpsId
|
4 |
+
*
|
5 |
+
* @package OPS
|
6 |
+
* @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
|
7 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Block_Form_OpsId extends Mage_Payment_Block_Form
|
11 |
+
{
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('ops/form/opsId.phtml');
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Netresearch/OPS/Block/Form/RecurringCc.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* RecurringCc.php
|
24 |
+
*
|
25 |
+
* @category payment form block
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Netresearch_OPS_Block_Form_RecurringCc extends Netresearch_OPS_Block_Form_Cc {
|
31 |
+
|
32 |
+
public function getCcBrands()
|
33 |
+
{
|
34 |
+
return $this->getConfig()->getAcceptedRecurringCcTypes();
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Netresearch/OPS/Block/Frauddetection.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Netresearch_OPS
|
24 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
class Netresearch_OPS_Block_Frauddetection
|
28 |
+
extends Mage_Core_Block_Template
|
29 |
+
{
|
30 |
+
protected $_template = "ops/frauddetection.phtml";
|
31 |
+
|
32 |
+
const TRACKING_CODE_APPLICATION_ID = "10376";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* renders the additional fraud detection js
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
protected function _toHtml()
|
40 |
+
{
|
41 |
+
$html = null;
|
42 |
+
$storeId = Mage::helper('core/data')->getStoreId();
|
43 |
+
if (true == Mage::getModel('ops/config')->getDeviceFingerPrinting($storeId)
|
44 |
+
&& Mage::getSingleton('customer/session')->getData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)) {
|
45 |
+
$html = parent::_toHtml();
|
46 |
+
}
|
47 |
+
|
48 |
+
return $html;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* get the tracking code application id from config
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getTrackingCodeAid()
|
57 |
+
{
|
58 |
+
return self::TRACKING_CODE_APPLICATION_ID;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* build md5 hash from customer session ID
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getTrackingSid()
|
68 |
+
{
|
69 |
+
$quote = Mage::getSingleton('checkout/type_onepage')->getQuote();
|
70 |
+
|
71 |
+
return md5(Mage::getModel('ops/config')->getPSPID($quote->getStoreId()) . Mage::helper('ops/order')->getOpsOrderId($quote));
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/community/Netresearch/OPS/Block/Info/Alias.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Block_Info_Alias
|
13 |
+
*
|
14 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
15 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
class Netresearch_OPS_Block_Info_Alias extends Netresearch_OPS_Block_Info_Redirect
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Init ops payment information block
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('ops/info/cc.phtml');
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
app/code/community/Netresearch/OPS/Block/Info/Cc.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS payment information block
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Block_Info_Cc extends Netresearch_OPS_Block_Info_Redirect
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Init ops payment information block
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
protected function _construct()
|
37 |
+
{
|
38 |
+
parent::_construct();
|
39 |
+
$this->setTemplate('ops/info/cc.phtml');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
app/code/community/Netresearch/OPS/Block/Info/Flex.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Flex.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Block_Info_Flex extends Mage_Payment_Block_Info
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* @inheritDoc
|
36 |
+
*/
|
37 |
+
protected function _construct()
|
38 |
+
{
|
39 |
+
parent::_construct();
|
40 |
+
$this->setTemplate('ops/info/flex.phtml');
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function getFlexTitle()
|
48 |
+
{
|
49 |
+
return $this->getMethod()->getInfoInstance()->getAdditionalInformation(
|
50 |
+
Netresearch_OPS_Model_Payment_Flex::INFO_KEY_TITLE
|
51 |
+
);
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Netresearch/OPS/Block/Info/OpsId.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS payment information block
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Block_Info_OpsId extends Mage_Payment_Block_Info
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Init ops payment information block
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
protected function _construct()
|
37 |
+
{
|
38 |
+
parent::_construct();
|
39 |
+
$this->setTemplate('ops/info/opsId.phtml');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
app/code/community/Netresearch/OPS/Block/Info/RecurringCc.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* RecurringCc.php
|
24 |
+
*
|
25 |
+
* @category payment info block
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Netresearch_OPS_Block_Info_RecurringCc extends Netresearch_OPS_Block_Info_Cc {
|
31 |
+
|
32 |
+
}
|
app/code/community/Netresearch/OPS/Block/Info/Redirect.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS payment information block
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Block_Info_Redirect extends Mage_Payment_Block_Info
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Init ops payment information block
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
protected function _construct()
|
37 |
+
{
|
38 |
+
parent::_construct();
|
39 |
+
$this->setTemplate('ops/info/redirect.phtml');
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Netresearch/OPS/Block/Paypage.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
class Netresearch_OPS_Block_Paypage extends Mage_Core_Block_Template
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* Init pay page block
|
32 |
+
*
|
33 |
+
* @return Netresearch_OPS_Block_Paypage
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->setTemplate('ops/paypage.phtml');
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Netresearch/OPS/Block/Placeform.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Netresearch_OPS
|
24 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
class Netresearch_OPS_Block_Placeform extends Mage_Core_Block_Template
|
28 |
+
{
|
29 |
+
protected $hasMissingParams;
|
30 |
+
protected $missingFormFields;
|
31 |
+
protected $formFields;
|
32 |
+
protected $question;
|
33 |
+
|
34 |
+
public function __construct()
|
35 |
+
{
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getConfig()
|
40 |
+
{
|
41 |
+
return Mage::getModel('ops/config');
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get checkout session namespace
|
46 |
+
*
|
47 |
+
* @return Mage_Checkout_Model_Session
|
48 |
+
*/
|
49 |
+
public function getCheckout()
|
50 |
+
{
|
51 |
+
return Mage::getSingleton('checkout/session');
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* OPS payment APi instance
|
56 |
+
*
|
57 |
+
* @return Netresearch_OPS_Model_Payment_Abstract
|
58 |
+
*/
|
59 |
+
protected function _getApi()
|
60 |
+
{
|
61 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
|
62 |
+
if ($order && !is_null($order->getId())) {
|
63 |
+
return $order->getPayment()->getMethodInstance();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Return order instance with loaded information by increment id
|
69 |
+
*
|
70 |
+
* @return Mage_Sales_Model_Order
|
71 |
+
*/
|
72 |
+
protected function _getOrder()
|
73 |
+
{
|
74 |
+
if ($this->getOrder()) {
|
75 |
+
$order = $this->getOrder();
|
76 |
+
} else if ($this->getCheckout()->getLastRealOrderId()) {
|
77 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
|
78 |
+
} else {
|
79 |
+
return null;
|
80 |
+
}
|
81 |
+
return $order;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* check if payment method is q kwixo one
|
86 |
+
*
|
87 |
+
* @return boolean
|
88 |
+
*/
|
89 |
+
public function isKwixoPaymentMethod()
|
90 |
+
{
|
91 |
+
$isKwixoPayment = false;
|
92 |
+
$methodInstance = $this->_getOrder()->getPayment()->getMethodInstance();
|
93 |
+
if ($methodInstance instanceof Netresearch_OPS_Model_Payment_Kwixo_Abstract) {
|
94 |
+
$isKwixoPayment= true;
|
95 |
+
}
|
96 |
+
return $isKwixoPayment;
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* Get Form data by using ops payment api
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function getFormData()
|
104 |
+
{
|
105 |
+
if (is_null($this->formFields) && $this->_getOrder() && !is_null($this->_getOrder()->getId())) {
|
106 |
+
$this->formFields = $this->_getApi()->getFormFields($this->_getOrder(), $this->getRequest()->getParams());
|
107 |
+
}
|
108 |
+
return $this->formFields;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Getting gateway url
|
113 |
+
*
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function getFormAction()
|
117 |
+
{
|
118 |
+
$formAction = '';
|
119 |
+
|
120 |
+
// extract variable to ensure php 5.4 compatibility
|
121 |
+
$question = $this->getQuestion();
|
122 |
+
|
123 |
+
if ($this->getRequest()->isPost() || empty($question)) {
|
124 |
+
$formAction = $this->getConfig()->getFrontendGatewayPath();
|
125 |
+
} else {
|
126 |
+
$formAction = Mage::getUrl(
|
127 |
+
'*/*/*', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
return $formAction;
|
132 |
+
}
|
133 |
+
|
134 |
+
public function hasMissingParams()
|
135 |
+
{
|
136 |
+
if (is_null($this->_getOrder())) {
|
137 |
+
return null;
|
138 |
+
}
|
139 |
+
if (is_null($this->hasMissingParams)) {
|
140 |
+
$this->hasMissingParams = $this->_getApi()->hasFormMissingParams($this->_getOrder(), $this->getRequest()->getParams(), $this->getFormData());
|
141 |
+
}
|
142 |
+
return $this->hasMissingParams;
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getQuestion()
|
146 |
+
{
|
147 |
+
if (is_null($this->question) && $this->_getOrder() && !is_null($this->_getOrder()->getId())) {
|
148 |
+
$this->question = $this->_getApi()->getQuestion($this->_getOrder(), $this->getRequest()->getParams());
|
149 |
+
}
|
150 |
+
return $this->question;
|
151 |
+
}
|
152 |
+
|
153 |
+
public function getQuestionedFormFields()
|
154 |
+
{
|
155 |
+
if (is_null($this->missingFormFields) && $this->_getOrder() && !is_null($this->_getOrder()->getId())) {
|
156 |
+
$this->missingFormFields = $this->_getApi()->getQuestionedFormFields($this->_getOrder(), $this->getRequest()->getParams());
|
157 |
+
}
|
158 |
+
return $this->missingFormFields;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function isIframeTarget()
|
162 |
+
{
|
163 |
+
return $this->getConfig()->getConfigData('template') === Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
}
|
app/code/community/Netresearch/OPS/Block/Placeform3dsecure.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
class Netresearch_OPS_Block_Placeform3dsecure extends Netresearch_OPS_Block_Placeform
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* Get Form data of 3D Secure
|
32 |
+
*
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getFormData()
|
36 |
+
{
|
37 |
+
if (!is_null($this->_getOrder())) {
|
38 |
+
return base64_decode($this->_getOrder()->getPayment()->getAdditionalInformation('HTML_ANSWER'));
|
39 |
+
}
|
40 |
+
return null;
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Netresearch/OPS/Block/RetryPayment.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* RetryPayment.php
|
24 |
+
*
|
25 |
+
* @category payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Netresearch_OPS_Block_RetryPayment extends Netresearch_OPS_Block_Placeform {
|
31 |
+
|
32 |
+
protected $order = null;
|
33 |
+
|
34 |
+
protected function _getApi()
|
35 |
+
{
|
36 |
+
return $this->_getOrder()->getPayment()->getMethodInstance();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _getOrder()
|
40 |
+
{
|
41 |
+
if(is_null($this->order)){
|
42 |
+
$opsOrderId = $this->getRequest()->getParam('orderID');
|
43 |
+
$this->order = Mage::helper('ops/order')->getOrder($opsOrderId);
|
44 |
+
}
|
45 |
+
return $this->order;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Brand.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch OPS
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
16 |
+
* newer versions in the future.
|
17 |
+
*
|
18 |
+
* @category Netresearch
|
19 |
+
* @package Netresearch_OPS
|
20 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
21 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
22 |
+
*/
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Netresearch
|
26 |
+
*
|
27 |
+
* @category Netresearch
|
28 |
+
* @package Netresearch_OPS
|
29 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Netresearch_OPS_Block_System_Config_Form_Field_Brand
|
33 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
34 |
+
{
|
35 |
+
public function __construct()
|
36 |
+
{
|
37 |
+
$this->addColumn('brand', array(
|
38 |
+
'label' => Mage::helper('ops')->__('Brand'),
|
39 |
+
'style' => 'width:120px',
|
40 |
+
));
|
41 |
+
$this->addColumn('value', array(
|
42 |
+
'label' => Mage::helper('ops')->__('Title'),
|
43 |
+
'style' => 'width:120px',
|
44 |
+
));
|
45 |
+
$this->_addAfter = false;
|
46 |
+
$this->_addButtonLabel = Mage::helper('ops')->__('Add Brand');
|
47 |
+
parent::__construct();
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/Method.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Method.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Netresearch_OPS_Block_System_Config_Form_Field_Method extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
31 |
+
{
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->addColumn('title', array(
|
35 |
+
'label' => Mage::helper('ops')->__('Title'),
|
36 |
+
'style' => 'width:80px',
|
37 |
+
'class' => 'required-entry'
|
38 |
+
));
|
39 |
+
$this->addColumn('pm', array(
|
40 |
+
'label' => 'PM',
|
41 |
+
'style' => 'width:80px',
|
42 |
+
'class' => 'required-entry'
|
43 |
+
));
|
44 |
+
$this->addColumn('brand', array(
|
45 |
+
'label' => 'BRAND',
|
46 |
+
'style' => 'width:80px',
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->_addAfter = false;
|
50 |
+
$this->_addButtonLabel = Mage::helper('ops')->__('Add Method');
|
51 |
+
parent::__construct();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Form/Field/RecurringActive.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* RecurringActive.php
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Block_System_Config_Form_Field_RecurringActive
|
33 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
34 |
+
{
|
35 |
+
|
36 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
37 |
+
{
|
38 |
+
$html = parent::_getElementHtml($element);
|
39 |
+
|
40 |
+
$javascript
|
41 |
+
= "
|
42 |
+
<script type=\"text/javascript\">
|
43 |
+
element = $('" . $element->getHtmlId() . "');
|
44 |
+
Event.observe(element, 'change', function(){
|
45 |
+
if(element.value == 1){
|
46 |
+
$('ops_recurring_cc_active_comment').style.display = 'block';
|
47 |
+
} else {
|
48 |
+
$('ops_recurring_cc_active_comment').style.display = 'none';
|
49 |
+
}
|
50 |
+
});
|
51 |
+
</script>";
|
52 |
+
|
53 |
+
return $html . $javascript;
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Kwixoconfiguration.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: michael
|
5 |
+
* Date: 23.07.13
|
6 |
+
* Time: 09:04
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Block_System_Config_Kwixoconfiguration
|
11 |
+
extends Mage_Adminhtml_Block_Abstract
|
12 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_template = 'ops/system/config/kwixoconfiglinks.phtml';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Render fieldset html
|
19 |
+
*
|
20 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render(Varien_Data_Form_Element_Abstract $fieldset)
|
25 |
+
{
|
26 |
+
$this->addData(
|
27 |
+
array(
|
28 |
+
'fieldset_label' => $fieldset->getLegend(),
|
29 |
+
)
|
30 |
+
);
|
31 |
+
|
32 |
+
return $this->toHtml();
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Mode.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mode.php
|
4 |
+
* @author paul.siedler@netresearch.de
|
5 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Netresearch_OPS_Block_System_Config_Mode extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
10 |
+
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$html = parent::_getElementHtml($element);
|
14 |
+
|
15 |
+
$javascript = "
|
16 |
+
<script type=\"text/javascript\">
|
17 |
+
element = $('".$element->getHtmlId()."');
|
18 |
+
Event.observe(element, 'change', function(){
|
19 |
+
if(element.selectedOptions[0].value != '".$element->getValue()."'){
|
20 |
+
$('ops_mode_comment').style.display = 'block';
|
21 |
+
} else {
|
22 |
+
$('ops_mode_comment').style.display = 'none';
|
23 |
+
}
|
24 |
+
});
|
25 |
+
</script>";
|
26 |
+
|
27 |
+
return $html.$javascript;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
}
|
app/code/community/Netresearch/OPS/Block/System/Config/Support.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Block_System_Config_Support extends Mage_Adminhtml_Block_Abstract
|
4 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
5 |
+
{
|
6 |
+
protected $_template = 'ops/system/config/support.phtml';
|
7 |
+
protected $_downloadLogPath = 'admin/downloadlog';
|
8 |
+
|
9 |
+
protected function getConfig()
|
10 |
+
{
|
11 |
+
return Mage::getModel('ops/config');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Render fieldset html
|
16 |
+
*
|
17 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function render(Varien_Data_Form_Element_Abstract $fieldset)
|
21 |
+
{
|
22 |
+
$originalData = $fieldset->getOriginalData();
|
23 |
+
$this->addData(array(
|
24 |
+
'fieldset_label' => $fieldset->getLegend(),
|
25 |
+
));
|
26 |
+
return $this->toHtml();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* get extension version
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getExtensionVersion()
|
35 |
+
{
|
36 |
+
return (string)Mage::getConfig()->getNode('modules')->children()->Netresearch_OPS->version;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* get Magento version
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getMageVersion()
|
45 |
+
{
|
46 |
+
$mageVersion = Mage::getVersion();
|
47 |
+
if (is_callable('Mage::getEdition')) {
|
48 |
+
$mageVersion = Mage::getEdition() . ' ' . $mageVersion;
|
49 |
+
}
|
50 |
+
return $mageVersion;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* get support mail address
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function getSupportMail()
|
59 |
+
{
|
60 |
+
$mail = $this->getConfig()->getConfigData('support_mail');
|
61 |
+
if (0 < strpos($mail, '@')) {
|
62 |
+
return $mail;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* if we have a link to documentation
|
68 |
+
*
|
69 |
+
* @return int
|
70 |
+
*/
|
71 |
+
public function hasDocumentation()
|
72 |
+
{
|
73 |
+
return strlen($this->getDocLinkDe() . $this->getDocLinkEn());
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* get URL of German documentation
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getDocLinkDe()
|
82 |
+
{
|
83 |
+
$link = $this->getConfig()->getConfigData('doc_link_de');
|
84 |
+
if (0 < strpos($link, '://')) {
|
85 |
+
return $link;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* get URL of English documentation
|
91 |
+
*
|
92 |
+
* @return string
|
93 |
+
*/
|
94 |
+
public function getDocLinkEn()
|
95 |
+
{
|
96 |
+
$link = $this->getConfig()->getConfigData('doc_link_en');
|
97 |
+
if (0 < strpos($link, '://')) {
|
98 |
+
return $link;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* if we have link to a FAQ
|
104 |
+
*
|
105 |
+
* @return int
|
106 |
+
*/
|
107 |
+
public function hasFaq()
|
108 |
+
{
|
109 |
+
return strlen($this->getFaqLinkDe() . $this->getFaqLinkEn());
|
110 |
+
}
|
111 |
+
/**
|
112 |
+
* get URL of German FAQ
|
113 |
+
*
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function getFaqLinkDe()
|
117 |
+
{
|
118 |
+
$link = $this->getConfig()->getConfigData('faq_link_de');
|
119 |
+
if (0 < strpos($link, '://')) {
|
120 |
+
return $link;
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* get URL of English FAQ
|
127 |
+
*
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
public function getFaqLinkEn()
|
131 |
+
{
|
132 |
+
$link = $this->getConfig()->getConfigData('faq_link_en');
|
133 |
+
if (0 < strpos($link, '://')) {
|
134 |
+
return $link;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* if we use a prefix for parameter ORDERID
|
140 |
+
*
|
141 |
+
* @return bool
|
142 |
+
*/
|
143 |
+
public function hasDevPrefix()
|
144 |
+
{
|
145 |
+
return 0 < strlen($this->getDevPrefix());
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* get prefix for parameter ORDERID
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
public function getDevPrefix()
|
154 |
+
{
|
155 |
+
return $this->getConfig()->getConfigData('devprefix');
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* get link for ops.log download action
|
160 |
+
*
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function getLogDownloadLink()
|
164 |
+
{
|
165 |
+
return $this->getUrl($this->_downloadLogPath);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
app/code/community/Netresearch/OPS/Controller/Abstract.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Controller_Abstract
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
12 |
+
{
|
13 |
+
protected function getQuote()
|
14 |
+
{
|
15 |
+
return $this->_getCheckout()->getQuote();
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get checkout session namespace
|
20 |
+
*
|
21 |
+
* @return Mage_Checkout_Model_Session
|
22 |
+
*/
|
23 |
+
protected function _getCheckout()
|
24 |
+
{
|
25 |
+
return Mage::getSingleton('checkout/session');
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function getConfig()
|
29 |
+
{
|
30 |
+
return Mage::getModel('ops/config');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Return order instance loaded by increment id'
|
35 |
+
*
|
36 |
+
* @return Mage_Sales_Model_Order
|
37 |
+
*/
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return order instance loaded by increment id'
|
41 |
+
*
|
42 |
+
* @return Mage_Sales_Model_Order
|
43 |
+
*/
|
44 |
+
|
45 |
+
protected function _getOrder($opsOrderId = null)
|
46 |
+
{
|
47 |
+
if (empty($this->_order)) {
|
48 |
+
if (is_null($opsOrderId)) {
|
49 |
+
$opsOrderId = $this->getRequest()->getParam('orderID');
|
50 |
+
}
|
51 |
+
$this->_order = Mage::helper('ops/order')->getOrder($opsOrderId);
|
52 |
+
}
|
53 |
+
return $this->_order;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Get singleton with Checkout by OPS Api
|
58 |
+
*
|
59 |
+
* @return Netresearch_OPS_Model_Payment_Abstract
|
60 |
+
*/
|
61 |
+
protected function _getApi()
|
62 |
+
{
|
63 |
+
if (!is_null($this->getRequest()->getParam('orderID'))):
|
64 |
+
return $this->_getOrder()->getPayment()->getMethodInstance();
|
65 |
+
else:
|
66 |
+
return Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance();
|
67 |
+
endif;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* get payment helper
|
72 |
+
*
|
73 |
+
* @return Netresearch_OPS_Helper_Payment
|
74 |
+
*/
|
75 |
+
protected function getPaymentHelper()
|
76 |
+
{
|
77 |
+
return Mage::helper('ops/payment');
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* get direct link helper
|
82 |
+
*
|
83 |
+
* @return Netresearch_OPS_Helper_Directlink
|
84 |
+
*/
|
85 |
+
protected function getDirectlinkHelper()
|
86 |
+
{
|
87 |
+
return Mage::helper('ops/directlink');
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function getSubscriptionHelper()
|
91 |
+
{
|
92 |
+
return Mage::helper('ops/subscription');
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Validation of incoming OPS data
|
97 |
+
*
|
98 |
+
* @return bool
|
99 |
+
*/
|
100 |
+
protected function _validateOPSData()
|
101 |
+
{
|
102 |
+
$helper = Mage::helper('ops');
|
103 |
+
$params = $this->getRequest()->getParams();
|
104 |
+
if ($this->getSubscriptionHelper()->isSubscriptionFeedback($params)) {
|
105 |
+
$profile = $this->getSubscriptionHelper()->getProfileForSubscription($params['orderID']);
|
106 |
+
if (!$profile->getId()) {
|
107 |
+
$this->_getCheckout()->addError($this->__('Subscription is not valid'));
|
108 |
+
$helper->log(
|
109 |
+
$helper->__(
|
110 |
+
"Incoming Acceptance Feedback\n\nRequest Path: %s\nParams: %s\n\nSubscription not valid\n",
|
111 |
+
$this->getRequest()->getPathInfo(),
|
112 |
+
serialize($this->getRequest()->getParams())
|
113 |
+
)
|
114 |
+
);
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
$storeId = $profile->getStoreId();
|
118 |
+
} else {
|
119 |
+
$order = $this->_getOrder();
|
120 |
+
if (!$order->getId()) {
|
121 |
+
$helper->log(
|
122 |
+
$helper->__(
|
123 |
+
"Incoming Acceptance Feedback\n\nRequest Path: %s\nParams: %s\n\nOrder not valid\n",
|
124 |
+
$this->getRequest()->getPathInfo(),
|
125 |
+
serialize($this->getRequest()->getParams())
|
126 |
+
)
|
127 |
+
);
|
128 |
+
$this->_getCheckout()->addError($this->__('Order is not valid'));
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
$storeId = $order->getStoreId();
|
132 |
+
}
|
133 |
+
|
134 |
+
//remove custom responseparams, because they are not hashed by Acceptance
|
135 |
+
if ($this->getConfig()->getConfigData('template') == Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME
|
136 |
+
&& array_key_exists('IFRAME', $params)
|
137 |
+
) {
|
138 |
+
unset($params['IFRAME']);
|
139 |
+
}
|
140 |
+
|
141 |
+
$secureKey = $this->getConfig()->getShaInCode($storeId);
|
142 |
+
$secureSet = $this->getPaymentHelper()->getSHAInSet($params, $secureKey);
|
143 |
+
|
144 |
+
$helper->log(
|
145 |
+
$helper->__(
|
146 |
+
"Incoming Acceptance Feedback\n\nRequest Path: %s\nParams: %s\n",
|
147 |
+
$this->getRequest()->getPathInfo(),
|
148 |
+
serialize($this->getRequest()->getParams())
|
149 |
+
)
|
150 |
+
);
|
151 |
+
|
152 |
+
if (Mage::helper('ops/payment')->shaCryptValidation($secureSet, $params['SHASIGN']) !== true) {
|
153 |
+
$this->_getCheckout()->addError($this->__('Hash is not valid'));
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
return true;
|
158 |
+
}
|
159 |
+
|
160 |
+
public function isJsonRequested($params)
|
161 |
+
{
|
162 |
+
if (array_key_exists('RESPONSEFORMAT', $params) && $params['RESPONSEFORMAT'] == 'JSON') {
|
163 |
+
return true;
|
164 |
+
}
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
|
168 |
+
public function getSubscriptionManager()
|
169 |
+
{
|
170 |
+
return Mage::getModel('ops/subscription_manager');
|
171 |
+
}
|
172 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Alias.php
ADDED
@@ -0,0 +1,491 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Netresearch_OPS
|
24 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
class Netresearch_OPS_Helper_Alias extends Mage_Core_Helper_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getAdminSession()
|
31 |
+
{
|
32 |
+
return Mage::getSingleton('admin/session');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function isAdminSession()
|
36 |
+
{
|
37 |
+
if ($this->getAdminSession()->getUser()) {
|
38 |
+
return 0 < $this->getAdminSession()->getUser()->getUserId();
|
39 |
+
}
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* PM value is not used for payments with Alias Manager
|
45 |
+
*
|
46 |
+
* @param Mage_Sales_Model_Quote_Payment|null Payment
|
47 |
+
*
|
48 |
+
* @return null
|
49 |
+
*/
|
50 |
+
public function getOpsCode($payment = null)
|
51 |
+
{
|
52 |
+
return $payment;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* BRAND value is not used for payments with Alias Manager
|
57 |
+
*
|
58 |
+
* @param Mage_Sales_Model_Quote_Payment|null Payment
|
59 |
+
*
|
60 |
+
* @return null
|
61 |
+
*/
|
62 |
+
public function getOpsBrand($payment = null)
|
63 |
+
{
|
64 |
+
return $payment;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* get alias or generate a new one
|
69 |
+
*
|
70 |
+
* alias has length 16 and consists of quote creation date, a separator,
|
71 |
+
* and the quote id to make sure we have the full quote id we shorten
|
72 |
+
* the creation date accordingly
|
73 |
+
*
|
74 |
+
* @param Mage_Sales_Model_Quote $quote
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getAlias($quote, $forceNew = false)
|
79 |
+
{
|
80 |
+
|
81 |
+
$alias = $quote->getPayment()->getAdditionalInformation('alias');
|
82 |
+
if (0 == strlen($alias) || $forceNew) {
|
83 |
+
/* turn createdAt into format MMDDHHii */
|
84 |
+
$createdAt = time();
|
85 |
+
$quoteId = $quote->getId();
|
86 |
+
/* shorten createdAt, if we would exceed maximum length */
|
87 |
+
$maxAliasLength = 16;
|
88 |
+
$separator = '99';
|
89 |
+
$maxCreatedAtLength
|
90 |
+
= $maxAliasLength - strlen($quoteId) - strlen($separator);
|
91 |
+
$alias = substr($createdAt, 0, $maxCreatedAtLength) . $separator
|
92 |
+
. $quoteId;
|
93 |
+
}
|
94 |
+
|
95 |
+
if ($this->isAdminSession() && !strpos($alias,'BE')) {
|
96 |
+
$alias = $alias.'BE';
|
97 |
+
}
|
98 |
+
return $alias;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* saves the alias if customer is logged in (and want to create an alias)
|
103 |
+
*
|
104 |
+
* @param $aliasData
|
105 |
+
* @param Mage_Sales_Model_Quote $quote
|
106 |
+
*
|
107 |
+
* @return Netresearch_OPS_Model_Alias | null
|
108 |
+
*/
|
109 |
+
public function saveAlias($aliasData)
|
110 |
+
{
|
111 |
+
$quote = null;
|
112 |
+
$aliasModel = null;
|
113 |
+
Mage::helper('ops')->log('aliasData ' . Zend_Json::encode(Mage::helper('ops/data')->clearMsg($aliasData)));
|
114 |
+
if (array_key_exists('Alias_OrderId', $aliasData) && is_numeric($aliasData['Alias_OrderId'])) {
|
115 |
+
$quote = Mage::getModel('sales/quote')->load($aliasData['Alias_OrderId']);
|
116 |
+
}
|
117 |
+
|
118 |
+
if ($quote instanceof Mage_Sales_Model_Quote
|
119 |
+
&& $quote->getPayment()
|
120 |
+
&& Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod()
|
121 |
+
!= Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
|
122 |
+
&& (array_key_exists('Alias_StorePermanently',$aliasData) && 'Y' == $aliasData['Alias_StorePermanently'])
|
123 |
+
) {
|
124 |
+
|
125 |
+
// alias does not exist -> create a new one if requested
|
126 |
+
if (!is_null($quote) && $quote->getPayment()) {
|
127 |
+
// create new alias
|
128 |
+
$aliasModel = $this->saveNewAlias($quote, $aliasData);
|
129 |
+
$quote->getPayment()->setAdditionalInformation(
|
130 |
+
'opsAliasId', $aliasModel->getId()
|
131 |
+
);
|
132 |
+
$quote->getPayment()->save();
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
return $aliasModel;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @param Mage_Sales_Model_Quote $quote
|
142 |
+
*/
|
143 |
+
protected function deleteAlias(Mage_Sales_Model_Quote $quote)
|
144 |
+
{
|
145 |
+
$customerId = $quote->getCustomer()->getId();
|
146 |
+
$billingAddressHash = $this->generateAddressHash(
|
147 |
+
$quote->getBillingAddress()
|
148 |
+
);
|
149 |
+
$shippingAddressHash = $this->generateAddressHash(
|
150 |
+
$quote->getShippingAddress()
|
151 |
+
);
|
152 |
+
$aliasModel = Mage::getModel('ops/alias');
|
153 |
+
$aliasCollection = $aliasModel->getCollection()
|
154 |
+
->addFieldToFilter('customer_id', $customerId)
|
155 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
156 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
157 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::PENDING)
|
158 |
+
->addFieldToFilter('store_id', array(array('eq' => $quote->getStoreId()), array('null' => true)))
|
159 |
+
->setOrder('created_at', 'DESC')
|
160 |
+
->setPageSize(1);
|
161 |
+
$aliasCollection->load();
|
162 |
+
foreach ($aliasCollection as $alias) {
|
163 |
+
$alias->delete();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
protected function saveNewAlias(Mage_Sales_Model_Quote $quote, $aliasData)
|
168 |
+
{
|
169 |
+
$customerId = $quote->getCustomer()->getId();
|
170 |
+
$billingAddressHash = $this->generateAddressHash(
|
171 |
+
$quote->getBillingAddress()
|
172 |
+
);
|
173 |
+
$shippingAddressHash = $this->generateAddressHash(
|
174 |
+
$quote->getShippingAddress()
|
175 |
+
);
|
176 |
+
|
177 |
+
$aliasModel = Mage::getModel('ops/alias');
|
178 |
+
$aliasModel->setCustomerId($customerId);
|
179 |
+
$aliasModel->setAlias($aliasData['Alias_AliasId']);
|
180 |
+
$aliasModel->setExpirationDate($aliasData['Card_ExpiryDate']);
|
181 |
+
$aliasModel->setBillingAddressHash($billingAddressHash);
|
182 |
+
$aliasModel->setShippingAddressHash($shippingAddressHash);
|
183 |
+
$aliasModel->setBrand($aliasData['Card_Brand']);
|
184 |
+
$aliasModel->setPaymentMethod($quote->getPayment()->getMethod());
|
185 |
+
$aliasModel->setPseudoAccountOrCCNo($aliasData['Card_CardNumber']);
|
186 |
+
$aliasModel->setState(Netresearch_OPS_Model_Alias_State::PENDING);
|
187 |
+
$aliasModel->setStoreId($quote->getStoreId());
|
188 |
+
if (array_key_exists('Card_CardHolderName', $aliasData)) {
|
189 |
+
$aliasModel->setCardHolder($aliasData['Card_CardHolderName']);
|
190 |
+
}
|
191 |
+
Mage::helper('ops')->log(
|
192 |
+
'saving alias' . Zend_Json::encode($aliasModel->getData())
|
193 |
+
);
|
194 |
+
$aliasModel->save();
|
195 |
+
|
196 |
+
return $aliasModel;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* generates hash from address data
|
201 |
+
*
|
202 |
+
* @param Mage_Sales_Model_Quote_Address $address the address data to hash
|
203 |
+
*
|
204 |
+
* @returns string hash of address
|
205 |
+
*/
|
206 |
+
public function generateAddressHash(
|
207 |
+
Mage_Customer_Model_Address_Abstract $address
|
208 |
+
)
|
209 |
+
{
|
210 |
+
/** @var Netresearch_OPS_Helper_Payment $opsHelper */
|
211 |
+
$opsHelper = Mage::helper('ops/payment');
|
212 |
+
$addressString = $address->getFirstname();
|
213 |
+
$addressString .= $address->getMiddlename();
|
214 |
+
$addressString .= $address->getLastname();
|
215 |
+
$addressString .= $address->getCompany();
|
216 |
+
$street = $address->getStreetFull();
|
217 |
+
if (is_array($street)) {
|
218 |
+
$street = implode('', $street);
|
219 |
+
}
|
220 |
+
$addressString .= $street;
|
221 |
+
$addressString .= $address->getPostcode();
|
222 |
+
$addressString .= $address->getCity();
|
223 |
+
$addressString .= $address->getCountryId();
|
224 |
+
|
225 |
+
return hash($opsHelper->getCryptMethod(), $addressString);
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* retrieves the aliases for a given customer
|
230 |
+
*
|
231 |
+
* @param int $customerId
|
232 |
+
* @param Mage_Sales_Model_Quote
|
233 |
+
*
|
234 |
+
* @return Netresearch_OPS_Model_Mysql4_Alias_Collection - collection
|
235 |
+
* of aliases for the given customer
|
236 |
+
*/
|
237 |
+
public function getAliasesForCustomer(
|
238 |
+
$customerId, Mage_Sales_Model_Quote $quote = null
|
239 |
+
)
|
240 |
+
{
|
241 |
+
$billingAddressHash = null;
|
242 |
+
$shippingAddressHash = null;
|
243 |
+
$storeId = null;
|
244 |
+
if (!is_null($quote)) {
|
245 |
+
$billingAddressHash = $this->generateAddressHash(
|
246 |
+
$quote->getBillingAddress()
|
247 |
+
);
|
248 |
+
$shippingAddressHash = $this->generateAddressHash(
|
249 |
+
$quote->getShippingAddress()
|
250 |
+
);
|
251 |
+
$storeId = $quote->getStoreId();
|
252 |
+
}
|
253 |
+
return Mage::getModel('ops/alias')
|
254 |
+
->getAliasesForCustomer(
|
255 |
+
$customerId, $billingAddressHash, $shippingAddressHash, $storeId
|
256 |
+
);
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* if alias is valid for address
|
261 |
+
*
|
262 |
+
* @param int $customerId
|
263 |
+
* @param string $alias
|
264 |
+
* @param Mage_Sales_Model_Quote_Address $billingAddress
|
265 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress
|
266 |
+
*
|
267 |
+
* @return boolean
|
268 |
+
*/
|
269 |
+
public function isAliasValidForAddresses(
|
270 |
+
$customerId, $alias, $billingAddress, $shippingAddress, $storeId = null
|
271 |
+
)
|
272 |
+
{
|
273 |
+
$aliasCollection = $this->getAliasesForAddresses(
|
274 |
+
$customerId, $billingAddress, $shippingAddress, $storeId
|
275 |
+
)
|
276 |
+
->addFieldToFilter('alias', $alias)
|
277 |
+
->setPageSize(1);
|
278 |
+
return (1 == $aliasCollection->count());
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* get aliases that are allowed for customer with given addresses
|
283 |
+
*
|
284 |
+
* @param int $customerId Id of customer
|
285 |
+
* @param Mage_Sales_Model_Quote_Address $billingAddress billing address
|
286 |
+
* @param Mage_Sales_Model_Quote_Address $shippingAddress shipping address
|
287 |
+
*
|
288 |
+
* @return Netresearch_OPS_Model_Mysql4_Alias_Collection
|
289 |
+
*/
|
290 |
+
public function getAliasesForAddresses(
|
291 |
+
$customerId, $billingAddress, $shippingAddress, $storeId = null
|
292 |
+
)
|
293 |
+
{
|
294 |
+
$billingAddressHash = $this->generateAddressHash($billingAddress);
|
295 |
+
$shippingAddressHash = $this->generateAddressHash($shippingAddress);
|
296 |
+
return Mage::getModel('ops/alias')->getCollection()
|
297 |
+
->addFieldToFilter('customer_id', $customerId)
|
298 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
299 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
300 |
+
->addFieldToFilter('store_id', array(array('eq' => $storeId), array('null' => true)));
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* formats the pseudo cc number in a brand specific format
|
305 |
+
* supported brand (so far):
|
306 |
+
* - MasterCard
|
307 |
+
* - Visa
|
308 |
+
* - American Express
|
309 |
+
* - Diners Club
|
310 |
+
*
|
311 |
+
* @param $brand - the cc brand we need to format the pseudo cc number
|
312 |
+
* @param $aliasCcNo - the pseudo cc number itself
|
313 |
+
*
|
314 |
+
* @return string - the formatted pseudo cc number
|
315 |
+
*/
|
316 |
+
public function formatAliasCardNo($brand, $aliasCcNo)
|
317 |
+
{
|
318 |
+
|
319 |
+
if (in_array(strtolower($brand), array('visa', 'mastercard'))) {
|
320 |
+
$aliasCcNo = implode(' ', str_split($aliasCcNo, 4));
|
321 |
+
}
|
322 |
+
if (in_array(strtolower($brand), array('american express', 'diners club', 'maestrouk'))) {
|
323 |
+
$aliasCcNo = str_replace('-', ' ', $aliasCcNo);
|
324 |
+
}
|
325 |
+
|
326 |
+
return strtoupper($aliasCcNo);
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* saves the alias and if given the cvc to the payment information
|
331 |
+
*
|
332 |
+
* @param Mage_Payment_Model_Info $payment - the payment which should be updated
|
333 |
+
* @param array $aliasData - the data we will update
|
334 |
+
* @param boolean $userIsRegistering - is registering method in checkout
|
335 |
+
* @param boolean $paymentSave - is it necessary to save the payment afterwards
|
336 |
+
*/
|
337 |
+
public function setAliasToPayment(Mage_Payment_Model_Info $payment, array $aliasData, $userIsRegistering = false, $paymentSave = false)
|
338 |
+
{
|
339 |
+
if (array_key_exists('alias_aliasid', $aliasData) && 0 < strlen(trim($aliasData['alias_aliasid']))) {
|
340 |
+
$payment->setAdditionalInformation('alias', trim($aliasData['alias_aliasid']));
|
341 |
+
$payment->setAdditionalInformation('userIsRegistering', $userIsRegistering);
|
342 |
+
if (array_key_exists('card_cvc', $aliasData)) {
|
343 |
+
$payment->setAdditionalInformation('cvc', $aliasData['card_cvc']);
|
344 |
+
$this->setCardHolderToAlias($payment->getQuote(), $aliasData);
|
345 |
+
}
|
346 |
+
|
347 |
+
if ( array_key_exists('method', $aliasData)) {
|
348 |
+
$alias = Mage::getModel('ops/alias')->load($aliasData['alias_aliasid'], 'alias');
|
349 |
+
$alias->setPaymentMethod($aliasData['method']);
|
350 |
+
$alias->save();
|
351 |
+
}
|
352 |
+
|
353 |
+
$payment->setDataChanges(true);
|
354 |
+
if($paymentSave === true){
|
355 |
+
$payment->save();
|
356 |
+
}
|
357 |
+
} else {
|
358 |
+
Mage::helper('ops/data')->log('did not save alias due to empty alias');
|
359 |
+
Mage::helper('ops/data')->log(serialize($aliasData));
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
protected function setCardHolderToAlias($quote, $aliasData)
|
364 |
+
{
|
365 |
+
$customerId = $quote->getCustomerId();
|
366 |
+
$billingAddressHash = $this->generateAddressHash($quote->getBillingAddress());
|
367 |
+
$shippingAddressHash = $this->generateAddressHash($quote->getShippingAddress());
|
368 |
+
$oldAlias = Mage::getModel('ops/alias')->getCollection()
|
369 |
+
->addFieldToFilter('customer_id', $customerId)
|
370 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
371 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
372 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
|
373 |
+
->addFieldToFilter('store_id', array(array('eq' => $quote->getStoreId()), array('null' => true)))
|
374 |
+
->getFirstItem();
|
375 |
+
// and if so update this alias with alias data from alias gateway
|
376 |
+
if (is_numeric($oldAlias->getId()) && is_null($oldAlias->getCardHolder()) && array_key_exists('Card_CardHolderName', $aliasData)
|
377 |
+
) {
|
378 |
+
$oldAlias->setCardHolder($aliasData['Card_CardHolderName']);
|
379 |
+
$oldAlias->save();
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* set the last pending alias to active and remove other aliases for customer based on address
|
385 |
+
*
|
386 |
+
* @param Mage_Sales_Model_Quote $quote
|
387 |
+
*/
|
388 |
+
public function setAliasActive(
|
389 |
+
Mage_Sales_Model_Quote $quote,
|
390 |
+
Mage_Sales_Model_Order $order = null,
|
391 |
+
$saveSalesObjects = false
|
392 |
+
) {
|
393 |
+
if (is_null($quote->getPayment()->getAdditionalInformation('userIsRegistering'))
|
394 |
+
|| false == $quote->getPayment()->getAdditionalInformation('userIsRegistering')
|
395 |
+
) {
|
396 |
+
$aliasesToDelete = Mage::helper('ops/alias')->getAliasesForAddresses(
|
397 |
+
$quote->getCustomer()->getId(), $quote->getBillingAddress(), $quote->getShippingAddress()
|
398 |
+
)
|
399 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE);
|
400 |
+
$lastPendingAlias = Mage::helper('ops/alias')->getAliasesForAddresses(
|
401 |
+
$quote->getCustomer()->getId(),
|
402 |
+
$quote->getBillingAddress(),
|
403 |
+
$quote->getShippingAddress(),
|
404 |
+
$quote->getStoreId()
|
405 |
+
)
|
406 |
+
->addFieldToFilter('alias', $quote->getPayment()->getAdditionalInformation('alias'))
|
407 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::PENDING)
|
408 |
+
->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC)
|
409 |
+
->getFirstItem();
|
410 |
+
if (0 < $lastPendingAlias->getId()) {
|
411 |
+
foreach ($aliasesToDelete as $alias) {
|
412 |
+
$alias->delete();
|
413 |
+
}
|
414 |
+
$lastPendingAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
|
415 |
+
$lastPendingAlias->setPaymentMethod($order->getPayment()->getMethod());
|
416 |
+
$lastPendingAlias->save();
|
417 |
+
}
|
418 |
+
} else {
|
419 |
+
$this->setAliasToActiveAfterUserRegisters($order, $quote);
|
420 |
+
}
|
421 |
+
$this->cleanUpAdditionalInformation($order->getPayment(), false, $saveSalesObjects);
|
422 |
+
$this->cleanUpAdditionalInformation($quote->getPayment(), false, $saveSalesObjects);
|
423 |
+
}
|
424 |
+
|
425 |
+
public function setAliasToActiveAfterUserRegisters(
|
426 |
+
Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote
|
427 |
+
)
|
428 |
+
{
|
429 |
+
if (true == $quote->getPayment()->getAdditionalInformation('userIsRegistering')
|
430 |
+
) {
|
431 |
+
$customerId = $order->getCustomerId();
|
432 |
+
$billingAddressHash = $this->generateAddressHash(
|
433 |
+
$quote->getBillingAddress()
|
434 |
+
);
|
435 |
+
$shippingAddressHash = $this->generateAddressHash(
|
436 |
+
$quote->getShippingAddress()
|
437 |
+
);
|
438 |
+
$aliasId = $quote->getPayment()->getAdditionalInformation(
|
439 |
+
'opsAliasId'
|
440 |
+
);
|
441 |
+
if (is_numeric($aliasId) && 0 < $aliasId) {
|
442 |
+
$alias = Mage::getModel('ops/alias')->getCollection()
|
443 |
+
->addFieldToFilter(
|
444 |
+
'alias', $quote->getPayment()->getAdditionalInformation('alias')
|
445 |
+
)
|
446 |
+
->addFieldToFilter(
|
447 |
+
'billing_address_hash', $billingAddressHash
|
448 |
+
)
|
449 |
+
->addFieldToFilter(
|
450 |
+
'shipping_address_hash', $shippingAddressHash
|
451 |
+
)
|
452 |
+
->addFieldToFilter('store_id', array('eq' => $quote->getStoreId()))
|
453 |
+
->getFirstItem();
|
454 |
+
|
455 |
+
$alias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
|
456 |
+
$alias->setPaymentMethod($order->getPayment()->getMethod());
|
457 |
+
$alias->setCustomerId($customerId);
|
458 |
+
$alias->save();
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* cleans up the stored cvc and storedOPSId
|
465 |
+
*
|
466 |
+
* @param Mage_Sales_Model_Quote_Payment || Mage_Sales_Model_Order_Payment $payment
|
467 |
+
* @param bool $cvcOnly
|
468 |
+
* @param bool $savePayment
|
469 |
+
*
|
470 |
+
*/
|
471 |
+
public function cleanUpAdditionalInformation($payment, $cvcOnly = false, $savePayment = false)
|
472 |
+
{
|
473 |
+
if (is_array($payment->getAdditionalInformation())
|
474 |
+
&& array_key_exists('cvc', $payment->getAdditionalInformation())
|
475 |
+
) {
|
476 |
+
$payment->unsAdditionalInformation('cvc');
|
477 |
+
}
|
478 |
+
|
479 |
+
if ($cvcOnly === false && is_array($payment->getAdditionalInformation())
|
480 |
+
&& array_key_exists('storedOPSId', $payment->getAdditionalInformation())
|
481 |
+
) {
|
482 |
+
$payment->unsAdditionalInformation('storedOPSId');
|
483 |
+
}
|
484 |
+
|
485 |
+
/* OGNH-7: seems not to needed anymore since payment and quote is saved after this call,
|
486 |
+
otherwise admin payments will fail */
|
487 |
+
if ($savePayment) {
|
488 |
+
$payment->save();
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Api.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Helper_Api
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2013 Netresearch
|
7 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
8 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Api extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
private $configModel = null;
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param $status - one of the fedd back status
|
19 |
+
*
|
20 |
+
* @throws Mage_Core_Exception - in case the status is not known
|
21 |
+
* @return string - the route for redirect
|
22 |
+
*/
|
23 |
+
public function getRedirectRouteFromStatus($status)
|
24 |
+
{
|
25 |
+
$route = null;
|
26 |
+
$configModel = $this->getConfigModel();
|
27 |
+
if ($this->isAcceptStatus($status)) {
|
28 |
+
$route = $configModel->getAcceptRedirectRoute();
|
29 |
+
}
|
30 |
+
if ($this->isCancelStatus($status)) {
|
31 |
+
$route = $configModel->getCancelRedirectRoute();
|
32 |
+
}
|
33 |
+
if ($this->isDeclineStatus($status)) {
|
34 |
+
$route = $configModel->getDeclineRedirectRoute();
|
35 |
+
}
|
36 |
+
if ($this->isExceptionStatus($status)) {
|
37 |
+
$route = $configModel->getExceptionRedirectRoute();
|
38 |
+
}
|
39 |
+
|
40 |
+
// in case none of the cases above match then the status is not known
|
41 |
+
if (is_null($route)) {
|
42 |
+
Mage::throwException('invalid status provided');
|
43 |
+
}
|
44 |
+
|
45 |
+
return $route;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* config getter
|
51 |
+
*
|
52 |
+
* @return Netresearch_OPS_Model_Config
|
53 |
+
*/
|
54 |
+
private function getConfigModel()
|
55 |
+
{
|
56 |
+
if (is_null($this->configModel)) {
|
57 |
+
$this->configModel = Mage::getModel('ops/config');
|
58 |
+
}
|
59 |
+
return $this->configModel;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* determine if the status is known as accepted status
|
64 |
+
*
|
65 |
+
* @param $status - the status
|
66 |
+
*
|
67 |
+
* @return bool - true if the status is known as accept status, false otherwise
|
68 |
+
*/
|
69 |
+
private function isAcceptStatus($status)
|
70 |
+
{
|
71 |
+
return in_array($status, array(
|
72 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT
|
73 |
+
)
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* determine if the status is known as canceled status
|
79 |
+
*
|
80 |
+
* @param $status - the status
|
81 |
+
*
|
82 |
+
* @return bool - true if the status is known as canceled status, false otherwise
|
83 |
+
*/
|
84 |
+
private function isCancelStatus($status)
|
85 |
+
{
|
86 |
+
return in_array($status, array(
|
87 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL
|
88 |
+
)
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* determine if the status is known as declined status
|
94 |
+
*
|
95 |
+
* @param $status - the status
|
96 |
+
*
|
97 |
+
* @return bool - true if the status is known as declined status, false otherwise
|
98 |
+
*/
|
99 |
+
private function isDeclineStatus($status)
|
100 |
+
{
|
101 |
+
return in_array($status, array(
|
102 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE
|
103 |
+
)
|
104 |
+
);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* determine if the status is known as exception status
|
109 |
+
*
|
110 |
+
* @param $status - the status
|
111 |
+
*
|
112 |
+
* @return bool - true if the status is known as exception status, false otherwise
|
113 |
+
*/
|
114 |
+
private function isExceptionStatus($status)
|
115 |
+
{
|
116 |
+
return in_array($status, array(
|
117 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION
|
118 |
+
)
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Creditcard.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package ${MODULENAME}
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Helper_Creditcard extends Netresearch_OPS_Helper_Payment_DirectLink_Request
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $aliasHelper = null;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param Netresearch_OPS_Helper_Alias $aliasHelper
|
18 |
+
*/
|
19 |
+
public function setAliasHelper($aliasHelper)
|
20 |
+
{
|
21 |
+
$this->aliasHelper = $aliasHelper;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return Netresearch_OPS_Helper_Alias
|
26 |
+
*/
|
27 |
+
public function getAliasHelper()
|
28 |
+
{
|
29 |
+
if (null === $this->aliasHelper) {
|
30 |
+
$this->aliasHelper = Mage::helper('ops/alias');
|
31 |
+
}
|
32 |
+
return $this->aliasHelper;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param $quote
|
39 |
+
* @param $requestParams
|
40 |
+
*/
|
41 |
+
public function handleAdminPayment(Mage_Sales_Model_Quote $quote, $requestParams)
|
42 |
+
{
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote)
|
47 |
+
{
|
48 |
+
$alias = $quote->getPayment()->getAdditionalInformation('alias');
|
49 |
+
if (is_null($alias) && $this->getDataHelper()->isAdminSession()) {
|
50 |
+
$alias = $this->getAliasHelper()->getAlias($quote);
|
51 |
+
}
|
52 |
+
$params = array (
|
53 |
+
'ALIAS' => $alias
|
54 |
+
);
|
55 |
+
if($this->getConfig()->getCreditDebitSplit($quote->getStoreId())){
|
56 |
+
$params['CREDITDEBIT'] = 'C';
|
57 |
+
}
|
58 |
+
if (is_numeric($quote->getPayment()->getAdditionalInformation('cvc'))) {
|
59 |
+
$params['CVC'] = $quote->getPayment()->getAdditionalInformation('cvc');
|
60 |
+
}
|
61 |
+
$requestParams3ds = array();
|
62 |
+
if ($this->getConfig()->get3dSecureIsActive() && false == $this->getDataHelper()->isAdminSession()) {
|
63 |
+
$requestParams3ds = array(
|
64 |
+
'FLAG3D' => 'Y',
|
65 |
+
'WIN3DS' => Netresearch_OPS_Model_Payment_Abstract::OPS_DIRECTLINK_WIN3DS,
|
66 |
+
'LANGUAGE' => Mage::app()->getLocale()->getLocaleCode(),
|
67 |
+
'HTTP_ACCEPT' => '*/*',
|
68 |
+
'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
|
69 |
+
'ACCEPTURL' => $this->getConfig()->getAcceptUrl(),
|
70 |
+
'DECLINEURL' => $this->getConfig()->getDeclineUrl(),
|
71 |
+
'EXCEPTIONURL' => $this->getConfig()->getExceptionUrl(),
|
72 |
+
);
|
73 |
+
}
|
74 |
+
$params = array_merge($params, $requestParams3ds);
|
75 |
+
return $params;
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Data.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Helper_Data
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Data extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
const LOG_FILE_NAME = 'ops.log';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Returns config model
|
17 |
+
*
|
18 |
+
* @return Netresearch_OPS_Model_Config
|
19 |
+
*/
|
20 |
+
public function getConfig()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('ops/config');
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Replace all dots or any content following and including plus ("+") and minus ("-") signs.
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getModuleVersionString()
|
30 |
+
{
|
31 |
+
$version = Mage::getConfig()->getNode('modules/Netresearch_OPS/version');
|
32 |
+
$plainversion = preg_replace('/\.|[+-].+$/','', $version);
|
33 |
+
return 'AC1X' . $plainversion;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Checks if logging is enabled and if yes, logs given message to logfile
|
38 |
+
*
|
39 |
+
* @param string $message
|
40 |
+
* @param int $level
|
41 |
+
*/
|
42 |
+
public function log($message, $level = null)
|
43 |
+
{
|
44 |
+
$separator = "\n"."===================================================================";
|
45 |
+
$message = $this->clearMsg($message);
|
46 |
+
if ($this->getConfig()->shouldLogRequests()) {
|
47 |
+
Mage::log($message.$separator, $level, self::LOG_FILE_NAME);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Returns full path to ops.log
|
53 |
+
*/
|
54 |
+
public function getLogPath()
|
55 |
+
{
|
56 |
+
return Mage::getBaseDir('log'). DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* deletes certain keys from the message which is going to logged
|
62 |
+
*
|
63 |
+
* @param $message - the message
|
64 |
+
*
|
65 |
+
* @return array - the cleared message
|
66 |
+
*/
|
67 |
+
public function clearMsg($message)
|
68 |
+
{
|
69 |
+
if (is_array($message)) {
|
70 |
+
$keysToBeDeleted = array('cvc', 'CVC');
|
71 |
+
foreach ($keysToBeDeleted as $keyToDelete) {
|
72 |
+
if (array_key_exists($keyToDelete, $message)) {
|
73 |
+
unset($message[$keyToDelete]);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
if (is_string($message)) {
|
78 |
+
$message = preg_replace('/"CVC":".*"(,)/i','',$message);
|
79 |
+
$message = preg_replace('/"CVC":".*"/i','',$message);
|
80 |
+
$message = preg_replace('/"CVC".*"[A-Z]*";/','',$message);
|
81 |
+
$message = preg_replace('/"CVC":".*"(})/i','}',$message);
|
82 |
+
}
|
83 |
+
return $message;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function redirect($url)
|
87 |
+
{
|
88 |
+
Mage::app()->getResponse()->setRedirect($url);
|
89 |
+
Mage::app()->getResponse()->sendResponse();
|
90 |
+
exit();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Redirects to the given order and prints some notice output
|
95 |
+
*
|
96 |
+
* @param int $orderId
|
97 |
+
* @param string $message
|
98 |
+
* @return void
|
99 |
+
*/
|
100 |
+
public function redirectNoticed($orderId, $message)
|
101 |
+
{
|
102 |
+
Mage::getSingleton('core/session')->addNotice($message);
|
103 |
+
$this->redirect(
|
104 |
+
Mage::getUrl('*/sales_order/view', array('order_id' => $orderId))
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getStatusText($statusCode)
|
109 |
+
{
|
110 |
+
$translationOrigin = "STATUS_".$statusCode;
|
111 |
+
$translationResult = $this->__($translationOrigin);
|
112 |
+
if ($translationOrigin != $translationResult):
|
113 |
+
return $translationResult. " ($statusCode)";
|
114 |
+
else:
|
115 |
+
return $statusCode;
|
116 |
+
endif;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getAmount($amount)
|
120 |
+
{
|
121 |
+
return round($amount * 100);
|
122 |
+
}
|
123 |
+
|
124 |
+
public function getAdminSession()
|
125 |
+
{
|
126 |
+
return Mage::getSingleton('admin/session');
|
127 |
+
}
|
128 |
+
|
129 |
+
public function isAdminSession()
|
130 |
+
{
|
131 |
+
if ($this->getAdminSession()->getUser()) {
|
132 |
+
return 0 < $this->getAdminSession()->getUser()->getUserId() || $this->getAdminSession()->isLoggedIn();
|
133 |
+
}
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
+
/*
|
138 |
+
* check if user is registering or not
|
139 |
+
*/
|
140 |
+
public function checkIfUserIsRegistering()
|
141 |
+
{
|
142 |
+
$isRegistering = false;
|
143 |
+
$checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
|
144 |
+
if ($checkoutMethod === Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER
|
145 |
+
|| $checkoutMethod === Mage_Sales_Model_Quote::CHECKOUT_METHOD_LOGIN_IN
|
146 |
+
) {
|
147 |
+
$isRegistering = true;
|
148 |
+
}
|
149 |
+
return $isRegistering;
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
/*
|
154 |
+
* check if user is registering or not
|
155 |
+
*/
|
156 |
+
public function checkIfUserIsNotRegistering()
|
157 |
+
{
|
158 |
+
$isRegistering = false;
|
159 |
+
$checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
|
160 |
+
if ($checkoutMethod === Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER) {
|
161 |
+
$isRegistering = true;
|
162 |
+
}
|
163 |
+
return $isRegistering;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Trigger sending order confirmation and invoice emails when Magento does not:
|
169 |
+
* - "authorization" after return from gateway (order emails)
|
170 |
+
* - "authorization+capture" (order or invoice emails)
|
171 |
+
*
|
172 |
+
* @param Mage_Sales_Model_Abstract $document
|
173 |
+
* @return Mage_Sales_Model_Abstract
|
174 |
+
* @throws Exception
|
175 |
+
*/
|
176 |
+
public function sendTransactionalEmail(Mage_Sales_Model_Abstract $document)
|
177 |
+
{
|
178 |
+
if ($document instanceof Mage_Sales_Model_Order) {
|
179 |
+
|
180 |
+
if (!$document->getEmailSent() && $document->getCanSendNewEmailFlag()) {
|
181 |
+
$document->sendNewOrderEmail();
|
182 |
+
}
|
183 |
+
|
184 |
+
} elseif ($document instanceof Mage_Sales_Model_Order_Invoice) {
|
185 |
+
|
186 |
+
if (!$document->getEmailSent() && Mage::getModel('ops/config')->getSendInvoice()) {
|
187 |
+
$document->sendEmail();
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
return $document;
|
193 |
+
}
|
194 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Debitcard.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Helper_Debitcard extends Netresearch_OPS_Helper_Creditcard
|
12 |
+
{
|
13 |
+
protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote)
|
14 |
+
{
|
15 |
+
$params = parent::getPaymentSpecificParams($quote);
|
16 |
+
if($this->getConfig()->getCreditDebitSplit($quote->getStoreId())){
|
17 |
+
$params['CREDITDEBIT'] = 'D';
|
18 |
+
}
|
19 |
+
return $params;
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Netresearch/OPS/Helper/DirectDebit.php
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @package Netresearch_OPS
|
7 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
8 |
+
* (http://www.netresearch.de)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_DirectDebit extends Netresearch_OPS_Helper_Payment_DirectLink_Request
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $dataHelper = null;
|
15 |
+
|
16 |
+
protected $quoteHelper = null;
|
17 |
+
|
18 |
+
protected $orderHelper = null;
|
19 |
+
|
20 |
+
protected $customerHelper = null;
|
21 |
+
|
22 |
+
protected $validator = null;
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* sets the data helper
|
29 |
+
*
|
30 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
31 |
+
*/
|
32 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper)
|
33 |
+
{
|
34 |
+
$this->dataHelper = $dataHelper;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* gets the data helper
|
39 |
+
*
|
40 |
+
* @return Mage_Core_Helper_Abstract
|
41 |
+
*/
|
42 |
+
public function getDataHelper()
|
43 |
+
{
|
44 |
+
if (null === $this->dataHelper) {
|
45 |
+
$this->dataHelper = Mage::helper('ops/data');
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->dataHelper;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* sets the quote helper
|
53 |
+
*
|
54 |
+
* @param Netresearch_OPS_Helper_Quote $quoteHelper
|
55 |
+
*/
|
56 |
+
public function setQuoteHelper(Netresearch_OPS_Helper_Quote $quoteHelper)
|
57 |
+
{
|
58 |
+
$this->quoteHelper = $quoteHelper;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* gets the quote helper
|
63 |
+
*
|
64 |
+
* @return Mage_Core_Helper_Abstract
|
65 |
+
*/
|
66 |
+
public function getQuoteHelper()
|
67 |
+
{
|
68 |
+
if (null === $this->quoteHelper) {
|
69 |
+
$this->quoteHelper = Mage::helper('ops/quote');
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->quoteHelper;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* sets the order helper
|
77 |
+
*
|
78 |
+
* @param Netresearch_OPS_Helper_Order $orderHelper
|
79 |
+
*/
|
80 |
+
public function setOrderHelper(Netresearch_OPS_Helper_Order $orderHelper)
|
81 |
+
{
|
82 |
+
$this->orderHelper = $orderHelper;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* gets the order helper
|
87 |
+
*
|
88 |
+
* @return Mage_Core_Helper_Abstract
|
89 |
+
*/
|
90 |
+
public function getOrderHelper()
|
91 |
+
{
|
92 |
+
if (null === $this->orderHelper) {
|
93 |
+
$this->orderHelper = Mage::helper('ops/order');
|
94 |
+
}
|
95 |
+
|
96 |
+
return $this->orderHelper;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* sets the customer helper
|
101 |
+
*
|
102 |
+
* @param Mage_Core_Helper_Abstract $customerHelper
|
103 |
+
*/
|
104 |
+
public function setCustomerHelper(Mage_Core_Helper_Abstract $customerHelper)
|
105 |
+
{
|
106 |
+
$this->customerHelper = $customerHelper;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* gets the customer helper
|
111 |
+
*
|
112 |
+
* @return Mage_Core_Helper_Abstract
|
113 |
+
*/
|
114 |
+
public function getCustomerHelper()
|
115 |
+
{
|
116 |
+
if (null === $this->customerHelper) {
|
117 |
+
$this->customerHelper = Mage::helper('customer/data');
|
118 |
+
}
|
119 |
+
|
120 |
+
return $this->customerHelper;
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
/**
|
125 |
+
* sets the validator
|
126 |
+
*
|
127 |
+
* @param Netresearch_OPS_Model_Validator_Payment_DirectDebit $validator
|
128 |
+
*/
|
129 |
+
public function setValidator(
|
130 |
+
Netresearch_OPS_Model_Validator_Payment_DirectDebit $validator
|
131 |
+
)
|
132 |
+
{
|
133 |
+
$this->validator = $validator;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* gets the validator
|
138 |
+
*
|
139 |
+
* @return Netresearch_OPS_Model_Validator_Payment_DirectDebit
|
140 |
+
*/
|
141 |
+
public function getValidator()
|
142 |
+
{
|
143 |
+
if (null === $this->validator) {
|
144 |
+
$this->validator = Mage::getModel(
|
145 |
+
'ops/validator_payment_directDebit'
|
146 |
+
);
|
147 |
+
}
|
148 |
+
|
149 |
+
return $this->validator;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* gets the country from a given array
|
154 |
+
*
|
155 |
+
* @param array $params
|
156 |
+
*
|
157 |
+
* @return string - the country in uppercase, empty string if no country
|
158 |
+
* was provided
|
159 |
+
*/
|
160 |
+
public function getCountry(array $params)
|
161 |
+
{
|
162 |
+
$country = '';
|
163 |
+
if (array_key_exists('country', $params)) {
|
164 |
+
$country = strtoupper($params['country']);
|
165 |
+
}
|
166 |
+
|
167 |
+
return $country;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* checks whether the given data has an iban field or not
|
172 |
+
*
|
173 |
+
* @param array $accountData
|
174 |
+
*
|
175 |
+
* @return bool - true if iban field is present and filled, false otherwise
|
176 |
+
*/
|
177 |
+
public function hasIban(array $accountData)
|
178 |
+
{
|
179 |
+
return array_key_exists('iban', $accountData)
|
180 |
+
&& 0 < strlen(trim($accountData['iban']));
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* sets the direct debit data to given payment
|
185 |
+
*
|
186 |
+
* @param Mage_Sales_Model_Quote_Payment $payment - the payment which
|
187 |
+
* should contain the
|
188 |
+
* additional data
|
189 |
+
* @param array $params -
|
190 |
+
*
|
191 |
+
* @return Mage_Sales_Model_Quote_Payment
|
192 |
+
*/
|
193 |
+
public function setDirectDebitDataToPayment(
|
194 |
+
Mage_Sales_Model_Quote_Payment $payment, array $params
|
195 |
+
)
|
196 |
+
{
|
197 |
+
$payment->setAdditionalInformation(
|
198 |
+
'PM', 'Direct Debits ' . $this->getCountry($params)
|
199 |
+
);
|
200 |
+
$this->setAccountHolder($payment, $params);
|
201 |
+
$this->setAccountData($payment, $params);
|
202 |
+
|
203 |
+
return $payment;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* sets the account holder to given payment
|
208 |
+
*
|
209 |
+
* @param Mage_Sales_Model_Quote_Payment $payment
|
210 |
+
* @param array $params
|
211 |
+
*/
|
212 |
+
protected function setAccountHolder(
|
213 |
+
Mage_Sales_Model_Quote_Payment $payment, array $params
|
214 |
+
)
|
215 |
+
{
|
216 |
+
if (array_key_exists('CN', $params)
|
217 |
+
&& 0 < strlen(trim($params['CN']))
|
218 |
+
) {
|
219 |
+
$payment->setAdditionalInformation('CN', trim($params['CN']));
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* set the account data to given payment
|
225 |
+
*
|
226 |
+
* @param Mage_Sales_Model_Quote_Payment $payment
|
227 |
+
* @param array $params
|
228 |
+
*/
|
229 |
+
protected function setAccountData(
|
230 |
+
Mage_Sales_Model_Quote_Payment $payment, array $params
|
231 |
+
)
|
232 |
+
{
|
233 |
+
$country = $this->getCountry($params);
|
234 |
+
|
235 |
+
if ('DE' == $country || 'AT' == $country) {
|
236 |
+
if ($this->hasIban($params) && 'DE' == $country) {
|
237 |
+
$payment->setAdditionalInformation(
|
238 |
+
'CARDNO', trim($params['iban'])
|
239 |
+
);
|
240 |
+
} else {
|
241 |
+
$payment->setAdditionalInformation(
|
242 |
+
'CARDNO',
|
243 |
+
trim($params['account']) . 'BLZ' . trim($params['bankcode'])
|
244 |
+
);
|
245 |
+
}
|
246 |
+
|
247 |
+
|
248 |
+
}
|
249 |
+
if ('NL' == $country) {
|
250 |
+
if ($this->hasIban($params)) {
|
251 |
+
$payment->setAdditionalInformation(
|
252 |
+
'CARDNO', trim($params['iban'])
|
253 |
+
);
|
254 |
+
$payment->setAdditionalInformation('BIC', trim($params['bic']));
|
255 |
+
} else {
|
256 |
+
$payment->setAdditionalInformation(
|
257 |
+
'CARDNO', str_pad($params['account'], '0', STR_PAD_LEFT)
|
258 |
+
);
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* validates direct debit payment from the backend
|
265 |
+
*
|
266 |
+
* @param $requestParams - the params passed on order submission
|
267 |
+
* @throws Mage_Core_Exception - if the data is not valid
|
268 |
+
* @return boolean - true if data were valid
|
269 |
+
*/
|
270 |
+
protected function validateAdminDirectDebit($requestParams)
|
271 |
+
{
|
272 |
+
$validator = $this->getValidator();
|
273 |
+
if (false === $validator->isValid($requestParams)) {
|
274 |
+
Mage::getModel('adminhtml/session')->setData('ops_direct_debit_params', $requestParams);
|
275 |
+
Mage::throwException(
|
276 |
+
implode('<br />', $validator->getMessages())
|
277 |
+
);
|
278 |
+
}
|
279 |
+
return true;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param Mage_Sales_Model_Quote $quote
|
284 |
+
* @param array $requestParams
|
285 |
+
* @return Netresearch_OPS_Helper_DirectDebit
|
286 |
+
*/
|
287 |
+
public function handleAdminPayment(Mage_Sales_Model_Quote $quote, $requestParams)
|
288 |
+
{
|
289 |
+
if ($this->getDataHelper()->isAdminSession() && is_array($requestParams)) {
|
290 |
+
$this->validateAdminDirectDebit($requestParams);
|
291 |
+
$this->setDirectDebitDataToPayment($quote->getPayment(), $requestParams);
|
292 |
+
$quote->getPayment()->save();
|
293 |
+
}
|
294 |
+
|
295 |
+
return $this;
|
296 |
+
}
|
297 |
+
|
298 |
+
protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote)
|
299 |
+
{
|
300 |
+
$cardHolderName = $quote->getPayment()->getAdditionalInformation('CN');
|
301 |
+
$params = array(
|
302 |
+
'CARDNO' => $quote->getPayment()->getAdditionalInformation('CARDNO'),
|
303 |
+
'CN' => utf8_decode($cardHolderName),
|
304 |
+
// Always the same on direct debit
|
305 |
+
'ED' => '9999',
|
306 |
+
'PM' => $quote->getPayment()->getAdditionalInformation('PM'),
|
307 |
+
);
|
308 |
+
if (0 < strlen(trim($quote->getPayment()->getAdditionalInformation('BIC')))) {
|
309 |
+
$bic = $quote->getPayment()->getAdditionalInformation('BIC');
|
310 |
+
$params['BIC'] = $bic;
|
311 |
+
}
|
312 |
+
$params['BRAND'] = $params['PM'];
|
313 |
+
|
314 |
+
return $params;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
app/code/community/Netresearch/OPS/Helper/Directlink.php
ADDED
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Helper_DirectLink
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Helper_Directlink extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Creates Transactions for directlink activities
|
14 |
+
*
|
15 |
+
* @param Mage_Sales_Model_Order $order
|
16 |
+
* @param int $transactionID - persistent transaction id
|
17 |
+
* @param int $subPayID - identifier for each transaction
|
18 |
+
* @param array $arrInformation - add dynamic data
|
19 |
+
* @param string $typename - name for the transaction exp.: refund
|
20 |
+
* @param string $comment - order comment
|
21 |
+
*
|
22 |
+
* @return Netresearch_OPS_Helper_Directlink $this
|
23 |
+
*/
|
24 |
+
public function directLinkTransact($order,$transactionID, $subPayID,
|
25 |
+
$arrInformation = array(), $typename, $comment, $closed = 0)
|
26 |
+
{
|
27 |
+
$payment = $order->getPayment();
|
28 |
+
$payment->setTransactionId($transactionID."/".$subPayID);
|
29 |
+
// $transaction = $payment->addTransaction($typename, null, false, $comment);
|
30 |
+
$payment->setParentTransactionId($transactionID);
|
31 |
+
$payment->setIsTransactionClosed($closed);
|
32 |
+
$payment->setTransactionAdditionalInfo($arrInformation, null);
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Checks if there is an active transaction for a special order for special
|
38 |
+
* type
|
39 |
+
*
|
40 |
+
* @param string $type - refund, capture etc.
|
41 |
+
* @param int $orderID
|
42 |
+
* @return bol success
|
43 |
+
*/
|
44 |
+
public function checkExistingTransact($type, $orderID)
|
45 |
+
{
|
46 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
47 |
+
->getCollection()
|
48 |
+
->addAttributeToFilter('order_id', $orderID)
|
49 |
+
->addAttributeToFilter('txn_type', $type)
|
50 |
+
->addAttributeToFilter('is_closed', 0)
|
51 |
+
->getLastItem();
|
52 |
+
|
53 |
+
return ($transaction->getTxnId()) ? true : false;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* get transaction type for given OPS status
|
58 |
+
*
|
59 |
+
* @param string $status
|
60 |
+
*
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getTypeForStatus($status)
|
64 |
+
{
|
65 |
+
switch ($status) {
|
66 |
+
case Netresearch_OPS_Model_Status::REFUNDED :
|
67 |
+
case Netresearch_OPS_Model_Status::REFUND_PENDING:
|
68 |
+
case Netresearch_OPS_Model_Status::REFUND_UNCERTAIN :
|
69 |
+
case Netresearch_OPS_Model_Status::REFUND_REFUSED :
|
70 |
+
case Netresearch_OPS_Model_Status::REFUNDED_OK :
|
71 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
|
72 |
+
case Netresearch_OPS_Model_Status::PAYMENT_REQUESTED :
|
73 |
+
case Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT :
|
74 |
+
case Netresearch_OPS_Model_Status::PAYMENT_PROCESSING:
|
75 |
+
case Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN:
|
76 |
+
case Netresearch_OPS_Model_Status::PAYMENT_IN_PROGRESS:
|
77 |
+
case Netresearch_OPS_Model_Status::PAYMENT_REFUSED:
|
78 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DECLINED_BY_ACQUIRER:
|
79 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
|
80 |
+
case Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED: //Void finished
|
81 |
+
case Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED_OK:
|
82 |
+
case Netresearch_OPS_Model_Status::DELETION_WAITING:
|
83 |
+
case Netresearch_OPS_Model_Status::DELETION_UNCERTAIN:
|
84 |
+
case Netresearch_OPS_Model_Status::DELETION_REFUSED:
|
85 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE;
|
86 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DELETED:
|
87 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DELETION_PENDING:
|
88 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DELETION_UNCERTAIN:
|
89 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DELETION_REFUSED:
|
90 |
+
case Netresearch_OPS_Model_Status::PAYMENT_DELETION_OK:
|
91 |
+
case Netresearch_OPS_Model_Status::DELETION_HANDLED_BY_MERCHANT:
|
92 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_DELETE_TRANSACTION_TYPE;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Process Direct Link Feedback to do: Capture, De-Capture and Refund
|
98 |
+
*
|
99 |
+
* @param Mage_Sales_Model_Order $order Order
|
100 |
+
* @param array $params Request params
|
101 |
+
*
|
102 |
+
* @return void
|
103 |
+
*/
|
104 |
+
public function processFeedback($order, $params)
|
105 |
+
{
|
106 |
+
Mage::getModel('ops/response_handler')->processResponse($params, $order->getPayment()->getMethodInstance());
|
107 |
+
$order->getPayment()->save();
|
108 |
+
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Get the payment transaction by PAYID and Operation
|
114 |
+
*
|
115 |
+
* @param Mage_Sales_Model_Order $order
|
116 |
+
* @param int $payId
|
117 |
+
* @param string $operation
|
118 |
+
*
|
119 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction
|
120 |
+
*
|
121 |
+
* @throws Mage_Core_Exception
|
122 |
+
*/
|
123 |
+
public function getPaymentTransaction($order, $payId, $operation)
|
124 |
+
{
|
125 |
+
$helper = Mage::helper('ops');
|
126 |
+
$transactionCollection = Mage::getModel('sales/order_payment_transaction')
|
127 |
+
->getCollection()
|
128 |
+
->addAttributeToFilter('txn_type', $operation)
|
129 |
+
->addAttributeToFilter('is_closed', 0)
|
130 |
+
->addAttributeToFilter('order_id', $order->getId());
|
131 |
+
if ($payId != '') {
|
132 |
+
$transactionCollection->addAttributeToFilter('parent_txn_id', $payId);
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($transactionCollection->count()>1 || $transactionCollection->count() == 0) {
|
136 |
+
$errorMsq = $helper->__(
|
137 |
+
"Warning, transaction count is %s instead of 1 for the Payid '%s', order '%s' and Operation '%s'.",
|
138 |
+
$transactionCollection->count(),
|
139 |
+
$payId,
|
140 |
+
$order->getId(),
|
141 |
+
$operation
|
142 |
+
);
|
143 |
+
$helper->log($errorMsq);
|
144 |
+
throw new Mage_Core_Exception($errorMsq);
|
145 |
+
}
|
146 |
+
|
147 |
+
if ($transactionCollection->count() == 1) {
|
148 |
+
$transaction = $transactionCollection->getLastItem();
|
149 |
+
$transaction->setOrderPaymentObject($order->getPayment());
|
150 |
+
return $transaction;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Check if there are payment transactions for an order and an operation
|
157 |
+
*
|
158 |
+
* @param Mage_Sales_Model_Order $order
|
159 |
+
* @param string $authorization
|
160 |
+
*
|
161 |
+
* @return boolean
|
162 |
+
*/
|
163 |
+
public function hasPaymentTransactions($order, $operation)
|
164 |
+
{
|
165 |
+
$transactionCollection = Mage::getModel('sales/order_payment_transaction')
|
166 |
+
->getCollection()
|
167 |
+
->addAttributeToFilter('txn_type', $operation)
|
168 |
+
->addAttributeToFilter('is_closed', 0)
|
169 |
+
->addAttributeToFilter('order_id', $order->getId());
|
170 |
+
|
171 |
+
return (0 < $transactionCollection->count());
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* validate incoming and internal amount value format and convert it to float
|
176 |
+
*
|
177 |
+
* @param string
|
178 |
+
* @return float
|
179 |
+
*/
|
180 |
+
public function formatAmount($amount)
|
181 |
+
{
|
182 |
+
// Avoid quotes added somewhere unknown
|
183 |
+
if (preg_match("/^[\"']([0-9-\..,-]+)[\"']$/i", $amount, $matches)) {
|
184 |
+
Mage::helper('ops')->log("Warning in formatAmount: Found quotes around amount in '" . var_export($amount, true) . "'");
|
185 |
+
$amount = $matches[1];
|
186 |
+
}
|
187 |
+
|
188 |
+
return number_format($amount, 2);
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* determine if the current OPS request is valid
|
193 |
+
*
|
194 |
+
* @param array $transactions Iteratable of Mage_Sales_Model_Order_Payment_Transaction
|
195 |
+
* @param Mage_Sales_Model_Order $order
|
196 |
+
* @param array $opsRequestParams
|
197 |
+
*
|
198 |
+
* @return boolean
|
199 |
+
*/
|
200 |
+
public function isValidOpsRequest($openTransaction, Mage_Sales_Model_Order $order, $opsRequestParams)
|
201 |
+
{
|
202 |
+
if ($this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_DELETE_TRANSACTION_TYPE) {
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
$requestedAmount = null;
|
207 |
+
if (array_key_exists('amount', $opsRequestParams)) {
|
208 |
+
$requestedAmount = $this->formatAmount($opsRequestParams['amount']);
|
209 |
+
}
|
210 |
+
|
211 |
+
/* find expected amount */
|
212 |
+
$expectedAmount = null;
|
213 |
+
if (false === is_null($openTransaction)) {
|
214 |
+
$transactionInfo = unserialize($openTransaction->getAdditionalInformation('arrInfo'));
|
215 |
+
if (array_key_exists('amount', $transactionInfo)) {
|
216 |
+
if (
|
217 |
+
is_null($expectedAmount)
|
218 |
+
|| $transactionInfo['amount'] == $requestedAmount
|
219 |
+
) {
|
220 |
+
$expectedAmount = $this->formatAmount($transactionInfo['amount']);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
if ($this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE
|
226 |
+
|| $this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE
|
227 |
+
) {
|
228 |
+
if (is_null($requestedAmount)
|
229 |
+
|| 0 == count($openTransaction)
|
230 |
+
|| $requestedAmount != $expectedAmount
|
231 |
+
) {
|
232 |
+
return false;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
if ($this->getTypeForStatus($opsRequestParams['STATUS']) == Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE) {
|
237 |
+
if (is_null($requestedAmount)) {
|
238 |
+
Mage::helper('ops')->log('Please configure Acceptance to submit amount');
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
$grandTotal = $this->formatAmount(Mage::helper('ops/payment')->getBaseGrandTotalFromSalesObject($order));
|
242 |
+
if ($grandTotal != $requestedAmount) {
|
243 |
+
if (is_null($openTransaction)
|
244 |
+
|| $expectedAmount != $requestedAmount
|
245 |
+
) {
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
return true;
|
251 |
+
}
|
252 |
+
|
253 |
+
public function performDirectLinkRequest($quote, $params, $storeId = null)
|
254 |
+
{
|
255 |
+
$url = Mage::getModel('ops/config')->getDirectLinkGatewayOrderPath($storeId);
|
256 |
+
$response = Mage::getSingleton('ops/api_directlink')->performRequest($params, $url, $storeId);
|
257 |
+
/**
|
258 |
+
* allow null as valid state for creating the order with status 'pending'
|
259 |
+
*/
|
260 |
+
if (!is_null($response['STATUS'])
|
261 |
+
&& Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
|
262 |
+
) {
|
263 |
+
Mage::getSingleton('checkout/type_onepage')->getCheckout()->setGotoSection('payment');
|
264 |
+
throw new Mage_Core_Exception(Mage::helper('ops/data')->__('Acceptance Payment failed'));
|
265 |
+
}
|
266 |
+
return $response;
|
267 |
+
}
|
268 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Kwixo.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Kwixo
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2013 Netresearch
|
8 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Kwixo extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
private $helper = null;
|
15 |
+
|
16 |
+
protected function getHelper()
|
17 |
+
{
|
18 |
+
if (null === $this->helper) {
|
19 |
+
$this->helper = Mage::helper('ops/data');
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->helper;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* validates the kwixoConfiguration data
|
27 |
+
*
|
28 |
+
* @param array $postData the data to validate
|
29 |
+
*
|
30 |
+
* @throws Mage_Core_Exception on errors
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function validateKwixoconfigurationMapping(array $postData)
|
34 |
+
{
|
35 |
+
$this->validateKwixoConfigurationData($postData);
|
36 |
+
$this->validateKwixoMappingExist($postData);
|
37 |
+
$this->validateCategoryExist($postData);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* saves the KwixoConfigurationMapping
|
42 |
+
*
|
43 |
+
* @param array $postData
|
44 |
+
*/
|
45 |
+
public function saveKwixoconfigurationMapping(array $postData)
|
46 |
+
{
|
47 |
+
$this->validateKwixoconfigurationMapping($postData);
|
48 |
+
$kwixoCatMapModel = Mage::getModel(
|
49 |
+
'ops/kwixo_category_mapping'
|
50 |
+
)->load($postData['id']);
|
51 |
+
$kwixoCatMapModel->setCategoryId($postData['category_id']);
|
52 |
+
$kwixoCatMapModel->setKwixoCategoryId(
|
53 |
+
$postData['kwixoCategory_id']
|
54 |
+
);
|
55 |
+
$kwixoCatMapModel->save();
|
56 |
+
if (array_key_exists('applysubcat', $postData)) {
|
57 |
+
$category = Mage::getModel('catalog/category')->load(
|
58 |
+
$postData['category_id']
|
59 |
+
);
|
60 |
+
$subcategories = $category->getAllChildren(true);
|
61 |
+
foreach ($subcategories as $subcategory) {
|
62 |
+
$kwixoCatMapModel = Mage::getModel(
|
63 |
+
'ops/kwixo_category_mapping'
|
64 |
+
)->loadByCategoryId($subcategory);
|
65 |
+
$kwixoCatMapModel->setCategoryId($subcategory);
|
66 |
+
$kwixoCatMapModel->setKwixoCategoryId(
|
67 |
+
$postData['kwixoCategory_id']
|
68 |
+
);
|
69 |
+
$kwixoCatMapModel->save();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
73 |
+
Mage::helper('ops/data')->__(
|
74 |
+
'Successfully added Kwixo category mapping'
|
75 |
+
)
|
76 |
+
);
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* validates if the structure of a given array does match the expected kwixo
|
82 |
+
* setting configuration
|
83 |
+
*
|
84 |
+
* @param array $postData - the array to inspect
|
85 |
+
*
|
86 |
+
* @throws Mage_Core_Exception - if the structure does not match
|
87 |
+
*/
|
88 |
+
private function validateKwixoConfigurationData(array $postData)
|
89 |
+
{
|
90 |
+
$helper = $this->getHelper();
|
91 |
+
$isValid = true;
|
92 |
+
$message = '';
|
93 |
+
if (0 === count($postData)) {
|
94 |
+
$message = $helper->__('Invalid form data provided');
|
95 |
+
$isValid = false;
|
96 |
+
}
|
97 |
+
|
98 |
+
if ($isValid && !array_key_exists('id', $postData)) {
|
99 |
+
$message = $helper->__('Invalid form data provided');
|
100 |
+
$isValid = false;
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($isValid && 0 < strlen($postData['id'])
|
104 |
+
&& (!is_numeric($postData['id'])
|
105 |
+
|| $postData['id'] < 0)
|
106 |
+
) {
|
107 |
+
$message = $helper->__('Invalid id provided');
|
108 |
+
$isValid = false;
|
109 |
+
}
|
110 |
+
if (false === $isValid) {
|
111 |
+
Mage::throwException($message);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* validates if the given array contains the neccessary information for
|
117 |
+
* a proper kwixo category setting
|
118 |
+
*
|
119 |
+
* @param array $postData - the array to inspect
|
120 |
+
*
|
121 |
+
* @throws Mage_Core_Exception - if the array does not contain the needed
|
122 |
+
* information
|
123 |
+
*
|
124 |
+
*/
|
125 |
+
private function validateKwixoMappingExist(array $postData)
|
126 |
+
{
|
127 |
+
$helper = $this->getHelper();
|
128 |
+
$kwixoCategories = Mage::getModel('ops/source_kwixo_productCategories')
|
129 |
+
->getValidKwixoCategoryIds();
|
130 |
+
if (!array_key_exists('kwixoCategory_id', $postData)
|
131 |
+
|| !in_array(
|
132 |
+
$postData['kwixoCategory_id'], $kwixoCategories
|
133 |
+
)
|
134 |
+
) {
|
135 |
+
Mage::throwException(
|
136 |
+
$helper->__('Invalid kwixo category provided')
|
137 |
+
);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* validates if the given array contains a proper category setting
|
143 |
+
*
|
144 |
+
* @param array $postData - the array to inspect
|
145 |
+
*
|
146 |
+
* @throws Mage_Core_Exception - if an invalid setting is given
|
147 |
+
*/
|
148 |
+
private function validateCategoryExist(array $postData)
|
149 |
+
{
|
150 |
+
$helper = $this->getHelper();
|
151 |
+
$isValid = true;
|
152 |
+
$message = '';
|
153 |
+
if (!array_key_exists('category_id', $postData)) {
|
154 |
+
$isValid = false;
|
155 |
+
$message = $helper->__('Invalid category provided');
|
156 |
+
|
157 |
+
}
|
158 |
+
if ($isValid
|
159 |
+
&& (!is_numeric($postData['category_id'])
|
160 |
+
|| is_null(
|
161 |
+
Mage::getModel('catalog/category')->load(
|
162 |
+
$postData['category_id']
|
163 |
+
)->getId()
|
164 |
+
))
|
165 |
+
) {
|
166 |
+
$isValid = false;
|
167 |
+
$message = $helper->__('Invalid category provided');
|
168 |
+
}
|
169 |
+
if (false === $isValid) {
|
170 |
+
Mage::throwException($message);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Order.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Order
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2013 Netresearch
|
8 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Order extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
const DELIMITER = '#';
|
15 |
+
|
16 |
+
/** @var $config Netresearch_OPS_Model_Config */
|
17 |
+
private $config = null;
|
18 |
+
|
19 |
+
protected $statusMappingModel = null;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
23 |
+
*/
|
24 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper)
|
25 |
+
{
|
26 |
+
$this->dataHelper = $dataHelper;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Netresearch_OPS_Helper_Data
|
31 |
+
*/
|
32 |
+
public function getDataHelper()
|
33 |
+
{
|
34 |
+
if (null === $this->dataHelper) {
|
35 |
+
$this->dataHelper = Mage::helper('ops/data');
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->dataHelper;
|
39 |
+
}
|
40 |
+
|
41 |
+
protected $dataHelper = null;
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* return the config model
|
46 |
+
*
|
47 |
+
* @return Netresearch_OPS_Model_Config
|
48 |
+
*/
|
49 |
+
protected function getConfig()
|
50 |
+
{
|
51 |
+
if (is_null($this->config)) {
|
52 |
+
$this->config = Mage::getModel('ops/config');
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->config;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* generates the OPS order id in dependency to the config
|
60 |
+
*
|
61 |
+
* @param mixed $salesObject
|
62 |
+
* @param bool $useOrderIdIfPossible if false forces the usage of quoteid (for Kwixo pm etc.)
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getOpsOrderId($salesObject, $useOrderIdIfPossible = true)
|
67 |
+
{
|
68 |
+
$config = $this->getConfig();
|
69 |
+
$devPrefix = $config->getConfigData('devprefix');
|
70 |
+
if ($salesObject instanceof Mage_Sales_Model_Order) {
|
71 |
+
/** @var $salesObject Mage_Sales_Model_Order */
|
72 |
+
$orderRef = $salesObject->getQuoteId();
|
73 |
+
} elseif ($salesObject instanceof Mage_Sales_Model_Quote) {
|
74 |
+
/** @var $salesObject Mage_Sales_Model_Quote */
|
75 |
+
$orderRef = $salesObject->getId();
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($config->getOrderReference($salesObject->getStoreId())
|
79 |
+
== Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
|
80 |
+
&& $useOrderIdIfPossible === true
|
81 |
+
) {
|
82 |
+
if ($salesObject instanceof Mage_Sales_Model_Quote) {
|
83 |
+
$salesObject->reserveOrderId();
|
84 |
+
$orderRef = self::DELIMITER . $salesObject->getReservedOrderId();
|
85 |
+
} elseif ($salesObject instanceof Mage_Sales_Model_Order) {
|
86 |
+
$orderRef = self::DELIMITER . $salesObject->getIncrementId();
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
return $devPrefix . $orderRef;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* getting the order from opsOrderId which can either the quote id or the order increment id
|
96 |
+
* in both cases the dev prefix is stripped, if neccessary
|
97 |
+
*
|
98 |
+
* @param $opsOrderId
|
99 |
+
*
|
100 |
+
* @return Mage_Sales_Model_Order
|
101 |
+
*/
|
102 |
+
public function getOrder($opsOrderId)
|
103 |
+
{
|
104 |
+
$order = null;
|
105 |
+
$fieldToFilter = 'quote_id';
|
106 |
+
$devPrefix = $this->getConfig()->getConfigData('devprefix');
|
107 |
+
if ($devPrefix == substr($opsOrderId, 0, strlen($devPrefix))) {
|
108 |
+
$opsOrderId = substr($opsOrderId, strlen($devPrefix));
|
109 |
+
}
|
110 |
+
// opsOrderId was created from order increment id, use increment id for filtering
|
111 |
+
if (0 === strpos($opsOrderId, self::DELIMITER)) {
|
112 |
+
$opsOrderId = substr($opsOrderId, strlen(self::DELIMITER));
|
113 |
+
$fieldToFilter = 'increment_id';
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
/* @var $order Mage_Sales_Model_Resource_Order_Collection */
|
118 |
+
$order = Mage::getModel('sales/order')->getCollection()
|
119 |
+
->addFieldToFilter($fieldToFilter, $opsOrderId)
|
120 |
+
// filter for OPS payment methods
|
121 |
+
->join(array('payment' => 'sales/order_payment'), 'main_table.entity_id=parent_id', 'method')
|
122 |
+
->addFieldToFilter('method', array(array('like' => 'ops_%')))
|
123 |
+
// sort by increment_id of order to get only the latest (relevant for quote id search)
|
124 |
+
->addOrder('main_table.increment_id');
|
125 |
+
|
126 |
+
return $order->getFirstItem();
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* load and return the quote via the quoteId
|
131 |
+
*
|
132 |
+
* @param string $quoteId
|
133 |
+
*
|
134 |
+
* @return Mage_Model_Sales_Quote
|
135 |
+
*/
|
136 |
+
public function getQuote($quoteId)
|
137 |
+
{
|
138 |
+
return Mage::getModel('sales/quote')->load($quoteId);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* check if billing is same as shipping address
|
143 |
+
*
|
144 |
+
* @param Mage_Model_Sales_Order $order
|
145 |
+
*
|
146 |
+
* @return int
|
147 |
+
*/
|
148 |
+
public function checkIfAddressesAreSame(Mage_Sales_Model_Order $order)
|
149 |
+
{
|
150 |
+
$addMatch = 0;
|
151 |
+
$billingAddressHash = null;
|
152 |
+
$shippingAddressHash = null;
|
153 |
+
if ($order->getBillingAddress() instanceof Mage_Customer_Model_Address_Abstract) {
|
154 |
+
$billingAddressHash = Mage::helper('ops/alias')->generateAddressHash(
|
155 |
+
$order->getBillingAddress()
|
156 |
+
);
|
157 |
+
}
|
158 |
+
if ($order->getShippingAddress() instanceof Mage_Customer_Model_Address_Abstract) {
|
159 |
+
$shippingAddressHash = Mage::helper('ops/alias')->generateAddressHash(
|
160 |
+
$order->getShippingAddress()
|
161 |
+
);
|
162 |
+
}
|
163 |
+
|
164 |
+
if ($billingAddressHash === $shippingAddressHash) {
|
165 |
+
$addMatch = 1;
|
166 |
+
}
|
167 |
+
|
168 |
+
return $addMatch;
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Order/Abstract.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PhpStorm.
|
5 |
+
* User: paul.siedler
|
6 |
+
* Date: 18.09.2014
|
7 |
+
* Time: 13:48
|
8 |
+
*/
|
9 |
+
abstract class Netresearch_OPS_Helper_Order_Abstract extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Return partial operation code for transaction type
|
13 |
+
*
|
14 |
+
* @return string Operation code defined in Netresearch_OPS_Model_Payment_Abstract
|
15 |
+
*/
|
16 |
+
protected abstract function getPartialOperationCode();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Return full operation code for transaction type
|
20 |
+
*
|
21 |
+
* @return string Operation code defined in Netresearch_OPS_Model_Payment_Abstract
|
22 |
+
*/
|
23 |
+
protected abstract function getFullOperationCode();
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Checks if partial capture and returns 'full' or 'partial'
|
28 |
+
*
|
29 |
+
* @param Mage_Sales_Order_Payment $payment
|
30 |
+
* @param float $amount
|
31 |
+
* @return string 'partial' if type is partial, else 'full'
|
32 |
+
*/
|
33 |
+
public function determineType($payment, $amount)
|
34 |
+
{
|
35 |
+
$orderTotalAmount = round(
|
36 |
+
(Mage::helper('ops/payment')->getBaseGrandTotalFromSalesObject($payment->getOrder())) * 100,
|
37 |
+
0
|
38 |
+
);
|
39 |
+
$amount = round(($amount * 100), 0);
|
40 |
+
|
41 |
+
if (abs($orderTotalAmount - $amount) <= 1) {
|
42 |
+
return 'full';
|
43 |
+
} else {
|
44 |
+
return 'partial';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* checks if the amount captured/refunded is equal to the amount of the full order
|
51 |
+
* and returns the operation code accordingly
|
52 |
+
*
|
53 |
+
* @param Mage_Sales_Order_Payment $payment
|
54 |
+
* @param float $amount
|
55 |
+
* @return string operation code for the requested amount
|
56 |
+
* @see getPartialOperationCode() and getFullOperationCode() *
|
57 |
+
*/
|
58 |
+
public function determineOperationCode($payment, $amount)
|
59 |
+
{
|
60 |
+
$orderTotalAmount = round(
|
61 |
+
(Mage::helper('ops/payment')->getBaseGrandTotalFromSalesObject($payment->getOrder())) * 100,
|
62 |
+
0
|
63 |
+
);
|
64 |
+
$totalProcessedAmount = round((($this->getPreviouslyProcessedAmount($payment) + $amount) * 100), 0);
|
65 |
+
|
66 |
+
if (abs($orderTotalAmount - $totalProcessedAmount) <= 1 ) {
|
67 |
+
return $this->getFullOperationCode();
|
68 |
+
} else {
|
69 |
+
return $this->getPartialOperationCode();
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns the Amount already processed for this kind of operation
|
76 |
+
* eg. getBaseAmountPaidOnline and getRefundedAmount
|
77 |
+
*
|
78 |
+
* @param Mage_Sales_Order_Payment $payment
|
79 |
+
* @return float amount already processed for this kind of operation
|
80 |
+
*/
|
81 |
+
protected abstract function getPreviouslyProcessedAmount($payment);
|
82 |
+
|
83 |
+
|
84 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Order/Capture.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Order_Capture
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2011 Netresearch
|
8 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Order_Capture extends Netresearch_OPS_Helper_Order_Abstract
|
12 |
+
{
|
13 |
+
protected function getFullOperationCode()
|
14 |
+
{
|
15 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_FULL;
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function getPartialOperationCode()
|
19 |
+
{
|
20 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL;
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function getPreviouslyProcessedAmount($payment)
|
24 |
+
{
|
25 |
+
return $payment->getBaseAmountPaidOnline();
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Prepare capture informations
|
31 |
+
*
|
32 |
+
* @param Mage_Sales_Order_Payment $payment
|
33 |
+
* @param float $amount
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function prepareOperation($payment, $amount)
|
37 |
+
{
|
38 |
+
$params = Mage::app()->getRequest()->getParams();
|
39 |
+
if (array_key_exists('invoice', $params)) {
|
40 |
+
$arrInfo = $params['invoice'];
|
41 |
+
$arrInfo['amount'] = $amount;
|
42 |
+
}
|
43 |
+
$arrInfo['type'] = $this->determineType($payment, $amount);
|
44 |
+
$arrInfo['operation'] = $this->determineOperationCode($payment, $amount);
|
45 |
+
|
46 |
+
return $arrInfo;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Prepare shipment
|
51 |
+
*
|
52 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice New invoice
|
53 |
+
* @param array $additionalData Array containing additional transaction data
|
54 |
+
*
|
55 |
+
* @return Mage_Sales_Model_Order_Shipment
|
56 |
+
*/
|
57 |
+
protected function _prepareShipment($invoice, $additionalData)
|
58 |
+
{
|
59 |
+
$savedQtys = $additionalData['items'];
|
60 |
+
$shipment = Mage::getModel('sales/service_order', $invoice->getOrder())
|
61 |
+
->prepareShipment($savedQtys);
|
62 |
+
if (!$shipment->getTotalQty()) {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$shipment->register();
|
67 |
+
if (array_key_exists('tracking', $additionalData)
|
68 |
+
&& $additionalData['tracking']
|
69 |
+
) {
|
70 |
+
foreach ($additionalData['tracking'] as $data) {
|
71 |
+
$track = Mage::getModel('sales/order_shipment_track')
|
72 |
+
->addData($data);
|
73 |
+
$shipment->addTrack($track);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return $shipment;
|
78 |
+
}
|
79 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Order/Refund.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Order_Refund
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2011 Netresearch
|
8 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Order_Refund extends Netresearch_OPS_Helper_Order_Abstract
|
12 |
+
{
|
13 |
+
protected $payment;
|
14 |
+
protected $amount;
|
15 |
+
protected $params;
|
16 |
+
|
17 |
+
protected function getFullOperationCode()
|
18 |
+
{
|
19 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL;
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function getPartialOperationCode()
|
23 |
+
{
|
24 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function getPreviouslyProcessedAmount($payment)
|
28 |
+
{
|
29 |
+
return $payment->getBaseAmountRefundedOnline();
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param Varien_Object $payment
|
35 |
+
*/
|
36 |
+
public function setPayment(Varien_Object $payment)
|
37 |
+
{
|
38 |
+
$this->payment = $payment;
|
39 |
+
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param float $amount
|
45 |
+
*/
|
46 |
+
public function setAmount($amount)
|
47 |
+
{
|
48 |
+
$this->amount = $amount;
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param array $params
|
55 |
+
* @return $this
|
56 |
+
*/
|
57 |
+
public function setCreditMemoRequestParams($params)
|
58 |
+
{
|
59 |
+
$this->params = $params;
|
60 |
+
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return array params
|
66 |
+
*/
|
67 |
+
public function getCreditMemoRequestParams()
|
68 |
+
{
|
69 |
+
if (!is_array($this->params)) {
|
70 |
+
$this->setCreditMemoRequestParams(Mage::app()->getRequest()->getParams());
|
71 |
+
}
|
72 |
+
|
73 |
+
return $this->params;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getInvoiceFromCreditMemoRequest()
|
77 |
+
{
|
78 |
+
$params = $this->getCreditMemoRequestParams();
|
79 |
+
if (array_key_exists('invoice_id', $params)) {
|
80 |
+
return Mage::getModel('sales/order_invoice')->load($params['invoice_id']);
|
81 |
+
}
|
82 |
+
|
83 |
+
return null;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getCreditMemoFromRequest()
|
87 |
+
{
|
88 |
+
$params = $this->getCreditMemoRequestParams();
|
89 |
+
if (array_key_exists('creditmemo', $params)) {
|
90 |
+
return $params['creditmemo'];
|
91 |
+
}
|
92 |
+
|
93 |
+
return array();
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
98 |
+
* @param float $amount
|
99 |
+
*/
|
100 |
+
public function prepareOperation($payment, $amount)
|
101 |
+
{
|
102 |
+
$params = $this->getCreditMemoRequestParams();
|
103 |
+
|
104 |
+
if (array_key_exists('creditmemo', $params)) {
|
105 |
+
$arrInfo = $params['creditmemo'];
|
106 |
+
$arrInfo['amount'] = $amount;
|
107 |
+
}
|
108 |
+
$arrInfo['type'] = $this->determineType($payment, $amount);
|
109 |
+
$arrInfo['operation'] = $this->determineOperationCode($payment, $amount);
|
110 |
+
|
111 |
+
if($arrInfo['type'] == 'full'){
|
112 |
+
// hard overwrite operation code for last transaction
|
113 |
+
$arrInfo['operation'] = $this->getFullOperationCode();
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
return $arrInfo;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Checks for open refund transaction
|
122 |
+
*
|
123 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
124 |
+
*
|
125 |
+
* @return Mage_Sales_Model_Order_Payment_Transaction|null
|
126 |
+
*/
|
127 |
+
public function getOpenRefundTransaction($payment){
|
128 |
+
/** @var Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection $refundTransactions */
|
129 |
+
$refundTransactions = Mage::getModel('sales/order_payment_transaction')->getCollection();
|
130 |
+
$transaction = $refundTransactions->addPaymentIdFilter($payment->getId())
|
131 |
+
->addTxnTypeFilter(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND)
|
132 |
+
->setOrderFilter($payment->getOrder())
|
133 |
+
->addFieldToFilter('is_closed', 0)
|
134 |
+
->getFirstItem();
|
135 |
+
|
136 |
+
return $transaction;
|
137 |
+
}
|
138 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Payment.php
ADDED
@@ -0,0 +1,1174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Payment
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2011 Netresearch
|
8 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
9 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
10 |
+
* @license OSL 3.0
|
11 |
+
*/
|
12 |
+
class Netresearch_OPS_Helper_Payment extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
protected $shaAlgorithm = null;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get checkout session namespace
|
18 |
+
*
|
19 |
+
* @return Mage_Checkout_Model_Session
|
20 |
+
*/
|
21 |
+
protected function _getCheckout()
|
22 |
+
{
|
23 |
+
return Mage::getSingleton('checkout/session');
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Get checkout session namespace
|
28 |
+
*
|
29 |
+
* @return Netresearch_OPS_Model_Config
|
30 |
+
*/
|
31 |
+
protected function getConfig()
|
32 |
+
{
|
33 |
+
return Mage::getSingleton('ops/config');
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get encrypt / decrypt algorithm
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function getCryptMethod()
|
42 |
+
{
|
43 |
+
if (null === $this->shaAlgorithm) {
|
44 |
+
$this->shaAlgorithm = $this->getConfig()->getConfigData('secret_key_type');
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this->shaAlgorithm;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Crypt Data by SHA1 ctypting algorithm by secret key
|
52 |
+
*
|
53 |
+
* @param array $data
|
54 |
+
* @param string $key
|
55 |
+
*
|
56 |
+
* @return string hash
|
57 |
+
*/
|
58 |
+
public function shaCrypt($data, $key = '')
|
59 |
+
{
|
60 |
+
if (is_array($data)) {
|
61 |
+
return hash($this->getCryptMethod(), implode("", $data));
|
62 |
+
}
|
63 |
+
if (is_string($data)) {
|
64 |
+
return hash($this->getCryptMethod(), $data);
|
65 |
+
} else {
|
66 |
+
return "";
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Check hash crypted by SHA1 with existing data
|
72 |
+
*
|
73 |
+
* @param array $data
|
74 |
+
* @param string $hash
|
75 |
+
* @param string $key
|
76 |
+
*
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
public function shaCryptValidation($data, $hashFromOPS, $key = '')
|
80 |
+
{
|
81 |
+
if (is_array($data)) {
|
82 |
+
$data = implode("", $data);
|
83 |
+
}
|
84 |
+
|
85 |
+
$hashUtf8 = strtoupper(hash($this->getCryptMethod(), $data));
|
86 |
+
$hashNonUtf8 = strtoupper(hash($this->getCryptMethod(), utf8_encode($data)));
|
87 |
+
|
88 |
+
$helper = Mage::helper('ops');
|
89 |
+
$helper->log($helper->__("Module Secureset: %s", $data));
|
90 |
+
|
91 |
+
if ($this->compareHashes($hashFromOPS, $hashUtf8)) {
|
92 |
+
return true;
|
93 |
+
} else {
|
94 |
+
$helper->log($helper->__("Trying again with non-utf8 secureset"));
|
95 |
+
|
96 |
+
return $this->compareHashes($hashFromOPS, $hashNonUtf8);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
private function compareHashes($hashFromOPS, $actual)
|
101 |
+
{
|
102 |
+
$helper = Mage::helper('ops');
|
103 |
+
$helper->log(
|
104 |
+
$helper->__(
|
105 |
+
"Checking hashes\nHashed String by Magento: %s\nHashed String by Acceptance: %s",
|
106 |
+
$actual,
|
107 |
+
$hashFromOPS
|
108 |
+
)
|
109 |
+
);
|
110 |
+
|
111 |
+
if ($hashFromOPS == $actual) {
|
112 |
+
Mage::helper('ops')->log("Successful validation");
|
113 |
+
|
114 |
+
return true;
|
115 |
+
}
|
116 |
+
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Return set of data which is ready for SHA crypt
|
122 |
+
*
|
123 |
+
* @param array $data
|
124 |
+
* @param string $key
|
125 |
+
*
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
public function getSHAInSet($params, $SHAkey)
|
129 |
+
{
|
130 |
+
$params = $this->prepareParamsAndSort($params);
|
131 |
+
$plainHashString = "";
|
132 |
+
foreach ($params as $paramSet):
|
133 |
+
if ($paramSet['value'] == '' || $paramSet['key'] == 'SHASIGN') {
|
134 |
+
continue;
|
135 |
+
}
|
136 |
+
$plainHashString .= strtoupper($paramSet['key']) . "=" . $paramSet['value'] . $SHAkey;
|
137 |
+
endforeach;
|
138 |
+
|
139 |
+
return $plainHashString;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Return prepared and sorted array for SHA Signature Validation
|
144 |
+
*
|
145 |
+
* @param array $params
|
146 |
+
*
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function prepareParamsAndSort($params)
|
150 |
+
{
|
151 |
+
unset($params['CardNo']);
|
152 |
+
unset($params['Brand']);
|
153 |
+
unset($params['SHASign']);
|
154 |
+
|
155 |
+
$params = array_change_key_case($params, CASE_UPPER);
|
156 |
+
|
157 |
+
//PHP ksort takes care about "_", OPS not
|
158 |
+
$sortedParams = array();
|
159 |
+
foreach ($params as $key => $value):
|
160 |
+
$sortedParams[str_replace("_", "", $key)] = array('key' => $key, 'value' => $value);
|
161 |
+
endforeach;
|
162 |
+
ksort($sortedParams);
|
163 |
+
|
164 |
+
return $sortedParams;
|
165 |
+
}
|
166 |
+
|
167 |
+
/*
|
168 |
+
* Get SHA-1-IN hash for ops-authentification
|
169 |
+
*
|
170 |
+
* All Parameters have to be alphabetically, UPPERCASE
|
171 |
+
* Empty Parameters shouldn't appear in the secure string
|
172 |
+
*
|
173 |
+
* @param array $formFields
|
174 |
+
* @param string $shaCode
|
175 |
+
*
|
176 |
+
* @return string
|
177 |
+
*/
|
178 |
+
public function getSHASign($formFields, $shaCode = null, $storeId = null)
|
179 |
+
{
|
180 |
+
if (is_null($shaCode)) {
|
181 |
+
$shaCode = Mage::getModel('ops/config')->getShaOutCode($storeId);
|
182 |
+
}
|
183 |
+
$formFields = array_change_key_case($formFields, CASE_UPPER);
|
184 |
+
uksort($formFields, 'strnatcasecmp');
|
185 |
+
$plainHashString = '';
|
186 |
+
foreach ($formFields as $formKey => $formVal) {
|
187 |
+
if (is_null($formVal) || '' === $formVal || $formKey == 'SHASIGN') {
|
188 |
+
continue;
|
189 |
+
}
|
190 |
+
$plainHashString .= strtoupper($formKey) . '=' . $formVal . $shaCode;
|
191 |
+
}
|
192 |
+
|
193 |
+
return $plainHashString;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* We get some CC info from ops, so we must save it
|
198 |
+
*
|
199 |
+
* @param Mage_Sales_Model_Order $order
|
200 |
+
* @param array $ccInfo
|
201 |
+
*
|
202 |
+
* @return Netresearch_OPS_ApiController
|
203 |
+
*/
|
204 |
+
public function _prepareCCInfo($order, $ccInfo)
|
205 |
+
{
|
206 |
+
if (isset($ccInfo['CN'])) {
|
207 |
+
$order->getPayment()->setCcOwner($ccInfo['CN']);
|
208 |
+
}
|
209 |
+
|
210 |
+
if (isset($ccInfo['CARDNO'])) {
|
211 |
+
$order->getPayment()->setCcNumberEnc($ccInfo['CARDNO']);
|
212 |
+
$order->getPayment()->setCcLast4(substr($ccInfo['CARDNO'], -4));
|
213 |
+
}
|
214 |
+
|
215 |
+
if (isset($ccInfo['ED'])) {
|
216 |
+
$order->getPayment()->setCcExpMonth(substr($ccInfo['ED'], 0, 2));
|
217 |
+
$order->getPayment()->setCcExpYear(substr($ccInfo['ED'], 2, 2));
|
218 |
+
}
|
219 |
+
|
220 |
+
return $this;
|
221 |
+
}
|
222 |
+
|
223 |
+
public function isPaymentAccepted($status)
|
224 |
+
{
|
225 |
+
return in_array(
|
226 |
+
$status, array(
|
227 |
+
Netresearch_OPS_Model_Status::AUTHORIZED,
|
228 |
+
Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
|
229 |
+
Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
|
230 |
+
Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT,
|
231 |
+
Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
|
232 |
+
Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
|
233 |
+
Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN,
|
234 |
+
Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION
|
235 |
+
)
|
236 |
+
);
|
237 |
+
}
|
238 |
+
|
239 |
+
public function isPaymentAuthorizeType($status)
|
240 |
+
{
|
241 |
+
return in_array(
|
242 |
+
$status, array(
|
243 |
+
Netresearch_OPS_Model_Status::AUTHORIZED,
|
244 |
+
Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
|
245 |
+
Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
|
246 |
+
Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
|
247 |
+
)
|
248 |
+
);
|
249 |
+
}
|
250 |
+
|
251 |
+
public function isPaymentCaptureType($status)
|
252 |
+
{
|
253 |
+
return in_array(
|
254 |
+
$status, array(
|
255 |
+
Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
|
256 |
+
Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
|
257 |
+
Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN
|
258 |
+
)
|
259 |
+
);
|
260 |
+
}
|
261 |
+
|
262 |
+
public function isPaymentFailed($status)
|
263 |
+
{
|
264 |
+
return false == $this->isPaymentAccepted($status);
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* apply ops state for order
|
269 |
+
*
|
270 |
+
* @param Mage_Sales_Model_Order $order Order
|
271 |
+
* @param array $params Request params
|
272 |
+
*
|
273 |
+
* @return string
|
274 |
+
*/
|
275 |
+
public function applyStateForOrder($order, $params)
|
276 |
+
{
|
277 |
+
|
278 |
+
Mage::getModel('ops/response_handler')->processResponse($params, $order->getPayment()->getMethodInstance());
|
279 |
+
$order->getPayment()->save();
|
280 |
+
|
281 |
+
$feedbackStatus = '';
|
282 |
+
|
283 |
+
switch ($params['STATUS']) {
|
284 |
+
case Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION : //3D-Secure
|
285 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
|
286 |
+
break;
|
287 |
+
case Netresearch_OPS_Model_Status::AUTHORIZED:
|
288 |
+
case Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT:
|
289 |
+
case Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING:
|
290 |
+
case Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN:
|
291 |
+
case Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT:
|
292 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
|
293 |
+
break;
|
294 |
+
case Netresearch_OPS_Model_Status::PAYMENT_REQUESTED:
|
295 |
+
case Netresearch_OPS_Model_Status::PAYMENT_PROCESSING:
|
296 |
+
case Netresearch_OPS_Model_Status::PAYMENT_PROCESSED_BY_MERCHANT:
|
297 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT;
|
298 |
+
break;
|
299 |
+
case Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED:
|
300 |
+
case Netresearch_OPS_Model_Status::PAYMENT_REFUSED:
|
301 |
+
// $this->declineOrder($order, $params);
|
302 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE;
|
303 |
+
break;
|
304 |
+
case Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER:
|
305 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL;
|
306 |
+
break;
|
307 |
+
default:
|
308 |
+
//all unknown transaction will accept as exceptional
|
309 |
+
// $this->handleException($order, $params);
|
310 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION;
|
311 |
+
}
|
312 |
+
|
313 |
+
return $feedbackStatus;
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Process success action by accept url
|
318 |
+
*
|
319 |
+
* @param Mage_Sales_Model_Order $order Order
|
320 |
+
* @param array $params Request params
|
321 |
+
*/
|
322 |
+
public function acceptOrder($order, $params, $instantCapture = 0)
|
323 |
+
{
|
324 |
+
$this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
|
325 |
+
$this->_prepareCCInfo($order, $params);
|
326 |
+
$this->setPaymentTransactionInformation($order->getPayment(), $params, 'accept');
|
327 |
+
$this->setFraudDetectionParameters($order->getPayment(), $params);
|
328 |
+
|
329 |
+
if ($transaction = Mage::helper('ops/payment')->getTransactionByTransactionId($order->getQuoteId())) {
|
330 |
+
$transaction->setTxnId($params['PAYID'])->save();
|
331 |
+
}
|
332 |
+
|
333 |
+
try {
|
334 |
+
if (false === $this->forceAuthorize($order)
|
335 |
+
&& ($this->getConfig()->getConfigData('payment_action')
|
336 |
+
== Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
|
337 |
+
|| $instantCapture)
|
338 |
+
&& $params['STATUS'] != Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
|
339 |
+
) {
|
340 |
+
$this->_processDirectSale($order, $params, $instantCapture);
|
341 |
+
} else {
|
342 |
+
$this->_processAuthorize($order, $params);
|
343 |
+
}
|
344 |
+
} catch (Exception $e) {
|
345 |
+
$this->_getCheckout()->addError(Mage::helper('ops')->__('Order can not be saved.'));
|
346 |
+
throw $e;
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Set Payment Transaction Information
|
352 |
+
*
|
353 |
+
* @param Mage_Sales_Model_Order_Payment $payment Sales Payment Model
|
354 |
+
* @param array $params Request params
|
355 |
+
* @param string $action Action (accept|cancel|decline|wait|exception)
|
356 |
+
*/
|
357 |
+
protected function setPaymentTransactionInformation(Mage_Sales_Model_Order_Payment $payment, $params, $action)
|
358 |
+
{
|
359 |
+
$payment->setTransactionId($params['PAYID']);
|
360 |
+
$code = $payment->getMethodInstance()->getCode();
|
361 |
+
|
362 |
+
$isInline = false;
|
363 |
+
|
364 |
+
/* In authorize mode we still have no authorization transaction for CC and DirectDebit payments,
|
365 |
+
* so capture or cancel won't work. So we need to create a new authorization transaction for them
|
366 |
+
* when a payment was accepted by Acceptance
|
367 |
+
*
|
368 |
+
* In exception-case we create the authorization-transaction too because some exception-cases can turn into accepted
|
369 |
+
*/
|
370 |
+
if (('accept' === $action || 'exception' === $action)
|
371 |
+
&& in_array($code, array('ops_cc', 'ops_directDebit'))
|
372 |
+
) {
|
373 |
+
$payment->setIsTransactionClosed(false);
|
374 |
+
$isInline = $this->isInlinePayment($payment);
|
375 |
+
/* create authorization transaction for non-inline pms */
|
376 |
+
if (false === $isInline
|
377 |
+
|| (array_key_exists('HTML_ANSWER', $params)
|
378 |
+
|| 0 < strlen(
|
379 |
+
$payment->getAdditionalInformation('HTML_ANSWER')
|
380 |
+
))
|
381 |
+
) {
|
382 |
+
$payment->addTransaction("authorization", null, true, $this->__("Process outgoing transaction"));
|
383 |
+
}
|
384 |
+
$payment->setLastTransId($params['PAYID']);
|
385 |
+
}
|
386 |
+
|
387 |
+
/* Acceptance sends parameter HTML_ANSWER to trigger 3D secure redirection */
|
388 |
+
if (isset($params['HTML_ANSWER']) && ('ops_cc' == $code)) {
|
389 |
+
$payment->setAdditionalInformation('HTML_ANSWER', $params['HTML_ANSWER']);
|
390 |
+
$payment->setIsTransactionPending(true);
|
391 |
+
}
|
392 |
+
|
393 |
+
$payment->setAdditionalInformation('paymentId', $params['PAYID']);
|
394 |
+
$payment->setAdditionalInformation('status', $params['STATUS']);
|
395 |
+
if (array_key_exists('ACCEPTANCE', $params) && 0 < strlen(trim($params['ACCEPTANCE']))) {
|
396 |
+
$payment->setAdditionalInformation('acceptance', $params['ACCEPTANCE']);
|
397 |
+
}
|
398 |
+
if (array_key_exists('BRAND', $params) && ('ops_cc' == $code) && 0 < strlen(trim($params['BRAND']))) {
|
399 |
+
$payment->setAdditionalInformation('CC_BRAND', $params['BRAND']);
|
400 |
+
}
|
401 |
+
if (false === $isInline || array_key_exists('HTML_ANSWER', $params)) {
|
402 |
+
$payment->setIsTransactionClosed(true);
|
403 |
+
}
|
404 |
+
$payment->setDataChanges(true);
|
405 |
+
$payment->save();
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* add fraud detection of Acceptance to additional payment data
|
410 |
+
*
|
411 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
412 |
+
* @param array $params
|
413 |
+
*/
|
414 |
+
protected function setFraudDetectionParameters($payment, $params)
|
415 |
+
{
|
416 |
+
$params = array_change_key_case($params, CASE_UPPER);
|
417 |
+
if (array_key_exists('SCORING', $params)) {
|
418 |
+
$payment->setAdditionalInformation('scoring', $params['SCORING']);
|
419 |
+
}
|
420 |
+
if (array_key_exists('SCO_CATEGORY', $params)) {
|
421 |
+
$payment->setAdditionalInformation('scoringCategory', $params['SCO_CATEGORY']);
|
422 |
+
}
|
423 |
+
$additionalScoringData = array();
|
424 |
+
foreach ($this->getConfig()->getAdditionalScoringKeys() as $key) {
|
425 |
+
if (array_key_exists($key, $params)) {
|
426 |
+
if (false === mb_detect_encoding($params[$key], 'UTF-8', true)) {
|
427 |
+
$additionalScoringData[$key] = utf8_encode($params[$key]);
|
428 |
+
} else {
|
429 |
+
$additionalScoringData[$key] = $params[$key];
|
430 |
+
}
|
431 |
+
}
|
432 |
+
}
|
433 |
+
$payment->setAdditionalInformation('additionalScoringData', $additionalScoringData);
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Process cancel action by cancel url
|
438 |
+
*
|
439 |
+
* @param Mage_Sales_Model_Order $order Order
|
440 |
+
* @param string[] $params Request params
|
441 |
+
* @param string $status Order status
|
442 |
+
* @param string $comment Order comment
|
443 |
+
* @throws Exception
|
444 |
+
* @deprecated
|
445 |
+
*/
|
446 |
+
public function cancelOrder($order, $params, $status, $comment)
|
447 |
+
{
|
448 |
+
//@TODO: remove obsolete function
|
449 |
+
|
450 |
+
try {
|
451 |
+
Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
|
452 |
+
$this->cancelInvoices($order);
|
453 |
+
$order->cancel();
|
454 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, $status, $comment);
|
455 |
+
$order->save();
|
456 |
+
|
457 |
+
try {
|
458 |
+
$this->setPaymentTransactionInformation($order->getPayment(), $params, 'cancel');
|
459 |
+
} catch (Exception $e) {
|
460 |
+
// just ignore that
|
461 |
+
Mage::helper('ops')->log(
|
462 |
+
'Catched exception while saving payment transaction information of a canceled order: '
|
463 |
+
. $e->getMessage()
|
464 |
+
);
|
465 |
+
}
|
466 |
+
} catch (Exception $e) {
|
467 |
+
$this->_getCheckout()->addError(Mage::helper('ops')->__('Order can not be canceled for system reason.'));
|
468 |
+
throw $e;
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Process decline action by ops decline url
|
474 |
+
*
|
475 |
+
* @param Mage_Sales_Model_Order $order Order
|
476 |
+
* @param array $params Request params
|
477 |
+
*/
|
478 |
+
public function declineOrder($order, $params)
|
479 |
+
{
|
480 |
+
//@TODO: remove obsolete function
|
481 |
+
|
482 |
+
try {
|
483 |
+
Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel
|
484 |
+
$this->cancelInvoices($order);
|
485 |
+
$order->cancel();
|
486 |
+
$order->setState(
|
487 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
488 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
489 |
+
Mage::helper('ops')->__(
|
490 |
+
'Order declined on ops side. Acceptance status: %s, Payment ID: %s.',
|
491 |
+
Mage::helper('ops')->getStatusText($params['STATUS']),
|
492 |
+
$params['PAYID']
|
493 |
+
)
|
494 |
+
);
|
495 |
+
$order->save();
|
496 |
+
|
497 |
+
$this->setPaymentTransactionInformation($order->getPayment(), $params, 'decline');
|
498 |
+
} catch (Exception $e) {
|
499 |
+
$this->_getCheckout()->addError(Mage::helper('ops')->__('Order can not be canceled for system reason.'));
|
500 |
+
throw $e;
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Wait for 3D secure confirmation
|
506 |
+
*
|
507 |
+
* @param Mage_Sales_Model_Order $order Order
|
508 |
+
* @param array $params Request params
|
509 |
+
*/
|
510 |
+
public function waitOrder($order, $params)
|
511 |
+
{
|
512 |
+
|
513 |
+
//@TODO: remove obsolete function
|
514 |
+
try {
|
515 |
+
$order->setState(
|
516 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
|
517 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
|
518 |
+
Mage::helper('ops')->__(
|
519 |
+
'Order is waiting for Acceptance confirmation of 3D-Secure. Acceptance status: %s, Payment ID: %s.',
|
520 |
+
Mage::helper('ops')->getStatusText($params['STATUS']),
|
521 |
+
$params['PAYID']
|
522 |
+
)
|
523 |
+
);
|
524 |
+
$order->save();
|
525 |
+
$this->setPaymentTransactionInformation($order->getPayment(), $params, 'wait');
|
526 |
+
} catch (Exception $e) {
|
527 |
+
$this->_getCheckout()->addError(
|
528 |
+
Mage::helper('ops')->__('Error during 3D-Secure processing of Acceptance. Error: %s', $e->getMessage())
|
529 |
+
);
|
530 |
+
throw $e;
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Process exception action by ops exception url
|
536 |
+
*
|
537 |
+
* @param Mage_Sales_Model_Order $order Order
|
538 |
+
* @param array $params Request params
|
539 |
+
*/
|
540 |
+
public function handleException($order, $params)
|
541 |
+
{
|
542 |
+
//@TODO: remove obsolete function
|
543 |
+
$exceptionMessage = $this->getPaymentExceptionMessage($params['STATUS']);
|
544 |
+
|
545 |
+
if (!empty($exceptionMessage)) {
|
546 |
+
try {
|
547 |
+
$this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
|
548 |
+
$this->_prepareCCInfo($order, $params);
|
549 |
+
$order->getPayment()->setLastTransId($params['PAYID']);
|
550 |
+
//to send new order email only when state is pending payment
|
551 |
+
if (!$order->getEmailSent() != 1
|
552 |
+
&& $order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
553 |
+
) {
|
554 |
+
$order->sendNewOrderEmail();
|
555 |
+
|
556 |
+
}
|
557 |
+
$order->addStatusHistoryComment($exceptionMessage);
|
558 |
+
$order->save();
|
559 |
+
$this->setPaymentTransactionInformation($order->getPayment(), $params, 'exception');
|
560 |
+
} catch (Exception $e) {
|
561 |
+
$this->_getCheckout()->addError(Mage::helper('ops')->__('Order can not be saved for system reason.'));
|
562 |
+
}
|
563 |
+
} else {
|
564 |
+
$this->_getCheckout()->addError(Mage::helper('ops')->__('An unknown exception occured.'));
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Get Payment Exception Message
|
570 |
+
*
|
571 |
+
* @param int $ops_status Request OPS Status
|
572 |
+
*/
|
573 |
+
protected function getPaymentExceptionMessage($ops_status)
|
574 |
+
{
|
575 |
+
$exceptionMessage = '';
|
576 |
+
switch ($ops_status) {
|
577 |
+
case Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN :
|
578 |
+
$exceptionMessage = Mage::helper('ops')->__(
|
579 |
+
'A technical problem arose during payment process, giving unpredictable result. Acceptance status: %s.',
|
580 |
+
Mage::helper('ops')->getStatusText($ops_status)
|
581 |
+
);
|
582 |
+
break;
|
583 |
+
default:
|
584 |
+
$exceptionMessage = Mage::helper('ops')->__(
|
585 |
+
'An unknown exception was thrown in the payment process. Acceptance status: %s.',
|
586 |
+
Mage::helper('ops')->getStatusText($ops_status)
|
587 |
+
);
|
588 |
+
}
|
589 |
+
|
590 |
+
return $exceptionMessage;
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Process Configured Payment Action: Direct Sale, create invoice if state is Pending
|
595 |
+
*
|
596 |
+
* @param Mage_Sales_Model_Order $order Order
|
597 |
+
* @param array $params Request params
|
598 |
+
*/
|
599 |
+
protected function _processDirectSale($order, $params, $instantCapture = 0)
|
600 |
+
{
|
601 |
+
//@TODO: remove obsolete function
|
602 |
+
|
603 |
+
Mage::register('ops_auto_capture', true);
|
604 |
+
$status = $params['STATUS'];
|
605 |
+
if ($status == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
|
606 |
+
$order->setState(
|
607 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
608 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
609 |
+
Mage::helper('ops')->__('Waiting for the payment of the customer')
|
610 |
+
);
|
611 |
+
|
612 |
+
// send new order mail for bank transfer, since it is 'successfully' authorized at this point
|
613 |
+
if ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_BankTransfer
|
614 |
+
&& $order->getEmailSent() != 1
|
615 |
+
) {
|
616 |
+
$order->sendNewOrderEmail();
|
617 |
+
}
|
618 |
+
|
619 |
+
$order->save();
|
620 |
+
} elseif ($status == Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING) {
|
621 |
+
$order->setState(
|
622 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
623 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
624 |
+
Mage::helper('ops')->__('Authorization waiting from Acceptance')
|
625 |
+
);
|
626 |
+
$order->save();
|
627 |
+
} elseif (($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
628 |
+
|| $instantCapture)
|
629 |
+
&& !$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)
|
630 |
+
) {
|
631 |
+
if ($status == Netresearch_OPS_Model_Status::AUTHORIZED) {
|
632 |
+
if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
633 |
+
$order->setState(
|
634 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
635 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
636 |
+
Mage::helper('ops')->__('Processed by Acceptance')
|
637 |
+
);
|
638 |
+
|
639 |
+
}
|
640 |
+
} else {
|
641 |
+
$order->setState(
|
642 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
643 |
+
true,
|
644 |
+
Mage::helper('ops')->__('Processed by Acceptance')
|
645 |
+
);
|
646 |
+
$order->save();
|
647 |
+
}
|
648 |
+
if (!$order->getInvoiceCollection()->getSize()
|
649 |
+
&& $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING
|
650 |
+
&& $order->canInvoice()
|
651 |
+
) {
|
652 |
+
$invoice = $order->prepareInvoice();
|
653 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
654 |
+
$invoice->register();
|
655 |
+
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
|
656 |
+
$invoice->getOrder()->setIsInProcess(true);
|
657 |
+
$invoice->save();
|
658 |
+
$this->sendInvoiceToCustomer($invoice);
|
659 |
+
|
660 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
661 |
+
->addObject($invoice)
|
662 |
+
->addObject($invoice->getOrder())
|
663 |
+
->save();
|
664 |
+
|
665 |
+
/*
|
666 |
+
* If the payment method is a redirect-payment-method send the email
|
667 |
+
* In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
|
668 |
+
*/
|
669 |
+
if ($this->isRedirectPaymentMethod($order) === true
|
670 |
+
&& $order->getEmailSent() != 1
|
671 |
+
) {
|
672 |
+
$order->sendNewOrderEmail();
|
673 |
+
}
|
674 |
+
$eventData = array('data_object' => $order, 'order' => $order);
|
675 |
+
Mage::dispatchEvent('ops_sales_order_save_commit_after', $eventData);
|
676 |
+
}
|
677 |
+
|
678 |
+
if ($this->isInlinePayment($order->getPayment())
|
679 |
+
&& 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
|
680 |
+
&& $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
|
681 |
+
) {
|
682 |
+
$order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(
|
683 |
+
Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true
|
684 |
+
)->save();
|
685 |
+
$this->setInvoicesToPaid($order);
|
686 |
+
$order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save();
|
687 |
+
$order->getPayment()->addTransaction(
|
688 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment()
|
689 |
+
)->setIsClosed(true)->save();
|
690 |
+
|
691 |
+
if ($order->getEmailSent() != 1) {
|
692 |
+
$order->sendNewOrderEmail();
|
693 |
+
}
|
694 |
+
|
695 |
+
$order->save();
|
696 |
+
}
|
697 |
+
if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice()
|
698 |
+
&& Mage::getModel('ops/config')->getPaymentAction($order->getStoreId())
|
699 |
+
=== Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE
|
700 |
+
) {
|
701 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
702 |
+
$this->sendInvoiceToCustomer($invoice);
|
703 |
+
}
|
704 |
+
}
|
705 |
+
} else {
|
706 |
+
$order->save();
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* send invoice to customer if that was configured by the merchant
|
712 |
+
*
|
713 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice Invoice to be sent
|
714 |
+
*
|
715 |
+
* @return void
|
716 |
+
*/
|
717 |
+
public function sendInvoiceToCustomer(Mage_Sales_Model_Order_Invoice $invoice)
|
718 |
+
{
|
719 |
+
if (false == $invoice->getEmailSent()
|
720 |
+
&& $this->getConfig()->getSendInvoice()
|
721 |
+
) {
|
722 |
+
$invoice->sendEmail($notifyCustomer = true);
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
/**
|
727 |
+
* Process Configured Payment Actions: Authorized, Default operation
|
728 |
+
* just place order
|
729 |
+
*
|
730 |
+
* @param Mage_Sales_Model_Order $order Order
|
731 |
+
* @param array $params Request params
|
732 |
+
*/
|
733 |
+
protected function _processAuthorize($order, $params)
|
734 |
+
{
|
735 |
+
$status = $params['STATUS'];
|
736 |
+
if ($status == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
|
737 |
+
$order->setState(
|
738 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
739 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
740 |
+
Mage::helper('ops')->__(
|
741 |
+
'Waiting for payment. Acceptance status: %s.', Mage::helper('ops')->getStatusText($status)
|
742 |
+
)
|
743 |
+
);
|
744 |
+
|
745 |
+
// send new order mail for bank transfer, since it is 'successfully' authorized at this point
|
746 |
+
if ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_BankTransfer
|
747 |
+
&& $order->getEmailSent() != 1
|
748 |
+
) {
|
749 |
+
$order->sendNewOrderEmail();
|
750 |
+
}
|
751 |
+
} elseif ($status == Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING) {
|
752 |
+
$order->setState(
|
753 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
754 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
755 |
+
Mage::helper('ops')->__(
|
756 |
+
'Authorization uncertain. Acceptance status: %s.', Mage::helper('ops')->getStatusText($status)
|
757 |
+
)
|
758 |
+
);
|
759 |
+
} else {
|
760 |
+
// for 3DS payments the order has to be retrieved from the payment review step
|
761 |
+
if ($this->isInlinePayment($order->getPayment())
|
762 |
+
&& 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER')))
|
763 |
+
&& $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::AUTHORIZED
|
764 |
+
) {
|
765 |
+
|
766 |
+
$order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(
|
767 |
+
Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true
|
768 |
+
)->save();
|
769 |
+
}
|
770 |
+
if ($this->isRedirectPaymentMethod($order) === true
|
771 |
+
&& $order->getEmailSent() != 1
|
772 |
+
) {
|
773 |
+
$order->sendNewOrderEmail();
|
774 |
+
}
|
775 |
+
|
776 |
+
if (!$this->isPaypalSpecialStatus($order->getPayment()->getMethodInstance(), $status)) {
|
777 |
+
|
778 |
+
$payId = $params['PAYID'];
|
779 |
+
$order->setState(
|
780 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
781 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
782 |
+
Mage::helper('ops')->__(
|
783 |
+
'Processed by Acceptance. Payment ID: %s. Acceptance status: %s.', $payId,
|
784 |
+
Mage::helper('ops')->getStatusText($status)
|
785 |
+
)
|
786 |
+
);
|
787 |
+
}
|
788 |
+
}
|
789 |
+
$order->save();
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Special status handling for Paypal and status 91
|
794 |
+
*
|
795 |
+
* @param $pm
|
796 |
+
* @param $status
|
797 |
+
*
|
798 |
+
* @return bool
|
799 |
+
*/
|
800 |
+
protected function isPaypalSpecialStatus($pm, $status)
|
801 |
+
{
|
802 |
+
return $pm instanceof Netresearch_OPS_Model_Payment_Paypal
|
803 |
+
&& $status == Netresearch_OPS_Model_Status::PAYMENT_PROCESSING;
|
804 |
+
}
|
805 |
+
|
806 |
+
/**
|
807 |
+
* Fetches transaction with given transaction id
|
808 |
+
*
|
809 |
+
* @param string $txnId
|
810 |
+
*
|
811 |
+
* @return mixed Mage_Sales_Model_Order_Payment_Transaction | boolean
|
812 |
+
*/
|
813 |
+
public function getTransactionByTransactionId($transactionId)
|
814 |
+
{
|
815 |
+
if (!$transactionId) {
|
816 |
+
return;
|
817 |
+
}
|
818 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')
|
819 |
+
->getCollection()
|
820 |
+
->addAttributeToFilter('txn_id', $transactionId)
|
821 |
+
->getLastItem();
|
822 |
+
if (is_null($transaction->getId())) {
|
823 |
+
return false;
|
824 |
+
}
|
825 |
+
$transaction->getOrderPaymentObject();
|
826 |
+
|
827 |
+
return $transaction;
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* refill cart
|
832 |
+
*
|
833 |
+
* @param Mage_Sales_Model_Order $order
|
834 |
+
*
|
835 |
+
* @return void
|
836 |
+
*/
|
837 |
+
public function refillCart($order)
|
838 |
+
{
|
839 |
+
// add items
|
840 |
+
$cart = Mage::getSingleton('checkout/cart');
|
841 |
+
|
842 |
+
if (0 < $cart->getQuote()->getItemsCollection()->count()) {
|
843 |
+
//cart is not empty, so refilling it is not required
|
844 |
+
return;
|
845 |
+
}
|
846 |
+
foreach ($order->getItemsCollection() as $item) {
|
847 |
+
try {
|
848 |
+
$cart->addOrderItem($item);
|
849 |
+
} catch (Exception $e) {
|
850 |
+
Mage::logException($e);
|
851 |
+
}
|
852 |
+
}
|
853 |
+
$cart->save();
|
854 |
+
|
855 |
+
// add coupon code
|
856 |
+
$coupon = $order->getCouponCode();
|
857 |
+
$session = Mage::getSingleton('checkout/session');
|
858 |
+
if (false == is_null($coupon)) {
|
859 |
+
$session->getQuote()->setCouponCode($coupon)->save();
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Save OPS Status to Payment
|
865 |
+
*
|
866 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
867 |
+
* @param array $params OPS-Response
|
868 |
+
*
|
869 |
+
* @return void
|
870 |
+
*/
|
871 |
+
public function saveOpsStatusToPayment(Mage_Sales_Model_Order_Payment $payment, $params)
|
872 |
+
{
|
873 |
+
$payment
|
874 |
+
->setAdditionalInformation('status', $params['STATUS'])
|
875 |
+
->save();
|
876 |
+
}
|
877 |
+
|
878 |
+
/**
|
879 |
+
* Check is payment method is a redirect method
|
880 |
+
*
|
881 |
+
* @param Mage_Sales_Model_Order $order
|
882 |
+
*/
|
883 |
+
protected function isRedirectPaymentMethod($order)
|
884 |
+
{
|
885 |
+
$method = $order->getPayment()->getMethodInstance();
|
886 |
+
if ($method
|
887 |
+
&& $method->getOrderPlaceRedirectUrl() != '' //Magento returns ''
|
888 |
+
&& $method->getOrderPlaceRedirectUrl() !== false
|
889 |
+
) { //Ops return false
|
890 |
+
return true;
|
891 |
+
} else {
|
892 |
+
return false;
|
893 |
+
}
|
894 |
+
}
|
895 |
+
|
896 |
+
public function getQuote()
|
897 |
+
{
|
898 |
+
return $this->_getCheckout()->getQuote();
|
899 |
+
}
|
900 |
+
|
901 |
+
/**
|
902 |
+
* sets the state to pending payment if neccessary (order is in state new)
|
903 |
+
* and adds a comment to status history
|
904 |
+
*
|
905 |
+
* @param $order - the order
|
906 |
+
*/
|
907 |
+
public function handleUnknownStatus($order)
|
908 |
+
{
|
909 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
910 |
+
$message = Mage::helper('ops')->__(
|
911 |
+
'Unknown Acceptance state for this order. Please check Acceptance backend for this order.'
|
912 |
+
);
|
913 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
|
914 |
+
$order->setState(
|
915 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
916 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
917 |
+
$message
|
918 |
+
);
|
919 |
+
} else {
|
920 |
+
$order->addStatusHistoryComment($message);
|
921 |
+
}
|
922 |
+
$order->save();
|
923 |
+
}
|
924 |
+
}
|
925 |
+
|
926 |
+
/**
|
927 |
+
* returns the base grand total from either a quote or an order
|
928 |
+
*
|
929 |
+
* @param $salesObject
|
930 |
+
*
|
931 |
+
* @return double the base amount of the order
|
932 |
+
* @throws Exception if $salesObject is not a quote or an order
|
933 |
+
*/
|
934 |
+
public function getBaseGrandTotalFromSalesObject($salesObject)
|
935 |
+
{
|
936 |
+
if ($salesObject instanceof Mage_Sales_Model_Order or $salesObject instanceof Mage_Sales_Model_Quote) {
|
937 |
+
return $salesObject->getBaseGrandTotal();
|
938 |
+
} else {
|
939 |
+
Mage::throwException('$salesObject is not a quote or an order instance');
|
940 |
+
}
|
941 |
+
}
|
942 |
+
|
943 |
+
|
944 |
+
/**
|
945 |
+
* Save the last used refund operation code to payment
|
946 |
+
*
|
947 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
948 |
+
* @param string $operationCode
|
949 |
+
*
|
950 |
+
* @return void
|
951 |
+
*/
|
952 |
+
public function saveOpsRefundOperationCodeToPayment(Mage_Sales_Model_Order_Payment $payment, $operationCode)
|
953 |
+
{
|
954 |
+
if (in_array(
|
955 |
+
strtoupper(trim($operationCode)),
|
956 |
+
array(
|
957 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
|
958 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
|
959 |
+
)
|
960 |
+
)
|
961 |
+
) {
|
962 |
+
Mage::helper('ops/data')->log(
|
963 |
+
sprintf(
|
964 |
+
"set last refund operation '%s' code to payment for order '%s'",
|
965 |
+
$operationCode,
|
966 |
+
$payment->getOrder()->getIncrementId()
|
967 |
+
)
|
968 |
+
);
|
969 |
+
$payment
|
970 |
+
->setAdditionalInformation('lastRefundOperationCode', $operationCode)
|
971 |
+
->save();
|
972 |
+
}
|
973 |
+
}
|
974 |
+
|
975 |
+
/**
|
976 |
+
* sets the canRefund information depending on the last refund operation code
|
977 |
+
*
|
978 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
979 |
+
*/
|
980 |
+
public function setCanRefundToPayment(Mage_Sales_Model_Order_Payment $payment)
|
981 |
+
{
|
982 |
+
$refundOperationCode = $payment->getAdditionalInformation('lastRefundOperationCode');
|
983 |
+
if (in_array(
|
984 |
+
strtoupper(trim($refundOperationCode)),
|
985 |
+
array(
|
986 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
|
987 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
|
988 |
+
)
|
989 |
+
)
|
990 |
+
) {
|
991 |
+
/*
|
992 |
+
* a further refund is possible if the transaction remains open, that means either the merchant
|
993 |
+
* did not close the transaction or the refunded amount is less than the orders amount
|
994 |
+
*/
|
995 |
+
$canRefund = ($refundOperationCode == Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL);
|
996 |
+
Mage::helper('ops/data')->log(
|
997 |
+
sprintf(
|
998 |
+
"set canRefund to '%s' for payment of order '%s'",
|
999 |
+
var_export($canRefund, true),
|
1000 |
+
$payment->getOrder()->getIncrementId()
|
1001 |
+
)
|
1002 |
+
);
|
1003 |
+
$payment
|
1004 |
+
->setAdditionalInformation('canRefund', $canRefund)
|
1005 |
+
->save();
|
1006 |
+
}
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
/**
|
1010 |
+
* determine whether the payment supports only authorize or not
|
1011 |
+
*
|
1012 |
+
* @param Mage_Sales_Model_Order $order
|
1013 |
+
*
|
1014 |
+
* @return true . if so, false otherwise
|
1015 |
+
*/
|
1016 |
+
protected function forceAuthorize(Mage_Sales_Model_Order $order)
|
1017 |
+
{
|
1018 |
+
return ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Kwixo_Abstract);
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
|
1022 |
+
/**
|
1023 |
+
* add ops_cc payment to checkout methods if quote total is zero and zero amount checkout is activated
|
1024 |
+
*
|
1025 |
+
* @param Mage_Payment_Block_Form_Container $block
|
1026 |
+
*
|
1027 |
+
* @return $this
|
1028 |
+
*/
|
1029 |
+
public function addCCForZeroAmountCheckout(Mage_Payment_Block_Form_Container $block)
|
1030 |
+
{
|
1031 |
+
$methods = $block->getMethods();
|
1032 |
+
if (false === $this->checkIfCCisInCheckoutMethods($methods)) {
|
1033 |
+
$ccPayment = Mage::getModel('ops/payment_cc');
|
1034 |
+
if ($ccPayment->getFeatureModel()->isCCAndZeroAmountAuthAllowed($ccPayment, $block->getQuote())) {
|
1035 |
+
$ccPayment->setInfoInstance($block->getQuote()->getPayment());
|
1036 |
+
$methods[] = $ccPayment;
|
1037 |
+
$block->setData('methods', $methods);
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
return $this;
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
|
1045 |
+
/**
|
1046 |
+
* check if ops_cc is in payment methods array
|
1047 |
+
*
|
1048 |
+
* @param $methods
|
1049 |
+
*
|
1050 |
+
* @return array
|
1051 |
+
*/
|
1052 |
+
protected function checkIfCCisInCheckoutMethods($methods)
|
1053 |
+
{
|
1054 |
+
$result = false;
|
1055 |
+
foreach ($methods as $method) {
|
1056 |
+
if ($method->getCode() == 'ops_cc') {
|
1057 |
+
$result = true;
|
1058 |
+
break;
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
return $result;
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
/**
|
1066 |
+
* checks if the payment method can use order's increment id as merchant's reference
|
1067 |
+
*
|
1068 |
+
* @param Mage_Payment_Model_Info $payment
|
1069 |
+
*
|
1070 |
+
* @return bool
|
1071 |
+
*/
|
1072 |
+
public function isInlinePaymentWithOrderId(Mage_Payment_Model_Info $payment)
|
1073 |
+
{
|
1074 |
+
return $this->isInlinePayment($payment) && $this->getConfig()->getInlineOrderReference() == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID;
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
/**
|
1078 |
+
* checks if the payment method can pbe processed via direct link
|
1079 |
+
*
|
1080 |
+
* @param Mage_Payment_Model_Info $payment
|
1081 |
+
*
|
1082 |
+
* @return bool
|
1083 |
+
*/
|
1084 |
+
public function isInlinePayment(Mage_Payment_Model_Info $payment)
|
1085 |
+
{
|
1086 |
+
$result = false;
|
1087 |
+
$methodInstance = $payment->getMethodInstance();
|
1088 |
+
if ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit
|
1089 |
+
|| ($methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
|
1090 |
+
&& ($methodInstance->hasBrandAliasInterfaceSupport($payment)
|
1091 |
+
|| Mage::helper('ops/data')->isAdminSession()))
|
1092 |
+
) {
|
1093 |
+
$result = true;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
return $result;
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
/**
|
1100 |
+
* checks if the inline payment can use quote id as merchant's reference
|
1101 |
+
*
|
1102 |
+
* @param Mage_Payment_Model_Info $payment
|
1103 |
+
*
|
1104 |
+
* @return bool
|
1105 |
+
*/
|
1106 |
+
public function isInlinePaymentWithQuoteId(Mage_Payment_Model_Info $payment)
|
1107 |
+
{
|
1108 |
+
return $this->isInlinePayment($payment)
|
1109 |
+
&& (0 === strlen(
|
1110 |
+
trim($payment->getMethodInstance()->getConfigPaymentAction())
|
1111 |
+
));
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
/**
|
1115 |
+
* sets the invoices of an order to paid
|
1116 |
+
*
|
1117 |
+
* @param Mage_Sales_Model_Order $order
|
1118 |
+
*
|
1119 |
+
* @return Netresearch_OPS_Helper_Payment
|
1120 |
+
*/
|
1121 |
+
public function setInvoicesToPaid($order)
|
1122 |
+
{
|
1123 |
+
/** @var $invoice Mage_Sales_Model_Order_Invoice */
|
1124 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
1125 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
1126 |
+
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
|
1127 |
+
$invoice->save();
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
return $this;
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
/**
|
1134 |
+
* cancel all invoices for a given order
|
1135 |
+
*
|
1136 |
+
* @param $order
|
1137 |
+
*
|
1138 |
+
* @return Netresearch_OPS_Helper_Payment
|
1139 |
+
* @throws Exception
|
1140 |
+
*/
|
1141 |
+
public function cancelInvoices($order)
|
1142 |
+
{
|
1143 |
+
/** @var $invoice Mage_Sales_Model_Order_Invoice */
|
1144 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
1145 |
+
$invoice->cancel();
|
1146 |
+
$invoice->save();
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
return $this;
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
/**
|
1153 |
+
* Returns if the current payment status is an invalid one, namely if it is one of the following:
|
1154 |
+
* Netresearch_OPS_Model_Payment_Abstract::INVALID_INCOMPLETE,
|
1155 |
+
* Netresearch_OPS_Model_Payment_Abstract::CANCELED_BY_CUSTOMER,
|
1156 |
+
* Netresearch_OPS_Model_Payment_Abstract::AUTHORISATION_DECLINED,
|
1157 |
+
*
|
1158 |
+
* @param $status
|
1159 |
+
*
|
1160 |
+
* @return bool
|
1161 |
+
*/
|
1162 |
+
public function isPaymentInvalid($status)
|
1163 |
+
{
|
1164 |
+
return in_array(
|
1165 |
+
$status,
|
1166 |
+
array(
|
1167 |
+
Netresearch_OPS_Model_Status::INVALID_INCOMPLETE,
|
1168 |
+
Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
|
1169 |
+
Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
|
1170 |
+
)
|
1171 |
+
);
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/Request.php
ADDED
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
abstract class Netresearch_OPS_Helper_Payment_DirectLink_Request
|
13 |
+
implements Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface
|
14 |
+
{
|
15 |
+
|
16 |
+
protected $dataHelper = null;
|
17 |
+
|
18 |
+
protected $quoteHelper = null;
|
19 |
+
|
20 |
+
protected $orderHelper = null;
|
21 |
+
|
22 |
+
protected $customerHelper = null;
|
23 |
+
|
24 |
+
protected $validator = null;
|
25 |
+
|
26 |
+
protected $requestHelper = null;
|
27 |
+
|
28 |
+
protected $config = null;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param null $config
|
32 |
+
*/
|
33 |
+
public function setConfig($config)
|
34 |
+
{
|
35 |
+
$this->config = $config;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return Netresearch_OPS_Model_Config
|
40 |
+
*/
|
41 |
+
public function getConfig()
|
42 |
+
{
|
43 |
+
if (null === $this->config) {
|
44 |
+
$this->config = Mage::getModel('ops/config');
|
45 |
+
}
|
46 |
+
return $this->config;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function setRequestHelper(Netresearch_OPS_Helper_Payment_Request $requestHelper)
|
50 |
+
{
|
51 |
+
$this->requestHelper = $requestHelper;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return Netresearch_OPS_Helper_Payment_Request
|
56 |
+
*/
|
57 |
+
public function getRequestHelper()
|
58 |
+
{
|
59 |
+
if (null === $this->requestHelper) {
|
60 |
+
$this->requestHelper = Mage::helper('ops/payment_request');
|
61 |
+
$this->requestHelper->setConfig($this->getConfig());
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this->requestHelper;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* sets the data helper
|
69 |
+
*
|
70 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
71 |
+
*/
|
72 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper)
|
73 |
+
{
|
74 |
+
$this->dataHelper = $dataHelper;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* gets the data helper
|
79 |
+
*
|
80 |
+
* @return Mage_Core_Helper_Abstract
|
81 |
+
*/
|
82 |
+
public function getDataHelper()
|
83 |
+
{
|
84 |
+
if (null === $this->dataHelper) {
|
85 |
+
$this->dataHelper = Mage::helper('ops/data');
|
86 |
+
}
|
87 |
+
|
88 |
+
return $this->dataHelper;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* sets the quote helper
|
93 |
+
*
|
94 |
+
* @param Netresearch_OPS_Helper_Quote $quoteHelper
|
95 |
+
*/
|
96 |
+
public function setQuoteHelper(Netresearch_OPS_Helper_Quote $quoteHelper)
|
97 |
+
{
|
98 |
+
$this->quoteHelper = $quoteHelper;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* gets the quote helper
|
103 |
+
*
|
104 |
+
* @return Mage_Core_Helper_Abstract
|
105 |
+
*/
|
106 |
+
public function getQuoteHelper()
|
107 |
+
{
|
108 |
+
if (null === $this->quoteHelper) {
|
109 |
+
$this->quoteHelper = Mage::helper('ops/quote');
|
110 |
+
}
|
111 |
+
|
112 |
+
return $this->quoteHelper;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* sets the order helper
|
117 |
+
*
|
118 |
+
* @param Netresearch_OPS_Helper_Order $orderHelper
|
119 |
+
*/
|
120 |
+
public function setOrderHelper(Netresearch_OPS_Helper_Order $orderHelper)
|
121 |
+
{
|
122 |
+
$this->orderHelper = $orderHelper;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* gets the order helper
|
127 |
+
*
|
128 |
+
* @return Netresearch_OPS_Helper_Order
|
129 |
+
*/
|
130 |
+
public function getOrderHelper()
|
131 |
+
{
|
132 |
+
if (null === $this->orderHelper) {
|
133 |
+
$this->orderHelper = Mage::helper('ops/order');
|
134 |
+
}
|
135 |
+
|
136 |
+
return $this->orderHelper;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* sets the customer helper
|
141 |
+
*
|
142 |
+
* @param Mage_Customer_Helper_Data $customerHelper
|
143 |
+
*/
|
144 |
+
public function setCustomerHelper(Mage_Core_Helper_Abstract $customerHelper)
|
145 |
+
{
|
146 |
+
$this->customerHelper = $customerHelper;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* gets the customer helper
|
151 |
+
*
|
152 |
+
* @return Mage_Customer_Helper_Data
|
153 |
+
*/
|
154 |
+
public function getCustomerHelper()
|
155 |
+
{
|
156 |
+
if (null === $this->customerHelper) {
|
157 |
+
$this->customerHelper = Mage::helper('customer/data');
|
158 |
+
}
|
159 |
+
|
160 |
+
return $this->customerHelper;
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
/**
|
165 |
+
* extracts the parameter for the direct link request from the quote, order and, optionally from existing request params
|
166 |
+
*
|
167 |
+
* @param Mage_Sales_Model_Quote $quote
|
168 |
+
* @param Mage_Sales_Model_Order $order
|
169 |
+
* @param array $requestParams
|
170 |
+
*
|
171 |
+
* @return array - the parameters for the direct link request
|
172 |
+
*/
|
173 |
+
public function getDirectLinkRequestParams(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order, $requestParams = array())
|
174 |
+
{
|
175 |
+
$billingAddress = $order->getBillingAddress();
|
176 |
+
$shippingAddress = $this->getShippingAddress($order, $billingAddress);
|
177 |
+
$requestParams = $this->getBaseRequestParams($quote, $order, $billingAddress);
|
178 |
+
$requestParams = array_merge($requestParams, $this->getPaymentSpecificParams($quote));
|
179 |
+
|
180 |
+
if ($this->getConfig()->canSubmitExtraParameter($quote->getStoreId())) {
|
181 |
+
$shipToParams = $this->getRequestHelper()->extractShipToParameters($shippingAddress, $quote);
|
182 |
+
$shipToParams = $this->decodeParamsForDirectLinkCall($shipToParams);
|
183 |
+
$requestParams = array_merge($requestParams, $shipToParams);
|
184 |
+
}
|
185 |
+
|
186 |
+
$requestParams = $this->addCustomerSpecificParams($requestParams);
|
187 |
+
$requestParams = $this->addParamsForAdminPayments($requestParams);
|
188 |
+
|
189 |
+
return $requestParams;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* specail handling like validation and so on for admin payments
|
194 |
+
*
|
195 |
+
* @param Mage_Sales_Model_Quote $quote
|
196 |
+
* @param array $requestParams
|
197 |
+
*
|
198 |
+
* @return mixed
|
199 |
+
*/
|
200 |
+
abstract public function handleAdminPayment(Mage_Sales_Model_Quote $quote, $requestParams);
|
201 |
+
|
202 |
+
/**
|
203 |
+
* extracts payment specific payment parameters
|
204 |
+
*
|
205 |
+
* @param Mage_Sales_Model_Quote $quote
|
206 |
+
*
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
abstract protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote);
|
210 |
+
|
211 |
+
/**
|
212 |
+
* gets the shipping address if there is one, otherwise the billing address is used as shipping address
|
213 |
+
*
|
214 |
+
* @param $order
|
215 |
+
* @param $billingAddress
|
216 |
+
*
|
217 |
+
* @return mixed
|
218 |
+
*/
|
219 |
+
protected function getShippingAddress(Mage_Sales_Model_Order $order, $billingAddress)
|
220 |
+
{
|
221 |
+
$shippingAddress = $order->getShippingAddress();
|
222 |
+
if (null === $shippingAddress || false === $shippingAddress) {
|
223 |
+
$shippingAddress = $billingAddress;
|
224 |
+
}
|
225 |
+
return $shippingAddress;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* utf8 decode for direct link calls
|
230 |
+
*
|
231 |
+
* @param array $requestParams
|
232 |
+
*
|
233 |
+
* @return array - the decoded array
|
234 |
+
*/
|
235 |
+
protected function decodeParamsForDirectLinkCall(array $requestParams)
|
236 |
+
{
|
237 |
+
foreach ($requestParams as $key => $value) {
|
238 |
+
$requestParams[$key] = utf8_decode($value);
|
239 |
+
}
|
240 |
+
return $requestParams;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @param $requestParams
|
245 |
+
*
|
246 |
+
* @return mixed
|
247 |
+
*/
|
248 |
+
protected function addCustomerSpecificParams($requestParams)
|
249 |
+
{
|
250 |
+
if ($this->getCustomerHelper()->isLoggedIn()) {
|
251 |
+
$requestParams['CUID'] = $this->getCustomerHelper()->getCustomer()->getId();
|
252 |
+
}
|
253 |
+
return $requestParams;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* @param $requestParams
|
258 |
+
*
|
259 |
+
* @return mixed
|
260 |
+
*/
|
261 |
+
protected function addParamsForAdminPayments($requestParams)
|
262 |
+
{
|
263 |
+
if ($this->getDataHelper()->isAdminSession()) {
|
264 |
+
$requestParams['ECI'] = Netresearch_OPS_Model_Eci_Values::MANUALLY_KEYED_FROM_MOTO;
|
265 |
+
$requestParams['REMOTE_ADDR'] = 'NONE';//$order->getRemoteIp();
|
266 |
+
}
|
267 |
+
return $requestParams;
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* @param $quote
|
272 |
+
* @param $order
|
273 |
+
* @param $billingAddress
|
274 |
+
*
|
275 |
+
* @return array
|
276 |
+
*/
|
277 |
+
protected function getBaseRequestParams($quote, $order, $billingAddress)
|
278 |
+
{
|
279 |
+
$merchantRef = $this->getOrderHelper()->getOpsOrderId($order, $this->canUseOrderId($quote->getPayment()));
|
280 |
+
$requestParams = array(
|
281 |
+
'AMOUNT' => $this->getDataHelper()->getAmount($quote->getBaseGrandTotal()),
|
282 |
+
'CURRENCY' => $this->getQuoteHelper()->getQuoteCurrency($quote),
|
283 |
+
'OPERATION' => $this->getQuoteHelper()->getPaymentAction($quote),
|
284 |
+
'ORDERID' => $merchantRef,
|
285 |
+
'ORIG' => $this->getDataHelper()->getModuleVersionString(),
|
286 |
+
'EMAIL' => $order->getCustomerEmail(),
|
287 |
+
'REMOTE_ADDR' => $quote->getRemoteIp(),
|
288 |
+
'RTIMEOUT' => $this->getConfig()->getTransActionTimeout()
|
289 |
+
);
|
290 |
+
|
291 |
+
$ownerParams = $this->getOwnerParams($quote, $billingAddress, $requestParams);
|
292 |
+
$requestParams = array_merge($requestParams, $ownerParams);
|
293 |
+
$requestParams['ADDMATCH'] = $this->getOrderHelper()->checkIfAddressesAreSame($order);
|
294 |
+
|
295 |
+
return $requestParams;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param $quote
|
300 |
+
* @param $billingAddress
|
301 |
+
* @param $requestParams
|
302 |
+
*
|
303 |
+
* @return array
|
304 |
+
*/
|
305 |
+
protected function getOwnerParams($quote, $billingAddress, $requestParams)
|
306 |
+
{
|
307 |
+
$ownerParams = $this->getRequestHelper()->getOwnerParams($billingAddress, $quote);
|
308 |
+
if (array_key_exists('OWNERADDRESS', $ownerParams) && array_key_exists('OWNERTOWN', $ownerParams)) {
|
309 |
+
$ownerAddrParams = $this->decodeParamsForDirectLinkCall(
|
310 |
+
array('OWNERADDRESS' => $ownerParams['OWNERADDRESS'], 'OWNERTOWN' => $ownerParams['OWNERTOWN'])
|
311 |
+
);
|
312 |
+
$ownerParams = array_merge($ownerParams, $ownerAddrParams);
|
313 |
+
}
|
314 |
+
|
315 |
+
return $ownerParams;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* @return bool
|
320 |
+
*/
|
321 |
+
public function canUseOrderId(Varien_Object $payment)
|
322 |
+
{
|
323 |
+
$methodInstance = $payment->getMethodInstance();
|
324 |
+
return
|
325 |
+
$this->getConfig()->getInlineOrderReference() == Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
|
326 |
+
&& $methodInstance instanceof Netresearch_OPS_Model_Payment_DirectLink;
|
327 |
+
}
|
328 |
+
|
329 |
+
|
330 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Payment/DirectLink/RequestInterface.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
11 |
+
* @category Netresearch
|
12 |
+
* @package Netresearch_OPS
|
13 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
interface Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* sets the data helper
|
20 |
+
*
|
21 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
22 |
+
*/
|
23 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper);
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return Netresearch_OPS_Model_Config
|
27 |
+
*/
|
28 |
+
public function getConfig();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* sets the quote helper
|
32 |
+
*
|
33 |
+
* @param Netresearch_OPS_Helper_Quote $quoteHelper
|
34 |
+
*/
|
35 |
+
public function setQuoteHelper(Netresearch_OPS_Helper_Quote $quoteHelper);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* extracts the parameter for the direct link request from the quote, order and, optionally from existing request params
|
39 |
+
*
|
40 |
+
* @param Mage_Sales_Model_Quote $quote
|
41 |
+
* @param Mage_Sales_Model_Order $order
|
42 |
+
* @param array $requestParams
|
43 |
+
*
|
44 |
+
* @return array - the parameters for the direct link request
|
45 |
+
*/
|
46 |
+
public function getDirectLinkRequestParams(
|
47 |
+
Mage_Sales_Model_Quote $quote,
|
48 |
+
Mage_Sales_Model_Order $order,
|
49 |
+
$requestParams = array()
|
50 |
+
);
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param null $config
|
54 |
+
*/
|
55 |
+
public function setConfig($config);
|
56 |
+
|
57 |
+
/**
|
58 |
+
* sets the order helper
|
59 |
+
*
|
60 |
+
* @param Netresearch_OPS_Helper_Order $orderHelper
|
61 |
+
*/
|
62 |
+
public function setOrderHelper(Netresearch_OPS_Helper_Order $orderHelper);
|
63 |
+
|
64 |
+
/**
|
65 |
+
* sets the customer helper
|
66 |
+
*
|
67 |
+
* @param Mage_Core_Helper_Abstract $customerHelper
|
68 |
+
*/
|
69 |
+
public function setCustomerHelper(Mage_Core_Helper_Abstract $customerHelper);
|
70 |
+
|
71 |
+
public function setRequestHelper(Netresearch_OPS_Helper_Payment_Request $requestHelper);
|
72 |
+
|
73 |
+
/**
|
74 |
+
* gets the customer helper
|
75 |
+
*
|
76 |
+
* @return Mage_Core_Helper_Abstract
|
77 |
+
*/
|
78 |
+
public function getCustomerHelper();
|
79 |
+
|
80 |
+
/**
|
81 |
+
* gets the order helper
|
82 |
+
*
|
83 |
+
* @return Mage_Core_Helper_Abstract
|
84 |
+
*/
|
85 |
+
public function getOrderHelper();
|
86 |
+
|
87 |
+
/**
|
88 |
+
* gets the data helper
|
89 |
+
*
|
90 |
+
* @return Mage_Core_Helper_Abstract
|
91 |
+
*/
|
92 |
+
public function getDataHelper();
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return Netresearch_OPS_Helper_Payment_Request
|
96 |
+
*/
|
97 |
+
public function getRequestHelper();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* special handling like validation and so on for admin payments
|
101 |
+
*
|
102 |
+
* @param Mage_Sales_Model_Quote $quote
|
103 |
+
* @param $requestParams
|
104 |
+
*
|
105 |
+
* @return mixed
|
106 |
+
*/
|
107 |
+
public function handleAdminPayment(Mage_Sales_Model_Quote $quote, $requestParams);
|
108 |
+
|
109 |
+
/**
|
110 |
+
* gets the quote helper
|
111 |
+
*
|
112 |
+
* @return Mage_Core_Helper_Abstract
|
113 |
+
*/
|
114 |
+
public function getQuoteHelper();
|
115 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Payment/Request.php
ADDED
@@ -0,0 +1,659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @package Netresearch_OPS
|
7 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Helper_Payment_Request
|
11 |
+
{
|
12 |
+
protected $config = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param Netresearch_OPS_Model_Config $config
|
16 |
+
*/
|
17 |
+
public function setConfig($config)
|
18 |
+
{
|
19 |
+
$this->config = $config;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return Netresearch_OPS_Model_Config
|
24 |
+
*/
|
25 |
+
public function getConfig()
|
26 |
+
{
|
27 |
+
if ($this->config === null) {
|
28 |
+
$this->config = Mage::getModel('ops/config');
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->config;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* extracts the ship to information from a given address
|
36 |
+
*
|
37 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
38 |
+
* @param Mage_Sales_Model_Quote || Mage_Sales_Model_Order $salesObject
|
39 |
+
*
|
40 |
+
* @return array - the parameters containing the ship to data
|
41 |
+
*/
|
42 |
+
public function extractShipToParameters($address, $salesObject = null)
|
43 |
+
{
|
44 |
+
$paramValues = array();
|
45 |
+
|
46 |
+
if (!$address instanceof Mage_Customer_Model_Address_Abstract) {
|
47 |
+
// virtual carts may not have a shipping address - so fall back to billing
|
48 |
+
if (!is_null($salesObject) && $salesObject->getShippingAddress()) {
|
49 |
+
$address = $salesObject->getShippingAddress();
|
50 |
+
} else {
|
51 |
+
$address = $salesObject->getBillingAddress();
|
52 |
+
}
|
53 |
+
|
54 |
+
if(!$address){
|
55 |
+
return $paramValues;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
$paramValues['ECOM_SHIPTO_POSTAL_CITY'] = $address->getCity();
|
60 |
+
$paramValues['ECOM_SHIPTO_POSTAL_POSTALCODE'] = $address->getPostcode();
|
61 |
+
$paramValues['ECOM_SHIPTO_POSTAL_STATE'] = $this->getIsoRegionCode($address);
|
62 |
+
$paramValues['ECOM_SHIPTO_POSTAL_COUNTRYCODE'] = $address->getCountry();
|
63 |
+
$paramValues['ECOM_SHIPTO_POSTAL_NAME_FIRST'] = $address->getFirstname();
|
64 |
+
$paramValues['ECOM_SHIPTO_POSTAL_NAME_LAST'] = $address->getLastname();
|
65 |
+
$paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = $address->getStreet(1);
|
66 |
+
$paramValues['ECOM_SHIPTO_POSTAL_STREET_LINE2'] = $address->getStreet(2);
|
67 |
+
|
68 |
+
return $paramValues;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Extracts the billing address parameters for the ECOM_BILLTO fields
|
73 |
+
*
|
74 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
75 |
+
* @param Mage_Sales_Model_Quote || Mage_Sales_Model_Order $salesObject
|
76 |
+
*
|
77 |
+
* @return string[] - array containing the ECOM_BILLTO parameters
|
78 |
+
*/
|
79 |
+
public function extractBillToParameters($address, $salesObject = null)
|
80 |
+
{
|
81 |
+
$paramValues = array();
|
82 |
+
|
83 |
+
if (!$address instanceof Mage_Customer_Model_Address_Abstract) {
|
84 |
+
if(!is_null($salesObject)) {
|
85 |
+
$address = $salesObject->getBillingAddress();
|
86 |
+
}
|
87 |
+
if(!$address){
|
88 |
+
return $paramValues;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$paramValues['ECOM_BILLTO_POSTAL_CITY'] = $address->getCity();
|
93 |
+
$paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
|
94 |
+
$paramValues['ECOM_BILLTO_POSTAL_COUNTY'] = $this->getIsoRegionCode($address);
|
95 |
+
$paramValues['ECOM_BILLTO_POSTAL_COUNTRYCODE'] = $address->getCountry();
|
96 |
+
$paramValues['ECOM_BILLTO_POSTAL_NAME_FIRST'] = $address->getFirstname();
|
97 |
+
$paramValues['ECOM_BILLTO_POSTAL_NAME_LAST'] = $address->getLastname();
|
98 |
+
$paramValues['ECOM_BILLTO_POSTAL_POSTALCODE'] = $address->getPostcode();
|
99 |
+
$paramValues['ECOM_BILLTO_POSTAL_STREET_LINE1'] = $address->getStreet(1);
|
100 |
+
$paramValues['ECOM_BILLTO_POSTAL_STREET_LINE2'] = $address->getStreet(2);
|
101 |
+
$paramValues['ECOM_BILLTO_POSTAL_STREET_LINE3'] = $address->getStreet(3);
|
102 |
+
|
103 |
+
return $paramValues;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* extraxcts the according Acceptance owner* parameter
|
108 |
+
*
|
109 |
+
* @param Mage_Customer_Model_Address_Abstract $billingAddress
|
110 |
+
*
|
111 |
+
* @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $salesObject
|
112 |
+
*
|
113 |
+
* @return string[]
|
114 |
+
*/
|
115 |
+
public function getOwnerParams(Mage_Customer_Model_Address_Abstract $billingAddress, $salesObject)
|
116 |
+
{
|
117 |
+
$ownerParams = array();
|
118 |
+
if ($this->getConfig()->canSubmitExtraParameter($salesObject->getStoreId())) {
|
119 |
+
$ownerParams = array(
|
120 |
+
'OWNERADDRESS' => str_replace("\n", ' ', $billingAddress->getStreet(1)),
|
121 |
+
'OWNERTOWN' => $billingAddress->getCity(),
|
122 |
+
'OWNERZIP' => $billingAddress->getPostcode(),
|
123 |
+
'OWNERTELNO' => $billingAddress->getTelephone(),
|
124 |
+
'OWNERCTY' => $billingAddress->getCountry(),
|
125 |
+
|
126 |
+
'ECOM_BILLTO_POSTAL_POSTALCODE' => $billingAddress->getPostcode(),
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
return $ownerParams;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Returns the template parameters and their dependencies
|
135 |
+
*
|
136 |
+
* @return array
|
137 |
+
*/
|
138 |
+
|
139 |
+
public function getTemplateParams($storeId = null)
|
140 |
+
{
|
141 |
+
$formFields = array();
|
142 |
+
switch ($this->getConfig()->getConfigData('template')) {
|
143 |
+
case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL:
|
144 |
+
$formFields['TP'] = $this->getConfig()->getPayPageTemplate($storeId);
|
145 |
+
break;
|
146 |
+
case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE:
|
147 |
+
$formFields['TP'] = $this->getConfig()->getTemplateIdentifier($storeId);
|
148 |
+
break;
|
149 |
+
case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME:
|
150 |
+
$formFields['PARAMPLUS'] = 'IFRAME=1';
|
151 |
+
case Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT:
|
152 |
+
$formFields['PMLISTTYPE'] = $this->getConfig()->getConfigData('pmlist', $storeId);
|
153 |
+
$formFields['TITLE'] = $this->getConfig()->getConfigData('html_title', $storeId);
|
154 |
+
$formFields['BGCOLOR'] = $this->getConfig()->getConfigData('bgcolor', $storeId);
|
155 |
+
$formFields['TXTCOLOR'] = $this->getConfig()->getConfigData('txtcolor', $storeId);
|
156 |
+
$formFields['TBLBGCOLOR'] = $this->getConfig()->getConfigData('tblbgcolor', $storeId);
|
157 |
+
$formFields['TBLTXTCOLOR'] = $this->getConfig()->getConfigData('tbltxtcolor', $storeId);
|
158 |
+
$formFields['BUTTONBGCOLOR'] = $this->getConfig()->getConfigData('buttonbgcolor', $storeId);
|
159 |
+
$formFields['BUTTONTXTCOLOR'] = $this->getConfig()->getConfigData('buttontxtcolor', $storeId);
|
160 |
+
$formFields['FONTTYPE'] = $this->getConfig()->getConfigData('fonttype', $storeId);
|
161 |
+
$formFields['LOGO'] = $this->getConfig()->getConfigData('logo', $storeId);
|
162 |
+
$formFields['HOMEURL'] = $this->getConfig()->hasHomeUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'home')) : 'NONE';
|
163 |
+
$formFields['CATALOGURL'] = $this->getConfig()->hasCatalogUrl() ? $this->getConfig()->getContinueUrl(array('redirect' => 'catalog')) : '';
|
164 |
+
break;
|
165 |
+
default:
|
166 |
+
break;
|
167 |
+
};
|
168 |
+
|
169 |
+
return $formFields;
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* extracts the region code in iso format (if possible)
|
175 |
+
*
|
176 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
177 |
+
*
|
178 |
+
* @return string - the region code in iso format
|
179 |
+
*/
|
180 |
+
public function getIsoRegionCode(Mage_Customer_Model_Address_Abstract $address)
|
181 |
+
{
|
182 |
+
$regionCode = trim($address->getRegionCode());
|
183 |
+
$countryCode = $address->getCountry();
|
184 |
+
if ($this->isAlreadyIsoCode($regionCode, $countryCode)) {
|
185 |
+
return $regionCode;
|
186 |
+
}
|
187 |
+
if (0 === strpos($regionCode, $countryCode . '-')) {
|
188 |
+
return str_replace($countryCode . '-', '', $regionCode);
|
189 |
+
}
|
190 |
+
|
191 |
+
return $this->getRegionCodeFromMapping($countryCode, $regionCode);
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* checks if the given region code is already in iso format
|
196 |
+
*
|
197 |
+
* @param string $regionCode
|
198 |
+
* @param string $countryCode
|
199 |
+
*
|
200 |
+
* @return bool
|
201 |
+
*/
|
202 |
+
protected function isAlreadyIsoCode($regionCode, $countryCode)
|
203 |
+
{
|
204 |
+
return ((strlen($regionCode) < 3 && !in_array($countryCode, array('AT')))
|
205 |
+
|| (strlen($regionCode) === 3 && !in_array($countryCode, array('DE'))));
|
206 |
+
}
|
207 |
+
|
208 |
+
protected function getRegionCodeFromMapping($countryCode, $regionCode)
|
209 |
+
{
|
210 |
+
$countryRegionMapping = $this->getCountryRegionMapping($countryCode);
|
211 |
+
if (array_key_exists($regionCode, $countryRegionMapping)) {
|
212 |
+
return $countryRegionMapping[$regionCode];
|
213 |
+
}
|
214 |
+
|
215 |
+
return $countryCode;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* retrieves country specific region mapping
|
220 |
+
*
|
221 |
+
* @param $countryCode
|
222 |
+
*
|
223 |
+
* @return array - the country specific region mapping or empty array if mapping could not be found
|
224 |
+
*/
|
225 |
+
protected function getCountryRegionMapping($countryCode)
|
226 |
+
{
|
227 |
+
if (strtoupper($countryCode) === 'DE') {
|
228 |
+
return $this->getRegionMappingForGermany();
|
229 |
+
}
|
230 |
+
if (strtoupper($countryCode) === 'AT') {
|
231 |
+
return $this->getRegionMappingForAustria();
|
232 |
+
}
|
233 |
+
if (strtoupper($countryCode) === 'ES') {
|
234 |
+
return $this->getRegionMappingForSpain();
|
235 |
+
}
|
236 |
+
if (strtoupper($countryCode) === 'FI') {
|
237 |
+
return $this->getRegionsMappingForFinland();
|
238 |
+
}
|
239 |
+
if (strtoupper($countryCode) === 'LV') {
|
240 |
+
return $this->getRegionsMappingForLatvia();
|
241 |
+
}
|
242 |
+
|
243 |
+
return array();;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* translates the Magento's region code for germany into ISO format
|
248 |
+
*
|
249 |
+
* @return array
|
250 |
+
*/
|
251 |
+
protected function getRegionMappingForGermany()
|
252 |
+
{
|
253 |
+
return array(
|
254 |
+
'NDS' => 'NI',
|
255 |
+
'BAW' => 'BW',
|
256 |
+
'BAY' => 'BY',
|
257 |
+
'BER' => 'BE',
|
258 |
+
'BRG' => 'BB',
|
259 |
+
'BRE' => 'HB',
|
260 |
+
'HAM' => 'HH',
|
261 |
+
'HES' => 'HE',
|
262 |
+
'MEC' => 'MV',
|
263 |
+
'NRW' => 'NW',
|
264 |
+
'RHE' => 'RP',
|
265 |
+
'SAR' => 'SL',
|
266 |
+
'SAS' => 'SN',
|
267 |
+
'SAC' => 'ST',
|
268 |
+
'SCN' => 'SH',
|
269 |
+
'THE' => 'TH'
|
270 |
+
);
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* translates the Magento's region code for austria into ISO format
|
275 |
+
*
|
276 |
+
* @return array
|
277 |
+
*/
|
278 |
+
protected function getRegionMappingForAustria()
|
279 |
+
{
|
280 |
+
return array(
|
281 |
+
'WI' => '9',
|
282 |
+
'NO' => '3',
|
283 |
+
'OO' => '4',
|
284 |
+
'SB' => '5',
|
285 |
+
'KN' => '2',
|
286 |
+
'ST' => '6',
|
287 |
+
'TI' => '7',
|
288 |
+
'BL' => '1',
|
289 |
+
'VB' => '8'
|
290 |
+
);
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* translates the Magento's region code for spain into ISO format
|
295 |
+
*
|
296 |
+
* @return array
|
297 |
+
*/
|
298 |
+
protected function getRegionMappingForSpain()
|
299 |
+
{
|
300 |
+
return array(
|
301 |
+
'A Coruсa' => 'C',
|
302 |
+
'Alava' => 'VI',
|
303 |
+
'Albacete' => 'AB',
|
304 |
+
'Alicante' => 'A',
|
305 |
+
'Almeria' => 'AL',
|
306 |
+
'Asturias' => 'O',
|
307 |
+
'Avila' => 'AV',
|
308 |
+
'Badajoz' => 'BA',
|
309 |
+
'Baleares' => 'PM',
|
310 |
+
'Barcelona' => 'B',
|
311 |
+
'Caceres' => 'CC',
|
312 |
+
'Cadiz' => 'CA',
|
313 |
+
'Cantabria' => 'S',
|
314 |
+
'Castellon' => 'CS',
|
315 |
+
'Ceuta' => 'CE',
|
316 |
+
'Ciudad Real' => 'CR',
|
317 |
+
'Cordoba' => 'CO',
|
318 |
+
'Cuenca' => 'CU',
|
319 |
+
'Girona' => 'GI',
|
320 |
+
'Granada' => 'GR',
|
321 |
+
'Guadalajara' => 'GU',
|
322 |
+
'Guipuzcoa' => 'SS',
|
323 |
+
'Huelva' => 'H',
|
324 |
+
'Huesca' => 'HU',
|
325 |
+
'Jaen' => 'J',
|
326 |
+
'La Rioja' => 'LO',
|
327 |
+
'Las Palmas' => 'GC',
|
328 |
+
'Leon' => 'LE',
|
329 |
+
'Lleida' => 'L',
|
330 |
+
'Lugo' => 'LU',
|
331 |
+
'Madrid' => 'M',
|
332 |
+
'Malaga' => 'MA',
|
333 |
+
'Melilla' => 'ML',
|
334 |
+
'Murcia' => 'MU',
|
335 |
+
'Navarra' => 'NA',
|
336 |
+
'Ourense' => 'OR',
|
337 |
+
'Palencia' => 'P',
|
338 |
+
'Pontevedra' => 'PO',
|
339 |
+
'Salamanca' => 'SA',
|
340 |
+
'Santa Cruz de Tenerife' => 'TF',
|
341 |
+
'Segovia' => 'Z',
|
342 |
+
'Sevilla' => 'SG',
|
343 |
+
'Soria' => 'SE',
|
344 |
+
'Tarragona' => 'SO',
|
345 |
+
'Teruel' => 'T',
|
346 |
+
'Toledo' => 'TE',
|
347 |
+
'Valencia' => 'TO',
|
348 |
+
'Valladolid' => 'V',
|
349 |
+
'Vizcaya' => 'VA',
|
350 |
+
'Zamora' => 'BI',
|
351 |
+
'Zaragoza' => 'ZA',
|
352 |
+
);
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* translates the Magento's region code for finland into ISO format
|
357 |
+
*
|
358 |
+
* @return array
|
359 |
+
*/
|
360 |
+
protected function getRegionsMappingForFinland()
|
361 |
+
{
|
362 |
+
return array(
|
363 |
+
'Lappi' => '10',
|
364 |
+
'Pohjois-Pohjanmaa' => '14',
|
365 |
+
'Kainuu' => '05',
|
366 |
+
'Pohjois-Karjala' => '13',
|
367 |
+
'Pohjois-Savo' => '15',
|
368 |
+
'Etelä-Savo' => '04',
|
369 |
+
'Etelä-Pohjanmaa' => '03',
|
370 |
+
'Pohjanmaa' => '12',
|
371 |
+
'Pirkanmaa' => '11',
|
372 |
+
'Satakunta' => '17',
|
373 |
+
'Keski-Pohjanmaa' => '07',
|
374 |
+
'Keski-Suomi' => '08',
|
375 |
+
'Varsinais-Suomi' => '19',
|
376 |
+
'Etelä-Karjala' => '02',
|
377 |
+
'Päijät-Häme' => '16',
|
378 |
+
'Kanta-Häme' => '06',
|
379 |
+
'Uusimaa' => '18',
|
380 |
+
'Itä-Uusimaa' => '19',
|
381 |
+
'Kymenlaakso' => '09',
|
382 |
+
'Ahvenanmaa' => '01'
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* translates the Magento's region code for latvia into ISO format
|
388 |
+
*
|
389 |
+
* @return array
|
390 |
+
*/
|
391 |
+
protected function getRegionsMappingForLatvia()
|
392 |
+
{
|
393 |
+
return array(
|
394 |
+
'Ādažu novads' => 'LV',
|
395 |
+
'Aglonas novads' => '001',
|
396 |
+
'Aizputes novads' => '003',
|
397 |
+
'Aknīstes novads' => '004',
|
398 |
+
'Alojas novads' => '005',
|
399 |
+
'Alsungas novads' => '006',
|
400 |
+
'Amatas novads' => '008',
|
401 |
+
'Apes novads' => '009',
|
402 |
+
'Auces novads' => '010',
|
403 |
+
'Babītes novads' => '012',
|
404 |
+
'Baldones novads' => '013',
|
405 |
+
'Baltinavas novads' => '014',
|
406 |
+
'Beverīnas novads' => '017',
|
407 |
+
'Brocēnu novads' => '018',
|
408 |
+
'Burtnieku novads' => '019',
|
409 |
+
'Carnikavas novads' => '020',
|
410 |
+
'Cesvaines novads' => '021',
|
411 |
+
'Ciblas novads' => '023',
|
412 |
+
'Dagdas novads' => '024',
|
413 |
+
'Dundagas novads' => '027',
|
414 |
+
'Durbes novads' => '028',
|
415 |
+
'Engures novads' => '029',
|
416 |
+
'Ērgļu novads' => 'LV',
|
417 |
+
'Garkalnes novads' => '031',
|
418 |
+
'Grobiņas novads' => '032',
|
419 |
+
'Iecavas novads' => '034',
|
420 |
+
'Ikšķiles novads' => '035',
|
421 |
+
'Ilūkstes novads' => '036',
|
422 |
+
'Inčukalna novads' => '037',
|
423 |
+
'Jaunjelgavas novads' => '038',
|
424 |
+
'Jaunpiebalgas novads' => '039',
|
425 |
+
'Jaunpils novads' => '040',
|
426 |
+
'Jēkabpils' => '042',
|
427 |
+
'Kandavas novads' => '043',
|
428 |
+
'Kārsavas novads' => 'LV',
|
429 |
+
'Ķeguma novads' => 'LV',
|
430 |
+
'Ķekavas novads' => 'LV',
|
431 |
+
'Kokneses novads' => '046',
|
432 |
+
'Krimuldas novads' => '048',
|
433 |
+
'Krustpils novads' => '049',
|
434 |
+
'Lielvārdes novads' => '053',
|
435 |
+
'Līgatnes novads' => 'LV',
|
436 |
+
'Līvānu novads' => '056',
|
437 |
+
'Lubānas novads' => '057',
|
438 |
+
'Mālpils novads' => '061',
|
439 |
+
'Mārupes novads' => '062',
|
440 |
+
'Mazsalacas novads' => '060',
|
441 |
+
'Naukšēnu novads' => '064',
|
442 |
+
'Neretas novads' => '065',
|
443 |
+
'Nīcas novads' => '066',
|
444 |
+
'Olaines novads' => '068',
|
445 |
+
'Ozolnieku novads' => '069',
|
446 |
+
'Pārgaujas novads' => 'LV',
|
447 |
+
'Pāvilostas novads' => '070',
|
448 |
+
'Pļaviņu novads' => '072',
|
449 |
+
'Priekules novads' => '074',
|
450 |
+
'Priekuļu novads' => '075',
|
451 |
+
'Raunas novads' => '076',
|
452 |
+
'Riebiņu novads' => '078',
|
453 |
+
'Rojas novads' => '079',
|
454 |
+
'Ropažu novads' => '080',
|
455 |
+
'Rucavas novads' => '081',
|
456 |
+
'Rugāju novads' => '082',
|
457 |
+
'Rūjienas novads' => '084',
|
458 |
+
'Rundāles novads' => '083',
|
459 |
+
'Salacgrīvas novads' => '085',
|
460 |
+
'Salas novads' => '086',
|
461 |
+
'Salaspils novads' => '087',
|
462 |
+
'Saulkrastu novads' => '089',
|
463 |
+
'Sējas novads' => 'LV',
|
464 |
+
'Siguldas novads' => '091',
|
465 |
+
'Skrīveru novads' => '092',
|
466 |
+
'Skrundas novads' => '093',
|
467 |
+
'Smiltenes novads' => '094',
|
468 |
+
'Stopiņu novads' => '095',
|
469 |
+
'Strenču novads' => '096',
|
470 |
+
'Tērvetes novads' => '098',
|
471 |
+
'Vaiņodes novads' => '100',
|
472 |
+
'Valmiera' => 'LV',
|
473 |
+
'Varakļānu novads' => '102',
|
474 |
+
'Vārkavas novads' => 'LV',
|
475 |
+
'Vecpiebalgas novads' => '104',
|
476 |
+
'Vecumnieku novads' => '105',
|
477 |
+
'Viesītes novads' => '107',
|
478 |
+
'Viļakas novads' => '108',
|
479 |
+
'Viļānu novads' => '109',
|
480 |
+
'Zilupes novads' => '110'
|
481 |
+
);
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Returns the mandatory fields for requests to Acceptance
|
486 |
+
*
|
487 |
+
* @param Mage_Sales_Model_Order $order
|
488 |
+
*
|
489 |
+
* @return array
|
490 |
+
*/
|
491 |
+
|
492 |
+
public function getMandatoryRequestFields(Mage_Sales_Model_Order $order)
|
493 |
+
{
|
494 |
+
$payment = $order->getPayment()->getMethodInstance();
|
495 |
+
$formFields = array();
|
496 |
+
$formFields['PSPID'] = $this->getConfig()->getPSPID($order->getStoreId());
|
497 |
+
$formFields['AMOUNT'] = Mage::helper('ops')->getAmount($order->getBaseGrandTotal());
|
498 |
+
$formFields['CURRENCY'] = Mage::app()->getStore()->getBaseCurrencyCode();
|
499 |
+
$formFields['ORDERID'] = Mage::helper('ops/order')->getOpsOrderId($order);
|
500 |
+
$formFields['LANGUAGE'] = Mage::app()->getLocale()->getLocaleCode();
|
501 |
+
$formFields['PM'] = $payment->getOpsCode($order->getPayment());
|
502 |
+
$formFields['EMAIL'] = $order->getCustomerEmail();
|
503 |
+
|
504 |
+
$formFields['ACCEPTURL'] = $this->getConfig()->getAcceptUrl();
|
505 |
+
$formFields['DECLINEURL'] = $this->getConfig()->getDeclineUrl();
|
506 |
+
$formFields['EXCEPTIONURL'] = $this->getConfig()->getExceptionUrl();
|
507 |
+
$formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
|
508 |
+
$formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
|
509 |
+
|
510 |
+
$formFields['FP_ACTIV'] = $this->isFingerPrintingActive($order) ? '1' : '0';
|
511 |
+
|
512 |
+
return $formFields;
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Will return the combination of activiation via config and the state of consent of the customer
|
517 |
+
*
|
518 |
+
* @param $order
|
519 |
+
*
|
520 |
+
* @return bool
|
521 |
+
*/
|
522 |
+
protected function isFingerPrintingActive($order)
|
523 |
+
{
|
524 |
+
return $this->getConfig()->getDeviceFingerPrinting($order->getStoreId())
|
525 |
+
&& Mage::getSingleton('customer/session')->getData(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY);
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Extracts the order item parameters and puts them in a array like
|
530 |
+
*
|
531 |
+
* @param Mage_Sales_Model_Order $order
|
532 |
+
*
|
533 |
+
* @return array
|
534 |
+
*/
|
535 |
+
public function extractOrderItemParameters(Mage_Sales_Model_Order $order)
|
536 |
+
{
|
537 |
+
$formFields = array();
|
538 |
+
|
539 |
+
// add order items
|
540 |
+
$count = 1;
|
541 |
+
foreach ($order->getAllItems() as $item) {
|
542 |
+
if ($item->getParentItemId()
|
543 |
+
&& $item->getParentItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
|
544 |
+
|| $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
|
545 |
+
) {
|
546 |
+
continue;
|
547 |
+
}
|
548 |
+
$formFields = array_merge($formFields, $this->getItemFormFields($count, $item));
|
549 |
+
$count++;
|
550 |
+
}
|
551 |
+
|
552 |
+
// add discount item
|
553 |
+
$discountItemFormFields = $this->getDiscountItemFormFields($order, $count);
|
554 |
+
if (is_array($discountItemFormFields)) {
|
555 |
+
$formFields = array_merge($formFields, $discountItemFormFields);
|
556 |
+
$count++;
|
557 |
+
}
|
558 |
+
|
559 |
+
// add shipping item
|
560 |
+
$shippingItemFields = $this->getShippingItemFormFields($order);
|
561 |
+
if (is_array($shippingItemFields)) {
|
562 |
+
$formFields = array_merge($formFields, $shippingItemFields);
|
563 |
+
}
|
564 |
+
|
565 |
+
return $formFields;
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* @param Mage_Sales_Model_Order $order
|
570 |
+
*
|
571 |
+
* @return float
|
572 |
+
*/
|
573 |
+
|
574 |
+
public function getShippingTaxRate($order)
|
575 |
+
{
|
576 |
+
$store = $order->getStore();
|
577 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
578 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
579 |
+
$taxRateId = Mage::getStoreConfig('tax/classes/shipping_tax_class', $store);
|
580 |
+
//taxRateId is the same model id as product tax classes, so you can do this:
|
581 |
+
$percent = $taxCalculation->getRate($request->setProductClassId($taxRateId));
|
582 |
+
|
583 |
+
return $percent;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Genereates item array for shipping, returns false if order is virtual
|
588 |
+
*
|
589 |
+
* @param Mage_Sales_Model_Order $order
|
590 |
+
*
|
591 |
+
* @return array | false
|
592 |
+
*/
|
593 |
+
protected function getShippingItemFormFields($order)
|
594 |
+
{
|
595 |
+
if ($order->getIsNotVirtual()) {
|
596 |
+
/* add shipping item */
|
597 |
+
$formFields['ORDERSHIPMETH'] = substr($order->getShippingDescription(), 0, 25);
|
598 |
+
$formFields['ORDERSHIPCOST'] = Mage::helper('ops')->getAmount($order->getBaseShippingAmount());
|
599 |
+
$formFields['ORDERSHIPTAXCODE']
|
600 |
+
= str_replace(',', '.', (string)(float)$this->getShippingTaxRate($order)) . '%';
|
601 |
+
$formFields['ORDERSHIPTAX'] = Mage::helper('ops')->getAmount($order->getBaseShippingTaxAmount());
|
602 |
+
return $formFields;
|
603 |
+
}
|
604 |
+
|
605 |
+
return false;
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Returns item array for Acceptance request for the specified item
|
610 |
+
*
|
611 |
+
* @param $count
|
612 |
+
* @param $item
|
613 |
+
*
|
614 |
+
* @return array
|
615 |
+
*/
|
616 |
+
protected function getItemFormFields($count, $item)
|
617 |
+
{
|
618 |
+
$formFields = array();
|
619 |
+
$formFields['ITEMID' . $count] = $item->getItemId();
|
620 |
+
$formFields['ITEMNAME' . $count] = substr($item->getName(), 0, 40);
|
621 |
+
$formFields['ITEMPRICE' . $count] = number_format($item->getBasePriceInclTax(), 2, '.', '');
|
622 |
+
$formFields['ITEMQUANT' . $count] = (int)$item->getQtyOrdered();
|
623 |
+
$formFields['ITEMVATCODE' . $count] = str_replace(',', '.', (string)(float)$item->getTaxPercent()) . '%';
|
624 |
+
$formFields['TAXINCLUDED' . $count] = 1;
|
625 |
+
|
626 |
+
return $formFields;
|
627 |
+
}
|
628 |
+
|
629 |
+
/**
|
630 |
+
* Creates array
|
631 |
+
*
|
632 |
+
* @param Mage_Sales_Model_Order $order
|
633 |
+
* @param $count
|
634 |
+
*
|
635 |
+
* @return mixed
|
636 |
+
*/
|
637 |
+
protected function getDiscountItemFormFields(Mage_Sales_Model_Order $order, $count)
|
638 |
+
{
|
639 |
+
$formFields = array();
|
640 |
+
/* add coupon item */
|
641 |
+
if ($order->getBaseDiscountAmount()) {
|
642 |
+
$couponAmount = $order->getBaseDiscountAmount();
|
643 |
+
$formFields['ITEMID' . $count] = 'DISCOUNT';
|
644 |
+
$couponRuleName = 'DISCOUNT';
|
645 |
+
if ($order->getCouponRuleName() && strlen(trim($order->getCouponRuleName())) > 0) {
|
646 |
+
$couponRuleName = substr(trim($order->getCouponRuleName()), 0, 30);
|
647 |
+
}
|
648 |
+
$formFields['ITEMNAME' . $count] = $couponRuleName;
|
649 |
+
$formFields['ITEMPRICE' . $count] = number_format($couponAmount, 2, '.', '');
|
650 |
+
$formFields['ITEMQUANT' . $count] = 1;
|
651 |
+
$formFields['ITEMVATCODE' . $count]
|
652 |
+
= str_replace(',', '.', (string)(float)$this->getShippingTaxRate($order)) . '%';
|
653 |
+
$formFields['TAXINCLUDED' . $count] = 1;
|
654 |
+
return $formFields;
|
655 |
+
|
656 |
+
}
|
657 |
+
return false;
|
658 |
+
}
|
659 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Quote.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Helper_Quote extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
const PAGE_SIZE = 100;
|
15 |
+
|
16 |
+
const MINUTES_IN_PAST = 15;
|
17 |
+
|
18 |
+
protected $dataHelper = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* cleans up old payment information (deletes cvc etc. from additional data)
|
22 |
+
*/
|
23 |
+
public function cleanUpOldPaymentInformation()
|
24 |
+
{
|
25 |
+
$allowedTimestamp = new Zend_Db_Expr(sprintf(
|
26 |
+
'NOW() - INTERVAL %d MINUTE', self::MINUTES_IN_PAST
|
27 |
+
));
|
28 |
+
/*
|
29 |
+
* fetching possible affected information from the sales_quote_payment table
|
30 |
+
* criteria are:
|
31 |
+
* - ops_cc was used
|
32 |
+
* - the last update is more than 15 minutes ago
|
33 |
+
* - and CVC is included in the additional information
|
34 |
+
*/
|
35 |
+
$paymentInformation = Mage::getModel('sales/quote_payment')
|
36 |
+
->getCollection()
|
37 |
+
->addFieldToFilter('method', array('eq' => 'ops_cc'))
|
38 |
+
->addFieldToFilter('updated_at', array('lt' => $allowedTimestamp))
|
39 |
+
->addFieldToFilter(
|
40 |
+
'additional_information', array('like' => '%"cvc"%')
|
41 |
+
)
|
42 |
+
->setOrder('created_at', 'DESC')
|
43 |
+
->setPageSize(self::PAGE_SIZE);
|
44 |
+
foreach ($paymentInformation as $payment) {
|
45 |
+
if (!is_null($payment->getAdditionalInformation('cvc'))) {
|
46 |
+
// quote needs to be loaded, because saving the payment information would fail otherwise
|
47 |
+
$payment->setQuote(
|
48 |
+
Mage::getModel('sales/quote')->load($payment->getQuoteId())
|
49 |
+
);
|
50 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation(
|
51 |
+
$payment, true
|
52 |
+
);
|
53 |
+
$payment->save();
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* returns the quote currency
|
63 |
+
*
|
64 |
+
* @param $quote
|
65 |
+
*
|
66 |
+
* @return string - the quotes currency
|
67 |
+
*/
|
68 |
+
public function getQuoteCurrency(Mage_Sales_Model_Quote $quote)
|
69 |
+
{
|
70 |
+
if ($quote->hasForcedCurrency()) {
|
71 |
+
return $quote->getForcedCurrency()->getCode();
|
72 |
+
} else {
|
73 |
+
return Mage::app()->getStore($quote->getStoreId())
|
74 |
+
->getBaseCurrencyCode();
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* get payment operation code
|
80 |
+
*
|
81 |
+
* @param Mage_Sales_Model_Order $order
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getPaymentAction($order)
|
86 |
+
{
|
87 |
+
$operation
|
88 |
+
= Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
|
89 |
+
|
90 |
+
// different capture operation name for direct debits
|
91 |
+
if ('Direct Debits DE' == $order->getPayment()
|
92 |
+
->getAdditionalInformation('PM')
|
93 |
+
|| 'Direct Debits AT' == $order->getPayment()
|
94 |
+
->getAdditionalInformation('PM')
|
95 |
+
) {
|
96 |
+
if ('authorize_capture' == Mage::getModel('ops/config')
|
97 |
+
->getPaymentAction($order->getStoreId())
|
98 |
+
) {
|
99 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION;
|
100 |
+
}
|
101 |
+
|
102 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
|
103 |
+
}
|
104 |
+
// no RES for Direct Debits NL, so we'll do the final sale
|
105 |
+
if ('Direct Debits NL' == $order->getPayment()
|
106 |
+
->getAdditionalInformation('PM')
|
107 |
+
) {
|
108 |
+
if ('authorize_capture' == Mage::getModel('ops/config')
|
109 |
+
->getPaymentAction($order->getStoreId())
|
110 |
+
) {
|
111 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_DIRECTDEBIT_NL;
|
112 |
+
}
|
113 |
+
|
114 |
+
return Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION;
|
115 |
+
}
|
116 |
+
|
117 |
+
if ('authorize_capture' == Mage::getModel('ops/config')
|
118 |
+
->getPaymentAction($order->getStoreId())
|
119 |
+
) {
|
120 |
+
$operation
|
121 |
+
= Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION;
|
122 |
+
}
|
123 |
+
|
124 |
+
return $operation;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @return Mage_Sales_Model_Quote
|
129 |
+
*/
|
130 |
+
public function getQuote()
|
131 |
+
{
|
132 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
133 |
+
return Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
134 |
+
}
|
135 |
+
|
136 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* gets the data helper
|
141 |
+
*
|
142 |
+
* @return Netresearch_OPS_Helper_Data
|
143 |
+
*/
|
144 |
+
public function getDataHelper()
|
145 |
+
{
|
146 |
+
if (null === $this->dataHelper) {
|
147 |
+
$this->dataHelper = Mage::helper('ops/data');
|
148 |
+
}
|
149 |
+
|
150 |
+
return $this->dataHelper;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* sets the data helper
|
155 |
+
*
|
156 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
157 |
+
*/
|
158 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper)
|
159 |
+
{
|
160 |
+
$this->dataHelper = $dataHelper;
|
161 |
+
}
|
162 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Subscription.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Subscription.php
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
class Netresearch_OPS_Helper_Subscription extends Mage_Core_Helper_Abstract
|
30 |
+
{
|
31 |
+
const SUBSCRIPTION_PREFIX = 'SUB-';
|
32 |
+
const TRIAL_SUFFIX = '-TRIAL';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Generates subscription id in the following pattern:
|
36 |
+
*
|
37 |
+
* SUB-subscriptionId-TRIAL
|
38 |
+
*
|
39 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile - the profile itself
|
40 |
+
* @param bool $withTrial - if you wish the trial suffix appended in case the profile has a trial subscription
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function generateSubscriptionId(Mage_Payment_Model_Recurring_Profile $profile, $withTrial = false)
|
45 |
+
{
|
46 |
+
$config = Mage::getModel('ops/config');
|
47 |
+
$devPrefix = $config->getConfigData('devprefix');
|
48 |
+
|
49 |
+
$subscriptionId = self::SUBSCRIPTION_PREFIX . $profile->getId();
|
50 |
+
if ($profile->getTrialPeriodUnit() && $withTrial) {
|
51 |
+
$subscriptionId .= self::TRIAL_SUFFIX;
|
52 |
+
}
|
53 |
+
|
54 |
+
return $devPrefix . $subscriptionId;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Determine if the given request parameters belong to a subscription
|
59 |
+
*
|
60 |
+
* @param $requestParams
|
61 |
+
*
|
62 |
+
* @return bool
|
63 |
+
*/
|
64 |
+
public function isSubscriptionFeedback($requestParams)
|
65 |
+
{
|
66 |
+
$result = false;
|
67 |
+
if (is_array($requestParams)
|
68 |
+
&& array_key_exists('orderID', $requestParams)
|
69 |
+
&& false != strstr($this->removeDevPrefix($requestParams['orderID']), self::SUBSCRIPTION_PREFIX)
|
70 |
+
) {
|
71 |
+
$result = true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return $result;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Loads the recurring profile for the given ORDERID
|
79 |
+
*
|
80 |
+
* @param $orderId
|
81 |
+
*
|
82 |
+
* @throws Mage_Core_Exception if no profile could be found
|
83 |
+
*
|
84 |
+
* @return Mage_Sales_Model_Order
|
85 |
+
* @throws Mage_Core_Exception
|
86 |
+
*/
|
87 |
+
public function getProfileForSubscription($orderId)
|
88 |
+
{
|
89 |
+
$orderId = $this->removeDevPrefix($orderId);
|
90 |
+
|
91 |
+
if ($this->isTrialFeedback($orderId)) {
|
92 |
+
$orderId = substr($orderId, -0, strlen(self::TRIAL_SUFFIX));
|
93 |
+
}
|
94 |
+
$orderId = substr($orderId, strlen(self::SUBSCRIPTION_PREFIX));
|
95 |
+
$profile = Mage::getModel('sales/recurring_profile')->load($orderId);
|
96 |
+
if (!$profile->getId()) {
|
97 |
+
Mage::throwException('Could find no subscription for id ' . $orderId);
|
98 |
+
}
|
99 |
+
|
100 |
+
return $profile;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Determines via the given orderId if the feedback request was a from a trial subscription
|
105 |
+
*
|
106 |
+
* @param string $orderId
|
107 |
+
*
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
public function isTrialFeedback($orderId)
|
111 |
+
{
|
112 |
+
return (bool)strstr($orderId, self::TRIAL_SUFFIX);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Determine day of billing according to the period unit of the subscription
|
117 |
+
*
|
118 |
+
* @param string $periodUnit @see Mage_Payment_Model_Recurring_Profile
|
119 |
+
* @param int $storeId
|
120 |
+
*
|
121 |
+
* @return int
|
122 |
+
*/
|
123 |
+
public function getBillingDayForPeriodUnit($periodUnit, $storeId = null)
|
124 |
+
{
|
125 |
+
$config = Mage::getModel('ops/config');
|
126 |
+
$day = 1;
|
127 |
+
|
128 |
+
switch ($periodUnit) {
|
129 |
+
case Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH:
|
130 |
+
$day = $config->getMonthlyBillingDay($storeId);
|
131 |
+
break;
|
132 |
+
case Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK:
|
133 |
+
// offset the day by one, since Magento counts from 0, but Acceptance from 1
|
134 |
+
$day = $config->getWeeklyBillingDay($storeId) + 1;
|
135 |
+
break;
|
136 |
+
}
|
137 |
+
|
138 |
+
return $day;
|
139 |
+
}
|
140 |
+
|
141 |
+
protected function removeDevPrefix($orderId)
|
142 |
+
{
|
143 |
+
$config = Mage::getModel('ops/config');
|
144 |
+
$devPrefix = $config->getConfigData('devprefix');
|
145 |
+
$orderId = substr($orderId, strlen($devPrefix));
|
146 |
+
return $orderId;
|
147 |
+
}
|
148 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Validation/Checkout/Step.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Helper_Validation_Checkout_Step
|
10 |
+
{
|
11 |
+
|
12 |
+
const BILLING_STEP = 'billing';
|
13 |
+
|
14 |
+
const SHIPPING_STEP = 'shipping';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* retrieves the params for pushing back to the billing step
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
protected function getBillingParams()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
'CN',
|
25 |
+
'OWNERZIP',
|
26 |
+
'OWNERTOWN',
|
27 |
+
'OWNERTELNO',
|
28 |
+
'OWNERADDRESS',
|
29 |
+
'ECOM_BILLTO_POSTAL_POSTALCODE'
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* retrieves the params for pushing back to the billing step
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
protected function getShippingParams()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
'ECOM_SHIPTO_POSTAL_NAME_FIRST',
|
42 |
+
'ECOM_SHIPTO_POSTAL_NAME_LAST',
|
43 |
+
'ECOM_SHIPTO_POSTAL_STREET1',
|
44 |
+
'ECOM_SHIPTO_POSTAL_STREET2',
|
45 |
+
'ECOM_SHIPTO_POSTAL_STREET3',
|
46 |
+
'ECOM_SHIPTO_POSTAL_COUNTRYCODE',
|
47 |
+
'ECOM_SHIPTO_POSTAL_COUNTY',
|
48 |
+
'ECOM_SHIPTO_POSTAL_POSTALCODE',
|
49 |
+
'ECOM_SHIPTO_POSTAL_CITY',
|
50 |
+
'ECOM_SHIPTO_POSTAL_STREET_NUMBER',
|
51 |
+
'ECOM_SHIPTO_POSTAL_STATE'
|
52 |
+
);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* gets the corresponding checkout step for the erroneous fields
|
57 |
+
*
|
58 |
+
* @param array $erroneousFields
|
59 |
+
*
|
60 |
+
* @return string - the checkout step
|
61 |
+
*/
|
62 |
+
public function getStep(array $erroneousFields)
|
63 |
+
{
|
64 |
+
$checkoutStep = '';
|
65 |
+
foreach ($erroneousFields as $erroneousField) {
|
66 |
+
if (in_array($erroneousField, $this->getBillingParams())) {
|
67 |
+
$checkoutStep = self::BILLING_STEP;
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
if (in_array($erroneousField, $this->getShippingParams())) {
|
71 |
+
$checkoutStep = self::SHIPPING_STEP;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return $checkoutStep;
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Validation/Result.php
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
class Netresearch_OPS_Helper_Validation_Result
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $checkoutStepHelper = null;
|
16 |
+
|
17 |
+
protected $config = null;
|
18 |
+
|
19 |
+
protected $formBlock = null;
|
20 |
+
|
21 |
+
protected $dataHelper = null;
|
22 |
+
|
23 |
+
protected $result = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param array $result
|
27 |
+
*/
|
28 |
+
public function setResult(array $result)
|
29 |
+
{
|
30 |
+
$this->result = $result;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function getResult()
|
37 |
+
{
|
38 |
+
return $this->result;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param null $checkOutStepHelper
|
43 |
+
*/
|
44 |
+
public function setCheckoutStepHelper($checkOutStepHelper)
|
45 |
+
{
|
46 |
+
$this->checkoutStepHelper = $checkOutStepHelper;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @return null
|
51 |
+
*/
|
52 |
+
public function getCheckoutStepHelper()
|
53 |
+
{
|
54 |
+
if (null === $this->checkoutStepHelper) {
|
55 |
+
$this->checkoutStepHelper = Mage::helper('ops/validation_checkout_step');
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->checkoutStepHelper;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param null $config
|
63 |
+
*/
|
64 |
+
public function setConfig($config)
|
65 |
+
{
|
66 |
+
$this->config = $config;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return null
|
71 |
+
*/
|
72 |
+
public function getConfig()
|
73 |
+
{
|
74 |
+
if (null === $this->config) {
|
75 |
+
$this->config = Mage::getModel('ops/config');
|
76 |
+
}
|
77 |
+
|
78 |
+
return $this->config;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @param null $dataHelper
|
83 |
+
*/
|
84 |
+
public function setDataHelper($dataHelper)
|
85 |
+
{
|
86 |
+
$this->dataHelper = $dataHelper;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @return null
|
91 |
+
*/
|
92 |
+
public function getDataHelper()
|
93 |
+
{
|
94 |
+
if (null === $this->dataHelper) {
|
95 |
+
$this->dataHelper = Mage::helper('ops/data');
|
96 |
+
}
|
97 |
+
|
98 |
+
return $this->dataHelper;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param null $formBlock
|
103 |
+
*/
|
104 |
+
public function setFormBlock($formBlock)
|
105 |
+
{
|
106 |
+
$this->formBlock = $formBlock;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @return null
|
111 |
+
*/
|
112 |
+
public function getFormBlock()
|
113 |
+
{
|
114 |
+
if (null === $this->formBlock) {
|
115 |
+
$this->formBlock = Mage::getBlockSingleton('ops/form');
|
116 |
+
}
|
117 |
+
|
118 |
+
return $this->formBlock;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @param array $messages
|
125 |
+
* @param Mage_Sales_Model_Quote $quote
|
126 |
+
*
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
public function getValidationFailedResult($messages, $quote)
|
130 |
+
{
|
131 |
+
$gotoSection = $this->getCheckoutStepHelper()->getStep(array_keys($messages));
|
132 |
+
$this->setBaseErroneousFields($messages, $gotoSection);
|
133 |
+
$this->getFields($messages);
|
134 |
+
$this->addErrorToExistingAddress($quote, $gotoSection);
|
135 |
+
$this->cleanResult();
|
136 |
+
|
137 |
+
return $this->getResult();
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @param $messages
|
142 |
+
* @param $result
|
143 |
+
*
|
144 |
+
* @return mixed
|
145 |
+
*/
|
146 |
+
protected function getFields($messages)
|
147 |
+
{
|
148 |
+
$mappedFields = $this->getConfig()->getFrontendFieldMapping();
|
149 |
+
$frontendFields = array();
|
150 |
+
foreach ($messages as $key => $value) {
|
151 |
+
if (array_key_exists($key, $mappedFields)) {
|
152 |
+
$frontendFields = $this->getFormBlock()->getFrontendValidationFields(
|
153 |
+
$mappedFields,
|
154 |
+
$key,
|
155 |
+
$value,
|
156 |
+
$frontendFields
|
157 |
+
);
|
158 |
+
}
|
159 |
+
}
|
160 |
+
$this->result['fields'] = $frontendFields;
|
161 |
+
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @param $quote
|
167 |
+
* @param $gotoSection
|
168 |
+
*/
|
169 |
+
protected function addErrorToExistingAddress($quote, $gotoSection)
|
170 |
+
{
|
171 |
+
if ($gotoSection == 'billing' && 0 < $quote->getBillingAddress()->getId()) {
|
172 |
+
$this->result['fields']['billing-address-select'] = $this->getDataHelper()->__(
|
173 |
+
'Billing address contains invalid data'
|
174 |
+
);
|
175 |
+
}
|
176 |
+
if ($gotoSection == 'shipping' && 0 < $quote->getShippingAddress()->getId()) {
|
177 |
+
$this->result['fields']['shipping-address-select'] = $this->getDataHelper()->__(
|
178 |
+
'Shipping address contains invalid data'
|
179 |
+
);
|
180 |
+
}
|
181 |
+
|
182 |
+
return $this;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @param $messages
|
187 |
+
* @param $result
|
188 |
+
* @param $gotoSection
|
189 |
+
*
|
190 |
+
* @return mixed
|
191 |
+
*/
|
192 |
+
protected function setBaseErroneousFields($messages, $gotoSection)
|
193 |
+
{
|
194 |
+
$this->result['error'] = implode(',', array_values($messages));
|
195 |
+
$this->result['goto_section'] = $gotoSection;
|
196 |
+
$this->result['opsError'] = true;
|
197 |
+
|
198 |
+
return $this;
|
199 |
+
}
|
200 |
+
|
201 |
+
protected function cleanResult()
|
202 |
+
{
|
203 |
+
if (array_key_exists('update_section', $this->result)) {
|
204 |
+
unset($this->result['update_section']);
|
205 |
+
}
|
206 |
+
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
|
210 |
+
}
|
app/code/community/Netresearch/OPS/Helper/Version.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Helper_Data
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2014 Netresearch
|
8 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Helper_Version extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
const CAN_USE_APPLICABLE_FOR_QUOTE_EE_MINOR = 14;
|
14 |
+
|
15 |
+
const CAN_USE_APPLICABLE_FOR_QUOTE_CE_MINOR = 8;
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* checks if Version is above EE 1.13 or CE 1.7.0.2
|
20 |
+
* useApplicableForQuote was implemented in CE 1.8 / EE 1.14
|
21 |
+
*
|
22 |
+
* @param $edition
|
23 |
+
*
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
public function canUseApplicableForQuote($edition)
|
27 |
+
{
|
28 |
+
$result = false;
|
29 |
+
$versionInfo = $this->getVersionInfo();
|
30 |
+
if (array_key_exists('minor', $versionInfo)
|
31 |
+
&& $versionInfo['minor'] >= $this->getVersionForEdition($edition)
|
32 |
+
) {
|
33 |
+
$result = true;
|
34 |
+
}
|
35 |
+
|
36 |
+
return $result;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* return allowed version
|
41 |
+
*
|
42 |
+
* @param $edition
|
43 |
+
*
|
44 |
+
* @return int
|
45 |
+
*/
|
46 |
+
protected function getVersionForEdition($edition)
|
47 |
+
{
|
48 |
+
if (Mage::EDITION_ENTERPRISE == $edition) {
|
49 |
+
return self::CAN_USE_APPLICABLE_FOR_QUOTE_EE_MINOR;
|
50 |
+
}
|
51 |
+
|
52 |
+
return self::CAN_USE_APPLICABLE_FOR_QUOTE_CE_MINOR;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* wraps Mage::getVersionInfo since Mage class is final and not testable
|
57 |
+
*
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
protected function getVersionInfo()
|
61 |
+
{
|
62 |
+
return Mage::getVersionInfo();
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
}
|
app/code/community/Netresearch/OPS/Model/Alias.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category OPS
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Alias model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Alias extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Constructor
|
34 |
+
*
|
35 |
+
* @see lib/Varien/Varien_Object#_construct()
|
36 |
+
* @return Netresearch_OPS_Model_Alias
|
37 |
+
*/
|
38 |
+
public function _construct()
|
39 |
+
{
|
40 |
+
$this->_init('ops/alias');
|
41 |
+
parent::_construct();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param $customerId - the id of the customer
|
46 |
+
* @param $billingAddressHash - optional billing address hash
|
47 |
+
* @param $shippingAdressHash - optional shipping address hash
|
48 |
+
* @return Netresearch_OPS_Model_Mysql4_Alias_Collection - collection of aliases for given customer
|
49 |
+
*/
|
50 |
+
public function getAliasesForCustomer($customerId, $billingAddressHash = null, $shippingAddressHash = null, $storeId = null)
|
51 |
+
{
|
52 |
+
$collection = $this->getCollection()
|
53 |
+
->addFieldToFilter('customer_id', $customerId);
|
54 |
+
if (!is_null($billingAddressHash) && !is_null($shippingAddressHash)) {
|
55 |
+
$collection
|
56 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
57 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
58 |
+
->addFieldToFilter('store_id', array('eq' => $storeId, 'null' => 'null'))
|
59 |
+
;
|
60 |
+
}
|
61 |
+
return $collection->load();
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
app/code/community/Netresearch/OPS/Model/Alias/State.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category OPS
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Alias state model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Alias_State
|
31 |
+
{
|
32 |
+
const ACTIVE = "active";
|
33 |
+
const PENDING = "pending";
|
34 |
+
}
|
app/code/community/Netresearch/OPS/Model/Api/Directlink.php
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS payment DirectLink Model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
|
33 |
+
const MAX_RETRY_COUNT = 3;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Perform a CURL call and log request end response to logfile
|
37 |
+
*
|
38 |
+
* @param array $params
|
39 |
+
* @return mixed
|
40 |
+
*/
|
41 |
+
public function call($params, $url)
|
42 |
+
{
|
43 |
+
try {
|
44 |
+
$http = new Varien_Http_Adapter_Curl();
|
45 |
+
$config = array('timeout' => 30);
|
46 |
+
$http->setConfig($config);
|
47 |
+
$http->write(Zend_Http_Client::POST, $url, '1.1', array(), http_build_query($params));
|
48 |
+
$response = $http->read();
|
49 |
+
$response = substr($response, strpos($response, "<?xml"), strlen($response));
|
50 |
+
|
51 |
+
return $response;
|
52 |
+
} catch (Exception $e) {
|
53 |
+
Mage::logException($e);
|
54 |
+
Mage::throwException(
|
55 |
+
Mage::helper('ops')->__('Acceptance server is temporarily not available, please try again later.')
|
56 |
+
);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Performs a POST request to the Direct Link Gateway with the given
|
62 |
+
* parameters and returns the result parameters as array
|
63 |
+
*
|
64 |
+
* @param array $params
|
65 |
+
* @return array
|
66 |
+
*/
|
67 |
+
public function performRequest($requestParams, $url, $storeId = 0)
|
68 |
+
{
|
69 |
+
$helper = Mage::helper('ops');
|
70 |
+
$params = $this->getEncodedParametersWithHash(
|
71 |
+
array_merge($requestParams,$this->buildAuthenticationParams($storeId)) //Merge Logic Operation Data with Authentication Data
|
72 |
+
, null, $storeId);
|
73 |
+
$responseParams = $this->getResponseParams($params, $url);
|
74 |
+
$helper->log($helper->__("Direct Link Request/Response in Acceptance \n\nRequest: %s\nResponse: %s\nMagento-URL: %s\nAPI-URL: %s",
|
75 |
+
serialize($params),
|
76 |
+
serialize($responseParams),
|
77 |
+
Mage::helper('core/url')->getCurrentUrl(),
|
78 |
+
$url
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->checkResponse($responseParams);
|
82 |
+
|
83 |
+
return $responseParams;
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getEncodedParametersWithHash($params, $shaCode=null, $storeId)
|
88 |
+
{
|
89 |
+
$hash = Mage::helper('ops/payment')->getSHASign($params, $shaCode, $storeId);
|
90 |
+
$params['SHASIGN'] = Mage::helper('ops/payment')->shaCrypt(iconv('iso-8859-1', 'utf-8', $hash));
|
91 |
+
|
92 |
+
return $params;
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
*
|
98 |
+
* wraps the request and response handling and repeats request/response
|
99 |
+
* if there are errors
|
100 |
+
*
|
101 |
+
* @param array $params - request params
|
102 |
+
* @param string $url - the url for the request
|
103 |
+
* @param int $retryCount - current request count
|
104 |
+
* @return array | null - null if requests were not successful, array containing Acceptance payment data otherwise
|
105 |
+
*
|
106 |
+
*/
|
107 |
+
protected function getResponseParams($params, $url, $retryCount = 0)
|
108 |
+
{
|
109 |
+
$responseParams = null;
|
110 |
+
$responseXml = null;
|
111 |
+
if ($retryCount < self::MAX_RETRY_COUNT) {
|
112 |
+
try {
|
113 |
+
$responseXml = $this->call($params, $url);
|
114 |
+
$responseParams = $this->getParamArrFromXmlString($responseXml);
|
115 |
+
} catch (Exception $e) {
|
116 |
+
try {
|
117 |
+
$responseParams = $this->getParamArrFromXmlString(utf8_encode($responseXml));
|
118 |
+
} catch (Exception $e) {
|
119 |
+
$ref = '';
|
120 |
+
if (array_key_exists('ORDERID', $params)) {
|
121 |
+
$ref = $params['ORDERID'];
|
122 |
+
} elseif (array_key_exists('PAYID', $params)) {
|
123 |
+
$ref = $params['PAYID'];
|
124 |
+
}
|
125 |
+
Mage::helper('ops')->log('DirectLink::getResponseParams failed: ' .
|
126 |
+
$e->getMessage() . ' current retry count: ' . $retryCount . ' for quote ' . $ref
|
127 |
+
);
|
128 |
+
$responseParams = $this->getResponseParams($params, $url, ++$retryCount);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
Mage::throwException(Mage::helper('ops')->__('An error occured during the Acceptance request. Your action could not be executed.'));
|
133 |
+
}
|
134 |
+
return $responseParams;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Return Authentication Params for OPS Call
|
139 |
+
*
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
protected function buildAuthenticationParams($storeId = 0)
|
143 |
+
{
|
144 |
+
return array(
|
145 |
+
'PSPID' => Mage::getModel('ops/config')->getPSPID($storeId),
|
146 |
+
'USERID' => Mage::getModel('ops/config')->getApiUserId($storeId),
|
147 |
+
'PSWD' => Mage::getModel('ops/config')->getApiPswd($storeId),
|
148 |
+
);
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Parses the XML-String to an array with the result data
|
153 |
+
*
|
154 |
+
* @param string xmlString
|
155 |
+
* @return array
|
156 |
+
*/
|
157 |
+
public function getParamArrFromXmlString($xmlString)
|
158 |
+
{
|
159 |
+
try {
|
160 |
+
$xml = new SimpleXMLElement($xmlString);
|
161 |
+
foreach ($xml->attributes() as $key => $value) {
|
162 |
+
$arrAttr[$key] = (string)$value;
|
163 |
+
}
|
164 |
+
foreach ($xml->children() as $child) {
|
165 |
+
$arrAttr[$child->getName()] = (string) $child;
|
166 |
+
}
|
167 |
+
return $arrAttr;
|
168 |
+
} catch (Exception $e) {
|
169 |
+
Mage::log('Could not convert string to xml in ' . __FILE__ . '::' . __METHOD__ . ': ' . $xmlString);
|
170 |
+
Mage::logException($e);
|
171 |
+
throw $e;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Check if the Response from OPS reports Errors
|
177 |
+
*
|
178 |
+
* @param array $responseParams
|
179 |
+
* @return mixed
|
180 |
+
*/
|
181 |
+
public function checkResponse($responseParams)
|
182 |
+
{
|
183 |
+
if (false === is_array($responseParams) || false === array_key_exists('NCERROR', $responseParams) || $responseParams['NCERROR'] > 0) {
|
184 |
+
if (empty($responseParams['NCERRORPLUS'])) {
|
185 |
+
$responseParams['NCERRORPLUS'] = Mage::helper('ops')->__('Invalid payment information')." Errorcode:".$responseParams['NCERROR'];
|
186 |
+
}
|
187 |
+
|
188 |
+
//avoid exception if STATUS is set with special values
|
189 |
+
if (isset($responseParams['STATUS']) && is_numeric($responseParams['STATUS'])) {
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
|
193 |
+
Mage::throwException(
|
194 |
+
Mage::helper('ops')->__("An error occured during the Acceptance request. Your action could not be executed. Message: '%s.'",$responseParams['NCERRORPLUS'])
|
195 |
+
);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Additional/OpenInvoiceNl.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Model_Backend_Operation_Capture_Additional_OpenInvoiceNl
|
10 |
+
extends Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_OpenInvoiceNlAbstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @see Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_OpenInvoiceNlAbstract
|
14 |
+
*/
|
15 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Capture/Parameter.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Model_Backend_Operation_Capture_Parameter
|
10 |
+
extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* checks whether we need to retrieve additional parameter for the capture request or not
|
14 |
+
*
|
15 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
16 |
+
*
|
17 |
+
* @return bool - true if we need to retrieve any additional parameters, false otherwise
|
18 |
+
*/
|
19 |
+
protected function isPmRequiringAdditionalParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
20 |
+
{
|
21 |
+
$opsPaymentMethodClass = get_class($opsPaymentMethod);
|
22 |
+
$opsPmsRequiringSpecialParams = $this->getOpsConfig()
|
23 |
+
->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE
|
24 |
+
);
|
25 |
+
|
26 |
+
return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* sets the model which retrieves the additional params
|
31 |
+
*
|
32 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
33 |
+
*/
|
34 |
+
protected function setAdditionalParamsModelFor(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
35 |
+
{
|
36 |
+
if ($opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_OpenInvoiceNl) {
|
37 |
+
$this->additionalParamsModel = Mage::getModel('ops/backend_operation_capture_additional_openInvoiceNl');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns the order helper for the corresponding transaction type
|
43 |
+
*
|
44 |
+
* @return Netresearch_OPS_Helper_Order_Abstract
|
45 |
+
*/
|
46 |
+
public function getOrderHelper()
|
47 |
+
{
|
48 |
+
return Mage::helper('ops/order_capture');
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Model_Backend_Operation_Parameter
|
10 |
+
{
|
11 |
+
protected $parameterModel = null;
|
12 |
+
|
13 |
+
protected $dataHelper = null;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* retrieves the neccessary parameter for the given operation
|
17 |
+
*
|
18 |
+
* @param $operation
|
19 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
20 |
+
* @param Varien_Object $payment
|
21 |
+
* @param $amount
|
22 |
+
* @param $arrInfo
|
23 |
+
*
|
24 |
+
* @return array
|
25 |
+
*/
|
26 |
+
public function getParameterFor(
|
27 |
+
$operation,
|
28 |
+
Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
29 |
+
Varien_Object $payment,
|
30 |
+
$amount
|
31 |
+
) {
|
32 |
+
return $this->getParameterModel($operation)->getRequestParams($opsPaymentMethod, $payment, $amount);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* retrieves the parameter model for the given operation
|
37 |
+
*
|
38 |
+
* @param $operation - the operation we need the parameters for
|
39 |
+
*
|
40 |
+
* @throws Mage_Core_Exception - in case the operation is not supported
|
41 |
+
* @return Netresearch_OPS_Model_Backend_Operation_Parameter_Interface - the model for the parameters of the
|
42 |
+
* operation
|
43 |
+
*/
|
44 |
+
protected function getParameterModel($operation)
|
45 |
+
{
|
46 |
+
if ($operation === Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE) {
|
47 |
+
return Mage::getModel('ops/backend_operation_capture_parameter');
|
48 |
+
}
|
49 |
+
if ($operation === Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE){
|
50 |
+
return Mage::getModel('ops/backend_operation_refund_parameter');
|
51 |
+
}
|
52 |
+
|
53 |
+
Mage::throwException($this->getDataHelper()->__('operation %s not supported', $operation));
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* retrieves the data helper
|
58 |
+
*
|
59 |
+
* @return Netresearch_OPS_Helper_Data|null
|
60 |
+
*/
|
61 |
+
protected function getDataHelper()
|
62 |
+
{
|
63 |
+
if (null == $this->dataHelper) {
|
64 |
+
$this->dataHelper = Mage::helper('ops/data');
|
65 |
+
}
|
66 |
+
|
67 |
+
return $this->dataHelper;
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Abstract.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
|
10 |
+
implements Netresearch_OPS_Model_Backend_Operation_Parameter_Interface
|
11 |
+
{
|
12 |
+
protected $requestParams = array();
|
13 |
+
|
14 |
+
protected $opsConfig = null;
|
15 |
+
protected $dataHelper = null;
|
16 |
+
|
17 |
+
protected $additionalParamsModel = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
21 |
+
* @param $payment
|
22 |
+
* @param $amount
|
23 |
+
*
|
24 |
+
* @return array
|
25 |
+
*/
|
26 |
+
public function getRequestParams(
|
27 |
+
Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
28 |
+
Varien_Object $payment,
|
29 |
+
$amount
|
30 |
+
) {
|
31 |
+
$this->getBaseParams($opsPaymentMethod, $payment, $amount );
|
32 |
+
$this->addPmSpecificParams($opsPaymentMethod, $payment, $amount);
|
33 |
+
|
34 |
+
return $this->requestParams;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* retrieves the basic parameters for a capture call
|
39 |
+
*
|
40 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
41 |
+
* @param Varien_Object $payment
|
42 |
+
* @param $amount
|
43 |
+
* @param $arrInfo
|
44 |
+
*
|
45 |
+
* @return $this
|
46 |
+
*/
|
47 |
+
protected function getBaseParams(
|
48 |
+
Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
49 |
+
Varien_Object $payment,
|
50 |
+
$amount
|
51 |
+
) {
|
52 |
+
$this->requestParams['AMOUNT'] = $this->getDataHelper()->getAmount($amount);
|
53 |
+
$this->requestParams['PAYID'] = $payment->getAdditionalInformation('paymentId');
|
54 |
+
$this->requestParams['OPERATION'] = $this->getOrderHelper()->determineOperationCode($payment, $amount);
|
55 |
+
$this->requestParams['CURRENCY'] = Mage::app()->getStore($payment->getOrder()->getStoreId())
|
56 |
+
->getBaseCurrencyCode();
|
57 |
+
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* retrieves ops config model
|
63 |
+
*
|
64 |
+
* @return Netresearch_OPS_Model_Config
|
65 |
+
*/
|
66 |
+
protected function getOpsConfig()
|
67 |
+
{
|
68 |
+
if (null === $this->opsConfig) {
|
69 |
+
$this->opsConfig = Mage::getModel('ops/config');
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->opsConfig;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* if we have to add payment specific paramters to our request, we'll set them here
|
77 |
+
*
|
78 |
+
* @param $opsPaymentMethod
|
79 |
+
* @param $payment
|
80 |
+
* @param $amount
|
81 |
+
*
|
82 |
+
* @return $this
|
83 |
+
*/
|
84 |
+
protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
85 |
+
Varien_Object $payment, $amount
|
86 |
+
) {
|
87 |
+
if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
|
88 |
+
$this->setAdditionalParamsModelFor($opsPaymentMethod);
|
89 |
+
if ($this->additionalParamsModel instanceof
|
90 |
+
Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
|
91 |
+
) {
|
92 |
+
$params = $this->additionalParamsModel->extractAdditionalParams($payment->getInvoice());
|
93 |
+
$this->requestParams = array_merge($this->requestParams, $params);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $this;
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function isPmRequiringAdditionalParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
101 |
+
{
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function setAdditionalParamsModelFor(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
106 |
+
{
|
107 |
+
$this->additionalParamsModel = null;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* retrieves the data helper
|
112 |
+
*
|
113 |
+
* @return Netresearch_OPS_Helper_Data|null
|
114 |
+
*/
|
115 |
+
protected function getDataHelper()
|
116 |
+
{
|
117 |
+
if (null == $this->dataHelper) {
|
118 |
+
$this->dataHelper = Mage::helper('ops/data');
|
119 |
+
}
|
120 |
+
|
121 |
+
return $this->dataHelper;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Returns the order helper for the corresponding transaction type
|
126 |
+
*
|
127 |
+
* @return Netresearch_OPS_Helper_Order_Abstract
|
128 |
+
*/
|
129 |
+
public abstract function getOrderHelper();
|
130 |
+
|
131 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Additional/Interface.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
interface Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
|
9 |
+
{
|
10 |
+
public function extractAdditionalParams(Mage_Sales_Model_Abstract $itemContainer);
|
11 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Additional/OpenInvoiceNlAbstract.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
abstract class Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_OpenInvoiceNlAbstract
|
11 |
+
implements Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
|
12 |
+
{
|
13 |
+
protected $additionalParams = array();
|
14 |
+
protected $opsDataHelper = null;
|
15 |
+
protected $itemIdx = 1;
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param Mage_Sales_Model_Abstract $itemContainer
|
20 |
+
*
|
21 |
+
* @return array
|
22 |
+
*/
|
23 |
+
public function extractAdditionalParams(Mage_Sales_Model_Abstract $itemContainer)
|
24 |
+
{
|
25 |
+
if ($itemContainer instanceof Mage_Sales_Model_Order_Invoice) {
|
26 |
+
$this->extractFromInvoiceItems($itemContainer);
|
27 |
+
$this->extractFromDiscountData($itemContainer);
|
28 |
+
$this->extractFromInvoicedShippingMethod($itemContainer);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->additionalParams;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* extracts all necessary data from the invoice items
|
36 |
+
*
|
37 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
38 |
+
*/
|
39 |
+
protected function extractFromInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
|
40 |
+
{
|
41 |
+
foreach ($invoice->getItemsCollection() as $item) {
|
42 |
+
/** @var $item Mage_Sales_Model_Order_Invoice_Item */
|
43 |
+
// filter out configurable products
|
44 |
+
if ($item->getParentItemId()
|
45 |
+
&& $item->getParentItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
|
46 |
+
|| $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = substr($item->getOrderItemId(), 0, 15);
|
50 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] = substr($item->getName(), 0, 30);
|
51 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount(
|
52 |
+
$item->getBasePriceInclTax()
|
53 |
+
);
|
54 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = $item->getQty();
|
55 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx]
|
56 |
+
=
|
57 |
+
str_replace(',', '.', (string)(float)$item->getTaxPercent()) . '%';
|
58 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
59 |
+
++$this->itemIdx;
|
60 |
+
}
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* extract the necessary data from the shipping data of the invoice
|
67 |
+
*
|
68 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
69 |
+
*
|
70 |
+
* @return $this
|
71 |
+
*/
|
72 |
+
protected function extractFromInvoicedShippingMethod(Mage_Sales_Model_Order_Invoice $invoice)
|
73 |
+
{
|
74 |
+
$amount = $invoice->getBaseShippingInclTax();
|
75 |
+
if (0 < $amount) {
|
76 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = 'SHIPPING';
|
77 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] =
|
78 |
+
substr($invoice->getOrder()->getShippingDescription(), 0, 30);
|
79 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($amount);
|
80 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1;
|
81 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%';
|
82 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
83 |
+
++$this->itemIdx;
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* retrieves used shipping tax rate
|
92 |
+
*
|
93 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
94 |
+
*
|
95 |
+
* @return float
|
96 |
+
*/
|
97 |
+
protected function getShippingTaxRate(Mage_Sales_Model_Order_Invoice $invoice)
|
98 |
+
{
|
99 |
+
$taxRate = 0.0;
|
100 |
+
$order = $invoice->getOrder();
|
101 |
+
|
102 |
+
$taxRate = (floatval(Mage::helper('ops/payment_request')->getShippingTaxRate($order)));
|
103 |
+
|
104 |
+
return $taxRate;
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* gets the ops data helper
|
110 |
+
*
|
111 |
+
* @return Netresearch_OPS_Helper_Data
|
112 |
+
*/
|
113 |
+
protected function getOpsDataHelper()
|
114 |
+
{
|
115 |
+
if (null === $this->opsDataHelper) {
|
116 |
+
$this->opsDataHelper = Mage::helper('ops/data');
|
117 |
+
}
|
118 |
+
|
119 |
+
return $this->opsDataHelper;
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @param $itemContainer
|
125 |
+
*/
|
126 |
+
protected function extractFromDiscountData($invoice)
|
127 |
+
{
|
128 |
+
$amount = $invoice->getBaseDiscountAmount();
|
129 |
+
if (0 > $amount) {
|
130 |
+
$couponRuleName = 'DISCOUNT';
|
131 |
+
$order = $invoice->getOrder();
|
132 |
+
if ($order->getCouponRuleName() && strlen(trim($order->getCouponRuleName())) > 0) {
|
133 |
+
$couponRuleName = substr(trim($order->getCouponRuleName()), 0, 30);
|
134 |
+
}
|
135 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = 'DISCOUNT';
|
136 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] = $couponRuleName;
|
137 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($amount);
|
138 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1;
|
139 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%';
|
140 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
141 |
+
++$this->itemIdx;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Parameter/Interface.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
interface Netresearch_OPS_Model_Backend_Operation_Parameter_Interface
|
10 |
+
{
|
11 |
+
public function getRequestParams(
|
12 |
+
Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
13 |
+
Varien_Object $payment,
|
14 |
+
$amount
|
15 |
+
);
|
16 |
+
|
17 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Additional/OpenInvoiceNl.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Backend_Operation_Refund_Additional_OpenInvoiceNl
|
11 |
+
extends Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_OpenInvoiceNlAbstract
|
12 |
+
{
|
13 |
+
protected $creditmemo = array();
|
14 |
+
protected $amount = 0;
|
15 |
+
protected $refundHelper = null;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param Mage_Sales_Model_Abstract $itemContainer
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function extractAdditionalParams(Mage_Sales_Model_Abstract $itemContainer = null)
|
22 |
+
{
|
23 |
+
$invoice = null;
|
24 |
+
if ($itemContainer instanceof Mage_Sales_Model_Order_Invoice && $itemContainer) {
|
25 |
+
$invoice = $itemContainer;
|
26 |
+
} else if ($itemContainer instanceof Mage_Sales_Block_Order_Creditmemo && $itemContainer){
|
27 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($itemContainer->getInvoiceId());
|
28 |
+
}
|
29 |
+
|
30 |
+
if($invoice == null){
|
31 |
+
// if invoice is not set we load id hard from the request params
|
32 |
+
$invoice = $this->getRefundHelper()->getInvoiceFromCreditMemoRequest();
|
33 |
+
}
|
34 |
+
$this->creditmemo = $this->getRefundHelper()->getCreditMemoFromRequest();
|
35 |
+
|
36 |
+
if ($invoice instanceof Mage_Sales_Model_Order_Invoice) {
|
37 |
+
$this->extractFromCreditMemoItems($invoice);
|
38 |
+
// We dont extract from discount data for the moment, because partial refunds are a problem
|
39 |
+
// $this->extractFromDiscountData($invoice);
|
40 |
+
$this->extractFromInvoicedShippingMethod($invoice);
|
41 |
+
$this->extractFromAdjustments($invoice);
|
42 |
+
// Overwrite amount to fix Magentos rounding problems (eg +1ct)
|
43 |
+
$this->additionalParams['AMOUNT'] = $this->amount;
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this->additionalParams;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* extracts all data from the invoice according to the credit memo items
|
51 |
+
*
|
52 |
+
* @param $itemContainer
|
53 |
+
*/
|
54 |
+
protected function extractFromCreditMemoItems(Mage_Sales_Model_Order_Invoice $invoice)
|
55 |
+
{
|
56 |
+
foreach ($invoice->getItemsCollection() as $item) {
|
57 |
+
if (array_key_exists($item->getOrderItemId(), $this->creditmemo['items'])) {
|
58 |
+
if ($item->getParentItemId()
|
59 |
+
&& $item->getParentItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
|
60 |
+
|| $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
61 |
+
continue;
|
62 |
+
}
|
63 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = substr($item->getOrderItemId(), 0, 15);
|
64 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] = substr($item->getName(), 0, 30);
|
65 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount(
|
66 |
+
$item->getBasePriceInclTax()
|
67 |
+
);
|
68 |
+
$this->amount += $this->getOpsDataHelper()->getAmount($item->getBasePriceInclTax()) * $this->creditmemo['items'][$item->getOrderItemId()]['qty'];
|
69 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = $this->creditmemo['items'][$item->getOrderItemId()]['qty'];
|
70 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx]
|
71 |
+
=
|
72 |
+
str_replace(',', '.', (string)(float)$item->getTaxPercent()) . '%';
|
73 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
74 |
+
++$this->itemIdx;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
protected function extractFromInvoicedShippingMethod(Mage_Sales_Model_Order_Invoice $invoice)
|
82 |
+
{
|
83 |
+
if ($this->creditmemo['shipping_amount'] > 0) {
|
84 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = 'SHIPPING';
|
85 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] =
|
86 |
+
substr($invoice->getOrder()->getShippingDescription(), 0, 30);
|
87 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($this->creditmemo['shipping_amount']);
|
88 |
+
$this->amount += $this->getOpsDataHelper()->getAmount($this->creditmemo['shipping_amount']);
|
89 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1;
|
90 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%';
|
91 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
92 |
+
++$this->itemIdx;
|
93 |
+
}
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* extracts all data from the adjustment fee/refund
|
99 |
+
*
|
100 |
+
* @param $invoice
|
101 |
+
*/
|
102 |
+
protected function extractFromAdjustments(Mage_Sales_Model_Order_Invoice $invoice)
|
103 |
+
{
|
104 |
+
|
105 |
+
if ($this->creditmemo['adjustment_positive'] > 0) {
|
106 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = 'ADJUSTREFUND';
|
107 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] = 'Adjustment Refund';
|
108 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount($this->creditmemo['adjustment_positive']);
|
109 |
+
$this->amount += $this->getOpsDataHelper()->getAmount($this->creditmemo['adjustment_positive']);
|
110 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1;
|
111 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%';
|
112 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
113 |
+
++$this->itemIdx;
|
114 |
+
|
115 |
+
}
|
116 |
+
if ($this->creditmemo['adjustment_negative'] > 0) {
|
117 |
+
$this->additionalParams['ITEMID' . $this->itemIdx] = 'ADJUSTFEE';
|
118 |
+
$this->additionalParams['ITEMNAME' . $this->itemIdx] = 'Adjustment Fee';
|
119 |
+
$this->additionalParams['ITEMPRICE' . $this->itemIdx] = $this->getOpsDataHelper()->getAmount(-$this->creditmemo['adjustment_negative']);
|
120 |
+
$this->amount += $this->getOpsDataHelper()->getAmount(-$this->creditmemo['adjustment_negative']);
|
121 |
+
$this->additionalParams['ITEMQUANT' . $this->itemIdx] = 1;
|
122 |
+
$this->additionalParams['ITEMVATCODE' . $this->itemIdx] = $this->getShippingTaxRate($invoice) . '%';
|
123 |
+
$this->additionalParams['TAXINCLUDED' . $this->itemIdx] = 1;
|
124 |
+
++$this->itemIdx;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* gets the refund helper
|
130 |
+
*
|
131 |
+
* @return Netresearch_OPS_Helper_Order_Refund|null
|
132 |
+
*/
|
133 |
+
protected function getRefundHelper()
|
134 |
+
{
|
135 |
+
if (null === $this->refundHelper) {
|
136 |
+
$this->refundHelper = Mage::helper('ops/order_refund');
|
137 |
+
}
|
138 |
+
|
139 |
+
return $this->refundHelper;
|
140 |
+
}
|
141 |
+
}
|
app/code/community/Netresearch/OPS/Model/Backend/Operation/Refund/Parameter.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Model_Backend_Operation_Refund_Parameter
|
10 |
+
extends Netresearch_OPS_Model_Backend_Operation_Parameter_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* checks whether we need to retrieve additional parameter for the refund request or not
|
14 |
+
*
|
15 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
16 |
+
*
|
17 |
+
* @return bool - true if we need to retrieve any additional parameters, false otherwise
|
18 |
+
*/
|
19 |
+
protected function isPmRequiringAdditionalParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
20 |
+
{
|
21 |
+
$opsPaymentMethodClass = get_class($opsPaymentMethod);
|
22 |
+
$opsPmsRequiringSpecialParams = $this->getOpsConfig()
|
23 |
+
->getMethodsRequiringAdditionalParametersFor(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE
|
24 |
+
);
|
25 |
+
|
26 |
+
return (in_array($opsPaymentMethodClass, array_values($opsPmsRequiringSpecialParams)));
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* sets the model which retrieves the additional params for the refund request
|
31 |
+
*
|
32 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
33 |
+
*/
|
34 |
+
protected function setAdditionalParamsModelFor(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod)
|
35 |
+
{
|
36 |
+
if ($opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_OpenInvoiceNl) {
|
37 |
+
$this->additionalParamsModel = Mage::getModel('ops/backend_operation_refund_additional_openInvoiceNl');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function addPmSpecificParams(Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
42 |
+
Varien_Object $payment, $amount
|
43 |
+
) {
|
44 |
+
if ($this->isPmRequiringAdditionalParams($opsPaymentMethod)) {
|
45 |
+
$this->setAdditionalParamsModelFor($opsPaymentMethod);
|
46 |
+
if ($this->additionalParamsModel instanceof
|
47 |
+
Netresearch_OPS_Model_Backend_Operation_Parameter_Additional_Interface
|
48 |
+
) {
|
49 |
+
$params = $this->additionalParamsModel->extractAdditionalParams(Mage::registry('current_creditmemo'));
|
50 |
+
$this->requestParams = array_merge($this->requestParams, $params);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Returns the order helper for the corresponding transaction type
|
59 |
+
*
|
60 |
+
* @return Netresearch_OPS_Helper_Order_Abstract
|
61 |
+
*/
|
62 |
+
public function getOrderHelper()
|
63 |
+
{
|
64 |
+
return Mage::helper('ops/order_refund');
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
}
|
app/code/community/Netresearch/OPS/Model/Config.php
ADDED
@@ -0,0 +1,841 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Config model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Config extends Mage_Payment_Model_Config
|
31 |
+
{
|
32 |
+
const OPS_PAYMENT_PATH = 'payment_services/ops/';
|
33 |
+
const OPS_CONTROLLER_ROUTE_API = 'ops/api/';
|
34 |
+
const OPS_CONTROLLER_ROUTE_PAYMENT = 'ops/payment/';
|
35 |
+
const OPS_CONTROLLER_ROUTE_ALIAS = 'ops/alias/';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Return ops payment config information
|
39 |
+
*
|
40 |
+
* @param string $path
|
41 |
+
* @param int $storeId
|
42 |
+
*
|
43 |
+
* @return Simple_Xml
|
44 |
+
*/
|
45 |
+
public function getConfigData($path, $storeId = null)
|
46 |
+
{
|
47 |
+
if (!empty($path)) {
|
48 |
+
return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . $path, $storeId);
|
49 |
+
}
|
50 |
+
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Return SHA1-in crypt key from config. Setup on admin place.
|
56 |
+
*
|
57 |
+
* @param int $storeId
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function getShaInCode($storeId = null)
|
62 |
+
{
|
63 |
+
return Mage::helper('core')->decrypt($this->getConfigData('secret_key_in', $storeId));
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Return SHA1-out crypt key from config. Setup on admin place.
|
68 |
+
*
|
69 |
+
* @param int $storeId
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getShaOutCode($storeId = null)
|
74 |
+
{
|
75 |
+
return Mage::helper('core')->decrypt($this->getConfigData('secret_key_out', $storeId));
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return frontend gateway path, get from config. Setup on admin place.
|
80 |
+
*
|
81 |
+
* @param int $storeId
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getFrontendGatewayPath($storeId = null)
|
86 |
+
{
|
87 |
+
return $this->determineOpsUrl('frontend_gateway', $storeId);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Return Direct Link Gateway path, get from config. Setup on admin place.
|
92 |
+
*
|
93 |
+
* @param int $storeId
|
94 |
+
*
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function getDirectLinkGatewayPath($storeId = null)
|
98 |
+
{
|
99 |
+
return $this->determineOpsUrl('directlink_gateway', $storeId);
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getDirectLinkGatewayOrderPath($storeId = null)
|
103 |
+
{
|
104 |
+
return $this->determineOpsUrl('directlink_gateway_order', $storeId);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Return API User, get from config. Setup on admin place.
|
109 |
+
*
|
110 |
+
* @param int $storeId
|
111 |
+
*
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function getApiUserId($storeId = null)
|
115 |
+
{
|
116 |
+
return $this->getConfigData('api_userid', $storeId);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Return API Passwd, get from config. Setup on admin place.
|
121 |
+
*
|
122 |
+
* @param int $storeId
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
public function getApiPswd($storeId = null)
|
127 |
+
{
|
128 |
+
return Mage::helper('core')->decrypt($this->getConfigData('api_pswd', $storeId));
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get PSPID, affiliation name in ops system
|
133 |
+
*
|
134 |
+
* @param int $storeId
|
135 |
+
*
|
136 |
+
* @return string
|
137 |
+
*/
|
138 |
+
public function getPSPID($storeId = null)
|
139 |
+
{
|
140 |
+
return $this->getConfigData('pspid', $storeId);
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getPaymentAction($storeId = null)
|
144 |
+
{
|
145 |
+
return $this->getConfigData('payment_action', $storeId);
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get paypage template for magento style templates using
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
public function getPayPageTemplate()
|
154 |
+
{
|
155 |
+
return Mage::getUrl(
|
156 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'paypage',
|
157 |
+
array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
|
158 |
+
);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Return url which ops system will use as accept
|
163 |
+
*
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
public function getAcceptUrl()
|
167 |
+
{
|
168 |
+
return Mage::getUrl(
|
169 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'accept',
|
170 |
+
array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Return url which ops system will use as accept for alias generation
|
176 |
+
*
|
177 |
+
* @param int $storeId
|
178 |
+
* @param bool $admin
|
179 |
+
*
|
180 |
+
* @return string
|
181 |
+
*/
|
182 |
+
public function getAliasAcceptUrl($storeId = null, $admin = false)
|
183 |
+
{
|
184 |
+
$params = array(
|
185 |
+
'_secure' => $this->isCurrentlySecure(),
|
186 |
+
'_nosid' => true
|
187 |
+
);
|
188 |
+
if (false === is_null($storeId)) {
|
189 |
+
$params['_store'] = $storeId;
|
190 |
+
}
|
191 |
+
|
192 |
+
if ($admin) {
|
193 |
+
$params['_nosecret'] = true;
|
194 |
+
|
195 |
+
return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/accept', $params);
|
196 |
+
} else {
|
197 |
+
return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'accept', $params);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Return url which ops system will use as decline url
|
203 |
+
*
|
204 |
+
* @return string
|
205 |
+
*/
|
206 |
+
public function getDeclineUrl()
|
207 |
+
{
|
208 |
+
return Mage::getUrl(
|
209 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'decline',
|
210 |
+
array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
|
211 |
+
);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Return url which ops system will use as exception url
|
216 |
+
*
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public function getExceptionUrl()
|
220 |
+
{
|
221 |
+
return Mage::getUrl(
|
222 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'exception',
|
223 |
+
array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
|
224 |
+
);
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Return url which ops system will use as exception url for alias generation
|
229 |
+
*
|
230 |
+
* @param int $storeId
|
231 |
+
* @param bool $admin
|
232 |
+
*
|
233 |
+
* @return string
|
234 |
+
*/
|
235 |
+
public function getAliasExceptionUrl($storeId = null, $admin = false)
|
236 |
+
{
|
237 |
+
$params = array(
|
238 |
+
'_secure' => $this->isCurrentlySecure(),
|
239 |
+
'_nosid' => true
|
240 |
+
);
|
241 |
+
if (false === is_null($storeId)) {
|
242 |
+
$params['_store'] = $storeId;
|
243 |
+
}
|
244 |
+
if ($admin) {
|
245 |
+
$params['_nosecret'] = true;
|
246 |
+
|
247 |
+
return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/exception', $params);
|
248 |
+
} else {
|
249 |
+
return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'exception', $params);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Return url which ops system will use as cancel url
|
255 |
+
*
|
256 |
+
* @return string
|
257 |
+
*/
|
258 |
+
public function getCancelUrl()
|
259 |
+
{
|
260 |
+
return Mage::getUrl(
|
261 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'cancel',
|
262 |
+
array('_nosid' => true, '_secure' => $this->isCurrentlySecure())
|
263 |
+
);
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Return url which ops system will use as continue shopping url
|
268 |
+
*
|
269 |
+
* @param array $redirect
|
270 |
+
*
|
271 |
+
* @return string
|
272 |
+
*/
|
273 |
+
public function getContinueUrl($redirect = array())
|
274 |
+
{
|
275 |
+
$urlParams = array('_nosid' => true, '_secure' => $this->isCurrentlySecure());
|
276 |
+
if (!empty($redirect)) {
|
277 |
+
$urlParams = array_merge($redirect, $urlParams);
|
278 |
+
}
|
279 |
+
|
280 |
+
return Mage::getUrl(self::OPS_CONTROLLER_ROUTE_PAYMENT . 'continue', $urlParams);
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Return url to redirect after confirming the order
|
285 |
+
*
|
286 |
+
* @return string
|
287 |
+
*/
|
288 |
+
public function getPaymentRedirectUrl()
|
289 |
+
{
|
290 |
+
return Mage::getUrl(
|
291 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform',
|
292 |
+
array('_secure' => true, '_nosid' => true)
|
293 |
+
);
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Return 3D Secure url to redirect after confirming the order
|
298 |
+
*
|
299 |
+
* @return string
|
300 |
+
*/
|
301 |
+
public function get3dSecureRedirectUrl()
|
302 |
+
{
|
303 |
+
return Mage::getUrl(
|
304 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'placeform3dsecure',
|
305 |
+
array('_secure' => true, '_nosid' => true)
|
306 |
+
);
|
307 |
+
}
|
308 |
+
|
309 |
+
public function getSaveCcBrandUrl()
|
310 |
+
{
|
311 |
+
return Mage::getUrl(
|
312 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'saveCcBrand',
|
313 |
+
array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
|
314 |
+
);
|
315 |
+
}
|
316 |
+
|
317 |
+
public function getGenerateHashUrl($storeId = null, $admin = false)
|
318 |
+
{
|
319 |
+
$params = array(
|
320 |
+
'_secure' => $this->isCurrentlySecure(),
|
321 |
+
'_nosid' => true,
|
322 |
+
);
|
323 |
+
if (false === is_null($storeId)) {
|
324 |
+
$params['_store'] = $storeId;
|
325 |
+
}
|
326 |
+
if ($admin) {
|
327 |
+
$params['_nosecret'] = true;
|
328 |
+
|
329 |
+
return Mage::getModel('adminhtml/url')->getUrl('adminhtml/alias/generatehash', $params);
|
330 |
+
} else {
|
331 |
+
return Mage::getModel('core/url')->getUrl(self::OPS_CONTROLLER_ROUTE_ALIAS . 'generatehash', $params);
|
332 |
+
}
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
public function getRegisterDirectDebitPaymentUrl()
|
337 |
+
{
|
338 |
+
return Mage::getUrl(
|
339 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'registerDirectDebitPayment',
|
340 |
+
array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
|
341 |
+
);
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Checks if requests should be logged or not regarding configuration
|
346 |
+
*
|
347 |
+
* @return boolean
|
348 |
+
*/
|
349 |
+
public function shouldLogRequests($storeId = null)
|
350 |
+
{
|
351 |
+
return $this->getConfigData('debug_flag', $storeId);
|
352 |
+
}
|
353 |
+
|
354 |
+
public function hasCatalogUrl()
|
355 |
+
{
|
356 |
+
return Mage::getStoreConfig('payment_services/ops/showcatalogbutton');
|
357 |
+
}
|
358 |
+
|
359 |
+
public function hasHomeUrl()
|
360 |
+
{
|
361 |
+
return Mage::getStoreConfig('payment_services/ops/showhomebutton');
|
362 |
+
}
|
363 |
+
|
364 |
+
public function getAcceptedCcTypes($code)
|
365 |
+
{
|
366 |
+
return Mage::getStoreConfig('payment/' . $code . '/types');
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Returns the cc types for which inline payments are activated
|
371 |
+
*
|
372 |
+
* @param string $code
|
373 |
+
*
|
374 |
+
* @return string[]
|
375 |
+
*/
|
376 |
+
public function getInlinePaymentCcTypes($code)
|
377 |
+
{
|
378 |
+
$redirectAll = (bool)(int)Mage::getStoreConfig('payment/' . $code . '/redirect_all');
|
379 |
+
if ($redirectAll) {
|
380 |
+
return array();
|
381 |
+
}
|
382 |
+
|
383 |
+
$inlineTypes = Mage::getStoreConfig('payment/' . $code . '/inline_types');
|
384 |
+
if (false == is_array($inlineTypes)) {
|
385 |
+
$inlineTypes = explode(',', $inlineTypes);
|
386 |
+
}
|
387 |
+
|
388 |
+
return $inlineTypes;
|
389 |
+
}
|
390 |
+
|
391 |
+
public function get3dSecureIsActive()
|
392 |
+
{
|
393 |
+
return Mage::getStoreConfig('payment/ops_cc/enabled_3dsecure');
|
394 |
+
}
|
395 |
+
|
396 |
+
public function getDirectDebitCountryIds()
|
397 |
+
{
|
398 |
+
return Mage::getStoreConfig('payment/ops_directDebit/countryIds');
|
399 |
+
}
|
400 |
+
|
401 |
+
public function getBankTransferCountryIds()
|
402 |
+
{
|
403 |
+
return Mage::getStoreConfig('payment/ops_bankTransfer/countryIds');
|
404 |
+
}
|
405 |
+
|
406 |
+
public function getDirectEbankingBrands()
|
407 |
+
{
|
408 |
+
return Mage::getStoreConfig('payment/ops_directEbanking/brands');
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Returns the generated alias (hosted tokenization) url or the special url if needed by vendor
|
413 |
+
*
|
414 |
+
* @param null $storeId
|
415 |
+
*
|
416 |
+
* @return mixed|Simple_Xml|string
|
417 |
+
*/
|
418 |
+
public function getAliasGatewayUrl($storeId = null)
|
419 |
+
{
|
420 |
+
$url = $this->determineOpsUrl('ops_alias_gateway', $storeId);
|
421 |
+
|
422 |
+
if ($this->getConfigData('ops_alias_gateway_test') != '') {
|
423 |
+
if ($this->getMode($storeId) == Netresearch_OPS_Model_Source_Mode::TEST) {
|
424 |
+
return $this->getConfigData('ops_alias_gateway_test');
|
425 |
+
} elseif ($this->getMode($storeId) == Netresearch_OPS_Model_Source_Mode::PROD) {
|
426 |
+
$url = str_replace('ncol/prod/', '', $url);
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
return $url;
|
431 |
+
}
|
432 |
+
|
433 |
+
public function getCcSaveAliasUrl($storeId = null, $admin = false)
|
434 |
+
{
|
435 |
+
$params = array(
|
436 |
+
'_secure' => $this->isCurrentlySecure()
|
437 |
+
);
|
438 |
+
if (false === is_null($storeId)) {
|
439 |
+
$params['_store'] = $storeId;
|
440 |
+
}
|
441 |
+
if ($admin) {
|
442 |
+
return Mage::getModel('adminhtml/url')->getUrl('ops/admin/saveAlias', $params);
|
443 |
+
} else {
|
444 |
+
return Mage::getUrl('ops/alias/save', $params);
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* get deeplink to transaction view at Acceptance
|
450 |
+
*
|
451 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
452 |
+
*
|
453 |
+
* @return string
|
454 |
+
*/
|
455 |
+
public function getOpsAdminPaymentUrl($payment)
|
456 |
+
{
|
457 |
+
return '';
|
458 |
+
}
|
459 |
+
|
460 |
+
public function isCurrentlySecure()
|
461 |
+
{
|
462 |
+
return Mage::app()->getStore()->isCurrentlySecure();
|
463 |
+
}
|
464 |
+
|
465 |
+
public function getIntersolveBrands($storeId = null)
|
466 |
+
{
|
467 |
+
$result = array();
|
468 |
+
$brands = Mage::getStoreConfig('payment/ops_interSolve/brands', $storeId);
|
469 |
+
if (!is_null($brands)) {
|
470 |
+
$result = unserialize($brands);
|
471 |
+
}
|
472 |
+
|
473 |
+
return $result;
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* @param int $storeId
|
478 |
+
*
|
479 |
+
* @return string[][]
|
480 |
+
*/
|
481 |
+
public function getFlexMethods($storeId = null)
|
482 |
+
{
|
483 |
+
$result = array();
|
484 |
+
$methods = Mage::getStoreConfig('payment/ops_flex/methods', $storeId);
|
485 |
+
if (!is_null($methods)) {
|
486 |
+
$result = unserialize($methods);
|
487 |
+
}
|
488 |
+
|
489 |
+
return $result;
|
490 |
+
}
|
491 |
+
|
492 |
+
public function getAllCcTypes()
|
493 |
+
{
|
494 |
+
return explode(',', Mage::getStoreConfig('payment/ops_cc/availableTypes'));
|
495 |
+
}
|
496 |
+
|
497 |
+
|
498 |
+
public function getAllDcTypes()
|
499 |
+
{
|
500 |
+
return explode(',', Mage::getStoreConfig('payment/ops_dc/availableTypes'));
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* get keys of parameters to be shown in scoring information block
|
505 |
+
*
|
506 |
+
* @return array
|
507 |
+
*/
|
508 |
+
public function getAdditionalScoringKeys()
|
509 |
+
{
|
510 |
+
return array(
|
511 |
+
'AAVCHECK',
|
512 |
+
'CVCCHECK',
|
513 |
+
'CCCTY',
|
514 |
+
'IPCTY',
|
515 |
+
'NBREMAILUSAGE',
|
516 |
+
'NBRIPUSAGE',
|
517 |
+
'NBRIPUSAGE_ALLTX',
|
518 |
+
'NBRUSAGE',
|
519 |
+
'VC',
|
520 |
+
'CARDNO',
|
521 |
+
'ED',
|
522 |
+
'CN'
|
523 |
+
);
|
524 |
+
}
|
525 |
+
|
526 |
+
public function getSendInvoice()
|
527 |
+
{
|
528 |
+
return (bool)(int)Mage::getStoreConfig('payment_services/ops/send_invoice');
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* if payment method with given code is enabled for backend payments
|
533 |
+
*
|
534 |
+
* @param string $code Payment method code
|
535 |
+
*
|
536 |
+
* @return bool
|
537 |
+
*/
|
538 |
+
public function isEnabledForBackend($code, $storeId = 0)
|
539 |
+
{
|
540 |
+
return (bool)(int)Mage::getStoreConfig('payment/' . $code . '/backend_enabled', $storeId);
|
541 |
+
}
|
542 |
+
|
543 |
+
public function isAliasInfoBlockEnabled()
|
544 |
+
{
|
545 |
+
return (bool)(int)Mage::getStoreConfig('payment/ops_cc/show_alias_manager_info_for_guests');
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* return config value for Alias Manager enabled
|
550 |
+
*
|
551 |
+
* @param $code
|
552 |
+
* @param $storeId
|
553 |
+
*
|
554 |
+
* @return bool
|
555 |
+
*/
|
556 |
+
public function isAliasManagerEnabled($code, $storeId = null)
|
557 |
+
{
|
558 |
+
return (bool)Mage::getStoreConfig('payment/' . $code . '/active_alias', $storeId);
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* getter for usage of order reference
|
563 |
+
*/
|
564 |
+
public function getOrderReference($storeId = null)
|
565 |
+
{
|
566 |
+
return $this->getConfigData('redirectOrderReference', $storeId);
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* @param int $storeId - the store id to use
|
571 |
+
*
|
572 |
+
* @return int whether the QuoteId should be shown in
|
573 |
+
* the order grid (1) or not (0)
|
574 |
+
*/
|
575 |
+
public function getShowQuoteIdInOrderGrid($storeId = null)
|
576 |
+
{
|
577 |
+
return $this->getConfigData('showQuoteIdInOrderGrid', $storeId);
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Check if the current environment is frontend or backend
|
582 |
+
*
|
583 |
+
* @return boolean
|
584 |
+
*/
|
585 |
+
public function isFrontendEnvironment()
|
586 |
+
{
|
587 |
+
return (false === Mage::app()->getStore()->isAdmin());
|
588 |
+
}
|
589 |
+
|
590 |
+
/**
|
591 |
+
* getter for the accept route for payments
|
592 |
+
*
|
593 |
+
* @return string
|
594 |
+
*/
|
595 |
+
public function getAcceptRedirectRoute()
|
596 |
+
{
|
597 |
+
return self::OPS_CONTROLLER_ROUTE_PAYMENT . 'accept';
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
* getter for the cancel route for payments
|
602 |
+
*
|
603 |
+
* @return string
|
604 |
+
*/
|
605 |
+
public function getCancelRedirectRoute()
|
606 |
+
{
|
607 |
+
return self::OPS_CONTROLLER_ROUTE_PAYMENT . 'cancel';
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* getter for the decline route for payments
|
612 |
+
*
|
613 |
+
* @return string
|
614 |
+
*/
|
615 |
+
public function getDeclineRedirectRoute()
|
616 |
+
{
|
617 |
+
return self::OPS_CONTROLLER_ROUTE_PAYMENT . 'decline';
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* getter for the decline route for payments
|
622 |
+
*
|
623 |
+
* @return string
|
624 |
+
*/
|
625 |
+
public function getExceptionRedirectRoute()
|
626 |
+
{
|
627 |
+
return self::OPS_CONTROLLER_ROUTE_PAYMENT . 'exception';
|
628 |
+
}
|
629 |
+
|
630 |
+
|
631 |
+
public function getMethodsRequiringAdditionalParametersFor($operation)
|
632 |
+
{
|
633 |
+
return Mage::getStoreConfig('payment/additional_params_required/' . $operation);
|
634 |
+
}
|
635 |
+
|
636 |
+
|
637 |
+
/**
|
638 |
+
* returns the url for the maintenance api calls
|
639 |
+
*
|
640 |
+
* @param null $storeId
|
641 |
+
*
|
642 |
+
* @return string - the url for the maintenance api calls
|
643 |
+
*/
|
644 |
+
public function getDirectLinkMaintenanceApiPath($storeId = null)
|
645 |
+
{
|
646 |
+
return $this->determineOpsUrl('directlink_maintenance_api', $storeId);
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* getter for the iDeal issuers
|
651 |
+
*
|
652 |
+
* @return array
|
653 |
+
*/
|
654 |
+
public function getIDealIssuers()
|
655 |
+
{
|
656 |
+
return Mage::getStoreConfig('payment/ops_iDeal/issuer');
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* whether extra parameters needs to be passed to Acceptance or not
|
661 |
+
*
|
662 |
+
* @param null $storeId
|
663 |
+
*
|
664 |
+
* @return bool - true if it's enabled, false otherwise
|
665 |
+
*/
|
666 |
+
public function canSubmitExtraParameter($storeId = null)
|
667 |
+
{
|
668 |
+
return (bool)$this->getConfigData('submitExtraParameters', $storeId);
|
669 |
+
}
|
670 |
+
|
671 |
+
public function getParameterLengths()
|
672 |
+
{
|
673 |
+
return $this->getConfigData('paramLength');
|
674 |
+
}
|
675 |
+
|
676 |
+
public function getFrontendFieldMapping()
|
677 |
+
{
|
678 |
+
return $this->getConfigData('frontendFieldMapping');
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
public function getValidationUrl()
|
683 |
+
{
|
684 |
+
return Mage::getUrl(
|
685 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'validate',
|
686 |
+
array('_secure' => $this->isCurrentlySecure(), '_nosid' => true)
|
687 |
+
);
|
688 |
+
}
|
689 |
+
|
690 |
+
public function getInlineOrderReference($storeId = null)
|
691 |
+
{
|
692 |
+
return $this->getConfigData('inlineOrderReference', $storeId);
|
693 |
+
}
|
694 |
+
|
695 |
+
/**
|
696 |
+
* Returns the mode of the store
|
697 |
+
*
|
698 |
+
* @param null $storeId
|
699 |
+
*
|
700 |
+
* @return string | mode (custom, prod, test) for the store
|
701 |
+
* @see Netresearch_OPS_Model_Source_Mode
|
702 |
+
*/
|
703 |
+
public function getMode($storeId = null)
|
704 |
+
{
|
705 |
+
return $this->getConfigData('mode', $storeId);
|
706 |
+
}
|
707 |
+
|
708 |
+
protected function getOpsUrl($path)
|
709 |
+
{
|
710 |
+
return $this->getConfigData('url/' . $path);
|
711 |
+
}
|
712 |
+
|
713 |
+
/**
|
714 |
+
* Will always return the base url (https://secure.domain.tld/ncol/[test, prod]) for the mode of the store
|
715 |
+
*
|
716 |
+
* @return string Url depending of the mode - will be empty for custom mode
|
717 |
+
*/
|
718 |
+
public function getOpsBaseUrl($storeId = null)
|
719 |
+
{
|
720 |
+
return $this->getOpsUrl('base_' . $this->getMode($storeId));
|
721 |
+
}
|
722 |
+
|
723 |
+
/**
|
724 |
+
* Returns the default url for the given gateway, depending on the mode, that is set for the the given store
|
725 |
+
*
|
726 |
+
* @param string $path
|
727 |
+
* @param int $storeId
|
728 |
+
*
|
729 |
+
* @return string
|
730 |
+
*/
|
731 |
+
public function getDefaultOpsUrl($path, $storeId = null)
|
732 |
+
{
|
733 |
+
return $this->getOpsBaseUrl($storeId) . $this->getOpsUrl($path);
|
734 |
+
}
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Returns the url for the given gateway depending on the set mode for the given store
|
738 |
+
*
|
739 |
+
* @param $path
|
740 |
+
* @param null $storeId
|
741 |
+
*
|
742 |
+
* @return string
|
743 |
+
*/
|
744 |
+
public function determineOpsUrl($path, $storeId = null)
|
745 |
+
{
|
746 |
+
if ($this->getMode($storeId) === Netresearch_OPS_Model_Source_Mode::CUSTOM) {
|
747 |
+
return $this->getConfigData($path, $storeId);
|
748 |
+
} else {
|
749 |
+
return $this->getDefaultOpsUrl($path, $storeId);
|
750 |
+
}
|
751 |
+
}
|
752 |
+
|
753 |
+
public function getTemplateIdentifier($storeId = null)
|
754 |
+
{
|
755 |
+
return $this->getConfigData('template_identifier', $storeId);
|
756 |
+
}
|
757 |
+
|
758 |
+
public function getResendPaymentInfoIdentity($storeId = null)
|
759 |
+
{
|
760 |
+
return $this->getConfigData('resendPaymentInfo_identity', $storeId);
|
761 |
+
}
|
762 |
+
|
763 |
+
public function getResendPaymentInfoTemplate($storeId = null)
|
764 |
+
{
|
765 |
+
return $this->getConfigData('resendPaymentInfo_template', $storeId);
|
766 |
+
}
|
767 |
+
|
768 |
+
public function getStateRestriction()
|
769 |
+
{
|
770 |
+
return $this->getConfigData('ops_state_restriction');
|
771 |
+
}
|
772 |
+
|
773 |
+
public function getPaymentRetryUrl($params, $storeId = null)
|
774 |
+
{
|
775 |
+
return Mage::getUrl(
|
776 |
+
self::OPS_CONTROLLER_ROUTE_PAYMENT . 'retry',
|
777 |
+
array('_secure' => true, '_nosid' => true, '_query' => $params, '_store' => $storeId)
|
778 |
+
);
|
779 |
+
}
|
780 |
+
|
781 |
+
/**
|
782 |
+
* Will return the state of the deviceFingerPrinting:
|
783 |
+
* - true if activated in config
|
784 |
+
* - false if deactivated in config
|
785 |
+
*
|
786 |
+
* @param int $storeId
|
787 |
+
*
|
788 |
+
* @return bool
|
789 |
+
*/
|
790 |
+
public function getDeviceFingerPrinting($storeId = null)
|
791 |
+
{
|
792 |
+
return (bool)$this->getConfigData('device_fingerprinting', $storeId);
|
793 |
+
}
|
794 |
+
|
795 |
+
public function getTransActionTimeout($storeId = null)
|
796 |
+
{
|
797 |
+
return (int)$this->getConfigData('ops_rtimeout', $storeId);
|
798 |
+
}
|
799 |
+
|
800 |
+
/**
|
801 |
+
*
|
802 |
+
* @param int|null $storeId
|
803 |
+
*
|
804 |
+
* @return bool
|
805 |
+
*/
|
806 |
+
public function getCreditDebitSplit($storeId = null)
|
807 |
+
{
|
808 |
+
return (bool)$this->getConfigData('creditdebit_split', $storeId);
|
809 |
+
}
|
810 |
+
|
811 |
+
public function getAllRecurringCcTypes()
|
812 |
+
{
|
813 |
+
return explode(',', Mage::getStoreConfig('payment/ops_recurring_cc/availableTypes'));
|
814 |
+
}
|
815 |
+
|
816 |
+
public function getAcceptedRecurringCcTypes()
|
817 |
+
{
|
818 |
+
return explode(',', Mage::getStoreConfig('payment/ops_recurring_cc/acceptedTypes'));
|
819 |
+
}
|
820 |
+
|
821 |
+
public function getMonthlyBillingDay($storeId = null)
|
822 |
+
{
|
823 |
+
return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . 'billing_day_month', $storeId);
|
824 |
+
}
|
825 |
+
|
826 |
+
public function getWeeklyBillingDay($storeId = null)
|
827 |
+
{
|
828 |
+
return Mage::getStoreConfig(self::OPS_PAYMENT_PATH . 'billing_day_week', $storeId);
|
829 |
+
}
|
830 |
+
|
831 |
+
public function getSuspendSubscriptionTemplate($storeId = null)
|
832 |
+
{
|
833 |
+
return $this->getConfigData('suspendSubscription_template', $storeId);
|
834 |
+
}
|
835 |
+
|
836 |
+
public function getSuspendSubscriptionIdentity($storeId = null)
|
837 |
+
{
|
838 |
+
return $this->getConfigData('suspendSubscription_identity', $storeId);
|
839 |
+
}
|
840 |
+
}
|
841 |
+
|
app/code/community/Netresearch/OPS/Model/Eci/Values.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS payment DirectLink Model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Eci_Values extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
const ECOM_WITH_SSL_ENCRYPTION = 7;
|
33 |
+
|
34 |
+
const MANUALLY_KEYED_FROM_MOTO = 1;
|
35 |
+
}
|
app/code/community/Netresearch/OPS/Model/File/Download.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Model_File_Download
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Number of bytes in one MB
|
8 |
+
*/
|
9 |
+
const ONE_MEGABYTE = 1048576;
|
10 |
+
|
11 |
+
protected $_fileHandler;
|
12 |
+
|
13 |
+
protected $_filePath;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Takes a file name and a size threshold.
|
17 |
+
* If the file is bigger than the threshold, the last written lines, up to the size of the
|
18 |
+
* threshold are returned
|
19 |
+
*
|
20 |
+
* @param string $path Path to file on server
|
21 |
+
* @param int $threshold Max file size, default is 1MB
|
22 |
+
* @return string Path to file to offer to download
|
23 |
+
* @throws Mage_Core_Exception
|
24 |
+
*/
|
25 |
+
public function getFile($path, $threshold = self::ONE_MEGABYTE)
|
26 |
+
{
|
27 |
+
$this->_filePath = $path;
|
28 |
+
if(!file_exists($this->_filePath) || !is_readable($this->_filePath)){
|
29 |
+
Mage::throwException('File '.$this->_filePath.' does not exist or is not readable.');
|
30 |
+
return '';
|
31 |
+
}
|
32 |
+
if(filesize($path) > $threshold){
|
33 |
+
return $this->_trimFileToThreshold($threshold);
|
34 |
+
} else {
|
35 |
+
return $this->_filePath;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Trims the current file to the given threshold and creates a temporary file
|
41 |
+
*
|
42 |
+
* @param $threshold Max file size
|
43 |
+
* @return string Path to the temporary file
|
44 |
+
* @throws Mage_Core_Exception
|
45 |
+
*/
|
46 |
+
protected function _trimFileToThreshold($threshold)
|
47 |
+
{
|
48 |
+
$this->_fileHandler = fopen($this->_filePath, 'r');
|
49 |
+
if(0 > fseek($this->_fileHandler, filesize($this->_filePath)-$threshold, SEEK_SET)){
|
50 |
+
Mage::throwException('Function fseek on file '. $this->_filePath.' failed.');
|
51 |
+
}
|
52 |
+
$content = fread($this->_fileHandler, $threshold);
|
53 |
+
fclose($this->_fileHandler);
|
54 |
+
$tempFileName = tempnam(sys_get_temp_dir(), 'tempFile');
|
55 |
+
file_put_contents($tempFileName, $content);
|
56 |
+
|
57 |
+
return $tempFileName;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
}
|
app/code/community/Netresearch/OPS/Model/Kwixo/Category/Mapping.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category OPS
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Alias model
|
29 |
+
*/
|
30 |
+
|
31 |
+
class Netresearch_OPS_Model_Kwixo_Category_Mapping
|
32 |
+
extends Mage_Core_Model_Abstract
|
33 |
+
{
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*
|
38 |
+
* @see lib/Varien/Varien_Object#_construct()
|
39 |
+
* @return Netresearch_OPS_Model_Kwixo_Category_Mapping
|
40 |
+
*/
|
41 |
+
public function _construct()
|
42 |
+
{
|
43 |
+
$this->_init('ops/kwixo_category_mapping');
|
44 |
+
parent::_construct();
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
public function loadByCategoryId($categoryId)
|
49 |
+
{
|
50 |
+
$collection = $this->getCollection()
|
51 |
+
->addFieldToFilter('category_id', $categoryId)
|
52 |
+
->load();
|
53 |
+
return $collection->getFirstItem();
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/community/Netresearch/OPS/Model/Kwixo/Shipping/Setting.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package ${MODULENAME}
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Model_Kwixo_Shipping_Setting
|
12 |
+
extends Mage_Core_Model_Abstract
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
+
*
|
17 |
+
* @see lib/Varien/Varien_Object#_construct()
|
18 |
+
* @return Netresearch_OPS_Model_Kwixo_Shipping_Setting
|
19 |
+
*/
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ops/kwixo_shipping_setting');
|
23 |
+
parent::_construct();
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Alias.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Model_Mysql4_Alias
|
13 |
+
* Netresearch_OPS_Model_Mysql4_Alias
|
14 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
15 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
|
20 |
+
class Netresearch_OPS_Model_Mysql4_Alias
|
21 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Constructor
|
25 |
+
*
|
26 |
+
* @see lib/Varien/Varien_Object#_construct()
|
27 |
+
* @return Netresearch_OPS_Model_Mysql4_Alias
|
28 |
+
*/
|
29 |
+
public function _construct()
|
30 |
+
{
|
31 |
+
$this->_init('ops/alias','id');
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Alias/Collection.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Model_Mysql4_Alias_Collection
|
13 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
14 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
15 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
class Netresearch_OPS_Model_Mysql4_Alias_Collection extends
|
21 |
+
Mage_Core_Model_Mysql4_Collection_Abstract
|
22 |
+
{
|
23 |
+
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
parent::_construct();
|
27 |
+
$this->_init('ops/alias');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Category/Mapping.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Netresearch_OPS_Model_Mysql4_Alias
|
12 |
+
* Netresearch_OPS_Model_Mysql4_Alias
|
13 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
14 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class Netresearch_OPS_Model_Mysql4_Kwixo_Category_Mapping
|
18 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor
|
23 |
+
*
|
24 |
+
* @see lib/Varien/Varien_Object#_construct()
|
25 |
+
* @return Netresearch_OPS_Model_Mysql4_Kwixo_Category_Mapping
|
26 |
+
*/
|
27 |
+
public function _construct()
|
28 |
+
{
|
29 |
+
$this->_init('ops/kwixo_category_mapping','id');
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Category/Mapping/Collection.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category OPS
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Model_Mysql4_Kwixo_Category_Mapping_Collection
|
13 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
14 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Netresearch_OPS_Model_Mysql4_Kwixo_Category_Mapping_Collection
|
19 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
20 |
+
{
|
21 |
+
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->_init('ops/kwixo_category_mapping');
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Shipping/Setting.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Model_Mysql4_Kwixo_Shipping_Setting
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
|
14 |
+
{
|
15 |
+
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('ops/kwixo_shipping_setting', 'id');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Netresearch/OPS/Model/Mysql4/Kwixo/Shipping/Setting/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package ${MODULENAME}
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Model_Mysql4_Kwixo_Shipping_Setting_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('ops/kwixo_shipping_setting');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Netresearch/OPS/Model/Observer.php
ADDED
@@ -0,0 +1,699 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Netresearch_OPS_Model_Observer
|
12 |
+
*
|
13 |
+
* @author André Herrn <andre.herrn@netresearch.de>
|
14 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
class Netresearch_OPS_Model_Observer
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get one page checkout model
|
22 |
+
*
|
23 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
24 |
+
*/
|
25 |
+
public function getOnepage()
|
26 |
+
{
|
27 |
+
return Mage::getSingleton('checkout/type_onepage');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getAdminSession()
|
31 |
+
{
|
32 |
+
return Mage::getSingleton('admin/session');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function isAdminSession()
|
36 |
+
{
|
37 |
+
|
38 |
+
if ($this->getAdminSession()->getUser()) {
|
39 |
+
return 0 < $this->getAdminSession()->getUser()->getUserId();
|
40 |
+
}
|
41 |
+
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getHelper($name = null)
|
46 |
+
{
|
47 |
+
if (is_null($name)) {
|
48 |
+
return Mage::helper('ops');
|
49 |
+
}
|
50 |
+
|
51 |
+
return Mage::helper('ops/' . $name);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return Netresearch_OPS_Model_Config
|
56 |
+
*/
|
57 |
+
public function getConfig()
|
58 |
+
{
|
59 |
+
return Mage::getModel('ops/config');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* trigger ops payment
|
64 |
+
*/
|
65 |
+
public function checkoutTypeOnepageSaveOrderBefore($observer)
|
66 |
+
{
|
67 |
+
$quote = $observer->getQuote();
|
68 |
+
$order = $observer->getOrder();
|
69 |
+
$code = $quote->getPayment()->getMethodInstance()->getCode();
|
70 |
+
|
71 |
+
try {
|
72 |
+
if ('ops_directDebit' == $code
|
73 |
+
&& Mage::helper('ops/payment')->isInlinePaymentWithQuoteId(
|
74 |
+
$quote->getPayment()
|
75 |
+
)
|
76 |
+
) {
|
77 |
+
$this->confirmDdPayment($order, $quote, $observer);
|
78 |
+
} elseif ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
|
79 |
+
$requestParams = $quote->getPayment()->getMethodInstance()->getFormFields($order, array(), false);
|
80 |
+
$this->invokeRequestParamValidation($requestParams);
|
81 |
+
}
|
82 |
+
} catch (Exception $e) {
|
83 |
+
$quote->setIsActive(true);
|
84 |
+
$this->getOnepage()->getCheckout()->setGotoSection('payment');
|
85 |
+
throw new Mage_Core_Exception($e->getMessage());
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public function salesModelServiceQuoteSubmitFailure($observer)
|
90 |
+
{
|
91 |
+
$quote = $observer->getQuote();
|
92 |
+
if (Mage::helper('ops/payment')->isInlinePaymentWithQuoteId($quote->getPayment())) {
|
93 |
+
$this->handleFailedCheckout(
|
94 |
+
$observer->getQuote(),
|
95 |
+
$observer->getOrder()
|
96 |
+
);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function getQuoteCurrency($quote)
|
101 |
+
{
|
102 |
+
if ($quote->hasForcedCurrency()) {
|
103 |
+
return $quote->getForcedCurrency()->getCode();
|
104 |
+
} else {
|
105 |
+
return Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode();
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
public function confirmAliasPayment($order, $quote)
|
110 |
+
{
|
111 |
+
$requestParams = Mage::helper('ops/creditcard')->getDirectLinkRequestParams($quote, $order);
|
112 |
+
$this->invokeRequestParamValidation($requestParams);
|
113 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation($quote->getPayment(), true);
|
114 |
+
|
115 |
+
return $this->performDirectLinkRequest($quote, $requestParams, $quote->getStoreId());
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
public function confirmDdPayment($order, $quote)
|
120 |
+
{
|
121 |
+
/** @var Netresearch_OPS_Helper_DirectDebit $directDebitHelper */
|
122 |
+
$directDebitHelper = Mage::helper('ops/directDebit');
|
123 |
+
$requestParams = Mage::app()->getRequest()->getParam('ops_directDebit');
|
124 |
+
$directDebitHelper->handleAdminPayment($quote, $requestParams);
|
125 |
+
$requestParams = $directDebitHelper->getDirectLinkRequestParams($quote, $order, $requestParams);
|
126 |
+
$this->invokeRequestParamValidation($requestParams);
|
127 |
+
|
128 |
+
return $this->performDirectLinkRequest($quote, $requestParams, $quote->getStoreId());
|
129 |
+
}
|
130 |
+
|
131 |
+
public function performDirectLinkRequest($quote, $params, $storeId = null)
|
132 |
+
{
|
133 |
+
$url = Mage::getModel('ops/config')->getDirectLinkGatewayOrderPath($storeId);
|
134 |
+
$response = Mage::getSingleton('ops/api_directlink')->performRequest($params, $url, $storeId);
|
135 |
+
/**
|
136 |
+
* allow null as valid state for creating the order with status 'pending'
|
137 |
+
*/
|
138 |
+
if (!is_null($response['STATUS'])
|
139 |
+
&& Mage::helper('ops/payment')->isPaymentFailed($response['STATUS'])
|
140 |
+
) {
|
141 |
+
throw new Mage_Core_Exception($this->getHelper()->__('Acceptance Payment failed'));
|
142 |
+
}
|
143 |
+
$quote->getPayment()->setAdditionalInformation('ops_response', $response)->save();
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Check if checkout was made with OPS CreditCart or DirectDebit
|
150 |
+
*
|
151 |
+
* @return boolean
|
152 |
+
*/
|
153 |
+
protected function isCheckoutWithExistingTxId($code)
|
154 |
+
{
|
155 |
+
if ('ops_opsid' == $code) {
|
156 |
+
return true;
|
157 |
+
} else {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Replace order cancel comfirm message of Magento by a custom message from Acceptance
|
164 |
+
*
|
165 |
+
* @event adminhtml_block_html_before
|
166 |
+
*
|
167 |
+
* @param Varien_Event_Observer $observer
|
168 |
+
*
|
169 |
+
* @return Netresearch_OPS_Model_Observer
|
170 |
+
*/
|
171 |
+
public function updateOrderCancelButton(Varien_Event_Observer $observer)
|
172 |
+
{
|
173 |
+
/* @var $block Mage_Adminhtml_Block_Template */
|
174 |
+
$block = $observer->getEvent()->getBlock();
|
175 |
+
|
176 |
+
//Stop if block is not sales order view
|
177 |
+
if ($block->getType() != 'adminhtml/sales_order_view') {
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
//If payment method is one of the Acceptance-ones and order can be cancelled manually
|
182 |
+
if ($block->getOrder()->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract
|
183 |
+
&& true === $block->getOrder()->getPayment()->getMethodInstance()->canCancelManually($block->getOrder())
|
184 |
+
) {
|
185 |
+
//Build message and update cancel button
|
186 |
+
$message = Mage::helper('ops')->__(
|
187 |
+
"Are you sure you want to cancel this order? Warning: Please check the payment status in the back-office of Acceptance before. By cancelling this order you won\\'t be able to update the status in Magento anymore."
|
188 |
+
);
|
189 |
+
$block->updateButton(
|
190 |
+
'order_cancel',
|
191 |
+
'onclick',
|
192 |
+
'deleteConfirm(\'' . $message . '\', \'' . $block->getCancelUrl() . '\')'
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
*
|
201 |
+
* appends a checkbox for closing the transaction if it's a Acceptance payment
|
202 |
+
*
|
203 |
+
* @event core_block_abstract_to_html_after
|
204 |
+
*
|
205 |
+
* @param Varien_Event_Observer $observer
|
206 |
+
*
|
207 |
+
* @return void
|
208 |
+
*/
|
209 |
+
public function appendCheckBoxToRefundForm($observer)
|
210 |
+
{
|
211 |
+
$html = '';
|
212 |
+
/*
|
213 |
+
* show the checkbox only if the credit memo create page is displayed and
|
214 |
+
* the refund can be done online and the payment is done via Acceptance
|
215 |
+
*/
|
216 |
+
if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
|
217 |
+
&& $observer->getBlock()->getParentBlock()
|
218 |
+
instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items
|
219 |
+
&& $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()
|
220 |
+
&& $observer->getBlock()->getParentBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
|
221 |
+
instanceof Netresearch_OPS_Model_Payment_Abstract
|
222 |
+
&& $observer->getBlock()->getParentBlock()->getCreditmemo()->canRefund()
|
223 |
+
&& $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()
|
224 |
+
&& $observer->getBlock()->getParentBlock()->getCreditmemo()->getInvoice()->getTransactionId()
|
225 |
+
) {
|
226 |
+
$transport = $observer->getTransport();
|
227 |
+
$block = $observer->getBlock();
|
228 |
+
$layout = $block->getLayout();
|
229 |
+
$html = $transport->getHtml();
|
230 |
+
$checkBoxHtml = $layout->createBlock(
|
231 |
+
'ops/adminhtml_sales_order_creditmemo_totals_checkbox',
|
232 |
+
'ops_refund_checkbox'
|
233 |
+
)
|
234 |
+
->setTemplate('ops/sales/order/creditmemo/totals/checkbox.phtml')
|
235 |
+
->renderView();
|
236 |
+
$html = $html . $checkBoxHtml;
|
237 |
+
$transport->setHtml($html);
|
238 |
+
}
|
239 |
+
|
240 |
+
return $html;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
*
|
245 |
+
* fetch the creation of credit memo event and display warning message when
|
246 |
+
* - credit memo could be done online
|
247 |
+
* - payment is a Acceptance payment
|
248 |
+
* - Acceptance transaction is closed
|
249 |
+
*
|
250 |
+
* @event core_block_abstract_to_html_after
|
251 |
+
*
|
252 |
+
* @param Varien_Event_Observer $observer
|
253 |
+
*
|
254 |
+
* @return void
|
255 |
+
*/
|
256 |
+
public function showWarningForClosedTransactions($observer)
|
257 |
+
{
|
258 |
+
$html = '';
|
259 |
+
/**
|
260 |
+
* - credit memo could be done online
|
261 |
+
* - payment is a Acceptance payment
|
262 |
+
* - Acceptance transaction is closed
|
263 |
+
*/
|
264 |
+
if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create
|
265 |
+
&& $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()
|
266 |
+
&& $observer->getBlock()->getCreditmemo()->getOrder()->getPayment()->getMethodInstance()
|
267 |
+
instanceof Netresearch_OPS_Model_Payment_Abstract
|
268 |
+
&& $observer->getBlock()->getCreditmemo()->getInvoice()
|
269 |
+
&& $observer->getBlock()->getCreditmemo()->getInvoice()->getTransactionId()
|
270 |
+
&& false === $observer->getBlock()->getCreditmemo()->canRefund()
|
271 |
+
) {
|
272 |
+
$transport = $observer->getTransport();
|
273 |
+
$block = $observer->getBlock();
|
274 |
+
$layout = $block->getLayout();
|
275 |
+
$html = $transport->getHtml();
|
276 |
+
$warningHtml = $layout->createBlock(
|
277 |
+
'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning',
|
278 |
+
'ops_closed-transaction-warning'
|
279 |
+
)->renderView();
|
280 |
+
$html = $warningHtml . $html;
|
281 |
+
$transport->setHtml($html);
|
282 |
+
}
|
283 |
+
|
284 |
+
return $html;
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
+
/**
|
289 |
+
* triggered by cron for deleting old payment data from the additional payment information
|
290 |
+
*
|
291 |
+
* @param $observer
|
292 |
+
*/
|
293 |
+
public function cleanUpOldPaymentData($observer)
|
294 |
+
{
|
295 |
+
Mage::helper('ops/quote')->cleanUpOldPaymentInformation();
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* in some cases the payment method is not set properly by Magento so we need to reset the
|
300 |
+
* payment method in the quote's payment before importing the data
|
301 |
+
*
|
302 |
+
* @event sales_quote_payment_import_data_before
|
303 |
+
*
|
304 |
+
* @param $observer
|
305 |
+
*
|
306 |
+
* @return $this
|
307 |
+
*/
|
308 |
+
public function clearPaymentMethodFromQuote(Varien_Event_Observer $observer)
|
309 |
+
{
|
310 |
+
if ($observer->getEventName() == 'sales_quote_payment_import_data_before'
|
311 |
+
&& $observer->getEvent()->getPayment() instanceof Mage_Sales_Model_Quote_Payment
|
312 |
+
) {
|
313 |
+
$observer->getEvent()->getPayment()->setMethod(null);
|
314 |
+
}
|
315 |
+
|
316 |
+
return $this;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* appends the status update button to the order's button in case it's an Acceptance payment
|
321 |
+
*
|
322 |
+
* @event core_block_abstract_prepare_layout_before
|
323 |
+
*
|
324 |
+
* @param Varien_Event_Observer $observer
|
325 |
+
*
|
326 |
+
* @return $this
|
327 |
+
*/
|
328 |
+
public function addStatusUpdateButtonToOrderView(Varien_Event_Observer $observer)
|
329 |
+
{
|
330 |
+
$block = $observer->getBlock();
|
331 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
|
332 |
+
$paymentMethod = $block->getOrder()->getPayment()->getMethodInstance();
|
333 |
+
if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
|
334 |
+
&& Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')
|
335 |
+
) {
|
336 |
+
|
337 |
+
$block->addButton(
|
338 |
+
'ops_refresh', array(
|
339 |
+
'label' => Mage::helper('ops/data')->__('Refresh payment status'),
|
340 |
+
'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/opsstatus/update') . '\')')
|
341 |
+
);
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
return $this;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* @event core_block_abstract_prepare_layout_before
|
350 |
+
*
|
351 |
+
* @param Varien_Event_Observer $observer
|
352 |
+
*
|
353 |
+
* @return $this
|
354 |
+
*/
|
355 |
+
public function addCcPaymentMethod(Varien_Event_Observer $observer)
|
356 |
+
{
|
357 |
+
/** @var $block Mage_Payment_Block_Form_Container */
|
358 |
+
$block = $observer->getEvent()->getBlock();
|
359 |
+
if ($block instanceof Mage_Payment_Block_Form_Container
|
360 |
+
&& !Mage::helper('ops/version')->canUseApplicableForQuote(Mage::getEdition())
|
361 |
+
) {
|
362 |
+
Mage::helper('ops/payment')->addCCForZeroAmountCheckout($block);
|
363 |
+
}
|
364 |
+
|
365 |
+
return $this;
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* @event core_block_abstract_prepare_layout_before
|
370 |
+
*
|
371 |
+
* @param Varien_Event_Observer $observer
|
372 |
+
*
|
373 |
+
* @return $this
|
374 |
+
*/
|
375 |
+
public function disableCaptureForZeroAmountInvoice(Varien_Event_Observer $observer)
|
376 |
+
{
|
377 |
+
$block = $observer->getEvent()->getBlock();
|
378 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items) {
|
379 |
+
$invoice = $block->getInvoice();
|
380 |
+
if ($invoice->getBaseGrandTotal() <= 0.01
|
381 |
+
&& $invoice->getOrder()->getPayment()->getMethodInstance() instanceof
|
382 |
+
Netresearch_OPS_Model_Payment_Abstract
|
383 |
+
) {
|
384 |
+
$invoice->getOrder()->getPayment()->getMethodInstance()->setCanCapture(false);
|
385 |
+
}
|
386 |
+
}
|
387 |
+
|
388 |
+
return $this;
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
/**
|
393 |
+
* @param $requestParams
|
394 |
+
*
|
395 |
+
* @throws Mage_Core_Exception
|
396 |
+
* @return Netresearch_OPS_Model_Observer
|
397 |
+
*/
|
398 |
+
protected function invokeRequestParamValidation($requestParams)
|
399 |
+
{
|
400 |
+
$validator = Mage::getModel('ops/validator_parameter_factory')->getValidatorFor(
|
401 |
+
Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
|
402 |
+
);
|
403 |
+
if (false == $validator->isValid($requestParams)) {
|
404 |
+
$this->getOnepage()->getCheckout()->setGotoSection('payment');
|
405 |
+
Mage::throwException(
|
406 |
+
$this->getHelper()->__('The data you have provided can not be processed by Acceptance')
|
407 |
+
);
|
408 |
+
}
|
409 |
+
|
410 |
+
return $this;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* validates the input fields after the payment step in OPC
|
416 |
+
*
|
417 |
+
* @event controller_action_postdispatch_checkout_onepage_savePayment
|
418 |
+
*
|
419 |
+
* @param Varien_Event_Observer $event
|
420 |
+
*
|
421 |
+
* @return $this
|
422 |
+
*/
|
423 |
+
public function controllerActionCheckoutOnepagePostdispatch(Varien_Event_Observer $event)
|
424 |
+
{
|
425 |
+
$controller = $event->getControllerAction();
|
426 |
+
$quote = $this->getOnepage()->getQuote();
|
427 |
+
if ($quote->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
|
428 |
+
$paramHelper = Mage::helper('ops/payment_request');
|
429 |
+
$shippingParams = array();
|
430 |
+
$billingParams = $paramHelper->getOwnerParams($quote->getBillingAddress(), $quote);
|
431 |
+
if ($quote->getShippingAddress()) {
|
432 |
+
$shippingParams = $paramHelper->extractShipToParameters($quote->getShippingAddress(), $quote);
|
433 |
+
}
|
434 |
+
$params = array_merge($billingParams, $shippingParams);
|
435 |
+
$validator = Mage::getModel('ops/validator_parameter_factory')->getValidatorFor(
|
436 |
+
Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
|
437 |
+
);
|
438 |
+
if (false == $validator->isValid($params)) {
|
439 |
+
$result = Mage::helper('ops/validation_result')->getValidationFailedResult(
|
440 |
+
$validator->getMessages(),
|
441 |
+
$quote
|
442 |
+
);
|
443 |
+
$controller->getResponse()->setBody(Mage::helper('core/data')->jsonEncode($result));
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
return $this;
|
448 |
+
}
|
449 |
+
|
450 |
+
|
451 |
+
public function salesOrderPaymentCapture(Varien_Event_Observer $event)
|
452 |
+
{
|
453 |
+
/** @var $payment Mage_Sales_Model_Order_Payment */
|
454 |
+
$payment = $event->getPayment();
|
455 |
+
$invoice = $event->getInvoice();
|
456 |
+
if ($payment->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
|
457 |
+
$payment->setInvoice($invoice);
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
return $this;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* resets the order status back to pending payment in case of directlink payments in Acceptance authorize status
|
466 |
+
*
|
467 |
+
* @event sales_order_payment_place_end
|
468 |
+
*
|
469 |
+
* @param Varien_Event_Observer $event
|
470 |
+
*/
|
471 |
+
public function setOrderStateDirectLink(Varien_Event_Observer $event)
|
472 |
+
{
|
473 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
474 |
+
$payment = $event->getPayment();
|
475 |
+
|
476 |
+
if ($payment->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_DirectLink
|
477 |
+
&& Mage::helper('ops/payment')->isInlinePayment($payment)
|
478 |
+
&& Netresearch_OPS_Model_Status::AUTHORIZED == $payment->getAdditionalInformation('status')
|
479 |
+
&& $payment->getOrder()->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
480 |
+
) {
|
481 |
+
$payment->getOrder()->setState(
|
482 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true,
|
483 |
+
$this->getHelper()->__('Payment has been authorized by Acceptance, but not yet captured.')
|
484 |
+
);
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
|
489 |
+
/**
|
490 |
+
* appends the resend payment info button to the order's button in case it's an Acceptance payment
|
491 |
+
* and the payment status is an authorize status
|
492 |
+
*
|
493 |
+
* @event core_block_abstract_prepare_layout_before
|
494 |
+
*
|
495 |
+
* @param Varien_Event_Observer $observer
|
496 |
+
*
|
497 |
+
* @return $this
|
498 |
+
*/
|
499 |
+
public function addResendPaymentInfoButtonToOrderView(Varien_Event_Observer $observer)
|
500 |
+
{
|
501 |
+
$block = $observer->getBlock();
|
502 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
|
503 |
+
$payment = $block->getOrder()->getPayment();
|
504 |
+
$paymentMethod = $payment->getMethodInstance();
|
505 |
+
if ($paymentMethod instanceof Netresearch_OPS_Model_Payment_Abstract
|
506 |
+
&& Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/invoice')
|
507 |
+
&& Netresearch_OPS_Model_Status::canResendPaymentInfo($payment->getAdditionalInformation('status'))
|
508 |
+
&& !in_array(
|
509 |
+
$block->getOrder()->getState(),
|
510 |
+
array(
|
511 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
512 |
+
Mage_Sales_Model_Order::STATE_CLOSED,
|
513 |
+
Mage_Sales_Model_Order::STATE_COMPLETE
|
514 |
+
)
|
515 |
+
)
|
516 |
+
) {
|
517 |
+
$block->addButton(
|
518 |
+
'ops_resend_info', array(
|
519 |
+
'label' => Mage::helper('ops/data')->__('Resend payment information'),
|
520 |
+
'onclick' => 'setLocation(\'' . $block->getUrl('adminhtml/admin/resendInfo') . '\')')
|
521 |
+
);
|
522 |
+
}
|
523 |
+
}
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Adjusts the confirmation message text of the recurring profiles cancel and suspend button to inform the merchant
|
528 |
+
* that no call to Acceptance will happen
|
529 |
+
*
|
530 |
+
* @event adminhtml_block_html_before
|
531 |
+
*
|
532 |
+
* @param Varien_Event_Observer $observer
|
533 |
+
*/
|
534 |
+
public function updateRecurringProfileButtons(Varien_Event_Observer $observer)
|
535 |
+
{
|
536 |
+
/** @var $block Mage_Sales_Block_Adminhtml_Recurring_Profile_View */
|
537 |
+
$block = $observer->getEvent()->getBlock();
|
538 |
+
|
539 |
+
if ($block->getType() == 'sales/adminhtml_recurring_profile_view') {
|
540 |
+
$profile = Mage::registry('current_recurring_profile');
|
541 |
+
if ($profile->getMethodCode() == Netresearch_OPS_Model_Payment_Recurring_Cc::CODE) {
|
542 |
+
$cancelMessage = Mage::helper('ops')
|
543 |
+
->__(
|
544 |
+
'Are you sure you want to perform this action? Canceling the subscription here will not actually cancel the subscription on Acceptance side. To stop charging the customer you will have to deactivate the subscription there.'
|
545 |
+
);
|
546 |
+
$cancelUrl = $block->getUrl(
|
547 |
+
'*/*/updateState',
|
548 |
+
array('profile' => $profile->getId(), 'action' => 'cancel')
|
549 |
+
);
|
550 |
+
|
551 |
+
$block->updateButton(
|
552 |
+
'cancel',
|
553 |
+
'onclick',
|
554 |
+
"confirmSetLocation('{$cancelMessage}', '{$cancelUrl}')"
|
555 |
+
);
|
556 |
+
|
557 |
+
$suspendMessage = Mage::helper('ops')
|
558 |
+
->__(
|
559 |
+
'Are you sure you want to perform this action? Suspending the subscription here will not actually cancel the subscription on Acceptance side. To stop charging the customer you will have to deactivate the subscription there.'
|
560 |
+
);
|
561 |
+
$suspendUrl = $block->getUrl(
|
562 |
+
'*/*/updateState',
|
563 |
+
array('profile' => $profile->getId(), 'action' => 'suspend')
|
564 |
+
);
|
565 |
+
|
566 |
+
$block->updateButton(
|
567 |
+
'suspend',
|
568 |
+
'onclick',
|
569 |
+
"confirmSetLocation('{$suspendMessage}', '{$suspendUrl}')"
|
570 |
+
);
|
571 |
+
}
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Overwrites the state of the recurring profile if necessary
|
577 |
+
*
|
578 |
+
* @event model_save_before - due to lack of event prefix for recurring profile models
|
579 |
+
*
|
580 |
+
* @param Varien_Event_Observer $observer
|
581 |
+
*
|
582 |
+
* @return $this
|
583 |
+
*/
|
584 |
+
public function overrideRecurringProfileState(Varien_Event_Observer $observer)
|
585 |
+
{
|
586 |
+
$object = $observer->getObject();
|
587 |
+
|
588 |
+
/** @var $object Mage_Payment_Model_Recurring_Profile */
|
589 |
+
if ($object instanceof Mage_Payment_Model_Recurring_Profile
|
590 |
+
&& $object->getMethodCode() === Netresearch_OPS_Model_Payment_Recurring_Cc::CODE
|
591 |
+
&& $object->getState() != $object->getNewState()
|
592 |
+
&& $object->getOverrideState() === true
|
593 |
+
) {
|
594 |
+
$object->setState($object->getNewState());
|
595 |
+
}
|
596 |
+
|
597 |
+
return $this;
|
598 |
+
}
|
599 |
+
|
600 |
+
|
601 |
+
/**
|
602 |
+
* @event adminhtml_block_html_before
|
603 |
+
*
|
604 |
+
* @param Varien_Event_Observer $observer
|
605 |
+
*
|
606 |
+
* @return $this
|
607 |
+
*/
|
608 |
+
public function updateRecurringProfileEditForm(Varien_Event_Observer $observer)
|
609 |
+
{
|
610 |
+
if ($observer->getBlock() instanceof Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form
|
611 |
+
&& Mage::getModel('ops/payment_recurring_cc')->getConfigData('active')
|
612 |
+
) {
|
613 |
+
/** @var Mage_Sales_Block_Adminhtml_Recurring_Profile_Edit_Form $form */
|
614 |
+
$html = $observer->getTransport()->getHtml();
|
615 |
+
|
616 |
+
$method = Mage::getModel('ops/payment_recurring_cc');
|
617 |
+
|
618 |
+
$message = Mage::helper('ops')
|
619 |
+
->__(
|
620 |
+
"When using %s as payment method the settings for '%s' and '%s' will not be processed.",
|
621 |
+
$method->getTitle(),
|
622 |
+
Mage::helper('payment')->__('Allow Initial Fee Failure'),
|
623 |
+
Mage::helper('payment')->__('Maximum Payment Failures')
|
624 |
+
);
|
625 |
+
|
626 |
+
$message = '<div class="notice-msg" style="padding-left: 26px;"><p style="padding: 7px;">' . $message
|
627 |
+
. '</p></div>';
|
628 |
+
$observer->getTransport()->setHtml($html . $message);
|
629 |
+
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
return $this;
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Since there is no other way for inline payments to change the order state, we enforce the pending_payment state
|
638 |
+
* for only authorized, not yet payed orders
|
639 |
+
*
|
640 |
+
* @param Varien_Event_Observer $observer
|
641 |
+
*
|
642 |
+
* @event sales_order_payment_place_end
|
643 |
+
* @return $this
|
644 |
+
*/
|
645 |
+
public function enforcePaymentPendingForAuthorizedOrders(Varien_Event_Observer $observer)
|
646 |
+
{
|
647 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
648 |
+
$payment = $observer->getData('payment');
|
649 |
+
/** @var Mage_Sales_Model_Order $order */
|
650 |
+
$order = $payment->getOrder();
|
651 |
+
|
652 |
+
$status = $payment->getAdditionalInformation('status');
|
653 |
+
if ($this->getConfig()->getPaymentAction($order->getStoreId())
|
654 |
+
== Netresearch_OPS_Model_Payment_Abstract::ACTION_AUTHORIZE
|
655 |
+
&& Netresearch_OPS_Model_Status::isAuthorize($status)
|
656 |
+
&& $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
657 |
+
) {
|
658 |
+
$message = $this->getHelper()->__('Order has been authorized, but not captured/paid yet.');
|
659 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $message);
|
660 |
+
|
661 |
+
}
|
662 |
+
|
663 |
+
return $this;
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Magento does not send order confirmation emails when
|
668 |
+
* - payment action "authorization" is processed in frontend via gateway.
|
669 |
+
* Magento does not send invoice emails when
|
670 |
+
* - payment action "authorization+capture" is processed in frontend or admin
|
671 |
+
*
|
672 |
+
* event: checkout_submit_all_after
|
673 |
+
*
|
674 |
+
* @param Varien_Event_Observer $observer
|
675 |
+
*/
|
676 |
+
public function sendTransactionalEmails(Varien_Event_Observer $observer)
|
677 |
+
{
|
678 |
+
/** @var Mage_Sales_Model_Order $order */
|
679 |
+
$order = $observer->getOrder();
|
680 |
+
if (!$order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract) {
|
681 |
+
// ignore third-party payment methods
|
682 |
+
return;
|
683 |
+
}
|
684 |
+
|
685 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
686 |
+
$quote = $observer->getQuote();
|
687 |
+
if ($quote->getPayment()->getOrderPlaceRedirectUrl()) {
|
688 |
+
// redirect payments require special treatment, may still get cancelled or declined
|
689 |
+
return;
|
690 |
+
}
|
691 |
+
|
692 |
+
try {
|
693 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
694 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order->getPayment()->getCreatedInvoice());
|
695 |
+
} catch (Exception $e) {
|
696 |
+
Mage::logException($e);
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Abstract.php
ADDED
@@ -0,0 +1,1105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**PAYMENT_PROCESSING
|
28 |
+
* OPS payment method model
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
|
31 |
+
{
|
32 |
+
|
33 |
+
protected $pm = '';
|
34 |
+
protected $brand = '';
|
35 |
+
|
36 |
+
protected $_code = 'ops';
|
37 |
+
protected $_formBlockType = 'ops/form';
|
38 |
+
protected $_infoBlockType = 'ops/info';
|
39 |
+
protected $_config = null;
|
40 |
+
protected $requestHelper = null;
|
41 |
+
protected $backendOperationParameterModel = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param null $backendOperationParameterModel
|
45 |
+
*/
|
46 |
+
public function setBackendOperationParameterModel($backendOperationParameterModel)
|
47 |
+
{
|
48 |
+
$this->backendOperationParameterModel = $backendOperationParameterModel;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return Netresearch_OPS_Model_Backend_Operation_Parameter
|
53 |
+
*/
|
54 |
+
public function getBackendOperationParameterModel()
|
55 |
+
{
|
56 |
+
if (null === $this->backendOperationParameterModel) {
|
57 |
+
$this->backendOperationParameterModel = Mage::getModel('ops/backend_operation_parameter');
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->backendOperationParameterModel;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Magento Payment Behaviour Settings
|
65 |
+
*/
|
66 |
+
protected $_isGateway = false;
|
67 |
+
protected $_canAuthorize = true;
|
68 |
+
protected $_canCapture = true;
|
69 |
+
protected $_canCapturePartial = true;
|
70 |
+
protected $_canRefund = true;
|
71 |
+
protected $_canRefundInvoicePartial = true;
|
72 |
+
protected $_canVoid = true;
|
73 |
+
protected $_canUseInternal = false;
|
74 |
+
protected $_canUseCheckout = true;
|
75 |
+
protected $_canUseForMultishipping = false;
|
76 |
+
protected $_isInitializeNeeded = true;
|
77 |
+
protected $_canManageRecurringProfiles = false;
|
78 |
+
|
79 |
+
/**
|
80 |
+
* OPS behaviour settings
|
81 |
+
*/
|
82 |
+
|
83 |
+
protected $_needsCartDataForRequest = false;
|
84 |
+
|
85 |
+
protected $_needsShipToParams = true;
|
86 |
+
|
87 |
+
protected $_needsBillToParams = false;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* OPS template modes
|
91 |
+
*/
|
92 |
+
const TEMPLATE_OPS_REDIRECT = 'ops';
|
93 |
+
const TEMPLATE_OPS_IFRAME = 'ops_iframe';
|
94 |
+
const TEMPLATE_OPS_TEMPLATE = 'ops_template';
|
95 |
+
const TEMPLATE_MAGENTO_INTERNAL = 'magento';
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* redirect references
|
100 |
+
*/
|
101 |
+
|
102 |
+
const REFERENCE_QUOTE_ID = 'quoteId';
|
103 |
+
const REFERENCE_ORDER_ID = 'orderId';
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Layout of the payment method
|
107 |
+
*/
|
108 |
+
const PMLIST_HORIZONTAL_LEFT = 0;
|
109 |
+
const PMLIST_HORIZONTAL = 1;
|
110 |
+
const PMLIST_VERTICAL = 2;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* OPS payment action constant
|
114 |
+
*/
|
115 |
+
const OPS_AUTHORIZE_ACTION = 'RES';
|
116 |
+
const OPS_AUTHORIZE_CAPTURE_ACTION = 'SAL';
|
117 |
+
const OPS_CAPTURE_FULL = 'SAS';
|
118 |
+
const OPS_CAPTURE_PARTIAL = 'SAL';
|
119 |
+
const OPS_CAPTURE_DIRECTDEBIT_NL = 'VEN';
|
120 |
+
const OPS_DELETE_AUTHORIZE = 'DEL';
|
121 |
+
const OPS_DELETE_AUTHORIZE_AND_CLOSE = 'DES';
|
122 |
+
const OPS_REFUND_FULL = 'RFS';
|
123 |
+
const OPS_REFUND_PARTIAL = 'RFD';
|
124 |
+
|
125 |
+
/**
|
126 |
+
* 3D-Secure
|
127 |
+
*/
|
128 |
+
const OPS_DIRECTLINK_WIN3DS = 'MAINW';
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Module Transaction Type Codes
|
132 |
+
*/
|
133 |
+
const OPS_CAPTURE_TRANSACTION_TYPE = 'capture';
|
134 |
+
const OPS_VOID_TRANSACTION_TYPE = 'void';
|
135 |
+
const OPS_REFUND_TRANSACTION_TYPE = 'refund';
|
136 |
+
const OPS_DELETE_TRANSACTION_TYPE = 'delete';
|
137 |
+
const OPS_AUTHORIZE_TRANSACTION_TYPE = 'authorize';
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Session key for device fingerprinting consent
|
141 |
+
*/
|
142 |
+
const FINGERPRINT_CONSENT_SESSION_KEY = 'device_fingerprinting_consent';
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Return OPS Config
|
146 |
+
*
|
147 |
+
* @return Netresearch_OPS_Model_Config
|
148 |
+
*/
|
149 |
+
public function getConfig()
|
150 |
+
{
|
151 |
+
if (is_null($this->_config)) {
|
152 |
+
$this->_config = Mage::getSingleton('ops/config');
|
153 |
+
}
|
154 |
+
|
155 |
+
return $this->_config;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getConfigPaymentAction()
|
159 |
+
{
|
160 |
+
return $this->getPaymentAction();
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* return if shipment params are needed for request
|
165 |
+
*
|
166 |
+
* @return bool
|
167 |
+
*/
|
168 |
+
public function getNeedsShipToParams()
|
169 |
+
{
|
170 |
+
return $this->_needsShipToParams;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* return if billing params are needed for request
|
175 |
+
*
|
176 |
+
* @return bool
|
177 |
+
*/
|
178 |
+
public function getNeedsBillToParams()
|
179 |
+
{
|
180 |
+
return $this->_needsBillToParams;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* returns the request helper
|
185 |
+
*
|
186 |
+
* @return Netresearch_OPS_Helper_Payment_Request
|
187 |
+
*/
|
188 |
+
public function getRequestHelper()
|
189 |
+
{
|
190 |
+
if (null === $this->requestHelper) {
|
191 |
+
$this->requestHelper = Mage::helper('ops/payment_request');
|
192 |
+
}
|
193 |
+
|
194 |
+
return $this->requestHelper;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* if payment method is available
|
199 |
+
*
|
200 |
+
* @param Mage_Sales_Model_Quote $quote
|
201 |
+
*
|
202 |
+
* @return boolean
|
203 |
+
*/
|
204 |
+
public function isAvailable($quote = null)
|
205 |
+
{
|
206 |
+
|
207 |
+
$storeId = 0;
|
208 |
+
// allow multi store/site for backend orders with disabled backend payment methods in default store
|
209 |
+
if (!is_null($quote) && !is_null($quote->getId())) {
|
210 |
+
$storeId = $quote->getStoreId();
|
211 |
+
}
|
212 |
+
if (Mage_Core_Model_App::ADMIN_STORE_ID == Mage::app()->getStore()->getId()
|
213 |
+
&& false == $this->isEnabledForBackend($storeId)
|
214 |
+
) {
|
215 |
+
return false;
|
216 |
+
}
|
217 |
+
|
218 |
+
return parent::isAvailable($quote);
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* if method is enabled for backend payments
|
223 |
+
*
|
224 |
+
* @return bool
|
225 |
+
*/
|
226 |
+
public function isEnabledForBackend($storeId = 0)
|
227 |
+
{
|
228 |
+
return $this->getConfig()->isEnabledForBackend($this->_code, $storeId);
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Redirect url to ops submit form
|
233 |
+
*
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
public function getOrderPlaceRedirectUrl()
|
237 |
+
{
|
238 |
+
return $this->getConfig()->getPaymentRedirectUrl();
|
239 |
+
}
|
240 |
+
|
241 |
+
protected function getPayment()
|
242 |
+
{
|
243 |
+
$checkout = Mage::getSingleton('checkout/session');
|
244 |
+
$payment = $checkout->getQuote()->getPayment();
|
245 |
+
if (!$payment->getId()) {
|
246 |
+
$payment = Mage::getModel('sales/order')->loadByIncrementId($checkout->getLastRealOrderId())->getPayment();
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
public function getOpsBrand($payment = null)
|
251 |
+
{
|
252 |
+
if (is_null($payment)) {
|
253 |
+
$payment = $this->getInfoInstance();
|
254 |
+
}
|
255 |
+
$brand = trim($payment->getAdditionalInformation('BRAND'));
|
256 |
+
if (!strlen($brand)) {
|
257 |
+
$brand = $this->brand;
|
258 |
+
}
|
259 |
+
|
260 |
+
return $brand;
|
261 |
+
}
|
262 |
+
|
263 |
+
public function getOpsCode($payment = null)
|
264 |
+
{
|
265 |
+
if (is_null($payment)) {
|
266 |
+
$payment = $this->getInfoInstance();
|
267 |
+
}
|
268 |
+
$pm = trim($payment->getAdditionalInformation('PM'));
|
269 |
+
if (!strlen($pm)) {
|
270 |
+
$pm = $this->pm;
|
271 |
+
}
|
272 |
+
|
273 |
+
return $pm;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Return payment_action value from config area
|
278 |
+
*
|
279 |
+
* @return string
|
280 |
+
*/
|
281 |
+
public function getPaymentAction()
|
282 |
+
{
|
283 |
+
return $this->getConfig()->getPaymentAction($this->getStoreId());
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* @param Mage_Sales_Model_Order $order
|
288 |
+
* @param string[]|null $requestParams
|
289 |
+
*
|
290 |
+
* @return string[]
|
291 |
+
*/
|
292 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
293 |
+
{
|
294 |
+
$billingAddress = $order->getBillingAddress();
|
295 |
+
$shippingAddress = $order->getShippingAddress();
|
296 |
+
if (null === $shippingAddress || false === $shippingAddress) {
|
297 |
+
$shippingAddress = $billingAddress;
|
298 |
+
}
|
299 |
+
$payment = $order->getPayment()->getMethodInstance();
|
300 |
+
$quote = Mage::helper('ops/order')->getQuote($order->getQuoteId());
|
301 |
+
|
302 |
+
$formFields = array();
|
303 |
+
$formFields['ORIG'] = Mage::helper("ops")->getModuleVersionString();
|
304 |
+
$formFields['BRAND'] = $payment->getOpsBrand($order->getPayment());
|
305 |
+
if ($this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
|
306 |
+
$formFields['CN'] = $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname();
|
307 |
+
$formFields['COM'] = $this->_getOrderDescription($order);
|
308 |
+
$formFields['ADDMATCH'] = Mage::helper('ops/order')->checkIfAddressesAreSame($order);
|
309 |
+
$ownerParams = $this->getRequestHelper()->getOwnerParams($billingAddress, $quote);
|
310 |
+
$formFields['ECOM_BILLTO_POSTAL_POSTALCODE'] = $billingAddress->getPostcode();
|
311 |
+
$formFields = array_merge($formFields, $ownerParams);
|
312 |
+
}
|
313 |
+
|
314 |
+
if (Mage::helper('customer/data')->isLoggedIn()) {
|
315 |
+
$formFields['CUID'] = Mage::helper('customer')->getCustomer()->getId();
|
316 |
+
}
|
317 |
+
|
318 |
+
return $formFields;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* return ship to params if needed otherwise false
|
323 |
+
*
|
324 |
+
* @param $shippingAddress
|
325 |
+
*
|
326 |
+
* @return array|bool
|
327 |
+
*/
|
328 |
+
public function getShipToParams($shippingAddress)
|
329 |
+
{
|
330 |
+
$shipToParams = false;
|
331 |
+
if ($this->getNeedsShipToParams()
|
332 |
+
&& $this->getConfig()->canSubmitExtraParameter()
|
333 |
+
&& $shippingAddress
|
334 |
+
) {
|
335 |
+
$shipToParams = $this->getRequestHelper()->extractShipToParameters($shippingAddress);
|
336 |
+
}
|
337 |
+
|
338 |
+
return $shipToParams;
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* return ship to params if needed otherwise false
|
343 |
+
*
|
344 |
+
* @param $billingAddress
|
345 |
+
*
|
346 |
+
* @return array|bool
|
347 |
+
*/
|
348 |
+
public function getBillToParams($billingAddress)
|
349 |
+
{
|
350 |
+
$billToParams = false;
|
351 |
+
if ($this->getNeedsBillToParams()
|
352 |
+
&& $this->getConfig()->canSubmitExtraParameter()
|
353 |
+
&& $billingAddress
|
354 |
+
) {
|
355 |
+
$billToParams = $this->getRequestHelper()->extractBillToParameters($billingAddress);
|
356 |
+
}
|
357 |
+
|
358 |
+
return $billToParams;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Prepare params array to send it to gateway page via POST
|
363 |
+
*
|
364 |
+
* @param Mage_Sales_Model_Order
|
365 |
+
* @param array
|
366 |
+
*
|
367 |
+
* @return array
|
368 |
+
*/
|
369 |
+
public function getFormFields($order, $requestParams, $isRequest = true)
|
370 |
+
{
|
371 |
+
$requestHelper = Mage::helper('ops/payment_request');
|
372 |
+
|
373 |
+
if (empty($order)) {
|
374 |
+
if (!($order = $this->getOrder())) {
|
375 |
+
return array();
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
// get mandatory parameters
|
380 |
+
$formFields = $this->getMandatoryFormFields($order);
|
381 |
+
|
382 |
+
// get method specific parameters
|
383 |
+
$methodDependendFields = $this->getMethodDependendFormFields($order, $requestParams);
|
384 |
+
if (is_array($methodDependendFields)) {
|
385 |
+
$formFields = array_merge($formFields, $methodDependendFields);
|
386 |
+
}
|
387 |
+
|
388 |
+
|
389 |
+
$paymentAction = $this->_getOPSPaymentOperation();
|
390 |
+
if ($paymentAction ) {
|
391 |
+
$formFields['OPERATION'] = $paymentAction;
|
392 |
+
}
|
393 |
+
|
394 |
+
$formFields = array_merge($formFields, $requestHelper->getTemplateParams($order->getStoreId()));
|
395 |
+
|
396 |
+
$formFields['ACCEPTURL'] = $this->getConfig()->getAcceptUrl();
|
397 |
+
$formFields['DECLINEURL'] = $this->getConfig()->getDeclineUrl();
|
398 |
+
$formFields['EXCEPTIONURL'] = $this->getConfig()->getExceptionUrl();
|
399 |
+
$formFields['CANCELURL'] = $this->getConfig()->getCancelUrl();
|
400 |
+
$formFields['BACKURL'] = $this->getConfig()->getCancelUrl();
|
401 |
+
|
402 |
+
|
403 |
+
/** @var $order Mage_Sales_Model_Order */
|
404 |
+
$shipToFormFields = $this->getShipToParams($order->getShippingAddress());
|
405 |
+
if (is_array($shipToFormFields)) {
|
406 |
+
$formFields = array_merge($formFields, $shipToFormFields);
|
407 |
+
}
|
408 |
+
|
409 |
+
$billToFormFields = $this->getBillToParams($order->getBillingAddress());
|
410 |
+
if (is_array($billToFormFields)) {
|
411 |
+
$formFields = array_merge($formFields, $billToFormFields);
|
412 |
+
}
|
413 |
+
|
414 |
+
$cartDataFormFields = $this->getOrderItemData($order);
|
415 |
+
|
416 |
+
if (is_array($cartDataFormFields)) {
|
417 |
+
$formFields = array_merge($formFields, $cartDataFormFields);
|
418 |
+
}
|
419 |
+
|
420 |
+
// get method specific parameters
|
421 |
+
$methodDependendFields = $this->getMethodDependendFormFields($order, $requestParams);
|
422 |
+
if (is_array($methodDependendFields)) {
|
423 |
+
$formFields = array_merge($formFields, $methodDependendFields);
|
424 |
+
}
|
425 |
+
|
426 |
+
$shaSign = Mage::helper('ops/payment')->shaCrypt(
|
427 |
+
Mage::helper('ops/payment')
|
428 |
+
->getSHASign($formFields, null, $order->getStoreId())
|
429 |
+
);
|
430 |
+
|
431 |
+
if ($isRequest) {
|
432 |
+
$helper = Mage::helper('ops');
|
433 |
+
$helper->log(
|
434 |
+
$helper->__(
|
435 |
+
"Register Order %s in Acceptance \n\nAll form fields: %s\nAcceptance String to hash: %s\nHash: %s",
|
436 |
+
$order->getIncrementId(),
|
437 |
+
serialize($formFields),
|
438 |
+
Mage::helper('ops/payment')->getSHASign($formFields, null, $order->getStoreId()),
|
439 |
+
$shaSign
|
440 |
+
)
|
441 |
+
);
|
442 |
+
}
|
443 |
+
|
444 |
+
$formFields['SHASIGN'] = $shaSign;
|
445 |
+
|
446 |
+
return $formFields;
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Get OPS Payment Action value
|
451 |
+
*
|
452 |
+
* @param string
|
453 |
+
*
|
454 |
+
* @return string
|
455 |
+
*/
|
456 |
+
protected function _getOPSPaymentOperation()
|
457 |
+
{
|
458 |
+
$value = $this->getPaymentAction();
|
459 |
+
if ($value == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
|
460 |
+
$value = self::OPS_AUTHORIZE_ACTION;
|
461 |
+
} elseif ($value == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
462 |
+
$value = self::OPS_AUTHORIZE_CAPTURE_ACTION;
|
463 |
+
}
|
464 |
+
|
465 |
+
return $value;
|
466 |
+
}
|
467 |
+
|
468 |
+
protected function convertToLatin1($StringToConvert)
|
469 |
+
{
|
470 |
+
$returnString = '';
|
471 |
+
$chars = str_split($StringToConvert);
|
472 |
+
foreach ($chars as $char) {
|
473 |
+
if (31 < ord($char) && ord($char) < 127) {
|
474 |
+
$returnString .= $char;
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
return $returnString;
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* get formated order description
|
483 |
+
*
|
484 |
+
* @param Mage_Sales_Model_Order
|
485 |
+
*
|
486 |
+
* @return string
|
487 |
+
*/
|
488 |
+
public function _getOrderDescription($order)
|
489 |
+
{
|
490 |
+
$descriptionItems = array();
|
491 |
+
$description = '';
|
492 |
+
$lengs = 0;
|
493 |
+
foreach ($order->getAllItems() as $item) {
|
494 |
+
if ($item->getParentItem()) {
|
495 |
+
continue;
|
496 |
+
}
|
497 |
+
// we know that Acceptance is not able to handle characters that are not available in iso-8859-1
|
498 |
+
// $descriptionItems[] = mb_ereg_replace("[^a-zA-Z0-9äáàéèíóöõúüûÄÁÀÉÍÓÖÕÚÜÛ_ ]" , "" , $item->getName());
|
499 |
+
$descriptionItems[] = $this->convertToLatin1($item->getName());
|
500 |
+
$description = Mage::helper('core/string')->substr(implode(', ', $descriptionItems), 0, 100);
|
501 |
+
//COM field is limited to 100 chars max
|
502 |
+
if (100 <= Mage::helper('core/string')->strlen($description)) {
|
503 |
+
break;
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
return $description;
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Get Main OPS Helper
|
512 |
+
*
|
513 |
+
* @return Netresearch_OPS_Helper_Data
|
514 |
+
*/
|
515 |
+
public function getHelper()
|
516 |
+
{
|
517 |
+
return Mage::helper('ops/data');
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Method that will be executed instead of authorize or capture
|
522 |
+
* if flag isInitializeNeeded set to true
|
523 |
+
*
|
524 |
+
* @param string $paymentAction
|
525 |
+
* @param object $stateObject
|
526 |
+
*
|
527 |
+
* @return Mage_Payment_Model_Abstract
|
528 |
+
*/
|
529 |
+
public function initialize($paymentAction, $stateObject)
|
530 |
+
{
|
531 |
+
$stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
|
532 |
+
->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
533 |
+
|
534 |
+
if (!$paymentAction) {
|
535 |
+
$paymentAction = $this->getConfigPaymentAction();
|
536 |
+
}
|
537 |
+
|
538 |
+
$message = $this->getHelper()
|
539 |
+
->__('Customer got redirected to Acceptance for %s. Awaiting feedback.', $paymentAction);
|
540 |
+
|
541 |
+
/** @var Mage_Sales_Model_Order $order */
|
542 |
+
$order = $this->getInfoInstance()->getOrder();
|
543 |
+
|
544 |
+
$order->addStatusHistoryComment($message);
|
545 |
+
|
546 |
+
return $this;
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* accept payment
|
551 |
+
*
|
552 |
+
* @see \Mage_Sales_Model_Order_Payment::registerPaymentReviewAction
|
553 |
+
*
|
554 |
+
* @param Mage_Payment_Model_Info $payment
|
555 |
+
*
|
556 |
+
* @return boolean
|
557 |
+
* @throws Mage_Core_Exception
|
558 |
+
*/
|
559 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
560 |
+
{
|
561 |
+
parent::acceptPayment($payment);
|
562 |
+
$status = $payment->getAdditionalInformation('status');
|
563 |
+
|
564 |
+
if ($status == Netresearch_OPS_Model_Status::AUTHORIZED || $status == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED) {
|
565 |
+
return true;
|
566 |
+
}
|
567 |
+
|
568 |
+
Mage::throwException(
|
569 |
+
$this->getHelper()->__(
|
570 |
+
'The order can not be accepted via Magento. For the actual status of the payment check the Acceptance backend.'
|
571 |
+
)
|
572 |
+
);
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* cancel order if in payment review state
|
577 |
+
*
|
578 |
+
* @see \Mage_Sales_Model_Order_Payment::registerPaymentReviewAction
|
579 |
+
*
|
580 |
+
* @param Mage_Payment_Model_Info $payment
|
581 |
+
*
|
582 |
+
* @return boolean
|
583 |
+
* @throws Mage_Core_Exception
|
584 |
+
*/
|
585 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
586 |
+
{
|
587 |
+
parent::denyPayment($payment);
|
588 |
+
|
589 |
+
Mage::getSingleton('admin/session')->addNotice(
|
590 |
+
$this->getHelper()->__('Order has been canceled permanently in Magento. Changes in Acceptance platform will no longer be considered.')
|
591 |
+
);
|
592 |
+
|
593 |
+
return true;
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* check if payment is in payment review state
|
598 |
+
*
|
599 |
+
* @param Mage_Payment_Model_Info $payment
|
600 |
+
*
|
601 |
+
* @return bool
|
602 |
+
*/
|
603 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
604 |
+
{
|
605 |
+
$status = $payment->getAdditionalInformation('status');
|
606 |
+
return Netresearch_OPS_Model_Status::canResendPaymentInfo($status);
|
607 |
+
}
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Determines if a capture will be processed
|
611 |
+
*
|
612 |
+
* @param Varien_Object $payment
|
613 |
+
* @param float $amount
|
614 |
+
*
|
615 |
+
* @throws Mage_Core_Exception
|
616 |
+
* @return \Mage_Payment_Model_Abstract|void
|
617 |
+
*/
|
618 |
+
public function capture(Varien_Object $payment, $amount)
|
619 |
+
{
|
620 |
+
// disallow Acceptance online capture if amount is zero
|
621 |
+
if ($amount < 0.01) {
|
622 |
+
return parent::capture($payment, $amount);
|
623 |
+
}
|
624 |
+
|
625 |
+
if (true === Mage::registry('ops_auto_capture')) {
|
626 |
+
Mage::unregister('ops_auto_capture');
|
627 |
+
|
628 |
+
return parent::capture($payment, $amount);
|
629 |
+
}
|
630 |
+
|
631 |
+
$orderId = $payment->getOrder()->getId();
|
632 |
+
$arrInfo = Mage::helper('ops/order_capture')->prepareOperation($payment, $amount);
|
633 |
+
$storeId = $payment->getOrder()->getStoreId();
|
634 |
+
|
635 |
+
if ($this->isRedirectNoticed($orderId)) {
|
636 |
+
return $this;
|
637 |
+
}
|
638 |
+
try {
|
639 |
+
$requestParams = $this->getBackendOperationParameterModel()->getParameterFor(
|
640 |
+
self::OPS_CAPTURE_TRANSACTION_TYPE,
|
641 |
+
$this,
|
642 |
+
$payment,
|
643 |
+
$amount,
|
644 |
+
$arrInfo
|
645 |
+
);
|
646 |
+
$response = Mage::getSingleton('ops/api_directlink')->performRequest(
|
647 |
+
$requestParams,
|
648 |
+
Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
|
649 |
+
$storeId
|
650 |
+
);
|
651 |
+
|
652 |
+
Mage::getModel('ops/response_handler')->processResponse($response, $this, false);
|
653 |
+
|
654 |
+
return $this;
|
655 |
+
|
656 |
+
} catch (Exception $e) {
|
657 |
+
Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
|
658 |
+
Mage::helper('ops')->log("Exception in capture request:" . $e->getMessage());
|
659 |
+
Mage::throwException($e->getMessage());
|
660 |
+
}
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Refund
|
665 |
+
*
|
666 |
+
* @param Varien_Object $payment
|
667 |
+
* @param float $amount
|
668 |
+
*
|
669 |
+
* @return \Mage_Payment_Model_Abstract|void
|
670 |
+
*/
|
671 |
+
public function refund(Varien_Object $payment, $amount)
|
672 |
+
{
|
673 |
+
$refundHelper = Mage::helper('ops/order_refund');
|
674 |
+
|
675 |
+
if ($refundHelper->getOpenRefundTransaction($payment)->getId()) {
|
676 |
+
Mage::throwException($this->getHelper()->__("There is already one creditmemo in the queue. The Creditmemo will be created automatically as soon as Acceptance sends an acknowledgement."));
|
677 |
+
}
|
678 |
+
|
679 |
+
$refundHelper->setAmount($amount)->setPayment($payment);
|
680 |
+
$arrInfo = $refundHelper->prepareOperation($payment, $amount);
|
681 |
+
$storeId = $payment->getOrder()->getStoreId();
|
682 |
+
|
683 |
+
try {
|
684 |
+
$requestParams = $this->getBackendOperationParameterModel()->getParameterFor(
|
685 |
+
self::OPS_REFUND_TRANSACTION_TYPE,
|
686 |
+
$this,
|
687 |
+
$payment,
|
688 |
+
$amount,
|
689 |
+
$arrInfo
|
690 |
+
);
|
691 |
+
$response = Mage::getSingleton('ops/api_directlink')->performRequest(
|
692 |
+
$requestParams,
|
693 |
+
Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
|
694 |
+
$storeId
|
695 |
+
);
|
696 |
+
Mage::getModel('ops/response_handler')->processResponse($response, $this, false);
|
697 |
+
} catch (Exception $e) {
|
698 |
+
Mage::logException($e);
|
699 |
+
Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
|
700 |
+
Mage::throwException($e->getMessage());
|
701 |
+
}
|
702 |
+
|
703 |
+
return $this;
|
704 |
+
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Returns the mandatory fields for requests to Acceptance
|
708 |
+
*
|
709 |
+
* @param Mage_Sales_Model_Order $order
|
710 |
+
*
|
711 |
+
* @return array
|
712 |
+
*/
|
713 |
+
public function getMandatoryFormFields($order)
|
714 |
+
{
|
715 |
+
$formFields = Mage::helper('ops/payment_request')->getMandatoryRequestFields($order);
|
716 |
+
$paymentAction = $this->_getOPSPaymentOperation();
|
717 |
+
if ($paymentAction) {
|
718 |
+
$formFields['OPERATION'] = $paymentAction;
|
719 |
+
}
|
720 |
+
|
721 |
+
return $formFields;
|
722 |
+
}
|
723 |
+
|
724 |
+
/**
|
725 |
+
* determines if the close transaction parameter is set in the credit memo data
|
726 |
+
*
|
727 |
+
* @param array $creditMemoData
|
728 |
+
*
|
729 |
+
* @return bool
|
730 |
+
*/
|
731 |
+
protected function getCloseTransactionFromCreditMemoData($creditMemoData)
|
732 |
+
{
|
733 |
+
$closeTransaction = false;
|
734 |
+
if (array_key_exists('ops_close_transaction', $creditMemoData)
|
735 |
+
&& strtolower(trim($creditMemoData['ops_close_transaction'])) == 'on'
|
736 |
+
) {
|
737 |
+
$closeTransaction = true;
|
738 |
+
}
|
739 |
+
|
740 |
+
return $closeTransaction;
|
741 |
+
}
|
742 |
+
|
743 |
+
/**
|
744 |
+
* Custom cancel behavior, deny cancel and force custom to use void instead
|
745 |
+
*
|
746 |
+
* @param Varien_Object $payment
|
747 |
+
*
|
748 |
+
* @return void
|
749 |
+
* @throws Mage_Core_Exception
|
750 |
+
*/
|
751 |
+
public function cancel(Varien_Object $payment)
|
752 |
+
{
|
753 |
+
/*
|
754 |
+
* Important: If an order was voided successfully and the user clicks on cancel in order-view
|
755 |
+
* this method is not triggered anymore
|
756 |
+
*/
|
757 |
+
|
758 |
+
//Proceed parent cancel method in case that regirstry value ops_auto_void is set
|
759 |
+
if (true === Mage::registry('ops_auto_void')):
|
760 |
+
Mage::unregister('ops_auto_void');
|
761 |
+
|
762 |
+
return parent::cancel($payment);
|
763 |
+
endif;
|
764 |
+
|
765 |
+
//If order has state 'pending_payment' and the payment has Acceptance-status 0 or null (unknown) then cancel the order
|
766 |
+
if (true === $this->canCancelManually($payment->getOrder())) {
|
767 |
+
$payment->getOrder()->addStatusHistoryComment(
|
768 |
+
$this->getHelper()->__("The order was cancelled manually. The Acceptance-state is 0 or null.")
|
769 |
+
);
|
770 |
+
|
771 |
+
return parent::cancel($payment);
|
772 |
+
}
|
773 |
+
|
774 |
+
//Abort cancel method by throwing a Mage_Core_Exception
|
775 |
+
throw new Mage_Core_Exception($this->getHelper()->__('Please use void to cancel the operation.'));
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* Custom void behavior, trigger Acceptance cancel request
|
780 |
+
*
|
781 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
782 |
+
*
|
783 |
+
* @return void
|
784 |
+
* @throws Mage_Core_Exception
|
785 |
+
*/
|
786 |
+
public function void(Varien_Object $payment)
|
787 |
+
{
|
788 |
+
|
789 |
+
$status = $payment->getAdditionalInformation('status');
|
790 |
+
|
791 |
+
if(!Netresearch_OPS_Model_Status::canVoidTransaction($status)){
|
792 |
+
Mage::throwException($this->getHelper()->__('Status %s can not be voided.', $status));
|
793 |
+
}
|
794 |
+
|
795 |
+
//Set initital params
|
796 |
+
$orderID = $payment->getOrder()->getId();
|
797 |
+
$order = Mage::getModel("sales/order")->load($orderID);
|
798 |
+
|
799 |
+
//Calculate amount which has to be captured
|
800 |
+
$alreadyCaptured = $payment->getBaseAmountPaidOnline();
|
801 |
+
|
802 |
+
$grandTotal = Mage::helper('ops/payment')
|
803 |
+
->getBaseGrandTotalFromSalesObject($order);
|
804 |
+
$voidAmount = $grandTotal - $alreadyCaptured;
|
805 |
+
$storeId = $order->getStoreId();
|
806 |
+
//Build void directLink-Request-Params
|
807 |
+
$requestParams = array(
|
808 |
+
'AMOUNT' => $this->getHelper()->getAmount($voidAmount),
|
809 |
+
'PAYID' => $payment->getAdditionalInformation('paymentId'),
|
810 |
+
'OPERATION' => self::OPS_DELETE_AUTHORIZE,
|
811 |
+
'CURRENCY' => Mage::app()->getStore($storeId)->getBaseCurrencyCode()
|
812 |
+
);
|
813 |
+
|
814 |
+
//Check if there is already a waiting void transaction, if yes: redirect to order view
|
815 |
+
if (Mage::helper('ops/directlink')->checkExistingTransact(
|
816 |
+
self::OPS_VOID_TRANSACTION_TYPE, $orderID
|
817 |
+
)
|
818 |
+
) {
|
819 |
+
$this->getHelper()->getAdminSession()->addError(
|
820 |
+
$this->getHelper()->__(
|
821 |
+
'You already sent a void request. Please wait until the void request will be acknowledged.'
|
822 |
+
)
|
823 |
+
);
|
824 |
+
|
825 |
+
return;
|
826 |
+
}
|
827 |
+
|
828 |
+
try {
|
829 |
+
//perform ops cancel request
|
830 |
+
$response = Mage::getSingleton('ops/api_directlink')
|
831 |
+
->performRequest(
|
832 |
+
$requestParams,
|
833 |
+
Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId),
|
834 |
+
$order->getStoreId()
|
835 |
+
);
|
836 |
+
|
837 |
+
if ($response['STATUS'] == Netresearch_OPS_Model_Status::INVALID_INCOMPLETE
|
838 |
+
&& $payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
|
839 |
+
) {
|
840 |
+
Mage::throwException(
|
841 |
+
$this->getHelper()->__('Order can no longer be voided. You have to refund the order online.')
|
842 |
+
);
|
843 |
+
}
|
844 |
+
|
845 |
+
|
846 |
+
$handler = Mage::getModel('ops/response_handler');
|
847 |
+
$handler->processResponse($response, $this, false);
|
848 |
+
|
849 |
+
|
850 |
+
return $this;
|
851 |
+
|
852 |
+
} catch (Exception $e) {
|
853 |
+
Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder());
|
854 |
+
Mage::helper('ops')->log(
|
855 |
+
"Exception in void request:" . $e->getMessage()
|
856 |
+
);
|
857 |
+
throw new Mage_Core_Exception($e->getMessage());
|
858 |
+
}
|
859 |
+
}
|
860 |
+
|
861 |
+
/**
|
862 |
+
* get question for fields with disputable value
|
863 |
+
* users are asked to correct the values before redirect to Acceptance
|
864 |
+
*
|
865 |
+
* @param Mage_Sales_Model_Order $order Current order
|
866 |
+
* @param array $requestParams Request parameters
|
867 |
+
*
|
868 |
+
* @return string
|
869 |
+
*/
|
870 |
+
public function getQuestion($order, $requestParams)
|
871 |
+
{
|
872 |
+
return '';
|
873 |
+
}
|
874 |
+
|
875 |
+
/**
|
876 |
+
* get an array of fields with disputable value
|
877 |
+
* users are asked to correct the values before redirect to Acceptance
|
878 |
+
*
|
879 |
+
* @param Mage_Sales_Model_Order $order Current order
|
880 |
+
* @param array $requestParams Request parameters
|
881 |
+
*
|
882 |
+
* @return array
|
883 |
+
*/
|
884 |
+
public function getQuestionedFormFields($quote, $requestParams)
|
885 |
+
{
|
886 |
+
return array();
|
887 |
+
}
|
888 |
+
|
889 |
+
/**
|
890 |
+
* if we need some missing form params
|
891 |
+
* users are asked to correct the values before redirect to Acceptance
|
892 |
+
*
|
893 |
+
* @param Mage_Sales_Model_Order $order
|
894 |
+
* @param array $requestParams Parameters sent in current request
|
895 |
+
* @param array $formFields Parameters to be sent to Acceptance
|
896 |
+
*
|
897 |
+
* @return bool
|
898 |
+
*/
|
899 |
+
public function hasFormMissingParams($order, $requestParams, $formFields = null)
|
900 |
+
{
|
901 |
+
if (false == is_array($requestParams)) {
|
902 |
+
$requestParams = array();
|
903 |
+
}
|
904 |
+
if (is_null($formFields)) {
|
905 |
+
$formFields = $this->getFormFields($order, $requestParams, false);
|
906 |
+
}
|
907 |
+
$availableParams = array_merge($requestParams, $formFields);
|
908 |
+
$requiredParams = $this->getQuestionedFormFields($order, $requestParams);
|
909 |
+
foreach ($requiredParams as $requiredParam) {
|
910 |
+
if (false == array_key_exists($requiredParam, $availableParams)
|
911 |
+
|| 0 == strlen($availableParams[$requiredParam])
|
912 |
+
) {
|
913 |
+
return true;
|
914 |
+
}
|
915 |
+
}
|
916 |
+
|
917 |
+
return false;
|
918 |
+
}
|
919 |
+
|
920 |
+
/**
|
921 |
+
* Check if order can be cancelled manually
|
922 |
+
*
|
923 |
+
* @param Mage_Sales_Model_Order $order
|
924 |
+
*
|
925 |
+
* @return bool
|
926 |
+
*/
|
927 |
+
public function canCancelManually($order)
|
928 |
+
{
|
929 |
+
$payment = $order->getPayment();
|
930 |
+
|
931 |
+
//If payment has Acceptance-status 0 or null (unknown) or another offline cancelable status
|
932 |
+
$status = $payment->getAdditionalInformation('status');
|
933 |
+
|
934 |
+
return is_null($status)
|
935 |
+
|| in_array(
|
936 |
+
$status, array(
|
937 |
+
Netresearch_OPS_Model_Status::INVALID_INCOMPLETE,
|
938 |
+
Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
|
939 |
+
Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
|
940 |
+
Netresearch_OPS_Model_Status::PAYMENT_DELETED
|
941 |
+
)
|
942 |
+
);
|
943 |
+
}
|
944 |
+
|
945 |
+
public function getOpsHtmlAnswer($payment = null)
|
946 |
+
{
|
947 |
+
$returnValue = '';
|
948 |
+
if (is_null($payment)) {
|
949 |
+
$quoteId = Mage::getSingleton('checkout/session')->getQuote()->getId();
|
950 |
+
if (is_null($quoteId)) {
|
951 |
+
$orderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
952 |
+
$order = Mage::getModel('sales/order')->loadByAttribute('increment_id', $orderIncrementId);
|
953 |
+
} else {
|
954 |
+
$order = Mage::getModel('sales/order')->loadByAttribute('quote_id', $quoteId);
|
955 |
+
}
|
956 |
+
if ($order instanceof Mage_Sales_Model_Order && 0 < $order->getId()) {
|
957 |
+
$payment = $order->getPayment();
|
958 |
+
$returnValue = $payment->getAdditionalInformation('HTML_ANSWER');
|
959 |
+
}
|
960 |
+
} elseif ($payment instanceof Mage_Payment_Model_Info) {
|
961 |
+
$returnValue = $payment->getAdditionalInformation('HTML_ANSWER');
|
962 |
+
}
|
963 |
+
|
964 |
+
return $returnValue;
|
965 |
+
}
|
966 |
+
|
967 |
+
public function getShippingTaxRate($order)
|
968 |
+
{
|
969 |
+
return $this->getRequestHelper()->getShippingTaxRate($order);
|
970 |
+
}
|
971 |
+
|
972 |
+
protected function isRedirectNoticed($orderId)
|
973 |
+
{
|
974 |
+
if (Mage::helper('ops/directlink')->checkExistingTransact(self::OPS_CAPTURE_TRANSACTION_TYPE, $orderId)) {
|
975 |
+
$this->getHelper()->redirectNoticed(
|
976 |
+
$orderId,
|
977 |
+
$this->getHelper()->__(
|
978 |
+
'You already sent a capture request. Please wait until the capture request is acknowledged.'
|
979 |
+
)
|
980 |
+
);
|
981 |
+
|
982 |
+
return true;
|
983 |
+
}
|
984 |
+
if (Mage::helper('ops/directlink')->checkExistingTransact(self::OPS_VOID_TRANSACTION_TYPE, $orderId)) {
|
985 |
+
$this->getHelper()->redirectNoticed(
|
986 |
+
$orderId,
|
987 |
+
$this->getHelper()->__(
|
988 |
+
'There is one void request waiting. Please wait until this request is acknowledged.'
|
989 |
+
)
|
990 |
+
);
|
991 |
+
|
992 |
+
return true;
|
993 |
+
}
|
994 |
+
|
995 |
+
return false;
|
996 |
+
}
|
997 |
+
|
998 |
+
public function setConfig(Netresearch_OPS_Model_Config $config)
|
999 |
+
{
|
1000 |
+
$this->_config = $config;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
/**
|
1004 |
+
* If cart Item information has to be transmitted to Acceptance
|
1005 |
+
*
|
1006 |
+
* @return bool
|
1007 |
+
*/
|
1008 |
+
|
1009 |
+
public function needsOrderItemDataForRequest()
|
1010 |
+
{
|
1011 |
+
return $this->_needsCartDataForRequest;
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
/**
|
1015 |
+
* Returns array with the order item data formatted in Acceptance fashion if payment method implementation
|
1016 |
+
* needs the data otherwise just returns false.
|
1017 |
+
*
|
1018 |
+
* @param Mage_Sales_Model_Order $order
|
1019 |
+
*
|
1020 |
+
* @return array|false
|
1021 |
+
*/
|
1022 |
+
public function getOrderItemData(Mage_Sales_Model_Order $order)
|
1023 |
+
{
|
1024 |
+
if (!$this->needsOrderItemDataForRequest()) {
|
1025 |
+
return false;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
return $this->getRequestHelper()->extractOrderItemParameters($order);
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
/**
|
1032 |
+
* @inheritDoc
|
1033 |
+
*/
|
1034 |
+
public function canVoid(Varien_Object $payment)
|
1035 |
+
{
|
1036 |
+
|
1037 |
+
if(Netresearch_OPS_Model_Status::canVoidTransaction($payment->getAdditionalInformation('status'))){
|
1038 |
+
return parent::canVoid($payment);
|
1039 |
+
} else {
|
1040 |
+
return false;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
/**
|
1046 |
+
* @inheritDoc
|
1047 |
+
*/
|
1048 |
+
public function assignData($data)
|
1049 |
+
{
|
1050 |
+
parent::assignData($data);
|
1051 |
+
|
1052 |
+
$paymentInfo = $this->getInfoInstance();
|
1053 |
+
if ($paymentInfo->getData($this->getCode())) {
|
1054 |
+
foreach ($paymentInfo->getData($this->getCode()) as $key => $value) {
|
1055 |
+
$paymentInfo->setAdditionalInformation($key, $value);
|
1056 |
+
}
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
return $this;
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
|
1063 |
+
/**
|
1064 |
+
* @inheritDoc
|
1065 |
+
*/
|
1066 |
+
public function validate()
|
1067 |
+
{
|
1068 |
+
|
1069 |
+
$paymentInfo = $this->getInfoInstance();
|
1070 |
+
if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
|
1071 |
+
$billingAddress = $paymentInfo->getOrder()->getBillingAddress();
|
1072 |
+
$shippingAddress = $paymentInfo->getOrder()->getShippingAddress();
|
1073 |
+
$salesObject = $paymentInfo->getOrder();
|
1074 |
+
} else {
|
1075 |
+
$salesObject = $paymentInfo->getQuote();
|
1076 |
+
$billingAddress = $salesObject->getBillingAddress();
|
1077 |
+
$shippingAddress = $salesObject->getShippingAddress();
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
$validator = Mage::getModel('ops/validator_parameter_factory')->getValidatorFor(
|
1081 |
+
Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
|
1082 |
+
);
|
1083 |
+
|
1084 |
+
$params = $this->getRequestHelper()->getOwnerParams($billingAddress, $salesObject);
|
1085 |
+
$billingParams = $this->getBillToParams($billingAddress);
|
1086 |
+
$shippingParams = $this->getShipToParams($shippingAddress);
|
1087 |
+
if($shippingParams) {
|
1088 |
+
$params = array_merge($params, $shippingParams);
|
1089 |
+
}
|
1090 |
+
if($billingParams){
|
1091 |
+
$params = array_merge($params, $billingParams);
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
if(false === $validator->isValid($params)){
|
1095 |
+
$result = Mage::helper('ops/validation_result')->getValidationFailedResult(
|
1096 |
+
$validator->getMessages(), $salesObject
|
1097 |
+
);
|
1098 |
+
throw new Mage_Payment_Exception('Validation failed', $result['fields']);
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
return parent::validate();
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
|
1105 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Backend/OpsId.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_Backend_OpsId
|
4 |
+
*
|
5 |
+
* @package OPS
|
6 |
+
* @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
|
7 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Backend_OpsId
|
11 |
+
extends Mage_Payment_Model_Method_Abstract
|
12 |
+
{
|
13 |
+
/* allow usage in Magento backend */
|
14 |
+
protected $_canUseInternal = true;
|
15 |
+
|
16 |
+
/* deny usage in Magento frontend */
|
17 |
+
protected $_canUseCheckout = false;
|
18 |
+
|
19 |
+
protected $_canBackendDirectCapture = true;
|
20 |
+
|
21 |
+
protected $_isGateway = false;
|
22 |
+
protected $_canAuthorize = false;
|
23 |
+
protected $_canCapture = true;
|
24 |
+
protected $_canCapturePartial = true;
|
25 |
+
protected $_canRefund = true;
|
26 |
+
protected $_canRefundInvoicePartial = true;
|
27 |
+
protected $_canVoid = true;
|
28 |
+
|
29 |
+
/** payment code */
|
30 |
+
protected $_code = 'ops_opsid';
|
31 |
+
|
32 |
+
protected $_formBlockType = 'ops/form_opsId';
|
33 |
+
|
34 |
+
protected $_infoBlockType = 'ops/info_opsId';
|
35 |
+
}
|
36 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Bancontact.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch OPS
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
16 |
+
* newer versions in the future.
|
17 |
+
*
|
18 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
19 |
+
* @license Open Software License (OSL 3.0)
|
20 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Netresearch_OPS_Model_Payment_BankContact
|
25 |
+
*
|
26 |
+
* @category Ingenico
|
27 |
+
* @package Netresearch_OPS
|
28 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Payment_Bancontact
|
31 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
32 |
+
{
|
33 |
+
protected $pm = 'CreditCard';
|
34 |
+
protected $brand = 'BCMC';
|
35 |
+
const CODE = 'ops_BCMC';
|
36 |
+
|
37 |
+
/** Check if we can capture directly from the backend */
|
38 |
+
protected $_canBackendDirectCapture = true;
|
39 |
+
|
40 |
+
/** info source path */
|
41 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
42 |
+
|
43 |
+
/** payment code */
|
44 |
+
protected $_code = self::CODE;
|
45 |
+
|
46 |
+
|
47 |
+
}
|
48 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/BankTransfer.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_BankTransfer
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_BankTransfer
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
/** Check if we can capture directly from the backend */
|
14 |
+
protected $_canBackendDirectCapture = true;
|
15 |
+
|
16 |
+
/** info source path */
|
17 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
18 |
+
|
19 |
+
/** payment code */
|
20 |
+
protected $_code = 'ops_bankTransfer';
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Assign data to info model instance
|
25 |
+
*
|
26 |
+
* @param mixed $data
|
27 |
+
* @return Mage_Payment_Model_Info
|
28 |
+
*/
|
29 |
+
public function assignData($data)
|
30 |
+
{
|
31 |
+
$countryId = '';
|
32 |
+
if (is_object($data) && $data instanceof Varien_Object) {
|
33 |
+
$countryId = $data->getCountryId();
|
34 |
+
} elseif (is_array($data) && isset($data['country_id'])) {
|
35 |
+
$countryId = $data['country_id'];
|
36 |
+
}
|
37 |
+
$pm = $brand = trim('Bank transfer' . (('*' == $countryId) ? '' : ' ' . $countryId));
|
38 |
+
|
39 |
+
$payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
40 |
+
$payment->setAdditionalInformation('PM', $pm);
|
41 |
+
$payment->setAdditionalInformation('BRAND', $brand);
|
42 |
+
|
43 |
+
parent::assignData($data);
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/BelfiusDirectNet.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_DexiaDirectNet
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_BelfiusDirectNet
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'Belfius Direct Net';
|
14 |
+
protected $brand = 'Belfius Direct Net';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_belfiusDirectNet';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/CashU.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_CashU
|
4 |
+
*
|
5 |
+
* @package OPS
|
6 |
+
* @copyright 2012 Netresearch App Factory AG <http://www.netresearch.de>
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_CashU
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'cashU';
|
14 |
+
protected $brand = 'cashU';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_cashU';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/CbcOnline.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_CbcOnline
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_CbcOnline
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'CBC Online';
|
14 |
+
protected $brand = 'CBC Online';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_cbcOnline';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Cc.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_Cc
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2011 Netresearch
|
8 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_Cc extends Netresearch_OPS_Model_Payment_DirectLink
|
12 |
+
{
|
13 |
+
const CODE = 'ops_cc';
|
14 |
+
|
15 |
+
/** info source path */
|
16 |
+
protected $_infoBlockType = 'ops/info_cc';
|
17 |
+
|
18 |
+
/** @var string $_formBlockType define a specific form block */
|
19 |
+
protected $_formBlockType = 'ops/form_cc';
|
20 |
+
|
21 |
+
/** payment code */
|
22 |
+
protected $_code = self::CODE;
|
23 |
+
|
24 |
+
protected $featureModel = null;
|
25 |
+
|
26 |
+
|
27 |
+
/** ops payment code */
|
28 |
+
public function getOpsCode($payment = null)
|
29 |
+
{
|
30 |
+
$opsBrand = $this->getOpsBrand($payment);
|
31 |
+
if ('PostFinance card' == $opsBrand) {
|
32 |
+
return 'PostFinance Card';
|
33 |
+
}
|
34 |
+
if ('UNEUROCOM' == $this->getOpsBrand($payment)) {
|
35 |
+
return 'UNEUROCOM';
|
36 |
+
}
|
37 |
+
|
38 |
+
return 'CreditCard';
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param null $payment
|
43 |
+
*
|
44 |
+
* @return array|mixed|null
|
45 |
+
*/
|
46 |
+
public function getOpsBrand($payment = null)
|
47 |
+
{
|
48 |
+
if (is_null($payment)) {
|
49 |
+
$payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
50 |
+
}
|
51 |
+
|
52 |
+
return $payment->getAdditionalInformation('CC_BRAND');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* If payment is inline there should be no orderPlaceRedirectUrl except for 3d secure cards - if order was placed
|
57 |
+
* through admin it is definitely an inline payment.
|
58 |
+
*
|
59 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
60 |
+
*
|
61 |
+
* @return bool|string
|
62 |
+
*/
|
63 |
+
public function getOrderPlaceRedirectUrl($payment = null)
|
64 |
+
{
|
65 |
+
$salesObject = $this->getInfoInstance()->getOrder() ? : $this->getInfoInstance()->getQuote();
|
66 |
+
if ($this->hasBrandAliasInterfaceSupport($payment) || is_null($salesObject->getRemoteIp())) {
|
67 |
+
if ('' == $this->getOpsHtmlAnswer($payment)) {
|
68 |
+
return false;
|
69 |
+
} // Prevent redirect on cc payment
|
70 |
+
else {
|
71 |
+
return $this->getConfig()->get3dSecureRedirectUrl();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return parent::getOrderPlaceRedirectUrl();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* only some brands are supported to be integrated into onepage checkout
|
80 |
+
*
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getBrandsForAliasInterface()
|
84 |
+
{
|
85 |
+
$brands = $this->getConfig()->getInlinePaymentCcTypes($this->getCode());
|
86 |
+
|
87 |
+
return $brands;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* if cc brand supports ops alias interface
|
92 |
+
*
|
93 |
+
* @param Mage_Payment_Model_Info $payment
|
94 |
+
*
|
95 |
+
* @return bool
|
96 |
+
*/
|
97 |
+
public function hasBrandAliasInterfaceSupport($payment = null)
|
98 |
+
{
|
99 |
+
return in_array(
|
100 |
+
$this->getOpsBrand($payment),
|
101 |
+
$this->getBrandsForAliasInterface()
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Validates alias for in quote provided addresses
|
107 |
+
*
|
108 |
+
* @param Mage_Sales_Model_Quote $quote
|
109 |
+
* @param Varien_Object $payment
|
110 |
+
*
|
111 |
+
* @throws Mage_Core_Exception
|
112 |
+
*/
|
113 |
+
protected function validateAlias($quote, $payment)
|
114 |
+
{
|
115 |
+
$alias = $payment->getAdditionalInformation('alias');
|
116 |
+
if (0 < strlen(trim($alias))
|
117 |
+
&& is_numeric($payment->getAdditionalInformation('cvc'))
|
118 |
+
&& false === Mage::helper('ops/alias')->isAliasValidForAddresses(
|
119 |
+
$quote->getCustomerId(),
|
120 |
+
$alias,
|
121 |
+
$quote->getBillingAddress(),
|
122 |
+
$quote->getShippingAddress(),
|
123 |
+
$quote->getStoreId()
|
124 |
+
)
|
125 |
+
) {
|
126 |
+
$this->getOnepage()->getCheckout()->setGotoSection('payment');
|
127 |
+
Mage::throwException(
|
128 |
+
$this->getHelper()->__('Invalid payment information provided!')
|
129 |
+
);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @return Netresearch_OPS_Helper_Creditcard
|
135 |
+
*/
|
136 |
+
public function getRequestParamsHelper()
|
137 |
+
{
|
138 |
+
if (null === $this->requestParamsHelper) {
|
139 |
+
$this->requestParamsHelper = Mage::helper('ops/creditcard');
|
140 |
+
}
|
141 |
+
|
142 |
+
return $this->requestParamsHelper;
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment,
|
147 |
+
$requestParams = array()
|
148 |
+
) {
|
149 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment, true);
|
150 |
+
if (true === Mage::getModel('ops/config')->isAliasManagerEnabled($this->getCode())) {
|
151 |
+
$this->validateAlias($quote, $payment);
|
152 |
+
}
|
153 |
+
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
protected function performPostDirectLinkCallAction(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order)
|
158 |
+
{
|
159 |
+
Mage::helper('ops/alias')->setAliasActive($quote, $order);
|
160 |
+
|
161 |
+
return $this;
|
162 |
+
}
|
163 |
+
|
164 |
+
protected function handleAdminPayment(Mage_Sales_Model_Quote $quote)
|
165 |
+
{
|
166 |
+
return $this;
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
/**
|
171 |
+
* returns allow zero amount authorization
|
172 |
+
* only TRUE if configured payment action for the store is authorize
|
173 |
+
*
|
174 |
+
* @param mixed null|int $storeId
|
175 |
+
*
|
176 |
+
* @return bool
|
177 |
+
*/
|
178 |
+
public function isZeroAmountAuthorizationAllowed($storeId = null)
|
179 |
+
{
|
180 |
+
$result = false;
|
181 |
+
if (
|
182 |
+
$this->getConfig()->getPaymentAction($storeId) == Netresearch_OPS_Model_Payment_Abstract::ACTION_AUTHORIZE
|
183 |
+
&& true == Mage::getStoreConfig('payment/ops_cc/zero_amount_checkout', $storeId)
|
184 |
+
) {
|
185 |
+
$result = true;
|
186 |
+
}
|
187 |
+
|
188 |
+
return $result;
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* method was implemented in CE 1.8 / EE 1.14
|
194 |
+
* if Version is CE 1.8 / EE 1.14 use parent method otherwise use our implementation
|
195 |
+
*
|
196 |
+
* @param Mage_Sales_Model_Quote $quote
|
197 |
+
* @param $checksBitMask
|
198 |
+
*
|
199 |
+
* @return bool
|
200 |
+
*/
|
201 |
+
public function isApplicableToQuote($quote, $checksBitMask)
|
202 |
+
{
|
203 |
+
$result = true;
|
204 |
+
if (Mage::helper('ops/version')->canUseApplicableForQuote(Mage::getEdition())) {
|
205 |
+
$result = parent::isApplicableToQuote($quote, $checksBitMask);
|
206 |
+
}
|
207 |
+
|
208 |
+
if ($quote->getBaseGrandTotal() < 0.01 && $result === false) {
|
209 |
+
$result = $this->getFeatureModel()->isCCAndZeroAmountAuthAllowed($this, $quote);
|
210 |
+
}
|
211 |
+
|
212 |
+
return $result;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @return Netresearch_OPS_Model_Payment_Features_ZeroAmountAuth
|
217 |
+
*/
|
218 |
+
public function getFeatureModel()
|
219 |
+
{
|
220 |
+
if (null === $this->featureModel) {
|
221 |
+
$this->featureModel = Mage::getModel('ops/payment_features_zeroAmountAuth');
|
222 |
+
}
|
223 |
+
|
224 |
+
return $this->featureModel;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* setter for canCapture from outside, needed for zero amount order since we need to disable online capture
|
229 |
+
* but still need to be able to create a invoice
|
230 |
+
*
|
231 |
+
* @param $canCapture
|
232 |
+
*/
|
233 |
+
public function setCanCapture($canCapture)
|
234 |
+
{
|
235 |
+
if ($this->_canCapture != $canCapture) {
|
236 |
+
$this->_canCapture = $canCapture;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Check wether payment method is available for quote
|
242 |
+
*
|
243 |
+
* @param Mage_Sales_Model_Quote $quote
|
244 |
+
*
|
245 |
+
* @return bool
|
246 |
+
*/
|
247 |
+
public function isAvailable($quote = null)
|
248 |
+
{
|
249 |
+
if (!is_null($quote) && !$quote->getItemsCount() > 0 && $this->getDataHelper()->isAdminSession()) {
|
250 |
+
/* Disable payment method in backend as long as there are no items in quote to
|
251 |
+
* avoid problems with alias creation in EE1.12 & EE1.13
|
252 |
+
*/
|
253 |
+
return false;
|
254 |
+
}
|
255 |
+
|
256 |
+
return parent::isAvailable($quote);
|
257 |
+
}
|
258 |
+
|
259 |
+
public function isInitializeNeeded()
|
260 |
+
{
|
261 |
+
return !$this->getPaymentHelper()->isInlinePayment($this->getInfoInstance());
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @inheritdoc
|
266 |
+
*/
|
267 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
268 |
+
{
|
269 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
270 |
+
if ($this->getConfig()->getCreditDebitSplit($order->getStoreId())) {
|
271 |
+
$formFields['CREDITDEBIT'] = "C";
|
272 |
+
}
|
273 |
+
|
274 |
+
return $formFields;
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/ChinaUnionPay.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch OPS
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
16 |
+
* newer versions in the future.
|
17 |
+
*
|
18 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
19 |
+
* @license Open Software License (OSL 3.0)
|
20 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Netresearch_OPS_Model_Payment_ChinaUnionPay
|
25 |
+
*
|
26 |
+
* @category Ingenico
|
27 |
+
* @package Netresearch_OPS
|
28 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Payment_ChinaUnionPay
|
31 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
32 |
+
{
|
33 |
+
protected $pm = 'PAYDOL_UPOP';
|
34 |
+
protected $brand = 'UnionPay';
|
35 |
+
const CODE = 'ops_chinaUnionPay';
|
36 |
+
|
37 |
+
/** Check if we can capture directly from the backend */
|
38 |
+
protected $_canBackendDirectCapture = true;
|
39 |
+
|
40 |
+
/** disable partial refund */
|
41 |
+
protected $_canRefundInvoicePartial = false;
|
42 |
+
|
43 |
+
/** disable partial capture */
|
44 |
+
protected $_canCapturePartial = false;
|
45 |
+
|
46 |
+
/** info source path */
|
47 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
48 |
+
|
49 |
+
/** payment code */
|
50 |
+
protected $_code = self::CODE;
|
51 |
+
|
52 |
+
public function getPaymentAction()
|
53 |
+
{
|
54 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Debitcard.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_Debitcard
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2016 Netresearch
|
8 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_Debitcard extends Netresearch_OPS_Model_Payment_Cc
|
12 |
+
{
|
13 |
+
|
14 |
+
/** payment code */
|
15 |
+
protected $_code = 'ops_dc';
|
16 |
+
|
17 |
+
|
18 |
+
/** ops payment code */
|
19 |
+
public function getOpsCode($payment = null)
|
20 |
+
{
|
21 |
+
return 'CreditCard';
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @inheritdoc
|
26 |
+
*/
|
27 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
28 |
+
{
|
29 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
30 |
+
if ($this->getConfig()->getCreditDebitSplit($order->getStoreId())) {
|
31 |
+
$formFields['CREDITDEBIT'] = "D";
|
32 |
+
}
|
33 |
+
|
34 |
+
return $formFields;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return Netresearch_OPS_Helper_Debitcard
|
39 |
+
*/
|
40 |
+
public function getRequestParamsHelper()
|
41 |
+
{
|
42 |
+
if (null === $this->requestParamsHelper) {
|
43 |
+
$this->requestParamsHelper = Mage::helper('ops/debitcard');
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this->requestParamsHelper;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
}
|
51 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/DirectDebit.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_DirectDebit
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_DirectDebit
|
11 |
+
extends Netresearch_OPS_Model_Payment_DirectLink
|
12 |
+
{
|
13 |
+
/** info source path */
|
14 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
15 |
+
|
16 |
+
/* define a specific form block */
|
17 |
+
protected $_formBlockType = 'ops/form_directDebit';
|
18 |
+
|
19 |
+
/** payment code */
|
20 |
+
protected $_code = 'ops_directDebit';
|
21 |
+
|
22 |
+
public function getOrderPlaceRedirectUrl()
|
23 |
+
{
|
24 |
+
// Prevent redirect on direct debit payment
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Netresearch_OPS_Helper_DirectDebit
|
31 |
+
*/
|
32 |
+
public function getRequestParamsHelper()
|
33 |
+
{
|
34 |
+
if (null === $this->requestParamsHelper) {
|
35 |
+
$this->requestParamsHelper = Mage::helper('ops/directDebit');
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->requestParamsHelper;
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment, $requestParams = array())
|
42 |
+
{
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function performPostDirectLinkCallAction(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order)
|
47 |
+
{
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function handleAdminPayment(Mage_Sales_Model_Quote $quote)
|
52 |
+
{
|
53 |
+
$directDebitHelper = Mage::helper('ops/directDebit');
|
54 |
+
$requestParams = Mage::app()->getRequest()->getParam('ops_directDebit');
|
55 |
+
$directDebitHelper->handleAdminPayment($quote, $requestParams);
|
56 |
+
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/DirectEbanking.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_DirectEbanking
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_DirectEbanking
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
/** Check if we can capture directly from the backend */
|
14 |
+
protected $_canBackendDirectCapture = true;
|
15 |
+
|
16 |
+
/** info source path */
|
17 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
18 |
+
|
19 |
+
/** payment code */
|
20 |
+
protected $_code = 'ops_directEbanking';
|
21 |
+
|
22 |
+
|
23 |
+
protected function getPayment()
|
24 |
+
{
|
25 |
+
$checkout = Mage::getSingleton('checkout/session');
|
26 |
+
$payment = $checkout->getQuote()->getPayment();
|
27 |
+
if (!$payment->getId()) {
|
28 |
+
$payment = Mage::getModel('sales/order')->loadByIncrementId($checkout->getLastRealOrderId())->getPayment();
|
29 |
+
}
|
30 |
+
return $payment;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Assign data to info model instance
|
35 |
+
*
|
36 |
+
* @param mixed $data
|
37 |
+
* @return Mage_Payment_Model_Info
|
38 |
+
*/
|
39 |
+
public function assignData($data)
|
40 |
+
{
|
41 |
+
$brand = '';
|
42 |
+
|
43 |
+
if (is_object($data) && $data instanceof Varien_Object) {
|
44 |
+
$brand = $data['directEbanking_brand'];
|
45 |
+
} elseif (is_array($data) && isset($data['directEbanking_brand'])) {
|
46 |
+
|
47 |
+
$brand = $data['directEbanking_brand'];
|
48 |
+
}
|
49 |
+
|
50 |
+
$brand = $this->fixSofortUberweisungBrand($brand);
|
51 |
+
|
52 |
+
$payment = $this->getInfoInstance();
|
53 |
+
// brand == pm for all DirectEbanking methods
|
54 |
+
$payment->setAdditionalInformation('PM', $brand);
|
55 |
+
$payment->setAdditionalInformation('BRAND', $brand);
|
56 |
+
parent::assignData($data);
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Fixes legacy brand value of Sofort Uberweisung for DirectEbanking
|
63 |
+
*
|
64 |
+
* @param string $value
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
protected function fixSofortUberweisungBrand($value){
|
68 |
+
if($value === 'Sofort Uberweisung'){
|
69 |
+
return 'DirectEbanking';
|
70 |
+
}
|
71 |
+
return $value;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/DirectLink.php
ADDED
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
abstract class Netresearch_OPS_Model_Payment_DirectLink extends Netresearch_OPS_Model_Payment_Abstract
|
10 |
+
{
|
11 |
+
/** Check if we can capture directly from the backend */
|
12 |
+
protected $_canBackendDirectCapture = true;
|
13 |
+
|
14 |
+
/** Check if we can capture directly from the backend */
|
15 |
+
protected $_canUseInternal = true;
|
16 |
+
|
17 |
+
protected $config = null;
|
18 |
+
|
19 |
+
protected $directLinkHelper = null;
|
20 |
+
|
21 |
+
protected $paymentHelper = null;
|
22 |
+
|
23 |
+
protected $quoteHelper = null;
|
24 |
+
|
25 |
+
protected $requestParamsHelper = null;
|
26 |
+
|
27 |
+
protected $validationFactory = null;
|
28 |
+
|
29 |
+
protected $dataHelper = null;
|
30 |
+
|
31 |
+
protected $_isInitializeNeeded = false;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface $requestParamsHelper
|
35 |
+
*/
|
36 |
+
public function setRequestParamsHelper($requestParamsHelper)
|
37 |
+
{
|
38 |
+
$this->requestParamsHelper = $requestParamsHelper;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* sets the quote helper
|
44 |
+
*
|
45 |
+
* @param Netresearch_OPS_Helper_Quote $quoteHelper
|
46 |
+
*/
|
47 |
+
public function setQuoteHelper(Netresearch_OPS_Helper_Quote $quoteHelper)
|
48 |
+
{
|
49 |
+
$this->quoteHelper = $quoteHelper;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* gets the quote helper
|
54 |
+
*
|
55 |
+
* @return Netresearch_OPS_Helper_Quote
|
56 |
+
*/
|
57 |
+
public function getQuoteHelper()
|
58 |
+
{
|
59 |
+
if (null === $this->quoteHelper) {
|
60 |
+
$this->quoteHelper = Mage::helper('ops/quote');
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this->quoteHelper;
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param Netresearch_OPS_Helper_Directlink $directLinkHelper
|
69 |
+
*/
|
70 |
+
public function setDirectLinkHelper($directLinkHelper)
|
71 |
+
{
|
72 |
+
$this->directLinkHelper = $directLinkHelper;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return Netresearch_OPS_Helper_Directlink
|
77 |
+
*/
|
78 |
+
public function getDirectLinkHelper()
|
79 |
+
{
|
80 |
+
if (null === $this->directLinkHelper) {
|
81 |
+
$this->directLinkHelper = MAge::helper('ops/directlink');
|
82 |
+
}
|
83 |
+
|
84 |
+
return $this->directLinkHelper;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param Netresearch_OPS_Helper_Payment $paymentHelper
|
89 |
+
*/
|
90 |
+
public function setPaymentHelper($paymentHelper)
|
91 |
+
{
|
92 |
+
$this->paymentHelper = $paymentHelper;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @return Netresearch_OPS_Helper_Payment
|
97 |
+
*/
|
98 |
+
public function getPaymentHelper()
|
99 |
+
{
|
100 |
+
if (null === $this->paymentHelper) {
|
101 |
+
$this->paymentHelper = Mage::helper('ops/payment');
|
102 |
+
}
|
103 |
+
|
104 |
+
return $this->paymentHelper;
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param null $config
|
110 |
+
*/
|
111 |
+
public function setConfig(Netresearch_OPS_Model_Config $config)
|
112 |
+
{
|
113 |
+
$this->config = $config;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @return Netresearch_OPS_Model_Config
|
118 |
+
*/
|
119 |
+
public function getConfig()
|
120 |
+
{
|
121 |
+
if (null === $this->config) {
|
122 |
+
$this->config = Mage::getModel('ops/config');
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this->config;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @param Varien_Object $payment
|
130 |
+
* @param float $amount
|
131 |
+
*
|
132 |
+
* @return Mage_Payment_Model_Abstract|void
|
133 |
+
*/
|
134 |
+
|
135 |
+
public function authorize(Varien_Object $payment, $amount)
|
136 |
+
{
|
137 |
+
if ($this->isInlinePayment($payment)
|
138 |
+
&& Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE == $this->getConfigPaymentAction()
|
139 |
+
) {
|
140 |
+
$order = $payment->getOrder();
|
141 |
+
$quote = $this->getQuoteHelper()->getQuote();
|
142 |
+
$this->confirmPayment($order, $quote, $payment);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Saves the payment model and runs the request to Acceptances webservice
|
148 |
+
*
|
149 |
+
* @param Mage_Sales_Model_Order $order
|
150 |
+
* @param Mage_Sales_Model_Quote $quote
|
151 |
+
* @param Varien_Object $payment
|
152 |
+
*
|
153 |
+
* @throws Mage_Core_Exception
|
154 |
+
*/
|
155 |
+
|
156 |
+
protected function confirmPayment(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote,
|
157 |
+
Varien_Object $payment
|
158 |
+
) {
|
159 |
+
$this->handleAdminPayment($quote);
|
160 |
+
$requestParams = $this->getRequestParamsHelper()->getDirectLinkRequestParams($quote, $order, $payment);
|
161 |
+
$this->invokeRequestParamValidation($requestParams);
|
162 |
+
$this->performPreDirectLinkCallActions($quote, $order);
|
163 |
+
$response = $this->getDirectLinkHelper()->performDirectLinkRequest(
|
164 |
+
$quote, $requestParams, $quote->getStoreId()
|
165 |
+
);
|
166 |
+
if ($response) {
|
167 |
+
$handler = Mage::getModel('ops/response_handler');
|
168 |
+
$handler->processResponse($response, $this, false);
|
169 |
+
$this->performPostDirectLinkCallAction($quote, $order);
|
170 |
+
|
171 |
+
} else {
|
172 |
+
$this->getPaymentHelper()->handleUnknownStatus($order);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Handles backend payments on Magento side
|
178 |
+
*
|
179 |
+
* @param Mage_Sales_Model_Quote $quote
|
180 |
+
*
|
181 |
+
* @return Netresearch_OPS_Model_Payment_DirectLink
|
182 |
+
*/
|
183 |
+
abstract protected function handleAdminPayment(Mage_Sales_Model_Quote $quote);
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @return Netresearch_OPS_Helper_Payment_DirectLink_RequestInterface
|
187 |
+
*/
|
188 |
+
abstract protected function getRequestParamsHelper();
|
189 |
+
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Perform necessary preparation before request to Acceptance is sent
|
193 |
+
*
|
194 |
+
* @param Mage_Sales_Model_Quote $quote
|
195 |
+
* @param Varien_Object $payment
|
196 |
+
* @param array $requestParams
|
197 |
+
*
|
198 |
+
* @return Netresearch_OPS_Model_Payment_DirectLink
|
199 |
+
*/
|
200 |
+
abstract protected function performPreDirectLinkCallActions(Mage_Sales_Model_Quote $quote, Varien_Object $payment,
|
201 |
+
$requestParams = array()
|
202 |
+
);
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Perform necessary work after the Directlink Request was sent and an response was received and processed
|
206 |
+
*
|
207 |
+
* @param Mage_Sales_Model_Quote $quote
|
208 |
+
* @param Mage_Sales_Model_Order $order
|
209 |
+
*
|
210 |
+
* @return Netresearch_OPS_Model_Payment_DirectLink
|
211 |
+
*/
|
212 |
+
abstract protected function performPostDirectLinkCallAction(Mage_Sales_Model_Quote $quote,
|
213 |
+
Mage_Sales_Model_Order $order
|
214 |
+
);
|
215 |
+
|
216 |
+
|
217 |
+
/**
|
218 |
+
* performs direct link request either for inline payments and direct sale mode or the normal maintenance call (invoice)
|
219 |
+
*
|
220 |
+
* @override
|
221 |
+
*
|
222 |
+
* @param Varien_Object $payment
|
223 |
+
* @param float $amount
|
224 |
+
*
|
225 |
+
* @return Mage_Payment_Model_Abstract|void
|
226 |
+
*/
|
227 |
+
public function capture(Varien_Object $payment, $amount)
|
228 |
+
{
|
229 |
+
/**
|
230 |
+
* process direct sale inline payments (initial request)
|
231 |
+
*/
|
232 |
+
if (Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE == $this->getConfigPaymentAction()
|
233 |
+
&& $this->getPaymentHelper()->isInlinePayment($payment)
|
234 |
+
) {
|
235 |
+
$order = $payment->getOrder();
|
236 |
+
$quote = $this->getQuoteHelper()->getQuote();
|
237 |
+
$this->confirmPayment($order, $quote, $payment);
|
238 |
+
} /**
|
239 |
+
* invoice request authorize mode if the payment was placed on Acceptance side
|
240 |
+
*/
|
241 |
+
elseif (0 < strlen(trim($payment->getAdditionalInformation('paymentId')))) {
|
242 |
+
parent::capture($payment, $amount);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
|
247 |
+
/**
|
248 |
+
* checks if the selected payment supports inline mode
|
249 |
+
*
|
250 |
+
* @param $payment - the payment to check
|
251 |
+
*
|
252 |
+
* @return bool - true if it's support inline mode, false otherwise
|
253 |
+
*/
|
254 |
+
protected function isInlinePayment($payment)
|
255 |
+
{
|
256 |
+
$result = false;
|
257 |
+
|
258 |
+
$methodInstance = $payment->getMethodInstance();
|
259 |
+
if ((
|
260 |
+
$methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
|
261 |
+
&& $methodInstance->hasBrandAliasInterfaceSupport($payment)
|
262 |
+
|| $this->getDataHelper()->isAdminSession()
|
263 |
+
)
|
264 |
+
|| $methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit
|
265 |
+
) {
|
266 |
+
$result = true;
|
267 |
+
}
|
268 |
+
|
269 |
+
return $result;
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Get one page checkout model
|
275 |
+
*
|
276 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
277 |
+
*/
|
278 |
+
public function getOnepage()
|
279 |
+
{
|
280 |
+
return Mage::getSingleton('checkout/type_onepage');
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Validate checkout request parameters
|
285 |
+
*
|
286 |
+
* @param $requestParams
|
287 |
+
*
|
288 |
+
* @throws Mage_Core_Exception
|
289 |
+
* @return Netresearch_OPS_Model_Payment_DirectLink
|
290 |
+
*/
|
291 |
+
protected function invokeRequestParamValidation($requestParams)
|
292 |
+
{
|
293 |
+
$validator = $this->getValidationFactory()->getValidatorFor(
|
294 |
+
Netresearch_OPS_Model_Validator_Parameter_Factory::TYPE_REQUEST_PARAMS_VALIDATION
|
295 |
+
);
|
296 |
+
if (false == $validator->isValid($requestParams)) {
|
297 |
+
$this->getOnepage()->getCheckout()->setGotoSection('payment');
|
298 |
+
Mage::throwException(
|
299 |
+
$this->getHelper()->__('The data you have provided can not be processed by Acceptance')
|
300 |
+
);
|
301 |
+
}
|
302 |
+
|
303 |
+
return $this;
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* @return Netresearch_OPS_Model_Validator_Parameter_Factory
|
308 |
+
*/
|
309 |
+
public function getValidationFactory()
|
310 |
+
{
|
311 |
+
if (null === $this->validationFactory) {
|
312 |
+
$this->validationFactory = Mage::getModel('ops/validator_parameter_factory');
|
313 |
+
}
|
314 |
+
|
315 |
+
return $this->validationFactory;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* sets the used validation factory
|
320 |
+
*
|
321 |
+
* @param Netresearch_OPS_Model_Validator_Parameter_Factory $validationFactory
|
322 |
+
*/
|
323 |
+
public function setValidationFactory(Netresearch_OPS_Model_Validator_Parameter_Factory $validationFactory)
|
324 |
+
{
|
325 |
+
$this->validationFactory = $validationFactory;
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
330 |
+
*/
|
331 |
+
public function setDataHelper(Netresearch_OPS_Helper_Data $dataHelper)
|
332 |
+
{
|
333 |
+
$this->dataHelper = $dataHelper;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* @return Netresearch_OPS_Helper_Data
|
338 |
+
*/
|
339 |
+
public function getDataHelper()
|
340 |
+
{
|
341 |
+
if (null === $this->dataHelper) {
|
342 |
+
$this->dataHelper = Mage::helper('ops/data');
|
343 |
+
}
|
344 |
+
|
345 |
+
return $this->dataHelper;
|
346 |
+
}
|
347 |
+
|
348 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/EDankort.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_EDankort
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_EDankort
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'eDankort';
|
14 |
+
protected $brand = 'eDankort';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_eDankort';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Eps.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_Eps
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Eps
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'EPS';
|
14 |
+
protected $brand = 'EPS';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_eps';
|
24 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Features/PaymentEmail.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Implements functionality to send Acceptance specific mails
|
24 |
+
*
|
25 |
+
* @category Payment method
|
26 |
+
* @package Netresearch OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
class Netresearch_OPS_Model_Payment_Features_PaymentEmail
|
30 |
+
{
|
31 |
+
|
32 |
+
protected function getConfig()
|
33 |
+
{
|
34 |
+
return Mage::getModel('ops/config');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check if payment email is available for order
|
39 |
+
*
|
40 |
+
* @param $order
|
41 |
+
*
|
42 |
+
* @return bool
|
43 |
+
*/
|
44 |
+
public function isAvailableForOrder($order)
|
45 |
+
{
|
46 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
47 |
+
$status = $order->getPayment()->getAdditionalInformation('status');
|
48 |
+
|
49 |
+
return Netresearch_OPS_Model_Status::canResendPaymentInfo($status);
|
50 |
+
}
|
51 |
+
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Resends the payment information and returns true/false, depending if succeeded or not
|
58 |
+
*
|
59 |
+
* @param Mage_Sales_Model_Order $order
|
60 |
+
*
|
61 |
+
* @return boolean success state
|
62 |
+
*/
|
63 |
+
public function resendPaymentInfo(Mage_Sales_Model_Order $order)
|
64 |
+
{
|
65 |
+
|
66 |
+
// reset payment method so the customer can choose freely from all available methods
|
67 |
+
$this->setPaymentMethodToGeneric($order);
|
68 |
+
|
69 |
+
|
70 |
+
$identity = $this->getIdentity($this->getConfig()->getResendPaymentInfoIdentity($order->getStoreId()));
|
71 |
+
|
72 |
+
$emailTemplate = $this->prepareTemplate(
|
73 |
+
$this->getConfig()->getResendPaymentInfoTemplate($order->getStoreId()),
|
74 |
+
$identity->getEmail(),
|
75 |
+
$identity->getName()
|
76 |
+
);
|
77 |
+
|
78 |
+
$parameters = array(
|
79 |
+
"order" => $order,
|
80 |
+
"paymentLink" => $this->generatePaymentLink($order),
|
81 |
+
"store" => Mage::app()->getStore($order->getStoreId())
|
82 |
+
);
|
83 |
+
|
84 |
+
return $emailTemplate->send($order->getCustomerEmail(), $order->getCustomerName(), $parameters);
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Generates the payment url
|
90 |
+
*
|
91 |
+
* @param Mage_Sales_Model_Order $order
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
protected function generatePaymentLink(Mage_Sales_Model_Order $order)
|
96 |
+
{
|
97 |
+
$opsOrderId = Mage::helper('ops/order')->getOpsOrderId($order);
|
98 |
+
|
99 |
+
$params = array(
|
100 |
+
'orderID' => $opsOrderId
|
101 |
+
);
|
102 |
+
|
103 |
+
$secret = $this->getConfig()->getShaInCode($order->getStoreId());
|
104 |
+
$raw = Mage::helper('ops/payment')->getSHAInSet($params, $secret);
|
105 |
+
|
106 |
+
$params['SHASIGN'] = strtoupper(Mage::helper('ops/payment')->shaCrypt($raw));
|
107 |
+
|
108 |
+
$url = Mage::getModel('ops/config')->getPaymentRetryUrl($params, $order->getStoreId());
|
109 |
+
|
110 |
+
return $url;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Set payment method to Netresearch_OPS_Model_Payment_Flex
|
115 |
+
*
|
116 |
+
* @param Mage_Sales_Model_Order $order
|
117 |
+
*
|
118 |
+
* @throws Exception
|
119 |
+
*/
|
120 |
+
protected function setPaymentMethodToGeneric(Mage_Sales_Model_Order $order)
|
121 |
+
{
|
122 |
+
$order->getPayment()->setMethod(Netresearch_OPS_Model_Payment_Flex::CODE)->save();
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Sends suspend subscription mail to configured store contact via configured mail template
|
127 |
+
*
|
128 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
129 |
+
* @param Mage_Customer_Model_Customer $customer
|
130 |
+
*
|
131 |
+
* @return bool
|
132 |
+
*/
|
133 |
+
public function sendSuspendSubscriptionMail($profile, $customer)
|
134 |
+
{
|
135 |
+
if (is_null($profile) || is_null($customer)) {
|
136 |
+
Mage::throwException('Could not send mail due to internal error!');
|
137 |
+
}
|
138 |
+
|
139 |
+
$emailTemplate = $this->prepareTemplate(
|
140 |
+
$this->getConfig()->getSuspendSubscriptionTemplate($profile->getStoreId()),
|
141 |
+
$customer->getEmail(),
|
142 |
+
$customer->getName()
|
143 |
+
);
|
144 |
+
|
145 |
+
$emailTemplate->addBcc($customer->getEmail());
|
146 |
+
|
147 |
+
$parameters = array(
|
148 |
+
"profile" => $profile,
|
149 |
+
"customer" => $customer,
|
150 |
+
"store" => Mage::app()->getStore($profile->getStoreId())
|
151 |
+
);
|
152 |
+
|
153 |
+
$identity = $this->getIdentity($this->getConfig()->getSuspendSubscriptionIdentity($profile->getStoreId()));
|
154 |
+
|
155 |
+
return $emailTemplate->send($identity->getEmail(), $identity->getName(), $parameters);
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Loads email and name of the given store identity
|
162 |
+
*
|
163 |
+
* @param string $key - identity to load, defaults to sales
|
164 |
+
*
|
165 |
+
* @return Varien_Object with data name and email
|
166 |
+
*/
|
167 |
+
protected function getIdentity($key = 'sales')
|
168 |
+
{
|
169 |
+
$identity = new Varien_Object();
|
170 |
+
$identity->setName(Mage::getStoreConfig('trans_email/ident_' . $key . '/name'))
|
171 |
+
->setEmail(Mage::getStoreConfig('trans_email/ident_' . $key . '/email'));
|
172 |
+
|
173 |
+
return $identity;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Loads the given template by identifier, sets sender mail and name
|
178 |
+
*
|
179 |
+
* @param string $template
|
180 |
+
* @param string $senderMail
|
181 |
+
* @param string $senderName
|
182 |
+
*
|
183 |
+
* @return Mage_Core_Model_Email_Template
|
184 |
+
*/
|
185 |
+
protected function prepareTemplate($template, $senderMail, $senderName)
|
186 |
+
{
|
187 |
+
$emailTemplate = Mage::getModel('core/email_template')->load($template);
|
188 |
+
if (is_null($emailTemplate->getTemplateSubject())) {
|
189 |
+
$emailTemplate = $emailTemplate->loadDefault($template);
|
190 |
+
}
|
191 |
+
$emailTemplate->setSenderName($senderName)
|
192 |
+
->setSenderEmail($senderMail);
|
193 |
+
|
194 |
+
return $emailTemplate;
|
195 |
+
}
|
196 |
+
|
197 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Features/ZeroAmountAuth.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_Features_ZeroAmountAuth
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2014 Netresearch
|
8 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_Features_ZeroAmountAuth
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* check if payment method is cc and zero amount authorization is enabled
|
16 |
+
*
|
17 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod
|
18 |
+
*
|
19 |
+
* @return bool
|
20 |
+
*/
|
21 |
+
public function isCCAndZeroAmountAuthAllowed(
|
22 |
+
Netresearch_OPS_Model_Payment_Abstract $opsPaymentMethod,
|
23 |
+
Mage_Sales_Model_Quote $quote
|
24 |
+
) {
|
25 |
+
$result = false;
|
26 |
+
$storeId = $quote->getStoreId();
|
27 |
+
if ($quote->getBaseGrandTotal() < 0.01
|
28 |
+
&& $opsPaymentMethod instanceof Netresearch_OPS_Model_Payment_Cc
|
29 |
+
&& $opsPaymentMethod->isZeroAmountAuthorizationAllowed($storeId)
|
30 |
+
&& 0 < $quote->getItemsCount()
|
31 |
+
&& !$quote->isNominal()
|
32 |
+
|
33 |
+
) {
|
34 |
+
$result = true;
|
35 |
+
}
|
36 |
+
|
37 |
+
return $result;
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Flex.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Flex.php
|
5 |
+
*
|
6 |
+
* @author paul.siedler@netresearch.de
|
7 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Flex extends Netresearch_OPS_Model_Payment_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
const CODE = 'ops_flex';
|
14 |
+
|
15 |
+
const INFO_KEY_TITLE = 'flex_title';
|
16 |
+
const INFO_KEY_PM = 'flex_pm';
|
17 |
+
const INFO_KEY_BRAND = 'flex_brand';
|
18 |
+
|
19 |
+
/** Check if we can capture directly from the backend */
|
20 |
+
protected $_canBackendDirectCapture = true;
|
21 |
+
|
22 |
+
/** info source path */
|
23 |
+
protected $_infoBlockType = 'ops/info_flex';
|
24 |
+
|
25 |
+
protected $_formBlockType = 'ops/form_flex';
|
26 |
+
|
27 |
+
/** payment code */
|
28 |
+
protected $_code = self::CODE;
|
29 |
+
|
30 |
+
protected $_needsCartDataForRequest = true;
|
31 |
+
|
32 |
+
public function getOpsCode($payment = null)
|
33 |
+
{
|
34 |
+
return $this->getInfoInstance()->getAdditionalInformation(self::INFO_KEY_PM);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getOpsBrand($payment = null)
|
38 |
+
{
|
39 |
+
return $this->getInfoInstance()->getAdditionalInformation(self::INFO_KEY_BRAND);
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/FortisPayButton.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_FortisPayButton
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_FortisPayButton
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'Fortis Pay Button';
|
14 |
+
protected $brand = 'Fortis Pay Button';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_fortisPayButton';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/GiroPay.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_GiroPay
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_GiroPay
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'giropay';
|
14 |
+
protected $brand = 'giropay';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_giroPay';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/IDeal.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_IDeal
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2011 Netresearch
|
8 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_IDeal
|
12 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
13 |
+
{
|
14 |
+
protected $pm = 'iDEAL';
|
15 |
+
protected $brand = 'iDEAL';
|
16 |
+
|
17 |
+
/** Check if we can capture directly from the backend */
|
18 |
+
protected $_canBackendDirectCapture = true;
|
19 |
+
|
20 |
+
/** info source path */
|
21 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
22 |
+
|
23 |
+
protected $_formBlockType = 'ops/form_ideal';
|
24 |
+
|
25 |
+
/** payment code */
|
26 |
+
protected $_code = 'ops_iDeal';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* adds payment specific information to the payment
|
30 |
+
*
|
31 |
+
* @param mixed $data - data containing the issuer id which should be used
|
32 |
+
*
|
33 |
+
* @return Netresearch_OPS_Model_Payment_IDeal
|
34 |
+
*/
|
35 |
+
public function assignData($data)
|
36 |
+
{
|
37 |
+
if ($data instanceof Varien_Object) {
|
38 |
+
$data = $data->getData();
|
39 |
+
}
|
40 |
+
if (array_key_exists('iDeal_issuer_id', $data)) {
|
41 |
+
$payment = Mage::getSingleton('checkout/session')
|
42 |
+
->getQuote()
|
43 |
+
->getPayment();
|
44 |
+
$payment
|
45 |
+
->setAdditionalInformation('iDeal_issuer_id', $data['iDeal_issuer_id']);
|
46 |
+
}
|
47 |
+
parent::assignData($data);
|
48 |
+
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* getter for the iDeal issuers
|
54 |
+
*
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
public function getIDealIssuers()
|
58 |
+
{
|
59 |
+
return Mage::getStoreConfig('payment/ops_iDeal/issuer');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* add iDeal issuer id to form fields
|
64 |
+
*
|
65 |
+
* @override Netresearch_OPS_Model_Payment_Abstract
|
66 |
+
*
|
67 |
+
* @param $order
|
68 |
+
* @param null $requestParams
|
69 |
+
*
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
73 |
+
{
|
74 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
75 |
+
if ($order->getPayment()->getAdditionalInformation('iDeal_issuer_id')) {
|
76 |
+
$formFields['ISSUERID'] = $order->getPayment()->getAdditionalInformation('iDeal_issuer_id');
|
77 |
+
}
|
78 |
+
|
79 |
+
return $formFields;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/IngHomePay.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_IngHomePay
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_IngHomePay
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'ING HomePay';
|
14 |
+
protected $brand = 'ING HomePay';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_ingHomePay';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/InterSolve.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_InterSolve
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_InterSolve
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'InterSolve';
|
14 |
+
protected $brand = 'InterSolve';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
protected $_formBlockType = 'ops/form_interSolve';
|
22 |
+
|
23 |
+
/** payment code */
|
24 |
+
protected $_code = 'ops_interSolve';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Assign data to info model instance
|
28 |
+
*
|
29 |
+
* @param mixed $data
|
30 |
+
* @return Mage_Payment_Model_Info
|
31 |
+
*/
|
32 |
+
public function assignData($data)
|
33 |
+
{
|
34 |
+
|
35 |
+
$brand = '';
|
36 |
+
if (is_object($data) && $data instanceof Varien_Object) {
|
37 |
+
$brand = $data->getIntersolveBrand();
|
38 |
+
} elseif (is_array($data) && isset($data['intersolve_brand'])) {
|
39 |
+
$brand = $data['intersolve_brand'];
|
40 |
+
}
|
41 |
+
if (strlen(trim($brand)) === 0) {
|
42 |
+
$brand = 'InterSolve';
|
43 |
+
}
|
44 |
+
$payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
45 |
+
$payment->setAdditionalInformation('BRAND', $brand);
|
46 |
+
|
47 |
+
parent::assignData($data);
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/KbcOnline.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_KbcOnline
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_KbcOnline
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'KBC Online';
|
14 |
+
protected $brand = 'KBC Online';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_kbcOnline';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Kwixo/Abstract.php
ADDED
@@ -0,0 +1,613 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Netresearch_OPS
|
24 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc.
|
25 |
+
* DBA Varien (http://www.varien.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php
|
27 |
+
* Open Software License (OSL 3.0)
|
28 |
+
*/
|
29 |
+
class Netresearch_OPS_Model_Payment_Kwixo_Abstract
|
30 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
31 |
+
{
|
32 |
+
|
33 |
+
private $kwixoShippingModel = null;
|
34 |
+
|
35 |
+
private $shippingSettings = null;
|
36 |
+
|
37 |
+
/**
|
38 |
+
*
|
39 |
+
* @param Mage_Sales_Model_Order $order
|
40 |
+
* @param array $requestParams
|
41 |
+
*/
|
42 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
43 |
+
{
|
44 |
+
$formFields = parent::getMethodDependendFormFields(
|
45 |
+
$order, $requestParams
|
46 |
+
);
|
47 |
+
unset($formFields['OWNERADDRESS']);
|
48 |
+
unset($formFields['OWNERTELNO']);
|
49 |
+
unset($formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1']);
|
50 |
+
$shippingMethod = 'none';
|
51 |
+
$isVirtual = true;
|
52 |
+
if ($order->getShippingAddress()) {
|
53 |
+
$isVirtual = false;
|
54 |
+
$carrierCode = $order->getShippingCarrier()->getCarrierCode();
|
55 |
+
$this->loadShippingSettingForCarrierCode($carrierCode);
|
56 |
+
$shippingMethod = $carrierCode;
|
57 |
+
}
|
58 |
+
|
59 |
+
$formFields['ECOM_ESTIMATEDELIVERYDATE']
|
60 |
+
= $this->getEstimatedDeliveryDate(
|
61 |
+
$this->getCode(), $order->getStoreId()
|
62 |
+
);
|
63 |
+
$formFields['RNPOFFERT'] = $this->getRnpFee(
|
64 |
+
$this->getCode(), $order->getStoreId()
|
65 |
+
);
|
66 |
+
$formFields['ECOM_SHIPMETHODTYPE'] = $this->getShippingMethodType(
|
67 |
+
$this->getCode(), $order->getStoreId(), $isVirtual
|
68 |
+
);
|
69 |
+
$formFields['ECOM_SHIPMETHODSPEED'] = $this->getShippingMethodSpeed(
|
70 |
+
$this->getCode(), $order->getStoreId()
|
71 |
+
);
|
72 |
+
$shipMethodDetails = $this->getShippingMethodDetails(
|
73 |
+
$this->getCode(), $order->getStoreId()
|
74 |
+
);
|
75 |
+
if (0 < strlen(trim($shipMethodDetails))) {
|
76 |
+
$formFields['ECOM_SHIPMETHODDETAILS'] = $shipMethodDetails;
|
77 |
+
}
|
78 |
+
if (4 == $formFields['ECOM_SHIPMETHODTYPE']
|
79 |
+
&& !array_key_exists(
|
80 |
+
'ECOM_SHIPMETHODDETAILS', $formFields
|
81 |
+
)
|
82 |
+
) {
|
83 |
+
$address = $order->getShippingAddress()
|
84 |
+
? $order->getShippingAddress()->toString()
|
85 |
+
: $order->getBillingAddress()->toString();
|
86 |
+
$formFields['ECOM_SHIPMETHODDETAILS'] = substr($address, 0, 50);
|
87 |
+
}
|
88 |
+
|
89 |
+
$formFields['ORDERSHIPMETH'] = $shippingMethod;
|
90 |
+
|
91 |
+
$formFields['CIVILITY']
|
92 |
+
= $this->getGender($order) == 'Male' ? 'Mr' : 'Mrs';
|
93 |
+
$formFields = array_merge(
|
94 |
+
$formFields, $this->getKwixoBillToParams($order)
|
95 |
+
);
|
96 |
+
$formFields = array_merge(
|
97 |
+
$formFields, $this->getKwixoShipToParams($order)
|
98 |
+
);
|
99 |
+
$formFields = array_merge(
|
100 |
+
$formFields, $this->getItemParams($order)
|
101 |
+
);
|
102 |
+
|
103 |
+
$formFields['ORDERID'] = Mage::helper('ops/order')->getOpsOrderId(
|
104 |
+
$order, false
|
105 |
+
);
|
106 |
+
$formFields = $this->populateFromArray(
|
107 |
+
$formFields, $requestParams, $order
|
108 |
+
);
|
109 |
+
|
110 |
+
return $formFields;
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
protected function getKwixoCategoryFromOrderItem(
|
115 |
+
Mage_Sales_Model_Order_Item $item
|
116 |
+
)
|
117 |
+
{
|
118 |
+
$product = Mage::getModel('catalog/product')->load(
|
119 |
+
$item->getProductId()
|
120 |
+
);
|
121 |
+
$kwixoCategoryId = null;
|
122 |
+
foreach ($product->getCategoryIds() as $categoryId) {
|
123 |
+
$kwixoCategory = Mage::getModel('ops/kwixo_category_mapping')
|
124 |
+
->loadByCategoryId($categoryId);
|
125 |
+
if (!is_null($kwixoCategory->getId())) {
|
126 |
+
$kwixoCategoryId = $kwixoCategory->getKwixoCategoryId();
|
127 |
+
break;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
return $kwixoCategoryId;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
*
|
136 |
+
*
|
137 |
+
* @param Mage_Sales_Model_Order $order
|
138 |
+
* @param array $requestParams
|
139 |
+
*
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
public function getKwixoBillToParams(Mage_Sales_Model_Order $order)
|
143 |
+
{
|
144 |
+
$formFields = array();
|
145 |
+
$billingAddress
|
146 |
+
= $order->getBillingAddress();
|
147 |
+
$splittedStreet = $this->splitHouseNumber(
|
148 |
+
$billingAddress->getStreet1()
|
149 |
+
);
|
150 |
+
$formFields['ECOM_BILLTO_POSTAL_NAME_FIRST']
|
151 |
+
= $billingAddress->getFirstname();
|
152 |
+
$formFields['ECOM_BILLTO_POSTAL_NAME_LAST']
|
153 |
+
= $billingAddress->getLastname();
|
154 |
+
$formFields['OWNERADDRESS'] = str_replace(
|
155 |
+
"\n", ' ', $billingAddress->getStreet1()
|
156 |
+
);
|
157 |
+
if (array_key_exists('street', $splittedStreet)) {
|
158 |
+
$formFields['OWNERADDRESS'] = trim($splittedStreet['street']);
|
159 |
+
}
|
160 |
+
$streetAppendix = trim($billingAddress->getStreet2());
|
161 |
+
if (0 < strlen($streetAppendix)) {
|
162 |
+
$formFields['OWNERADDRESS2'] = $streetAppendix;
|
163 |
+
}
|
164 |
+
$formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = '';
|
165 |
+
if (array_key_exists('housenumber', $splittedStreet)) {
|
166 |
+
$formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER']
|
167 |
+
= $splittedStreet['housenumber'];
|
168 |
+
}
|
169 |
+
$formFields['OWNERTELNO'] = $billingAddress->getTelephone();
|
170 |
+
|
171 |
+
return $formFields;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* return the shipping parameters as array based on shipping method type
|
176 |
+
*
|
177 |
+
* @param Mage_Sales_Model_Order $order
|
178 |
+
* @param array $requestParams
|
179 |
+
*
|
180 |
+
* @return array
|
181 |
+
*/
|
182 |
+
public function getKwixoShipToParams(Mage_Sales_Model_Order $order)
|
183 |
+
{
|
184 |
+
$formFields = array();
|
185 |
+
$shippingAddress = $order->getShippingAddress();
|
186 |
+
if ($shippingAddress === false) {
|
187 |
+
$shippingAddress = $order->getBillingAddress();
|
188 |
+
}
|
189 |
+
$splittedStreet = $this->splitHouseNumber(
|
190 |
+
$shippingAddress->getStreet1()
|
191 |
+
);
|
192 |
+
|
193 |
+
$shippingMethodType = (int)$this->getShippingMethodType(
|
194 |
+
$this->getCode(), $order->getStoreId()
|
195 |
+
);
|
196 |
+
|
197 |
+
if (in_array(
|
198 |
+
$shippingMethodType, $this->getShippingMethodTypeValues()
|
199 |
+
)
|
200 |
+
) {
|
201 |
+
if (4 === $shippingMethodType) {
|
202 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX']
|
203 |
+
= $shippingAddress->getPrefix();
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
$company = trim($shippingAddress->getCompany());
|
208 |
+
if (0 < strlen($company)) {
|
209 |
+
$formFields['ECOM_SHIPTO_COMPANY'] = $company;
|
210 |
+
}
|
211 |
+
$fax = trim($shippingAddress->getFax());
|
212 |
+
if (0 < strlen($fax)) {
|
213 |
+
$formFields['ECOM_SHIPTO_TELECOM_FAX_NUMBER'] = $fax;
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1']
|
218 |
+
= $shippingAddress->getStreet1();
|
219 |
+
if (array_key_exists('street', $splittedStreet)) {
|
220 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1']
|
221 |
+
= $splittedStreet['street'];
|
222 |
+
}
|
223 |
+
$streetAppendix = trim($shippingAddress->getStreet2());
|
224 |
+
if (0 < strlen($streetAppendix)) {
|
225 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_LINE2']
|
226 |
+
= $streetAppendix;
|
227 |
+
}
|
228 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER'] = '';
|
229 |
+
if (array_key_exists('housenumber', $splittedStreet)) {
|
230 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER']
|
231 |
+
= $splittedStreet['housenumber'];
|
232 |
+
}
|
233 |
+
$formFields['ECOM_SHIPTO_POSTAL_POSTALCODE']
|
234 |
+
= $shippingAddress->getPostcode();
|
235 |
+
$formFields['ECOM_SHIPTO_POSTAL_CITY']
|
236 |
+
= $shippingAddress->getCity();
|
237 |
+
$formFields['ECOM_SHIPTO_POSTAL_COUNTRYCODE']
|
238 |
+
= $shippingAddress->getCountryId();
|
239 |
+
}
|
240 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_FIRST']
|
241 |
+
= $shippingAddress->getFirstname();
|
242 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_LAST']
|
243 |
+
= $shippingAddress->getLastname();
|
244 |
+
$formFields['ECOM_SHIPTO_TELECOM_PHONE_NUMBER']
|
245 |
+
= $shippingAddress->getTelephone();
|
246 |
+
|
247 |
+
return $formFields;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* return item params for the order
|
252 |
+
* for each item a ascending number will be added to the parameter name
|
253 |
+
*
|
254 |
+
* @param Mage_Sales_Model_Order $order
|
255 |
+
*
|
256 |
+
* @return array
|
257 |
+
*/
|
258 |
+
public function getItemParams(Mage_Sales_Model_Order $order)
|
259 |
+
{
|
260 |
+
$formFields = array();
|
261 |
+
$items = $order->getAllItems();
|
262 |
+
$subtotal = 0;
|
263 |
+
if (is_array($items)) {
|
264 |
+
$itemCounter = 1;
|
265 |
+
foreach ($items as $item) {
|
266 |
+
if ($item->getParentItemId()) {
|
267 |
+
continue;
|
268 |
+
}
|
269 |
+
|
270 |
+
$subtotal += $item->getBasePriceInclTax(
|
271 |
+
) * $item->getQtyOrdered();
|
272 |
+
$formFields['ITEMFDMPRODUCTCATEG' . $itemCounter]
|
273 |
+
= $this->getKwixoCategoryFromOrderItem(
|
274 |
+
$item
|
275 |
+
);
|
276 |
+
$formFields['ITEMID' . $itemCounter] = $item->getItemId();
|
277 |
+
$formFields['ITEMNAME' . $itemCounter] = substr(
|
278 |
+
$item->getName(), 0, 40
|
279 |
+
);
|
280 |
+
$formFields['ITEMPRICE' . $itemCounter] = number_format(
|
281 |
+
$item->getBasePriceInclTax(), 2, '.', ''
|
282 |
+
);
|
283 |
+
$formFields['ITEMQUANT' . $itemCounter]
|
284 |
+
= (int)$item->getQtyOrdered(
|
285 |
+
);
|
286 |
+
$formFields['ITEMVAT' . $itemCounter] = str_replace(
|
287 |
+
',', '.', (string)(float)$item->getBaseTaxAmount()
|
288 |
+
);
|
289 |
+
$formFields['TAXINCLUDED' . $itemCounter] = 1;
|
290 |
+
$itemCounter++;
|
291 |
+
}
|
292 |
+
$shippingPrice = $order->getBaseShippingAmount();
|
293 |
+
$shippingPriceInclTax = $order->getBaseShippingInclTax();
|
294 |
+
$subtotal += $shippingPriceInclTax;
|
295 |
+
$shippingTaxAmount = $shippingPriceInclTax - $shippingPrice;
|
296 |
+
|
297 |
+
$roundingError = $order->getBaseGrandTotal() - $subtotal;
|
298 |
+
$shippingPrice += $roundingError;
|
299 |
+
/* add shipping item */
|
300 |
+
$formFields['ITEMFDMPRODUCTCATEG' . $itemCounter] = 1;
|
301 |
+
$formFields['ITEMID' . $itemCounter] = 'SHIPPING';
|
302 |
+
$shippingDescription
|
303 |
+
=
|
304 |
+
0 < strlen(trim($order->getShippingDescription()))
|
305 |
+
? $order->getShippingDescription() : 'shipping';
|
306 |
+
$formFields['ITEMNAME' . $itemCounter] = substr(
|
307 |
+
$shippingDescription, 0, 30
|
308 |
+
);
|
309 |
+
$formFields['ITEMPRICE' . $itemCounter] = number_format(
|
310 |
+
$shippingPrice, 2, '.', ''
|
311 |
+
);
|
312 |
+
$formFields['ITEMQUANT' . $itemCounter] = 1;
|
313 |
+
$formFields['ITEMVAT' . $itemCounter] = number_format(
|
314 |
+
$shippingTaxAmount, 2, '.', ''
|
315 |
+
);
|
316 |
+
}
|
317 |
+
|
318 |
+
return $formFields;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* splits house number and street for france addresses
|
323 |
+
*
|
324 |
+
* @param string $address
|
325 |
+
*
|
326 |
+
* @return array
|
327 |
+
*/
|
328 |
+
public function splitHouseNumber($address)
|
329 |
+
{
|
330 |
+
$splittedStreet = array();
|
331 |
+
$street = str_replace("\n", ' ', $address);
|
332 |
+
$regexp = '/(?P<housenumber>[0-9]+)([,:\s])(?P<street>.+)/';
|
333 |
+
if (!preg_match($regexp, $street, $splittedStreet)) {
|
334 |
+
$splittedStreet[1] = $street;
|
335 |
+
$splittedStreet[2] = '';
|
336 |
+
}
|
337 |
+
|
338 |
+
return $splittedStreet;
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* returns the delivery date as date based on actual date and adding
|
343 |
+
* the configurated value as days to it
|
344 |
+
*
|
345 |
+
* @param string $code
|
346 |
+
* @param string $storeId
|
347 |
+
*
|
348 |
+
* @return bool|string
|
349 |
+
*/
|
350 |
+
public function getEstimatedDeliveryDate($code, $storeId = null)
|
351 |
+
{
|
352 |
+
$dateNow = date("Y-m-d");
|
353 |
+
$dayValue = (string)Mage::getStoreConfig(
|
354 |
+
'payment/' . $code . "/delivery_date", $storeId
|
355 |
+
);
|
356 |
+
$deliveryDate = strtotime($dateNow . "+" . $dayValue . "days");
|
357 |
+
|
358 |
+
return date("Y-m-d", $deliveryDate);
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* return the RNP Fee value
|
363 |
+
*
|
364 |
+
* @param string $code
|
365 |
+
* @param int $storeId
|
366 |
+
*
|
367 |
+
* @return boolean
|
368 |
+
*/
|
369 |
+
public function getRnpFee($code, $storeId = null)
|
370 |
+
{
|
371 |
+
return (int)(bool)Mage::getStoreConfig(
|
372 |
+
"payment/" . $code . "/rnp_fee", $storeId
|
373 |
+
);
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* returns the Shipping Method Type configured in backend
|
378 |
+
*
|
379 |
+
* @param string $code
|
380 |
+
* @param int $storeId
|
381 |
+
*
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
public function getShippingMethodType(
|
385 |
+
$code, $storeId = null, $isVirtual = false
|
386 |
+
)
|
387 |
+
{
|
388 |
+
// use download type for orders containing virtual products only
|
389 |
+
if ($isVirtual) {
|
390 |
+
return Netresearch_OPS_Model_Source_Kwixo_ShipMethodType::DOWNLOAD;
|
391 |
+
}
|
392 |
+
$shippingMethodType = $this->getKwixoShippingModel()
|
393 |
+
->getKwixoShippingType();
|
394 |
+
if (null === $shippingMethodType) {
|
395 |
+
$shippingMethodType = Mage::getStoreConfig(
|
396 |
+
"payment/" . $code . "/ecom_shipMethodType", $storeId
|
397 |
+
);
|
398 |
+
}
|
399 |
+
|
400 |
+
return $shippingMethodType;
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* return the shipping method speed configured in backend
|
405 |
+
*
|
406 |
+
* @param string $code
|
407 |
+
* @param int $storeId
|
408 |
+
*
|
409 |
+
* @return int
|
410 |
+
*/
|
411 |
+
public function getShippingMethodSpeed($code, $storeId = null)
|
412 |
+
{
|
413 |
+
$shippingMethodSpeed = $this->getKwixoShippingModel()
|
414 |
+
->getKwixoShippingMethodSpeed();
|
415 |
+
if (null === $shippingMethodSpeed) {
|
416 |
+
$shippingMethodSpeed = Mage::getStoreConfig(
|
417 |
+
"payment/" . $code . "/ecom_shipMethodSpeed", $storeId
|
418 |
+
);
|
419 |
+
}
|
420 |
+
|
421 |
+
return (int)$shippingMethodSpeed;
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* return the item product categories configured in backend as array
|
426 |
+
*
|
427 |
+
* @param string $code
|
428 |
+
* @param int $storeId
|
429 |
+
*
|
430 |
+
* @return array
|
431 |
+
*/
|
432 |
+
public function getItemFmdProductCateg($code, $storeId = null)
|
433 |
+
{
|
434 |
+
return explode(
|
435 |
+
",", Mage::getStoreConfig(
|
436 |
+
"payment/" . $code . "/product_categories", $storeId
|
437 |
+
)
|
438 |
+
);
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* return the shipping method detail text
|
443 |
+
*
|
444 |
+
* @param string $code
|
445 |
+
* @param int $storeId
|
446 |
+
*
|
447 |
+
* @return string
|
448 |
+
*/
|
449 |
+
public function getShippingMethodDetails($code, $storeId = null)
|
450 |
+
{
|
451 |
+
$shippingMethodDetails = $this->getKwixoShippingModel()
|
452 |
+
->getKwixoShippingDetails();
|
453 |
+
if (null === $shippingMethodDetails) {
|
454 |
+
$shippingMethodDetails = Mage::getStoreConfig(
|
455 |
+
"payment/" . $code . "/shiping_method_details", $storeId
|
456 |
+
);
|
457 |
+
}
|
458 |
+
|
459 |
+
return $shippingMethodDetails;
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* get question for fields with disputable value
|
464 |
+
* users are asked to correct the values before redirect to Acceptance
|
465 |
+
*
|
466 |
+
* @param Mage_Sales_Model_Order $order Current order
|
467 |
+
* @param array $requestParams Request parameters
|
468 |
+
*
|
469 |
+
* @return string
|
470 |
+
*/
|
471 |
+
public function getQuestion($order, $requestParams)
|
472 |
+
{
|
473 |
+
return Mage::helper('ops/data')->__(
|
474 |
+
'Please make sure that the displayed data is correct.'
|
475 |
+
);
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* get an array of fields with disputable value
|
480 |
+
* users are asked to correct the values before redirect to Acceptance
|
481 |
+
*
|
482 |
+
* @param Mage_Sales_Model_Order $order Current order
|
483 |
+
* @param array $requestParams Request parameters
|
484 |
+
*
|
485 |
+
* @return array
|
486 |
+
*/
|
487 |
+
public function getQuestionedFormFields($order, $requestParams)
|
488 |
+
{
|
489 |
+
$questionedFormFields = array(
|
490 |
+
'CIVILITY',
|
491 |
+
'OWNERADDRESS',
|
492 |
+
'ECOM_BILLTO_POSTAL_STREET_NUMBER',
|
493 |
+
|
494 |
+
);
|
495 |
+
$storeId = null;
|
496 |
+
if ($order instanceof Mage_Sales_Model_Order) {
|
497 |
+
$storeId = $order->getStoreId();
|
498 |
+
}
|
499 |
+
$shippingMethodType = (int)$this->getShippingMethodType(
|
500 |
+
$this->getCode(), $storeId
|
501 |
+
);
|
502 |
+
if (in_array(
|
503 |
+
$shippingMethodType, $this->getShippingMethodTypeValues()
|
504 |
+
)
|
505 |
+
) {
|
506 |
+
$questionedFormFields [] = 'ECOM_SHIPTO_POSTAL_STREET_NUMBER';
|
507 |
+
$questionedFormFields [] = 'ECOM_SHIPTO_POSTAL_STREET_LINE1';
|
508 |
+
}
|
509 |
+
|
510 |
+
if ($shippingMethodType === 4) {
|
511 |
+
$questionedFormFields [] = 'ECOM_SHIPTO_TELECOM_PHONE_NUMBER';
|
512 |
+
$questionedFormFields [] = 'ECOM_SHIPTO_POSTAL_NAME_PREFIX';
|
513 |
+
}
|
514 |
+
|
515 |
+
return $questionedFormFields;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* return shipping method values except for the type download
|
520 |
+
*
|
521 |
+
* @return array
|
522 |
+
*/
|
523 |
+
public function getShippingMethodTypeValues()
|
524 |
+
{
|
525 |
+
return array(1, 2, 3, 4);
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* populates an array with the values from another if the keys are matching
|
530 |
+
*
|
531 |
+
* @param array $formFields - the array to populate
|
532 |
+
* @param null $dataArray - the array containing the data
|
533 |
+
*
|
534 |
+
* @return array - the populated array
|
535 |
+
*/
|
536 |
+
protected function populateFromArray(
|
537 |
+
array $formFields, $dataArray = null, $order
|
538 |
+
)
|
539 |
+
{
|
540 |
+
// copy some already known values, but only the ones from the questioned
|
541 |
+
// form fields
|
542 |
+
if (is_array($dataArray)) {
|
543 |
+
foreach ($dataArray as $key => $value) {
|
544 |
+
if (array_key_exists($key, $formFields)
|
545 |
+
&& in_array(
|
546 |
+
$key,
|
547 |
+
$this->getQuestionedFormFields($order, $dataArray), true
|
548 |
+
)
|
549 |
+
|| $key == 'CIVILITY'
|
550 |
+
) {
|
551 |
+
$formFields[$key] = $value;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
return $formFields;
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* get gender text for customer
|
561 |
+
*
|
562 |
+
* @param Mage_Sales_Model_Order $order
|
563 |
+
*/
|
564 |
+
public function getGender(Mage_Sales_Model_Order $order)
|
565 |
+
{
|
566 |
+
$gender = Mage::getSingleton('eav/config')
|
567 |
+
->getAttribute('customer', 'gender')
|
568 |
+
->getSource()
|
569 |
+
->getOptionText($order->getCustomerGender());
|
570 |
+
|
571 |
+
return $gender;
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* sets the kwixo shipping setting model
|
576 |
+
*
|
577 |
+
* @param Netresearch_OPS_Model_Kwixo_Shipping_Setting $kwixoShippingModel
|
578 |
+
*/
|
579 |
+
public function setKwixoShippingModel(
|
580 |
+
Netresearch_OPS_Model_Kwixo_Shipping_Setting $kwixoShippingModel
|
581 |
+
)
|
582 |
+
{
|
583 |
+
$this->kwixoShippingModel = $kwixoShippingModel;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* returns the kwixo shipping setting model
|
588 |
+
*
|
589 |
+
* @return Netresearch_OPS_Model_Kwixo_Shipping_Setting
|
590 |
+
*/
|
591 |
+
public function getKwixoShippingModel()
|
592 |
+
{
|
593 |
+
if (null === $this->kwixoShippingModel) {
|
594 |
+
$this->kwixoShippingModel = Mage::getModel(
|
595 |
+
'ops/kwixo_shipping_setting'
|
596 |
+
);
|
597 |
+
}
|
598 |
+
|
599 |
+
return $this->kwixoShippingModel;
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* @param $carrierCode
|
604 |
+
*/
|
605 |
+
private function loadShippingSettingForCarrierCode($carrierCode)
|
606 |
+
{
|
607 |
+
$this->shippingSettings = $this->getKwixoShippingModel()->load(
|
608 |
+
$carrierCode, 'shipping_code'
|
609 |
+
);
|
610 |
+
|
611 |
+
return $this->shippingSettings;
|
612 |
+
}
|
613 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/KwixoApresReception.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_ApresReception
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2013 Netresearch
|
7 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_KwixoApresReception extends Netresearch_OPS_Model_Payment_Kwixo_Abstract
|
11 |
+
{
|
12 |
+
protected $pm = 'KWIXO_RNP';
|
13 |
+
|
14 |
+
/** Check if we can capture directly from the backend */
|
15 |
+
protected $_canBackendDirectCapture = true;
|
16 |
+
|
17 |
+
protected $_formBlockType = 'ops/form_kwixo_apresReception';
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_kwixoApresReception';
|
24 |
+
|
25 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/KwixoComptant.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_ApresReception
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2013 Netresearch
|
8 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_KwixoComptant extends Netresearch_OPS_Model_Payment_Kwixo_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'KWIXO_STANDARD';
|
14 |
+
|
15 |
+
/** Check if we can capture directly from the backend */
|
16 |
+
protected $_canBackendDirectCapture = true;
|
17 |
+
|
18 |
+
protected $_formBlockType = 'ops/form_kwixo_comptant';
|
19 |
+
|
20 |
+
/** info source path */
|
21 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
22 |
+
|
23 |
+
/** payment code */
|
24 |
+
protected $_code = 'ops_kwixoComptant';
|
25 |
+
|
26 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/KwixoCredit.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_KwixoCredit
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2013 Netresearch
|
8 |
+
* @author Sebastian Ertner <sebastian.ertner@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_KwixoCredit extends Netresearch_OPS_Model_Payment_Kwixo_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'KWIXO_CREDIT';
|
14 |
+
|
15 |
+
/** Check if we can capture directly from the backend */
|
16 |
+
protected $_canBackendDirectCapture = true;
|
17 |
+
|
18 |
+
/** info source path */
|
19 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
20 |
+
|
21 |
+
|
22 |
+
protected $_formBlockType = 'ops/form_kwixo_credit';
|
23 |
+
|
24 |
+
/** payment code */
|
25 |
+
protected $_code = 'ops_kwixoCredit';
|
26 |
+
|
27 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Masterpass.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_IDeal
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2016 Netresearch
|
8 |
+
* @author Benjamin Heuer <benjamin.heuer@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_Masterpass
|
12 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
13 |
+
{
|
14 |
+
protected $pm = 'MasterPass';
|
15 |
+
protected $brand = 'MasterPass';
|
16 |
+
|
17 |
+
/** Check if we can capture directly from the backend */
|
18 |
+
protected $_canBackendDirectCapture = true;
|
19 |
+
|
20 |
+
/** info source path */
|
21 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
22 |
+
|
23 |
+
/** payment code */
|
24 |
+
protected $_code = 'ops_Masterpass';
|
25 |
+
|
26 |
+
}
|
27 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Mpass.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_Mpass
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Mpass
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'MPASS';
|
14 |
+
protected $brand = 'MPASS';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_mpass';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoice/Abstract.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* open invoice payment via Acceptance
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Payment_OpenInvoice_Abstract extends Netresearch_OPS_Model_Payment_Abstract
|
31 |
+
{
|
32 |
+
protected $_needsCartDataForRequest = true;
|
33 |
+
protected $_needsShipToParams = false;
|
34 |
+
|
35 |
+
public function getMethodDependendFormFields($order, $requestParams = null)
|
36 |
+
{
|
37 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
38 |
+
|
39 |
+
$billingAddress = $order->getBillingAddress();
|
40 |
+
$birthday = new DateTime($order->getCustomerDob());
|
41 |
+
|
42 |
+
|
43 |
+
$gender = $order->getCustomerGender() == 1 ? 'M' : 'F';
|
44 |
+
|
45 |
+
|
46 |
+
$billingAddress = $order->getBillingAddress();
|
47 |
+
$street = str_replace("\n", ' ', $billingAddress->getStreet(-1));
|
48 |
+
$regexp = '/^([^0-9]*)([0-9].*)$/';
|
49 |
+
if (!preg_match($regexp, $street, $splittedStreet)) {
|
50 |
+
$splittedStreet[1] = $street;
|
51 |
+
$splittedStreet[2] = '';
|
52 |
+
}
|
53 |
+
|
54 |
+
$formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
|
55 |
+
$formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
|
56 |
+
|
57 |
+
//$formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX'] = $shippingAddress->getPrefix();
|
58 |
+
$formFields['ECOM_BILLTO_POSTAL_NAME_FIRST'] = substr($billingAddress->getFirstname(), 0, 50);
|
59 |
+
$formFields['ECOM_BILLTO_POSTAL_NAME_LAST'] = substr($billingAddress->getLastname(), 0, 50);
|
60 |
+
$formFields['ECOM_SHIPTO_DOB'] = $birthday->format('d/m/Y');
|
61 |
+
$formFields['ECOM_CONSUMER_GENDER'] = $gender;
|
62 |
+
|
63 |
+
return $formFields;
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceAt.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Netresearch_OPS_Model_Payment_OpenInvoiceAt
|
5 |
+
*
|
6 |
+
* @package
|
7 |
+
* @copyright 2016 Netresearch
|
8 |
+
* @author Benjamin Heuer <benjamin.heuer@netresearch.de>
|
9 |
+
* @license OSL 3.0
|
10 |
+
*/
|
11 |
+
class Netresearch_OPS_Model_Payment_OpenInvoiceAt
|
12 |
+
extends Netresearch_OPS_Model_Payment_OpenInvoice_Abstract
|
13 |
+
{
|
14 |
+
protected $pm = 'Open Invoice AT';
|
15 |
+
protected $brand = 'Open Invoice AT';
|
16 |
+
|
17 |
+
/** if we can capture directly from the backend */
|
18 |
+
protected $_canBackendDirectCapture = false;
|
19 |
+
|
20 |
+
protected $_canCapturePartial = false;
|
21 |
+
protected $_canRefundInvoicePartial = false;
|
22 |
+
|
23 |
+
/** info source path */
|
24 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
25 |
+
|
26 |
+
/** payment code */
|
27 |
+
protected $_code = 'ops_openInvoiceAt';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Open Invoice AT is not available if quote has a coupon
|
31 |
+
*
|
32 |
+
* @param Mage_Sales_Model_Quote $quote
|
33 |
+
*
|
34 |
+
* @return boolean
|
35 |
+
*/
|
36 |
+
public function isAvailable( $quote = null ) {
|
37 |
+
/* availability depends on quote */
|
38 |
+
if( false == $quote instanceof Mage_Sales_Model_Quote ) {
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
/* not available if quote contains a coupon and allow_discounted_carts is disabled */
|
43 |
+
if( !$this->isAvailableForDiscountedCarts()
|
44 |
+
&& $quote->getSubtotal() != $quote->getSubtotalWithDiscount()
|
45 |
+
) {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
/* not available if there is no gender or no birthday */
|
50 |
+
if( is_null( $quote->getCustomerGender() ) || is_null( $quote->getCustomerDob() ) ) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
return parent::isAvailable( $quote );
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getPaymentAction() {
|
58 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* @param Mage_Sales_Model_Order $order
|
63 |
+
* @param array|null $requestParams
|
64 |
+
*
|
65 |
+
* @return array
|
66 |
+
*/
|
67 |
+
public function getMethodDependendFormFields( $order, $requestParams = null ) {
|
68 |
+
$formFields = parent::getMethodDependendFormFields( $order, $requestParams );
|
69 |
+
|
70 |
+
$shippingAddress = $order->getShippingAddress();
|
71 |
+
|
72 |
+
$gender = Mage::getSingleton( 'eav/config' )
|
73 |
+
->getAttribute( 'customer', 'gender' )
|
74 |
+
->getSource()
|
75 |
+
->getOptionText( $order->getCustomerGender() );
|
76 |
+
|
77 |
+
$formFields[ 'CIVILITY' ] = $gender == 'Male' ? 'Herr' : 'Frau';
|
78 |
+
$formFields[ 'ECOM_CONSUMER_GENDER' ] = $gender == 'Male' ? 'M' : 'F';
|
79 |
+
|
80 |
+
if( !$this->getConfig()->canSubmitExtraParameter( $order->getStoreId() ) ) {
|
81 |
+
// add the shipto parameters even if the submitOption is false, because they are required for OpenInvoice
|
82 |
+
$shipToParams = $this->getRequestHelper()->extractShipToParameters( $shippingAddress, $order );
|
83 |
+
$formFields = array_merge( $formFields, $shipToParams );
|
84 |
+
}
|
85 |
+
|
86 |
+
return $formFields;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* getter for the allow_discounted_carts
|
91 |
+
*
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
protected function isAvailableForDiscountedCarts() {
|
95 |
+
return (bool) $this->getConfigData( 'allow_discounted_carts' );
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceDe.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_OpenInvoiceDe
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_OpenInvoiceDe
|
11 |
+
extends Netresearch_OPS_Model_Payment_OpenInvoice_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'Open Invoice DE';
|
14 |
+
protected $brand = 'Open Invoice DE';
|
15 |
+
|
16 |
+
/** if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = false;
|
18 |
+
|
19 |
+
protected $_canCapturePartial = false;
|
20 |
+
protected $_canRefundInvoicePartial = false;
|
21 |
+
|
22 |
+
/** info source path */
|
23 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
24 |
+
|
25 |
+
/** payment code */
|
26 |
+
protected $_code = 'ops_openInvoiceDe';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Open Invoice DE is not available if quote has a coupon
|
30 |
+
*
|
31 |
+
* @param Mage_Sales_Model_Quote $quote
|
32 |
+
* @return boolean
|
33 |
+
*/
|
34 |
+
public function isAvailable($quote=null)
|
35 |
+
{
|
36 |
+
/* availability depends on quote */
|
37 |
+
if (false == $quote instanceof Mage_Sales_Model_Quote) {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
|
41 |
+
/* not available if quote contains a coupon and allow_discounted_carts is disabled */
|
42 |
+
if (!$this->isAvailableForDiscountedCarts()
|
43 |
+
&& $quote->getSubtotal() != $quote->getSubtotalWithDiscount()
|
44 |
+
) {
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
/* not available if there is no gender or no birthday */
|
49 |
+
if (is_null($quote->getCustomerGender()) || is_null($quote->getCustomerDob())) {
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
return parent::isAvailable($quote);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getPaymentAction()
|
57 |
+
{
|
58 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getMethodDependendFormFields($order, $requestParams=null)
|
62 |
+
{
|
63 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
64 |
+
|
65 |
+
$shippingAddress = $order->getShippingAddress();
|
66 |
+
|
67 |
+
$gender = Mage::getSingleton('eav/config')
|
68 |
+
->getAttribute('customer', 'gender')
|
69 |
+
->getSource()
|
70 |
+
->getOptionText($order->getCustomerGender());
|
71 |
+
|
72 |
+
$formFields[ 'CIVILITY' ] = $gender == 'Male' ? 'Herr' : 'Frau';
|
73 |
+
$formFields[ 'ECOM_CONSUMER_GENDER' ] = $gender == 'Male' ? 'M' : 'F';
|
74 |
+
|
75 |
+
if (!$this->getConfig()->canSubmitExtraParameter($order->getStoreId())) {
|
76 |
+
// add the shipto parameters even if the submitOption is false, because they are required for OpenInvoice
|
77 |
+
$shipToParams = $this->getRequestHelper()->extractShipToParameters($shippingAddress, $order);
|
78 |
+
$formFields = array_merge($formFields, $shipToParams);
|
79 |
+
}
|
80 |
+
|
81 |
+
return $formFields;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* getter for the allow_discounted_carts
|
86 |
+
*
|
87 |
+
* @return array
|
88 |
+
*/
|
89 |
+
protected function isAvailableForDiscountedCarts()
|
90 |
+
{
|
91 |
+
return (bool) $this->getConfigData('allow_discounted_carts');
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/OpenInvoiceNl.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_OpenInvoiceNl
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_OpenInvoiceNl
|
11 |
+
extends Netresearch_OPS_Model_Payment_OpenInvoice_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'Open Invoice NL';
|
14 |
+
protected $brand = 'Open Invoice NL';
|
15 |
+
|
16 |
+
/** if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = false;
|
18 |
+
|
19 |
+
|
20 |
+
/** info source path */
|
21 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
22 |
+
|
23 |
+
/** payment code */
|
24 |
+
protected $_code = 'ops_openInvoiceNl';
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Open Invoice NL is not available if quote has a coupon
|
29 |
+
*
|
30 |
+
* @param Mage_Sales_Model_Quote $quote
|
31 |
+
* @return boolean
|
32 |
+
*/
|
33 |
+
public function isAvailable($quote=null)
|
34 |
+
{
|
35 |
+
/* availability depends on quote */
|
36 |
+
if (false == $quote instanceof Mage_Sales_Model_Quote) {
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
|
40 |
+
/* not available if there is no gender or no birthday */
|
41 |
+
if (is_null($quote->getCustomerGender()) || is_null($quote->getCustomerDob())) {
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
return parent::isAvailable($quote);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* get some method dependend form fields
|
50 |
+
*
|
51 |
+
* @param Mage_Sales_Model_Quote $order
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public function getMethodDependendFormFields($order, $requestParams=null)
|
55 |
+
{
|
56 |
+
$billingAddress = $order->getBillingAddress();
|
57 |
+
$shippingAddress = $order->getShippingAddress();
|
58 |
+
$street = str_replace("\n", ' ',$billingAddress->getStreet(-1));
|
59 |
+
$regexp = '/^([^0-9]*)([0-9].*)$/';
|
60 |
+
if (!preg_match($regexp, $street, $splittedStreet)) {
|
61 |
+
$splittedStreet[1] = $street;
|
62 |
+
$splittedStreet[2] = '';
|
63 |
+
}
|
64 |
+
$formFields = parent::getMethodDependendFormFields($order, $requestParams);
|
65 |
+
|
66 |
+
$gender = Mage::getSingleton('eav/config')
|
67 |
+
->getAttribute('customer', 'gender')
|
68 |
+
->getSource()
|
69 |
+
->getOptionText($order->getCustomerGender());
|
70 |
+
|
71 |
+
$formFields['CIVILITY'] = $gender == 'Male' ? 'M' : 'V';
|
72 |
+
$formFields['ECOM_CONSUMER_GENDER'] = $gender == 'Male' ? 'M' : 'V';
|
73 |
+
$formFields['OWNERADDRESS'] = trim($splittedStreet[1]);
|
74 |
+
$formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
|
75 |
+
$formFields['OWNERZIP'] = $billingAddress->getPostcode();
|
76 |
+
$formFields['OWNERTOWN'] = $billingAddress->getCity();
|
77 |
+
$formFields['OWNERCTY'] = $billingAddress->getCountry();
|
78 |
+
$formFields['OWNERTELNO'] = $billingAddress->getTelephone();
|
79 |
+
|
80 |
+
$street = str_replace("\n", ' ',$shippingAddress->getStreet(-1));
|
81 |
+
if (!preg_match($regexp, $street, $splittedStreet)) {
|
82 |
+
$splittedStreet[1] = $street;
|
83 |
+
$splittedStreet[2] = '';
|
84 |
+
}
|
85 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_PREFIX'] = $shippingAddress->getPrefix();
|
86 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_FIRST'] = $shippingAddress->getFirstname();
|
87 |
+
$formFields['ECOM_SHIPTO_POSTAL_NAME_LAST'] = $shippingAddress->getLastname();
|
88 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = trim($splittedStreet[1]);
|
89 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER'] = trim($splittedStreet[2]);
|
90 |
+
$formFields['ECOM_SHIPTO_POSTAL_POSTALCODE'] = $shippingAddress->getPostcode();
|
91 |
+
$formFields['ECOM_SHIPTO_POSTAL_CITY'] = $shippingAddress->getCity();
|
92 |
+
$formFields['ECOM_SHIPTO_POSTAL_COUNTRYCODE'] = $shippingAddress->getCountry();
|
93 |
+
|
94 |
+
// copy some already known values
|
95 |
+
$formFields['ECOM_SHIPTO_ONLINE_EMAIL'] = $order->getCustomerEmail();
|
96 |
+
|
97 |
+
if (is_array($requestParams)) {
|
98 |
+
if (array_key_exists('OWNERADDRESS', $requestParams)) {
|
99 |
+
$formFields['OWNERADDRESS'] = $requestParams['OWNERADDRESS'];
|
100 |
+
}
|
101 |
+
if (array_key_exists('ECOM_BILLTO_POSTAL_STREET_NUMBER', $requestParams)) {
|
102 |
+
$formFields['ECOM_BILLTO_POSTAL_STREET_NUMBER'] = $requestParams['ECOM_BILLTO_POSTAL_STREET_NUMBER'];
|
103 |
+
}
|
104 |
+
if (array_key_exists('ECOM_SHIPTO_POSTAL_STREET_LINE1', $requestParams)) {
|
105 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_LINE1'] = $requestParams['ECOM_SHIPTO_POSTAL_STREET_LINE1'];
|
106 |
+
}
|
107 |
+
if (array_key_exists('ECOM_SHIPTO_POSTAL_STREET_NUMBER', $requestParams)) {
|
108 |
+
$formFields['ECOM_SHIPTO_POSTAL_STREET_NUMBER'] = $requestParams['ECOM_SHIPTO_POSTAL_STREET_NUMBER'];
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
return $formFields;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* get question for fields with disputable value
|
117 |
+
* users are asked to correct the values before redirect to Acceptance
|
118 |
+
*
|
119 |
+
* @param Mage_Sales_Model_Order $order Current order
|
120 |
+
* @param array $requestParams Request parameters
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getQuestion($order, $requestParams)
|
124 |
+
{
|
125 |
+
return Mage::helper('ops')->__('Please make sure that your street and house number are correct.');
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* get an array of fields with disputable value
|
130 |
+
* users are asked to correct the values before redirect to Acceptance
|
131 |
+
*
|
132 |
+
* @param Mage_Sales_Model_Order $order Current order
|
133 |
+
* @param array $requestParams Request parameters
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
public function getQuestionedFormFields($order, $requestParams)
|
137 |
+
{
|
138 |
+
return array(
|
139 |
+
'OWNERADDRESS',
|
140 |
+
'ECOM_BILLTO_POSTAL_STREET_NUMBER',
|
141 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE1',
|
142 |
+
'ECOM_SHIPTO_POSTAL_STREET_NUMBER',
|
143 |
+
);
|
144 |
+
}
|
145 |
+
|
146 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Paypal.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_Paypal
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Paypal
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'PAYPAL';
|
14 |
+
protected $brand = 'PAYPAL';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_paypal';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Paysafecard.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_Paysafecard
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_Paysafecard
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'paysafecard';
|
14 |
+
protected $brand = 'paysafecard';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_paysafecard';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/PingPing.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_PingPing
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_PingPing
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'PingPing';
|
14 |
+
protected $brand = 'PingPing';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_pingPing';
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/PostFinanceEFinance.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS_Model_Payment_PostFinanceEFinance
|
4 |
+
*
|
5 |
+
* @package
|
6 |
+
* @copyright 2011 Netresearch
|
7 |
+
* @author Thomas Kappel <thomas.kappel@netresearch.de>
|
8 |
+
* @license OSL 3.0
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Model_Payment_PostFinanceEFinance
|
11 |
+
extends Netresearch_OPS_Model_Payment_Abstract
|
12 |
+
{
|
13 |
+
protected $pm = 'PostFinance e-finance';
|
14 |
+
protected $brand = 'PostFinance e-finance';
|
15 |
+
|
16 |
+
/** Check if we can capture directly from the backend */
|
17 |
+
protected $_canBackendDirectCapture = true;
|
18 |
+
|
19 |
+
/** info source path */
|
20 |
+
protected $_infoBlockType = 'ops/info_redirect';
|
21 |
+
|
22 |
+
/** payment code */
|
23 |
+
protected $_code = 'ops_postFinanceEFinance';
|
24 |
+
}
|
25 |
+
|
app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc.php
ADDED
@@ -0,0 +1,382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Implementation of the Cc payment method implementing subscription manager functionality
|
24 |
+
* via Magentos recurring profiles
|
25 |
+
*
|
26 |
+
* @category Payment method
|
27 |
+
* @package Netresearch OPS
|
28 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Payment_Recurring_Cc
|
31 |
+
extends Netresearch_OPS_Model_Payment_Cc
|
32 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
33 |
+
{
|
34 |
+
const CODE = 'ops_recurring_cc';
|
35 |
+
protected $_code = self::CODE;
|
36 |
+
|
37 |
+
protected $_canFetchTransactionInfo = false;
|
38 |
+
protected $_canManageRecurringProfiles = true;
|
39 |
+
protected $_canUseInternal = false;
|
40 |
+
|
41 |
+
/** info source path */
|
42 |
+
protected $_infoBlockType = 'ops/info_recurringCc';
|
43 |
+
|
44 |
+
/** @var string $_formBlockType define a specific form block */
|
45 |
+
protected $_formBlockType = 'ops/form_recurringCc';
|
46 |
+
|
47 |
+
protected $parameterModel = null;
|
48 |
+
protected $subscriptionManager = null;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return Netresearch_OPS_Model_Subscription_Manager
|
52 |
+
*/
|
53 |
+
public function getSubscriptionManager()
|
54 |
+
{
|
55 |
+
if (is_null($this->subscriptionManager)) {
|
56 |
+
$this->subscriptionManager = Mage::getModel('ops/subscription_manager');
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this->subscriptionManager;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param Netresearch_OPS_Model_Subscription_Manager $subscriptionManager
|
64 |
+
*
|
65 |
+
* @returns $this
|
66 |
+
*/
|
67 |
+
public function setSubscriptionManager($subscriptionManager)
|
68 |
+
{
|
69 |
+
$this->subscriptionManager = $subscriptionManager;
|
70 |
+
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag
|
77 |
+
*/
|
78 |
+
public function getParameterModel()
|
79 |
+
{
|
80 |
+
if (is_null($this->parameterModel)) {
|
81 |
+
$this->parameterModel = Mage::getModel('ops/payment_recurring_cc_parameterBag');
|
82 |
+
}
|
83 |
+
|
84 |
+
return $this->parameterModel;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag $parameterModel
|
89 |
+
*
|
90 |
+
* @returns $this
|
91 |
+
*/
|
92 |
+
public function setParameterModel($parameterModel)
|
93 |
+
{
|
94 |
+
$this->parameterModel = $parameterModel;
|
95 |
+
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Validate data
|
102 |
+
*
|
103 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
104 |
+
*
|
105 |
+
* @throws Mage_Core_Exception
|
106 |
+
*/
|
107 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
108 |
+
{
|
109 |
+
if ($profile->getState() === Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN) {
|
110 |
+
$this->invokeRequestParamValidation(
|
111 |
+
$this->getParameterModel()->collectProfileParameters($profile)->toArray()
|
112 |
+
);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Submits the trial subscription to the Acceptance webservice
|
118 |
+
*
|
119 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
120 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
121 |
+
*
|
122 |
+
* @return string[]
|
123 |
+
*/
|
124 |
+
protected function submitTrialSubscription(
|
125 |
+
Mage_Payment_Model_Recurring_Profile $profile,
|
126 |
+
Mage_Payment_Model_Info $paymentInfo
|
127 |
+
) {
|
128 |
+
if ($profile->getTrialPeriodUnit()) {
|
129 |
+
$requestParams = $this->getParameterModel()->collectAllParametersForTrial($paymentInfo, $profile);
|
130 |
+
$this->getParameterModel()->unsetData();
|
131 |
+
$response = $this->getDirectLinkHelper()->performDirectLinkRequest(
|
132 |
+
$profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
|
133 |
+
);
|
134 |
+
|
135 |
+
if ($this->getPaymentHelper()->isPaymentFailed($response['STATUS'])
|
136 |
+
|| $response['creation_status'] == Netresearch_OPS_Model_Subscription_Manager::CREATION_FAILED
|
137 |
+
) {
|
138 |
+
Mage::throwException($this->getDataHelper()->__('Placing of trial subscription transaction failed'));
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Submit to the gateway
|
145 |
+
*
|
146 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
147 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
148 |
+
*/
|
149 |
+
public function submitRecurringProfile(
|
150 |
+
Mage_Payment_Model_Recurring_Profile $profile,
|
151 |
+
Mage_Payment_Model_Info $paymentInfo
|
152 |
+
) {
|
153 |
+
$this->performPreDirectLinkCallActions($profile->getQuote(), $paymentInfo);
|
154 |
+
|
155 |
+
$this->submitTrialSubscription($profile, $paymentInfo);
|
156 |
+
|
157 |
+
$this->submitRegularSubscription($profile, $paymentInfo);
|
158 |
+
|
159 |
+
$this->submitInitialFee($profile, $paymentInfo);
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Fetch details
|
164 |
+
*
|
165 |
+
* @param string $referenceId
|
166 |
+
* @param Varien_Object $result
|
167 |
+
*/
|
168 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
169 |
+
{
|
170 |
+
Mage::throwException('Fetching profile details from Acceptance not supported');
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Check whether can get recurring profile details
|
175 |
+
*
|
176 |
+
* @return bool
|
177 |
+
*/
|
178 |
+
public function canGetRecurringProfileDetails()
|
179 |
+
{
|
180 |
+
// querying the subscription status via API is not possible
|
181 |
+
return false;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Update data
|
186 |
+
*
|
187 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
188 |
+
*/
|
189 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
190 |
+
{
|
191 |
+
Mage::throwException('Function not supported');
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Manage status update according to given new state on the profile
|
196 |
+
*
|
197 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
198 |
+
*/
|
199 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
200 |
+
{
|
201 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
202 |
+
switch ($profile->getNewState()) {
|
203 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE:
|
204 |
+
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
205 |
+
$this->addAdminNotice('To actually activate the subscription an update in the Acceptance backend is needed.'
|
206 |
+
);
|
207 |
+
} else {
|
208 |
+
Mage::throwException(
|
209 |
+
$this->getDataHelper()->__('Automatic activation not possible. Please contact our support team.')
|
210 |
+
);
|
211 |
+
}
|
212 |
+
break;
|
213 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED:
|
214 |
+
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
215 |
+
$this->addAdminNotice('To actually cancel the subscription an update in the Acceptance backend is needed.'
|
216 |
+
);
|
217 |
+
} else {
|
218 |
+
$this->sendSuspendMail($profile);
|
219 |
+
}
|
220 |
+
break;
|
221 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED:
|
222 |
+
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
223 |
+
$this->addAdminNotice('To actually suspend the subscription an update in the Acceptance backend is needed.'
|
224 |
+
);
|
225 |
+
} else {
|
226 |
+
$this->sendSuspendMail($profile);
|
227 |
+
}
|
228 |
+
break;
|
229 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_EXPIRED:
|
230 |
+
Mage::throwException('Expire function not implemented!');
|
231 |
+
break;
|
232 |
+
default:
|
233 |
+
$message = $this->getDataHelper()->__('Action for state %s not supported', $profile->getNewState());
|
234 |
+
Mage::throwException($message);
|
235 |
+
break;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Adds translated message to admin session as notice
|
241 |
+
*
|
242 |
+
* @param string $message
|
243 |
+
*/
|
244 |
+
protected function addAdminNotice($message)
|
245 |
+
{
|
246 |
+
Mage::getSingleton('adminhtml/session')->addNotice($this->getDataHelper()->__($message));
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
*
|
251 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
252 |
+
*
|
253 |
+
* @throws Mage_Core_Exception
|
254 |
+
*/
|
255 |
+
protected function sendSuspendMail($profile)
|
256 |
+
{
|
257 |
+
$session = Mage::getSingleton('customer/session');
|
258 |
+
$mailModel = Mage::getModel('ops/payment_features_paymentEmail');
|
259 |
+
if ($session->getCustomer()->getId() != $profile->getCustomerId()) {
|
260 |
+
// prevent access to subscriptions not of the customers account
|
261 |
+
Mage::throwException(
|
262 |
+
$this->getDataHelper()->__('You are not allowed to suspend this subscription!')
|
263 |
+
);
|
264 |
+
}
|
265 |
+
$customer = Mage::getModel('customer/customer')->load($profile->getCustomerId());
|
266 |
+
$result = $mailModel->sendSuspendSubscriptionMail($profile, $customer);
|
267 |
+
if ($result) {
|
268 |
+
// mail successfully sent
|
269 |
+
$profile->setNewState($profile::STATE_PENDING);
|
270 |
+
$profile->setOverrideState(true);
|
271 |
+
$session->addSuccess(
|
272 |
+
$this->getDataHelper()
|
273 |
+
->__('Your suspend request was successfully sent. A copy of the email will be sent to your address.'
|
274 |
+
)
|
275 |
+
);
|
276 |
+
} else {
|
277 |
+
// sending the mail failed
|
278 |
+
Mage::throwException(
|
279 |
+
$this->getDataHelper()
|
280 |
+
->__('Could not send suspend mail, please try again or contact our support directly.')
|
281 |
+
);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Check wether payment method is available for quote
|
287 |
+
*
|
288 |
+
* @param Mage_Sales_Model_Quote $quote
|
289 |
+
*
|
290 |
+
* @return bool
|
291 |
+
*/
|
292 |
+
public function isAvailable($quote = null)
|
293 |
+
{
|
294 |
+
if ($quote && !$quote->isNominal()) {
|
295 |
+
// allow only nominal quotes
|
296 |
+
return false;
|
297 |
+
}
|
298 |
+
|
299 |
+
return parent::isAvailable($quote);
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
public function hasBrandAliasInterfaceSupport($payment = null)
|
304 |
+
{
|
305 |
+
// only support inline, since we need the alias
|
306 |
+
return true;
|
307 |
+
}
|
308 |
+
|
309 |
+
public function getOrderPlaceRedirectUrl($payment = null)
|
310 |
+
{
|
311 |
+
if ('' == $this->getOpsHtmlAnswer($payment)) {
|
312 |
+
// Prevent redirect on cc payment
|
313 |
+
return false;
|
314 |
+
} else {
|
315 |
+
// 3ds redirect
|
316 |
+
return Mage::getModel('ops/config')->get3dSecureRedirectUrl();
|
317 |
+
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
public function isZeroAmountAuthorizationAllowed($storeId = null)
|
322 |
+
{
|
323 |
+
return false;
|
324 |
+
}
|
325 |
+
|
326 |
+
public function getBrandsForAliasInterface()
|
327 |
+
{
|
328 |
+
return $this->getConfigData('availableTypes');
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
333 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
334 |
+
*
|
335 |
+
* @throws Mage_Core_Exception
|
336 |
+
*/
|
337 |
+
protected function submitRegularSubscription(Mage_Payment_Model_Recurring_Profile $profile,
|
338 |
+
Mage_Payment_Model_Info $paymentInfo
|
339 |
+
) {
|
340 |
+
$requestParams = $this->getParameterModel()->collectAllParameters($paymentInfo, $profile);
|
341 |
+
$this->getParameterModel()->unsetData();
|
342 |
+
$response = $this->getDirectLinkHelper()->performDirectLinkRequest(
|
343 |
+
$profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
|
344 |
+
);
|
345 |
+
|
346 |
+
if ($this->getPaymentHelper()->isPaymentFailed($response['STATUS'])
|
347 |
+
|| $response['creation_status'] == Netresearch_OPS_Model_Subscription_Manager::CREATION_FAILED
|
348 |
+
) {
|
349 |
+
Mage::throwException($this->getDataHelper()->__('Placing of subscription transaction failed'));
|
350 |
+
}
|
351 |
+
|
352 |
+
$this->getSubscriptionManager()->processSubscriptionFeedback($response, $profile);
|
353 |
+
}
|
354 |
+
|
355 |
+
protected function submitInitialFee(
|
356 |
+
Mage_Payment_Model_Recurring_Profile $profile,
|
357 |
+
Mage_Payment_Model_Info $paymentInfo
|
358 |
+
) {
|
359 |
+
/** @var $profile Mage_Sales_Model_Recurring_Profile */
|
360 |
+
if ($profile->getInitAmount() > 0) {
|
361 |
+
$order = $this->getSubscriptionManager()->createInitialOrder($profile);
|
362 |
+
|
363 |
+
$requestParams = $this->getParameterModel()
|
364 |
+
->collectAllParametersForInitialFee($paymentInfo, $profile, $order);
|
365 |
+
$this->getParameterModel()->unsetData();
|
366 |
+
try{
|
367 |
+
|
368 |
+
$response = $this->getDirectLinkHelper()->performDirectLinkRequest(
|
369 |
+
$profile->getQuote(), $requestParams, $profile->getQuote()->getStoreId()
|
370 |
+
);
|
371 |
+
} catch (Exception $e){
|
372 |
+
Mage::logException($e);
|
373 |
+
}
|
374 |
+
|
375 |
+
$this->getSubscriptionManager()->processSubscriptionFeedback($response, $profile, $order);
|
376 |
+
|
377 |
+
}
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
|
382 |
+
}
|
app/code/community/Netresearch/OPS/Model/Payment/Recurring/Cc/ParameterBag.php
ADDED
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Parameter.php
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag extends Varien_Object
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Period units from Ingenico
|
36 |
+
*/
|
37 |
+
const PERIOD_UNIT_WEEK = 'ww';
|
38 |
+
const PERIOD_UNIT_DAY = 'd';
|
39 |
+
const PERIOD_UNIT_MONTH = 'm';
|
40 |
+
|
41 |
+
protected $requestHelper = null;
|
42 |
+
protected $config = null;
|
43 |
+
protected $quoteHelper = null;
|
44 |
+
protected $dataHelper = null;
|
45 |
+
protected $subscriptionHelper = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return Netresearch_OPS_Helper_Subscription
|
49 |
+
*/
|
50 |
+
public function getSubscriptionHelper()
|
51 |
+
{
|
52 |
+
if (is_null($this->subscriptionHelper)) {
|
53 |
+
$this->subscriptionHelper = Mage::helper('ops/subscription');
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->subscriptionHelper;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param Netresearch_OPS_Helper_Subscription $subscriptionHelper
|
61 |
+
*
|
62 |
+
* @returns $this
|
63 |
+
*/
|
64 |
+
public function setSubscriptionHelper($subscriptionHelper)
|
65 |
+
{
|
66 |
+
$this->subscriptionHelper = $subscriptionHelper;
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return Netresearch_OPS_Helper_Data
|
73 |
+
*/
|
74 |
+
public function getDataHelper()
|
75 |
+
{
|
76 |
+
if (is_null($this->dataHelper)) {
|
77 |
+
$this->dataHelper = Mage::helper('ops');
|
78 |
+
}
|
79 |
+
|
80 |
+
return $this->dataHelper;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
85 |
+
*
|
86 |
+
* @returns $this
|
87 |
+
*/
|
88 |
+
public function setDataHelper($dataHelper)
|
89 |
+
{
|
90 |
+
$this->dataHelper = $dataHelper;
|
91 |
+
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @return Netresearch_OPS_Helper_Quote
|
97 |
+
*/
|
98 |
+
public function getQuoteHelper()
|
99 |
+
{
|
100 |
+
if (is_null($this->quoteHelper)) {
|
101 |
+
$this->quoteHelper = Mage::helper('ops/quote');
|
102 |
+
}
|
103 |
+
|
104 |
+
return $this->quoteHelper;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param Netresearch_OPS_Helper_Quote $quoteHelper
|
109 |
+
*
|
110 |
+
* @returns $this
|
111 |
+
*/
|
112 |
+
public function setQuoteHelper($quoteHelper)
|
113 |
+
{
|
114 |
+
$this->quoteHelper = $quoteHelper;
|
115 |
+
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @return Netresearch_OPS_Model_Config
|
121 |
+
*/
|
122 |
+
public function getConfig()
|
123 |
+
{
|
124 |
+
if (is_null($this->config)) {
|
125 |
+
$this->config = Mage::getModel('ops/config');
|
126 |
+
}
|
127 |
+
|
128 |
+
return $this->config;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @param Netresearch_OPS_Model_Config $config
|
133 |
+
*
|
134 |
+
* @returns $this
|
135 |
+
*/
|
136 |
+
public function setConfig($config)
|
137 |
+
{
|
138 |
+
$this->config = $config;
|
139 |
+
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @return Netresearch_OPS_Helper_Payment_Request
|
145 |
+
*/
|
146 |
+
public function getRequestHelper()
|
147 |
+
{
|
148 |
+
if (is_null($this->requestHelper)) {
|
149 |
+
$this->requestHelper = Mage::helper('ops/payment_request');
|
150 |
+
}
|
151 |
+
|
152 |
+
return $this->requestHelper;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param Netresearch_OPS_Helper_Payment_Request $requestHelper
|
157 |
+
*
|
158 |
+
* @returns $this
|
159 |
+
*/
|
160 |
+
public function setRequestHelper($requestHelper)
|
161 |
+
{
|
162 |
+
$this->requestHelper = $requestHelper;
|
163 |
+
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Maps the Magento recurring profile units to the Acceptance ones
|
169 |
+
*
|
170 |
+
* @param string $unit
|
171 |
+
*
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
protected function mapUnit($unit)
|
175 |
+
{
|
176 |
+
switch ($unit) {
|
177 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_DAY:
|
178 |
+
return self::PERIOD_UNIT_DAY;
|
179 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_MONTH:
|
180 |
+
return self::PERIOD_UNIT_MONTH;
|
181 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_WEEK:
|
182 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH:
|
183 |
+
return self::PERIOD_UNIT_WEEK;
|
184 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR:
|
185 |
+
return self::PERIOD_UNIT_MONTH;
|
186 |
+
default:
|
187 |
+
return '';
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Some period units are not supported by default by Ingenico, therefore we must adjust the frequency for
|
193 |
+
* the following period units to match the MONTH unit:
|
194 |
+
*
|
195 |
+
* Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH
|
196 |
+
* Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR
|
197 |
+
*
|
198 |
+
* @param string $unit
|
199 |
+
* @param int $frequency
|
200 |
+
*
|
201 |
+
* @return int adjusted frequency
|
202 |
+
*/
|
203 |
+
protected function adjustFrequencyToUnitSpecialCases($unit, $frequency)
|
204 |
+
{
|
205 |
+
switch ($unit) {
|
206 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH:
|
207 |
+
$frequency *= 2;
|
208 |
+
break;
|
209 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR:
|
210 |
+
$frequency *= 12;
|
211 |
+
break;
|
212 |
+
default:
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
|
216 |
+
return $frequency;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Collects parameters specific to customer (addresses) and quote
|
221 |
+
*
|
222 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
223 |
+
*
|
224 |
+
* @return Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag
|
225 |
+
*/
|
226 |
+
public function collectPaymentParameters(Mage_Payment_Model_Info $paymentInfo, $trial = false)
|
227 |
+
{
|
228 |
+
$this->setData('CN', $paymentInfo->getAdditionalInformation('CC_CN'))
|
229 |
+
->setData('ALIAS', $paymentInfo->getAdditionalInformation('alias'))
|
230 |
+
->setData('BRAND', $paymentInfo->getAdditionalInformation('CC_BRAND'))
|
231 |
+
->setData('CURRENCY', $this->getQuoteHelper()->getQuoteCurrency($paymentInfo->getQuote()))
|
232 |
+
->setData('OPERATION', Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION)
|
233 |
+
->setData('ORIG', $this->getDataHelper()->getModuleVersionString())
|
234 |
+
->setData('REMOTE_ADDR', $paymentInfo->getQuote()->getRemoteIp());
|
235 |
+
|
236 |
+
|
237 |
+
if ($paymentInfo->getMethodInstance()->getConfigData('enabled_3dsecure')) {
|
238 |
+
$this->addData(
|
239 |
+
array(
|
240 |
+
'FLAG3D' => 'Y',
|
241 |
+
'WIN3DS' => Netresearch_OPS_Model_Payment_Abstract::OPS_DIRECTLINK_WIN3DS,
|
242 |
+
'LANGUAGE' => Mage::app()->getLocale()->getLocaleCode(),
|
243 |
+
'HTTP_ACCEPT' => '*/*',
|
244 |
+
'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
|
245 |
+
'ACCEPTURL' => $this->getConfig()->getAcceptUrl(),
|
246 |
+
'DECLINEURL' => $this->getConfig()->getDeclineUrl(),
|
247 |
+
'EXCEPTIONURL' => $this->getConfig()->getExceptionUrl(),
|
248 |
+
)
|
249 |
+
);
|
250 |
+
}
|
251 |
+
|
252 |
+
return $this;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Collects profile specific request parameters
|
257 |
+
*
|
258 |
+
* @see http://payment-services.ingenico.com/int/en/ogone/support/guides/integration%20guides/subscription-manager/via-e-commerce-and-directlink
|
259 |
+
*
|
260 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
261 |
+
* @param boolean $trial - if the array should contain the parameters necessary for the trial period
|
262 |
+
*
|
263 |
+
* @return $this
|
264 |
+
*/
|
265 |
+
public function collectProfileParameters(Mage_Payment_Model_Recurring_Profile $profile, $trial = false)
|
266 |
+
{
|
267 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
268 |
+
|
269 |
+
// get subscription amount from profile values
|
270 |
+
list($subscriptionAmount) = $this->getProfileValues($profile, $trial);
|
271 |
+
|
272 |
+
// determine dates and adjust period values depending on trial parameter
|
273 |
+
list($startDate, $endDate, $periodUnit, $periodFrequency) = $this->generateDates($profile, $trial);
|
274 |
+
|
275 |
+
$subOrderId = $this->getSubscriptionHelper()->generateSubscriptionId($profile, $trial);
|
276 |
+
|
277 |
+
$this->setData('SUB_COM', $profile->getScheduleDescription())
|
278 |
+
->setData('SUB_ORDERID', $subOrderId)
|
279 |
+
->setData('SUB_PERIOD_NUMBER', $periodFrequency)
|
280 |
+
->setData('SUB_PERIOD_UNIT', $periodUnit)
|
281 |
+
->setData('SUB_STARTDATE', $startDate->format('d/m/Y'))
|
282 |
+
->setData('SUB_ENDDATE', $endDate ? $endDate->format('d/m/Y') : '')
|
283 |
+
->setData('SUB_STATUS', 1)
|
284 |
+
->setData('SUBSCRIPTION_ID', $subOrderId)
|
285 |
+
->setData('ORDERID', $subOrderId)
|
286 |
+
->setData('SUB_AMOUNT', $this->getDataHelper()->getAmount($subscriptionAmount))
|
287 |
+
// amount is always 0 for subscription transactions
|
288 |
+
->setData('AMOUNT', 0)
|
289 |
+
->setData('SUB_PERIOD_MOMENT',
|
290 |
+
$this->getSubscriptionHelper()->getBillingDayForPeriodUnit($periodUnit, $profile->getStoreId())
|
291 |
+
);
|
292 |
+
|
293 |
+
// add OWNER* and ECOM_BILLTO_* and ECOM_SHIPTO_* parameters
|
294 |
+
$this->collectAddressParameters($profile);
|
295 |
+
|
296 |
+
return $this;
|
297 |
+
}
|
298 |
+
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Calculates the end date of the profile from the start date, frequency, period unit and maximum cycles
|
302 |
+
*
|
303 |
+
* @param DateTime $startDate | start date of the subscription
|
304 |
+
* @param string $periodUnit | unit of the frequency (d, w, m)
|
305 |
+
* @param int $frequency | every nth unit the customer will be charged
|
306 |
+
* @param int $maxCycles | maximum amount of cycles
|
307 |
+
*
|
308 |
+
* @return DateTime|null - the end date or null if no maximum cycle amount is set
|
309 |
+
*/
|
310 |
+
public function calculateEndDate(DateTime $startDate, $periodUnit, $frequency, $maxCycles)
|
311 |
+
{
|
312 |
+
if(!$this->isMappedUnit($periodUnit)){
|
313 |
+
$frequency = $this->adjustFrequencyToUnitSpecialCases($periodUnit, $frequency);
|
314 |
+
$periodUnit = $this->mapUnit($periodUnit);
|
315 |
+
}
|
316 |
+
|
317 |
+
$endDate = null;
|
318 |
+
if ($maxCycles) {
|
319 |
+
$endDate = clone $startDate;
|
320 |
+
if ($endDate->format('d') > 28 && $periodUnit != self::PERIOD_UNIT_DAY) {
|
321 |
+
$endDate->sub(new DateInterval('P3D'));
|
322 |
+
}
|
323 |
+
|
324 |
+
$dateDiff = $frequency * $maxCycles;
|
325 |
+
// fix period unit for week, since the payment provider requests a strange unit
|
326 |
+
$periodUnit = $periodUnit == self::PERIOD_UNIT_WEEK ? 'w' : $periodUnit;
|
327 |
+
|
328 |
+
$endDate->add(new DateInterval('P' . $dateDiff . strtoupper($periodUnit)));
|
329 |
+
}
|
330 |
+
return $endDate;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Tests if the given unit is already mapped to the Ingenico types
|
335 |
+
*
|
336 |
+
* @param string $unit - unit to check
|
337 |
+
*
|
338 |
+
* @return bool
|
339 |
+
*/
|
340 |
+
protected function isMappedUnit($unit){
|
341 |
+
return in_array($unit, array(
|
342 |
+
self::PERIOD_UNIT_DAY,
|
343 |
+
self::PERIOD_UNIT_WEEK,
|
344 |
+
self::PERIOD_UNIT_MONTH
|
345 |
+
));
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Collects all parameters from the given objects and returns the parameter array
|
350 |
+
*
|
351 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
352 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
353 |
+
*
|
354 |
+
* @return mixed[] - utf8_encoded request parameters
|
355 |
+
*/
|
356 |
+
public function collectAllParameters(Mage_Payment_Model_Info $paymentInfo,
|
357 |
+
Mage_Payment_Model_Recurring_Profile $profile
|
358 |
+
) {
|
359 |
+
$this->collectProfileParameters($profile)
|
360 |
+
->collectPaymentParameters($paymentInfo);
|
361 |
+
|
362 |
+
return $this->encodeValues()->toArray();
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Collects all parameters relevant for the trial period from the given objects and returns the parameter array
|
367 |
+
*
|
368 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
369 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
370 |
+
*
|
371 |
+
* @return mixed[] - utf8_encoded request parameters
|
372 |
+
*/
|
373 |
+
public function collectAllParametersForTrial(Mage_Payment_Model_Info $paymentInfo,
|
374 |
+
Mage_Payment_Model_Recurring_Profile $profile
|
375 |
+
) {
|
376 |
+
$this->collectProfileParameters($profile, true)
|
377 |
+
->collectPaymentParameters($paymentInfo, true);
|
378 |
+
|
379 |
+
return $this->encodeValues()->toArray();
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* collects all relevant parameters for the initial fee
|
384 |
+
*
|
385 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
386 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
387 |
+
* @param Mage_Sales_Model_Order $order
|
388 |
+
*
|
389 |
+
* @return string[] - utf8 encoded request parameters
|
390 |
+
*/
|
391 |
+
public function collectAllParametersForInitialFee(Mage_Payment_Model_Info $paymentInfo,
|
392 |
+
Mage_Payment_Model_Recurring_Profile $profile,
|
393 |
+
Mage_Sales_Model_Order $order
|
394 |
+
) {
|
395 |
+
/** @var $profile Mage_Sales_Model_Recurring_Profile */
|
396 |
+
$this->collectPaymentParameters($paymentInfo)->collectAddressParameters($profile);
|
397 |
+
|
398 |
+
$this->setData('AMOUNT', $this->getDataHelper()->getAmount($profile->getInitAmount()));
|
399 |
+
$this->setData('ORDERID', Mage::helper('ops/order')->getOpsOrderId($order));
|
400 |
+
|
401 |
+
return $this->encodeValues()->toArray();
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* utf8_decodes all parameters
|
406 |
+
*
|
407 |
+
* @return $this
|
408 |
+
*/
|
409 |
+
protected function encodeValues()
|
410 |
+
{
|
411 |
+
foreach ($this->getData() as $key => $value) {
|
412 |
+
$this->setData($key, utf8_decode($value));
|
413 |
+
}
|
414 |
+
|
415 |
+
return $this;
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Determines base values for the subscription depending on the trial parameter
|
420 |
+
*
|
421 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
422 |
+
* @param $trial - if the values for the trial subscription should be used or not
|
423 |
+
*
|
424 |
+
* @return string[] - containing the following:
|
425 |
+
* [0] => amount for the subscription,
|
426 |
+
* [1] => period Unit,
|
427 |
+
* [2] => periodFrequency,
|
428 |
+
* [3] => max
|
429 |
+
*/
|
430 |
+
protected function getProfileValues($profile, $trial)
|
431 |
+
{
|
432 |
+
// subscription equals shipping for the product + the product amount+tax itself
|
433 |
+
if ($trial) {
|
434 |
+
$subscriptionAmount = $profile->getTrialBillingAmount() + $profile->getShippingAmount();
|
435 |
+
$periodUnit = $this->mapUnit($profile->getTrialPeriodUnit());
|
436 |
+
$periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
|
437 |
+
$profile->getTrialPeriodUnit(), $profile->getTrialPeriodFrequency()
|
438 |
+
);
|
439 |
+
$maxCycles = $profile->getTrialPeriodMaxCycles();
|
440 |
+
|
441 |
+
} else {
|
442 |
+
$subscriptionAmount
|
443 |
+
= $profile->getBillingAmount() + $profile->getTaxAmount() + $profile->getShippingAmount();
|
444 |
+
$periodUnit = $this->mapUnit($profile->getPeriodUnit());
|
445 |
+
$periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
|
446 |
+
$profile->getPeriodUnit(), $profile->getPeriodFrequency()
|
447 |
+
);
|
448 |
+
$maxCycles = $profile->getPeriodMaxCycles();
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
return array($subscriptionAmount, $periodUnit, $periodFrequency, $maxCycles);
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Determines the start and end date from the given values.
|
457 |
+
*
|
458 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
459 |
+
* @param $trial
|
460 |
+
*
|
461 |
+
* @return string[] - containing the following:
|
462 |
+
* 0 => updated start date
|
463 |
+
* 1 => updated enddate
|
464 |
+
* 2 => updated period unit
|
465 |
+
* 3 => updated period frequency
|
466 |
+
*/
|
467 |
+
protected function generateDates($profile, $trial)
|
468 |
+
{
|
469 |
+
// get profile values - subscription amount is not needed here
|
470 |
+
list(, $periodUnit, $periodFrequency, $maxCycles) = $this->getProfileValues($profile, $trial);
|
471 |
+
|
472 |
+
if (!$profile->getTrialPeriodUnit() && !$trial || $trial) {
|
473 |
+
// if we collect the trial parameters, or if we don't have a trial period at all
|
474 |
+
$startDate = new DateTime($profile->getStartDateTime());
|
475 |
+
$endDate = $this->calculateEndDate(
|
476 |
+
$startDate, $periodUnit, $periodFrequency, $maxCycles
|
477 |
+
);
|
478 |
+
} else {
|
479 |
+
// if we collect the regular subscription and a trial is existent
|
480 |
+
$trialStartDate = new DateTime($profile->getStartDateTime());
|
481 |
+
$trialPeriodUnit = $this->mapUnit($profile->getTrialPeriodUnit());
|
482 |
+
$trialPeriodFrequency = $this->adjustFrequencyToUnitSpecialCases(
|
483 |
+
$profile->getTrialPeriodUnit(), $profile->getTrialPeriodFrequency()
|
484 |
+
);
|
485 |
+
// calculate trial end date and use it as start date for the regular subscription
|
486 |
+
$trialEndDate = $this->calculateEndDate(
|
487 |
+
$trialStartDate, $trialPeriodUnit, $trialPeriodFrequency, $profile->getTrialPeriodMaxCycles()
|
488 |
+
);
|
489 |
+
|
490 |
+
$startDate = clone $trialEndDate;
|
491 |
+
$periodUnit = $this->mapUnit($profile->getPeriodUnit());
|
492 |
+
$periodFrequency = $this->adjustFrequencyToUnitSpecialCases(
|
493 |
+
$profile->getPeriodUnit(), $profile->getPeriodFrequency()
|
494 |
+
);
|
495 |
+
$maxCycles = $profile->getPeriodMaxCycles();
|
496 |
+
$endDate = $this->calculateEndDate(
|
497 |
+
$trialEndDate, $periodUnit, $periodFrequency, $maxCycles
|
498 |
+
);
|
499 |
+
}
|
500 |
+
|
501 |
+
return array($startDate, $endDate, $periodUnit, $periodFrequency);
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Add address data to the bag if it is available
|
506 |
+
*
|
507 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
508 |
+
*/
|
509 |
+
protected function collectAddressParameters(Mage_Payment_Model_Recurring_Profile $profile)
|
510 |
+
{
|
511 |
+
/** @var $profile Mage_Sales_Model_Recurring_Profile */
|
512 |
+
if ($profile->getQuote()) {
|
513 |
+
$this->addData(
|
514 |
+
$this->getRequestHelper()->getOwnerParams(
|
515 |
+
$profile->getQuote()->getBillingAddress(), $profile->getQuote()
|
516 |
+
)
|
517 |
+
)->addData($this->getRequestHelper()->extractBillToParameters($profile->getQuote()->getBillingAddress()));
|
518 |
+
|
519 |
+
if ($profile->getQuote()->getShippingAddress()) {
|
520 |
+
$this->addData(
|
521 |
+
$this->getRequestHelper()->extractShipToParameters($profile->getQuote()->getShippingAddress())
|
522 |
+
);
|
523 |
+
}
|
524 |
+
}
|
525 |
+
}
|
526 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Handler.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Handler.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Handler
|
33 |
+
{
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param array $responseArray
|
37 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
|
38 |
+
* @param bool $shouldRegisterFeedback
|
39 |
+
* determines if the Mage_Sales_Model_Order_Payments register*Feedback
|
40 |
+
* functions get called, defaults to true
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
public function processResponse(
|
44 |
+
$responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod, $shouldRegisterFeedback = true
|
45 |
+
){
|
46 |
+
$responseArray = array_change_key_case($responseArray, CASE_LOWER);
|
47 |
+
$this->getTypeHandler($responseArray['status'])
|
48 |
+
->handleResponse($responseArray, $paymentMethod, $shouldRegisterFeedback);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $status
|
53 |
+
*
|
54 |
+
* @return Netresearch_OPS_Model_Response_TypeInterface
|
55 |
+
*/
|
56 |
+
protected function getTypeHandler($status)
|
57 |
+
{
|
58 |
+
$type = null;
|
59 |
+
|
60 |
+
if (Netresearch_OPS_Model_Status::isCapture($status)) {
|
61 |
+
$type = Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_TRANSACTION_TYPE;
|
62 |
+
} elseif (Netresearch_OPS_Model_Status::isRefund($status)) {
|
63 |
+
$type = Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_TRANSACTION_TYPE;
|
64 |
+
} elseif (Netresearch_OPS_Model_Status::isVoid($status)) {
|
65 |
+
$type = Netresearch_OPS_Model_Payment_Abstract::OPS_VOID_TRANSACTION_TYPE;
|
66 |
+
} elseif (Netresearch_OPS_Model_Status::isAuthorize($status)) {
|
67 |
+
$type = Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_TRANSACTION_TYPE;
|
68 |
+
} elseif (Netresearch_OPS_Model_Status::isSpecialStatus($status)) {
|
69 |
+
$type = 'special';
|
70 |
+
} else {
|
71 |
+
Mage::throwException(Mage::helper('ops')->__('Can not handle status %s.', $status));
|
72 |
+
}
|
73 |
+
|
74 |
+
return Mage::getModel('ops/response_type_' . $type);
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Abstract.php
ADDED
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Abstract.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Class Netresearch_OPS_Model_Response_Type_Abstract
|
34 |
+
*
|
35 |
+
* @method Netresearch_OPS_Model_Payment_Abstract getMethodInstance()
|
36 |
+
* @method Netresearch_OPS_Model_Response_Type_Abstract setMethodInstance(Netresearch_OPS_Model_Payment_Abstract $instance)
|
37 |
+
* @method int getStatus()
|
38 |
+
* @method int getPayid()
|
39 |
+
* @method bool hasPayidsub()
|
40 |
+
* @method int getPayidsub()
|
41 |
+
* @method float getAmount()
|
42 |
+
* @method string getCurrency()
|
43 |
+
* @method string getOrderid()
|
44 |
+
* @method string getAavaddress()
|
45 |
+
* @method string getAavcheck()
|
46 |
+
* @method string get Aavzip()
|
47 |
+
* @method string getAcceptance()
|
48 |
+
* @method string getBin()
|
49 |
+
* @method string getBrand()
|
50 |
+
* @method string getCardno()
|
51 |
+
* @method string getCccty()
|
52 |
+
* @method string getCn()
|
53 |
+
* @method string getCvccheck()
|
54 |
+
* @method string getScoring()
|
55 |
+
* @method bool hasScoring()
|
56 |
+
* @method string getScoCategory()
|
57 |
+
* @method bool hasScoCategory()
|
58 |
+
* @method string getShasign()
|
59 |
+
* @method string getSubbrand()
|
60 |
+
* @method string getTrxdate()
|
61 |
+
* @method string getVc()
|
62 |
+
* @method int getNcstatus()
|
63 |
+
* @method string getNcerror()
|
64 |
+
* @method string getNcerrorplus()
|
65 |
+
* @method string getHtmlAnswer()
|
66 |
+
* @method string getIpcty()
|
67 |
+
* @method bool hasAcceptance()
|
68 |
+
* @method bool hasBrand()
|
69 |
+
* @method bool getShouldRegisterFeedback() if feedback should get registered on payment object
|
70 |
+
* @method Netresearch_OPS_Model_Response_Type_Abstract setShouldRegisterFeedback($shouldRegisterFeedback)
|
71 |
+
*
|
72 |
+
*/
|
73 |
+
abstract class Netresearch_OPS_Model_Response_Type_Abstract extends Varien_Object
|
74 |
+
implements Netresearch_OPS_Model_Response_TypeInterface
|
75 |
+
{
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return Netresearch_OPS_Model_Config
|
79 |
+
*/
|
80 |
+
public function getConfig()
|
81 |
+
{
|
82 |
+
if (is_null($this->getData('config'))) {
|
83 |
+
$this->setData('config', Mage::getModel('ops/config'));
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this->getData('config');
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Performs the necessary actions for Magento to progress the order state correctly and automatically build the
|
91 |
+
* create sales objects
|
92 |
+
*
|
93 |
+
* @param array $responseArray
|
94 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
|
95 |
+
* @param bool $shouldRegisterFeedback determines if the Mage_Sales_Model_Order_Payments register*Feedback
|
96 |
+
* functions get called, defaults to true
|
97 |
+
*
|
98 |
+
* @return Netresearch_OPS_Model_Response_TypeInterface
|
99 |
+
*/
|
100 |
+
public function handleResponse($responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod,
|
101 |
+
$shouldRegisterFeedback = true
|
102 |
+
) {
|
103 |
+
$this->setData(array_change_key_case($responseArray, CASE_LOWER));
|
104 |
+
$this->setMethodInstance($paymentMethod);
|
105 |
+
$this->setShouldRegisterFeedback($shouldRegisterFeedback);
|
106 |
+
|
107 |
+
if ($this->getStatus() == $this->getMethodInstance()->getInfoInstance()->getAdditionalInformation('status')
|
108 |
+
&& $this->getTransactionId() == $paymentMethod->getInfoInstance()->getLastTransId()) {
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
$this->setGeneralTransactionInfo();
|
113 |
+
$this->_handleResponse();
|
114 |
+
$this->updateAdditionalInformation();
|
115 |
+
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Handles the specific actions for the concrete payment status
|
121 |
+
*/
|
122 |
+
protected abstract function _handleResponse();
|
123 |
+
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Updates the additional information of the payment info object
|
127 |
+
*
|
128 |
+
* @see \Netresearch_OPS_Model_Response_Type_Abstract::updateDefaultInformation
|
129 |
+
* @see \Netresearch_OPS_Model_Response_Type_Abstract::setFraudDetectionParameters
|
130 |
+
*/
|
131 |
+
protected function updateAdditionalInformation()
|
132 |
+
{
|
133 |
+
$this->updateDefaultInformation();
|
134 |
+
$this->setFraudDetectionParameters();
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Updates default information in additional information of the payment info object
|
139 |
+
*/
|
140 |
+
protected function updateDefaultInformation()
|
141 |
+
{
|
142 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
143 |
+
|
144 |
+
$payment->setAdditionalInformation('paymentId', $this->getPayid())
|
145 |
+
->setAdditionalInformation('status', $this->getStatus());
|
146 |
+
|
147 |
+
if ($this->hasAcceptance()) {
|
148 |
+
$payment->setAdditionalInformation('acceptence', $this->getAcceptance());
|
149 |
+
}
|
150 |
+
|
151 |
+
if ($this->hasBrand() && $this->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Cc) {
|
152 |
+
$payment->setAdditionalInformation('CC_BRAND', $this->getBrand());
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Sets Transaction details (TransactionId etc.)
|
158 |
+
*/
|
159 |
+
protected function setGeneralTransactionInfo()
|
160 |
+
{
|
161 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
162 |
+
|
163 |
+
$payment->setTransactionParentId($this->getPayid());
|
164 |
+
$transId = $this->getTransactionId();
|
165 |
+
|
166 |
+
$payment->setLastTransId($transId);
|
167 |
+
$payment->setTransactionId($transId);
|
168 |
+
$payment->setIsTransactionClosed(false);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Updates fraud detection information on additional information of the payment info object
|
173 |
+
*/
|
174 |
+
protected function setFraudDetectionParameters()
|
175 |
+
{
|
176 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
177 |
+
if ($this->hasScoring()) {
|
178 |
+
$payment->setAdditionalInformation('scoring', $this->getScoring());
|
179 |
+
}
|
180 |
+
|
181 |
+
if ($this->hasScoCategory()) {
|
182 |
+
$payment->setAdditionalInformation('scoringCategory', $this->getScoCategory());
|
183 |
+
}
|
184 |
+
|
185 |
+
$additionalScoringData = array();
|
186 |
+
foreach ($this->getConfig()->getAdditionalScoringKeys() as $key) {
|
187 |
+
if ($this->hasData(strtolower($key))) {
|
188 |
+
if (false === mb_detect_encoding($this->getData(strtolower($key)), 'UTF-8', true)) {
|
189 |
+
$additionalScoringData[$key] = utf8_encode($this->getData(strtolower($key)));
|
190 |
+
} else {
|
191 |
+
$additionalScoringData[$key] = $this->getData(strtolower($key));
|
192 |
+
}
|
193 |
+
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
$payment->setAdditionalInformation('additionalScoringData', $additionalScoringData);
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @param string $orderComment
|
202 |
+
* @param string $additionalInfo
|
203 |
+
*
|
204 |
+
* @return string
|
205 |
+
*/
|
206 |
+
protected function addOrderComment($orderComment, $additionalInfo = '')
|
207 |
+
{
|
208 |
+
|
209 |
+
$orderComment = $this->getOrderComment($orderComment, $additionalInfo);
|
210 |
+
$this->getMethodInstance()->getInfoInstance()->getOrder()->addStatusHistoryComment($orderComment);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Add order comment about final status
|
215 |
+
*
|
216 |
+
* @param string $additionalInfo
|
217 |
+
*/
|
218 |
+
protected function addFinalStatusComment($additionalInfo = '')
|
219 |
+
{
|
220 |
+
$this->addOrderComment($this->getFinalStatusComment($additionalInfo));
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Add order comment about intermediate status
|
225 |
+
*
|
226 |
+
* @param string $additionalInfo
|
227 |
+
*/
|
228 |
+
protected function addIntermediateStatusComment($additionalInfo = '')
|
229 |
+
{
|
230 |
+
$this->addOrderComment($this->getIntermediateStatusComment($additionalInfo));
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Add order comment about refused status
|
235 |
+
*
|
236 |
+
* @param string $additionalInfo
|
237 |
+
*/
|
238 |
+
protected function addRefusedStatusComment($additionalInfo = '')
|
239 |
+
{
|
240 |
+
$this->addOrderComment($this->getRefusedStatusComment($additionalInfo));
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Add order comment about fraud status
|
245 |
+
*
|
246 |
+
* @param string $additionalInfo
|
247 |
+
*/
|
248 |
+
protected function addFraudStatusComment($additionalInfo = '')
|
249 |
+
{
|
250 |
+
$this->addOrderComment($this->getFraudStatusComment($additionalInfo));
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* @param string $additionalInfo
|
256 |
+
*
|
257 |
+
* @return string
|
258 |
+
*/
|
259 |
+
protected function getFinalStatusComment($additionalInfo = '')
|
260 |
+
{
|
261 |
+
$orderComment = Mage::helper('ops')->__(
|
262 |
+
'Received Acceptance feedback status update with final status %s.',
|
263 |
+
$this->getStatus()
|
264 |
+
|
265 |
+
);
|
266 |
+
return $this->getOrderComment($orderComment, $additionalInfo);
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* @param string $additionalInfo
|
272 |
+
*
|
273 |
+
* @return string
|
274 |
+
*/
|
275 |
+
protected function getIntermediateStatusComment($additionalInfo = '')
|
276 |
+
{
|
277 |
+
$orderComment = Mage::helper('ops')->__(
|
278 |
+
'Received Acceptance feedback status update with intermediate status %s.',
|
279 |
+
$this->getStatus()
|
280 |
+
);
|
281 |
+
return $this->getOrderComment($orderComment, $additionalInfo);
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* @param string $additionalInfo
|
286 |
+
*
|
287 |
+
* @return string
|
288 |
+
*/
|
289 |
+
protected function getRefusedStatusComment($additionalInfo = '')
|
290 |
+
{
|
291 |
+
$orderComment = Mage::helper('ops')->__(
|
292 |
+
'Received Acceptance feedback status update with refused status %s.',
|
293 |
+
$this->getStatus()
|
294 |
+
);
|
295 |
+
return $this->getOrderComment($orderComment, $additionalInfo);
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param string $additionalInfo
|
300 |
+
*
|
301 |
+
* @return string
|
302 |
+
*/
|
303 |
+
protected function getFraudStatusComment($additionalInfo = '')
|
304 |
+
{
|
305 |
+
$orderComment = Mage::helper('ops')->__(
|
306 |
+
'Received Acceptance feedback status update with suspected fraud status %s.',
|
307 |
+
$this->getStatus()
|
308 |
+
);
|
309 |
+
return $this->getOrderComment($orderComment, $additionalInfo);
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* @param string $additionalInfo
|
314 |
+
* @param string $orderComment
|
315 |
+
*
|
316 |
+
* @return string
|
317 |
+
*/
|
318 |
+
protected function getOrderComment($orderComment, $additionalInfo = '')
|
319 |
+
{
|
320 |
+
if ($additionalInfo) {
|
321 |
+
$orderComment .= ' ' . $additionalInfo;
|
322 |
+
}
|
323 |
+
|
324 |
+
return $orderComment;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Merges the PAYID with the PAYIDSUB, if the latter is present, otherwise just returns the PAYID
|
329 |
+
*
|
330 |
+
* @return string
|
331 |
+
*/
|
332 |
+
public function getTransactionId()
|
333 |
+
{
|
334 |
+
$transId = $this->getPayid();
|
335 |
+
if ($this->hasPayidsub()) {
|
336 |
+
$transId .= '/' . $this->getPayidsub();
|
337 |
+
}
|
338 |
+
|
339 |
+
return $transId;
|
340 |
+
}
|
341 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Authorize.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Authorize.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Type_Authorize extends Netresearch_OPS_Model_Response_Type_Abstract
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Handles the specific actions for the concrete payment status
|
36 |
+
*/
|
37 |
+
protected function _handleResponse()
|
38 |
+
{
|
39 |
+
if (!Netresearch_OPS_Model_Status::isAuthorize($this->getStatus())) {
|
40 |
+
throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a authorize status!', $this->getStatus()));
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/** @var Mage_Sales_Model_Order $order */
|
45 |
+
$order = $this->getMethodInstance()->getInfoInstance()->getOrder();
|
46 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
47 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
48 |
+
|
49 |
+
// if no parent transaction id has been set yet set the parentTransactionId so we can void
|
50 |
+
if (!$payment->getParentTransactionId()) {
|
51 |
+
$payment->setParentTransactionId($this->getPayid());
|
52 |
+
}
|
53 |
+
|
54 |
+
if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
|
55 |
+
// handle authorization declined
|
56 |
+
// thrown exception gets catched by core and order will not been created
|
57 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED
|
58 |
+
) {
|
59 |
+
if (!$this->getShouldRegisterFeedback()) {
|
60 |
+
Mage::throwException(
|
61 |
+
Mage::helper('ops')->__(
|
62 |
+
'Payment failed because the authorization was declined! Please choose another payment method.'
|
63 |
+
)
|
64 |
+
);
|
65 |
+
} elseif ($payment->getAdditionalInformation('status')
|
66 |
+
== Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION
|
67 |
+
&& $order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW
|
68 |
+
) {
|
69 |
+
try {
|
70 |
+
// if the payment was previously in payment review/has status 46 the identification obviously failed and the order gets canceled
|
71 |
+
$payment->setNotificationResult(true);
|
72 |
+
$payment->registerPaymentReviewAction(
|
73 |
+
Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, false
|
74 |
+
);
|
75 |
+
} catch (Mage_Core_Exception $e) {
|
76 |
+
/**
|
77 |
+
* in CE 1.7 Mage_Sales_Model_Order::registerCancellation will always fail with exception if the
|
78 |
+
* order is in payment_review state. we therefore cancel the order 'manually'.
|
79 |
+
*
|
80 |
+
* below code is c&p from Mage_Sales_Model_Order::registerCancellation:
|
81 |
+
*
|
82 |
+
* @see Mage_Sales_Model_Order::registerCancellation
|
83 |
+
*/
|
84 |
+
if ($e->getMessage() === Mage::helper('sales')->__('Order does not allow to be canceled.')) {
|
85 |
+
$cancelState = Mage_Sales_Model_Order::STATE_CANCELED;
|
86 |
+
foreach ($order->getAllItems() as $item) {
|
87 |
+
if ($cancelState != Mage_Sales_Model_Order::STATE_PROCESSING
|
88 |
+
&& $item->getQtyToRefund()
|
89 |
+
) {
|
90 |
+
if ($item->getQtyToShip() > $item->getQtyToCancel()) {
|
91 |
+
$cancelState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
92 |
+
} else {
|
93 |
+
$cancelState = Mage_Sales_Model_Order::STATE_COMPLETE;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
$item->cancel();
|
97 |
+
}
|
98 |
+
|
99 |
+
$order->setSubtotalCanceled($order->getSubtotal() - $order->getSubtotalInvoiced());
|
100 |
+
$order->setBaseSubtotalCanceled(
|
101 |
+
$order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced()
|
102 |
+
);
|
103 |
+
|
104 |
+
$order->setTaxCanceled($order->getTaxAmount() - $order->getTaxInvoiced());
|
105 |
+
$order->setBaseTaxCanceled($order->getBaseTaxAmount() - $order->getBaseTaxInvoiced());
|
106 |
+
|
107 |
+
$order->setShippingCanceled($order->getShippingAmount() - $order->getShippingInvoiced());
|
108 |
+
$order->setBaseShippingCanceled(
|
109 |
+
$order->getBaseShippingAmount() - $order->getBaseShippingInvoiced()
|
110 |
+
);
|
111 |
+
|
112 |
+
$order->setDiscountCanceled(
|
113 |
+
abs($order->getDiscountAmount()) - $order->getDiscountInvoiced()
|
114 |
+
);
|
115 |
+
$order->setBaseDiscountCanceled(
|
116 |
+
abs($order->getBaseDiscountAmount()) - $order->getBaseDiscountInvoiced()
|
117 |
+
);
|
118 |
+
|
119 |
+
$order->setTotalCanceled($order->getGrandTotal() - $order->getTotalPaid());
|
120 |
+
$order->setBaseTotalCanceled($order->getBaseGrandTotal() - $order->getBaseTotalPaid());
|
121 |
+
|
122 |
+
$order->setState($cancelState, true, $this->getFinalStatusComment());
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
} elseif ($this->getStatus() == Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER) {
|
127 |
+
$order->registerCancellation($this->getFinalStatusComment());
|
128 |
+
}
|
129 |
+
|
130 |
+
if ($this->getShouldRegisterFeedback()) {
|
131 |
+
if ($order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
|
132 |
+
|
133 |
+
$action = Mage_Sales_Model_Order_Payment::REVIEW_ACTION_ACCEPT;
|
134 |
+
$targetState = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
|
135 |
+
if (Netresearch_OPS_Model_Status::canResendPaymentInfo($this->getStatus())
|
136 |
+
&& Mage::helper('ops/payment')->isInlinePayment($payment)
|
137 |
+
) {
|
138 |
+
$targetState = Mage_Sales_Model_Order::STATE_CANCELED;
|
139 |
+
$action = Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY;
|
140 |
+
}
|
141 |
+
$payment->setNotificationResult(true);
|
142 |
+
$payment->registerPaymentReviewAction($action, false);
|
143 |
+
if ($order->getState() != $targetState) {
|
144 |
+
$order->setState($targetState, true, $this->getFinalStatusComment());
|
145 |
+
}
|
146 |
+
} elseif ($order->getState() === Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
147 |
+
|| $order->getState() === Mage_Sales_Model_Order::STATE_NEW
|
148 |
+
) {
|
149 |
+
$payment->registerAuthorizationNotification($this->getAmount());
|
150 |
+
$order->setState(
|
151 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $this->getFinalStatusComment()
|
152 |
+
);
|
153 |
+
|
154 |
+
}
|
155 |
+
} else {
|
156 |
+
$this->addFinalStatusComment();
|
157 |
+
}
|
158 |
+
} else {
|
159 |
+
$payment->setIsTransactionPending(true);
|
160 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::STAND_BY_SUSPECTED_FRAUD) {
|
161 |
+
$payment->setIsFraudDetected(true);
|
162 |
+
$order->setState(
|
163 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
|
164 |
+
Mage_Sales_Model_Order::STATUS_FRAUD,
|
165 |
+
$this->getFraudStatusComment(
|
166 |
+
Mage::helper('ops')->__('Please have a look in Acceptance backend for more information.')
|
167 |
+
)
|
168 |
+
);
|
169 |
+
} else {
|
170 |
+
$order->addStatusHistoryComment($this->getIntermediateStatusComment());
|
171 |
+
}
|
172 |
+
if ($this->getShouldRegisterFeedback()) {
|
173 |
+
$payment->registerAuthorizationNotification($this->getAmount());
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
if ($this->getShouldRegisterFeedback()) {
|
178 |
+
$payment->save();
|
179 |
+
$order->save();
|
180 |
+
|
181 |
+
// gateway payments do not send confirmation emails by default
|
182 |
+
if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED){
|
183 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Capture.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Capture.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Type_Capture extends Netresearch_OPS_Model_Response_Type_Abstract
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Handles the specific actions for the concrete payment status
|
36 |
+
*/
|
37 |
+
protected function _handleResponse()
|
38 |
+
{
|
39 |
+
if (!Netresearch_OPS_Model_Status::isCapture($this->getStatus())) {
|
40 |
+
throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a capture status!', $this->getStatus()));
|
41 |
+
}
|
42 |
+
|
43 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
44 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
45 |
+
/** @var Mage_Sales_Model_Order $order */
|
46 |
+
$order = $payment->getOrder();
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Basically we have to check the following things here:
|
51 |
+
*
|
52 |
+
* Order state - payment_review suggests an already existing intermediate status
|
53 |
+
* - pending_payment or new suggests no feedback yet
|
54 |
+
*
|
55 |
+
* payment status - intermediate and not failed -> move to payment review or add another comment
|
56 |
+
* - intermediate and failed -> if recoverable let the order open and place comment
|
57 |
+
* - finished - finish invoice dependent on order state
|
58 |
+
*/
|
59 |
+
|
60 |
+
if (Netresearch_OPS_Model_Status::isIntermediate($this->getStatus())) {
|
61 |
+
|
62 |
+
$message = $this->getIntermediateStatusComment();
|
63 |
+
$payment->setIsTransactionPending(true);
|
64 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
65 |
+
|| $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING
|
66 |
+
) {
|
67 |
+
// transaction was placed on PSP, initial feedback to shop or partial capture case
|
68 |
+
|
69 |
+
$payment->setPreparedMessage($message);
|
70 |
+
if ($this->getShouldRegisterFeedback()) {
|
71 |
+
$payment->registerCaptureNotification($this->getAmount());
|
72 |
+
}
|
73 |
+
|
74 |
+
} elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
|
75 |
+
// payment was pending and is still pending
|
76 |
+
$payment->setIsTransactionApproved(false);
|
77 |
+
$payment->setIsTransactionDenied(false);
|
78 |
+
$payment->setPreparedMessage($message);
|
79 |
+
|
80 |
+
if ($this->getShouldRegisterFeedback()) {
|
81 |
+
$payment->setNotificationResult(true);
|
82 |
+
$payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false);
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
// final status, means 9 or 95
|
88 |
+
$message = $this->getFinalStatusComment();
|
89 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
|
90 |
+
$payment->setNotificationResult(true);
|
91 |
+
$payment->setPreparedMessage($message);
|
92 |
+
if ($this->getShouldRegisterFeedback()) {
|
93 |
+
$payment->setNotificationResult(true);
|
94 |
+
$payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_ACCEPT, false);
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
$payment->setPreparedMessage($message);
|
98 |
+
if ($this->getShouldRegisterFeedback()) {
|
99 |
+
$payment->registerCaptureNotification($this->getAmount());
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
if ($this->getShouldRegisterFeedback()) {
|
105 |
+
$payment->save();
|
106 |
+
$order->save();
|
107 |
+
|
108 |
+
// gateway payments do not send confirmation emails by default
|
109 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
110 |
+
|
111 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($this->getTransactionId(), 'transaction_id');
|
112 |
+
if($invoice->getId()){
|
113 |
+
Mage::helper('ops')->sendTransactionalEmail($invoice);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Refund.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Refund.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Type_Refund extends Netresearch_OPS_Model_Response_Type_Abstract
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Handles the specific actions for the concrete payment status
|
36 |
+
*/
|
37 |
+
protected function _handleResponse()
|
38 |
+
{
|
39 |
+
if (!Netresearch_OPS_Model_Status::isRefund($this->getStatus())) {
|
40 |
+
Mage::throwException(Mage::helper('ops')->__('%s is not a refund status!', $this->getStatus()));
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
45 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
46 |
+
|
47 |
+
/** @var Mage_Sales_Model_Order $order */
|
48 |
+
$order = $payment->getOrder();
|
49 |
+
|
50 |
+
if (!$this->hasPayidsub()) {
|
51 |
+
$creditMemo = $this->determineCreditMemo();
|
52 |
+
$payment->setRefundTransactionId($creditMemo->getTransactionId());
|
53 |
+
} else {
|
54 |
+
$creditMemo = Mage::getModel('sales/order_creditmemo')->load(
|
55 |
+
$this->getTransactionId(), 'transaction_id'
|
56 |
+
);
|
57 |
+
$payment->setRefundTransactionId($this->getTransactionId());
|
58 |
+
}
|
59 |
+
|
60 |
+
if ($creditMemo->getId()) {
|
61 |
+
if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())
|
62 |
+
&& $creditMemo->getState() == Mage_Sales_Model_Order_Creditmemo::STATE_OPEN
|
63 |
+
) {
|
64 |
+
$creditMemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED);
|
65 |
+
$this->closeRefundTransaction($creditMemo);
|
66 |
+
$this->addFinalStatusComment();
|
67 |
+
} elseif ($this->getStatus() == Netresearch_OPS_Model_Status::REFUND_REFUSED) {
|
68 |
+
$order = $creditMemo->getOrder();
|
69 |
+
$creditMemo->cancel()->save();
|
70 |
+
$this->closeRefundTransaction($creditMemo);
|
71 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($creditMemo->getInvoiceId());
|
72 |
+
$invoice->setIsUsedForRefund(0)
|
73 |
+
->setBaseTotalRefunded(
|
74 |
+
$invoice->getBaseTotalRefunded() - $creditMemo->getBaseGrandTotal()
|
75 |
+
);
|
76 |
+
$creditMemo->setInvoice($invoice);
|
77 |
+
/** @var Mage_Sales_Model_Order_Creditmemo_Item $item */
|
78 |
+
foreach ($creditMemo->getAllItems() as $item) {
|
79 |
+
$item->getOrderItem()->setAmountRefunded(
|
80 |
+
$item->getOrderItem()->getAmountRefunded() - $item->getRowTotal()
|
81 |
+
);
|
82 |
+
$item->getOrderItem()->setBaseAmountRefunded(
|
83 |
+
$item->getOrderItem()->getBaseAmountRefunded() - $item->getBaseRowTotal()
|
84 |
+
);
|
85 |
+
}
|
86 |
+
$order->setTotalRefunded($order->getTotalRefunded() - $creditMemo->getBaseGrandTotal());
|
87 |
+
$order->setBaseTotalRefunded($order->getBaseTotalRefunded() - $creditMemo->getBaseGrandTotal());
|
88 |
+
|
89 |
+
$this->addRefusedStatusComment();
|
90 |
+
$state = Mage_Sales_Model_Order::STATE_COMPLETE;
|
91 |
+
if ($order->canShip() || $order->canInvoice()) {
|
92 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
93 |
+
}
|
94 |
+
$order->setState(
|
95 |
+
$state,
|
96 |
+
true,
|
97 |
+
$this->getRefusedStatusComment(Mage::helper('ops')->__('Refund refused by Acceptance.'))
|
98 |
+
);
|
99 |
+
} else {
|
100 |
+
$this->addIntermediateStatusComment();
|
101 |
+
}
|
102 |
+
|
103 |
+
} else {
|
104 |
+
if ($this->getShouldRegisterFeedback()) {
|
105 |
+
$payment->setParentTransactionId($this->getPayid());
|
106 |
+
$payment->setTransactionId($this->getTransactionId());
|
107 |
+
$payment->setIsTransactionClosed(Netresearch_OPS_Model_Status::isFinal($this->getStatus()));
|
108 |
+
$payment->registerRefundNotification($this->getAmount());
|
109 |
+
}
|
110 |
+
if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
|
111 |
+
$this->addFinalStatusComment();
|
112 |
+
} else {
|
113 |
+
$this->addIntermediateStatusComment();
|
114 |
+
$creditMemo = $payment->getCreatedCreditMemo() ?: $payment->getCreditmemo();
|
115 |
+
if ($creditMemo) {
|
116 |
+
$creditMemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
if ($this->getShouldRegisterFeedback()) {
|
121 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
122 |
+
->addObject($order)
|
123 |
+
->addObject($payment)
|
124 |
+
->addObject($creditMemo);
|
125 |
+
|
126 |
+
if ($creditMemo->getInvoice()) {
|
127 |
+
$transactionSave->addObject($creditMemo->getInvoice());
|
128 |
+
}
|
129 |
+
$transactionSave->save();
|
130 |
+
}
|
131 |
+
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Will load the creditmemo by identifying open refund transactions
|
137 |
+
*
|
138 |
+
* @return Mage_Sales_Model_Order_Creditmemo|null
|
139 |
+
*/
|
140 |
+
protected function determineCreditMemo()
|
141 |
+
{
|
142 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
143 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
144 |
+
$refundTransaction = Mage::helper('ops/order_refund')->getOpenRefundTransaction($payment);
|
145 |
+
/** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
|
146 |
+
$creditmemo = Mage::getModel('sales/order_creditmemo')->load(
|
147 |
+
$refundTransaction->getTxnId(), 'transaction_id'
|
148 |
+
);
|
149 |
+
|
150 |
+
return $creditmemo;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Closes the refund transaction for the given creditmemo
|
155 |
+
*
|
156 |
+
* @param $creditMemo
|
157 |
+
*/
|
158 |
+
protected function closeRefundTransaction($creditMemo)
|
159 |
+
{
|
160 |
+
$refundTransaction = $this->getMethodInstance()->getInfoInstance()->lookupTransaction(
|
161 |
+
$creditMemo->getTransactionId(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
|
162 |
+
);
|
163 |
+
if ($refundTransaction) {
|
164 |
+
$refundTransaction->setIsClosed(true)
|
165 |
+
->save();
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Special.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Special.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Type_Special extends Netresearch_OPS_Model_Response_Type_Abstract
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Handles the specific actions for the concrete payment statuses
|
36 |
+
*/
|
37 |
+
protected function _handleResponse()
|
38 |
+
{
|
39 |
+
if (!Netresearch_OPS_Model_Status::isSpecialStatus($this->getStatus())) {
|
40 |
+
throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a special status!', $this->getStatus()));
|
41 |
+
}
|
42 |
+
|
43 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
44 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
45 |
+
$order = $payment->getOrder();
|
46 |
+
$helper = Mage::helper('ops');
|
47 |
+
|
48 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION) {
|
49 |
+
$payment->setIsTransactionPending(true);
|
50 |
+
$payment->setAdditionalInformation('HTML_ANSWER', $this->getHtmlAnswer());
|
51 |
+
$order->addStatusHistoryComment(
|
52 |
+
$this->getIntermediateStatusComment($helper->__('Customer redirected for 3DS authorization.'))
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT) {
|
57 |
+
$order->addStatusHistoryComment(
|
58 |
+
$this->getIntermediateStatusComment(
|
59 |
+
$helper->__(
|
60 |
+
'Customer received your payment instructions, waiting for actual payment.'
|
61 |
+
)
|
62 |
+
)
|
63 |
+
|
64 |
+
);
|
65 |
+
|
66 |
+
// gateway payments do not send confirmation emails by default
|
67 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::STORED_WAITING_EXTERNAL_RESULT) {
|
71 |
+
//TODO handle status 40
|
72 |
+
}
|
73 |
+
|
74 |
+
if ($this->getStatus() == Netresearch_OPS_Model_Status::INVALID_INCOMPLETE) {
|
75 |
+
//save status information to order before exception
|
76 |
+
$this->updateAdditionalInformation();
|
77 |
+
$payment->save();
|
78 |
+
|
79 |
+
$message = Mage::helper('ops')->__('Acceptance status 0, the action failed.');
|
80 |
+
if ($helper->isAdminSession()) {
|
81 |
+
$message .= ' ' . $this->getNcerror() . ' ' . $this->getNcerrorplus();
|
82 |
+
}
|
83 |
+
Mage::throwException($message);
|
84 |
+
}
|
85 |
+
|
86 |
+
$payment->save();
|
87 |
+
$order->save();
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/Type/Void.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Void.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Response_Type_Void extends Netresearch_OPS_Model_Response_Type_Abstract
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Handles the specific actions for the concrete payment status
|
36 |
+
*/
|
37 |
+
protected function _handleResponse()
|
38 |
+
{
|
39 |
+
if (!Netresearch_OPS_Model_Status::isVoid($this->getStatus())) {
|
40 |
+
throw new Mage_Core_Exception(Mage::helper('ops')->__('%s is not a void status!', $this->getStatus()));
|
41 |
+
}
|
42 |
+
|
43 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
44 |
+
$payment = $this->getMethodInstance()->getInfoInstance();
|
45 |
+
/** @var Mage_Sales_Model_Order $order */
|
46 |
+
$order = $payment->getOrder();
|
47 |
+
if (Netresearch_OPS_Model_Status::isFinal($this->getStatus())) {
|
48 |
+
if ($this->getShouldRegisterFeedback()) {
|
49 |
+
|
50 |
+
$payment->setMessage(
|
51 |
+
Mage::helper('ops')->__('Received Acceptance status %s. Order cancelled.', $this->getStatus())
|
52 |
+
);
|
53 |
+
$payment->registerVoidNotification($this->getAmount());
|
54 |
+
|
55 |
+
// payment void does not cancel the order, but sets it to processing. we therefore need to cancel the order ourselves
|
56 |
+
$order->registerCancellation($this->getFinalStatusComment(), true);
|
57 |
+
} else {
|
58 |
+
$this->addFinalStatusComment();
|
59 |
+
}
|
60 |
+
} else {
|
61 |
+
$payment->setMessage($this->getIntermediateStatusComment());
|
62 |
+
}
|
63 |
+
|
64 |
+
$order->save();
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
}
|
app/code/community/Netresearch/OPS/Model/Response/TypeInterface.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* TypeInterface.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Interface Netresearch_OPS_Model_Response_TypeInterface
|
34 |
+
*/
|
35 |
+
interface Netresearch_OPS_Model_Response_TypeInterface
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Performs the necessary actions for Magento to progress the order state correctly and automatically build the
|
39 |
+
* create sales objects
|
40 |
+
*
|
41 |
+
* @param array $responseArray
|
42 |
+
* @param Netresearch_OPS_Model_Payment_Abstract $paymentMethod
|
43 |
+
* @param bool $shouldRegisterFeedback determines if the Mage_Sales_Model_Order_Payments register*Feedback
|
44 |
+
* functions get called, defaults to true
|
45 |
+
*
|
46 |
+
* @return Netresearch_OPS_Model_Response_TypeInterface
|
47 |
+
*/
|
48 |
+
public function handleResponse($responseArray, Netresearch_OPS_Model_Payment_Abstract $paymentMethod,
|
49 |
+
$shouldRegisterFeedback
|
50 |
+
);
|
51 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/BankTransfer/Countries.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS bank transfer countries
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_BankTransfer_Countries
|
31 |
+
{
|
32 |
+
protected $countries = array(
|
33 |
+
'BE',
|
34 |
+
'DE',
|
35 |
+
'FR',
|
36 |
+
'NL',
|
37 |
+
);
|
38 |
+
|
39 |
+
protected $options = array();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function toOptionArray($isMultiselect=false)
|
45 |
+
{
|
46 |
+
if (!$this->options) {
|
47 |
+
$this->options = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
|
48 |
+
if (!$isMultiselect) {
|
49 |
+
array_unshift($this->options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
|
50 |
+
}
|
51 |
+
foreach ($this->options as $offset=>$option) {
|
52 |
+
if (!in_array($option['value'], $this->countries)) {
|
53 |
+
unset($this->options[$offset]);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
$this->options['*'] = array('value'=>'*', 'label'=> Mage::helper('adminhtml')->__(Mage::helper('ops')->__('Miscellaneous Countries')));
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this->options;
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Cc/AliasInterfaceEnabledTypes.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS credit card types
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Cc_AliasInterfaceEnabledTypes
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$options = array();
|
38 |
+
$types = array_intersect(
|
39 |
+
Mage::getModel('ops/config')->getAllCcTypes(),
|
40 |
+
$this->getAliasInterfaceCompatibleTypes()
|
41 |
+
);
|
42 |
+
foreach ($types as $type) {
|
43 |
+
$options[] = array(
|
44 |
+
'value' => $type,
|
45 |
+
'label' => Mage::helper('ops')->__($type)
|
46 |
+
);
|
47 |
+
}
|
48 |
+
return $options;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getAliasInterfaceCompatibleTypes()
|
52 |
+
{
|
53 |
+
return array(
|
54 |
+
'American Express',
|
55 |
+
'Diners Club',
|
56 |
+
'MaestroUK',
|
57 |
+
'MasterCard',
|
58 |
+
'VISA',
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Cc/RecurringTypes.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* RecurringTypes.php
|
24 |
+
*
|
25 |
+
* @category payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
class Netresearch_OPS_Model_Source_Cc_RecurringTypes
|
30 |
+
{
|
31 |
+
|
32 |
+
public function toOptionArray()
|
33 |
+
{
|
34 |
+
$options = array();
|
35 |
+
$types = Mage::getModel('ops/config')->getAllRecurringCcTypes();
|
36 |
+
$translatedTypes = array();
|
37 |
+
foreach ($types as $type) {
|
38 |
+
$translatedTypes[Mage::helper('ops')->__($type)] = $type;
|
39 |
+
}
|
40 |
+
ksort($translatedTypes);
|
41 |
+
foreach ($translatedTypes as $label => $value) {
|
42 |
+
$options[] = array(
|
43 |
+
'value' => $value,
|
44 |
+
'label' => $label
|
45 |
+
);
|
46 |
+
}
|
47 |
+
return $options;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Cc/Types.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS credit card types
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Cc_Types
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$options = array();
|
38 |
+
$types = Mage::getModel('ops/config')->getAllCcTypes();
|
39 |
+
$translatedTypes = array();
|
40 |
+
foreach ($types as $type) {
|
41 |
+
$translatedTypes[Mage::helper('ops')->__($type)] = $type;
|
42 |
+
}
|
43 |
+
ksort($translatedTypes);
|
44 |
+
foreach ($translatedTypes as $label=>$value) {
|
45 |
+
$options[] = array(
|
46 |
+
'value' => $value,
|
47 |
+
'label' => $label
|
48 |
+
);
|
49 |
+
}
|
50 |
+
return $options;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/DebitCard/AliasInterfaceEnabledTypes.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS credit card types
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_DebitCard_AliasInterfaceEnabledTypes
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$options = array();
|
38 |
+
$types = array_intersect(
|
39 |
+
Mage::getModel('ops/config')->getAllDcTypes(),
|
40 |
+
$this->getAliasInterfaceCompatibleTypes()
|
41 |
+
);
|
42 |
+
foreach ($types as $type) {
|
43 |
+
$options[] = array(
|
44 |
+
'value' => $type,
|
45 |
+
'label' => Mage::helper('ops')->__($type)
|
46 |
+
);
|
47 |
+
}
|
48 |
+
return $options;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getAliasInterfaceCompatibleTypes()
|
52 |
+
{
|
53 |
+
return array(
|
54 |
+
'Maestro',
|
55 |
+
'MaestroUK',
|
56 |
+
'MasterCard',
|
57 |
+
'VISA',
|
58 |
+
);
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/DebitCard/Types.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS debitcard types
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_DebitCard_Types
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$options = array();
|
38 |
+
$types = Mage::getModel('ops/config')->getAllDcTypes();
|
39 |
+
$translatedTypes = array();
|
40 |
+
foreach ($types as $type) {
|
41 |
+
$translatedTypes[Mage::helper('ops')->__($type)] = $type;
|
42 |
+
}
|
43 |
+
ksort($translatedTypes);
|
44 |
+
foreach ($translatedTypes as $label=>$value) {
|
45 |
+
$options[] = array(
|
46 |
+
'value' => $value,
|
47 |
+
'label' => $label
|
48 |
+
);
|
49 |
+
}
|
50 |
+
return $options;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/DirectDebit/Countries.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS direct debit countries
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_DirectDebit_Countries
|
31 |
+
{
|
32 |
+
protected $countries = array(
|
33 |
+
'DE',
|
34 |
+
'AT',
|
35 |
+
'NL',
|
36 |
+
);
|
37 |
+
|
38 |
+
protected $options = array();
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
public function toOptionArray($isMultiselect=false)
|
44 |
+
{
|
45 |
+
if (!$this->options) {
|
46 |
+
$this->options = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
|
47 |
+
if (!$isMultiselect) {
|
48 |
+
array_unshift($this->options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
|
49 |
+
}
|
50 |
+
foreach ($this->options as $offset=>$option) {
|
51 |
+
if (!in_array($option['value'], $this->countries)) {
|
52 |
+
unset($this->options[$offset]);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->options;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/DirectEbanking/Brands.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Netresearch_OPS
|
24 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
/**
|
28 |
+
* OPS direct ebanking countries
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_DirectEbanking_Brands
|
31 |
+
{
|
32 |
+
protected $options = array(
|
33 |
+
array(
|
34 |
+
'value' => 'DirectEbanking',
|
35 |
+
),
|
36 |
+
array(
|
37 |
+
'value' => 'DirectEbankingAT',
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'value' => 'DirectEbankingBE',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'value' => 'DirectEbankingCH',
|
44 |
+
),
|
45 |
+
array(
|
46 |
+
'value' => 'DirectEbankingDE',
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'value' => 'DirectEbankingFR',
|
50 |
+
),
|
51 |
+
array(
|
52 |
+
'value' => 'DirectEbankingGB',
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function toOptionArray($isMultiselect = false)
|
60 |
+
{
|
61 |
+
foreach ($this->options as $key => $value) {
|
62 |
+
$this->options[$key]['label'] = Mage::helper('ops')->__($value['value']);
|
63 |
+
}
|
64 |
+
return $this->options;
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Kwixo/ProductCategories.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Source Model for ProductCategories
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Kwixo_ProductCategories
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* return the product categories as array
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
return array(
|
40 |
+
array(
|
41 |
+
'value' => 1,
|
42 |
+
'label' => Mage::helper('ops/data')->__('Food & gastronomy')
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'value' => 2,
|
46 |
+
'label' => Mage::helper('ops/data')->__('Car & Motorbike')
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'value' => 3,
|
50 |
+
'label' => Mage::helper('ops/data')->__('Culture & leisure')
|
51 |
+
),
|
52 |
+
array(
|
53 |
+
'value' => 4,
|
54 |
+
'label' => Mage::helper('ops/data')->__('Home & garden')
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'value' => 5,
|
58 |
+
'label' => Mage::helper('ops/data')->__('Appliances')
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'value' => 6,
|
62 |
+
'label' => Mage::helper('ops/data')->__('Auctions and bulk purchases')
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'value' => 7,
|
66 |
+
'label' => Mage::helper('ops/data')->__('Flowers & gifts')
|
67 |
+
),
|
68 |
+
array(
|
69 |
+
'value' => 8,
|
70 |
+
'label' => Mage::helper('ops/data')->__('Computer & software')
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'value' => 9,
|
74 |
+
'label' => Mage::helper('ops/data')->__('Health & beauty')
|
75 |
+
),
|
76 |
+
array(
|
77 |
+
'value' => 10,
|
78 |
+
'label' => Mage::helper('ops/data')->__('Services for individuals')
|
79 |
+
),
|
80 |
+
array(
|
81 |
+
'value' => 11,
|
82 |
+
'label' => Mage::helper('ops/data')->__('Services for professionals')
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'value' => 12,
|
86 |
+
'label' => Mage::helper('ops/data')->__('Sports')
|
87 |
+
),
|
88 |
+
array(
|
89 |
+
'value' => 13,
|
90 |
+
'label' => Mage::helper('ops/data')->__('Clothing & accessories')
|
91 |
+
),
|
92 |
+
array(
|
93 |
+
'value' => 14,
|
94 |
+
'label' => Mage::helper('ops/data')->__('Travel & tourism')
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'value' => 15,
|
98 |
+
'label' => Mage::helper('ops/data')->__('Hifi, photo & video')
|
99 |
+
),
|
100 |
+
array(
|
101 |
+
'value' => 16,
|
102 |
+
'label' => Mage::helper('ops/data')->__('Telephony & communication')
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'value' => 17,
|
106 |
+
'label' => Mage::helper('ops/data')->__('Jewelry & precious metals')
|
107 |
+
),
|
108 |
+
array(
|
109 |
+
'value' => 18,
|
110 |
+
'label' => Mage::helper('ops/data')->__('Baby articles and accessories')
|
111 |
+
),
|
112 |
+
array(
|
113 |
+
'value' => 19,
|
114 |
+
'label' => Mage::helper('ops/data')->__('Sound & light')
|
115 |
+
)
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getValidKwixoCategoryIds()
|
120 |
+
{
|
121 |
+
$kwixoValues = array();
|
122 |
+
foreach ($this->toOptionArray() as $option) {
|
123 |
+
$kwixoValues[] = $option['value'];
|
124 |
+
}
|
125 |
+
return $kwixoValues;
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Kwixo/ShipMethodType.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Source Model for ShipMethodTypes
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Kwixo_ShipMethodType
|
31 |
+
{
|
32 |
+
|
33 |
+
const PICK_UP_AT_MERCHANT = 1;
|
34 |
+
|
35 |
+
const COLLECTION_POINT = 2;
|
36 |
+
|
37 |
+
const COLLECT_AT_AIRPORT = 3;
|
38 |
+
|
39 |
+
const TRANSPORTER = 4;
|
40 |
+
|
41 |
+
const DOWNLOAD = 5;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* return options as array
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function toOptionArray()
|
49 |
+
{
|
50 |
+
return array(
|
51 |
+
array(
|
52 |
+
'value' => "",
|
53 |
+
'label' => Mage::helper('ops/data')->__('--Please select--')
|
54 |
+
),
|
55 |
+
array(
|
56 |
+
'value' => self::PICK_UP_AT_MERCHANT,
|
57 |
+
'label' => Mage::helper('ops/data')->__('Pick up at merchant')
|
58 |
+
),
|
59 |
+
array(
|
60 |
+
'value' => self::COLLECTION_POINT,
|
61 |
+
'label' => Mage::helper('ops/data')->__(
|
62 |
+
'Collection point (Kiala...)'
|
63 |
+
)
|
64 |
+
),
|
65 |
+
array(
|
66 |
+
'value' => self::COLLECT_AT_AIRPORT,
|
67 |
+
'label' => Mage::helper('ops/data')->__(
|
68 |
+
'Collect at airport, train station or travel agency'
|
69 |
+
)
|
70 |
+
),
|
71 |
+
array(
|
72 |
+
'value' => self::TRANSPORTER,
|
73 |
+
'label' => Mage::helper('ops/data')->__(
|
74 |
+
'Transporter (La Poste, UPS...)'
|
75 |
+
)
|
76 |
+
),
|
77 |
+
array(
|
78 |
+
'value' => self::DOWNLOAD,
|
79 |
+
'label' => Mage::helper('ops/data')->__('Download')
|
80 |
+
)
|
81 |
+
);
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getValidValues()
|
85 |
+
{
|
86 |
+
return array(
|
87 |
+
self::PICK_UP_AT_MERCHANT,
|
88 |
+
self::COLLECTION_POINT,
|
89 |
+
self::COLLECT_AT_AIRPORT,
|
90 |
+
self::TRANSPORTER,
|
91 |
+
self::DOWNLOAD
|
92 |
+
);
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Mode.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mode.php
|
4 |
+
* @author paul.siedler@netresearch.de
|
5 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Source_Mode {
|
11 |
+
|
12 |
+
const PROD = 'prod';
|
13 |
+
const TEST = 'test';
|
14 |
+
const CUSTOM = 'custom';
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function toOptionArray(){
|
22 |
+
return array(
|
23 |
+
array('value' => self::TEST, 'label' => Mage::helper('ops')->__(self::TEST)),
|
24 |
+
array('value' => self::PROD, 'label' => Mage::helper('ops')->__(self::PROD)),
|
25 |
+
array('value' => self::CUSTOM, 'label' => Mage::helper('ops')->__(self::CUSTOM)),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/OrderReference.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS order reference action dropdown source
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_OrderReference
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Prepare ops template mode list as option array
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
return array(
|
40 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID, 'label' => Mage::helper('ops')->__('quote id')),
|
41 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID, 'label' => Mage::helper('ops')->__('order id')),
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/PaymentAction.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS Payment Action Dropdown source
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_PaymentAction
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Prepare payment action list as optional array
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
return array(
|
40 |
+
array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('ops')->__('Authorization')),
|
41 |
+
array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('ops')->__('Direct Sale')),
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Pmlist.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS template Action Dropdown source
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Pmlist
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Prepare ops payment block layout as option array
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
return array(
|
40 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::PMLIST_HORIZONTAL_LEFT, 'label' => Mage::helper('ops')->__('Horizontally grouped logo with group name on left')),
|
41 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::PMLIST_HORIZONTAL, 'label' => Mage::helper('ops')->__('Horizontally grouped logo with no group name')),
|
42 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::PMLIST_VERTICAL, 'label' => Mage::helper('ops')->__('Verical list')),
|
43 |
+
);
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/Template.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* OPS template Action Dropdown source
|
29 |
+
*/
|
30 |
+
class Netresearch_OPS_Model_Source_Template
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Prepare ops template mode list as option array
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*/
|
37 |
+
public function toOptionArray()
|
38 |
+
{
|
39 |
+
return array(
|
40 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT, 'label' => Mage::helper('ops')->__('Acceptance - Redirect mode')),
|
41 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL, 'label' => Mage::helper('ops')->__('Magento - internal shop template')),
|
42 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME, 'label' => Mage::helper('ops')->__('Acceptance - iFrame mode')),
|
43 |
+
array('value' => Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE, 'label' => Mage::helper('ops')->__('Acceptance - Dynamic template'))
|
44 |
+
);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Netresearch/OPS/Model/Source/TemplateType.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TemplateType.php
|
4 |
+
* @author paul.siedler@netresearch.de
|
5 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Netresearch_OPS_Model_Source_TemplateType {
|
10 |
+
|
11 |
+
const URL = 'url';
|
12 |
+
const ID = 'id';
|
13 |
+
|
14 |
+
public function toOptionArray(){
|
15 |
+
return array(
|
16 |
+
array('value' => self::URL, 'label' => Mage::helper('ops')->__(self::URL)),
|
17 |
+
array('value' => self::ID, 'label' => Mage::helper('ops')->__(self::ID))
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Netresearch/OPS/Model/Status.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Status.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
/**
|
33 |
+
* OPS response status
|
34 |
+
*
|
35 |
+
* Statuses in 1 digit are 'normal' statuses:
|
36 |
+
*
|
37 |
+
* 0 or 1 means the payment entry was not completed either because it is still underway or because interrupted or because
|
38 |
+
* a validation error prevented from confirming. If the cause is a validation error, an additional error code (*) (NCERROR) identifies the error.
|
39 |
+
*
|
40 |
+
* 2 means the acquirer did not authorise the payment.
|
41 |
+
*
|
42 |
+
* 5 means the acquirer authorised the payment.
|
43 |
+
*
|
44 |
+
* 9 means the payment was captured.
|
45 |
+
*
|
46 |
+
* Statuses in 2 digits corresponds either to 'intermediary' situations or to abnormal events. When the second digit is:
|
47 |
+
*
|
48 |
+
* 1, this means the payment processing is on hold.
|
49 |
+
*
|
50 |
+
* 2, this means an error occurred during the communication with the acquirer. The result is therefore not determined.
|
51 |
+
* You must therefore call the acquirer's helpdesk to find out the actual result of this transaction.
|
52 |
+
*
|
53 |
+
* 3, this means the payment processing (capture or cancellation) was refused by the acquirer whilst the payment had been authorised beforehand.
|
54 |
+
* It can be due to a technical error or to the expiration of the autorisation. You must therefore call the acquirer's helpdesk to find out the actual result of this transaction.
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
class Netresearch_OPS_Model_Status
|
58 |
+
{
|
59 |
+
|
60 |
+
const INVALID_INCOMPLETE = 0;
|
61 |
+
const CANCELED_BY_CUSTOMER = 1;
|
62 |
+
const AUTHORISATION_DECLINED = 2;
|
63 |
+
|
64 |
+
const ORDER_STORED = 4;
|
65 |
+
const STORED_WAITING_EXTERNAL_RESULT = 40;
|
66 |
+
const WAITING_CLIENT_PAYMENT = 41;
|
67 |
+
const WAITING_FOR_IDENTIFICATION = 46;
|
68 |
+
|
69 |
+
const AUTHORIZED = 5;
|
70 |
+
const AUTHORIZED_WAITING_EXTERNAL_RESULT = 50;
|
71 |
+
const AUTHORIZATION_WAITING = 51;
|
72 |
+
const AUTHORIZED_UNKNOWN = 52;
|
73 |
+
const STAND_BY_SUSPECTED_FRAUD = 55;
|
74 |
+
const OK_WITH_SHEDULED_PAYMENTS = 56;
|
75 |
+
const NOT_OK_WITH_SHEDULED_PAYMENTS = 57;
|
76 |
+
const AUTHORISATION_TO_BE_REQUESTED_MANUALLY = 59;
|
77 |
+
|
78 |
+
const AUTHORIZED_AND_CANCELLED = 6;
|
79 |
+
const DELETION_WAITING = 61;
|
80 |
+
const DELETION_UNCERTAIN = 62;
|
81 |
+
const DELETION_REFUSED = 63;
|
82 |
+
const AUTHORIZED_AND_CANCELLED_OK = 64;
|
83 |
+
|
84 |
+
const PAYMENT_DELETED = 7;
|
85 |
+
const PAYMENT_DELETION_PENDING = 71;
|
86 |
+
const PAYMENT_DELETION_UNCERTAIN = 72;
|
87 |
+
const PAYMENT_DELETION_REFUSED = 73;
|
88 |
+
const PAYMENT_DELETION_OK = 74;
|
89 |
+
const DELETION_HANDLED_BY_MERCHANT = 75;
|
90 |
+
|
91 |
+
const REFUNDED = 8;
|
92 |
+
const REFUND_PENDING = 81;
|
93 |
+
const REFUND_UNCERTAIN = 82;
|
94 |
+
const REFUND_REFUSED = 83;
|
95 |
+
const REFUNDED_OK = 84;
|
96 |
+
const REFUND_PROCESSED_BY_MERCHANT = 85;
|
97 |
+
|
98 |
+
const PAYMENT_REQUESTED = 9;
|
99 |
+
const PAYMENT_PROCESSING = 91;
|
100 |
+
const PAYMENT_UNCERTAIN = 92;
|
101 |
+
const PAYMENT_REFUSED = 93;
|
102 |
+
const PAYMENT_DECLINED_BY_ACQUIRER = 94;
|
103 |
+
const PAYMENT_PROCESSED_BY_MERCHANT = 95;
|
104 |
+
const REFUND_REVERSED = 96;
|
105 |
+
const PAYMENT_IN_PROGRESS = 99;
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Returns if the given status is a final status (single digit status)
|
109 |
+
*
|
110 |
+
* @param int $status
|
111 |
+
*
|
112 |
+
* @return bool
|
113 |
+
*/
|
114 |
+
static function isFinal($status)
|
115 |
+
{
|
116 |
+
return in_array(
|
117 |
+
$status, array(
|
118 |
+
self::INVALID_INCOMPLETE,
|
119 |
+
self::CANCELED_BY_CUSTOMER,
|
120 |
+
self::AUTHORISATION_DECLINED,
|
121 |
+
self::ORDER_STORED,
|
122 |
+
self::AUTHORIZED,
|
123 |
+
self::AUTHORIZED_AND_CANCELLED,
|
124 |
+
self::PAYMENT_DELETED,
|
125 |
+
self::DELETION_HANDLED_BY_MERCHANT,
|
126 |
+
self::REFUNDED,
|
127 |
+
self::REFUND_PROCESSED_BY_MERCHANT,
|
128 |
+
self::PAYMENT_REQUESTED,
|
129 |
+
self::PAYMENT_PROCESSED_BY_MERCHANT
|
130 |
+
)
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Checks if the given status is an intermediate one (not single digit)
|
136 |
+
*
|
137 |
+
* @param int $status
|
138 |
+
*
|
139 |
+
* @return bool
|
140 |
+
*/
|
141 |
+
static function isIntermediate($status)
|
142 |
+
{
|
143 |
+
return !self::isFinal($status);
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Checks if the given state belongs to the capture status group (9 and 9x)
|
148 |
+
*
|
149 |
+
* @param int $status
|
150 |
+
*
|
151 |
+
* @return bool
|
152 |
+
*/
|
153 |
+
static function isCapture($status)
|
154 |
+
{
|
155 |
+
return in_array(
|
156 |
+
$status,
|
157 |
+
array(
|
158 |
+
self::PAYMENT_REQUESTED,
|
159 |
+
self::PAYMENT_PROCESSING,
|
160 |
+
self::PAYMENT_UNCERTAIN,
|
161 |
+
self::PAYMENT_REFUSED,
|
162 |
+
self::PAYMENT_DECLINED_BY_ACQUIRER,
|
163 |
+
self::PAYMENT_PROCESSED_BY_MERCHANT,
|
164 |
+
self::REFUND_REVERSED,
|
165 |
+
self::PAYMENT_IN_PROGRESS
|
166 |
+
)
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Checks if the given status belongs to refund status group (8 and 8x)
|
172 |
+
*
|
173 |
+
* @param int $status
|
174 |
+
*
|
175 |
+
* @return bool
|
176 |
+
*/
|
177 |
+
static function isRefund($status)
|
178 |
+
{
|
179 |
+
return in_array(
|
180 |
+
$status,
|
181 |
+
array(
|
182 |
+
self::REFUNDED,
|
183 |
+
self::REFUND_PENDING,
|
184 |
+
self::REFUND_UNCERTAIN,
|
185 |
+
self::REFUND_REFUSED,
|
186 |
+
self::REFUNDED_OK,
|
187 |
+
self::REFUND_PROCESSED_BY_MERCHANT,
|
188 |
+
)
|
189 |
+
);
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Checks if the given status belongs to void/delete status group (6 and 6x)
|
194 |
+
*
|
195 |
+
* @param int $status
|
196 |
+
*
|
197 |
+
* @return bool
|
198 |
+
*/
|
199 |
+
static function isVoid($status)
|
200 |
+
{
|
201 |
+
return in_array(
|
202 |
+
$status,
|
203 |
+
array(
|
204 |
+
self::PAYMENT_DELETED,
|
205 |
+
self::AUTHORIZED_AND_CANCELLED,
|
206 |
+
self::DELETION_WAITING,
|
207 |
+
self::DELETION_UNCERTAIN,
|
208 |
+
self::DELETION_REFUSED,
|
209 |
+
self::AUTHORIZED_AND_CANCELLED_OK,
|
210 |
+
)
|
211 |
+
);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Checks if the given status belongs to authorize status group
|
216 |
+
*
|
217 |
+
* @param int $status
|
218 |
+
*
|
219 |
+
* @return bool
|
220 |
+
*/
|
221 |
+
static function isAuthorize($status)
|
222 |
+
{
|
223 |
+
return in_array(
|
224 |
+
$status,
|
225 |
+
array(
|
226 |
+
self::AUTHORISATION_DECLINED,
|
227 |
+
self::AUTHORIZED,
|
228 |
+
self::AUTHORIZED_WAITING_EXTERNAL_RESULT,
|
229 |
+
self::AUTHORIZATION_WAITING,
|
230 |
+
self::AUTHORIZED_UNKNOWN,
|
231 |
+
self::STAND_BY_SUSPECTED_FRAUD,
|
232 |
+
self::OK_WITH_SHEDULED_PAYMENTS,
|
233 |
+
self::NOT_OK_WITH_SHEDULED_PAYMENTS,
|
234 |
+
self::AUTHORISATION_TO_BE_REQUESTED_MANUALLY,
|
235 |
+
self::CANCELED_BY_CUSTOMER
|
236 |
+
)
|
237 |
+
);
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Checks if given Status is a special status (waiting for client payment, waiting for authentification, invalid)
|
242 |
+
*
|
243 |
+
* @param int $status
|
244 |
+
*
|
245 |
+
* @return bool
|
246 |
+
*/
|
247 |
+
static function isSpecialStatus($status)
|
248 |
+
{
|
249 |
+
return in_array(
|
250 |
+
$status,
|
251 |
+
array(
|
252 |
+
self::WAITING_CLIENT_PAYMENT,
|
253 |
+
self::WAITING_FOR_IDENTIFICATION,
|
254 |
+
self::STORED_WAITING_EXTERNAL_RESULT,
|
255 |
+
self::INVALID_INCOMPLETE,
|
256 |
+
)
|
257 |
+
);
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* check if for a given status payment info can be resend
|
262 |
+
*
|
263 |
+
* @param $status
|
264 |
+
*
|
265 |
+
* @return bool
|
266 |
+
*/
|
267 |
+
static function canResendPaymentInfo($status)
|
268 |
+
{
|
269 |
+
return in_array(
|
270 |
+
$status,
|
271 |
+
array(
|
272 |
+
self::NOT_OK_WITH_SHEDULED_PAYMENTS,
|
273 |
+
self::CANCELED_BY_CUSTOMER,
|
274 |
+
self::AUTHORISATION_DECLINED,
|
275 |
+
self::AUTHORISATION_TO_BE_REQUESTED_MANUALLY,
|
276 |
+
self::PAYMENT_UNCERTAIN,
|
277 |
+
self::PAYMENT_REFUSED,
|
278 |
+
self::INVALID_INCOMPLETE
|
279 |
+
)
|
280 |
+
);
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* check if payment with given status can be voided
|
285 |
+
*
|
286 |
+
* @param $status
|
287 |
+
*
|
288 |
+
* @return bool
|
289 |
+
*/
|
290 |
+
static function canVoidTransaction($status)
|
291 |
+
{
|
292 |
+
return in_array(
|
293 |
+
$status,
|
294 |
+
array(
|
295 |
+
self::AUTHORIZED,
|
296 |
+
self::REFUNDED
|
297 |
+
)
|
298 |
+
);
|
299 |
+
}
|
300 |
+
}
|
app/code/community/Netresearch/OPS/Model/Status/Feedback.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Netresearch_OPS
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
class Netresearch_OPS_Model_Status_Feedback
|
28 |
+
{
|
29 |
+
const OPS_ORDER_FEEDBACK_STATUS_ACCEPT = 'accept';
|
30 |
+
const OPS_ORDER_FEEDBACK_STATUS_DECLINE = 'decline';
|
31 |
+
const OPS_ORDER_FEEDBACK_STATUS_CANCEL = 'cancel';
|
32 |
+
const OPS_ORDER_FEEDBACK_STATUS_EXCEPTION = 'exception';
|
33 |
+
}
|
app/code/community/Netresearch/OPS/Model/Status/Update.php
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Status_Update
|
11 |
+
{
|
12 |
+
|
13 |
+
/** @var Netresearch_OPS_Model_Api_DirectLink $directLinkApi */
|
14 |
+
protected $directLinkApi = null;
|
15 |
+
|
16 |
+
protected $order = null;
|
17 |
+
|
18 |
+
protected $requestParams = array();
|
19 |
+
|
20 |
+
/** @var Netresearch_OPS_Model_Config $opsConfig */
|
21 |
+
protected $opsConfig = null;
|
22 |
+
|
23 |
+
protected $opsResponse = array();
|
24 |
+
|
25 |
+
protected $paymentHelper = null;
|
26 |
+
|
27 |
+
protected $directLinkHelper = null;
|
28 |
+
|
29 |
+
protected $messageContainer = null;
|
30 |
+
|
31 |
+
protected $dataHelper = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param null $dataHelper
|
35 |
+
*/
|
36 |
+
public function setDataHelper($dataHelper)
|
37 |
+
{
|
38 |
+
$this->dataHelper = $dataHelper;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return Netresearch_OPS_Helper_Data
|
43 |
+
*/
|
44 |
+
public function getDataHelper()
|
45 |
+
{
|
46 |
+
if (null == $this->dataHelper) {
|
47 |
+
$this->dataHelper = Mage::helper('ops/data');
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->dataHelper;
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* @param Mage_Core_Model_Session_Abstract $messageContainer
|
54 |
+
*/
|
55 |
+
public function setMessageContainer(Mage_Core_Model_Session_Abstract $messageContainer)
|
56 |
+
{
|
57 |
+
$this->messageContainer = $messageContainer;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return Mage_Core_Model_Session_Abstract
|
62 |
+
*/
|
63 |
+
public function getMessageContainer()
|
64 |
+
{
|
65 |
+
if (null == $this->messageContainer) {
|
66 |
+
$this->messageContainer = Mage::getSingleton('adminhtml/session');
|
67 |
+
}
|
68 |
+
return $this->messageContainer;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @param Netresearch_OPS_Model_Config $opsConfig
|
73 |
+
*/
|
74 |
+
public function setOpsConfig(Netresearch_OPS_Model_Config $opsConfig)
|
75 |
+
{
|
76 |
+
$this->opsConfig = $opsConfig;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return Netresearch_OPS_Model_Config
|
81 |
+
*/
|
82 |
+
public function getOpsConfig()
|
83 |
+
{
|
84 |
+
if (null === $this->opsConfig) {
|
85 |
+
$this->opsConfig = Mage::getModel('ops/config');
|
86 |
+
}
|
87 |
+
return $this->opsConfig;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @param array $requestParams
|
92 |
+
*/
|
93 |
+
public function setRequestParams($requestParams)
|
94 |
+
{
|
95 |
+
$this->requestParams = $requestParams;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
public function getRequestParams()
|
102 |
+
{
|
103 |
+
return $this->requestParams;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param Netresearch_OPS_Helper_Order $orderHelper
|
108 |
+
*/
|
109 |
+
public function setOrderHelper(Netresearch_OPS_Helper_Order $orderHelper)
|
110 |
+
{
|
111 |
+
$this->orderHelper = $orderHelper;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @return Netresearch_OPS_Helper_Order
|
116 |
+
*/
|
117 |
+
public function getOrderHelper()
|
118 |
+
{
|
119 |
+
if (null == $this->orderHelper) {
|
120 |
+
$this->orderHelper = Mage::helper('ops/order');
|
121 |
+
}
|
122 |
+
|
123 |
+
return $this->orderHelper;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* @param array $opsResponse
|
128 |
+
*/
|
129 |
+
public function setOpsResponse($opsResponse)
|
130 |
+
{
|
131 |
+
$this->opsResponse = $opsResponse;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @return array
|
136 |
+
*/
|
137 |
+
public function getOpsResponse()
|
138 |
+
{
|
139 |
+
return $this->opsResponse;
|
140 |
+
}
|
141 |
+
|
142 |
+
/** @var Netresearch_OPS_Helper_Order $orderHelper */
|
143 |
+
protected $orderHelper = null;
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @param Netresearch_OPS_Model_Api_DirectLink $directLinkApi
|
147 |
+
*/
|
148 |
+
public function setDirectLinkApi(Netresearch_OPS_Model_Api_DirectLink $directLinkApi)
|
149 |
+
{
|
150 |
+
$this->directLinkApi = $directLinkApi;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @return Netresearch_OPS_Model_Api_DirectLink
|
155 |
+
*/
|
156 |
+
public function getDirectLinkApi()
|
157 |
+
{
|
158 |
+
if (null === $this->directLinkApi) {
|
159 |
+
$this->directLinkApi = Mage::getModel('ops/api_directlink');
|
160 |
+
}
|
161 |
+
return $this->directLinkApi;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* @param Mage_Sales_Model_Order $order
|
166 |
+
*/
|
167 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
168 |
+
{
|
169 |
+
$this->order = $order;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @return Mage_Sales_Model_Order
|
174 |
+
*/
|
175 |
+
public function getOrder()
|
176 |
+
{
|
177 |
+
return $this->order;
|
178 |
+
}
|
179 |
+
|
180 |
+
public function updateStatusFor(Mage_Sales_Model_Order $order)
|
181 |
+
{
|
182 |
+
if (false === ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_Abstract)) {
|
183 |
+
return $this;
|
184 |
+
}
|
185 |
+
$this->setOrder($order);
|
186 |
+
$this->buildParams($order->getPayment());
|
187 |
+
|
188 |
+
try {
|
189 |
+
$this->performRequest();
|
190 |
+
$this->updatePaymentStatus();
|
191 |
+
} catch (Mage_Core_Exception $e) {
|
192 |
+
$this->getMessageContainer()->addError($e->getMessage());
|
193 |
+
}
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
|
197 |
+
protected function buildParams(Mage_Sales_Model_Order_Payment $payment)
|
198 |
+
{
|
199 |
+
// use PAYID if possible
|
200 |
+
if (0 < strlen(trim($payment->getAdditionalInformation('paymentId')))) {
|
201 |
+
$this->requestParams['PAYID'] = $payment->getAdditionalInformation('paymentId');
|
202 |
+
|
203 |
+
} else {
|
204 |
+
$useOrderId = true;
|
205 |
+
if ($this->canNotUseOrderId($payment)
|
206 |
+
) {
|
207 |
+
$useOrderId = false;
|
208 |
+
}
|
209 |
+
$this->requestParams['ORDERID'] = $this->getOrderHelper()->getOpsOrderId($this->getOrder(), $useOrderId);
|
210 |
+
}
|
211 |
+
$this->addPayIdSub($payment);
|
212 |
+
|
213 |
+
|
214 |
+
return $this;
|
215 |
+
}
|
216 |
+
|
217 |
+
protected function performRequest()
|
218 |
+
{
|
219 |
+
$storeId = $this->getOrder()->getStoreId();
|
220 |
+
$url = $this->getOpsConfig()->getDirectLinkMaintenanceApiPath($storeId);
|
221 |
+
try {
|
222 |
+
$this->opsResponse = $this->getDirectLinkApi()->performRequest($this->getRequestParams(), $url, $storeId);
|
223 |
+
} catch (Mage_Core_Exception $e) {
|
224 |
+
$this->getMessageContainer()->addError($this->getDataHelper()->__($e->getMessage()));
|
225 |
+
return $this;
|
226 |
+
}
|
227 |
+
$this->opsResponse = array_change_key_case($this->opsResponse, CASE_UPPER);
|
228 |
+
// in further processing the amount is sometimes in upper and sometimes in lower case :(
|
229 |
+
if (array_key_exists('AMOUNT', $this->opsResponse)) {
|
230 |
+
$this->opsResponse['amount'] = $this->opsResponse['AMOUNT'];
|
231 |
+
}
|
232 |
+
|
233 |
+
|
234 |
+
return $this;
|
235 |
+
}
|
236 |
+
|
237 |
+
protected function updatePaymentStatus()
|
238 |
+
{
|
239 |
+
if (!array_key_exists('STATUS', $this->getOpsResponse())
|
240 |
+
|| $this->opsResponse['STATUS'] == $this->getOrder()->getPayment()->getAdditionalInformation('status')
|
241 |
+
) {
|
242 |
+
$this->getMessageContainer()->addNotice($this->getDataHelper()->__('No update available from Acceptance.'));
|
243 |
+
return $this;
|
244 |
+
}
|
245 |
+
|
246 |
+
if (false != strlen(trim($this->getOrder()->getPayment()->getAdditionalInformation('paymentId')))) {
|
247 |
+
Mage::getModel('ops/response_handler')->processResponse($this->getOpsResponse(),
|
248 |
+
$this->getOrder()->getPayment()->getMethodInstance()
|
249 |
+
);
|
250 |
+
} else {
|
251 |
+
// simulate initial request
|
252 |
+
$this->getPaymentHelper()->applyStateForOrder($this->getOrder(), $this->getOpsResponse());
|
253 |
+
}
|
254 |
+
|
255 |
+
$this->getPaymentHelper()->saveOpsStatusToPayment($this->getOrder()->getPayment(), $this->getOpsResponse());
|
256 |
+
$this->getMessageContainer()->addSuccess($this->getDataHelper()->__('Acceptance status successfully updated'));
|
257 |
+
|
258 |
+
return $this;
|
259 |
+
}
|
260 |
+
|
261 |
+
public function getPaymentHelper()
|
262 |
+
{
|
263 |
+
if (null == $this->paymentHelper) {
|
264 |
+
$this->paymentHelper = Mage::helper('ops/payment');
|
265 |
+
}
|
266 |
+
|
267 |
+
return $this->paymentHelper;
|
268 |
+
}
|
269 |
+
|
270 |
+
public function setPaymentHelper(Netresearch_OPS_Helper_Payment $paymentHelper)
|
271 |
+
{
|
272 |
+
$this->paymentHelper = $paymentHelper;
|
273 |
+
}
|
274 |
+
|
275 |
+
public function getDirectLinkHelper()
|
276 |
+
{
|
277 |
+
if (null == $this->directLinkHelper) {
|
278 |
+
$this->directLinkHelper = Mage::helper('ops/directlink');
|
279 |
+
}
|
280 |
+
|
281 |
+
return $this->directLinkHelper;
|
282 |
+
}
|
283 |
+
|
284 |
+
public function setDirectLinkHelper(Netresearch_OPS_Helper_Directlink $directLinkHelper)
|
285 |
+
{
|
286 |
+
$this->directLinkHelper = $directLinkHelper;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
291 |
+
*/
|
292 |
+
protected function addPayIdSub(Mage_Sales_Model_Order_Payment $payment)
|
293 |
+
{
|
294 |
+
$lastTransaction = $payment->getLastTransId();
|
295 |
+
$lastTransactionParts = explode('/', $lastTransaction);
|
296 |
+
if($lastTransaction && count($lastTransactionParts)>1){
|
297 |
+
$this->requestParams['PAYIDSUB'] = $lastTransactionParts[1];
|
298 |
+
}
|
299 |
+
return $this;
|
300 |
+
}
|
301 |
+
|
302 |
+
protected function canNotUseOrderId(Mage_Sales_Model_Order_Payment $payment)
|
303 |
+
{
|
304 |
+
$methodInstance = $payment->getMethodInstance();
|
305 |
+
|
306 |
+
return ($methodInstance instanceof Netresearch_OPS_Model_Payment_Kwixo_Abstract)
|
307 |
+
|| ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit)
|
308 |
+
|| ($methodInstance instanceof Netresearch_OPS_Model_Payment_Cc
|
309 |
+
&& $methodInstance->hasBrandAliasInterfaceSupport($payment));
|
310 |
+
}
|
311 |
+
|
312 |
+
}
|
app/code/community/Netresearch/OPS/Model/Subscription/Manager.php
ADDED
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Management endpoint for order creation from subscription feedback
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
class Netresearch_OPS_Model_Subscription_Manager
|
33 |
+
{
|
34 |
+
const CREATION_FAILED = 'ERROR';
|
35 |
+
const CREATION_SUCCEEDED = 'OK';
|
36 |
+
|
37 |
+
|
38 |
+
protected $subscriptionHelper = null;
|
39 |
+
protected $paymentHelper = null;
|
40 |
+
protected $dataHelper = null;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @return Netresearch_OPS_Helper_Data
|
44 |
+
*/
|
45 |
+
public function getDataHelper()
|
46 |
+
{
|
47 |
+
if (is_null($this->dataHelper)) {
|
48 |
+
$this->dataHelper = Mage::helper('ops');
|
49 |
+
}
|
50 |
+
|
51 |
+
return $this->dataHelper;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param Netresearch_OPS_Helper_Data $dataHelper
|
56 |
+
*
|
57 |
+
* @returns $this
|
58 |
+
*/
|
59 |
+
public function setDataHelper($dataHelper)
|
60 |
+
{
|
61 |
+
$this->dataHelper = $dataHelper;
|
62 |
+
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return Netresearch_OPS_Helper_Payment
|
68 |
+
*/
|
69 |
+
public function getPaymentHelper()
|
70 |
+
{
|
71 |
+
if (is_null($this->paymentHelper)) {
|
72 |
+
$this->paymentHelper = Mage::helper('ops/payment');
|
73 |
+
}
|
74 |
+
|
75 |
+
return $this->paymentHelper;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param Netresearch_OPS_Helper_Payment $paymentHelper
|
80 |
+
*
|
81 |
+
* @returns $this
|
82 |
+
*/
|
83 |
+
public function setPaymentHelper($paymentHelper)
|
84 |
+
{
|
85 |
+
$this->paymentHelper = $paymentHelper;
|
86 |
+
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @return Netresearch_OPS_Helper_Subscription
|
93 |
+
*/
|
94 |
+
public function getSubscriptionHelper()
|
95 |
+
{
|
96 |
+
if (is_null($this->subscriptionHelper)) {
|
97 |
+
$this->subscriptionHelper = Mage::helper('ops/subscription');
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this->subscriptionHelper;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @param Netresearch_OPS_Helper_Subscription $subscriptionHelper
|
105 |
+
*
|
106 |
+
* @returns $this
|
107 |
+
*/
|
108 |
+
public function setSubscriptionHelper($subscriptionHelper)
|
109 |
+
{
|
110 |
+
$this->subscriptionHelper = $subscriptionHelper;
|
111 |
+
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Process request from Acceptance automatic subscription payments and initial creations
|
118 |
+
*
|
119 |
+
*
|
120 |
+
* @param mixed[] $responseParams
|
121 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile - only has to be provided during the initial setup of
|
122 |
+
* the subscription
|
123 |
+
* @param Mage_Sales_Model_Order $order
|
124 |
+
*
|
125 |
+
*
|
126 |
+
* @return Mage_Sales_Model_Order | false
|
127 |
+
*/
|
128 |
+
public function processSubscriptionFeedback($responseParams, $profile = null, $order = null)
|
129 |
+
{
|
130 |
+
$createOrder = true;
|
131 |
+
$feedbackType = false;
|
132 |
+
$orderId = $responseParams['orderID'];
|
133 |
+
if (!is_array($responseParams)) {
|
134 |
+
Mage::throwException($this->getDataHelper()->__('No response array provided'));
|
135 |
+
}
|
136 |
+
|
137 |
+
if (is_null($profile)) {
|
138 |
+
$profile = $this->getSubscriptionHelper()->getProfileForSubscription($orderId);
|
139 |
+
}
|
140 |
+
|
141 |
+
if (array_key_exists('creation_status', $responseParams)) {
|
142 |
+
switch ($responseParams['creation_status']) {
|
143 |
+
case self::CREATION_SUCCEEDED:
|
144 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
145 |
+
break;
|
146 |
+
default:
|
147 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN);
|
148 |
+
break;
|
149 |
+
}
|
150 |
+
$profile->setReferenceId($responseParams['subscription_id']);
|
151 |
+
$profile->setProfileVendorInfo(serialize($responseParams));
|
152 |
+
$profile->setAdditionalInfo(serialize($responseParams));
|
153 |
+
$feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL;
|
154 |
+
// do not create an order since it already got created
|
155 |
+
$createOrder = false;
|
156 |
+
}
|
157 |
+
|
158 |
+
if (!$feedbackType) {
|
159 |
+
if ($this->getSubscriptionHelper()->isTrialFeedback($orderId)) {
|
160 |
+
$feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
|
161 |
+
} else {
|
162 |
+
$feedbackType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if ($createOrder && is_null($order)) {
|
167 |
+
return $this->createOrderFromFeedback($profile, $feedbackType, $responseParams);
|
168 |
+
} elseif (!is_null($order)) {
|
169 |
+
return $this->processPaymentFeedback($responseParams, $profile, $order);
|
170 |
+
}
|
171 |
+
|
172 |
+
return $createOrder;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Creates an order for the given item type using the recurring profile model
|
177 |
+
*
|
178 |
+
* @see Mage_Sales_Model_Recurring_Profile::createOrder()
|
179 |
+
*
|
180 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
181 |
+
* @param string $feedbackType - @see Mage_Sales_Model_Recurring_Profile payment types
|
182 |
+
* @param string[] $responseParams
|
183 |
+
*
|
184 |
+
* @return Mage_Sales_Model_Order the created order
|
185 |
+
*/
|
186 |
+
protected function createOrderFromFeedback($profile, $feedbackType, $responseParams)
|
187 |
+
{
|
188 |
+
// Just set the payment type, the recurring profile sets the correct amounts automatically
|
189 |
+
$orderItem = new Varien_Object();
|
190 |
+
$orderItem->setPaymentType($feedbackType);
|
191 |
+
if ($feedbackType == Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL) {
|
192 |
+
$orderItemInfo = new Varien_Object($profile->getOrderItemInfo());
|
193 |
+
$calculator = Mage::getModel('tax/calculation');
|
194 |
+
$tax = $calculator->calcTaxAmount($profile->getTrialBillingAmount(),
|
195 |
+
$orderItemInfo->getTaxPercent(), true, true
|
196 |
+
);
|
197 |
+
$price = $profile->getTrialBillingAmount() - $tax;
|
198 |
+
$orderItem->setPrice($price)
|
199 |
+
->setTaxAmount($tax);
|
200 |
+
}
|
201 |
+
|
202 |
+
$order = $profile->createOrder($orderItem);
|
203 |
+
$billingAddressInfo = $profile->getBillingAddressInfo();
|
204 |
+
$order->setQuoteId($billingAddressInfo['quote_id']);
|
205 |
+
|
206 |
+
$order = $this->processPaymentFeedback($responseParams, $profile, $order);
|
207 |
+
|
208 |
+
return $order;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Creates an order for the initial fee. It also fixes the missing data for the order item, so a capture can be
|
213 |
+
* properly processed and an invoice created.
|
214 |
+
*
|
215 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
216 |
+
*
|
217 |
+
* @return Mage_Sales_Model_Order
|
218 |
+
*/
|
219 |
+
public function createInitialOrder(Mage_Payment_Model_Recurring_Profile $profile)
|
220 |
+
{
|
221 |
+
/** @var $profile Mage_Sales_Model_Recurring_Profile */
|
222 |
+
$item = new Varien_Object();
|
223 |
+
$orderItemInfo = new Varien_Object($profile->getOrderItemInfo());
|
224 |
+
$calculator = Mage::getModel('tax/calculation');
|
225 |
+
$taxAmount = $calculator->calcTaxAmount($profile->getInitAmount(), $orderItemInfo->getTaxPercent(), true,
|
226 |
+
true
|
227 |
+
);
|
228 |
+
$amountWithoutTax = $profile->getInitAmount() - $taxAmount;
|
229 |
+
$item->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL)
|
230 |
+
->setPrice($amountWithoutTax)
|
231 |
+
->setTaxAmount($taxAmount);
|
232 |
+
|
233 |
+
$order = $profile->createOrder($item);
|
234 |
+
$order->setQuoteId($profile->getQuote()->getId());
|
235 |
+
|
236 |
+
/** @var $item Mage_Sales_Model_Order_Item */
|
237 |
+
list($item) = $order->getAllItems();
|
238 |
+
$item->setData('base_discount_amount', 0)
|
239 |
+
->setData('base_discount_calculation_price', $profile->getInitAmount())
|
240 |
+
->setData('base_hidden_tax_amount', 0)
|
241 |
+
->setData('base_original_price', $profile->getInitAmount())
|
242 |
+
->setData('base_price_incl_tax', $profile->getInitAmount())
|
243 |
+
->setData('base_row_tax', $taxAmount)
|
244 |
+
->setData('base_row_total_incl_tax', $profile->getInitAmount())
|
245 |
+
->setData('base_tax_amount', $taxAmount)
|
246 |
+
->setData('base_taxable_amount', $profile->getInitAmount())
|
247 |
+
->setData('calculation_price', $amountWithoutTax)
|
248 |
+
->setData('converted_price', $amountWithoutTax)
|
249 |
+
->setData('discount_calculation_price', $profile->getInitAmount())
|
250 |
+
->setData('price_incl_tax', $profile->getInitAmount())
|
251 |
+
->setData('row_tax', $taxAmount)
|
252 |
+
->setData('row_total_incl_tax', $profile->getInitAmount())
|
253 |
+
->setData('taxable_amount', $profile->getInitAmount());
|
254 |
+
|
255 |
+
$itemData = $item->getData();
|
256 |
+
$item->addData($profile->getOrderItemInfo());
|
257 |
+
$item->addData($itemData);
|
258 |
+
$item->setId(null);
|
259 |
+
$order->getItemsCollection()->removeItemByKey(0);
|
260 |
+
$order->addItem($item);
|
261 |
+
$order->save();
|
262 |
+
|
263 |
+
return $order;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Takes the responseparameters and applies the corresponding action (capture/authorize) on the order payment.
|
268 |
+
* Also updates the Acceptance information on the payment.
|
269 |
+
*
|
270 |
+
* @param string[] $responseParams
|
271 |
+
* @param Mage_Sales_Model_Recurring_Profile $profile
|
272 |
+
* @param Mage_Sales_Model_Order $order
|
273 |
+
*
|
274 |
+
* @return Mage_Sales_Model_Order $order - updated order
|
275 |
+
*/
|
276 |
+
protected function processPaymentFeedback($responseParams, $profile, $order)
|
277 |
+
{
|
278 |
+
$payment = $order->getPayment();
|
279 |
+
foreach ($responseParams as $key => $value) {
|
280 |
+
$payment->setTransactionAdditionalInfo($key, $value);
|
281 |
+
}
|
282 |
+
$payment->setTransactionId($responseParams['PAYID'])
|
283 |
+
->setCurrencyCode($responseParams['currency'])
|
284 |
+
->setIsTransactionClosed(0);
|
285 |
+
$order->save();
|
286 |
+
$profile->addOrderRelation($order->getId());
|
287 |
+
if ($this->getPaymentHelper()->isPaymentAuthorizeType($responseParams['STATUS'])) {
|
288 |
+
$payment->registerAuthorizationNotification($responseParams['amount']);
|
289 |
+
} elseif ($this->getPaymentHelper()->isPaymentCaptureType($responseParams['STATUS'])) {
|
290 |
+
$payment->registerCaptureNotification($responseParams['amount']);
|
291 |
+
} elseif ($responseParams['STATUS']
|
292 |
+
== Netresearch_OPS_Model_Payment_Abstract::OPS_WAITING_FOR_IDENTIFICATION
|
293 |
+
) {
|
294 |
+
// handle 3ds payment - only relevant for initial order creation
|
295 |
+
$payment->setIsTransactionPending(1);
|
296 |
+
$payment->registerCaptureNotification($responseParams['amount'], true);
|
297 |
+
}
|
298 |
+
$order->save();
|
299 |
+
$this->getPaymentHelper()->applyStateForOrder($order, $responseParams);
|
300 |
+
|
301 |
+
return $order;
|
302 |
+
}
|
303 |
+
|
304 |
+
}
|
app/code/community/Netresearch/OPS/Model/System/Config/Backend/Flex/Methods.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Methods.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Netresearch_OPS_Model_System_Config_Backend_Flex_Methods
|
31 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
32 |
+
{
|
33 |
+
protected $_eventPrefix = 'ops_config_backend_flex_methods';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* additional validation for unique brands
|
37 |
+
*
|
38 |
+
* @override
|
39 |
+
* @throws Mage_Core_Exception if the brands are not unique -> validation failed
|
40 |
+
* @return Netresearch_Ops_Model_System_Config_Backend_Intersolve_Brands
|
41 |
+
*/
|
42 |
+
public function save()
|
43 |
+
{
|
44 |
+
$methods = $this->getValue();
|
45 |
+
if (is_array($methods) && sizeof($methods) > 1) {
|
46 |
+
$alreadyProcessedMethods = array();
|
47 |
+
foreach ($methods as $method) {
|
48 |
+
|
49 |
+
if (is_array($method)
|
50 |
+
&& array_key_exists('pm', $method)
|
51 |
+
&& array_key_exists('brand', $method)
|
52 |
+
) {
|
53 |
+
if(empty($method['title'])||empty($method['pm'])){
|
54 |
+
Mage::throwException("Can not save empty title or PM fields");
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
if (in_array($method['pm'].'_'.$method['brand'], $alreadyProcessedMethods)) {
|
59 |
+
Mage::throwException("PM and Brand combination must be unique");
|
60 |
+
}
|
61 |
+
$alreadyProcessedMethods[] = $method['pm'].'_'.$method['brand'];
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return parent::save();
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Netresearch/OPS/Model/System/Config/Backend/HashMethods.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @category Netresearch
|
18 |
+
* @package Netresearch_OPS
|
19 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
*
|
27 |
+
* @category Netresearch
|
28 |
+
* @package Netresearch_OPS
|
29 |
+
* @author Benjamin Heuer <benjamin.heuer@netresearch.de>
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Netresearch_Ops_Model_System_Config_Backend_HashMethods
|
33 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* Options getter
|
37 |
+
*
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
public function toOptionArray()
|
41 |
+
{
|
42 |
+
return array(
|
43 |
+
array('value' => 'sha1', 'label'=>Mage::helper('ops')->__('SHA-1')),
|
44 |
+
array('value' => 'sha256', 'label'=>Mage::helper('ops')->__('SHA-256')),
|
45 |
+
array('value' => 'sha512', 'label'=>Mage::helper('ops')->__('SHA-512'))
|
46 |
+
);
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Netresearch/OPS/Model/System/Config/Backend/Intersolve/Brands.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @category Netresearch
|
18 |
+
* @package Netresearch_OPS
|
19 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
*
|
27 |
+
* @category Netresearch
|
28 |
+
* @package Netresearch_OPS
|
29 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Netresearch_Ops_Model_System_Config_Backend_Intersolve_Brands
|
33 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
34 |
+
{
|
35 |
+
protected $_eventPrefix = 'ops_config_backend_intersolve_brands';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* additional validation for unique brands
|
39 |
+
*
|
40 |
+
* @override
|
41 |
+
* @throws Mage_Core_Exception if the brands are not unique -> validation failed
|
42 |
+
* @return Netresearch_Ops_Model_System_Config_Backend_Intersolve_Brands
|
43 |
+
*/
|
44 |
+
public function save()
|
45 |
+
{
|
46 |
+
$brands = $this->getValue();
|
47 |
+
if (is_array($brands) && sizeof($brands) > 1) {
|
48 |
+
$alreadyProcessedBrands = array();
|
49 |
+
foreach ($brands as $brand) {
|
50 |
+
if (is_array($brand) && array_key_exists('brand', $brand)) {
|
51 |
+
if (in_array($brand['brand'], $alreadyProcessedBrands)) {
|
52 |
+
Mage::throwException("Brands must be unique");
|
53 |
+
}
|
54 |
+
$alreadyProcessedBrands[] = $brand['brand'];
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
return parent::save();
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Netresearch/OPS/Model/System/Config/Mode.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mode.php
|
4 |
+
* @author paul.siedler@netresearch.de
|
5 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Netresearch_OPS_Model_System_Config_Mode extends Mage_Core_Model_Config_Data
|
10 |
+
{
|
11 |
+
|
12 |
+
public function _afterSave()
|
13 |
+
{
|
14 |
+
|
15 |
+
if($this->getValue() != Netresearch_OPS_Model_Source_Mode::CUSTOM && $this->isValueChanged()){
|
16 |
+
$xmlConfig = Mage::getConfig()->loadModulesConfiguration('config.xml');
|
17 |
+
foreach($this->getUrlPaths() as $path){
|
18 |
+
$default = $xmlConfig->getNode('default/'.$path);
|
19 |
+
$newValue = preg_replace('/\/ncol\/\w+/', '/ncol/'.$this->getValue(), $default);
|
20 |
+
Mage::getConfig()->saveConfig($path, $newValue, $this->getScope(), $this->getScopeId());
|
21 |
+
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return parent::_afterSave();
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function getUrlPaths(){
|
29 |
+
return array(
|
30 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'ops_gateway',
|
31 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'ops_alias_gateway',
|
32 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'frontend_gateway',
|
33 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_gateway',
|
34 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_gateway_order',
|
35 |
+
Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'directlink_maintenance_api'
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/Netresearch/OPS/Model/System/Config/Template.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Template.php
|
5 |
+
* @author paul.siedler@netresearch.de
|
6 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Model_System_Config_Template extends Mage_Core_Model_Config_Data
|
10 |
+
{
|
11 |
+
protected function getConfig()
|
12 |
+
{
|
13 |
+
return Mage::getModel('ops/config');
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
|
18 |
+
{
|
19 |
+
$paypageUrl = $this->getConfig()->getPayPageTemplate();
|
20 |
+
$paypageInfo = Mage::helper('ops')->__(
|
21 |
+
'With this setting the customer will be redirected to the Acceptance paypage with the look and feel of your shop. ' .
|
22 |
+
'</br> The template used can be seen here: </br>'
|
23 |
+
);
|
24 |
+
$paypageInfo .= "<a href=\"" . $paypageUrl . "\">" . $paypageUrl . "</a>";
|
25 |
+
|
26 |
+
$result = "<p class=\"note\"><span id=\"ops_template_comment\"></span></p>";
|
27 |
+
$result .= "
|
28 |
+
<script type=\"text/javascript\">
|
29 |
+
Translator.add(
|
30 |
+
'" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL . "',
|
31 |
+
'" . $paypageInfo . "'
|
32 |
+
);
|
33 |
+
Translator.add(
|
34 |
+
'" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE . "',
|
35 |
+
'" . Mage::helper('ops')->__('With this setting the customer will be redirected to the Acceptance paypage. The look and feel of that page will be defined by a dynamically loaded template file whose origin you can define below.') . "'
|
36 |
+
);
|
37 |
+
Translator.add(
|
38 |
+
'" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME . "',
|
39 |
+
'" . Mage::helper('ops')->__('With this setting the customer will enter the payment details on a page in your shop that hosts the Acceptance paypage in an iFrame. You can style the paypage through the parameters below.') . "'
|
40 |
+
);
|
41 |
+
Translator.add(
|
42 |
+
'" . Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT . "',
|
43 |
+
'" . Mage::helper('ops')->__('With this setting the customer will get redirected to Acceptance to enter his payment details. You can style the page through the parameters below.') . "'
|
44 |
+
);
|
45 |
+
selectElement = $('payment_services_ops_template');
|
46 |
+
|
47 |
+
function updateComment(value){
|
48 |
+
var comment = $('ops_template_comment');
|
49 |
+
comment.innerHTML = Translator.translate(value);
|
50 |
+
}
|
51 |
+
|
52 |
+
Event.observe(window, 'load', function(){
|
53 |
+
updateComment('" . $currentValue . "');
|
54 |
+
Event.observe(selectElement, 'change', function(){
|
55 |
+
updateComment(selectElement.value);
|
56 |
+
});
|
57 |
+
});
|
58 |
+
</script>";
|
59 |
+
|
60 |
+
return $result;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/CompositeInterface.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
interface Netresearch_OPS_Model_Validator_CompositeInterface
|
9 |
+
{
|
10 |
+
public function addValidator(Zend_Validate_Interface $validator);
|
11 |
+
|
12 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/Kwixo/Shipping/Setting.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package ${MODULENAME}
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Model_Validator_Kwixo_Shipping_Setting
|
12 |
+
{
|
13 |
+
|
14 |
+
private $messages = array();
|
15 |
+
|
16 |
+
public function isValid(array $data)
|
17 |
+
{
|
18 |
+
$result = false;
|
19 |
+
$methodCodes = array_keys(Mage::getSingleton('shipping/config')->getAllCarriers());
|
20 |
+
if (0 < count($data)) {
|
21 |
+
$result = true;
|
22 |
+
foreach ($data as $code => $row) {
|
23 |
+
if (!in_array($code, $methodCodes)) continue;
|
24 |
+
$result = $this->validateRow($code, $row) && $result;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
return $result;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getMessages()
|
31 |
+
{
|
32 |
+
return $this->messages;
|
33 |
+
}
|
34 |
+
|
35 |
+
private function validateRow($code, $row)
|
36 |
+
{
|
37 |
+
$shippingTypeResult = $this->validateShippingType($code, $row);
|
38 |
+
$shippingSpeedResult = $this->validateShippingSpeed($code, $row);
|
39 |
+
$shippingDetailsResult = $this->validateShippingDetails($code, $row);
|
40 |
+
return $shippingTypeResult && $shippingSpeedResult && $shippingDetailsResult;
|
41 |
+
}
|
42 |
+
|
43 |
+
private function validateShippingType($code, $row)
|
44 |
+
{
|
45 |
+
$validValues = Mage::getModel('ops/source_kwixo_shipMethodType')
|
46 |
+
->getValidValues();
|
47 |
+
|
48 |
+
if (array_key_exists('kwixo_shipping_type', $row)
|
49 |
+
&& Zend_Validate::is(
|
50 |
+
$row['kwixo_shipping_type'], 'Digits'
|
51 |
+
)
|
52 |
+
&& 0 < $row['kwixo_shipping_type']
|
53 |
+
&& in_array((int)$row['kwixo_shipping_type'], $validValues)
|
54 |
+
|
55 |
+
) {
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
$this->messages[$code]['kwixo_shipping_type_error']
|
59 |
+
= 'invalid shipping type provided';
|
60 |
+
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
private function validateShippingSpeed($code, $row)
|
65 |
+
{
|
66 |
+
if (array_key_exists('kwixo_shipping_speed', $row)
|
67 |
+
&& Zend_Validate::is(
|
68 |
+
$row['kwixo_shipping_speed'], 'Digits'
|
69 |
+
)
|
70 |
+
&& 0 < $row['kwixo_shipping_speed']
|
71 |
+
) {
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
$this->messages[$code]['kwixo_shipping_speed_error']
|
75 |
+
= 'invalid shipping speed provided';
|
76 |
+
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
private function validateShippingDetails($code, $row)
|
81 |
+
{
|
82 |
+
if (array_key_exists('kwixo_shipping_details', $row)
|
83 |
+
&& Zend_Validate::is(
|
84 |
+
$row['kwixo_shipping_details'], 'StringLength',
|
85 |
+
array('min' => 0, 'max' => 50)
|
86 |
+
)
|
87 |
+
) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
$this->messages[$code]['kwixo_shipping_details_error']
|
91 |
+
= 'invalid shipping details provided';
|
92 |
+
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/Parameter/Factory.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Validator_Parameter_Factory extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
const TYPE_REQUEST_PARAMS_VALIDATION = 'request_validation';
|
14 |
+
|
15 |
+
protected $validator = null;
|
16 |
+
|
17 |
+
protected $config = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* sets the necessary dependencies for this class
|
21 |
+
*/
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->validator = Mage::getModel('ops/validator_parameter_validator');
|
26 |
+
$this->config = Mage::getModel('ops/config');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* creates validator for given type
|
31 |
+
*
|
32 |
+
* @param $type - the requested type
|
33 |
+
*
|
34 |
+
* @return Netresearch_OPS_Model_Validator_Parameter_Validator
|
35 |
+
*/
|
36 |
+
public function getValidatorFor($type)
|
37 |
+
{
|
38 |
+
if ($type == self::TYPE_REQUEST_PARAMS_VALIDATION) {
|
39 |
+
$this->createRequestParamsValidator();
|
40 |
+
}
|
41 |
+
|
42 |
+
return $this->validator;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* configures the validator for validation of the request parameter
|
47 |
+
*
|
48 |
+
* @return $this
|
49 |
+
*/
|
50 |
+
protected function createRequestParamsValidator()
|
51 |
+
{
|
52 |
+
$validator = Mage::getModel('ops/validator_parameter_length');
|
53 |
+
$validator->setFieldLengths($this->config->getParameterLengths());
|
54 |
+
$this->validator->addValidator($validator);
|
55 |
+
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/Parameter/Length.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Validator_Parameter_Length implements Zend_Validate_Interface
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $messages = array();
|
14 |
+
|
15 |
+
protected $fieldLengths = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param array $fieldLengths - the fieldLengths which are assumed as valid
|
19 |
+
*/
|
20 |
+
public function setFieldLengths(array $fieldLengths)
|
21 |
+
{
|
22 |
+
$this->fieldLengths = $fieldLengths;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* gets the current configuration of the field lengths
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function getFieldLengths()
|
31 |
+
{
|
32 |
+
return $this->fieldLengths;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* checks if the given data matching the given string lengths
|
37 |
+
*
|
38 |
+
* @param mixed $dataToValidate
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
public function isValid($dataToValidate)
|
43 |
+
{
|
44 |
+
$validationResult = true;
|
45 |
+
if (is_array($dataToValidate) && 0 < count($dataToValidate)) {
|
46 |
+
foreach ($dataToValidate as $key => $value) {
|
47 |
+
$maxLength = $this->getFieldLengthFor($key);
|
48 |
+
if(is_null($value)){
|
49 |
+
$value = '';
|
50 |
+
}
|
51 |
+
if (0 < $maxLength) {
|
52 |
+
if (false == Zend_Validate::is(utf8_encode($value), 'StringLength', array('max' => $maxLength, 'encoding' => 'utf-8'))) {
|
53 |
+
$this->messages[$key] = Mage::helper('ops/data')->__('value exceeds %d characters', $maxLength);
|
54 |
+
$validationResult = false;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
return $validationResult;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* gets the messages
|
65 |
+
*
|
66 |
+
* @return array
|
67 |
+
*/
|
68 |
+
public function getMessages()
|
69 |
+
{
|
70 |
+
return $this->messages;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* gets the valid string length for a given value
|
75 |
+
*
|
76 |
+
* @param $paramName
|
77 |
+
*
|
78 |
+
* @return int -1 if not found, the corresponding value otherwise
|
79 |
+
*/
|
80 |
+
protected function getFieldLengthFor($paramName)
|
81 |
+
{
|
82 |
+
$value = -1;
|
83 |
+
if (array_key_exists($paramName, $this->fieldLengths)) {
|
84 |
+
$value = $this->fieldLengths[$paramName];
|
85 |
+
}
|
86 |
+
|
87 |
+
return $value;
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/Parameter/Validator.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Model_Validator_Parameter_Validator
|
11 |
+
implements Netresearch_OPS_Model_Validator_CompositeInterface, Zend_Validate_Interface
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $validators = array();
|
15 |
+
|
16 |
+
protected $messages = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* adds a validator
|
20 |
+
*
|
21 |
+
* @param Zend_Validate_Interface $validator
|
22 |
+
*/
|
23 |
+
public function addValidator(Zend_Validate_Interface $validator)
|
24 |
+
{
|
25 |
+
$this->validators[] = $validator;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param $dataToValidate
|
30 |
+
*
|
31 |
+
* @return bool - indicates whether the data are valid or not
|
32 |
+
*/
|
33 |
+
public function isValid($dataToValidate)
|
34 |
+
{
|
35 |
+
$isValid = true;
|
36 |
+
foreach ($this->validators as $validator) {
|
37 |
+
/** @var Zend_Validate_Interface $validator */
|
38 |
+
$isValid = $isValid && $validator->isValid($dataToValidate);
|
39 |
+
if (false === $validator->isValid($dataToValidate)) {
|
40 |
+
$this->messages = array_merge($this->messages, $validator->getMessages());
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return $isValid;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getMessages()
|
48 |
+
{
|
49 |
+
return $this->messages;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getValidators()
|
53 |
+
{
|
54 |
+
return $this->validators;
|
55 |
+
}
|
56 |
+
}
|
app/code/community/Netresearch/OPS/Model/Validator/Payment/DirectDebit.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Model_Validator_Payment_DirectDebit
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $messages = array();
|
15 |
+
|
16 |
+
protected $dataHelper = null;
|
17 |
+
|
18 |
+
protected $directDebitHelper = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* sets the data helper
|
22 |
+
*
|
23 |
+
* @param Mage_Core_Helper_Abstract $dataHelper
|
24 |
+
*/
|
25 |
+
public function setDataHelper(Mage_Core_Helper_Abstract $dataHelper)
|
26 |
+
{
|
27 |
+
$this->dataHelper = $dataHelper;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* gwets the data helper
|
32 |
+
*
|
33 |
+
* @return Mage_Core_Helper_Abstract|null
|
34 |
+
*/
|
35 |
+
public function getDataHelper()
|
36 |
+
{
|
37 |
+
if (null == $this->dataHelper) {
|
38 |
+
$this->dataHelper = Mage::helper('ops/data');
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this->dataHelper;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* sets the direct debit helper
|
46 |
+
*
|
47 |
+
* @param Netresearch_OPS_Helper_DirectDebit $directDebitHelper
|
48 |
+
*/
|
49 |
+
public function setDirectDebitHelper(Netresearch_OPS_Helper_DirectDebit $directDebitHelper)
|
50 |
+
{
|
51 |
+
$this->directDebitHelper = $directDebitHelper;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* gets the direct debit helper
|
56 |
+
*
|
57 |
+
* @return Netresearch_OPS_Helper_DirectDebit
|
58 |
+
*/
|
59 |
+
public function getDirectDebitHelper()
|
60 |
+
{
|
61 |
+
if (null === $this->directDebitHelper) {
|
62 |
+
$this->directDebitHelper = Mage::helper('ops/directDebit');
|
63 |
+
}
|
64 |
+
return $this->directDebitHelper;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* validates the direct debit payment data
|
69 |
+
*
|
70 |
+
* @param array $directDebitData
|
71 |
+
*
|
72 |
+
* @return bool - true if the direct data are valid, false otherwise
|
73 |
+
*/
|
74 |
+
public function isValid(array $directDebitData)
|
75 |
+
{
|
76 |
+
if (false === $this->checkPreconditions($directDebitData)) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
return $this->validateAccountData($directDebitData);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* gets the validation messages
|
85 |
+
*
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
public function getMessages()
|
89 |
+
{
|
90 |
+
return $this->messages;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* checks if the neccesaary data are present
|
95 |
+
*
|
96 |
+
* @param array $accountData
|
97 |
+
*
|
98 |
+
* @return bool - true if the neccessary data are present, false otherwise
|
99 |
+
*/
|
100 |
+
protected function checkPreconditions(array $accountData)
|
101 |
+
{
|
102 |
+
if (0 == count($accountData)
|
103 |
+
|| !array_key_exists(
|
104 |
+
'CN', $accountData
|
105 |
+
)
|
106 |
+
|| !array_key_exists('country', $accountData)
|
107 |
+
|| !array_key_exists('account', $accountData)
|
108 |
+
|| !array_key_exists('iban', $accountData)
|
109 |
+
) {
|
110 |
+
$this->messages[] = $this->getDataHelper()->__(
|
111 |
+
'invalid data provided'
|
112 |
+
);
|
113 |
+
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* checks if the account data are valid
|
122 |
+
*
|
123 |
+
* @param array $accountData
|
124 |
+
*
|
125 |
+
* @return bool - true if the data are valid, false otherise
|
126 |
+
*/
|
127 |
+
protected function validateAccountData(array $accountData)
|
128 |
+
{
|
129 |
+
$result = true;
|
130 |
+
if ($this->hasAccountHolder($accountData)) {
|
131 |
+
$this->messages[] = $this->getDataHelper()->__(
|
132 |
+
'Account holder must be provided'
|
133 |
+
);
|
134 |
+
$result = false;
|
135 |
+
}
|
136 |
+
|
137 |
+
// check iban data
|
138 |
+
if ($this->hasIban($accountData)) {
|
139 |
+
$result = $this->validateIban(
|
140 |
+
$accountData['country'], $accountData['iban'],
|
141 |
+
(array_key_exists('bic', $accountData))? $accountData['bic'] : ''
|
142 |
+
);
|
143 |
+
}
|
144 |
+
// check bank account data
|
145 |
+
else {
|
146 |
+
$result = $this->validateBankAccount(
|
147 |
+
$accountData['country'], $accountData['account'],
|
148 |
+
(array_key_exists('bankcode', $accountData))
|
149 |
+
? $accountData['bankcode'] : ''
|
150 |
+
);
|
151 |
+
}
|
152 |
+
|
153 |
+
return $result;
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* validates iban and (optional) bic data
|
159 |
+
*
|
160 |
+
* @param $country - the country for the iban
|
161 |
+
* @param $iban - the iban to validate
|
162 |
+
* @param $bic - the bic if given
|
163 |
+
*
|
164 |
+
* @return bool - true if the iban data are valid, false otherwise
|
165 |
+
*/
|
166 |
+
protected function validateIban($country, $iban, $bic)
|
167 |
+
{
|
168 |
+
$country = strtoupper(trim($country));
|
169 |
+
$result = true;
|
170 |
+
if ('DE' != $country && 'NL' != $country) {
|
171 |
+
$result = false;
|
172 |
+
$this->messages[] = $this->getDataHelper()->__(
|
173 |
+
'Country not supported for IBAN'
|
174 |
+
);
|
175 |
+
}
|
176 |
+
$validator = new Zend_Validate_Iban();
|
177 |
+
|
178 |
+
if (!$validator->isValid($iban)) {
|
179 |
+
$result = false;
|
180 |
+
|
181 |
+
$this->messages[] = $this->getDataHelper()->__('Invalid IBAN provided');
|
182 |
+
}
|
183 |
+
if ('NL' == $country
|
184 |
+
&& (11 < strlen(trim($bic)))
|
185 |
+
) {
|
186 |
+
$result = false;
|
187 |
+
$this->messages[] = $this->getDataHelper()->__(
|
188 |
+
'invalid BIC provided'
|
189 |
+
);
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
return $result;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* validates bank account data
|
198 |
+
*
|
199 |
+
* @param $country - the country for the bank account data
|
200 |
+
* @param $accountNo - the account number
|
201 |
+
* @param $bankCode - the bank code
|
202 |
+
*
|
203 |
+
* @return bool - true if the data are valid, false otherwise
|
204 |
+
*/
|
205 |
+
protected function validateBankAccount($country, $accountNo, $bankCode)
|
206 |
+
{
|
207 |
+
$result = true;
|
208 |
+
if (!is_numeric($accountNo)) {
|
209 |
+
$this->messages[] = $this->getDataHelper()->__(
|
210 |
+
'Account number must contain numbers only.'
|
211 |
+
);
|
212 |
+
$result = false;
|
213 |
+
}
|
214 |
+
$country = strtolower($country);
|
215 |
+
if (('de' == $country || 'at' == $country) && !is_numeric($bankCode)) {
|
216 |
+
$this->messages[] = $this->getDataHelper()->__(
|
217 |
+
'Bank code must contain numbers only.'
|
218 |
+
);
|
219 |
+
$result = false;
|
220 |
+
}
|
221 |
+
|
222 |
+
return $result;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* checks if account holder is provided in the given account data
|
227 |
+
*
|
228 |
+
* @param array $accountData
|
229 |
+
*
|
230 |
+
* @return bool - true if account holder is present, false otherwise
|
231 |
+
*/
|
232 |
+
protected function hasAccountHolder(array $accountData)
|
233 |
+
{
|
234 |
+
return array_key_exists('CN', $accountData)
|
235 |
+
&& 0 === strlen(trim($accountData['CN']));
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* checks if the account data has the ibna field
|
240 |
+
*
|
241 |
+
* @param array $accountData
|
242 |
+
*
|
243 |
+
* @return bool - true if the account data contain the iban
|
244 |
+
*/
|
245 |
+
protected function hasIban(array $accountData)
|
246 |
+
{
|
247 |
+
return $this->getDirectDebitHelper()->hasIban($accountData);
|
248 |
+
}
|
249 |
+
|
250 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Customer/Renderer/StateTest.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_Adminhtml_Customer_Renderer_StateTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case
|
5 |
+
{
|
6 |
+
|
7 |
+
public function testRender()
|
8 |
+
{
|
9 |
+
$column = new Varien_Object();
|
10 |
+
$column->setIndex('state');
|
11 |
+
$row = new Varien_Object();
|
12 |
+
$row->setData(array('state' => Netresearch_OPS_Model_Alias_State::ACTIVE));
|
13 |
+
$block = Mage::app()->getLayout()->getBlockSingleton(
|
14 |
+
'ops/adminhtml_customer_renderer_state'
|
15 |
+
);
|
16 |
+
$block->setColumn($column);
|
17 |
+
$this->assertEquals(
|
18 |
+
Mage::helper('ops/data')->__(
|
19 |
+
Netresearch_OPS_Model_Alias_State::ACTIVE
|
20 |
+
) , $block->render($row)
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Kwixo/Shipping/EditTest.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @package Netresearch_OPS
|
7 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
class Netresearch_OPS_Test_Block_Adminhtml_Kwixo_Shipping_EditTest
|
11 |
+
extends EcomDev_PHPUnit_Test_Case
|
12 |
+
{
|
13 |
+
|
14 |
+
public function setUp()
|
15 |
+
{
|
16 |
+
$sessionMock = $this->getModelMock(
|
17 |
+
'core/session', array('init', 'save', 'getSessionIdForHost')
|
18 |
+
);
|
19 |
+
|
20 |
+
$this->replaceByMock('model', 'core/session', $sessionMock);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testGetFormActionUrl()
|
24 |
+
{
|
25 |
+
|
26 |
+
$widgetContainer = new Mage_Adminhtml_Block_Widget_Form_Container();
|
27 |
+
$block
|
28 |
+
= new Netresearch_OPS_Block_Adminhtml_Kwixo_Shipping_Edit();
|
29 |
+
$this->assertEquals(
|
30 |
+
$widgetContainer->getUrl('adminhtml/kwixoshipping/save', array()),
|
31 |
+
$block->getFormActionUrl()
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function testGetShippingMethods()
|
36 |
+
{
|
37 |
+
$shippingConfigMock = $this->getModelMock(
|
38 |
+
'shipping/config', array('getAllCarriers')
|
39 |
+
);
|
40 |
+
$shippingConfigMock->expects($this->any())
|
41 |
+
->method('getAllCarriers')
|
42 |
+
->will(
|
43 |
+
$this->returnValue(
|
44 |
+
array('dhl' => 'dhl', 'hermes' => 'hermes', 'ips' => 'ips')
|
45 |
+
)
|
46 |
+
);
|
47 |
+
$this->replaceByMock('model', 'shipping/config', $shippingConfigMock);
|
48 |
+
|
49 |
+
$block = new Netresearch_OPS_Block_Adminhtml_Kwixo_Shipping_Edit();
|
50 |
+
$result = $block->getShippingMethods();
|
51 |
+
$this->assertEquals(3, count($result));
|
52 |
+
$this->assertEquals($result[0]['code'], 'dhl');
|
53 |
+
$this->assertEquals($result[1]['code'], 'hermes');
|
54 |
+
$this->assertEquals($result[1]['label'], 'hermes');
|
55 |
+
$this->assertEquals($result[2]['code'], 'ips');
|
56 |
+
$this->assertEquals($result[2]['label'], 'ips');
|
57 |
+
|
58 |
+
$block->setData(
|
59 |
+
'postData', array('dhl' => array('error' => 'sample error'))
|
60 |
+
);
|
61 |
+
$result = $block->getShippingMethods();
|
62 |
+
$this->assertEquals($result[0]['values']['error'], 'sample error');
|
63 |
+
}
|
64 |
+
|
65 |
+
public function testGetKwixoShippingTypes()
|
66 |
+
{
|
67 |
+
$block = new Netresearch_OPS_Block_Adminhtml_Kwixo_Shipping_Edit();
|
68 |
+
$expectedResult = Mage::getModel('ops/source_kwixo_shipMethodType')
|
69 |
+
->toOptionArray();
|
70 |
+
$this->assertEquals($expectedResult, $block->getKwixoShippingTypes());
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
public function testGetFormKey()
|
75 |
+
{
|
76 |
+
$block = new Netresearch_OPS_Block_Adminhtml_Kwixo_Shipping_Edit();
|
77 |
+
$expectedResult = Mage::getSingleton('core/session')->getFormKey();
|
78 |
+
$this->assertEquals($expectedResult, $block->getFormKey());
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Adminhtml/Sales/Order/Creditmemo/Totals/CheckboxTest.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Block_Adminhtml_Sales_Order_Creditmemo_Totals_CheckboxTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
|
5 |
+
public function testGetTemplate()
|
6 |
+
{
|
7 |
+
$block = Mage::app()->getLayout()->getBlockSingleton('ops/adminhtml_sales_order_creditmemo_totals_checkbox');
|
8 |
+
$this->assertEquals('ops/sales/order/creditmemo/totals/checkbox.phtml', $block->getTemplate());
|
9 |
+
}
|
10 |
+
|
11 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Alias/ListTest.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category OPS
|
4 |
+
* @package Netresearch_OPS
|
5 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
6 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
7 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Netresearch_OPS_Test_Block_Alias_ListTest
|
13 |
+
*
|
14 |
+
* @author Thomas Birke <thomas.birke@netresearch.de>
|
15 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
16 |
+
* @copyright Copyright (c) 2012 Netresearch GmbH & Co. KG
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
class Netresearch_OPS_Test_Block_Alias_ListTest
|
20 |
+
extends EcomDev_PHPUnit_Test_Case
|
21 |
+
{
|
22 |
+
private $block;
|
23 |
+
|
24 |
+
public function setUp()
|
25 |
+
{
|
26 |
+
parent::setup();
|
27 |
+
$this->block = Mage::app()->getLayout()->getBlockSingleton('ops/alias_list');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function testGetMethodName()
|
31 |
+
{
|
32 |
+
$this->assertNull($this->block->getMethodName('something_stupid'));
|
33 |
+
|
34 |
+
Mage::app()->getStore()->setConfig('payment/ops_cc/title', 'OPS Credit Card');
|
35 |
+
$this->assertEquals(
|
36 |
+
'OPS Credit Card',
|
37 |
+
$this->block->getMethodName('ops_cc')
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function testGetAliasDeleteUrl()
|
42 |
+
{
|
43 |
+
// array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure());
|
44 |
+
$this->mockSessions();
|
45 |
+
$aliasId = 1;
|
46 |
+
// previous behaviour until OGNB-229: Mage::getUrl('ops/customer/deleteAlias/id/' . $aliasId)
|
47 |
+
$this->assertEquals(Mage::getUrl('ops/customer/deleteAlias/id/' . $aliasId), $this->block->getAliasDeleteUrl($aliasId));
|
48 |
+
|
49 |
+
// new since OGNB-229: passed aliasId as array param
|
50 |
+
$this->assertEquals(Mage::getUrl('ops/customer/deleteAlias/', array('id' => $aliasId)), $this->block->getAliasDeleteUrl($aliasId));
|
51 |
+
|
52 |
+
$_SERVER['HTTPS'] = 'on';
|
53 |
+
$this->assertEquals(
|
54 |
+
Mage::getUrl(
|
55 |
+
'ops/customer/deleteAlias/',
|
56 |
+
array(
|
57 |
+
'_secure' => true,
|
58 |
+
'id' => $aliasId)
|
59 |
+
),
|
60 |
+
$this->block->getAliasDeleteUrl($aliasId)
|
61 |
+
);
|
62 |
+
}
|
63 |
+
protected function mockSessions()
|
64 |
+
{
|
65 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
66 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
67 |
+
->getMock();
|
68 |
+
$this->replaceByMock('singleton', 'core/session', $sessionMock);
|
69 |
+
|
70 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
71 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
72 |
+
->getMock();
|
73 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* PHP version 5
|
18 |
+
*
|
19 |
+
* @category Netresearch
|
20 |
+
* @package Netresearch_OPS
|
21 |
+
* @author Christoph Aßmann <christoph.assmann@netresearch.de>
|
22 |
+
* @copyright 2016 Netresearch GmbH & Co. KG
|
23 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
24 |
+
* @link http://www.netresearch.de/
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Netresearch_OPS_Test_Block_Checkout_DeviceFingerprintingTest
|
29 |
+
*
|
30 |
+
* @category Netresearch
|
31 |
+
* @package Netresearch_OPS
|
32 |
+
* @author Christoph Aßmann <christoph.assmann@netresearch.de>
|
33 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
34 |
+
* @link http://www.netresearch.de/
|
35 |
+
*/
|
36 |
+
class Netresearch_OPS_Test_Block_Checkout_DeviceFingerprintingTest
|
37 |
+
extends EcomDev_PHPUnit_Test_Case
|
38 |
+
{
|
39 |
+
protected function setUp()
|
40 |
+
{
|
41 |
+
$sessionMock = $this->getModelMock('core/session', array('init'));
|
42 |
+
$this->replaceByMock('singleton', 'core/session', $sessionMock);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @test
|
47 |
+
* @loadFixture
|
48 |
+
*/
|
49 |
+
public function fingerPrintingEnabled()
|
50 |
+
{
|
51 |
+
/** @var Netresearch_OPS_Block_Checkout_DeviceFingerprinting $block */
|
52 |
+
$block = Mage::app()->getLayout()->createBlock('ops/checkout_deviceFingerprinting');
|
53 |
+
|
54 |
+
$html = $block->toHtml();
|
55 |
+
$this->assertNotEmpty($html);
|
56 |
+
|
57 |
+
$url = $block->getConsentUrl();
|
58 |
+
$this->assertStringEndsWith('ops/device/', $url);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @test
|
63 |
+
* @loadFixture
|
64 |
+
*/
|
65 |
+
public function fingerPrintingDisabled()
|
66 |
+
{
|
67 |
+
/** @var Netresearch_OPS_Block_Checkout_DeviceFingerprinting $block */
|
68 |
+
$block = Mage::app()->getLayout()->createBlock('ops/checkout_deviceFingerprinting');
|
69 |
+
$html = $block->toHtml();
|
70 |
+
$this->assertEmpty($html);
|
71 |
+
|
72 |
+
$url = $block->getConsentUrl();
|
73 |
+
$this->assertStringEndsWith('ops/device/', $url);
|
74 |
+
}
|
75 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest/fixtures/fingerPrintingDisabled.yaml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
config:
|
2 |
+
default/dev/template/allow_symlink: 1
|
3 |
+
default/payment_services/ops/device_fingerprinting: 0
|
app/code/community/Netresearch/OPS/Test/Block/Checkout/DeviceFingerprintingTest/fixtures/fingerPrintingEnabled.yaml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
config:
|
2 |
+
default/dev/template/allow_symlink: 1
|
3 |
+
default/payment_services/ops/device_fingerprinting: 1
|
app/code/community/Netresearch/OPS/Test/Block/Form/CcTest.php
ADDED
@@ -0,0 +1,459 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_Form_CcTest extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
/** @var Netresearch_OPS_Block_Form_Cc $_block */
|
6 |
+
private $_block;
|
7 |
+
|
8 |
+
public function setUp()
|
9 |
+
{
|
10 |
+
parent::setup();
|
11 |
+
$this->_block = Mage::app()->getLayout()->getBlockSingleton('ops/form_cc');
|
12 |
+
$this->_block->setMethod(Mage::getModel('ops/payment_cc'));
|
13 |
+
$this->mockSessions();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function testGetAliasBrands()
|
17 |
+
{
|
18 |
+
|
19 |
+
$aliasBrands = array(
|
20 |
+
'American Express',
|
21 |
+
'Diners Club',
|
22 |
+
'MaestroUK',
|
23 |
+
'MasterCard',
|
24 |
+
'VISA',
|
25 |
+
);
|
26 |
+
|
27 |
+
$ccAliasInterfaceEnabledTypesMock = $this->getModelMock(
|
28 |
+
'ops/source_cc_aliasInterfaceEnabledTypes', array('getAliasInterfaceCompatibleTypes')
|
29 |
+
);
|
30 |
+
$ccAliasInterfaceEnabledTypesMock->expects($this->any())
|
31 |
+
->method('getAliasInterfaceCompatibleTypes')
|
32 |
+
->will($this->returnValue($aliasBrands));
|
33 |
+
$this->replaceByMock('model', 'ops/source_cc_aliasInterfaceEnabledTypes', $ccAliasInterfaceEnabledTypesMock);
|
34 |
+
/** @var Netresearch_OPS_Block_Form_Cc $ccForm */
|
35 |
+
$ccForm = Mage::app()->getLayout()->getBlockSingleton('ops/form_cc');
|
36 |
+
$ccAliases = $ccForm->getAliasBrands();
|
37 |
+
$this->assertEquals($aliasBrands, $ccAliases);
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
public function testTemplate()
|
42 |
+
{
|
43 |
+
//Frontend case
|
44 |
+
$modelMock = $this->getModelMock('ops/config', array('isFrontendEnvironment'));
|
45 |
+
$modelMock->expects($this->any())
|
46 |
+
->method('isFrontendEnvironment')
|
47 |
+
->will($this->returnValue(true));
|
48 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
49 |
+
$ccForm = new Netresearch_OPS_Block_Form_Cc();
|
50 |
+
$this->assertEquals(Netresearch_OPS_Block_Form_Cc::FRONTEND_TEMPLATE, $ccForm->getTemplate());
|
51 |
+
|
52 |
+
//Backend case
|
53 |
+
$modelMock = $this->getModelMock('ops/config', array('isFrontendEnvironment'));
|
54 |
+
$modelMock->expects($this->any())
|
55 |
+
->method('isFrontendEnvironment')
|
56 |
+
->will($this->returnValue(false));
|
57 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
58 |
+
$ccForm = new Netresearch_OPS_Block_Form_Cc();
|
59 |
+
$this->assertEquals(Netresearch_OPS_Block_Form_Cc::FRONTEND_TEMPLATE, $ccForm->getTemplate());
|
60 |
+
}
|
61 |
+
|
62 |
+
public function testGetCcBrands()
|
63 |
+
{
|
64 |
+
$blockMock = $this->getBlockMock('ops/form_cc', array('getMethod'));
|
65 |
+
$method = new Varien_Object();
|
66 |
+
$method->setCode('ops_cc');
|
67 |
+
$blockMock->expects($this->any())
|
68 |
+
->method('getMethod')
|
69 |
+
->will($this->returnValue($method));
|
70 |
+
$this->replaceByMock('block', 'ops/form_cc', $blockMock);
|
71 |
+
|
72 |
+
|
73 |
+
$this->assertInternalType('array', $blockMock->getCcBrands());
|
74 |
+
}
|
75 |
+
|
76 |
+
public function testIsAliasPMEnabled()
|
77 |
+
{
|
78 |
+
$model = Mage::getModel('ops/config');
|
79 |
+
$this->assertEquals(
|
80 |
+
$model->isAliasManagerEnabled('ops_cc'), $this->_block->isAliasPMEnabled()
|
81 |
+
);
|
82 |
+
}
|
83 |
+
|
84 |
+
public function testGetStoredAliasDataForCustomer()
|
85 |
+
{
|
86 |
+
|
87 |
+
$reflectionClass = new ReflectionClass(get_class($this->_block));
|
88 |
+
$method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
|
89 |
+
$method->setAccessible(true);
|
90 |
+
$this->assertNull($method->invoke($this->_block, 0, 'bla'));
|
91 |
+
|
92 |
+
$blockMock = $this->getBlockMock(
|
93 |
+
'ops/form_cc', array('getStoredAliasForCustomer')
|
94 |
+
);
|
95 |
+
$blockMock->expects($this->once())
|
96 |
+
->method('getStoredAliasForCustomer')
|
97 |
+
->will($this->returnValue(array()));
|
98 |
+
$reflectionClass = new ReflectionClass(get_class($blockMock));
|
99 |
+
$method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
|
100 |
+
$method->setAccessible(true);
|
101 |
+
$this->assertNull($method->invoke($blockMock, 0, 'bla'));
|
102 |
+
|
103 |
+
|
104 |
+
$blockMock = $this->getBlockMock(
|
105 |
+
'ops/form_cc', array('getStoredAliasForCustomer')
|
106 |
+
);
|
107 |
+
$blockMock->expects($this->once())
|
108 |
+
->method('getStoredAliasForCustomer')
|
109 |
+
->will($this->returnValue(array(0 => new Varien_Object(array('bla' => 'foo')))));
|
110 |
+
$reflectionClass = new ReflectionClass(get_class($blockMock));
|
111 |
+
$method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
|
112 |
+
$method->setAccessible(true);
|
113 |
+
$this->assertEquals(
|
114 |
+
'foo', $method->invoke($blockMock, 0, 'bla')
|
115 |
+
);
|
116 |
+
|
117 |
+
$blockMock = $this->getBlockMock(
|
118 |
+
'ops/form_cc', array('getStoredAliasForCustomer')
|
119 |
+
);
|
120 |
+
$blockMock->expects($this->once())
|
121 |
+
->method('getStoredAliasForCustomer')
|
122 |
+
->will($this->returnValue(array(0 => new Varien_Object(array('bla' => 'foo')))));
|
123 |
+
$reflectionClass = new ReflectionClass(get_class($blockMock));
|
124 |
+
$method = $reflectionClass->getMethod("getStoredAliasDataForCustomer");
|
125 |
+
$method->setAccessible(true);
|
126 |
+
$this->assertNull($method->invoke($blockMock, 0, 'foo'));
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
public function testGetAliasCardNumber()
|
131 |
+
{
|
132 |
+
$blockMock = $this->getBlockMock(
|
133 |
+
'ops/form_cc', array('getStoredAliasForCustomer')
|
134 |
+
);
|
135 |
+
$blockMock->expects($this->any())
|
136 |
+
->method('getStoredAliasForCustomer')
|
137 |
+
->will(
|
138 |
+
$this->returnValue(
|
139 |
+
array(
|
140 |
+
0 => new Varien_Object(
|
141 |
+
array(
|
142 |
+
'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
|
143 |
+
'brand' => 'visa'
|
144 |
+
)
|
145 |
+
)
|
146 |
+
)
|
147 |
+
)
|
148 |
+
);
|
149 |
+
$this->assertEquals('XXXX XXXX XXXX 1111', $blockMock->getAliasCardNumber(0));
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @loadFixture aliases.yaml
|
154 |
+
*/
|
155 |
+
public function testGetStoredAliasForCustomer()
|
156 |
+
{
|
157 |
+
|
158 |
+
$reflectionClass = new ReflectionClass(get_class($this->_block));
|
159 |
+
$method = $reflectionClass->getMethod("getStoredAliasForCustomer");
|
160 |
+
$method->setAccessible(true);
|
161 |
+
$this->assertEquals(0, count($method->invoke($this->_block)));
|
162 |
+
|
163 |
+
|
164 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
|
165 |
+
$configMock->expects($this->any())
|
166 |
+
->method('isAliasManagerEnabled')
|
167 |
+
->will($this->returnValue(true));
|
168 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
169 |
+
|
170 |
+
$aliases = Mage::getModel('ops/alias')
|
171 |
+
->getCollection()
|
172 |
+
->addFieldToFilter('customer_id', 1)
|
173 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
|
174 |
+
->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
|
175 |
+
$alias = $aliases->getFirstItem();
|
176 |
+
$aliasHelperMock = $this->getHelperMock('ops/alias', array('getAliasesForAddresses'));
|
177 |
+
$aliasHelperMock->expects($this->once())
|
178 |
+
->method('getAliasesForAddresses')
|
179 |
+
->will($this->returnValue($aliases));
|
180 |
+
$this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
|
181 |
+
|
182 |
+
$customerMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
|
183 |
+
$customerMock->expects($this->once())
|
184 |
+
->method('isLoggedIn')
|
185 |
+
->will($this->returnValue(true));
|
186 |
+
$this->replaceByMock('helper', 'customer/data', $customerMock);
|
187 |
+
|
188 |
+
$fakeCustomer = new Varien_Object();
|
189 |
+
$fakeCustomer->setId(1);
|
190 |
+
|
191 |
+
$fakeQuote = new Varien_Object();
|
192 |
+
$fakeQuote->setCustomer($fakeCustomer);
|
193 |
+
|
194 |
+
|
195 |
+
$blockMock = $this->getBlockMock('ops/form_cc', array('getQuote', 'getMethodCode'));
|
196 |
+
$blockMock->expects($this->once())
|
197 |
+
->method('getQuote')
|
198 |
+
->will($this->returnValue($fakeQuote));
|
199 |
+
$blockMock->expects($this->any())
|
200 |
+
->method('getMethodCode')
|
201 |
+
->will($this->returnValue('ops_cc'));
|
202 |
+
$this->replaceByMock('block', 'ops/form_cc', $blockMock);
|
203 |
+
|
204 |
+
$reflectionClass = new ReflectionClass(get_class($blockMock));
|
205 |
+
$method = $reflectionClass->getMethod("getStoredAliasForCustomer");
|
206 |
+
$method->setAccessible(true);
|
207 |
+
$aliases = $method->invoke($blockMock);
|
208 |
+
$this->assertEquals($alias->getData(), $aliases[1]->getData());
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
public function testGetExpirationDatePart()
|
214 |
+
{
|
215 |
+
$blockMock = $this->getBlockMock(
|
216 |
+
'ops/form_cc', array('getStoredAliasForCustomer')
|
217 |
+
);
|
218 |
+
$blockMock->expects($this->any())
|
219 |
+
->method('getStoredAliasForCustomer')
|
220 |
+
->will($this->returnValue(array(0 => new Varien_Object(array('expiration_date' => '0416')))));
|
221 |
+
$this->assertEquals('04', $blockMock->getExpirationDatePart(0, 'month'));
|
222 |
+
$this->assertEquals('16', $blockMock->getExpirationDatePart(0, 'year'));
|
223 |
+
}
|
224 |
+
|
225 |
+
public function testGetCardHolderName()
|
226 |
+
{
|
227 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
|
228 |
+
$configMock->expects($this->any())
|
229 |
+
->method('isAliasManagerEnabled')
|
230 |
+
->will($this->returnValue(false));
|
231 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
232 |
+
|
233 |
+
$this->assertNull($block = $this->_block->getCardHolderName(2));
|
234 |
+
|
235 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
|
236 |
+
$configMock->expects($this->any())
|
237 |
+
->method('isAliasManagerEnabled')
|
238 |
+
->will($this->returnValue(true));
|
239 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
240 |
+
|
241 |
+
|
242 |
+
$blockMock = $this->getBlockMock(
|
243 |
+
'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias')
|
244 |
+
);
|
245 |
+
|
246 |
+
$blockMock->expects($this->any())
|
247 |
+
->method('getStoredAliasDataForCustomer')
|
248 |
+
->will($this->returnValue('Hubertus von Fürstenberg'));
|
249 |
+
|
250 |
+
$blockMock->expects($this->any())
|
251 |
+
->method('getStoredAlias')
|
252 |
+
->will($this->returnValue('4711'));
|
253 |
+
$this->assertEquals('Hubertus von Fürstenberg', $blockMock->getCardHolderName(2));
|
254 |
+
|
255 |
+
$blockMock = $this->getBlockMock(
|
256 |
+
'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias', 'getMethodCode')
|
257 |
+
);
|
258 |
+
$blockMock->expects($this->any())
|
259 |
+
->method('getMethodCode')
|
260 |
+
->will($this->returnValue('ops_cc'));
|
261 |
+
$blockMock->expects($this->once())
|
262 |
+
->method('getStoredAliasDataForCustomer')
|
263 |
+
->will($this->returnValue(null));
|
264 |
+
|
265 |
+
$blockMock->expects($this->any())
|
266 |
+
->method('getStoredAlias')
|
267 |
+
->will($this->returnValue('4711'));
|
268 |
+
|
269 |
+
$customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn', 'getCustomerName'));
|
270 |
+
$customerHelperMock->expects($this->any())
|
271 |
+
->method('isLoggedIn')
|
272 |
+
->will($this->returnValue(true));
|
273 |
+
$customerHelperMock->expects($this->any())
|
274 |
+
->method('getCustomerName')
|
275 |
+
->will($this->returnValue('Hubertus zu Fürstenberg'));
|
276 |
+
$this->replaceByMock('helper', 'customer/data', $customerHelperMock);
|
277 |
+
|
278 |
+
|
279 |
+
$this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName(2));
|
280 |
+
|
281 |
+
$blockMock = $this->getBlockMock(
|
282 |
+
'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias', 'getMethodCode')
|
283 |
+
);
|
284 |
+
$blockMock->expects($this->any())
|
285 |
+
->method('getMethodCode')
|
286 |
+
->will($this->returnValue('ops_cc'));
|
287 |
+
$blockMock->expects($this->once())
|
288 |
+
->method('getStoredAliasDataForCustomer')
|
289 |
+
->will($this->returnValue(''));
|
290 |
+
|
291 |
+
$blockMock->expects($this->any())
|
292 |
+
->method('getStoredAlias')
|
293 |
+
->will($this->returnValue('4711'));
|
294 |
+
|
295 |
+
$this->assertEquals('Hubertus zu Fürstenberg', $blockMock->getCardHolderName(2));
|
296 |
+
|
297 |
+
$blockMock = $this->getBlockMock(
|
298 |
+
'ops/form_cc', array('getStoredAliasDataForCustomer', 'getStoredAlias')
|
299 |
+
);
|
300 |
+
$blockMock->expects($this->once())
|
301 |
+
->method('getStoredAliasDataForCustomer')
|
302 |
+
->will($this->returnValue(null));
|
303 |
+
|
304 |
+
$blockMock->expects($this->any())
|
305 |
+
->method('getStoredAlias')
|
306 |
+
->will($this->returnValue('4711'));
|
307 |
+
|
308 |
+
$customerHelperMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
|
309 |
+
$customerHelperMock->expects($this->any())
|
310 |
+
->method('isLoggedIn')
|
311 |
+
->will($this->returnValue(false));
|
312 |
+
$this->replaceByMock('helper', 'customer/data', $customerHelperMock);
|
313 |
+
|
314 |
+
$this->assertNull($blockMock->getCardHolderName(2));
|
315 |
+
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
public function testGetStoredAliasBrandWithInlineBrand()
|
320 |
+
{
|
321 |
+
/** @var Netresearch_OPS_Block_Form_Cc $blockMock */
|
322 |
+
|
323 |
+
$blockMock = $this->getBlockMock(
|
324 |
+
'ops/form_cc', array('getStoredAliasForCustomer', 'getMethodCode')
|
325 |
+
);
|
326 |
+
$blockMock->expects($this->any())
|
327 |
+
->method('getStoredAliasForCustomer')
|
328 |
+
->will(
|
329 |
+
$this->returnValue(
|
330 |
+
array(0 => new Varien_Object(
|
331 |
+
array(
|
332 |
+
'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
|
333 |
+
'brand' => 'VISA'
|
334 |
+
)
|
335 |
+
))
|
336 |
+
)
|
337 |
+
);
|
338 |
+
$blockMock->expects($this->any())
|
339 |
+
->method('getMethodCode')
|
340 |
+
->will($this->returnValue('ops_cc'));
|
341 |
+
|
342 |
+
$modelMock = $this->getModelMock(
|
343 |
+
'ops/config', array('getInlinePaymentCcTypes')
|
344 |
+
);
|
345 |
+
$modelMock->expects($this->any())
|
346 |
+
->method('getInlinePaymentCcTypes')
|
347 |
+
->will(
|
348 |
+
$this->returnValue(
|
349 |
+
array(
|
350 |
+
'VISA'
|
351 |
+
)
|
352 |
+
)
|
353 |
+
);
|
354 |
+
|
355 |
+
$this->assertEquals('VISA', $blockMock->getStoredAliasBrand(0));
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
public function testGetStoredAliasBrandWithNonInlineBrand()
|
360 |
+
{
|
361 |
+
/** @var Netresearch_OPS_Block_Form_Cc $blockMock */
|
362 |
+
|
363 |
+
$blockMock = $this->getBlockMock(
|
364 |
+
'ops/form_cc', array('getStoredAliasForCustomer', 'getMethodCode')
|
365 |
+
);
|
366 |
+
$blockMock->expects($this->any())
|
367 |
+
->method('getStoredAliasForCustomer')
|
368 |
+
->will(
|
369 |
+
$this->returnValue(
|
370 |
+
array(new Varien_Object(
|
371 |
+
array(
|
372 |
+
'pseudo_account_or_cc_no' => 'xxxxxxxxxxxx1111',
|
373 |
+
'brand' => 'VISA'
|
374 |
+
)
|
375 |
+
))
|
376 |
+
)
|
377 |
+
);
|
378 |
+
$blockMock->expects($this->any())
|
379 |
+
->method('getMethodCode')
|
380 |
+
->will($this->returnValue('ops_cc'));
|
381 |
+
|
382 |
+
$modelMock = $this->getModelMock(
|
383 |
+
'ops/config', array('getInlinePaymentCcTypes')
|
384 |
+
);
|
385 |
+
$modelMock->expects($this->any())
|
386 |
+
->method('getInlinePaymentCcTypes')
|
387 |
+
->will(
|
388 |
+
$this->returnValue(
|
389 |
+
array(
|
390 |
+
'FOO'
|
391 |
+
)
|
392 |
+
)
|
393 |
+
);
|
394 |
+
|
395 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
396 |
+
|
397 |
+
$this->assertEquals('', $blockMock->getStoredAliasBrand(0));
|
398 |
+
}
|
399 |
+
|
400 |
+
public function testIsAliasInfoBlockEnabled()
|
401 |
+
{
|
402 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
|
403 |
+
$configMock->expects($this->any())
|
404 |
+
->method('isAliasPMEnabled')
|
405 |
+
->will($this->returnValue(false));
|
406 |
+
$configMock->expects($this->any())
|
407 |
+
->method('isAliasInfoBlockEnabled')
|
408 |
+
->will($this->returnValue(false));
|
409 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
410 |
+
|
411 |
+
$this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
|
412 |
+
|
413 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
|
414 |
+
$configMock->expects($this->any())
|
415 |
+
->method('isAliasPMEnabled')
|
416 |
+
->will($this->returnValue(false));
|
417 |
+
$configMock->expects($this->any())
|
418 |
+
->method('isAliasInfoBlockEnabled')
|
419 |
+
->will($this->returnValue(true));
|
420 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
421 |
+
|
422 |
+
$this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
|
423 |
+
|
424 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
|
425 |
+
$configMock->expects($this->any())
|
426 |
+
->method('isAliasPMEnabled')
|
427 |
+
->will($this->returnValue(true));
|
428 |
+
$configMock->expects($this->any())
|
429 |
+
->method('isAliasInfoBlockEnabled')
|
430 |
+
->will($this->returnValue(false));
|
431 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
432 |
+
|
433 |
+
$this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
|
434 |
+
|
435 |
+
$configMock = $this->getModelMock('ops/config', array('isAliasPMEnabled', 'isAliasInfoBlockEnabled'));
|
436 |
+
$configMock->expects($this->any())
|
437 |
+
->method('isAliasPMEnabled')
|
438 |
+
->will($this->returnValue(true));
|
439 |
+
$configMock->expects($this->any())
|
440 |
+
->method('isAliasInfoBlockEnabled')
|
441 |
+
->will($this->returnValue(true));
|
442 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
443 |
+
|
444 |
+
$this->assertFalse(Mage::app()->getLayout()->getBlockSingleton('ops/form_cc')->isAliasInfoBlockEnabled());
|
445 |
+
}
|
446 |
+
|
447 |
+
protected function mockSessions()
|
448 |
+
{
|
449 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
450 |
+
->disableOriginalConstructor()// This one removes session_start and other methods usage
|
451 |
+
->getMock();
|
452 |
+
$this->replaceByMock('singleton', 'core/session', $sessionMock);
|
453 |
+
|
454 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
455 |
+
->disableOriginalConstructor()// This one removes session_start and other methods usage
|
456 |
+
->getMock();
|
457 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
458 |
+
}
|
459 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/CcTest/fixtures/aliases.yaml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
ops/alias:
|
3 |
+
- id: 1
|
4 |
+
customer_id: 1
|
5 |
+
alias: 4711
|
6 |
+
brand: 'VISA'
|
7 |
+
billing_address_hash: '0815'
|
8 |
+
shipping_address_hash: '2342'
|
9 |
+
pseudo_account_or_cc_no: 'xxxx1111'
|
10 |
+
expiration_date: '0116'
|
11 |
+
payment_method: 'ops_cd'
|
12 |
+
state: 'active'
|
13 |
+
store_id: 0
|
14 |
+
created_at: '2000-01-01 00:00:01'
|
15 |
+
|
16 |
+
- id: 2
|
17 |
+
customer_id: 1
|
18 |
+
alias: 4712
|
19 |
+
brand: 'VISA'
|
20 |
+
billing_address_hash: '0816'
|
21 |
+
shipping_address_hash: '2342'
|
22 |
+
pseudo_account_or_cc_no: 'xxxx1112'
|
23 |
+
expiration_date: '0116'
|
24 |
+
payment_method: 'ops_cc'
|
25 |
+
state: 'active'
|
26 |
+
store_id: 0
|
27 |
+
created_at: '1970-01-01 00:00:01'
|
28 |
+
|
29 |
+
- id: 3
|
30 |
+
customer_id: 1
|
31 |
+
alias: 4713
|
32 |
+
brand: 'VISA'
|
33 |
+
billing_address_hash: '0817'
|
34 |
+
shipping_address_hash: '0817'
|
35 |
+
pseudo_account_or_cc_no: 'xxxx1113'
|
36 |
+
expiration_date: '0116'
|
37 |
+
payment_method: 'ops_cc'
|
38 |
+
state: 'pending'
|
39 |
+
store_id: 0
|
40 |
+
created_at: '1970-01-01 00:00:02'
|
41 |
+
|
42 |
+
- id: 4
|
43 |
+
customer_id: 2
|
44 |
+
alias: 4711
|
45 |
+
brand: 'VISA'
|
46 |
+
billing_address_hash: '1508'
|
47 |
+
shipping_address_hash: '4223'
|
48 |
+
pseudo_account_or_cc_no: 'xxxx1111'
|
49 |
+
expiration_date: '0117'
|
50 |
+
payment_method: 'ops_cc'
|
51 |
+
state: 'active'
|
52 |
+
store_id: 0
|
53 |
+
created_at: '1970-01-01 00:00:02'
|
54 |
+
|
55 |
+
- id: 5
|
56 |
+
customer_id: 1
|
57 |
+
alias: 4711
|
58 |
+
brand: 'VISA'
|
59 |
+
billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
60 |
+
shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
61 |
+
pseudo_account_or_cc_no: 'xxxx1111'
|
62 |
+
expiration_date: '0117'
|
63 |
+
payment_method: 'ops_cc'
|
64 |
+
state: 'active'
|
65 |
+
store_id: 0
|
66 |
+
created_at: '1970-01-01 00:00:02'
|
67 |
+
|
68 |
+
- id: 6
|
69 |
+
customer_id: 1
|
70 |
+
alias: 4714
|
71 |
+
brand: 'VISA'
|
72 |
+
billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
73 |
+
shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
74 |
+
pseudo_account_or_cc_no: 'xxxx1111'
|
75 |
+
expiration_date: '0116'
|
76 |
+
payment_method: 'ops_cd'
|
77 |
+
state: 'pending'
|
78 |
+
store_id: 0
|
79 |
+
created_at: '2000-11-01 00:00:01'
|
80 |
+
|
81 |
+
- id: 7
|
82 |
+
customer_id: 23
|
83 |
+
alias: 4714
|
84 |
+
brand: 'VISA'
|
85 |
+
billing_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
86 |
+
shipping_address_hash: '1b9ecdf409e240717f04b7155712658ab09116bb'
|
87 |
+
pseudo_account_or_cc_no: 'xxxx1111'
|
88 |
+
expiration_date: '0116'
|
89 |
+
payment_method: 'ops_cd'
|
90 |
+
state: 'active'
|
91 |
+
store_id: 0
|
92 |
+
created_at: '2000-11-01 00:00:01'
|
app/code/community/Netresearch/OPS/Test/Block/Form/DirectDebitTest.php
ADDED
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_Form_DirectDebitTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case
|
5 |
+
{
|
6 |
+
public function testTemplate()
|
7 |
+
{
|
8 |
+
//Frontend case
|
9 |
+
$modelMock = $this->getModelMock(
|
10 |
+
'ops/config', array('isFrontendEnvironment')
|
11 |
+
);
|
12 |
+
$modelMock->expects($this->any())
|
13 |
+
->method('isFrontendEnvironment')
|
14 |
+
->will($this->returnValue(true));
|
15 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
16 |
+
$ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
|
17 |
+
$this->assertEquals(
|
18 |
+
Netresearch_OPS_Block_Form_DirectDebit::TEMPLATE,
|
19 |
+
$ccForm->getTemplate()
|
20 |
+
);
|
21 |
+
|
22 |
+
//Backend case
|
23 |
+
$modelMock = $this->getModelMock(
|
24 |
+
'ops/config', array('isFrontendEnvironment')
|
25 |
+
);
|
26 |
+
$modelMock->expects($this->any())
|
27 |
+
->method('isFrontendEnvironment')
|
28 |
+
->will($this->returnValue(false));
|
29 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
30 |
+
$ccForm = new Netresearch_OPS_Block_Form_DirectDebit();
|
31 |
+
$this->assertEquals(
|
32 |
+
Netresearch_OPS_Block_Form_DirectDebit::TEMPLATE,
|
33 |
+
$ccForm->getTemplate()
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function testDirectDebitCountryIds()
|
38 |
+
{
|
39 |
+
$fakeConfig = new Varien_Object();
|
40 |
+
$fakeConfig->setDirectDebitCountryIds("AT, DE, NL");
|
41 |
+
$blockMock = $this->getBlockMock(
|
42 |
+
'ops/form_directDebit', array('getconfig')
|
43 |
+
);
|
44 |
+
$blockMock->expects($this->once())
|
45 |
+
->method('getConfig')
|
46 |
+
->will($this->returnValue($fakeConfig));
|
47 |
+
$this->assertEquals(
|
48 |
+
explode(',', 'AT, DE, NL'), $blockMock->getDirectDebitCountryIds()
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
public function testGetParams()
|
53 |
+
{
|
54 |
+
$sessionMock = $this->getModelMock(
|
55 |
+
'adminhtml/session', array('init', 'save')
|
56 |
+
);
|
57 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
58 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
59 |
+
$expectedResult = array(
|
60 |
+
'country' => '',
|
61 |
+
'CN' => '',
|
62 |
+
'iban' => '',
|
63 |
+
'bic' => '',
|
64 |
+
'account' => '',
|
65 |
+
'bankcode' => ''
|
66 |
+
);
|
67 |
+
$this->assertEquals($expectedResult, $block->getParams());
|
68 |
+
$newParams = array('bla' => 'foo');
|
69 |
+
$sessionMock->setData(
|
70 |
+
'ops_direct_debit_params', $newParams
|
71 |
+
);
|
72 |
+
$result = $block->getParams();
|
73 |
+
$this->assertFalse($sessionMock->hasData('ops_direct_debit_params'));
|
74 |
+
$this->assertEquals($newParams, $result);
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
public function testIsIbanFieldRequired()
|
79 |
+
{
|
80 |
+
$sessionMock = $this->getModelMock(
|
81 |
+
'adminhtml/session', array('init', 'save')
|
82 |
+
);
|
83 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
84 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
85 |
+
$this->assertTrue($block->isIbanFieldRequired());
|
86 |
+
$newParams = array('iban' => 'foo');
|
87 |
+
$sessionMock->setData(
|
88 |
+
'ops_direct_debit_params', $newParams
|
89 |
+
);
|
90 |
+
$block->getParams();
|
91 |
+
$this->assertTrue($block->isIbanFieldRequired());
|
92 |
+
$newParams = array('account' => '');
|
93 |
+
$sessionMock->setData(
|
94 |
+
'ops_direct_debit_params', $newParams
|
95 |
+
);
|
96 |
+
$block->getParams();
|
97 |
+
$this->assertTrue($block->isIbanFieldRequired());
|
98 |
+
|
99 |
+
$newParams = array('account' => '123456');
|
100 |
+
$sessionMock->setData(
|
101 |
+
'ops_direct_debit_params', $newParams
|
102 |
+
);
|
103 |
+
$block->getParams();
|
104 |
+
$this->assertFalse($block->isIbanFieldRequired());
|
105 |
+
}
|
106 |
+
|
107 |
+
public function testIsAccountFieldRequired()
|
108 |
+
{
|
109 |
+
$sessionMock = $this->getModelMock(
|
110 |
+
'adminhtml/session', array('init', 'save')
|
111 |
+
);
|
112 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
113 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
114 |
+
$this->assertTrue($block->isAccountFieldRequired());
|
115 |
+
$newParams = array('account' => 'foo');
|
116 |
+
$sessionMock->setData(
|
117 |
+
'ops_direct_debit_params', $newParams
|
118 |
+
);
|
119 |
+
$block->getParams();
|
120 |
+
$this->assertTrue($block->isAccountFieldRequired());
|
121 |
+
$newParams = array('account' => '');
|
122 |
+
$sessionMock->setData(
|
123 |
+
'ops_direct_debit_params', $newParams
|
124 |
+
);
|
125 |
+
$block->getParams();
|
126 |
+
$this->assertTrue($block->isAccountFieldRequired());
|
127 |
+
|
128 |
+
$newParams = array('account' => '123456', 'iban' => '');
|
129 |
+
$sessionMock->setData(
|
130 |
+
'ops_direct_debit_params', $newParams
|
131 |
+
);
|
132 |
+
$block->getParams();
|
133 |
+
$this->assertTrue($block->isAccountFieldRequired());
|
134 |
+
|
135 |
+
$newParams = array('account' => '123456', 'iban' => '123456');
|
136 |
+
$sessionMock->setData(
|
137 |
+
'ops_direct_debit_params', $newParams
|
138 |
+
);
|
139 |
+
$block->getParams();
|
140 |
+
$this->assertFalse($block->isAccountFieldRequired());
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
public function testIsBankCodeFieldRequired()
|
145 |
+
{
|
146 |
+
$sessionMock = $this->getModelMock(
|
147 |
+
'adminhtml/session', array('init', 'save')
|
148 |
+
);
|
149 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
150 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
151 |
+
$this->assertFalse($block->isBankCodeFieldRequired());
|
152 |
+
|
153 |
+
$newParams = array('account' => '12345');
|
154 |
+
$sessionMock->setData(
|
155 |
+
'ops_direct_debit_params', $newParams
|
156 |
+
);
|
157 |
+
$block->getParams();
|
158 |
+
$this->assertFalse($block->isBankCodeFieldRequired());
|
159 |
+
|
160 |
+
$newParams = array('account' => '123456', 'country' => 'de');
|
161 |
+
$sessionMock->setData(
|
162 |
+
'ops_direct_debit_params', $newParams
|
163 |
+
);
|
164 |
+
$block->getParams();
|
165 |
+
$this->assertTrue($block->isBankCodeFieldRequired());
|
166 |
+
}
|
167 |
+
|
168 |
+
public function testIsBankCodeFieldVisible()
|
169 |
+
{
|
170 |
+
$sessionMock = $this->getModelMock(
|
171 |
+
'adminhtml/session', array('init', 'save')
|
172 |
+
);
|
173 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
174 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
175 |
+
$this->assertFalse($block->isBankCodeFieldVisible());
|
176 |
+
$newParams = array('country' => 'at');
|
177 |
+
$sessionMock->setData(
|
178 |
+
'ops_direct_debit_params', $newParams
|
179 |
+
);
|
180 |
+
$block->getParams();
|
181 |
+
$this->assertTrue($block->isBankCodeFieldVisible());
|
182 |
+
|
183 |
+
$newParams = array('country' => 'de');
|
184 |
+
$sessionMock->setData(
|
185 |
+
'ops_direct_debit_params', $newParams
|
186 |
+
);
|
187 |
+
$block->getParams();
|
188 |
+
$this->assertTrue($block->isBankCodeFieldVisible());
|
189 |
+
|
190 |
+
$newParams = array('country' => 'nl');
|
191 |
+
$sessionMock->setData(
|
192 |
+
'ops_direct_debit_params', $newParams
|
193 |
+
);
|
194 |
+
$block->getParams();
|
195 |
+
$this->assertFalse($block->isBankCodeFieldVisible());
|
196 |
+
}
|
197 |
+
|
198 |
+
public function testIsBicFieldVisible()
|
199 |
+
{
|
200 |
+
$sessionMock = $this->getModelMock(
|
201 |
+
'adminhtml/session', array('init', 'save')
|
202 |
+
);
|
203 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
204 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
205 |
+
$this->assertFalse($block->isBicFieldVisible());
|
206 |
+
|
207 |
+
$newParams = array('country' => 'de');
|
208 |
+
$sessionMock->setData(
|
209 |
+
'ops_direct_debit_params', $newParams
|
210 |
+
);
|
211 |
+
$block->getParams();
|
212 |
+
$this->assertFalse($block->isBicFieldVisible());
|
213 |
+
|
214 |
+
$newParams = array('country' => 'at');
|
215 |
+
$sessionMock->setData(
|
216 |
+
'ops_direct_debit_params', $newParams
|
217 |
+
);
|
218 |
+
$block->getParams();
|
219 |
+
$this->assertFalse($block->isBicFieldVisible());
|
220 |
+
|
221 |
+
$newParams = array('country' => 'nl');
|
222 |
+
$sessionMock->setData(
|
223 |
+
'ops_direct_debit_params', $newParams
|
224 |
+
);
|
225 |
+
$block->getParams();
|
226 |
+
$this->assertTrue($block->isBicFieldVisible());
|
227 |
+
}
|
228 |
+
|
229 |
+
public function testGetCountry()
|
230 |
+
{
|
231 |
+
$sessionMock = $this->getModelMock(
|
232 |
+
'adminhtml/session', array('init', 'save')
|
233 |
+
);
|
234 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
235 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
236 |
+
$this->assertEquals('', $block->getCountry());
|
237 |
+
$newParams = array('country' => 'de');
|
238 |
+
$sessionMock->setData(
|
239 |
+
'ops_direct_debit_params', $newParams
|
240 |
+
);
|
241 |
+
$block->getParams();
|
242 |
+
$this->assertEquals('de', $block->getCountry());
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
public function testGetIban()
|
247 |
+
{
|
248 |
+
$sessionMock = $this->getModelMock(
|
249 |
+
'adminhtml/session', array('init', 'save')
|
250 |
+
);
|
251 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
252 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
253 |
+
$this->assertEquals('', $block->getIban());
|
254 |
+
$newParams = array('iban' => '1234567');
|
255 |
+
$sessionMock->setData(
|
256 |
+
'ops_direct_debit_params', $newParams
|
257 |
+
);
|
258 |
+
$block->getParams();
|
259 |
+
$this->assertEquals('1234567', $block->getIban());
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
public function testGetBic()
|
264 |
+
{
|
265 |
+
$sessionMock = $this->getModelMock(
|
266 |
+
'adminhtml/session', array('init', 'save')
|
267 |
+
);
|
268 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
269 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
270 |
+
$this->assertEquals('', $block->getBic());
|
271 |
+
$newParams = array('bic' => '1234567');
|
272 |
+
$sessionMock->setData(
|
273 |
+
'ops_direct_debit_params', $newParams
|
274 |
+
);
|
275 |
+
$block->getParams();
|
276 |
+
$this->assertEquals('1234567', $block->getBic());
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
public function testGetAccount()
|
281 |
+
{
|
282 |
+
$sessionMock = $this->getModelMock(
|
283 |
+
'adminhtml/session', array('init', 'save')
|
284 |
+
);
|
285 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
286 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
287 |
+
$this->assertEquals('', $block->getAccount());
|
288 |
+
$newParams = array('account' => '1234567');
|
289 |
+
$sessionMock->setData(
|
290 |
+
'ops_direct_debit_params', $newParams
|
291 |
+
);
|
292 |
+
$block->getParams();
|
293 |
+
$this->assertEquals('1234567', $block->getAccount());
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
public function testGetBankcode()
|
298 |
+
{
|
299 |
+
$sessionMock = $this->getModelMock(
|
300 |
+
'adminhtml/session', array('init', 'save')
|
301 |
+
);
|
302 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
303 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
304 |
+
$this->assertEquals('', $block->getBankcode());
|
305 |
+
$newParams = array('bankcode' => '1234567');
|
306 |
+
$sessionMock->setData(
|
307 |
+
'ops_direct_debit_params', $newParams
|
308 |
+
);
|
309 |
+
$block->getParams();
|
310 |
+
$this->assertEquals('1234567', $block->getBankcode());
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
public function testGetCardholderName()
|
315 |
+
{
|
316 |
+
$sessionMock = $this->getModelMock(
|
317 |
+
'adminhtml/session', array('init', 'save')
|
318 |
+
);
|
319 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
320 |
+
$block = new Netresearch_OPS_Block_Form_DirectDebit();
|
321 |
+
$this->assertEquals('', $block->getCardholderName());
|
322 |
+
$newParams = array('CN' => 'Hans wurst');
|
323 |
+
$sessionMock->setData(
|
324 |
+
'ops_direct_debit_params', $newParams
|
325 |
+
);
|
326 |
+
$block->getParams();
|
327 |
+
$this->assertEquals('Hans wurst', $block->getCardholderName());
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/Field/MethodTest.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* MethodTest.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Block_Form_Field_MethodTest extends EcomDev_PHPUnit_Test_Case
|
34 |
+
{
|
35 |
+
public function testBlockConstruction()
|
36 |
+
{
|
37 |
+
/** @var Netresearch_OPS_Block_System_Config_Form_Field_Method $block */
|
38 |
+
$block = Mage::app()->getLayout()->createBlock('ops/system_config_form_field_method');
|
39 |
+
$this->assertTrue($block instanceof Netresearch_OPS_Block_System_Config_Form_Field_Method);
|
40 |
+
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/FlexTest.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* FlexTest.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Block_Form_FlexTest extends EcomDev_PHPUnit_Test_Case
|
34 |
+
{
|
35 |
+
public function testGetFlexMethods()
|
36 |
+
{
|
37 |
+
Mage::app()->setCurrentStore(0);
|
38 |
+
Mage::getConfig()->saveConfig('payment/ops_flex/methods', serialize($this->getMethodArray()));
|
39 |
+
|
40 |
+
/** @var Netresearch_OPS_Block_Form_Flex $block */
|
41 |
+
$block = Mage::app()->getLayout()->createBlock('ops/form_flex');
|
42 |
+
|
43 |
+
$block->setMethod(Mage::getModel('ops/payment_flex'));
|
44 |
+
|
45 |
+
$this->assertTrue(is_array($block->getFlexMethods()));
|
46 |
+
$this->assertEquals(1, count($block->getFlexMethods()));
|
47 |
+
}
|
48 |
+
|
49 |
+
private function getMethodArray()
|
50 |
+
{
|
51 |
+
return array(
|
52 |
+
array(
|
53 |
+
'title' => 'foo',
|
54 |
+
'brand' => 'bar',
|
55 |
+
'pm' => 'zzz'
|
56 |
+
)
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
public function testGetDefaultOptionTitle()
|
62 |
+
{
|
63 |
+
Mage::app()->setCurrentStore(0);
|
64 |
+
Mage::getConfig()->saveConfig('payment/ops_flex/default_title', 'flex');
|
65 |
+
Mage::getConfig()->cleanCache();
|
66 |
+
|
67 |
+
/** @var Netresearch_OPS_Block_Form_Flex $block */
|
68 |
+
$block = Mage::app()->getLayout()->createBlock('ops/form_flex');
|
69 |
+
|
70 |
+
$block->setMethod(Mage::getModel('ops/payment_flex'));
|
71 |
+
|
72 |
+
$this->assertEquals('flex', $block->getDefaultOptionTitle());
|
73 |
+
}
|
74 |
+
|
75 |
+
public function testIsDefaultOptionActive()
|
76 |
+
{
|
77 |
+
Mage::app()->setCurrentStore(0);
|
78 |
+
Mage::getConfig()->saveConfig('payment/ops_flex/default', true);
|
79 |
+
Mage::getConfig()->cleanCache();
|
80 |
+
|
81 |
+
/** @var Netresearch_OPS_Block_Form_Flex $block */
|
82 |
+
$block = Mage::app()->getLayout()->createBlock('ops/form_flex');
|
83 |
+
|
84 |
+
$block->setMethod(Mage::getModel('ops/payment_flex'));
|
85 |
+
|
86 |
+
$this->assertTrue($block->isDefaultOptionActive());
|
87 |
+
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/Ideal.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_Form_Ideal extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
public function testGetIssuers()
|
6 |
+
{
|
7 |
+
$issuers = Mage::getModel('ops/payment_iDeal')->getIDealIssuers();
|
8 |
+
$block = Mage::app()->getLayout()->createBlock('ops/form_Ideal');
|
9 |
+
$this->assertEquals($issuers,$block->getIssuers());
|
10 |
+
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/InterSolveTest.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* InterSolveTest.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Block_Form_InterSolveTest extends EcomDev_PHPUnit_Test_Case
|
34 |
+
{
|
35 |
+
public function testGetInterSolveBrands()
|
36 |
+
{
|
37 |
+
Mage::getConfig()->saveConfig(
|
38 |
+
'payment/ops_interSolve/brands', serialize($this->getBrandArray())
|
39 |
+
);
|
40 |
+
Mage::getConfig()->cleanCache();
|
41 |
+
|
42 |
+
$block = Mage::app()->getLayout()->createBlock('ops/form_interSolve');
|
43 |
+
$this->assertEquals($this->getBrandArray(), $block->getInterSolveBrands());
|
44 |
+
}
|
45 |
+
|
46 |
+
private function getBrandArray()
|
47 |
+
{
|
48 |
+
return array(
|
49 |
+
array('brand' => 'foo', 'title' => 'bar')
|
50 |
+
);
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/ApresReceptionTest.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Test_Block_Form_Kwixo_ApresReceptionTest extends EcomDev_PHPUnit_Test_Case
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $block = null;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->block = new Netresearch_OPS_Block_Form_Kwixo_ApresReception();
|
18 |
+
}
|
19 |
+
|
20 |
+
public function testGetTemplate()
|
21 |
+
{
|
22 |
+
$this->assertEquals('ops/form/kwixo/apres_reception.phtml', $this->block->getTemplate());
|
23 |
+
}
|
24 |
+
|
25 |
+
public function testGetPmLogo()
|
26 |
+
{
|
27 |
+
$this->assertEquals('images/ops/kwixo/apres_reception.jpg', $this->block->getPmLogo());
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/ComptantTest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Test_Block_Form_Kwixo_ComptantTest extends EcomDev_PHPUnit_Test_Case
|
12 |
+
{
|
13 |
+
protected $block = null;
|
14 |
+
|
15 |
+
public function setUp()
|
16 |
+
{
|
17 |
+
$this->block = new Netresearch_OPS_Block_Form_Kwixo_Comptant();
|
18 |
+
}
|
19 |
+
|
20 |
+
public function testGetTemplate()
|
21 |
+
{
|
22 |
+
$this->assertEquals('ops/form/kwixo/comptant.phtml', $this->block->getTemplate());
|
23 |
+
}
|
24 |
+
|
25 |
+
public function testGetPmLogo()
|
26 |
+
{
|
27 |
+
$this->assertEquals('images/ops/kwixo/comptant.jpg', $this->block->getPmLogo());
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Form/Kwixo/CreditTest.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
class Netresearch_OPS_Test_Block_Form_Kwixo_CreditTest extends EcomDev_PHPUnit_Test_Case
|
14 |
+
{
|
15 |
+
|
16 |
+
protected $block = null;
|
17 |
+
|
18 |
+
public function setUp()
|
19 |
+
{
|
20 |
+
$this->block = new Netresearch_OPS_Block_Form_Kwixo_Credit();
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testGetTemplate()
|
24 |
+
{
|
25 |
+
$block = new Netresearch_OPS_Block_Form_Kwixo_Credit();
|
26 |
+
$this->assertEquals('ops/form/kwixo/credit.phtml', $block->getTemplate());
|
27 |
+
}
|
28 |
+
|
29 |
+
public function testGetPmLogo()
|
30 |
+
{
|
31 |
+
$this->assertEquals('images/ops/kwixo/credit.jpg', $this->block->getPmLogo());
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/FormTest.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_FormTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
5 |
+
{
|
6 |
+
private $_block;
|
7 |
+
|
8 |
+
public function setUp()
|
9 |
+
{
|
10 |
+
parent::setup();
|
11 |
+
$this->_block = Mage::app()->getLayout()->getBlockSingleton('ops/form');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function testIsUserRegistering()
|
15 |
+
{
|
16 |
+
$dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsRegistering'));
|
17 |
+
$dataHelperMock->expects($this->any())
|
18 |
+
->method('checkIfUserIsRegistering')
|
19 |
+
->will($this->returnValue(false));
|
20 |
+
$this->replaceByMock('helper', 'ops/data', $dataHelperMock);
|
21 |
+
|
22 |
+
$block = new Netresearch_OPS_Block_Form();
|
23 |
+
$this->assertFalse($block->isUserRegistering());
|
24 |
+
}
|
25 |
+
|
26 |
+
public function testIsUserNotRegistering()
|
27 |
+
{
|
28 |
+
$dataHelperMock = $this->getHelperMock('ops/data', array('checkIfUserIsNotRegistering'));
|
29 |
+
$dataHelperMock->expects($this->any())
|
30 |
+
->method('checkIfUserIsNotRegistering')
|
31 |
+
->will($this->returnValue(false));
|
32 |
+
$this->replaceByMock('helper', 'ops/data', $dataHelperMock);
|
33 |
+
|
34 |
+
$block = new Netresearch_OPS_Block_Form();
|
35 |
+
$this->assertFalse($block->isUserNotRegistering());
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
public function testGetPmLogo()
|
40 |
+
{
|
41 |
+
$this->assertEquals(null, $this->_block->getPmLogo());
|
42 |
+
}
|
43 |
+
|
44 |
+
public function testGetFrontendValidatorsAreEmtpyWhenNoExtraParamtersAreSubmitted()
|
45 |
+
{
|
46 |
+
$quoteMock = Mage::getModel('sales/quote');
|
47 |
+
$quoteMock->setStoreId(0);
|
48 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
49 |
+
->disableOriginalConstructor()// This one removes session_start and other methods usage
|
50 |
+
->setMethods(array('getQuote'))
|
51 |
+
->getMock();
|
52 |
+
$sessionMock->expects($this->any())
|
53 |
+
->method('getQuote')
|
54 |
+
->will($this->returnValue($quoteMock));
|
55 |
+
$this->replaceByMock('singleton', 'checkout/session', $sessionMock);
|
56 |
+
|
57 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
58 |
+
$configMock->expects($this->once())
|
59 |
+
->method('canSubmitExtraParameter')
|
60 |
+
->will($this->returnValue(false));
|
61 |
+
$this->_block->setConfig($configMock);
|
62 |
+
$this->_block->setQuote($quoteMock);
|
63 |
+
$this->assertEquals(Mage::helper('core/data')->jsonEncode(array()), $this->_block->getFrontendValidators());
|
64 |
+
}
|
65 |
+
|
66 |
+
public function testGetFrontendValidatorsAreEmptyDueToEmptyValidators()
|
67 |
+
{
|
68 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter', 'getParameterLengths'));
|
69 |
+
$configMock->expects($this->once())
|
70 |
+
->method('canSubmitExtraParameter')
|
71 |
+
->will($this->returnValue(true));
|
72 |
+
$configMock->expects($this->once())
|
73 |
+
->method('getParameterLengths')
|
74 |
+
->will($this->returnValue(array()));
|
75 |
+
|
76 |
+
$quote = Mage::getModel('sales/quote');
|
77 |
+
$blockMock = $this->getBlockMock('ops/form', array('getQuote'));
|
78 |
+
$blockMock->expects($this->any())
|
79 |
+
->method('getQuote')
|
80 |
+
->will($this->returnValue($quote));
|
81 |
+
$blockMock->setConfig($configMock);
|
82 |
+
$this->assertEquals(Mage::helper('core/data')->jsonEncode(array()), $blockMock->getFrontendValidators());
|
83 |
+
}
|
84 |
+
|
85 |
+
public function testGetFrontendValidatorsAreEmptyDueToUnmappedValidators()
|
86 |
+
{
|
87 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter', 'getParameterLengths'));
|
88 |
+
$configMock->expects($this->once())
|
89 |
+
->method('canSubmitExtraParameter')
|
90 |
+
->will($this->returnValue(true));
|
91 |
+
$configMock->expects($this->once())
|
92 |
+
->method('getParameterLengths')
|
93 |
+
->will($this->returnValue(array('Foo' => 50)));
|
94 |
+
|
95 |
+
$quote = Mage::getModel('sales/quote');
|
96 |
+
$blockMock = $this->getBlockMock('ops/form', array('getQuote'));
|
97 |
+
$blockMock->expects($this->any())
|
98 |
+
->method('getQuote')
|
99 |
+
->will($this->returnValue($quote));
|
100 |
+
$blockMock->setConfig($configMock);
|
101 |
+
$this->assertEquals(Mage::helper('core/data')->jsonEncode(array()), $blockMock->getFrontendValidators());
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
public function testGetFrontendValidatorsAreNotEmpty()
|
106 |
+
{
|
107 |
+
|
108 |
+
$configValues = array('CN' => 50, 'ECOM_BILLTO_POSTAL_POSTALCODE' => 10, 'ECOM_SHIPTO_POSTAL_POSTALCODE' => 10);
|
109 |
+
|
110 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter', 'getParameterLengths'));
|
111 |
+
$configMock->expects($this->once())
|
112 |
+
->method('canSubmitExtraParameter')
|
113 |
+
->will($this->returnValue(true));
|
114 |
+
$configMock->expects($this->once())
|
115 |
+
->method('getParameterLengths')
|
116 |
+
->will($this->returnValue($configValues));
|
117 |
+
|
118 |
+
$quote = Mage::getModel('sales/quote');
|
119 |
+
$blockMock = $this->getBlockMock('ops/form', array('getQuote'));
|
120 |
+
$blockMock->expects($this->any())
|
121 |
+
->method('getQuote')
|
122 |
+
->will($this->returnValue($quote));
|
123 |
+
$blockMock->setConfig($configMock);
|
124 |
+
$this->assertEquals(
|
125 |
+
Mage::helper('core/data')->jsonEncode(
|
126 |
+
array(
|
127 |
+
'billing:firstname' => 50, 'billing:lastname' => 50, 'billing:postcode' => 10,
|
128 |
+
'shipping:postcode' => 10
|
129 |
+
)
|
130 |
+
), $blockMock->getFrontendValidators()
|
131 |
+
);
|
132 |
+
}
|
133 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/FormTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Block/FrauddetectionTest.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Block_FrauddetectionTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
5 |
+
{
|
6 |
+
|
7 |
+
public function testToHtml()
|
8 |
+
{
|
9 |
+
$block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
|
10 |
+
$this->assertEquals(null, $block->toHtml());
|
11 |
+
|
12 |
+
$configMock = $this->getModelMock('ops/config', array('getDeviceFingerPrinting'));
|
13 |
+
$configMock->expects($this->once())
|
14 |
+
->method('getDeviceFingerPrinting')
|
15 |
+
->will($this->returnValue(true));
|
16 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
17 |
+
|
18 |
+
$sessionMock = $this->getModelMock('customer/session', array('getData'));
|
19 |
+
$sessionMock->expects($this->once())
|
20 |
+
->method('getData')
|
21 |
+
->with(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)
|
22 |
+
->will($this->returnValue(true));
|
23 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
24 |
+
// for some reason the html is not rendered in the tests
|
25 |
+
$this->assertNotNull($block->toHtml());
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
public function testGetTrackingCodeAid()
|
30 |
+
{
|
31 |
+
$block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
|
32 |
+
$this->assertEquals('10376', $block->getTrackingCodeAid());
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
public function testGetTrackingSid()
|
37 |
+
{
|
38 |
+
$quote = Mage::getModel('sales/quote');
|
39 |
+
$quote->setReservedOrderId('123456');
|
40 |
+
$quote->getStoreId(0);
|
41 |
+
Mage::app(0)->getStore(0)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH . 'PSPID', 'abc');
|
42 |
+
|
43 |
+
$block = Mage::app()->getLayout()->getBlockSingleton('ops/frauddetection');
|
44 |
+
$modelMock = $this->getModelMock('checkout/type_onepage', array('getQuote'));
|
45 |
+
$modelMock->expects($this->once())
|
46 |
+
->method('getQuote')
|
47 |
+
->will($this->returnValue($quote));
|
48 |
+
$this->replaceByMock('singleton', 'checkout/type_onepage', $modelMock);
|
49 |
+
$this->assertEquals(md5(Mage::getModel('ops/config')->getPSPID() . '#123456'), $block->getTrackingSid());
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/Info/FlexTest.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2016 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* FlexTest.php
|
24 |
+
*
|
25 |
+
* @category Payment
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Block_Info_FlexTest extends EcomDev_PHPUnit_Test_Case
|
34 |
+
{
|
35 |
+
public function testGetFlexTitle()
|
36 |
+
{
|
37 |
+
$payment = Mage::getModel('sales/order_payment');
|
38 |
+
$payment->setAdditionalInformation(Netresearch_OPS_Model_Payment_Flex::INFO_KEY_TITLE, 'FLEX');
|
39 |
+
|
40 |
+
/** @var Netresearch_OPS_Block_Info_Flex $block */
|
41 |
+
$block = Mage::app()->getLayout()->createBlock('ops/info_flex');
|
42 |
+
$method = Mage::getModel('ops/payment_flex');
|
43 |
+
$method->setData('info_instance', $payment);
|
44 |
+
$payment->setMethodInstance($method);
|
45 |
+
$block->setInfo($payment);
|
46 |
+
|
47 |
+
$this->assertEquals('FLEX', $block->getFlexTitle());
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/PlaceFormShaTest.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Block_PlaceformShaTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
private $_helper;
|
5 |
+
private $_shaKey;
|
6 |
+
|
7 |
+
public function setUp()
|
8 |
+
{
|
9 |
+
parent::setup();
|
10 |
+
|
11 |
+
$this->_helper = new Netresearch_OPS_Helper_Payment();
|
12 |
+
$this->_shaKey = 'qu4rkkuchen12345';
|
13 |
+
}
|
14 |
+
|
15 |
+
public function testShaGenerationWithTestData()
|
16 |
+
{
|
17 |
+
$params = array(
|
18 |
+
'AMOUNT' => '2129',
|
19 |
+
'CIVILITY' => 'Herr',
|
20 |
+
'CURRENCY' => 'EUR',
|
21 |
+
'ECOM_BILLTO_POSTAL_NAME_FIRST' => 'John',
|
22 |
+
'ECOM_BILLTO_POSTAL_NAME_LAST' => 'Doe',
|
23 |
+
'ECOM_SHIPTO_DOB' => '09/10/1940',
|
24 |
+
'EMAIL' => 'john@doe.com',
|
25 |
+
'ITEMID1' => 'article1',
|
26 |
+
'ITEMNAME1' => 'coffee',
|
27 |
+
'ITEMPRICE1' => '3.00',
|
28 |
+
'ITEMQUANT1' => '4',
|
29 |
+
'ITEMVAT1' => '0.57',
|
30 |
+
'LANGUAGE' => 'de_DE',
|
31 |
+
'ORDERID' => 'order123',
|
32 |
+
'ORDERSHIPCOST' => '100',
|
33 |
+
'ORDERSHIPTAX' => '6',
|
34 |
+
'OWNERADDRESS' => 'test street',
|
35 |
+
'OWNERCTY' => 'DE',
|
36 |
+
'OWNERTELNO' => '+49 111 222 33 444',
|
37 |
+
'OWNERTOWN' => 'Berlin',
|
38 |
+
'OWNERZIP' => '10000',
|
39 |
+
'PM' => 'Open Invoice DE',
|
40 |
+
'PSPID' => 'NRMAGbillpay1',
|
41 |
+
);
|
42 |
+
$expected = '695103f8891dfc80ea46369203925b898a381334';
|
43 |
+
$shaSign = $this->_helper->getSHASign($params, $this->_shaKey, 0);
|
44 |
+
$result = $this->_helper->shaCrypt($shaSign);
|
45 |
+
$this->assertEquals($expected, $result);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function testShaGenerationWithSpecialChars()
|
49 |
+
{
|
50 |
+
$params = array(
|
51 |
+
'PSPID' => 'NRMAGbillpay1',
|
52 |
+
'AMOUNT' => '560',
|
53 |
+
'ORDERID' => 'TBI72',
|
54 |
+
'CURRENCY' => 'EUR',
|
55 |
+
'OWNERCTY' => 'DE',
|
56 |
+
'ITEMVAT1' => '0.10',
|
57 |
+
'LANGUAGE' => 'de_DE',
|
58 |
+
'PM' => 'Open Invoice DE',
|
59 |
+
'CIVILITY' => 'Herr',
|
60 |
+
'EMAIL' => 'thomas.kappel@netresearch.de',
|
61 |
+
'ORDERSHIPCOST' => '500',
|
62 |
+
'ORDERSHIPTAX' => '0',
|
63 |
+
'ECOM_BILLTO_POSTAL_NAME_FIRST' => 'Karla',
|
64 |
+
'ECOM_BILLTO_POSTAL_NAME_LAST' => 'Kolumna',
|
65 |
+
'OWNERTELNO' => '64065460',
|
66 |
+
'ITEMPRICE1' => '0.60',
|
67 |
+
'ECOM_SHIPTO_DOB' => '09/10/1940',
|
68 |
+
'OWNERADDRESS' => 'Tierparkallee 2',
|
69 |
+
'OWNERTOWN' => 'Leipzig',
|
70 |
+
'ITEMID1' => '26',
|
71 |
+
'ITEMNAME1' => 'Club Mate',
|
72 |
+
'ITEMQUANT1' => '1',
|
73 |
+
'OWNERZIP' => '04229',
|
74 |
+
);
|
75 |
+
$expected = 'baf6099446e3bf93ecf26e622032e7db2139839c';
|
76 |
+
$shaSign = $this->_helper->getSHASign($params, $this->_shaKey, 0);
|
77 |
+
$result = $this->_helper->shaCrypt($shaSign);
|
78 |
+
$this->assertEquals($expected, $result);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
app/code/community/Netresearch/OPS/Test/Block/PlaceformTest.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Block_PlaceformTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
public function testGetFormAction()
|
5 |
+
{
|
6 |
+
$this->mockSessions();
|
7 |
+
//$block = Mage::app()->getLayout()->getBlockSingleton('ops/placeform');
|
8 |
+
$blockMock = $this->getBlockMock('ops/placeform', array('getQuestion'));
|
9 |
+
$blockMock->expects($this->any())
|
10 |
+
->method('getQuestion')
|
11 |
+
->will($this->returnValue('How much is the fish?'));
|
12 |
+
|
13 |
+
$action = $blockMock->getFormAction();
|
14 |
+
$this->assertEquals(Mage::getUrl('*/*/*', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())), $action);
|
15 |
+
|
16 |
+
// check explicitly for https
|
17 |
+
$_SERVER['HTTPS'] = 'on';
|
18 |
+
$action = $blockMock->getFormAction();
|
19 |
+
$this->assertEquals(Mage::getUrl('*/*/*', array('_secure' =>true)), $action);
|
20 |
+
|
21 |
+
$blockMock = $this->getBlockMock('ops/placeform', array('getQuestion'));
|
22 |
+
$blockMock->expects($this->any())
|
23 |
+
->method('getQuestion')
|
24 |
+
->will($this->returnValue(null));
|
25 |
+
|
26 |
+
$action = $blockMock->getFormAction();
|
27 |
+
$this->assertEquals($blockMock->getConfig()->getFrontendGatewayPath(), $action);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function testIsKwixoPaymentMethodTrue()
|
31 |
+
{
|
32 |
+
$order = Mage::getModel('sales/order');
|
33 |
+
$payment = Mage::getModel('sales/order_payment');
|
34 |
+
$payment->setMethod('ops_kwixoApresReception');
|
35 |
+
$order->setPayment($payment);
|
36 |
+
|
37 |
+
$blockMock = $this->getBlockMock('ops/placeform', array('_getOrder'));
|
38 |
+
$blockMock->expects($this->any())
|
39 |
+
->method('_getOrder')
|
40 |
+
->will($this->returnValue($order));
|
41 |
+
|
42 |
+
$this->assertTrue($blockMock->isKwixoPaymentMethod());
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
public function testIsKwixoPaymentMethodFalse()
|
47 |
+
{
|
48 |
+
$order = Mage::getModel('sales/order');
|
49 |
+
$payment = Mage::getModel('sales/order_payment');
|
50 |
+
$payment->setMethod('ops_cc');
|
51 |
+
$order->setPayment($payment);
|
52 |
+
|
53 |
+
$blockMock = $this->getBlockMock('ops/placeform', array('_getOrder'));
|
54 |
+
$blockMock->expects($this->any())
|
55 |
+
->method('_getOrder')
|
56 |
+
->will($this->returnValue($order));
|
57 |
+
|
58 |
+
$this->assertFalse($blockMock->isKwixoPaymentMethod());
|
59 |
+
|
60 |
+
}
|
61 |
+
protected function mockSessions()
|
62 |
+
{
|
63 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
64 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
65 |
+
->getMock();
|
66 |
+
$this->replaceByMock('singleton', 'core/session', $sessionMock);
|
67 |
+
|
68 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
69 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
70 |
+
->getMock();
|
71 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/System/Config/KwixoconfigurationTest.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package ${MODULENAME}
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Test_Block_System_Config_KwixoconfigurationTest
|
12 |
+
extends EcomDev_PHPUnit_Test_Case
|
13 |
+
{
|
14 |
+
|
15 |
+
public function testRender()
|
16 |
+
{
|
17 |
+
$element = new Varien_Data_Form_Element_Text();
|
18 |
+
$element->setLegend('I am legend');
|
19 |
+
$block = new Netresearch_OPS_Block_System_Config_Kwixoconfiguration();
|
20 |
+
$block->render($element);
|
21 |
+
$this->assertEquals('I am legend', $block->getData('fieldset_label'));
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/community/Netresearch/OPS/Test/Block/System/Config/ModeTest.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ModeTest.php
|
4 |
+
* @author paul.siedler@netresearch.de
|
5 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Netresearch_OPS_Test_Block_System_Config_ModeTest extends EcomDev_PHPUnit_Test_Case {
|
10 |
+
|
11 |
+
public function testGetElementHtmlContainsScriptTag()
|
12 |
+
{
|
13 |
+
$element = new Varien_Data_Form_Element_Select();
|
14 |
+
$element->setForm(new Varien_Object());
|
15 |
+
$block = new Netresearch_OPS_Block_System_Config_Mode();
|
16 |
+
$html = $block->render($element);
|
17 |
+
$this->assertTrue(preg_match('/<script/', $html) > 0);
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/AdminControllerTest.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* AdminControllerTest.php
|
5 |
+
* @author paul.siedler@netresearch.de
|
6 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Test_Controller_Adminhtml_AdminControllerTest extends EcomDev_PHPUnit_Test_Case_Controller
|
11 |
+
{
|
12 |
+
|
13 |
+
public function setUp(){
|
14 |
+
parent::setUp();
|
15 |
+
|
16 |
+
$nodePath = "modules/Enterprise_AdminGws/active";
|
17 |
+
if (Mage::helper('core/data')->isModuleEnabled('Enterprise_AdminGws')) {
|
18 |
+
Mage::getConfig()->setNode($nodePath, 'false', true);
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->fakeAdminUser();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function testResendInfoActionWillSucceed()
|
25 |
+
{
|
26 |
+
$mailFeatureMock = $this->getModelMock('ops/payment_features_paymentEmail', array('resendPaymentInfo', 'isAvailableForOrder'));
|
27 |
+
$mailFeatureMock->expects($this->any())
|
28 |
+
->method('isAvailableForOrder')
|
29 |
+
->will($this->returnValue(true));
|
30 |
+
$mailFeatureMock->expects($this->once())
|
31 |
+
->method('resendPaymentInfo')
|
32 |
+
->will($this->returnValue(true));
|
33 |
+
$this->replaceByMock('model', 'ops/payment_features_paymentEmail', $mailFeatureMock);
|
34 |
+
|
35 |
+
$orderMock = $this->getModelMock('sales/order', array('load'));
|
36 |
+
$orderMock->expects($this->once())
|
37 |
+
->method('load')
|
38 |
+
->will($this->returnValue($orderMock));
|
39 |
+
$this->replaceByMock('model', 'sales/order', $orderMock);
|
40 |
+
|
41 |
+
$this->dispatch('adminhtml/admin/resendInfo', array('order_id' => 1));
|
42 |
+
}
|
43 |
+
|
44 |
+
public function testResendInfoActionWillFail()
|
45 |
+
{
|
46 |
+
$mailFeatureMock = $this->getModelMock('ops/payment_features_paymentEmail', array('resendPaymentInfo', 'isAvailableForOrder'));
|
47 |
+
$mailFeatureMock->expects($this->any())
|
48 |
+
->method('isAvailableForOrder')
|
49 |
+
->will($this->returnValue(true));
|
50 |
+
$mailFeatureMock->expects($this->once())
|
51 |
+
->method('resendPaymentInfo')
|
52 |
+
->will($this->returnValue(false));
|
53 |
+
$this->replaceByMock('model', 'ops/payment_features_paymentEmail', $mailFeatureMock);
|
54 |
+
|
55 |
+
$orderMock = $this->getModelMock('sales/order', array('load'));
|
56 |
+
$orderMock->expects($this->once())
|
57 |
+
->method('load')
|
58 |
+
->will($this->returnValue($orderMock));
|
59 |
+
$this->replaceByMock('model', 'sales/order', $orderMock);
|
60 |
+
|
61 |
+
$this->dispatch('adminhtml/admin/resendInfo', array('order_id' => 1));
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function fakeAdminUser(){
|
65 |
+
$fakeUser = $this->getModelMock('admin/user', array('getId', 'getRole'));
|
66 |
+
$fakeUser->expects($this->any())
|
67 |
+
->method('getId')
|
68 |
+
->will($this->returnValue(1));
|
69 |
+
|
70 |
+
$adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save', 'getUser'));
|
71 |
+
$adminSessionMock->expects($this->any())
|
72 |
+
->method('isAllowed')
|
73 |
+
->will($this->returnValue(true));
|
74 |
+
$adminSessionMock->expects($this->any())
|
75 |
+
->method('getUser')
|
76 |
+
->will($this->returnValue($fakeUser));
|
77 |
+
$this->replaceByMock('model', 'admin/session', $adminSessionMock);
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixocategoryControllerTest.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Controller_Adminhtml_KwixocategoryControllerTest
|
3 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
4 |
+
{
|
5 |
+
public function setUp()
|
6 |
+
{
|
7 |
+
parent::setUp();
|
8 |
+
$fakeUser = $this->getModelMock('admin/user', array('getId', 'getRole'));
|
9 |
+
$fakeUser->expects($this->any())
|
10 |
+
->method('getId')
|
11 |
+
->will($this->returnValue(1));
|
12 |
+
|
13 |
+
$sessionMock = $this->getModelMock(
|
14 |
+
'admin/session', array('getUser', 'init', 'save', 'isAllowed')
|
15 |
+
);
|
16 |
+
$sessionMock->expects($this->any())
|
17 |
+
->method('getUser')
|
18 |
+
->will($this->returnValue($fakeUser));
|
19 |
+
|
20 |
+
$sessionMock->expects($this->any())
|
21 |
+
->method('isAllowed')
|
22 |
+
->will($this->returnValue(true));
|
23 |
+
|
24 |
+
$this->replaceByMock('singleton', 'admin/session', $sessionMock);
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @loadFixture category_mapping
|
30 |
+
*/
|
31 |
+
public function testDeleteAction()
|
32 |
+
{
|
33 |
+
$this->dispatch('adminhtml/kwixocategory/delete', array());
|
34 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(1);
|
35 |
+
$this->assertEquals(1, $model->getId());
|
36 |
+
$this->dispatch('adminhtml/kwixocategory/delete', array('id' => 666));
|
37 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(1);
|
38 |
+
$this->assertEquals(1, $model->getId());
|
39 |
+
$this->dispatch('adminhtml/kwixocategory/delete', array('id' => 10));
|
40 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(1);
|
41 |
+
$this->assertNull($model->getId());
|
42 |
+
Mage::getSingleton('adminhtml/session')->getMessages(true);
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixocategoryControllerTest/fixtures/category_mapping.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
ops/kwixo_category_mapping:
|
3 |
+
- id: 1
|
4 |
+
kwixo_category_id: 10
|
5 |
+
category_id: 10
|
6 |
+
- id: 2
|
7 |
+
kwixo_category_id: 1
|
8 |
+
category_id: 11
|
9 |
+
- id: 3
|
10 |
+
kwixo_category_id: 2
|
11 |
+
category_id: 12
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixoshippingControllerTest.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG
|
7 |
+
* (http://www.netresearch.de)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php
|
9 |
+
* Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
class Netresearch_OPS_Test_Controller_Adminhtml_KwixoshippingControllerTest
|
14 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
15 |
+
{
|
16 |
+
|
17 |
+
public function setUp()
|
18 |
+
{
|
19 |
+
parent::setUp();
|
20 |
+
$fakeUser = $this->getModelMock('admin/user', array('getId', 'getRole'));
|
21 |
+
$fakeUser->expects($this->any())
|
22 |
+
->method('getId')
|
23 |
+
->will($this->returnValue(1));
|
24 |
+
|
25 |
+
$sessionMock = $this->getModelMock(
|
26 |
+
'admin/session', array('getUser', 'init', 'save', 'isAllowed')
|
27 |
+
);
|
28 |
+
$sessionMock->expects($this->any())
|
29 |
+
->method('getUser')
|
30 |
+
->will($this->returnValue($fakeUser));
|
31 |
+
|
32 |
+
$sessionMock->expects($this->any())
|
33 |
+
->method('isAllowed')
|
34 |
+
->will($this->returnValue(true));
|
35 |
+
|
36 |
+
$this->replaceByMock('singleton', 'admin/session', $sessionMock);
|
37 |
+
|
38 |
+
$nodePath = "modules/Enterprise_AdminGws/active";
|
39 |
+
if (Mage::helper('core/data')->isModuleEnabled('Enterprise_AdminGws')) {
|
40 |
+
Mage::getConfig()->setNode($nodePath, 'false', true);
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
public function testIndexAction()
|
48 |
+
{
|
49 |
+
|
50 |
+
$this->dispatch('adminhtml/kwixoshipping/index', array());
|
51 |
+
$this->assertRequestRoute('adminhtml/kwixoshipping/index');
|
52 |
+
$this->assertLayoutBlockCreated('kwixoshipping');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function testSaveAction()
|
56 |
+
{
|
57 |
+
$this->dispatch('adminhtml/kwixoshipping/save', array());
|
58 |
+
$this->assertRequestRoute('adminhtml/kwixoshipping/save');
|
59 |
+
$this->assertRedirectTo('adminhtml/kwixoshipping/index');
|
60 |
+
}
|
61 |
+
|
62 |
+
public function testSaveActionWithPost()
|
63 |
+
{
|
64 |
+
$postData = array(
|
65 |
+
'form_key' => '1234'
|
66 |
+
);
|
67 |
+
$this->getRequest()->setPost($postData);
|
68 |
+
$this->getRequest()->setMethod('POST');
|
69 |
+
$this->dispatch('adminhtml/kwixoshipping/save', array());
|
70 |
+
$this->assertRequestRoute('adminhtml/kwixoshipping/save');
|
71 |
+
$this->assertRedirectTo('adminhtml/kwixoshipping/index');
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @loadFixture shipping_settings.yaml
|
76 |
+
*/
|
77 |
+
public function testSaveActionWithRealPostData()
|
78 |
+
{
|
79 |
+
$postData = array(
|
80 |
+
'form_key' => '1234',
|
81 |
+
'flatrate' => array(
|
82 |
+
'kwixo_shipping_type' => 1,
|
83 |
+
'kwixo_shipping_speed' => 1,
|
84 |
+
'kwixo_shipping_details' => 'foo'
|
85 |
+
)
|
86 |
+
);
|
87 |
+
$this->getRequest()->setPost($postData);
|
88 |
+
$this->getRequest()->setMethod('POST');
|
89 |
+
$this->dispatch('adminhtml/kwixoshipping/save', array());
|
90 |
+
$this->assertRequestRoute('adminhtml/kwixoshipping/save');
|
91 |
+
$this->assertRedirectTo('adminhtml/kwixoshipping/index');
|
92 |
+
$kwixoModel = Mage::getModel('ops/kwixo_shipping_setting')->load(1);
|
93 |
+
|
94 |
+
// assure that saving the data worked properly
|
95 |
+
|
96 |
+
$this->assertEquals('flatrate', $kwixoModel->getShippingCode());
|
97 |
+
$this->assertEquals(1, $kwixoModel->getKwixoShippingType());
|
98 |
+
$this->assertEquals(1, $kwixoModel->getKwixoShippingSpeed());
|
99 |
+
$this->assertEquals('foo', $kwixoModel->getKwixoShippingDetails());
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @loadFixture shipping_settings.yaml
|
105 |
+
*/
|
106 |
+
public function testSaveActionWithErrorneousPostData()
|
107 |
+
{
|
108 |
+
$postData = array(
|
109 |
+
'form_key' => '1234',
|
110 |
+
'flatrate' => array(
|
111 |
+
'kwixo_shipping_type' => -1,
|
112 |
+
'kwixo_shipping_speed' => 'abc',
|
113 |
+
'kwixo_shipping_details' => 'foo'
|
114 |
+
)
|
115 |
+
);
|
116 |
+
$this->getRequest()->setPost($postData);
|
117 |
+
$this->getRequest()->setMethod('POST');
|
118 |
+
$this->dispatch('adminhtml/kwixoshipping/save', array());
|
119 |
+
$this->assertRequestRoute('adminhtml/kwixoshipping/save');
|
120 |
+
$this->assertRedirectTo('adminhtml/kwixoshipping/index');
|
121 |
+
$kwixoModel = Mage::getModel('ops/kwixo_shipping_setting')->load(1);
|
122 |
+
|
123 |
+
// assure that saving the data worked properly
|
124 |
+
|
125 |
+
$this->assertEquals('flatrate', $kwixoModel->getShippingCode());
|
126 |
+
$this->assertNotEquals(-1, $kwixoModel->getKwixoShippingType());
|
127 |
+
$this->assertNotEquals('abc', $kwixoModel->getKwixoShippingSpeed());
|
128 |
+
$this->assertNotEquals('foo', $kwixoModel->getKwixoShippingDetails());
|
129 |
+
}
|
130 |
+
|
131 |
+
public function testDeleteNotFoundAction()
|
132 |
+
{
|
133 |
+
$this->dispatch('adminhtml/kwixoshipping/delete', array());
|
134 |
+
$headers = $this->getResponse()->getHeaders();
|
135 |
+
$notFound = false;
|
136 |
+
foreach ($headers as $header) {
|
137 |
+
if ($header['name'] == 'Status'
|
138 |
+
&& $header['value'] == '404 File not found'
|
139 |
+
) {
|
140 |
+
$notFound = true;
|
141 |
+
break;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
$this->assertTrue($notFound);
|
145 |
+
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/KwixoshippingControllerTest/fixtures/shipping_settings.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
ops/kwixo_shipping_setting:
|
3 |
+
- id: 1
|
4 |
+
shipping_code: flatrate
|
5 |
+
kwixo_shipping_type: ''
|
6 |
+
kwixo_shipping_speed: ''
|
7 |
+
kwixo_shipping_details: ''
|
app/code/community/Netresearch/OPS/Test/Controller/Adminhtml/OpsstatusControllerTest.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Netresearch_OPS_Test_Controller_Adminhtml_OpsstatusControllerTest
|
11 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
12 |
+
{
|
13 |
+
|
14 |
+
public function setUp()
|
15 |
+
{
|
16 |
+
parent::setUp();
|
17 |
+
|
18 |
+
$nodePath = "modules/Enterprise_AdminGws/active";
|
19 |
+
if (Mage::helper('core/data')->isModuleEnabled('Enterprise_AdminGws')) {
|
20 |
+
Mage::getConfig()->setNode($nodePath, 'false', true);
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
public function testUpdateActionWillRedirect()
|
26 |
+
{
|
27 |
+
$fakeUser = $this->getModelMock('admin/user', array('getId', 'getRole'));
|
28 |
+
$fakeUser->expects($this->any())
|
29 |
+
->method('getId')
|
30 |
+
->will($this->returnValue(1));
|
31 |
+
|
32 |
+
$adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save', 'getUser'));
|
33 |
+
$adminSessionMock->expects($this->any())
|
34 |
+
->method('isAllowed')
|
35 |
+
->will($this->returnValue(true));
|
36 |
+
$adminSessionMock->expects($this->any())
|
37 |
+
->method('getUser')
|
38 |
+
->will($this->returnValue($fakeUser));
|
39 |
+
$this->replaceByMock('model', 'admin/session', $adminSessionMock);
|
40 |
+
|
41 |
+
$statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
|
42 |
+
$this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
|
43 |
+
|
44 |
+
$this->dispatch('adminhtml/opsstatus/update', array('order_id' => 1));
|
45 |
+
$this->assertRedirectTo('adminhtml/sales_order/view', array('order_id' => 1));
|
46 |
+
}
|
47 |
+
|
48 |
+
public function testUpdateActionWillNotRedirect()
|
49 |
+
{
|
50 |
+
$fakeUser = $this->getModelMock('admin/user', array('getId', 'getRole'));
|
51 |
+
$fakeUser->expects($this->any())
|
52 |
+
->method('getId')
|
53 |
+
->will($this->returnValue(1));
|
54 |
+
|
55 |
+
$adminSessionMock = $this->getModelMock('admin/session', array('isAllowed', 'init', 'save', 'getUser'));
|
56 |
+
$adminSessionMock->expects($this->any())
|
57 |
+
->method('isAllowed')
|
58 |
+
->will($this->returnValue(false));
|
59 |
+
$adminSessionMock->expects($this->any())
|
60 |
+
->method('getUser')
|
61 |
+
->will($this->returnValue($fakeUser));
|
62 |
+
$this->replaceByMock('model', 'admin/session', $adminSessionMock);
|
63 |
+
|
64 |
+
$statusUpdateMock = $this->getModelMock('ops/status_update', array('updateStatusFor'));
|
65 |
+
$this->replaceByMock('model', 'ops/status_update', $statusUpdateMock);
|
66 |
+
|
67 |
+
$this->dispatch('adminhtml/opsstatus/update', array('order_id' => 1));
|
68 |
+
$this->assertEquals('403 Forbidden', $this->getResponse()->getSentHeader('Http/1.1'));
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Controller_AliasControllerTest
|
3 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
4 |
+
{
|
5 |
+
|
6 |
+
public function testAcceptAliasAction()
|
7 |
+
{
|
8 |
+
$quote = Mage::getModel('sales/quote');
|
9 |
+
$payment = Mage::getModel('sales/quote_payment');
|
10 |
+
$quote->setPayment($payment);
|
11 |
+
$sessionMock = $this->getModelMock('checkout/session', array('getQuote'));
|
12 |
+
$sessionMock->expects($this->any())
|
13 |
+
->method('getQuote')
|
14 |
+
->will($this->returnValue($quote));
|
15 |
+
$this->replaceByMock('singleton', 'checkout/session', $sessionMock);
|
16 |
+
$aliasHelperMock = $this->getHelperMock('ops/alias', array('saveAlias', 'setAliasToPayment'));
|
17 |
+
$this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
|
18 |
+
$routeToDispatch = 'ops/alias/accept';
|
19 |
+
$params = array('Alias_AliasId' => '4711');
|
20 |
+
$this->dispatch($routeToDispatch, $params);
|
21 |
+
$result = $this->getResponse()->getOutputBody();
|
22 |
+
$this->assertEquals($result, "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:success', '4711'); };</script>");
|
23 |
+
|
24 |
+
$params = array('Alias_AliasId' => '4711', 'Card_CVC' => '123');
|
25 |
+
$this->dispatch($routeToDispatch, $params);
|
26 |
+
$result = $this->getResponse()->getOutputBody();
|
27 |
+
$this->assertEquals($result, "<script type='application/javascript'>window.onload = function() { top.document.fire('alias:success', '4711'); };</script>");
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @loadFixture orders.yaml
|
33 |
+
*/
|
34 |
+
public function testGenerateHashAction()
|
35 |
+
{
|
36 |
+
|
37 |
+
$fakeQuote = Mage::getModel('sales/order')->load(11);
|
38 |
+
$quoteMock = $this->getModelMock('sales/quote', array('load', 'save'));
|
39 |
+
$quoteMock->expects($this->any())
|
40 |
+
->method('load')
|
41 |
+
->will($this->returnValue($fakeQuote));
|
42 |
+
$this->replaceByMock('model', 'sales/quote', $quoteMock);
|
43 |
+
$params = array(
|
44 |
+
'alias' => 4711,
|
45 |
+
'storeId' => 1
|
46 |
+
);
|
47 |
+
|
48 |
+
$configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
|
49 |
+
$configHelperMock->expects($this->any())
|
50 |
+
->method('getAliasAcceptUrl')
|
51 |
+
->with(1)
|
52 |
+
->will($this->returnValue(1));
|
53 |
+
$configHelperMock->expects($this->any())
|
54 |
+
->method('getAliasExceptionUrl')
|
55 |
+
->with(1)
|
56 |
+
->will($this->returnValue(1));
|
57 |
+
$this->replaceByMock('model', 'ops/config', $configHelperMock);
|
58 |
+
|
59 |
+
$this->dispatch('ops/alias/generateHash', $params);
|
60 |
+
$result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
|
61 |
+
$this->assertArrayHasKey('hash', $result);
|
62 |
+
|
63 |
+
$params = array(
|
64 |
+
'alias' => 4712,
|
65 |
+
'storeId' => 0
|
66 |
+
);
|
67 |
+
|
68 |
+
$configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExceptionUrl'));
|
69 |
+
$configHelperMock->expects($this->any())
|
70 |
+
->method('getAliasAcceptUrl')
|
71 |
+
->with(0)
|
72 |
+
->will($this->returnValue(1));
|
73 |
+
$configHelperMock->expects($this->any())
|
74 |
+
->method('getAliasExceptionUrl')
|
75 |
+
->with(0)
|
76 |
+
->will($this->returnValue(1));
|
77 |
+
$this->replaceByMock('model', 'ops/config', $configHelperMock);
|
78 |
+
|
79 |
+
$this->dispatch('ops/alias/generateHash', $params);
|
80 |
+
$result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
|
81 |
+
$this->assertArrayHasKey('hash', $result);
|
82 |
+
|
83 |
+
$params = array(
|
84 |
+
'alias' => 4713,
|
85 |
+
'storeId' => 1,
|
86 |
+
'isAdmin' => 1,
|
87 |
+
'brand' => 'visa'
|
88 |
+
);
|
89 |
+
|
90 |
+
$configHelperMock = $this->getModelMock('ops/config', array('getAliasAcceptUrl', 'getAliasExecptionUrl'));
|
91 |
+
$configHelperMock->expects($this->any())
|
92 |
+
->method('getAliasAcceptUrl')
|
93 |
+
->with(0)
|
94 |
+
->will($this->returnValue(1));
|
95 |
+
$configHelperMock->expects($this->any())
|
96 |
+
->method('getAliasExceptionUrl')
|
97 |
+
->with(0)
|
98 |
+
->will($this->returnValue(1));
|
99 |
+
$this->replaceByMock('model', 'ops/config', $configHelperMock);
|
100 |
+
|
101 |
+
$this->dispatch('ops/alias/generateHash', $params);
|
102 |
+
$result = Mage::helper('core')->jsonDecode($this->getResponse()->getOutputBody());
|
103 |
+
$this->assertArrayHasKey('hash', $result);
|
104 |
+
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/AliasControllerTest/fixtures/orders.yaml
ADDED
@@ -0,0 +1,595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
sales/order:
|
3 |
+
- entity_id: 11
|
4 |
+
increment_id: 100000011
|
5 |
+
shipping_address_id: 42
|
6 |
+
base_grand_total: 119.00
|
7 |
+
grand_total: 119.00
|
8 |
+
currency: 'EUR'
|
9 |
+
customer_gender: 1
|
10 |
+
shipping_method: 'flatrate_flatrate'
|
11 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
12 |
+
state: 'pending_payment'
|
13 |
+
status: 'pending_payment'
|
14 |
+
quote_id: 23
|
15 |
+
|
16 |
+
- entity_id: 12
|
17 |
+
increment_id: 100000012
|
18 |
+
shipping_address_id: 42
|
19 |
+
base_grand_total: 119.00
|
20 |
+
grand_total: 119.00
|
21 |
+
currency: 'EUR'
|
22 |
+
customer_gender: 1
|
23 |
+
shipping_method: 'flatrate_flatrate'
|
24 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
25 |
+
state: 'pending_payment'
|
26 |
+
status: 'pending_payment'
|
27 |
+
quote_id: 24
|
28 |
+
|
29 |
+
- entity_id: 13
|
30 |
+
increment_id: 100000013
|
31 |
+
shipping_address_id: 43
|
32 |
+
base_grand_total: 177.55
|
33 |
+
grand_total: 177.55
|
34 |
+
currency: 'EUR'
|
35 |
+
customer_gender: 1
|
36 |
+
shipping_method: 'flatrate_flatrate'
|
37 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
38 |
+
state: 'processing'
|
39 |
+
status: 'processing'
|
40 |
+
quote_id: 25
|
41 |
+
|
42 |
+
- entity_id: 14
|
43 |
+
increment_id: 100000014
|
44 |
+
shipping_address_id: 43
|
45 |
+
base_grand_total: 177.55
|
46 |
+
grand_total: 177.55
|
47 |
+
currency: 'EUR'
|
48 |
+
customer_gender: 1
|
49 |
+
shipping_method: 'flatrate_flatrate'
|
50 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
51 |
+
state: 'pending_payment'
|
52 |
+
status: 'pending_payment'
|
53 |
+
quote_id: 26
|
54 |
+
|
55 |
+
- entity_id: 15
|
56 |
+
increment_id: 100000015
|
57 |
+
shipping_address_id: 43
|
58 |
+
base_grand_total: 177.55
|
59 |
+
grand_total: 200.00
|
60 |
+
currency: '$'
|
61 |
+
customer_gender: 1
|
62 |
+
shipping_method: 'flatrate_flatrate'
|
63 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
64 |
+
state: 'pending_payment'
|
65 |
+
status: 'pending_payment'
|
66 |
+
quote_id: 27
|
67 |
+
|
68 |
+
- entity_id: 16
|
69 |
+
increment_id: 100000016
|
70 |
+
shipping_address_id: 43
|
71 |
+
base_grand_total: 19.99
|
72 |
+
grand_total: 19.99
|
73 |
+
currency: 'EUR'
|
74 |
+
customer_gender: 1
|
75 |
+
shipping_method: 'flatrate_flatrate'
|
76 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
77 |
+
state: 'pending_payment'
|
78 |
+
status: 'pending_payment'
|
79 |
+
quote_id: 28
|
80 |
+
|
81 |
+
- entity_id: 17
|
82 |
+
increment_id: 100000017
|
83 |
+
shipping_address_id: 43
|
84 |
+
base_grand_total: 19.99
|
85 |
+
grand_total: 19.99
|
86 |
+
currency: 'EUR'
|
87 |
+
customer_gender: 1
|
88 |
+
shipping_method: 'flatrate_flatrate'
|
89 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
90 |
+
state: 'pending_payment'
|
91 |
+
status: 'pending_payment'
|
92 |
+
quote_id: 29
|
93 |
+
|
94 |
+
- entity_id: 18
|
95 |
+
increment_id: 100000018
|
96 |
+
shipping_address_id: 43
|
97 |
+
base_grand_total: 19.99
|
98 |
+
grand_total: 19.99
|
99 |
+
currency: 'EUR'
|
100 |
+
customer_gender: 1
|
101 |
+
shipping_method: 'flatrate_flatrate'
|
102 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
103 |
+
state: 'pending_payment'
|
104 |
+
status: 'pending_payment'
|
105 |
+
quote_id: 30
|
106 |
+
|
107 |
+
- entity_id: 19
|
108 |
+
increment_id: 100000019
|
109 |
+
shipping_address_id: 50
|
110 |
+
base_grand_total: 19.99
|
111 |
+
grand_total: 19.99
|
112 |
+
currency: 'EUR'
|
113 |
+
customer_gender: 1
|
114 |
+
shipping_method: 'flatrate_flatrate'
|
115 |
+
customer_email: 'willi.usa.customer@trash-mail.com'
|
116 |
+
state: 'pending_payment'
|
117 |
+
status: 'pending_payment'
|
118 |
+
quote_id: 43
|
119 |
+
|
120 |
+
- entity_id: 20
|
121 |
+
increment_id: 100000020
|
122 |
+
shipping_address_id: 42
|
123 |
+
base_grand_total: 119.00
|
124 |
+
grand_total: 119.00
|
125 |
+
currency: 'EUR'
|
126 |
+
customer_gender: 1
|
127 |
+
shipping_method: 'flatrate_flatrate'
|
128 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
129 |
+
state: 'pending_payment'
|
130 |
+
status: 'pending_payment'
|
131 |
+
quote_id: 42#
|
132 |
+
|
133 |
+
- entity_id: 21
|
134 |
+
increment_id: 100000021
|
135 |
+
shipping_address_id: 42
|
136 |
+
base_grand_total: 119.00
|
137 |
+
grand_total: 119.00
|
138 |
+
currency: 'EUR'
|
139 |
+
customer_gender: 1
|
140 |
+
shipping_method: 'flatrate_flatrate'
|
141 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
142 |
+
state: 'pending_payment'
|
143 |
+
status: 'pending_payment'
|
144 |
+
|
145 |
+
- entity_id: 22
|
146 |
+
increment_id: 100000022
|
147 |
+
shipping_address_id: 42
|
148 |
+
base_grand_total: 119.00
|
149 |
+
grand_total: 119.00
|
150 |
+
currency: 'EUR'
|
151 |
+
customer_gender: 1
|
152 |
+
shipping_method: 'flatrate_flatrate'
|
153 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
154 |
+
state: 'pending_payment'
|
155 |
+
status: 'pending_payment'
|
156 |
+
|
157 |
+
- entity_id: 23
|
158 |
+
increment_id: 100000023
|
159 |
+
store_id: 1
|
160 |
+
shipping_address_id: 42
|
161 |
+
base_grand_total: 119.00
|
162 |
+
grand_total: 119.00
|
163 |
+
currency: 'EUR'
|
164 |
+
customer_gender: 1
|
165 |
+
shipping_method: 'flatrate_flatrate'
|
166 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
167 |
+
state: 'pending_payment'
|
168 |
+
status: 'pending_payment'
|
169 |
+
|
170 |
+
- entity_id: 24
|
171 |
+
increment_id: 100000024
|
172 |
+
store_id: 1
|
173 |
+
shipping_address_id: 46
|
174 |
+
base_grand_total: 119.00
|
175 |
+
grand_total: 119.00
|
176 |
+
currency: 'EUR'
|
177 |
+
customer_gender: 1
|
178 |
+
shipping_method: 'flatrate_flatrate'
|
179 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
180 |
+
state: 'pending_payment'
|
181 |
+
status: 'pending_payment'
|
182 |
+
|
183 |
+
- entity_id: 24
|
184 |
+
increment_id: 100000024
|
185 |
+
store_id: 1
|
186 |
+
shipping_address_id: 42
|
187 |
+
base_grand_total: 119.00
|
188 |
+
grand_total: 119.00
|
189 |
+
currency: 'EUR'
|
190 |
+
customer_gender: 1
|
191 |
+
shipping_method: 'flatrate_flatrate'
|
192 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
193 |
+
state: 'pending_payment'
|
194 |
+
status: 'pending_payment'
|
195 |
+
|
196 |
+
- entity_id: 25
|
197 |
+
increment_id: 100000025
|
198 |
+
store_id: 1
|
199 |
+
shipping_address_id: 42
|
200 |
+
base_grand_total: 119.00
|
201 |
+
grand_total: 119.00
|
202 |
+
currency: 'EUR'
|
203 |
+
customer_gender: 1
|
204 |
+
shipping_method: 'flatrate_flatrate'
|
205 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
206 |
+
state: 'pending_payment'
|
207 |
+
status: 'pending_payment'
|
208 |
+
|
209 |
+
- entity_id: 26
|
210 |
+
increment_id: 100000026
|
211 |
+
store_id: 1
|
212 |
+
shipping_address_id: 42
|
213 |
+
base_grand_total: 119.00
|
214 |
+
grand_total: 119.00
|
215 |
+
currency: 'EUR'
|
216 |
+
customer_gender: 1
|
217 |
+
shipping_method: 'flatrate_flatrate'
|
218 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
219 |
+
state: 'pending_payment'
|
220 |
+
status: 'pending_payment'
|
221 |
+
|
222 |
+
- entity_id: 27
|
223 |
+
increment_id: 100000027
|
224 |
+
store_id: 1
|
225 |
+
shipping_address_id: 42
|
226 |
+
base_grand_total: 119.00
|
227 |
+
grand_total: 119.00
|
228 |
+
currency: 'EUR'
|
229 |
+
customer_gender: 1
|
230 |
+
shipping_method: 'flatrate_flatrate'
|
231 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
232 |
+
state: 'pending_payment'
|
233 |
+
status: 'pending_payment'
|
234 |
+
|
235 |
+
- entity_id: 28
|
236 |
+
increment_id: 100000028
|
237 |
+
store_id: 1
|
238 |
+
shipping_address_id: 42
|
239 |
+
base_grand_total: 119.00
|
240 |
+
grand_total: 119.00
|
241 |
+
currency: 'EUR'
|
242 |
+
customer_gender: 1
|
243 |
+
shipping_method: 'flatrate_flatrate'
|
244 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
245 |
+
state: 'pending_payment'
|
246 |
+
status: 'pending_payment'
|
247 |
+
|
248 |
+
- entity_id: 29
|
249 |
+
increment_id: 100000029
|
250 |
+
store_id: 1
|
251 |
+
shipping_address_id: 42
|
252 |
+
base_grand_total: 119.00
|
253 |
+
grand_total: 119.00
|
254 |
+
currency: 'EUR'
|
255 |
+
customer_gender: 1
|
256 |
+
shipping_method: 'flatrate_flatrate'
|
257 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
258 |
+
state: 'pending_payment'
|
259 |
+
status: 'pending_payment'
|
260 |
+
|
261 |
+
- entity_id: 30
|
262 |
+
increment_id: 100000030
|
263 |
+
store_id: 1
|
264 |
+
shipping_address_id: 42
|
265 |
+
base_grand_total: 119.00
|
266 |
+
grand_total: 119.00
|
267 |
+
currency: 'EUR'
|
268 |
+
customer_gender: 1
|
269 |
+
shipping_method: 'flatrate_flatrate'
|
270 |
+
customer_email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
271 |
+
state: 'pending_payment'
|
272 |
+
status: 'pending_payment'
|
273 |
+
|
274 |
+
sales/quote:
|
275 |
+
- entity_id: 1
|
276 |
+
base_grand_total: 119.00
|
277 |
+
grand_total: 119.00
|
278 |
+
currency: 'EUR'
|
279 |
+
customer_gender: 1
|
280 |
+
shipping_method: 'flatrate_flatrate'
|
281 |
+
|
282 |
+
- entity_id: 2
|
283 |
+
base_grand_total: 119.00
|
284 |
+
grand_total: 200.00
|
285 |
+
currency: '$'
|
286 |
+
customer_gender: 1
|
287 |
+
shipping_method: 'flatrate_flatrate'
|
288 |
+
|
289 |
+
- entity_id: 10
|
290 |
+
store_id: 0
|
291 |
+
customer_id: 23
|
292 |
+
created_at: '2013-05-14 14:45:00'
|
293 |
+
|
294 |
+
- entity_id: 11
|
295 |
+
store_id: 0
|
296 |
+
created_at: '2013-05-14 14:45:00'
|
297 |
+
|
298 |
+
- entity_id: 23
|
299 |
+
store_id: 0
|
300 |
+
created_at: '2013-05-14 14:45:00'
|
301 |
+
|
302 |
+
- entity_id: 12
|
303 |
+
store_id: 0
|
304 |
+
created_at: '2013-05-14 14:45:00'
|
305 |
+
|
306 |
+
sales/quote_payment:
|
307 |
+
- payment_id: 1
|
308 |
+
quote_id: 10
|
309 |
+
updated_at: '1970-01-01'
|
310 |
+
method: 'ops_cc'
|
311 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
312 |
+
|
313 |
+
- payment_id: 2
|
314 |
+
quote_id: 11
|
315 |
+
updated_at: '1970-01-01'
|
316 |
+
method: 'ops_cc'
|
317 |
+
quote_id: 11
|
318 |
+
|
319 |
+
- payment_id: 3
|
320 |
+
quote_id: 10
|
321 |
+
updated_at: '1970-01-01'
|
322 |
+
method: 'ops_cc'
|
323 |
+
additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
324 |
+
|
325 |
+
- payment_id: 4
|
326 |
+
quote_id: 12
|
327 |
+
updated_at: '1970-01-01'
|
328 |
+
method: 'ops_paypal'
|
329 |
+
additional_information: a:7:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:3:"cvc";s:3:"123";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:4:"4714";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
330 |
+
|
331 |
+
sales/order_payment:
|
332 |
+
- entity_id: 1
|
333 |
+
parent_id: 11
|
334 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
335 |
+
method: 'ops_bankTransfer'
|
336 |
+
|
337 |
+
- entity_id: 2
|
338 |
+
parent_id: 12
|
339 |
+
additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"5";}
|
340 |
+
|
341 |
+
- entity_id: 3
|
342 |
+
parent_id: 13
|
343 |
+
additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:6:"status";s:1:"0";}
|
344 |
+
|
345 |
+
- entity_id: 4
|
346 |
+
parent_id: 14
|
347 |
+
additional_information: a:2:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";}
|
348 |
+
|
349 |
+
- entity_id: 5
|
350 |
+
parent_id: 15
|
351 |
+
additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";}
|
352 |
+
method: 'ops_cc'
|
353 |
+
|
354 |
+
- entity_id: 6
|
355 |
+
parent_id: 16
|
356 |
+
additional_information: a:3:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";}
|
357 |
+
|
358 |
+
- entity_id: 7
|
359 |
+
parent_id: 17
|
360 |
+
additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFS";s:9:"canRefund";b:0;}
|
361 |
+
|
362 |
+
- entity_id: 8
|
363 |
+
parent_id: 18
|
364 |
+
additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:23:"lastRefundOperationCode";s:3:"RFD";s:9:"canRefund";b:1;}
|
365 |
+
|
366 |
+
- entity_id: 9
|
367 |
+
parent_id: 19
|
368 |
+
method: 'ops_openInvoiceDe'
|
369 |
+
|
370 |
+
- entity_id: 11
|
371 |
+
parent_id: 20
|
372 |
+
additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
|
373 |
+
|
374 |
+
- entity_id: 12
|
375 |
+
parent_id: 21
|
376 |
+
additional_information: a:4:{s:2:"PM";s:16:"Direct Debits DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
|
377 |
+
method: 'ops_directDebit'
|
378 |
+
|
379 |
+
- entity_id: 13
|
380 |
+
parent_id: 22
|
381 |
+
additional_information: a:4:{s:2:"PM";s:16:"Direct Debits NL";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
|
382 |
+
|
383 |
+
- entity_id: 14
|
384 |
+
parent_id: 23
|
385 |
+
additional_information: a:4:{s:2:"PM";s:16:"Bank transfer DE";s:5:"BRAND";s:16:"Bank transfer DE";s:11:"HTML_ANSWER";s:4:"HTML";s:9:"canRefund";b:1;}
|
386 |
+
|
387 |
+
- entity_id: 42
|
388 |
+
parent_id: 20
|
389 |
+
|
390 |
+
- entity_id: 15
|
391 |
+
parent_id: 24
|
392 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:4:"VISA";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
393 |
+
method: 'ops_cc'
|
394 |
+
|
395 |
+
- entity_id: 16
|
396 |
+
parent_id: 25
|
397 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
398 |
+
method: 'ops_cc'
|
399 |
+
|
400 |
+
- entity_id: 17
|
401 |
+
parent_id: 26
|
402 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
403 |
+
method: 'ops_paypal'
|
404 |
+
|
405 |
+
- entity_id: 18
|
406 |
+
parent_id: 27
|
407 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
408 |
+
method: 'ops_kwixoApresReception'
|
409 |
+
|
410 |
+
- entity_id: 19
|
411 |
+
parent_id: 28
|
412 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
413 |
+
method: 'ops_kwixoComptant'
|
414 |
+
|
415 |
+
- entity_id: 20
|
416 |
+
parent_id: 29
|
417 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
418 |
+
method: 'ops_kwixoCredit'
|
419 |
+
|
420 |
+
- entity_id: 21
|
421 |
+
parent_id: 30
|
422 |
+
additional_information: a:6:{s:8:"CC_BRAND";s:16:"PostFinance Card";s:5:"CC_CN";s:10:"Max Muster";s:12:"saveOpsAlias";s:1:"0";s:5:"alias";s:12:"041907169941";s:12:"ops_response";a:22:{s:7:"orderID";s:11:"SER13041841";s:5:"PAYID";s:8:"20908736";s:8:"NCSTATUS";s:1:"0";s:7:"NCERROR";s:1:"0";s:10:"ACCEPTANCE";s:7:"test123";s:6:"STATUS";s:1:"5";s:5:"IPCTY";s:2:"AU";s:5:"CCCTY";s:2:"US";s:3:"ECI";s:2:"12";s:8:"CVCCheck";s:2:"NO";s:8:"AAVCheck";s:2:"NO";s:2:"VC";s:2:"NO";s:6:"AAVZIP";s:2:"NO";s:10:"AAVADDRESS";s:2:"NO";s:6:"amount";s:2:"35";s:8:"currency";s:3:"EUR";s:2:"PM";s:10:"CreditCard";s:5:"BRAND";s:4:"VISA";s:7:"SCORING";s:1:"3";s:12:"SCO_CATEGORY";s:1:"O";s:5:"ALIAS";s:12:"041907169941";s:11:"NCERRORPLUS";s:1:"!";}s:28:"checkoutFinishedSuccessfully";b:1;}
|
423 |
+
method: 'checkmo'
|
424 |
+
|
425 |
+
sales/shipment:
|
426 |
+
- entity_id: 1
|
427 |
+
increment_id: 100000077
|
428 |
+
order_id: 11
|
429 |
+
shipping_address_id: 42
|
430 |
+
|
431 |
+
- entity_id: 2
|
432 |
+
increment_id: 100000078
|
433 |
+
order_id: 12
|
434 |
+
shipping_address_id: 43
|
435 |
+
|
436 |
+
sales/order_address:
|
437 |
+
- entity_id: 42
|
438 |
+
parent_id: 11
|
439 |
+
address_type: 'billing'
|
440 |
+
firstname: 'Hubertus'
|
441 |
+
postcode: '04229'
|
442 |
+
lastname: 'Fürstenberg'
|
443 |
+
street: 'An der Tabaksmühle 3a'
|
444 |
+
city: 'Leipzig'
|
445 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
446 |
+
country_id: 'DE'
|
447 |
+
prefix: 'Prof. Dr.'
|
448 |
+
middlename: 'von'
|
449 |
+
suffix: 'MdL'
|
450 |
+
company: ''
|
451 |
+
fax: 12345678
|
452 |
+
|
453 |
+
- entity_id: 43
|
454 |
+
parent_id: 11
|
455 |
+
address_type: 'shipping'
|
456 |
+
firstname: 'Hubertus'
|
457 |
+
postcode: '04229'
|
458 |
+
lastname: 'Fürstenberg'
|
459 |
+
street: 'An der Tabaksmühle 3a'
|
460 |
+
city: 'Leipzig'
|
461 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
462 |
+
country_id: 'DE'
|
463 |
+
prefix: 'Prof. Dr.'
|
464 |
+
middlename: 'von'
|
465 |
+
suffix: 'MdL'
|
466 |
+
company: ''
|
467 |
+
same_as_billing: 1
|
468 |
+
|
469 |
+
- entity_id: 44
|
470 |
+
parent_id: 12
|
471 |
+
address_type: 'billing'
|
472 |
+
firstname: 'Hubertus'
|
473 |
+
postcode: '04229'
|
474 |
+
lastname: 'Fürstenberg'
|
475 |
+
street: 'An der Tabaksmühle 3a'
|
476 |
+
city: 'Leipzig'
|
477 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
478 |
+
country_id: 'DE'
|
479 |
+
prefix: 'Prof. Dr.'
|
480 |
+
middlename: 'von'
|
481 |
+
suffix: 'MdL'
|
482 |
+
company: ''
|
483 |
+
|
484 |
+
- entity_id: 45
|
485 |
+
parent_id: 12
|
486 |
+
address_type: 'shipping'
|
487 |
+
firstname: 'Hubertus'
|
488 |
+
postcode: '04227'
|
489 |
+
lastname: 'Fürstenberg'
|
490 |
+
street: 'An der Tabaksmühle 3a'
|
491 |
+
city: 'Leipzig'
|
492 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
493 |
+
country_id: 'DE'
|
494 |
+
prefix: 'Prof. Dr.'
|
495 |
+
middlename: 'von'
|
496 |
+
suffix: 'MdL'
|
497 |
+
company: ''
|
498 |
+
same_as_billing: 1
|
499 |
+
|
500 |
+
- entity_id: 46
|
501 |
+
parent_id: 24
|
502 |
+
address_type: 'shipping'
|
503 |
+
firstname: 'Hubertus'
|
504 |
+
postcode: '04227'
|
505 |
+
lastname: 'Fürstenberg'
|
506 |
+
street: '44 rue Parmentier'
|
507 |
+
city: 'Leipzig'
|
508 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
509 |
+
country_id: 'DE'
|
510 |
+
prefix: 'Prof. Dr.'
|
511 |
+
middlename: 'von'
|
512 |
+
suffix: 'MdL'
|
513 |
+
company: ''
|
514 |
+
same_as_billing: 1
|
515 |
+
|
516 |
+
- entity_id: 47
|
517 |
+
parent_id: 27
|
518 |
+
address_type: 'billing'
|
519 |
+
firstname: 'Hubertus'
|
520 |
+
postcode: '04227'
|
521 |
+
lastname: 'Fürstenberg'
|
522 |
+
street: '44 rue Parmentier'
|
523 |
+
city: 'Leipzig'
|
524 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
525 |
+
country_id: 'DE'
|
526 |
+
prefix: 'Prof. Dr.'
|
527 |
+
middlename: 'von'
|
528 |
+
suffix: 'MdL'
|
529 |
+
company: ''
|
530 |
+
same_as_shipping: 1
|
531 |
+
|
532 |
+
- entity_id: 48
|
533 |
+
parent_id: 28
|
534 |
+
address_type: 'billing'
|
535 |
+
firstname: 'Hubertus'
|
536 |
+
postcode: '04227'
|
537 |
+
lastname: 'Fürstenberg'
|
538 |
+
street: '44 rue Parmentier'
|
539 |
+
city: 'Leipzig'
|
540 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
541 |
+
country_id: 'DE'
|
542 |
+
prefix: 'Prof. Dr.'
|
543 |
+
middlename: 'von'
|
544 |
+
suffix: 'MdL'
|
545 |
+
company: ''
|
546 |
+
|
547 |
+
- entity_id: 49
|
548 |
+
parent_id: 19
|
549 |
+
address_type: 'billing'
|
550 |
+
firstname: 'Hubertus'
|
551 |
+
postcode: '04227'
|
552 |
+
lastname: 'Fürstenberg'
|
553 |
+
street: '44 rue Parmentier'
|
554 |
+
city: 'Leipzig'
|
555 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
556 |
+
country_id: 'DE'
|
557 |
+
prefix: 'Prof. Dr.'
|
558 |
+
middlename: 'von'
|
559 |
+
suffix: 'MdL'
|
560 |
+
company: ''
|
561 |
+
|
562 |
+
- entity_id: 50
|
563 |
+
parent_id: 19
|
564 |
+
address_type: 'shipping'
|
565 |
+
firstname: 'Hubertus'
|
566 |
+
postcode: '04227'
|
567 |
+
lastname: 'Fürstenberg'
|
568 |
+
street: '44 rue Parmentier'
|
569 |
+
city: 'Leipzig'
|
570 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
571 |
+
country_id: 'DE'
|
572 |
+
prefix: 'Prof. Dr.'
|
573 |
+
middlename: 'von'
|
574 |
+
suffix: 'MdL'
|
575 |
+
company: ''
|
576 |
+
|
577 |
+
sales/order_item:
|
578 |
+
- item_id: 11
|
579 |
+
order_id: 11
|
580 |
+
qty_ordered: 2.0000
|
581 |
+
qty_shipped: 2.0000
|
582 |
+
sku: 4711
|
583 |
+
name: 'some great test item'
|
584 |
+
price: 19.99
|
585 |
+
tax_amount: 1.99
|
586 |
+
|
587 |
+
- item_id: 12
|
588 |
+
order_id: 11
|
589 |
+
qty_ordered: 2.0000
|
590 |
+
qty_shipped: 2.0000
|
591 |
+
sku: 4711
|
592 |
+
name: 'some great test item 2'
|
593 |
+
price: 19.99
|
594 |
+
tax_amount: 1.99
|
595 |
+
|
app/code/community/Netresearch/OPS/Test/Controller/ApiControllerTest.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Controller_ApiControllerTest
|
3 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
4 |
+
{
|
5 |
+
|
6 |
+
private $oldSeoValue = null;
|
7 |
+
|
8 |
+
private function setUpHelperMock($returnStatus, $setStoreId = true)
|
9 |
+
{
|
10 |
+
$paymentHelperMock = $this->getHelperMock(
|
11 |
+
'ops/payment', array('applyStateForOrder', 'shaCryptValidation')
|
12 |
+
);
|
13 |
+
$paymentHelperMock->expects($this->any())
|
14 |
+
->method('applyStateForOrder')
|
15 |
+
->will($this->returnValue($returnStatus));
|
16 |
+
|
17 |
+
$paymentHelperMock->expects($this->any())
|
18 |
+
->method('shaCryptValidation')
|
19 |
+
->will($this->returnValue(true));
|
20 |
+
$this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
|
21 |
+
|
22 |
+
$fakePayment = new Varien_Object();
|
23 |
+
$fakePayment->setMethodInstance(Mage::getModel('ops/payment_cc'));
|
24 |
+
|
25 |
+
$fakeOrder = new Varien_Object();
|
26 |
+
$fakeOrder->setPayment($fakePayment);
|
27 |
+
$fakeOrder->setId(1);
|
28 |
+
if ($setStoreId) {
|
29 |
+
$fakeOrder->setStoreId(1);
|
30 |
+
}
|
31 |
+
$orderHelperMock = $this->getHelperMock('ops/order', array('getOrder'));
|
32 |
+
$orderHelperMock->expects($this->any())
|
33 |
+
->method('getOrder')
|
34 |
+
->will($this->returnValue($fakeOrder));
|
35 |
+
$this->replaceByMock('helper', 'ops/order', $orderHelperMock);
|
36 |
+
}
|
37 |
+
|
38 |
+
private function getRequestParams()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
'orderID' => 1,
|
42 |
+
'SHASIGN' => '12344',
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
public function testRedirectToSuccessRoute()
|
47 |
+
{
|
48 |
+
$this->setUpHelperMock(
|
49 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT
|
50 |
+
);
|
51 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
52 |
+
$modelMock->expects($this->any())
|
53 |
+
->method('getId()')
|
54 |
+
->will($this->returnValue(null));
|
55 |
+
$this->replaceByMock('model', 'core/store', $modelMock);
|
56 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
57 |
+
$this->assertRedirectTo(
|
58 |
+
Mage::getModel('ops/config')->getAcceptRedirectRoute(),
|
59 |
+
array('_query' => $this->getRequestParams(), '_store' => 1)
|
60 |
+
);
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
public function testRedirectToSuccessRouteWithOrderId()
|
65 |
+
{
|
66 |
+
$this->setUpHelperMock(
|
67 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT
|
68 |
+
);
|
69 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
70 |
+
$modelMock->expects($this->any())
|
71 |
+
->method('getId()')
|
72 |
+
->will($this->returnValue(null));
|
73 |
+
$requestParams = $this->getRequestParams();
|
74 |
+
$requestParams['orderID'] = '#1000001';
|
75 |
+
$this->dispatch('ops/api/postBack', $requestParams);
|
76 |
+
$this->assertRedirectTo(
|
77 |
+
Mage::getModel('ops/config')->getAcceptRedirectRoute(),
|
78 |
+
array('_query' => $requestParams, '_store' => 1)
|
79 |
+
);
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
public function testRedirectToCancelRoute()
|
84 |
+
{
|
85 |
+
$this->setUpHelperMock(
|
86 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL
|
87 |
+
);
|
88 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
89 |
+
$modelMock->expects($this->any())
|
90 |
+
->method('getId()')
|
91 |
+
->will($this->returnValue(null));
|
92 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
93 |
+
$this->assertRedirectTo(
|
94 |
+
Mage::getModel('ops/config')->getCancelRedirectRoute(),
|
95 |
+
array('_query' => $this->getRequestParams(), '_store' => 1)
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
public function testRedirectToDeclineRoute()
|
100 |
+
{
|
101 |
+
$this->setUpHelperMock(
|
102 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE
|
103 |
+
);
|
104 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
105 |
+
$modelMock->expects($this->any())
|
106 |
+
->method('getId()')
|
107 |
+
->will($this->returnValue(null));
|
108 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
109 |
+
$this->assertRedirectTo(
|
110 |
+
Mage::getModel('ops/config')->getDeclineRedirectRoute(),
|
111 |
+
array('_query' => $this->getRequestParams(), '_store' => 1)
|
112 |
+
);
|
113 |
+
}
|
114 |
+
|
115 |
+
public function testRedirectToExceptionRoute()
|
116 |
+
{
|
117 |
+
$this->setUpHelperMock(
|
118 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION
|
119 |
+
);
|
120 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
121 |
+
$modelMock->expects($this->any())
|
122 |
+
->method('getId()')
|
123 |
+
->will($this->returnValue(null));
|
124 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
125 |
+
$this->assertRedirectTo(
|
126 |
+
Mage::getModel('ops/config')->getExceptionRedirectRoute(),
|
127 |
+
array('_query' => $this->getRequestParams(), '_store' => 1)
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
public function testExceptionReturnsStatus500()
|
132 |
+
{
|
133 |
+
$this->setUpHelperMock(
|
134 |
+
'INVALID_STATUS'
|
135 |
+
);
|
136 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
137 |
+
$modelMock->expects($this->any())
|
138 |
+
->method('getId()')
|
139 |
+
->will($this->returnValue(null));
|
140 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
141 |
+
$this->assertResponseHttpCode(500);
|
142 |
+
$this->getResponse();
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
public function testRedirectIfStoreIdDoesNotMatch()
|
147 |
+
{
|
148 |
+
$this->setUpHelperMock(
|
149 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
150 |
+
false
|
151 |
+
);
|
152 |
+
$modelMock = $this->getModelMock('core/store', array('getId'));
|
153 |
+
$modelMock->expects($this->any())
|
154 |
+
->method('getId()')
|
155 |
+
->will($this->returnValue(9999));
|
156 |
+
$this->replaceByMock('model', 'core/store', $modelMock);
|
157 |
+
$this->dispatch('ops/api/postBack', $this->getRequestParams());
|
158 |
+
$this->assertRedirectTo(
|
159 |
+
'ops/payment/accept', array('_query' => $this->getRequestParams(), '_store' => 1)
|
160 |
+
);
|
161 |
+
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/DeviceControllerTest.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* DeviceControllerTest.php
|
24 |
+
*
|
25 |
+
* @category ${CATEGORY}
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Controller_DeviceControllerTest extends EcomDev_PHPUnit_Test_Case_Controller
|
34 |
+
{
|
35 |
+
public function testToggleConsentAction()
|
36 |
+
{
|
37 |
+
|
38 |
+
$params = array('consent' => true, '_store' => 1);
|
39 |
+
$this->dispatch('ops/device/toggleConsent', $params);
|
40 |
+
$this->assertResponseBodyJson();
|
41 |
+
$this->assertResponseBodyJsonMatch(array('consent' => false));
|
42 |
+
|
43 |
+
Mage::app()->getStore(1)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'device_fingerprinting', 1);
|
44 |
+
$this->dispatch('ops/device/toggleConsent', $params);
|
45 |
+
$this->assertResponseBodyJson();
|
46 |
+
$this->assertResponseBodyJsonMatch(array('consent' => true));
|
47 |
+
}
|
48 |
+
|
49 |
+
public function testConsentAction()
|
50 |
+
{
|
51 |
+
$this->dispatch('ops/device/consent');
|
52 |
+
$this->assertResponseBodyJson();
|
53 |
+
$this->assertResponseBodyJsonMatch(array('consent' => false));
|
54 |
+
|
55 |
+
$params = array('consent' => true, '_store' => 1);
|
56 |
+
Mage::app()->getStore(1)->setConfig(Netresearch_OPS_Model_Config::OPS_PAYMENT_PATH.'device_fingerprinting', 1);
|
57 |
+
$this->dispatch('ops/device/toggleConsent', $params);
|
58 |
+
$this->assertResponseBodyJson();
|
59 |
+
$this->assertResponseBodyJsonMatch(array('consent' => true));
|
60 |
+
|
61 |
+
$this->dispatch('ops/device/consent');
|
62 |
+
$this->assertResponseBodyJson();
|
63 |
+
$this->assertResponseBodyJsonMatch(array('consent' => true));
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest.php
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Controller_PaymentControllerTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
5 |
+
{
|
6 |
+
|
7 |
+
public function setUp()
|
8 |
+
{
|
9 |
+
parent::setUp();
|
10 |
+
$helperMock = $this->getHelperMock(
|
11 |
+
'ops/payment', array(
|
12 |
+
'shaCryptValidation',
|
13 |
+
'cancelOrder',
|
14 |
+
'declineOrder',
|
15 |
+
'handleException',
|
16 |
+
'getSHAInSet',
|
17 |
+
'refillCart'
|
18 |
+
)
|
19 |
+
);
|
20 |
+
$helperMock->expects($this->any())
|
21 |
+
->method('shaCryptValidation')
|
22 |
+
->will($this->returnValue(true));
|
23 |
+
|
24 |
+
$this->replaceByMock('helper', 'ops/payment', $helperMock);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
29 |
+
*/
|
30 |
+
public function testAcceptAction()
|
31 |
+
{
|
32 |
+
$params = array();
|
33 |
+
$this->dispatch('ops/payment/accept', $params);
|
34 |
+
$this->assertRedirect('checkout/cart');
|
35 |
+
|
36 |
+
|
37 |
+
$params = array(
|
38 |
+
'orderID' => '#100000011'
|
39 |
+
);
|
40 |
+
$this->dispatch('ops/payment/accept', $params);
|
41 |
+
$this->assertRedirect('checkout/onepage/success');
|
42 |
+
|
43 |
+
$params = array(
|
44 |
+
'orderID' => '23'
|
45 |
+
);
|
46 |
+
$this->dispatch('ops/payment/accept', $params);
|
47 |
+
$this->assertRedirect('checkout/onepage/success');
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
53 |
+
*/
|
54 |
+
public function testExceptionAction()
|
55 |
+
{
|
56 |
+
$params = array();
|
57 |
+
$this->dispatch('ops/payment/exception', $params);
|
58 |
+
$this->assertRedirect('checkout/cart');
|
59 |
+
|
60 |
+
$params = array(
|
61 |
+
'orderID' => '#100000011'
|
62 |
+
);
|
63 |
+
$this->dispatch('ops/payment/exception', $params);
|
64 |
+
$this->assertRedirect('checkout/onepage/success');
|
65 |
+
|
66 |
+
$params = array(
|
67 |
+
'orderID' => '23'
|
68 |
+
);
|
69 |
+
$this->dispatch('ops/payment/exception', $params);
|
70 |
+
$this->assertRedirect('checkout/onepage/success');
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
76 |
+
*/
|
77 |
+
public function testDeclineAction()
|
78 |
+
{
|
79 |
+
$routeToDispatch = 'ops/payment/decline';
|
80 |
+
$params = array();
|
81 |
+
$this->dispatch($routeToDispatch, $params);
|
82 |
+
$this->assertRedirect('checkout/onepage');
|
83 |
+
|
84 |
+
|
85 |
+
$params = array(
|
86 |
+
'orderID' => '#100000011'
|
87 |
+
);
|
88 |
+
$this->dispatch($routeToDispatch, $params);
|
89 |
+
$this->assertRedirect('checkout/onepage');
|
90 |
+
|
91 |
+
$params = array(
|
92 |
+
'orderID' => '23'
|
93 |
+
);
|
94 |
+
$this->dispatch($routeToDispatch, $params);
|
95 |
+
$this->assertRedirect('checkout/onepage');
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
101 |
+
*/
|
102 |
+
public function testCancelAction()
|
103 |
+
{
|
104 |
+
$routeToDispatch = 'ops/payment/cancel';
|
105 |
+
$params = array();
|
106 |
+
$this->dispatch($routeToDispatch, $params);
|
107 |
+
$this->assertRedirect('checkout/onepage');
|
108 |
+
|
109 |
+
$params = array(
|
110 |
+
'orderID' => '#100000011'
|
111 |
+
);
|
112 |
+
$this->dispatch($routeToDispatch, $params);
|
113 |
+
$this->assertRedirect('checkout/onepage');
|
114 |
+
|
115 |
+
$params = array(
|
116 |
+
'orderID' => '23'
|
117 |
+
);
|
118 |
+
$this->dispatch($routeToDispatch, $params);
|
119 |
+
$this->assertRedirect('checkout/onepage');
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
125 |
+
*/
|
126 |
+
public function testContinueAction()
|
127 |
+
{
|
128 |
+
$routeToDispatch = 'ops/payment/continue';
|
129 |
+
$params = array();
|
130 |
+
$this->dispatch($routeToDispatch, $params);
|
131 |
+
$this->assertRedirect('checkout/cart');
|
132 |
+
|
133 |
+
|
134 |
+
$params = array(
|
135 |
+
'orderID' => '#100000011'
|
136 |
+
);
|
137 |
+
$this->dispatch($routeToDispatch, $params);
|
138 |
+
$this->assertRedirect('checkout/cart');
|
139 |
+
|
140 |
+
$params = array(
|
141 |
+
'orderID' => '23'
|
142 |
+
);
|
143 |
+
$this->dispatch($routeToDispatch, $params);
|
144 |
+
$this->assertRedirect('checkout/cart');
|
145 |
+
|
146 |
+
$params = array(
|
147 |
+
'orderID' => '#100000011',
|
148 |
+
'redirect' => 'catalog'
|
149 |
+
);
|
150 |
+
$this->dispatch($routeToDispatch, $params);
|
151 |
+
$this->assertRedirect('/');
|
152 |
+
|
153 |
+
$params = array(
|
154 |
+
'orderID' => '23',
|
155 |
+
'redirect' => 'catalog'
|
156 |
+
);
|
157 |
+
$this->dispatch($routeToDispatch, $params);
|
158 |
+
$this->assertRedirect('/');
|
159 |
+
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
165 |
+
*/
|
166 |
+
public function testRepayActionWithInvalidHash()
|
167 |
+
{
|
168 |
+
// test 1: hash not valid
|
169 |
+
$order = Mage::getModel('sales/order')->load(11);
|
170 |
+
$opsOrderId = Mage::helper('ops/order')->getOpsOrderId($order);
|
171 |
+
|
172 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('shaCryptValidation'));
|
173 |
+
$paymentHelperMock->expects($this->any())
|
174 |
+
->method('shaCryptValidation')
|
175 |
+
->will($this->returnValue(false));
|
176 |
+
$this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
|
177 |
+
|
178 |
+
|
179 |
+
$params = array('orderID' => $opsOrderId, 'SHASIGN' => 'foo');
|
180 |
+
$this->dispatch('ops/payment/retry', $params);
|
181 |
+
$this->assertRedirectTo('/');
|
182 |
+
$message = Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage();
|
183 |
+
$this->assertNotNull($message);
|
184 |
+
$this->assertEquals($message->getText(), 'Hash not valid');
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
190 |
+
*/
|
191 |
+
public function testRepayActionWithInvalidOrder()
|
192 |
+
{
|
193 |
+
|
194 |
+
// test 1: hash valid, order can not be retried
|
195 |
+
// orderID 100000011
|
196 |
+
$order = Mage::getModel('sales/order')->load(11);
|
197 |
+
$opsOrderId = Mage::helper('ops/order')->getOpsOrderId($order);
|
198 |
+
|
199 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('shaCryptValidation'));
|
200 |
+
$paymentHelperMock->expects($this->any())
|
201 |
+
->method('shaCryptValidation')
|
202 |
+
->will($this->returnValue(true));
|
203 |
+
$this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
|
204 |
+
|
205 |
+
$params = array(
|
206 |
+
'orderID' => $opsOrderId,
|
207 |
+
'SHASIGN' => 'foo'
|
208 |
+
);
|
209 |
+
$this->dispatch('ops/payment/retry', $params);
|
210 |
+
$this->assertRedirectTo('/');
|
211 |
+
$message = Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage();
|
212 |
+
$this->assertNotNull($message);
|
213 |
+
$this->assertEquals(
|
214 |
+
$message->getText(), 'Not possible to reenter the payment details for order ' . $order->getIncrementId()
|
215 |
+
);
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
221 |
+
*/
|
222 |
+
public function testRepayActionWithSuccess()
|
223 |
+
{
|
224 |
+
// test 3: order is fine
|
225 |
+
// orderID 100000013
|
226 |
+
|
227 |
+
$order = Mage::getModel('sales/order')->load(13);
|
228 |
+
$opsOrderId = Mage::helper('ops/order')->getOpsOrderId($order);
|
229 |
+
|
230 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('shaCryptValidation'));
|
231 |
+
$paymentHelperMock->expects($this->any())
|
232 |
+
->method('shaCryptValidation')
|
233 |
+
->will($this->returnValue(true));
|
234 |
+
$this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
|
235 |
+
|
236 |
+
$params = array(
|
237 |
+
'orderID' => $opsOrderId,
|
238 |
+
'SHASIGN' => 'foo'
|
239 |
+
);
|
240 |
+
|
241 |
+
$this->dispatch('ops/payment/retry', $params);
|
242 |
+
$this->assertLayoutLoaded();
|
243 |
+
$this->assertLayoutHandleLoaded('ops_payment_retry');
|
244 |
+
|
245 |
+
}
|
246 |
+
}
|
app/code/community/Netresearch/OPS/Test/Controller/PaymentControllerTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/AliasTest.php
ADDED
@@ -0,0 +1,733 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* To change this template, choose Tools | Templates
|
4 |
+
* and open the template in the editor.
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Description of AliasTest
|
9 |
+
*
|
10 |
+
* @author sebastian
|
11 |
+
*/
|
12 |
+
class Netresearch_OPS_Test_Helper_AliasTest extends EcomDev_PHPUnit_Test_Case
|
13 |
+
{
|
14 |
+
|
15 |
+
private $_helper;
|
16 |
+
private $store;
|
17 |
+
|
18 |
+
public function setUp()
|
19 |
+
{
|
20 |
+
parent::setup();
|
21 |
+
$this->_helper = Mage::helper('ops/alias');
|
22 |
+
$this->store = Mage::app()->getStore(0)->load(0);
|
23 |
+
$this->mockSessions();
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function mockSessions()
|
27 |
+
{
|
28 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
29 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
30 |
+
->getMock();
|
31 |
+
$this->replaceByMock('singleton', 'checkout/session', $sessionMock);
|
32 |
+
|
33 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
34 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
35 |
+
->getMock();
|
36 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function mockCheckoutOnepage($method)
|
40 |
+
{
|
41 |
+
$onepage = $this->getModelMock('checkout/type_onepage', array('getCheckoutMethod'));
|
42 |
+
$onepage->expects($this->any())
|
43 |
+
->method('getCheckoutMehtod')
|
44 |
+
->will($this->returnValue($method));
|
45 |
+
$this->replaceByMock('singleton', 'checkout/type_onepage', $onepage);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
50 |
+
*/
|
51 |
+
public function testGetAliasWithoutAdditionalInformation()
|
52 |
+
{
|
53 |
+
$aliasHelperMock = $this->getHelperMock('ops/alias', array('isAdminSession'));
|
54 |
+
$aliasHelperMock->expects($this->any())
|
55 |
+
->method('isAdminSession')
|
56 |
+
->will($this->returnValue(false));
|
57 |
+
$quote = Mage::getModel('sales/quote')->load(11);
|
58 |
+
|
59 |
+
$alias = $aliasHelperMock->getAlias($quote);
|
60 |
+
|
61 |
+
$this->assertTrue(
|
62 |
+
strlen($aliasHelperMock->getAlias($quote)) <= 16
|
63 |
+
);
|
64 |
+
$this->assertTrue(
|
65 |
+
strpos($aliasHelperMock->getAlias($quote), "99") != false
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
public function testGetAliasWithAdditionalInformation()
|
70 |
+
{
|
71 |
+
$quote = new Varien_Object();
|
72 |
+
$payment = new Varien_Object();
|
73 |
+
$payment->setAdditionalInformation(array('alias' => 'testAlias'));
|
74 |
+
$quote->setPayment($payment);
|
75 |
+
|
76 |
+
$aliasHelperMock = $this->getHelperMock('ops/alias', array('isAdminSession'));
|
77 |
+
$aliasHelperMock->expects($this->any())
|
78 |
+
->method('isAdminSession')
|
79 |
+
->will($this->returnValue(false));
|
80 |
+
|
81 |
+
$this->assertEquals(
|
82 |
+
'testAlias', $aliasHelperMock->getAlias($quote)
|
83 |
+
);
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
public function testGetOpsCode()
|
89 |
+
{
|
90 |
+
$this->assertEquals(null, Mage::helper('ops/alias')->getOpsCode());
|
91 |
+
}
|
92 |
+
|
93 |
+
public function testGetOpsBrand()
|
94 |
+
{
|
95 |
+
$this->assertEquals(null, Mage::helper('ops/alias')->getOpsBrand());
|
96 |
+
}
|
97 |
+
|
98 |
+
public function testSaveAliasIfCustomerIsNotLoggedIn()
|
99 |
+
{
|
100 |
+
$this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
101 |
+
$quote = Mage::getModel('sales/quote');
|
102 |
+
$this->assertEquals(
|
103 |
+
null,
|
104 |
+
$this->_helper->saveAlias(array(
|
105 |
+
'OrderID' => 4711,
|
106 |
+
'StorePermanently' => 'N'
|
107 |
+
))
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
public function testSaveAliasIfCustomerIsLoggedIn()
|
112 |
+
{
|
113 |
+
$this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER);
|
114 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
115 |
+
$quote = $this->getModelMock('sales/quote', array('save'));
|
116 |
+
$this->replaceByMock('model', 'sales/quote', $quote);
|
117 |
+
$quote->setBillingAddress($this->getAddressData());
|
118 |
+
$quote->setShippingAddress($this->getAddressData());
|
119 |
+
$quote->setId(4711);
|
120 |
+
$customer = Mage::getModel('customer/customer');
|
121 |
+
$customer->setId(1);
|
122 |
+
$aliasData['Alias_OrderId'] = 4711;
|
123 |
+
$aliasData['Alias_AliasId'] = 4711;
|
124 |
+
$aliasData['Card_Brand'] = 'Visa';
|
125 |
+
$aliasData['Card_CardNumber'] = 'xxxx0815';
|
126 |
+
$aliasData['Card_ExpiryDate'] = '1212';
|
127 |
+
$aliasData['Card_CardHolderName'] = 'Foo Baar';
|
128 |
+
$aliasData['Alias_StorePermanently'] = 'Y';
|
129 |
+
$payment = $this->getModelMock('sales/quote_payment', array('save'));
|
130 |
+
$payment->setMethod('CreditCard');
|
131 |
+
$payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
|
132 |
+
// $quote->setCustomer($customer);
|
133 |
+
$quote->setPayment($payment);
|
134 |
+
|
135 |
+
$quoteMock = $this->getModelMock(
|
136 |
+
'sales/quote', array('load', 'getPayment', 'getCustomer')
|
137 |
+
);
|
138 |
+
$quoteMock->expects($this->any())
|
139 |
+
->method('load')
|
140 |
+
->will($this->returnValue($quoteMock));
|
141 |
+
$quoteMock->expects($this->any())
|
142 |
+
->method('getPayment')
|
143 |
+
->will($this->returnValue($payment));
|
144 |
+
$quoteMock->expects($this->any())
|
145 |
+
->method('getCustomer')
|
146 |
+
->will($this->returnValue($customer));
|
147 |
+
$this->replaceByMock('model', 'sales/quote', $quoteMock);
|
148 |
+
$alias = $this->_helper->saveAlias($aliasData);
|
149 |
+
$this->assertEquals('4711', $alias->getAlias());
|
150 |
+
$this->assertEquals('Visa', $alias->getBrand());
|
151 |
+
$this->assertEquals('xxxx0815', $alias->getPseudoAccountOrCcNo());
|
152 |
+
$this->assertEquals('1212', $alias->getExpirationDate());
|
153 |
+
$this->assertEquals(
|
154 |
+
'da39a3ee5e6b4b0d3255bfef95601890afd80709',
|
155 |
+
$alias->getBillingAddressHash()
|
156 |
+
);
|
157 |
+
$this->assertEquals(
|
158 |
+
'da39a3ee5e6b4b0d3255bfef95601890afd80709',
|
159 |
+
$alias->getShippingAddressHash()
|
160 |
+
);
|
161 |
+
$this->assertEquals('CreditCard', $alias->getPaymentMethod());
|
162 |
+
$this->assertEquals(1, $alias->getCustomerId());
|
163 |
+
|
164 |
+
$oldAliasId = $alias->getId();
|
165 |
+
$alias = $this->_helper->saveAlias($aliasData, $quote);
|
166 |
+
$this->assertNotEquals($oldAliasId, $alias->getId());
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
171 |
+
*/
|
172 |
+
public function testSaveAliasUpdate()
|
173 |
+
{
|
174 |
+
$this->mockCheckoutOnepage(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER);
|
175 |
+
$quote = $this->getModelMock('sales/quote', array('save'));
|
176 |
+
$this->replaceByMock('model', 'sales/quote', $quote);
|
177 |
+
$quote->setBillingAddress($this->getAddressData());
|
178 |
+
$quote->setShippingAddress($this->getAddressData());
|
179 |
+
$quote->setId(4711);
|
180 |
+
$customer = new Varien_Object();
|
181 |
+
$customer->setId(1);
|
182 |
+
$aliasData['Alias_OrderId'] = 4711;
|
183 |
+
$aliasData['Alias_AliasId'] = 4711;
|
184 |
+
$aliasData['Card_Brand'] = 'Visa';
|
185 |
+
$aliasData['Card_CardNumber'] = 'xxxx0815';
|
186 |
+
$aliasData['Card_ExpiryDate'] = '1212';
|
187 |
+
$aliasData['Card_CardHolderName'] = 'Foo Baar';
|
188 |
+
$aliasData['Alias_StorePermanently'] = 'Y';
|
189 |
+
$payment = $this->getModelMock('sales/quote_payment', array('save'));
|
190 |
+
$payment->setMethod('CreditCard');
|
191 |
+
$payment->setAdditionalInformation(array('saveOpsAlias' => '1'));
|
192 |
+
// $quote->setCustomer($customer);
|
193 |
+
$quote->setPayment($payment);
|
194 |
+
|
195 |
+
$quoteMock = $this->getModelMock(
|
196 |
+
'sales/quote', array('load', 'getPayment', 'getCustomer')
|
197 |
+
);
|
198 |
+
$quoteMock->expects($this->any())
|
199 |
+
->method('load')
|
200 |
+
->will($this->returnValue($quoteMock));
|
201 |
+
$quoteMock->expects($this->any())
|
202 |
+
->method('getPayment')
|
203 |
+
->will($this->returnValue($payment));
|
204 |
+
$quoteMock->expects($this->any())
|
205 |
+
->method('getCustomer')
|
206 |
+
->will($this->returnValue($customer));
|
207 |
+
$this->replaceByMock('model', 'sales/quote', $quoteMock);
|
208 |
+
$oldAlias = $this->_helper->saveAlias($aliasData);
|
209 |
+
$oldAlias->setState(Netresearch_OPS_Model_Alias_State::ACTIVE);
|
210 |
+
$oldAlias->save();
|
211 |
+
|
212 |
+
$aliasData['Alias_OrderId'] = 4711;
|
213 |
+
$aliasData['Alias_AliasId'] = 4711;
|
214 |
+
$aliasData['Card_Brand'] = 'Mastercard';
|
215 |
+
$aliasData['Card_CardNumber'] = 'xxxx01111';
|
216 |
+
$aliasData['Card_ExpiryDate'] = '1213';
|
217 |
+
$aliasData['Card_CardHolderName'] = 'Max Power';
|
218 |
+
$aliasData['Alias_StorePermanently'] = 'Y';
|
219 |
+
|
220 |
+
$updatedAlias = $this->_helper->saveAlias($aliasData);
|
221 |
+
$this->assertEquals(4711,$updatedAlias->getAlias());
|
222 |
+
$this->assertEquals('Mastercard',$updatedAlias->getBrand());
|
223 |
+
$this->assertEquals('xxxx01111',$updatedAlias->getPseudoAccountOrCcNo());
|
224 |
+
$this->assertEquals('1213',$updatedAlias->getExpirationDate());
|
225 |
+
$this->assertEquals('Max Power',$updatedAlias->getCardHolder());
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
231 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
232 |
+
*/
|
233 |
+
public function testSaveNewAlias()
|
234 |
+
{
|
235 |
+
$reflection_class = new ReflectionClass("Netresearch_OPS_Helper_Alias");
|
236 |
+
$method = $reflection_class->getMethod("saveNewAlias");
|
237 |
+
$method->setAccessible(true);
|
238 |
+
|
239 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
240 |
+
$aliasData = array(
|
241 |
+
'Alias_AliasId' => 'TestAlias',
|
242 |
+
'Card_ExpiryDate' => '12.12.0012',
|
243 |
+
'Card_Brand' => 'Visa',
|
244 |
+
'Card_CardNumber' => '12345678',
|
245 |
+
'Card_CardHolderName' => 'Foo',
|
246 |
+
'Alias_StorePermanently' => 'Y'
|
247 |
+
);
|
248 |
+
$aliasHelper = Mage::helper('ops/alias');
|
249 |
+
$alias = $method->invoke($aliasHelper, $quote, $aliasData);
|
250 |
+
$this->assertEquals('TestAlias', $alias->getAlias());
|
251 |
+
$this->assertEquals('12.12.0012', $alias->getExpirationDate());
|
252 |
+
$this->assertEquals('Foo', $alias->getCardHolder());
|
253 |
+
$this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
|
254 |
+
|
255 |
+
$aliasData = array(
|
256 |
+
'Alias_AliasId' => 'TestAlias',
|
257 |
+
'Card_ExpiryDate' => '12.12.0012',
|
258 |
+
'Card_Brand' => 'Visa',
|
259 |
+
'Card_CardNumber' => '12345678',
|
260 |
+
'Alias_StorePermanently' => 'Y'
|
261 |
+
);
|
262 |
+
$aliasHelper = Mage::helper('ops/alias');
|
263 |
+
$alias = $method->invoke($aliasHelper, $quote, $aliasData);
|
264 |
+
$this->assertEquals('TestAlias', $alias->getAlias());
|
265 |
+
$this->assertEquals('12.12.0012', $alias->getExpirationDate());
|
266 |
+
$this->assertNull($alias->getCardHolder());
|
267 |
+
$this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
|
268 |
+
|
269 |
+
$aliasData = array(
|
270 |
+
'Alias_AliasId' => 'TestAlias',
|
271 |
+
'Card_ExpiryDate' => '12.12.0012',
|
272 |
+
'Card_Brand' => 'Visa',
|
273 |
+
'Card_CardNumber' => '12345678',
|
274 |
+
'Card_CardHolderName' => '',
|
275 |
+
'Alias_StorePermanently' => 'Y'
|
276 |
+
);
|
277 |
+
$aliasHelper = Mage::helper('ops/alias');
|
278 |
+
$alias = $method->invoke($aliasHelper, $quote, $aliasData);
|
279 |
+
$this->assertEquals('TestAlias', $alias->getAlias());
|
280 |
+
$this->assertEquals('12.12.0012', $alias->getExpirationDate());
|
281 |
+
$this->assertEquals('', $alias->getCardHolder());
|
282 |
+
$this->assertEquals(Netresearch_OPS_Model_Alias_State::PENDING, $alias->getState());
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
287 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
288 |
+
*/
|
289 |
+
public function testDeleteAlias()
|
290 |
+
{
|
291 |
+
$reflection_class = new ReflectionClass("Netresearch_OPS_Helper_Alias");
|
292 |
+
$method = $reflection_class->getMethod("deleteAlias");
|
293 |
+
$method->setAccessible(true);
|
294 |
+
$aliasModel = Mage::getModel('ops/alias');
|
295 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
296 |
+
$quote->setBillingAddress($this->getAddressData());
|
297 |
+
$quote->setShippingAddress($this->getAddressData());
|
298 |
+
$customer = Mage::getModel('customer/customer');
|
299 |
+
$customer->setId(1);
|
300 |
+
|
301 |
+
$quote->setCustomer($customer);
|
302 |
+
|
303 |
+
$customerId = $quote->getCustomer()->getId();
|
304 |
+
$aliasesForCustomer = $aliasCollection = $aliasModel->getCollection()
|
305 |
+
->addFieldToFilter('customer_id', $customerId)
|
306 |
+
->load();
|
307 |
+
$oldAliasSize = count($aliasesForCustomer);
|
308 |
+
|
309 |
+
$aliasData = array(
|
310 |
+
'Alias_AliasId' => '4711',
|
311 |
+
'Card_ExpiryDate' => '0117',
|
312 |
+
'Card_Brand' => 'Visa',
|
313 |
+
'Card_CardNumber' => 'xxxx1111'
|
314 |
+
);
|
315 |
+
$aliasHelper = Mage::helper('ops/alias');
|
316 |
+
$method->invoke($aliasHelper, $quote, $aliasData);
|
317 |
+
$newAliasForCustomer = $aliasCollection = $aliasModel->getCollection()
|
318 |
+
->addFieldToFilter('customer_id', $customerId)
|
319 |
+
->load();
|
320 |
+
$newAliasSize = count($newAliasForCustomer);
|
321 |
+
$this->assertGreaterThan($newAliasSize, $oldAliasSize);
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
326 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
327 |
+
*/
|
328 |
+
public function testDeleteAliasDoesNotDeleteAliasIfAddressDoesNotMatch()
|
329 |
+
{
|
330 |
+
$reflection_class = new ReflectionClass("Netresearch_OPS_Helper_Alias");
|
331 |
+
$method = $reflection_class->getMethod("deleteAlias");
|
332 |
+
$method->setAccessible(true);
|
333 |
+
$aliasModel = Mage::getModel('ops/alias');
|
334 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
335 |
+
$customer = Mage::getModel('customer/customer');
|
336 |
+
$customer->setId(1);
|
337 |
+
|
338 |
+
$quote->setCustomer($customer);
|
339 |
+
|
340 |
+
$customerId = $quote->getCustomer()->getId();
|
341 |
+
$aliasesForCustomer = $aliasCollection = $aliasModel->getCollection()
|
342 |
+
->addFieldToFilter('customer_id', $customerId)
|
343 |
+
->load();
|
344 |
+
$oldAliasSize = count($aliasesForCustomer);
|
345 |
+
|
346 |
+
$aliasData = array(
|
347 |
+
'Alias_AliasId' => '4711',
|
348 |
+
'Card_ExpiryDate' => '0117',
|
349 |
+
'Card_Brand' => 'Visa',
|
350 |
+
'Card_CardNumber' => 'xxxx1111'
|
351 |
+
);
|
352 |
+
$aliasHelper = Mage::helper('ops/alias');
|
353 |
+
$method->invoke($aliasHelper, $quote, $aliasData);
|
354 |
+
$newAliasForCustomer = $aliasCollection = $aliasModel->getCollection()
|
355 |
+
->addFieldToFilter('customer_id', $customerId)
|
356 |
+
->load();
|
357 |
+
$newAliasSize = count($newAliasForCustomer);
|
358 |
+
$this->assertEquals($newAliasSize, $oldAliasSize);
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
363 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
364 |
+
*/
|
365 |
+
public function testGetAliasesForCustomer()
|
366 |
+
{
|
367 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
368 |
+
|
369 |
+
$aliasesCollection = $this->_helper->getAliasesForCustomer(1);
|
370 |
+
$this->assertEquals(5, count($aliasesCollection));
|
371 |
+
|
372 |
+
$aliasesCollection = $this->_helper->getAliasesForCustomer(2);
|
373 |
+
$this->assertEquals(1, count($aliasesCollection));
|
374 |
+
|
375 |
+
$aliasesCollection = $this->_helper->getAliasesForCustomer(3);
|
376 |
+
$this->assertEquals(0, count($aliasesCollection));
|
377 |
+
|
378 |
+
$aliasesCollection = $this->_helper->getAliasesForCustomer(
|
379 |
+
null, $quote
|
380 |
+
);
|
381 |
+
$this->assertEquals(0, count($aliasesCollection));
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
386 |
+
*/
|
387 |
+
public function testIsAliasValidForAddresses()
|
388 |
+
{
|
389 |
+
$billingAddress = Mage::getModel('sales/quote_address');
|
390 |
+
$shippingAddress = Mage::getModel('sales/quote_address');
|
391 |
+
$this->assertFalse(
|
392 |
+
$this->_helper->isAliasValidForAddresses(
|
393 |
+
1, '4711', $shippingAddress, $billingAddress
|
394 |
+
)
|
395 |
+
);
|
396 |
+
|
397 |
+
$billingAddress = $this->getAddressData();
|
398 |
+
$shippingAddress = $this->getAddressData();
|
399 |
+
|
400 |
+
$this->assertTrue(
|
401 |
+
$this->_helper->isAliasValidForAddresses(
|
402 |
+
1, '4711', $shippingAddress, $billingAddress
|
403 |
+
)
|
404 |
+
);
|
405 |
+
|
406 |
+
$this->assertFalse(
|
407 |
+
$this->_helper->isAliasValidForAddresses(
|
408 |
+
2, '4711', $shippingAddress, $billingAddress
|
409 |
+
)
|
410 |
+
);
|
411 |
+
}
|
412 |
+
|
413 |
+
protected function getAddressData()
|
414 |
+
{
|
415 |
+
$address = new Mage_Sales_Model_Quote_Address();
|
416 |
+
$address->setFirstname('foo');
|
417 |
+
$address->setLastname('bert');
|
418 |
+
$address->setStreet1('bla street 1');
|
419 |
+
$address->setZipcode('4711');
|
420 |
+
$address->setCity('Cologne');
|
421 |
+
$address->setCountry_id(1);
|
422 |
+
return $address;
|
423 |
+
}
|
424 |
+
|
425 |
+
public function testGenerateAddressHash()
|
426 |
+
{
|
427 |
+
$address = $this->getAddressData();
|
428 |
+
$this->assertEquals(
|
429 |
+
'1b9ecdf409e240717f04b7155712658ab09116bb',
|
430 |
+
$this->_helper->generateAddressHash($address)
|
431 |
+
);
|
432 |
+
$address->setData('street', array('wuseldusel', 'foo'));
|
433 |
+
$this->assertEquals(
|
434 |
+
'260a9287b2964d3674f49f589d5e5fd7143041cf',
|
435 |
+
$this->_helper->generateAddressHash($address)
|
436 |
+
);
|
437 |
+
}
|
438 |
+
|
439 |
+
public function testFormatAliasCardNo()
|
440 |
+
{
|
441 |
+
$helper = Mage::helper('ops/alias');
|
442 |
+
$cardNo = 'xxxxxxxxxxxx1111';
|
443 |
+
$cardType = 'VISA';
|
444 |
+
$this->assertEquals(
|
445 |
+
'XXXX XXXX XXXX 1111',
|
446 |
+
$helper->formatAliasCardNo($cardType, $cardNo)
|
447 |
+
);
|
448 |
+
|
449 |
+
$cardNo = 'xxxxxxxxxxxx9999';
|
450 |
+
$cardType = 'MasterCard';
|
451 |
+
$this->assertEquals(
|
452 |
+
'XXXX XXXX XXXX 9999',
|
453 |
+
$helper->formatAliasCardNo($cardType, $cardNo)
|
454 |
+
);
|
455 |
+
|
456 |
+
$cardNo = '3750-xxxxxx-03';
|
457 |
+
$cardType = 'american express';
|
458 |
+
$this->assertEquals(
|
459 |
+
'3750 XXXXXX 03', $helper->formatAliasCardNo($cardType, $cardNo)
|
460 |
+
);
|
461 |
+
|
462 |
+
$cardNo = '3750-xxxxxx-03';
|
463 |
+
$cardType = 'DINERS CLUB';
|
464 |
+
$this->assertEquals(
|
465 |
+
'3750 XXXXXX 03', $helper->formatAliasCardNo($cardType, $cardNo)
|
466 |
+
);
|
467 |
+
|
468 |
+
|
469 |
+
$cardNo = '675941-XXXXXXXX-08';
|
470 |
+
$cardType = 'MaestroUK';
|
471 |
+
$this->assertEquals(
|
472 |
+
'675941 XXXXXXXX 08', $helper->formatAliasCardNo($cardType, $cardNo)
|
473 |
+
);
|
474 |
+
|
475 |
+
$cardNo = '675956-XXXXXXXX-54';
|
476 |
+
$cardType = 'MaestroUK';
|
477 |
+
$this->assertEquals(
|
478 |
+
'675956 XXXXXXXX 54', $helper->formatAliasCardNo($cardType, $cardNo)
|
479 |
+
);
|
480 |
+
|
481 |
+
$cardNo = '564182-XXXXXXXX-69';
|
482 |
+
$cardType = 'MaestroUK';
|
483 |
+
$this->assertEquals(
|
484 |
+
'564182 XXXXXXXX 69', $helper->formatAliasCardNo($cardType, $cardNo)
|
485 |
+
);
|
486 |
+
|
487 |
+
$cardNo = '3750-xxxxxx-03';
|
488 |
+
$cardType = 'PostFinance Card';
|
489 |
+
$this->assertEquals(
|
490 |
+
'3750-XXXXXX-03', $helper->formatAliasCardNo($cardType, $cardNo)
|
491 |
+
);
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
*
|
496 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
497 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
498 |
+
*/
|
499 |
+
public function testSetAliasToPayment()
|
500 |
+
{
|
501 |
+
$params = array();
|
502 |
+
$quote = Mage::getModel('sales/quote')->load(11);
|
503 |
+
$helper = Mage::helper('ops/alias');
|
504 |
+
$helper->setAliasToPayment($quote->getPayment(), $params);
|
505 |
+
$payment = $quote->getPayment();
|
506 |
+
$this->assertArrayNotHasKey('alias', $payment->getAdditionalInformation());
|
507 |
+
$this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
|
508 |
+
|
509 |
+
$params = array(
|
510 |
+
'alias_aliasid' => '4711'
|
511 |
+
);
|
512 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
513 |
+
$helper = Mage::helper('ops/alias');
|
514 |
+
$helper->setAliasToPayment($quote->getPayment(), $params);
|
515 |
+
$payment = $quote->getPayment();
|
516 |
+
|
517 |
+
$this->assertArrayHasKey('alias', $payment->getAdditionalInformation());
|
518 |
+
$this->assertEquals('4711', $payment->getAdditionalInformation('alias'));
|
519 |
+
$this->assertArrayNotHasKey('cvc', $payment->getAdditionalInformation());
|
520 |
+
|
521 |
+
$params = array(
|
522 |
+
'alias_aliasid' => '4712',
|
523 |
+
'card_cvc' => '123'
|
524 |
+
);
|
525 |
+
|
526 |
+
$dataHelperMock = $this->getHelperMock('ops/data', array('isAdminSession'));
|
527 |
+
$dataHelperMock->expects($this->any())
|
528 |
+
->method('isAdminSession')
|
529 |
+
->will($this->returnValue(false));
|
530 |
+
$this->replaceByMock('helper', 'ops/data', $dataHelperMock);
|
531 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
532 |
+
$helper = Mage::helper('ops/alias');
|
533 |
+
$helper->setAliasToPayment($quote->getPayment(), $params);
|
534 |
+
$payment = $quote->getPayment();
|
535 |
+
$this->assertEquals('4712', $payment->getAdditionalInformation('alias'));
|
536 |
+
$this->assertArrayHasKey('cvc', $payment->getAdditionalInformation());
|
537 |
+
$this->assertEquals('123', $payment->getAdditionalInformation('cvc'));
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
542 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
543 |
+
*/
|
544 |
+
public function testSetCardHolder()
|
545 |
+
{
|
546 |
+
$reflection_class = new ReflectionClass("Netresearch_OPS_Helper_Alias");
|
547 |
+
$method = $reflection_class->getMethod('setCardHolderToAlias');
|
548 |
+
$method->setAccessible(true);
|
549 |
+
|
550 |
+
$helperObject = Mage::helper('ops/alias');
|
551 |
+
|
552 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
553 |
+
$quote->setBillingAddress($this->getAddressData());
|
554 |
+
$quote->setShippingAddress($this->getAddressData());
|
555 |
+
|
556 |
+
$oldAlias = Mage::getModel('ops/alias')->load(7);
|
557 |
+
$aliasData = array(
|
558 |
+
'alias_aliasid' => '4712',
|
559 |
+
'card_cvc' => '123',
|
560 |
+
'Card_CardHolderName' => 'Max Muster'
|
561 |
+
);
|
562 |
+
|
563 |
+
$method->invoke($helperObject, $quote,$aliasData);
|
564 |
+
$updatedAlias = Mage::getModel('ops/alias')->load(7);
|
565 |
+
$this->assertEquals($aliasData['Card_CardHolderName'], $updatedAlias->getCardHolder());
|
566 |
+
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
571 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
572 |
+
*/
|
573 |
+
public function testSetAliasActive()
|
574 |
+
{
|
575 |
+
$order = Mage::getModel('sales/order')->load(11);
|
576 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
577 |
+
$quote->setBillingAddress($this->getAddressData());
|
578 |
+
$quote->setShippingAddress($this->getAddressData());
|
579 |
+
$payment = $this->getModelMock('sales/quote_payment', array('save'));
|
580 |
+
$payment->setAdditionalInformation('alias', '4714');
|
581 |
+
$payment->setAdditionalInformation('userIsRegistering', false);
|
582 |
+
$orderPayment = $this->getModelMock('sales/order_payment', array('save'));
|
583 |
+
$orderPayment->setAdditionalInformation('alias', '4714');
|
584 |
+
$orderPayment->setAdditionalInformation('userIsRegistering', false);
|
585 |
+
$quote->setPayment($payment);
|
586 |
+
$order->setPayment($orderPayment);
|
587 |
+
$customer = Mage::getModel('customer/customer');
|
588 |
+
$customer->setId(1);
|
589 |
+
$quote->setCustomer($customer);
|
590 |
+
$billingAddressHash = Mage::helper('ops/alias')->generateAddressHash($quote->getBillingAddress());
|
591 |
+
$shippingAddressHash = Mage::helper('ops/alias')->generateAddressHash($quote->getShippingAddress());
|
592 |
+
$aliasesToDelete = Mage::getModel('ops/alias')
|
593 |
+
->getCollection()
|
594 |
+
->addFieldToFilter('customer_id', $quote->getCustomer()->getId())
|
595 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
596 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
597 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE);
|
598 |
+
$oldAlias = $aliasesToDelete->getFirstItem();
|
599 |
+
$helperMock = $this->getHelperMock('ops/alias', array('cleanUpAdditionalInformation'));
|
600 |
+
$helperMock->setAliasActive($quote, $order);
|
601 |
+
$aliasesToUpdate = Mage::getModel('ops/alias')
|
602 |
+
->getCollection()
|
603 |
+
->addFieldToFilter('customer_id', $quote->getCustomer()->getId())
|
604 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
605 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
606 |
+
->addFieldToFilter('alias', '4714')
|
607 |
+
->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)
|
608 |
+
->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
|
609 |
+
$newAlias = $aliasesToUpdate->getFirstItem();
|
610 |
+
|
611 |
+
$testAlias = Mage::getModel('ops/alias')->load($oldAlias->getId());
|
612 |
+
$this->assertEquals(null, $testAlias->getId());
|
613 |
+
$this->assertEquals('active', $newAlias->getState());
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
618 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
619 |
+
*/
|
620 |
+
public function testSetAliasActiveWhenUserRegisters()
|
621 |
+
{
|
622 |
+
$order = $this->getModelMock('sales/order', array('getPayment'));
|
623 |
+
$quote = $this->getModelMock('sales/quote', array('getPayment'));
|
624 |
+
$quote->setBillingAddress($this->getAddressData());
|
625 |
+
$quote->setShippingAddress($this->getAddressData());
|
626 |
+
$payment = $this->getModelMock('sales/quote_payment', array('save'));
|
627 |
+
$payment->setAdditionalInformation('alias', '4714');
|
628 |
+
$payment->setAdditionalInformation('userIsRegistering', true);
|
629 |
+
$orderPayment = $this->getModelMock('sales/order_payment', array('save'));
|
630 |
+
$orderPayment->setAdditionalInformation('alias', '4714');
|
631 |
+
$orderPayment->setAdditionalInformation('userIsRegistering', true);
|
632 |
+
$quote->expects($this->any())
|
633 |
+
->method('getPayment')
|
634 |
+
->will($this->returnValue($payment));
|
635 |
+
|
636 |
+
$order->expects($this->any())
|
637 |
+
->method('getPayment')
|
638 |
+
->will($this->returnValue($orderPayment));
|
639 |
+
$customer = Mage::getModel('customer/customer');
|
640 |
+
$customer->setId(1);
|
641 |
+
$quote->setCustomer($customer);
|
642 |
+
$helperMock = $this->getHelperMock('ops/alias', array('cleanUpAdditionalInformation', 'setAliasToActiveAfterUserRegisters'));
|
643 |
+
$helperMock->expects($this->once())
|
644 |
+
->method('setAliasToActiveAfterUserRegisters')
|
645 |
+
->with($order, $quote);
|
646 |
+
|
647 |
+
$helperMock->setAliasActive($quote, $order);
|
648 |
+
|
649 |
+
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
653 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
654 |
+
*/
|
655 |
+
public function testSetAliasToActiveAfterUserRegisters()
|
656 |
+
{
|
657 |
+
$order = Mage::getModel('sales/order')->load(11);
|
658 |
+
$order->setCustomerId(123);
|
659 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
660 |
+
$quote->setBillingAddress($this->getAddressData());
|
661 |
+
$quote->setShippingAddress($this->getAddressData());
|
662 |
+
$quote->getPayment()->setAdditionalInformation('alias', '4714');
|
663 |
+
$quote->getPayment()->setAdditionalInformation('opsAliasId','11111');
|
664 |
+
$quote->getPayment()->setAdditionalInformation('userIsRegistering',true);
|
665 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER);
|
666 |
+
$quote->setStoreId(null);
|
667 |
+
$billingAddressHash = Mage::helper('ops/alias')->generateAddressHash($quote->getBillingAddress());
|
668 |
+
$shippingAddressHash = Mage::helper('ops/alias')->generateAddressHash($quote->getShippingAddress());
|
669 |
+
|
670 |
+
$oldAlias = Mage::getModel('ops/alias')->getCollection()
|
671 |
+
->addFieldToFilter('alias', $quote->getPayment()->getAdditionalInformation('alias'))
|
672 |
+
->addFieldToFilter('billing_address_hash', $billingAddressHash)
|
673 |
+
->addFieldToFilter('shipping_address_hash', $shippingAddressHash)
|
674 |
+
->getFirstItem();
|
675 |
+
|
676 |
+
Mage::helper('ops/alias')->setAliasToActiveAfterUserRegisters($order,$quote);
|
677 |
+
$testAlias = Mage::getModel('ops/alias')->load($oldAlias->getId());
|
678 |
+
$this->assertEquals(Netresearch_OPS_Model_Alias_State::ACTIVE, $testAlias->getState());
|
679 |
+
$this->assertEquals(123,$testAlias->getCustomerId());
|
680 |
+
}
|
681 |
+
|
682 |
+
/**
|
683 |
+
* @loadFixture ../../../var/fixtures/aliases.yaml
|
684 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
685 |
+
*/
|
686 |
+
public function testCleanUpAdditionalInformation()
|
687 |
+
{
|
688 |
+
$quote = Mage::getModel('sales/quote')->load(11);
|
689 |
+
$payment = $quote->getPayment();
|
690 |
+
$payment->setAdditionalInformation('cvc', 'cvctest');
|
691 |
+
$payment->setAdditionalInformation('storedOPSId', 'storedOPSIdTest');
|
692 |
+
|
693 |
+
|
694 |
+
|
695 |
+
$this->assertTrue(array_key_exists('cvc', $payment->getAdditionalInformation()));
|
696 |
+
$this->assertTrue(array_key_exists('storedOPSId', $payment->getAdditionalInformation()));
|
697 |
+
|
698 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment);
|
699 |
+
|
700 |
+
$this->assertTrue(is_array($payment->getAdditionalInformation()));
|
701 |
+
$this->assertFalse(array_key_exists('cvc' ,$payment->getAdditionalInformation()));
|
702 |
+
$this->assertFalse(array_key_exists('storedOPSId', $payment->getAdditionalInformation()));
|
703 |
+
|
704 |
+
$quote = Mage::getModel('sales/quote')->load(11);
|
705 |
+
$payment = $quote->getPayment();
|
706 |
+
$payment->setAdditionalInformation('cvc', 'cvctest');
|
707 |
+
$payment->setAdditionalInformation('storedOPSId', 'storedOPSIdTest');
|
708 |
+
|
709 |
+
|
710 |
+
|
711 |
+
$this->assertTrue(array_key_exists('cvc', $payment->getAdditionalInformation()));
|
712 |
+
$this->assertTrue(array_key_exists('storedOPSId', $payment->getAdditionalInformation()));
|
713 |
+
|
714 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment, true);
|
715 |
+
|
716 |
+
$this->assertTrue(is_array($payment->getAdditionalInformation()));
|
717 |
+
$this->assertFalse(array_key_exists('cvc' ,$payment->getAdditionalInformation()));
|
718 |
+
$this->assertTrue(array_key_exists('storedOPSId', $payment->getAdditionalInformation()));
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
*/
|
723 |
+
public function testCleanUpAdditionalInformationWithSave()
|
724 |
+
{
|
725 |
+
$payment = $this->getModelMock('sales/quote_payment', array('save'));
|
726 |
+
$payment->expects($this->once())
|
727 |
+
->method('save')
|
728 |
+
;
|
729 |
+
|
730 |
+
Mage::helper('ops/alias')->cleanUpAdditionalInformation($payment, true, true);
|
731 |
+
|
732 |
+
}
|
733 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/AliasTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/ApiTest.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: michael
|
5 |
+
* Date: 07.05.13
|
6 |
+
* Time: 16:55
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Test_Helper_ApiTest extends EcomDev_PHPUnit_Test_Case
|
11 |
+
{
|
12 |
+
|
13 |
+
public function testGetRedirectRouteFromStatus()
|
14 |
+
{
|
15 |
+
$helper = Mage::helper('ops/api');
|
16 |
+
$configModel = Mage::getModel('ops/config');
|
17 |
+
$successRoute = $configModel->getAcceptRedirectRoute();
|
18 |
+
$this->assertEquals(
|
19 |
+
$successRoute, $helper->getRedirectRouteFromStatus(
|
20 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
$cancelRoute = $configModel->getCancelRedirectRoute();
|
25 |
+
$this->assertEquals(
|
26 |
+
$cancelRoute, $helper->getRedirectRouteFromStatus(
|
27 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL
|
28 |
+
)
|
29 |
+
);
|
30 |
+
|
31 |
+
$declineRoute = $configModel->getDeclineRedirectRoute();
|
32 |
+
$this->assertEquals(
|
33 |
+
$declineRoute, $helper->getRedirectRouteFromStatus(
|
34 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE
|
35 |
+
)
|
36 |
+
);
|
37 |
+
|
38 |
+
$exceptionRoute = $configModel->getExceptionRedirectRoute();
|
39 |
+
$this->assertEquals(
|
40 |
+
$exceptionRoute, $helper->getRedirectRouteFromStatus(
|
41 |
+
Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_EXCEPTION
|
42 |
+
)
|
43 |
+
);
|
44 |
+
|
45 |
+
try {
|
46 |
+
$helper->getRedirectRouteFromStatus('');
|
47 |
+
} catch (Exception $e) {
|
48 |
+
$this->assertEquals('invalid status provided', $e->getMessage());
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/DataTest.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Helper_DataTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
protected $helper;
|
5 |
+
protected $store;
|
6 |
+
|
7 |
+
public function setUp()
|
8 |
+
{
|
9 |
+
parent::setup();
|
10 |
+
$this->helper = Mage::helper('ops');
|
11 |
+
$this->store = Mage::app()->getStore(0)->load(0);
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @test
|
16 |
+
*/
|
17 |
+
public function getModuleVersionString()
|
18 |
+
{
|
19 |
+
$path = 'modules/Netresearch_OPS/version';
|
20 |
+
|
21 |
+
Mage::getConfig()->setNode($path, '12.03.01');
|
22 |
+
$this->assertSame('OGmg120301', $this->helper->getModuleVersionString());
|
23 |
+
|
24 |
+
Mage::getConfig()->setNode($path, '12.06.12+383');
|
25 |
+
$this->assertSame('OGmg120612', $this->helper->getModuleVersionString());
|
26 |
+
|
27 |
+
Mage::getConfig()->setNode($path, '12.09.12-beta2+808');
|
28 |
+
$this->assertSame('OGmg120912', $this->helper->getModuleVersionString());
|
29 |
+
|
30 |
+
$this->store->resetConfig();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function testCheckIfUserIsRegistering()
|
34 |
+
{
|
35 |
+
$quote = new Varien_Object();
|
36 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER);
|
37 |
+
$sessionMock = $this->getModelMock('checkout/session', array('getQuote', 'init', 'save'));
|
38 |
+
$sessionMock->expects($this->any())
|
39 |
+
->method('getQuote')
|
40 |
+
->will($this->returnValue($quote));
|
41 |
+
$this->replaceByMock('model', 'checkout/session', $sessionMock);
|
42 |
+
|
43 |
+
|
44 |
+
$this->assertTrue(Mage::helper('ops/data')->checkIfUserIsRegistering());
|
45 |
+
|
46 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_LOGIN_IN);
|
47 |
+
$this->assertTrue(Mage::helper('ops/data')->checkIfUserIsRegistering());
|
48 |
+
|
49 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
|
50 |
+
$this->assertFalse(Mage::helper('ops/data')->checkIfUserIsRegistering());
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
public function testCheckIfUserIsNotRegistering()
|
55 |
+
{
|
56 |
+
$quote = new Varien_Object();
|
57 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER);
|
58 |
+
$sessionMock = $this->getModelMock('checkout/session', array('getQuote', 'init', 'save'));
|
59 |
+
$sessionMock->expects($this->any())
|
60 |
+
->method('getQuote')
|
61 |
+
->will($this->returnValue($quote));
|
62 |
+
$this->replaceByMock('model', 'checkout/session', $sessionMock);
|
63 |
+
|
64 |
+
$this->assertTrue(Mage::helper('ops/data')->checkIfUserIsNotRegistering());
|
65 |
+
|
66 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_LOGIN_IN);
|
67 |
+
$this->assertFalse(Mage::helper('ops/data')->checkIfUserIsNotRegistering());
|
68 |
+
|
69 |
+
$quote->setCheckoutMethod(Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST);
|
70 |
+
$this->assertFalse(Mage::helper('ops/data')->checkIfUserIsNotRegistering());
|
71 |
+
}
|
72 |
+
|
73 |
+
public function testClearMsg()
|
74 |
+
{
|
75 |
+
$helper = Mage::helper('ops/data');
|
76 |
+
$testArray = array('cvc' => '1', 'CVC' => '2', 'test' => 'me');
|
77 |
+
$testArray = $helper->clearMsg($testArray);
|
78 |
+
$this->assertFalse(array_key_exists('cvc', $testArray));
|
79 |
+
$this->assertFalse(array_key_exists('CVC', $testArray));
|
80 |
+
$this->assertTrue(array_key_exists('test', $testArray));
|
81 |
+
$testString = '{"CVC":"123"}';
|
82 |
+
$this->assertFalse(strpos($helper->clearMsg($testString), 'CVC'));
|
83 |
+
$testString = '{"CVC":"123","CN":"Some Name"}';
|
84 |
+
$this->assertFalse(strpos($helper->clearMsg($testString), 'CVC'));
|
85 |
+
$testString = '{"cvc":"123","CN":"Some Name"}';
|
86 |
+
$this->assertFalse(strpos($helper->clearMsg($testString), 'cvc'));
|
87 |
+
$this->assertTrue(false !== strpos($helper->clearMsg($testString), 'CN'));
|
88 |
+
|
89 |
+
$testString = 'a:3:{s:5:"Alias";s:14:"10290855992990";s:3:"CVC";s:3:"777";s:2:"CN";s:13:"Homer Simpson";}';
|
90 |
+
$this->assertFalse(strpos($helper->clearMsg($testString), 'CVC'));
|
91 |
+
$this->assertTrue(false !== strpos($helper->clearMsg($testString), 'Homer'));
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @test
|
96 |
+
*/
|
97 |
+
public function sendNoMail()
|
98 |
+
{
|
99 |
+
$documentMock = $this->getMockBuilder('Mage_Sales_Model_Order_Shipment')
|
100 |
+
->setMethods(['getEmailSent'])
|
101 |
+
->getMock()
|
102 |
+
;
|
103 |
+
$documentMock
|
104 |
+
->expects($this->never())
|
105 |
+
->method('getEmailSent')
|
106 |
+
;
|
107 |
+
|
108 |
+
Mage::helper('ops/data')->sendTransactionalEmail($documentMock);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @test
|
113 |
+
*/
|
114 |
+
public function sendOrderEmail()
|
115 |
+
{
|
116 |
+
$orderMock = $this->getModelMock('sales/order', [
|
117 |
+
'getEmailSent', 'getCanSendNewEmailFlag', 'sendNewOrderEmail'
|
118 |
+
]);
|
119 |
+
$orderMock
|
120 |
+
->expects($this->exactly(3))
|
121 |
+
->method('getEmailSent')
|
122 |
+
->willReturnOnConsecutiveCalls(true, false, false)
|
123 |
+
;
|
124 |
+
$orderMock
|
125 |
+
->expects($this->exactly(2))
|
126 |
+
->method('getCanSendNewEmailFlag')
|
127 |
+
->willReturnOnConsecutiveCalls(false, true)
|
128 |
+
;
|
129 |
+
$orderMock
|
130 |
+
->expects($this->once())
|
131 |
+
->method('sendNewOrderEmail')
|
132 |
+
;
|
133 |
+
$this->replaceByMock('model', 'sales/order', $orderMock);
|
134 |
+
|
135 |
+
$order = Mage::getModel('sales/order');
|
136 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
137 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
138 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @test
|
143 |
+
*/
|
144 |
+
public function sendInvoiceEmail()
|
145 |
+
{
|
146 |
+
$configMock = $this->getModelMock('ops/config', ['getSendInvoice']);
|
147 |
+
$configMock
|
148 |
+
->expects($this->exactly(2))
|
149 |
+
->method('getSendInvoice')
|
150 |
+
->willReturnOnConsecutiveCalls(false, true)
|
151 |
+
;
|
152 |
+
$this->replaceByMock('model', 'ops/config', $configMock);
|
153 |
+
|
154 |
+
$invoiceMock = $this->getModelMock('sales/order_invoice', [
|
155 |
+
'getEmailSent', 'sendEmail'
|
156 |
+
]);
|
157 |
+
$invoiceMock
|
158 |
+
->expects($this->exactly(3))
|
159 |
+
->method('getEmailSent')
|
160 |
+
->willReturnOnConsecutiveCalls(true, false, false)
|
161 |
+
;
|
162 |
+
$invoiceMock
|
163 |
+
->expects($this->once())
|
164 |
+
->method('sendEmail')
|
165 |
+
;
|
166 |
+
$this->replaceByMock('model', 'sales/order', $invoiceMock);
|
167 |
+
|
168 |
+
$order = Mage::getModel('sales/order');
|
169 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
170 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
171 |
+
Mage::helper('ops/data')->sendTransactionalEmail($order);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest.php
ADDED
@@ -0,0 +1,501 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
class Netresearch_OPS_Test_Helper_DirectDebitTest
|
12 |
+
extends EcomDev_PHPUnit_Test_Case
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function getDirectDebitHelper()
|
16 |
+
{
|
17 |
+
return Mage::helper('ops/directDebit');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function testGetDataHelper()
|
21 |
+
{
|
22 |
+
$this->assertTrue(
|
23 |
+
$this->getDirectDebitHelper()->getDataHelper() instanceof
|
24 |
+
Netresearch_OPS_Helper_Data
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
public function testGetQuoteHelper()
|
29 |
+
{
|
30 |
+
$this->assertTrue(
|
31 |
+
$this->getDirectDebitHelper()->getQuoteHelper() instanceof
|
32 |
+
Netresearch_OPS_Helper_Quote
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function testGetOrderHelper()
|
37 |
+
{
|
38 |
+
$this->assertTrue(
|
39 |
+
$this->getDirectDebitHelper()->getOrderHelper() instanceof
|
40 |
+
Netresearch_OPS_Helper_Order
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function testGetCustomerHelper()
|
45 |
+
{
|
46 |
+
$this->assertTrue(
|
47 |
+
$this->getDirectDebitHelper()->getCustomerHelper() instanceof
|
48 |
+
Mage_Customer_Helper_Data
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
public function testGetValidator()
|
53 |
+
{
|
54 |
+
$this->assertTrue(
|
55 |
+
$this->getDirectDebitHelper()->getValidator() instanceof
|
56 |
+
Netresearch_OPS_Model_Validator_Payment_DirectDebit
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
public function testGetCountry()
|
61 |
+
{
|
62 |
+
$helper = $this->getDirectDebitHelper();
|
63 |
+
$params = array();
|
64 |
+
$this->assertEquals('', $helper->getCountry($params));
|
65 |
+
$params['country'] = 'de';
|
66 |
+
$this->assertEquals('DE', $helper->getCountry($params));
|
67 |
+
}
|
68 |
+
|
69 |
+
public function testHasIban()
|
70 |
+
{
|
71 |
+
$helper = $this->getDirectDebitHelper();
|
72 |
+
$params = array();
|
73 |
+
$this->assertFalse($helper->hasIban($params));
|
74 |
+
$params['iban'] = '';
|
75 |
+
$this->assertFalse($helper->hasIban($params));
|
76 |
+
$params['iban'] = ' ';
|
77 |
+
$this->assertFalse($helper->hasIban($params));
|
78 |
+
$params['iban'] = '123456789';
|
79 |
+
$this->assertTrue($helper->hasIban($params));
|
80 |
+
}
|
81 |
+
|
82 |
+
public function testSetDirectDebitDataToPayment()
|
83 |
+
{
|
84 |
+
$payment = Mage::getModel('sales/quote_payment');
|
85 |
+
$helper = $this->getDirectDebitHelper();
|
86 |
+
$params = array('country' => 'de', 'account' => '', 'bankcode' => '');
|
87 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
88 |
+
$this->assertEquals(
|
89 |
+
'Direct Debits DE', $payment->getAdditionalInformation('PM')
|
90 |
+
);
|
91 |
+
|
92 |
+
$params = array(
|
93 |
+
'country' => 'de', 'CN' => 'Account Holder', 'account' => '',
|
94 |
+
'bankcode' => ''
|
95 |
+
);
|
96 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
97 |
+
$this->assertEquals(
|
98 |
+
'Account Holder', $payment->getAdditionalInformation('CN')
|
99 |
+
);
|
100 |
+
|
101 |
+
$params = array(
|
102 |
+
'country' => 'nl', 'CN' => 'Account Holder',
|
103 |
+
'account' => '1234567', 'bankcode' => ''
|
104 |
+
);
|
105 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
106 |
+
$this->assertEquals(
|
107 |
+
'1234567', $payment->getAdditionalInformation('CARDNO')
|
108 |
+
);
|
109 |
+
|
110 |
+
$params = array(
|
111 |
+
'country' => 'at', 'CN' => 'Account Holder',
|
112 |
+
'account' => '1234567', 'bankcode' => '1234567'
|
113 |
+
);
|
114 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
115 |
+
$this->assertEquals(
|
116 |
+
'1234567BLZ1234567', $payment->getAdditionalInformation('CARDNO')
|
117 |
+
);
|
118 |
+
|
119 |
+
$params = array(
|
120 |
+
'country' => 'de', 'CN' => 'Account Holder',
|
121 |
+
'account' => '1234567', 'bankcode' => '1234567'
|
122 |
+
);
|
123 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
124 |
+
$this->assertEquals(
|
125 |
+
'1234567BLZ1234567', $payment->getAdditionalInformation('CARDNO')
|
126 |
+
);
|
127 |
+
|
128 |
+
$params = array(
|
129 |
+
'country' => 'de', 'CN' => 'Account Holder',
|
130 |
+
'iban' => 'DE1234567890', 'account' => '1234567',
|
131 |
+
'bankcode' => '1234567'
|
132 |
+
);
|
133 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
134 |
+
$this->assertEquals(
|
135 |
+
'DE1234567890', $payment->getAdditionalInformation('CARDNO')
|
136 |
+
);
|
137 |
+
|
138 |
+
$params = array(
|
139 |
+
'country' => 'at', 'CN' => 'Account Holder',
|
140 |
+
'iban' => 'DE1234567890', 'account' => '1234567',
|
141 |
+
'bankcode' => '1234567'
|
142 |
+
);
|
143 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
144 |
+
$this->assertEquals(
|
145 |
+
'1234567BLZ1234567', $payment->getAdditionalInformation('CARDNO')
|
146 |
+
);
|
147 |
+
|
148 |
+
$params = array(
|
149 |
+
'country' => 'nl', 'CN' => 'Account Holder',
|
150 |
+
'iban' => 'NL1234567890', 'bic' => '12345678',
|
151 |
+
'account' => '1234567', 'bankcode' => '1234567'
|
152 |
+
);
|
153 |
+
$helper->setDirectDebitDataToPayment($payment, $params);
|
154 |
+
$this->assertEquals(
|
155 |
+
'NL1234567890', $payment->getAdditionalInformation('CARDNO')
|
156 |
+
);
|
157 |
+
$this->assertEquals(
|
158 |
+
'12345678', $payment->getAdditionalInformation('BIC')
|
159 |
+
);
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
164 |
+
*/
|
165 |
+
public function testGetDirectLinkRequestParams()
|
166 |
+
{
|
167 |
+
|
168 |
+
$store = Mage::app()->getStore(0)->load(0);
|
169 |
+
$store->resetConfig();
|
170 |
+
|
171 |
+
$store->setConfig(
|
172 |
+
'payment_services/ops/inlineOrderReference',
|
173 |
+
Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID
|
174 |
+
);
|
175 |
+
|
176 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
177 |
+
$order = Mage::getModel('sales/order')->load(11);
|
178 |
+
$dataHelper = $this->getHelperMock('ops/data', array('isAdminSession'));
|
179 |
+
$dataHelper->expects($this->any())
|
180 |
+
->method('isAdminSession')
|
181 |
+
->will($this->returnValue(false));
|
182 |
+
|
183 |
+
$customerHelper = $this->getHelperMock(
|
184 |
+
'customer/data', array('isLoggedIn')
|
185 |
+
);
|
186 |
+
$customerHelper->expects($this->any())
|
187 |
+
->method('isLoggedIn')
|
188 |
+
->will($this->returnValue(false));
|
189 |
+
|
190 |
+
$quoteHelper = $this->getHelperMock(
|
191 |
+
'ops/quote', array('getPaymentAction', 'getQuoteCurrency')
|
192 |
+
);
|
193 |
+
$quoteHelper->expects($this->any())
|
194 |
+
->method('getPaymentAction')
|
195 |
+
->will($this->returnValue('RES'));
|
196 |
+
$quoteHelper->expects($this->any())
|
197 |
+
->method('getQuoteCurrency')
|
198 |
+
->will($this->returnValue('EUR'));
|
199 |
+
|
200 |
+
$orderHelper = $this->getHelperMock(
|
201 |
+
'ops/order', array('checkIfAddressesAreSame')
|
202 |
+
);
|
203 |
+
$orderHelper->expects($this->any())
|
204 |
+
->method('checkIfAddressesAreSame')
|
205 |
+
->will($this->returnValue(1));
|
206 |
+
|
207 |
+
$helper = $this->getDirectDebitHelper();
|
208 |
+
$helper->setDataHelper($dataHelper);
|
209 |
+
$helper->setCustomerHelper($customerHelper);
|
210 |
+
$helper->setQuoteHelper($quoteHelper);
|
211 |
+
$helper->setOrderHelper($orderHelper);
|
212 |
+
$this->assertEquals(
|
213 |
+
$this->getExpectedResultOnFrontendRequest($order),
|
214 |
+
$helper->getDirectLinkRequestParams($quote, $order)
|
215 |
+
);
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
220 |
+
*/
|
221 |
+
public function testGetDirectLinkRequestParamsWithNoShippingAddress()
|
222 |
+
{
|
223 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
224 |
+
$order = Mage::getModel('sales/order')->load(28);
|
225 |
+
$dataHelper = $this->getHelperMock('ops/data', array('isAdminSession'));
|
226 |
+
$dataHelper->expects($this->any())
|
227 |
+
->method('isAdminSession')
|
228 |
+
->will($this->returnValue(false));
|
229 |
+
|
230 |
+
$customerHelper = $this->getHelperMock(
|
231 |
+
'customer/data', array('isLoggedIn')
|
232 |
+
);
|
233 |
+
$customerHelper->expects($this->any())
|
234 |
+
->method('isLoggedIn')
|
235 |
+
->will($this->returnValue(false));
|
236 |
+
|
237 |
+
$quoteHelper = $this->getHelperMock(
|
238 |
+
'ops/quote', array('getPaymentAction', 'getQuoteCurrency')
|
239 |
+
);
|
240 |
+
$quoteHelper->expects($this->any())
|
241 |
+
->method('getPaymentAction')
|
242 |
+
->will($this->returnValue('RES'));
|
243 |
+
$quoteHelper->expects($this->any())
|
244 |
+
->method('getQuoteCurrency')
|
245 |
+
->will($this->returnValue('EUR'));
|
246 |
+
|
247 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
248 |
+
$configMock->expects($this->any())
|
249 |
+
->method('canSubmitExtraParameter')
|
250 |
+
->will($this->returnValue(true));
|
251 |
+
|
252 |
+
$helper = $this->getDirectDebitHelper();
|
253 |
+
$helper->setConfig($configMock);
|
254 |
+
$helper->getRequestHelper()->setConfig($configMock);
|
255 |
+
$helper->setDataHelper($dataHelper);
|
256 |
+
$helper->setCustomerHelper($customerHelper);
|
257 |
+
$helper->setQuoteHelper($quoteHelper);
|
258 |
+
|
259 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order);
|
260 |
+
$this->assertEquals(
|
261 |
+
'04227',
|
262 |
+
$result['ECOM_SHIPTO_POSTAL_POSTALCODE']
|
263 |
+
);
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
268 |
+
*/
|
269 |
+
public function testGetDirectLinkRequestParamsWithLoggedInCustomer()
|
270 |
+
{
|
271 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
272 |
+
$order = Mage::getModel('sales/order')->load(28);
|
273 |
+
$dataHelper = $this->getHelperMock('ops/data', array('isAdminSession'));
|
274 |
+
$dataHelper->expects($this->any())
|
275 |
+
->method('isAdminSession')
|
276 |
+
->will($this->returnValue(false));
|
277 |
+
|
278 |
+
$fakeCustomer = new Varien_Object();
|
279 |
+
$fakeCustomer->setId(666);
|
280 |
+
$customerHelper = $this->getHelperMock(
|
281 |
+
'customer/data', array('isLoggedIn', 'getCustomer')
|
282 |
+
);
|
283 |
+
$customerHelper->expects($this->any())
|
284 |
+
->method('isLoggedIn')
|
285 |
+
->will($this->returnValue(true));
|
286 |
+
$customerHelper->expects($this->any())
|
287 |
+
->method('getCustomer')
|
288 |
+
->will($this->returnValue($fakeCustomer));
|
289 |
+
|
290 |
+
$quoteHelper = $this->getHelperMock(
|
291 |
+
'ops/quote', array('getPaymentAction', 'getQuoteCurrency')
|
292 |
+
);
|
293 |
+
$quoteHelper->expects($this->any())
|
294 |
+
->method('getPaymentAction')
|
295 |
+
->will($this->returnValue('RES'));
|
296 |
+
$quoteHelper->expects($this->any())
|
297 |
+
->method('getQuoteCurrency')
|
298 |
+
->will($this->returnValue('EUR'));
|
299 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
300 |
+
$configMock->expects($this->any())
|
301 |
+
->method('canSubmitExtraParameter')
|
302 |
+
->will($this->returnValue(true));
|
303 |
+
$helper = $this->getDirectDebitHelper();
|
304 |
+
$helper->setConfig($configMock);
|
305 |
+
$helper->getRequestHelper()->setConfig($configMock);
|
306 |
+
$helper->setDataHelper($dataHelper);
|
307 |
+
$helper->setCustomerHelper($customerHelper);
|
308 |
+
$helper->setQuoteHelper($quoteHelper);
|
309 |
+
|
310 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order);
|
311 |
+
$this->assertEquals(666, $result['CUID']);
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
317 |
+
*/
|
318 |
+
public function testGetDirectLinkRequestParamsForBackendOrder()
|
319 |
+
{
|
320 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
321 |
+
$order = Mage::getModel('sales/order')->load(11);
|
322 |
+
|
323 |
+
$validator = $this->getModelMock(
|
324 |
+
'ops/validator_payment_directDebit', array('isValid')
|
325 |
+
);
|
326 |
+
$validator->expects($this->any())
|
327 |
+
->method('isValid')
|
328 |
+
->will($this->returnValue(true));
|
329 |
+
|
330 |
+
$dataHelper = $this->getHelperMock('ops/data', array('isAdminSession'));
|
331 |
+
$dataHelper->expects($this->any())
|
332 |
+
->method('isAdminSession')
|
333 |
+
->will($this->returnValue(true));
|
334 |
+
|
335 |
+
$customerHelper = $this->getHelperMock(
|
336 |
+
'customer/data', array('isLoggedIn')
|
337 |
+
);
|
338 |
+
$customerHelper->expects($this->any())
|
339 |
+
->method('isLoggedIn')
|
340 |
+
->will($this->returnValue(false));
|
341 |
+
|
342 |
+
$quoteHelper = $this->getHelperMock(
|
343 |
+
'ops/quote', array('getPaymentAction', 'getQuoteCurrency')
|
344 |
+
);
|
345 |
+
$quoteHelper->expects($this->any())
|
346 |
+
->method('getPaymentAction')
|
347 |
+
->will($this->returnValue('RES'));
|
348 |
+
$quoteHelper->expects($this->any())
|
349 |
+
->method('getQuoteCurrency')
|
350 |
+
->will($this->returnValue('EUR'));
|
351 |
+
|
352 |
+
$orderHelper = $this->getHelperMock(
|
353 |
+
'ops/order', array('checkIfAddressesAreSame')
|
354 |
+
);
|
355 |
+
$orderHelper->expects($this->any())
|
356 |
+
->method('checkIfAddressesAreSame')
|
357 |
+
->will($this->returnValue(1));
|
358 |
+
|
359 |
+
$helper = $this->getDirectDebitHelper();
|
360 |
+
$helper->setDataHelper($dataHelper);
|
361 |
+
$helper->setCustomerHelper($customerHelper);
|
362 |
+
$helper->setQuoteHelper($quoteHelper);
|
363 |
+
$helper->setOrderHelper($orderHelper);
|
364 |
+
$helper->setValidator($validator);
|
365 |
+
|
366 |
+
$params = array(
|
367 |
+
'country' => 'DE', 'CN' => 'Hans Wurst', 'account' => '4711',
|
368 |
+
'bankcode' => '0815'
|
369 |
+
);
|
370 |
+
$helper->handleAdminPayment($quote, $params);
|
371 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order, $params);
|
372 |
+
$this->assertEquals('Direct Debits DE', $result['PM']);
|
373 |
+
$this->assertEquals('Hans Wurst', $result['CN']);
|
374 |
+
$this->assertEquals($result['PM'], $result['BRAND']);
|
375 |
+
$this->assertEquals('4711BLZ0815', $result['CARDNO']);
|
376 |
+
$this->assertEquals(1, $result['ECI']);
|
377 |
+
|
378 |
+
$params = array(
|
379 |
+
'country' => 'DE', 'CN' => 'Hans Wurst', 'account' => '4711',
|
380 |
+
'bankcode' => '0815', 'bic' => '4712', 'iban' => '0816'
|
381 |
+
);
|
382 |
+
$helper->handleAdminPayment($quote, $params);
|
383 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order, $params);
|
384 |
+
$this->assertEquals('0816', $result['CARDNO']);
|
385 |
+
$this->assertArrayNotHasKey('BIC', $result);
|
386 |
+
|
387 |
+
$params = array(
|
388 |
+
'country' => 'NL', 'CN' => 'Hans Wurst', 'account' => '4711',
|
389 |
+
'bankcode' => '0815', 'bic' => '4712', 'iban' => '0816'
|
390 |
+
);
|
391 |
+
$helper->handleAdminPayment($quote, $params);
|
392 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order, $params);
|
393 |
+
$this->assertEquals('0816', $result['CARDNO']);
|
394 |
+
$this->assertArrayHasKey('BIC', $result);
|
395 |
+
$this->assertEquals('4712', $result['BIC']);
|
396 |
+
|
397 |
+
$params = array(
|
398 |
+
'country' => 'NL', 'CN' => 'Hans Wurst', 'account' => '4711',
|
399 |
+
'bankcode' => '0815', 'bic' => '', 'iban' => '0816'
|
400 |
+
);
|
401 |
+
$quote->getPayment()->setAdditionalInformation('PM', 'Direct Debits NL');
|
402 |
+
$helper->handleAdminPayment($quote, $params);
|
403 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order, $params);
|
404 |
+
$this->assertArrayNotHasKey('BIC', $result);
|
405 |
+
|
406 |
+
$params = array(
|
407 |
+
'country' => 'DE', 'CN' => 'Hans Wurst', 'account' => '4711',
|
408 |
+
'bankcode' => '0815', 'bic' => '', 'iban' => '0816'
|
409 |
+
);
|
410 |
+
$quote->getPayment()->setAdditionalInformation('PM', 'Direct Debits DE');
|
411 |
+
$helper->handleAdminPayment($quote, $params);
|
412 |
+
$result = $helper->getDirectLinkRequestParams($quote, $order, $params);
|
413 |
+
$this->assertArrayNotHasKey('BIC', $result);
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
/**
|
418 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
419 |
+
*/
|
420 |
+
public function testGetDirectLinkRequestParamsForBackendOrderThrowsException(
|
421 |
+
)
|
422 |
+
{
|
423 |
+
$sessionMock = $this->getModelMock(
|
424 |
+
'adminhtml/session', array('init', 'save')
|
425 |
+
);
|
426 |
+
$this->replaceByMock('model', 'adminhtml/session', $sessionMock);
|
427 |
+
|
428 |
+
$quote = Mage::getModel('sales/quote')->load(10);
|
429 |
+
$order = Mage::getModel('sales/order')->load(11);
|
430 |
+
|
431 |
+
$validator = $this->getModelMock(
|
432 |
+
'ops/validator_payment_directDebit', array('isValid', 'getMessages')
|
433 |
+
);
|
434 |
+
$validator->expects($this->any())
|
435 |
+
->method('isValid')
|
436 |
+
->will($this->returnValue(false));
|
437 |
+
$validator->expects($this->any())
|
438 |
+
->method('getMessages')
|
439 |
+
->will($this->returnValue(array('foo', 'bar')));
|
440 |
+
|
441 |
+
$dataHelper = $this->getHelperMock('ops/data', array('isAdminSession'));
|
442 |
+
$dataHelper->expects($this->any())
|
443 |
+
->method('isAdminSession')
|
444 |
+
->will($this->returnValue(true));
|
445 |
+
|
446 |
+
$helper = $this->getDirectDebitHelper();
|
447 |
+
$helper->setDataHelper($dataHelper);
|
448 |
+
$helper->setValidator($validator);
|
449 |
+
|
450 |
+
$params = array(
|
451 |
+
'country' => 'DE', 'CN' => 'Hans Wurst', 'account' => '4711',
|
452 |
+
'bankcode' => '0815'
|
453 |
+
);
|
454 |
+
try {
|
455 |
+
$helper->getDirectLinkRequestParams(
|
456 |
+
$quote, $order, $params
|
457 |
+
);
|
458 |
+
} catch (Exception $e) {
|
459 |
+
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
protected function getExpectedResultOnFrontendRequest($order)
|
464 |
+
{
|
465 |
+
return array(
|
466 |
+
'AMOUNT' => 0.0,
|
467 |
+
'CARDNO' => NULL,
|
468 |
+
'CN' => utf8_decode(""),
|
469 |
+
'CURRENCY' => "EUR",
|
470 |
+
'ED' => "9999",
|
471 |
+
'OPERATION' => "RES",
|
472 |
+
'ORDERID' => Mage::getModel('ops/config')->getConfigData('devprefix') . $order->getQuoteId(),
|
473 |
+
'PM' => NULL,
|
474 |
+
'OWNERADDRESS' => utf8_decode(
|
475 |
+
"An der Tabaksmühle 3a"
|
476 |
+
),
|
477 |
+
'OWNERTOWN' => utf8_decode("Leipzig"),
|
478 |
+
'OWNERZIP' => "04229",
|
479 |
+
'OWNERTELNO' => NULL,
|
480 |
+
'OWNERCTY' => "DE",
|
481 |
+
'ADDMATCH' => 1,
|
482 |
+
'RTIMEOUT' => 45,
|
483 |
+
'ECOM_SHIPTO_POSTAL_POSTALCODE' => "04229",
|
484 |
+
'ECOM_BILLTO_POSTAL_POSTALCODE' => "04229",
|
485 |
+
'ORIG' => Mage::helper("ops")->getModuleVersionString(),
|
486 |
+
'BRAND' => NULL,
|
487 |
+
'ECOM_SHIPTO_POSTAL_NAME_FIRST' => 'Hubertus',
|
488 |
+
'ECOM_SHIPTO_POSTAL_NAME_LAST' => utf8_decode('Fürstenberg'),
|
489 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE1' => utf8_decode('An der Tabaksmühle 3a'),
|
490 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE2' => '',
|
491 |
+
'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => 'DE',
|
492 |
+
'ECOM_SHIPTO_POSTAL_CITY' => 'Leipzig',
|
493 |
+
'EMAIL' => 'hubertus.von.fuerstenberg@trash-mail.com',
|
494 |
+
'REMOTE_ADDR' => null,
|
495 |
+
'ECOM_SHIPTO_POSTAL_STATE' => ''
|
496 |
+
);
|
497 |
+
|
498 |
+
}
|
499 |
+
|
500 |
+
|
501 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/DirectDebitTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest.php
ADDED
@@ -0,0 +1,544 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Helper_DirectLinkTest
|
3 |
+
extends Netresearch_OPS_Test_Model_Response_TestCase
|
4 |
+
{
|
5 |
+
public function setUp()
|
6 |
+
{
|
7 |
+
parent::setup();
|
8 |
+
$this->_helper = Mage::helper('ops/directlink');
|
9 |
+
$transaction = Mage::getModel('sales/order_payment_transaction');
|
10 |
+
$transaction->setAdditionalInformation('arrInfo', serialize(array(
|
11 |
+
'amount' => '184.90'
|
12 |
+
)));
|
13 |
+
$transaction->setIsClosed(0);
|
14 |
+
$this->_transaction = $transaction;
|
15 |
+
$this->_order = Mage::getModel('sales/order');
|
16 |
+
$this->_order->setGrandTotal('184.90');
|
17 |
+
$this->_order->setBaseGrandTotal('184.90');
|
18 |
+
}
|
19 |
+
|
20 |
+
public function testDeleteActions()
|
21 |
+
{
|
22 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETED)));
|
23 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_PENDING)));
|
24 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_UNCERTAIN)));
|
25 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_REFUSED)));
|
26 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::PAYMENT_DELETION_OK)));
|
27 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, array('STATUS'=> Netresearch_OPS_Model_Status::DELETION_HANDLED_BY_MERCHANT)));
|
28 |
+
}
|
29 |
+
|
30 |
+
public function testRefundActions()
|
31 |
+
{
|
32 |
+
|
33 |
+
$opsRequest = array(
|
34 |
+
'STATUS' => Netresearch_OPS_Model_Status::REFUNDED,
|
35 |
+
'amount' => '184.90'
|
36 |
+
);
|
37 |
+
$this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Refund should not be possible without open transactions');
|
38 |
+
$this->assertTrue($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, $opsRequest), 'Refund should be possible with open transactions');
|
39 |
+
$opsRequest['amount'] = '14.90';
|
40 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, $opsRequest), 'Refund should NOT be possible because of differing amount');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function testCancelActions()
|
44 |
+
{
|
45 |
+
$opsRequest = array(
|
46 |
+
'STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED,
|
47 |
+
'amount' => '184.90'
|
48 |
+
);
|
49 |
+
$this->assertFalse($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Cancel should not be possible without open transactions');
|
50 |
+
$this->assertTrue($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, $opsRequest), 'Cancel should be possible with open transactions');
|
51 |
+
$opsRequest['amount'] = '14.90';
|
52 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, $opsRequest), 'Cancel should NOT be possible because of differing amount');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function testCaptureActions()
|
56 |
+
{
|
57 |
+
$opsRequest = array(
|
58 |
+
'STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
|
59 |
+
'amount' => '184.90'
|
60 |
+
);
|
61 |
+
$this->assertTrue($this->_helper->isValidOpsRequest(null, $this->_order, $opsRequest), 'Capture should be possible because of no open transactions and matching amount');
|
62 |
+
$opsRequest['amount'] = '14.90';
|
63 |
+
$this->assertFalse($this->_helper->isValidOpsRequest($this->_transaction, $this->_order, $opsRequest), 'Capture should NOT be possible because of differing amount');
|
64 |
+
}
|
65 |
+
|
66 |
+
public function testCleanupParameters()
|
67 |
+
{
|
68 |
+
$expected = 123.45;
|
69 |
+
$result = $this->_helper->formatAmount('123.45');
|
70 |
+
$this->assertEquals($expected, $result);
|
71 |
+
|
72 |
+
$result = $this->_helper->formatAmount('\'123.45\'');
|
73 |
+
$this->assertEquals($expected, $result);
|
74 |
+
|
75 |
+
$result = $this->_helper->formatAmount('"123.45"');
|
76 |
+
$this->assertEquals($expected, $result);
|
77 |
+
|
78 |
+
$expected = $this->_helper->formatAmount(0.3);
|
79 |
+
$result = $this->_helper->formatAmount(0.1 + 0.2);
|
80 |
+
$this->assertEquals($expected . '', $result . '');
|
81 |
+
$this->assertEquals((float) $expected, (float) $result);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
86 |
+
*/
|
87 |
+
public function testProcessFeedbackCaptureSuccess()
|
88 |
+
{
|
89 |
+
$this->mockEmailHelper($this->once());
|
90 |
+
|
91 |
+
$order = Mage::getModel('sales/order')->load(11);
|
92 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
93 |
+
$directlinkHelperMock->expects($this->any())
|
94 |
+
->method('isValidOpsRequest')
|
95 |
+
->will($this->returnValue(true));
|
96 |
+
|
97 |
+
$closure = function ($order, $params = array()) {
|
98 |
+
$order->getPayment()->setAdditionalInformation('status', 9);
|
99 |
+
return $order->getPayment();
|
100 |
+
};
|
101 |
+
|
102 |
+
$captureHelper = $this->getHelperMock('ops/order_capture', array('acceptCapture'));
|
103 |
+
$captureHelper->expects($this->any())
|
104 |
+
->method('acceptCapture')
|
105 |
+
->will($this->returnCallback($closure));
|
106 |
+
$this->replaceByMock('helper', 'ops/order_capture', $captureHelper);
|
107 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REQUESTED);
|
108 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
109 |
+
$this->assertEquals(9, $order->getPayment()->getAdditionalInformation('status'));
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
114 |
+
*/
|
115 |
+
public function testProcessFeedbackRefundSuccess()
|
116 |
+
{
|
117 |
+
$this->mockEmailHelper($this->never());
|
118 |
+
|
119 |
+
$mock = $this->getModelMock('sales/order', array('getBillingAddress'));
|
120 |
+
$mock->expects($this->any())
|
121 |
+
->method('getBillingAddress')
|
122 |
+
->will($this->returnValue(new Varien_Object()));
|
123 |
+
$this->replaceByMock('model', 'sales/order', $mock);
|
124 |
+
|
125 |
+
$order = Mage::getModel('sales/order')->load(11);
|
126 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
127 |
+
$directlinkHelperMock->expects($this->any())
|
128 |
+
->method('isValidOpsRequest')
|
129 |
+
->will($this->returnValue(true));
|
130 |
+
|
131 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::REFUNDED, 'PAYID' => '4711');
|
132 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
133 |
+
$this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
139 |
+
*/
|
140 |
+
public function testProcessFeedbackRefundWithStatusEightyFiveSuccess()
|
141 |
+
{
|
142 |
+
$this->mockEmailHelper($this->never());
|
143 |
+
|
144 |
+
$order = Mage::getModel('sales/order')->load(11);
|
145 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
146 |
+
$directlinkHelperMock->expects($this->any())
|
147 |
+
->method('isValidOpsRequest')
|
148 |
+
->will($this->returnValue(true));
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
$closure = function ($order, $params = array()) {
|
153 |
+
$order->getPayment()->setAdditionalInformation('status',
|
154 |
+
Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT
|
155 |
+
);
|
156 |
+
return $order->getPayment();
|
157 |
+
};
|
158 |
+
|
159 |
+
$refundHelper = $this->getHelperMock('ops/order_refund', array('createRefund'));
|
160 |
+
$refundHelper->expects($this->any())
|
161 |
+
->method('createRefund')
|
162 |
+
->will($this->returnCallback($closure));
|
163 |
+
$this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
|
164 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_PROCESSED_BY_MERCHANT, 'PAYID' => '4711');
|
165 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
166 |
+
$this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
171 |
+
*/
|
172 |
+
public function testProcessFeedbackPaymentWaiting()
|
173 |
+
{
|
174 |
+
$this->mockEmailHelper($this->once());
|
175 |
+
|
176 |
+
/** @var Mage_Sales_Model_Order $order */
|
177 |
+
$order = Mage::getModel('sales/order')->load(11);
|
178 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
179 |
+
$directlinkHelperMock->expects($this->any())
|
180 |
+
->method('isValidOpsRequest')
|
181 |
+
->will($this->returnValue(true));
|
182 |
+
|
183 |
+
$cntBefore = $order->getStatusHistoryCollection()->count();
|
184 |
+
|
185 |
+
|
186 |
+
$closure = function ($order, $params = array()) {
|
187 |
+
$order->getPayment()->setAdditionalInformation('status',
|
188 |
+
Netresearch_OPS_Model_Status::PAYMENT_PROCESSING
|
189 |
+
);
|
190 |
+
return $order->getPayment();
|
191 |
+
};
|
192 |
+
|
193 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_PROCESSING, 'PAYID' => '4711');
|
194 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
195 |
+
$cntAfter = $order->getStatusHistoryCollection()->count();
|
196 |
+
$this->assertTrue($cntBefore < $cntAfter);
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
201 |
+
*/
|
202 |
+
public function testProcessFeedbackPaymentRefused()
|
203 |
+
{
|
204 |
+
// mail sending is triggered but getEmailSent takes effect
|
205 |
+
$this->mockEmailHelper($this->once());
|
206 |
+
|
207 |
+
/** @var Mage_Sales_Model_Order $order */
|
208 |
+
$order = Mage::getModel('sales/order')->load(11);
|
209 |
+
$directlinkHelperMock = $this->getHelperMock(
|
210 |
+
'ops/directlink',
|
211 |
+
array('isValidOpsRequest', 'closePaymentTransaction')
|
212 |
+
);
|
213 |
+
$directlinkHelperMock->expects($this->any())
|
214 |
+
->method('isValidOpsRequest')
|
215 |
+
->will($this->returnValue(true));
|
216 |
+
|
217 |
+
$closure = function ($order, $params = array()) {
|
218 |
+
$order->getPayment()->setAdditionalInformation(
|
219 |
+
'status',
|
220 |
+
Netresearch_OPS_Model_Status::PAYMENT_REFUSED
|
221 |
+
);
|
222 |
+
return $order->getPayment();
|
223 |
+
};
|
224 |
+
|
225 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::PAYMENT_REFUSED, 'PAYID' => '4711');
|
226 |
+
|
227 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
232 |
+
*/
|
233 |
+
public function testProcessFeedbackRefundWaiting()
|
234 |
+
{
|
235 |
+
$this->mockEmailHelper($this->never());
|
236 |
+
|
237 |
+
$paymentMock = $this->getModelMock('core/resource_transaction', array('save'));
|
238 |
+
$this->replaceByMock('model', 'core/resource_transaction', $paymentMock);
|
239 |
+
|
240 |
+
/** @var Mage_Sales_Model_Order $order */
|
241 |
+
$order = Mage::getModel('sales/order')->load(11);
|
242 |
+
|
243 |
+
$creditMemo = $this->getModelMock('sales/order_creditmemo', array('_beforeSave'));
|
244 |
+
$order->getPayment()->setCreatedCreditMemo($creditMemo);
|
245 |
+
/** @var Netresearch_OPS_Helper_Directlink $directlinkHelperMock */
|
246 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
247 |
+
$directlinkHelperMock->expects($this->any())
|
248 |
+
->method('isValidOpsRequest')
|
249 |
+
->will($this->returnValue(true));
|
250 |
+
|
251 |
+
$cntBefore = $order->getStatusHistoryCollection()->count();
|
252 |
+
|
253 |
+
|
254 |
+
$closure = function ($order, $params = array()) {
|
255 |
+
$order->getPayment()->setAdditionalInformation('status',
|
256 |
+
Netresearch_OPS_Model_Status::REFUND_PENDING
|
257 |
+
);
|
258 |
+
return $order->getPayment();
|
259 |
+
};
|
260 |
+
|
261 |
+
$refundHelper = $this->getHelperMock('ops/order_refund', array('createRefund'));
|
262 |
+
$refundHelper->expects($this->any())
|
263 |
+
->method('createRefund')
|
264 |
+
->will($this->returnCallback($closure));
|
265 |
+
$this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
|
266 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_PENDING, 'PAYID' => '4711');
|
267 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
268 |
+
$cntAfter = $order->getStatusHistoryCollection()->count();
|
269 |
+
$this->assertTrue($cntBefore < $cntAfter);
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
275 |
+
*/
|
276 |
+
public function testProcessFeedbackRefundRefused()
|
277 |
+
{
|
278 |
+
$this->mockEmailHelper($this->never());
|
279 |
+
|
280 |
+
$transMock = $this->getModelMock('core/resource_transaction', array('save'));
|
281 |
+
$this->replaceByMock('model', 'core/resource_transaction', $transMock);
|
282 |
+
|
283 |
+
/** @var Mage_Sales_Model_Order $order */
|
284 |
+
$order = Mage::getModel('sales/order')->load(11);
|
285 |
+
$directlinkHelperMock = $this->getHelperMock(
|
286 |
+
'ops/directlink',
|
287 |
+
array('isValidOpsRequest', 'closePaymentTransaction')
|
288 |
+
);
|
289 |
+
$creditMemo = $this->getModelMock('sales/order_creditmemo', array('_beforeSave'));
|
290 |
+
$order->getPayment()->setCreatedCreditMemo($creditMemo);
|
291 |
+
$directlinkHelperMock->expects($this->any())
|
292 |
+
->method('isValidOpsRequest')
|
293 |
+
->will($this->returnValue(true));
|
294 |
+
|
295 |
+
$closure = function ($order, $params = array()) {
|
296 |
+
$order->getPayment()->setAdditionalInformation(
|
297 |
+
'status',
|
298 |
+
Netresearch_OPS_Model_Status::REFUND_PENDING
|
299 |
+
);
|
300 |
+
return $order->getPayment();
|
301 |
+
};
|
302 |
+
|
303 |
+
$refundHelper = $this->getHelperMock('ops/order_refund', array('createRefund'));
|
304 |
+
$refundHelper->expects($this->any())
|
305 |
+
->method('createRefund')
|
306 |
+
->will($this->returnCallback($closure));
|
307 |
+
$this->replaceByMock('helper', 'ops/order_refund', $refundHelper);
|
308 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::REFUND_REFUSED, 'PAYID' => '4711');
|
309 |
+
|
310 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
311 |
+
|
312 |
+
$this->assertEquals(Netresearch_OPS_Model_Status::REFUND_REFUSED, $order->getPayment()->getAdditionalInformation('status'));
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
317 |
+
*/
|
318 |
+
public function testProcessFeedbackVoidSuccess()
|
319 |
+
{
|
320 |
+
$this->mockEmailHelper($this->never());
|
321 |
+
$this->mockOrderConfig();
|
322 |
+
|
323 |
+
$transMock = $this->getModelMock('core/resource_transaction', array('save'));
|
324 |
+
$this->replaceByMock('model', 'core/resource_transaction', $transMock);
|
325 |
+
|
326 |
+
$order = Mage::getModel('sales/order')->load(11);
|
327 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
328 |
+
$directlinkHelperMock->expects($this->any())
|
329 |
+
->method('isValidOpsRequest')
|
330 |
+
->will($this->returnValue(true));
|
331 |
+
|
332 |
+
|
333 |
+
|
334 |
+
$closure = function ($order, $params = array()) {
|
335 |
+
$order->getPayment()->setAdditionalInformation('status', 6);
|
336 |
+
return $order->getPayment();
|
337 |
+
};
|
338 |
+
|
339 |
+
$voidHelper = $this->getHelperMock('ops/order_void', array('acceptVoid'));
|
340 |
+
$voidHelper->expects($this->any())
|
341 |
+
->method('acceptVoid')
|
342 |
+
->will($this->returnCallback($closure));
|
343 |
+
$this->replaceByMock('helper', 'ops/order_void', $voidHelper);
|
344 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED_AND_CANCELLED, 'PAYID' => '4711');
|
345 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
346 |
+
$this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
351 |
+
*/
|
352 |
+
public function testProcessFeedbackVoidWaiting()
|
353 |
+
{
|
354 |
+
$this->mockEmailHelper($this->never());
|
355 |
+
|
356 |
+
/** @var Mage_Sales_Model_Order $order */
|
357 |
+
$order = Mage::getModel('sales/order')->load(11);
|
358 |
+
/** @var Netresearch_OPS_Helper_Directlink $directlinkHelperMock */
|
359 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
360 |
+
$directlinkHelperMock->expects($this->any())
|
361 |
+
->method('isValidOpsRequest')
|
362 |
+
->will($this->returnValue(true));
|
363 |
+
|
364 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::DELETION_WAITING, 'PAYID' => '4711');
|
365 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
366 |
+
$this->assertNotEmpty($order->getPayment()->getMessage());
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
372 |
+
*/
|
373 |
+
public function testProcessFeedbackVoidRefused()
|
374 |
+
{
|
375 |
+
$this->mockEmailHelper($this->never());
|
376 |
+
|
377 |
+
/** @var Mage_Sales_Model_Order $order */
|
378 |
+
$order = Mage::getModel('sales/order')->load(11);
|
379 |
+
$directlinkHelperMock = $this->getHelperMock(
|
380 |
+
'ops/directlink',
|
381 |
+
array('isValidOpsRequest')
|
382 |
+
);
|
383 |
+
$directlinkHelperMock->expects($this->any())
|
384 |
+
->method('isValidOpsRequest')
|
385 |
+
->will($this->returnValue(true));
|
386 |
+
|
387 |
+
$closure = function ($order, $params = array()) {
|
388 |
+
$order->getPayment()->setAdditionalInformation(
|
389 |
+
'status',
|
390 |
+
Netresearch_OPS_Model_Status::DELETION_REFUSED
|
391 |
+
);
|
392 |
+
return $order->getPayment();
|
393 |
+
};
|
394 |
+
|
395 |
+
$refundHelper = $this->getHelperMock('ops/order_void', array('acceptVoid'));
|
396 |
+
$refundHelper->expects($this->any())
|
397 |
+
->method('acceptVoid')
|
398 |
+
->will($this->returnCallback($closure));
|
399 |
+
$this->replaceByMock('helper', 'ops/order_void', $refundHelper);
|
400 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::DELETION_REFUSED, 'PAYID' => '4711');
|
401 |
+
|
402 |
+
|
403 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
408 |
+
*/
|
409 |
+
public function testProcessFeedbackAuthorizeChanged()
|
410 |
+
{
|
411 |
+
// mail sending is triggered but getEmailSent takes effect
|
412 |
+
$this->mockEmailHelper($this->once());
|
413 |
+
$this->mockOrderConfig();
|
414 |
+
|
415 |
+
/** @var Mage_Sales_Model_Order $order */
|
416 |
+
$order = Mage::getModel('sales/order')->load(11);
|
417 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
418 |
+
$directlinkHelperMock->expects($this->any())
|
419 |
+
->method('isValidOpsRequest')
|
420 |
+
->will($this->returnValue(true));
|
421 |
+
|
422 |
+
$cntBefore = $order->getStatusHistoryCollection()->count();
|
423 |
+
|
424 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED, 'PAYID' => '4711');
|
425 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
426 |
+
$cntAfter = $order->getStatusHistoryCollection()->count();
|
427 |
+
$this->assertTrue($cntBefore < $cntAfter);
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
433 |
+
*/
|
434 |
+
public function testProcessFeedbackAuthorizeKwixoAccepted()
|
435 |
+
{
|
436 |
+
$this->mockEmailHelper($this->once());
|
437 |
+
$this->mockOrderConfig();
|
438 |
+
|
439 |
+
/** @var Mage_Sales_Model_Order $order */
|
440 |
+
$order = Mage::getModel('sales/order')->load(27);
|
441 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
442 |
+
$directlinkHelperMock->expects($this->any())
|
443 |
+
->method('isValidOpsRequest')
|
444 |
+
->will($this->returnValue(true));
|
445 |
+
|
446 |
+
$cntBefore = $order->getStatusHistoryCollection()->count();
|
447 |
+
|
448 |
+
|
449 |
+
$closure = function ($order, $params = array()) {
|
450 |
+
$order->getPayment()->setAdditionalInformation('status', Netresearch_OPS_Model_Status::AUTHORIZED
|
451 |
+
);
|
452 |
+
return $order->getPayment();
|
453 |
+
};
|
454 |
+
|
455 |
+
$paymentHelper = $this->getHelperMock('ops/payment', array('acceptOrder'));
|
456 |
+
$paymentHelper->expects($this->any())
|
457 |
+
->method('acceptOrder')
|
458 |
+
->will($this->returnCallback($closure));
|
459 |
+
$this->replaceByMock('helper', 'ops/payment', $paymentHelper);
|
460 |
+
|
461 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::AUTHORIZED, 'PAYID' => '4711');
|
462 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
463 |
+
$this->assertEquals($params['STATUS'], $order->getPayment()->getAdditionalInformation('status'));
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
468 |
+
* @expectedException Mage_Core_Exception
|
469 |
+
* @expectedExceptionMessage Can not handle status 4711.
|
470 |
+
*/
|
471 |
+
public function testProcessFeedbackUnknownStatus()
|
472 |
+
{
|
473 |
+
$this->mockEmailHelper($this->never());
|
474 |
+
|
475 |
+
/** @var Mage_Sales_Model_Order $order */
|
476 |
+
$order = Mage::getModel('sales/order')->load(11);
|
477 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
478 |
+
$directlinkHelperMock->expects($this->any())
|
479 |
+
->method('isValidOpsRequest')
|
480 |
+
->will($this->returnValue(true));
|
481 |
+
|
482 |
+
|
483 |
+
$params = array('STATUS' => 4711, 'PAYID' => '4711');
|
484 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
485 |
+
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
490 |
+
* @expectedException Mage_Core_Exception
|
491 |
+
* @expectedExceptionMessage Acceptance status 0, the action failed.
|
492 |
+
*/
|
493 |
+
public function testProcessFeedbackInvalidStatus()
|
494 |
+
{
|
495 |
+
$helperMock = $this->getHelperMock('ops', array('isAdminSession', 'sendTransactionalEmail'));
|
496 |
+
$helperMock->expects($this->once())
|
497 |
+
->method('isAdminSession')
|
498 |
+
->will($this->returnValue(false));
|
499 |
+
$helperMock->expects($this->never())
|
500 |
+
->method('sendTransactionalEmail');
|
501 |
+
$this->replaceByMock('helper', 'ops', $helperMock);
|
502 |
+
|
503 |
+
/** @var Mage_Sales_Model_Order $order */
|
504 |
+
$order = Mage::getModel('sales/order')->load(11);
|
505 |
+
$order->getPayment()->setAdditionalInformation('status', 500);
|
506 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
507 |
+
$directlinkHelperMock->expects($this->any())
|
508 |
+
->method('isValidOpsRequest')
|
509 |
+
->will($this->returnValue(true));
|
510 |
+
|
511 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::INVALID_INCOMPLETE, 'PAYID' => '4711');
|
512 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
513 |
+
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
518 |
+
* @expectedException Mage_Core_Exception
|
519 |
+
* @expectedExceptionMessage Acceptance status 0, the action failed.
|
520 |
+
*/
|
521 |
+
public function testProcessFeedbackInvalidStatusAsAdmin()
|
522 |
+
{
|
523 |
+
$helperMock = $this->getHelperMock('ops', array('isAdminSession', 'sendTransactionalEmail'));
|
524 |
+
$helperMock->expects($this->once())
|
525 |
+
->method('isAdminSession')
|
526 |
+
->will($this->returnValue(true));
|
527 |
+
$helperMock->expects($this->never())
|
528 |
+
->method('sendTransactionalEmail');
|
529 |
+
$this->replaceByMock('helper', 'ops', $helperMock);
|
530 |
+
|
531 |
+
/** @var Mage_Sales_Model_Order $order */
|
532 |
+
$order = Mage::getModel('sales/order')->load(11);
|
533 |
+
$order->getPayment()->setAdditionalInformation('status', 500);
|
534 |
+
$directlinkHelperMock = $this->getHelperMock('ops/directlink', array('isValidOpsRequest'));
|
535 |
+
$directlinkHelperMock->expects($this->any())
|
536 |
+
->method('isValidOpsRequest')
|
537 |
+
->will($this->returnValue(true));
|
538 |
+
|
539 |
+
$params = array('STATUS' => Netresearch_OPS_Model_Status::INVALID_INCOMPLETE, 'PAYID' => '4711');
|
540 |
+
$directlinkHelperMock->processFeedback($order, $params);
|
541 |
+
|
542 |
+
}
|
543 |
+
}
|
544 |
+
|
app/code/community/Netresearch/OPS/Test/Helper/DirectLinkTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/KwixoTest.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Helper_KwixoTest
|
4 |
+
extends EcomDev_PHPUnit_Test_Case_Controller
|
5 |
+
{
|
6 |
+
|
7 |
+
public function testValidateKwixoconfigurationMappingContainsNoData()
|
8 |
+
{
|
9 |
+
|
10 |
+
$this->helperMustThrowException(array());
|
11 |
+
}
|
12 |
+
|
13 |
+
public function testValidateKwixoconfigurationMappingContainsInvalidId()
|
14 |
+
{
|
15 |
+
$this->helperMustThrowException(array('od' => 1));
|
16 |
+
}
|
17 |
+
|
18 |
+
public function testValidateKwixoconfigurationMappingContainsEmptyId()
|
19 |
+
{
|
20 |
+
$this->helperMustThrowException(array('id' => ''));
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testValidateKwixoconfigurationMappingContainsNonNumericId()
|
24 |
+
{
|
25 |
+
$this->helperMustThrowException(array('id' => 'abc'));
|
26 |
+
}
|
27 |
+
|
28 |
+
public function testValidateKwixoconfigurationMappingContainsNegativeId()
|
29 |
+
{
|
30 |
+
$this->helperMustThrowException(array('id' => -1));
|
31 |
+
}
|
32 |
+
|
33 |
+
public function testValidateKwixoconfigurationMappingContainsNoKwixoCategory(
|
34 |
+
)
|
35 |
+
{
|
36 |
+
$this->helperMustThrowException(array('id' => 1));
|
37 |
+
}
|
38 |
+
|
39 |
+
public function testValidateKwixoconfigurationMappingContainsInvalidKwixoCategory(
|
40 |
+
)
|
41 |
+
{
|
42 |
+
$this->helperMustThrowException(
|
43 |
+
array('id' => 1, 'kwixoCategory_id' => 666)
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function testValidateKwixoconfigurationMappingContainsNoCategory()
|
48 |
+
{
|
49 |
+
$this->helperMustThrowException(
|
50 |
+
array('id' => 1, 'kwixoCategory_id' => 1)
|
51 |
+
);
|
52 |
+
}
|
53 |
+
|
54 |
+
public function testValidateKwixoconfigurationMappingContainsNonNumericCategory(
|
55 |
+
)
|
56 |
+
{
|
57 |
+
$this->helperMustThrowException(
|
58 |
+
array('id' => 1, 'kwixoCategory_id' => 1, 'category_id' => 'abc')
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
public function testValidateKwixoconfigurationMappingContainsNegativeCategory(
|
63 |
+
)
|
64 |
+
{
|
65 |
+
$this->helperMustThrowException(
|
66 |
+
array('id' => 1, 'kwixoCategory_id' => 1, 'category_id' => -1)
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
public function testValidateKwixoconfigurationMappingContainsNegativeCategory2(
|
71 |
+
)
|
72 |
+
{
|
73 |
+
$helper = Mage::helper('ops/kwixo');
|
74 |
+
$helper->validateKwixoconfigurationMapping(
|
75 |
+
array('id' => 1, 'kwixoCategory_id' => 1, 'category_id' => 1)
|
76 |
+
);
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
protected function helperMustThrowException($invalidData)
|
81 |
+
{
|
82 |
+
$helper = Mage::helper('ops/kwixo');
|
83 |
+
$this->setExpectedException('Mage_Core_Exception');
|
84 |
+
$helper->validateKwixoconfigurationMapping($invalidData);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @loadFixture category_mapping
|
89 |
+
*/
|
90 |
+
public function testSaveKwixoConfigurationMapping()
|
91 |
+
{
|
92 |
+
$helperMock = $this->getHelperMock(
|
93 |
+
'ops/kwixo', array('validateKwixoconfigurationMapping')
|
94 |
+
);
|
95 |
+
$helperMock->saveKwixoconfigurationMapping(
|
96 |
+
array('id' => 1, 'category_id' => 666, 'kwixoCategory_id' => 777)
|
97 |
+
);
|
98 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(1);
|
99 |
+
$this->assertEquals(666, $model->getCategoryId());
|
100 |
+
$this->assertEquals(777, $model->getKwixoCategoryId());
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @loadFixture category_mapping
|
105 |
+
*/
|
106 |
+
public function testSaveKwixoConfigurationMappingForSubCategories()
|
107 |
+
{
|
108 |
+
$helperMock = $this->getHelperMock(
|
109 |
+
'ops/kwixo', array('validateKwixoconfigurationMapping')
|
110 |
+
);
|
111 |
+
|
112 |
+
$categoryMock = $this->getModelMock('catalog/category', array('load', 'getAllChildren'));
|
113 |
+
$categoryMock->expects($this->any())
|
114 |
+
->method('getAllChildren')
|
115 |
+
->will($this->returnValue(array(11)));
|
116 |
+
$categoryMock->expects($this->any())
|
117 |
+
->method('load')
|
118 |
+
->will($this->returnValue($categoryMock));
|
119 |
+
$this->replaceByMock('model', 'catalog/category', $categoryMock);
|
120 |
+
|
121 |
+
$helperMock->saveKwixoconfigurationMapping(
|
122 |
+
array('id' => 1, 'category_id' => 666,
|
123 |
+
'kwixoCategory_id' => 777, 'applysubcat' => true)
|
124 |
+
);
|
125 |
+
|
126 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(1);
|
127 |
+
$this->assertEquals(666, $model->getCategoryId());
|
128 |
+
$this->assertEquals(777, $model->getKwixoCategoryId());
|
129 |
+
$model = Mage::getModel('ops/kwixo_category_mapping')->load(2);
|
130 |
+
$this->assertEquals(777, $model->getKwixoCategoryId());
|
131 |
+
}
|
132 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/KwixoTest/fixtures/category_mapping.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
ops/kwixo_category_mapping:
|
3 |
+
- id: 1
|
4 |
+
kwixo_category_id: 10
|
5 |
+
category_id: 10
|
6 |
+
- id: 2
|
7 |
+
kwixo_category_id: 1
|
8 |
+
category_id: 11
|
9 |
+
- id: 3
|
10 |
+
kwixo_category_id: 2
|
11 |
+
category_id: 11
|
app/code/community/Netresearch/OPS/Test/Helper/Order/CaptureTest.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Helper_Order_CaptureTest extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
8 |
+
*/
|
9 |
+
public function testOperationPartialAndTypePartial()
|
10 |
+
{
|
11 |
+
$helper = Mage::helper('ops/order_capture');
|
12 |
+
$invoice = array("items" => "foo");
|
13 |
+
Mage::app()->getRequest()->setParam('invoice', $invoice);
|
14 |
+
$payment = new Varien_Object();
|
15 |
+
$order = Mage::getModel('sales/order')->load(11);
|
16 |
+
$payment->setOrder($order);
|
17 |
+
// order base_grand_total == grand_total == 119.00
|
18 |
+
|
19 |
+
$expected = array(
|
20 |
+
"items" => $invoice["items"],
|
21 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_PARTIAL,
|
22 |
+
"type" => "partial",
|
23 |
+
"amount" => 100.00
|
24 |
+
);
|
25 |
+
|
26 |
+
$payment->setBaseAmountPaidOnline(0.00);
|
27 |
+
$amount = 100.00;
|
28 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
35 |
+
*/
|
36 |
+
public function testOperationFullAndTypePartial()
|
37 |
+
{
|
38 |
+
$helper = Mage::helper('ops/order_capture');
|
39 |
+
$invoice = array("items" => "foo");
|
40 |
+
Mage::app()->getRequest()->setParam('invoice', $invoice);
|
41 |
+
$payment = new Varien_Object();
|
42 |
+
$order = Mage::getModel('sales/order')->load(11);
|
43 |
+
$payment->setOrder($order);
|
44 |
+
// order base_grand_total == grand_total == 119.00
|
45 |
+
|
46 |
+
$expected = array(
|
47 |
+
"items" => $invoice["items"],
|
48 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_FULL,
|
49 |
+
"type" => "partial",
|
50 |
+
"amount" => 100.00
|
51 |
+
);
|
52 |
+
|
53 |
+
$payment->setBaseAmountPaidOnline(19.00);
|
54 |
+
$amount = 100.00;
|
55 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
60 |
+
*/
|
61 |
+
public function testOperationFullAndTypeFull()
|
62 |
+
{
|
63 |
+
$helper = Mage::helper('ops/order_capture');
|
64 |
+
$invoice = array("items" => "foo");
|
65 |
+
Mage::app()->getRequest()->setParam('invoice', $invoice);
|
66 |
+
$payment = new Varien_Object();
|
67 |
+
$order = Mage::getModel('sales/order')->load(11);
|
68 |
+
$payment->setOrder($order);
|
69 |
+
// order base_grand_total == grand_total == 119.00
|
70 |
+
|
71 |
+
$expected = array(
|
72 |
+
"items" => $invoice["items"],
|
73 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_FULL,
|
74 |
+
"type" => "full",
|
75 |
+
"amount" => 119.00
|
76 |
+
);
|
77 |
+
|
78 |
+
$payment->setBaseAmountPaidOnline(0.00);
|
79 |
+
$amount = 119.00;
|
80 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
81 |
+
}
|
82 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/Order/CaptureTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/Order/RefundTest.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Helper_Order_RefundTest extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
|
6 |
+
public function setUp()
|
7 |
+
{
|
8 |
+
Mage::unregister('_helper/ops/order_refund');
|
9 |
+
parent::setUp();
|
10 |
+
}
|
11 |
+
/**
|
12 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
13 |
+
*/
|
14 |
+
public function testDetermineOperationCode()
|
15 |
+
{
|
16 |
+
/* @var $helper Netresearch_OPS_Helper_Order_Refund */
|
17 |
+
$helper = Mage::helper('ops/order_refund');
|
18 |
+
$payment = new Varien_Object();
|
19 |
+
|
20 |
+
// complete refund should lead to RFS
|
21 |
+
$order = Mage::getModel('sales/order')->load(11);
|
22 |
+
$payment->setOrder($order);
|
23 |
+
$payment->setBaseAmountRefundedOnline(0.00);
|
24 |
+
$amount = 119.00;
|
25 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, $helper->determineOperationCode($payment, $amount));
|
26 |
+
|
27 |
+
// complete refund should lead to RFS
|
28 |
+
$order = Mage::getModel('sales/order')->load(16);
|
29 |
+
$payment->setOrder($order);
|
30 |
+
$payment->setBaseAmountRefundedOnline(0.00);
|
31 |
+
$amount = 19.99;
|
32 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, $helper->determineOperationCode($payment, $amount));
|
33 |
+
|
34 |
+
// partial refund should lead to RFD
|
35 |
+
$order = Mage::getModel('sales/order')->load(11);
|
36 |
+
$payment->setOrder($order);
|
37 |
+
$payment->setBaseAmountRefundedOnline(0.00);
|
38 |
+
$amount = 100.00;
|
39 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL, $helper->determineOperationCode($payment, $amount));
|
40 |
+
|
41 |
+
// partial refund + new amount to refund should lead to RFS
|
42 |
+
$order = Mage::getModel('sales/order')->load(11);
|
43 |
+
$payment->setOrder($order);
|
44 |
+
$payment->setBaseAmountRefundedOnline(19.00);
|
45 |
+
$amount = 100.00;
|
46 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, $helper->determineOperationCode($payment, $amount));
|
47 |
+
|
48 |
+
// partial refund + new amount to refund should lead to RFS
|
49 |
+
$order = Mage::getModel('sales/order')->load(16);
|
50 |
+
$payment->setOrder($order);
|
51 |
+
$payment->setBaseAmountRefundedOnline(17.98);
|
52 |
+
$amount = 2.01;
|
53 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, $helper->determineOperationCode($payment, $amount));
|
54 |
+
|
55 |
+
// partial refund + new amount to refund should lead to RFS
|
56 |
+
$order = Mage::getModel('sales/order')->load(16);
|
57 |
+
$payment->setOrder($order);
|
58 |
+
$payment->setBaseAmountRefundedOnline(17.98);
|
59 |
+
$amount = 2.00;
|
60 |
+
$this->assertEquals(Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL, $helper->determineOperationCode($payment, $amount));
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
66 |
+
*/
|
67 |
+
public function testOperationPartialAndTypePartial()
|
68 |
+
{
|
69 |
+
$helper = Mage::helper('ops/order_refund');
|
70 |
+
$creditmemo = array("creditmemo" => array("items" => "foo"));
|
71 |
+
$helper->setCreditMemoRequestParams($creditmemo);
|
72 |
+
$payment = new Varien_Object();
|
73 |
+
$order = Mage::getModel('sales/order')->load(11);
|
74 |
+
$payment->setOrder($order);
|
75 |
+
// order base_grand_total == grand_total == 119.00
|
76 |
+
|
77 |
+
$expected = array(
|
78 |
+
"items" => $creditmemo["creditmemo"]["items"],
|
79 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL,
|
80 |
+
"type" => "partial",
|
81 |
+
"amount" => 100.00
|
82 |
+
);
|
83 |
+
|
84 |
+
$payment->setBaseAmountRefundedOnline(0.00);
|
85 |
+
$amount = 100.00;
|
86 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
93 |
+
*/
|
94 |
+
public function testOperationFullAndTypePartial()
|
95 |
+
{
|
96 |
+
$helper = Mage::helper('ops/order_refund');
|
97 |
+
$creditmemo = array("creditmemo" => array("items" => "foo"));
|
98 |
+
$helper->setCreditMemoRequestParams($creditmemo);
|
99 |
+
$payment = new Varien_Object();
|
100 |
+
$order = Mage::getModel('sales/order')->load(11);
|
101 |
+
$payment->setOrder($order);
|
102 |
+
// order base_grand_total == grand_total == 119.00
|
103 |
+
|
104 |
+
$expected = array(
|
105 |
+
"items" => $creditmemo["creditmemo"]["items"],
|
106 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
|
107 |
+
"type" => "partial",
|
108 |
+
"amount" => 100.00
|
109 |
+
);
|
110 |
+
|
111 |
+
$payment->setBaseAmountRefundedOnline(19.00);
|
112 |
+
$amount = 100.00;
|
113 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @loadFixture ../../../../var/fixtures/orders.yaml
|
118 |
+
*/
|
119 |
+
public function testOperationFullAndTypeFull()
|
120 |
+
{
|
121 |
+
$helper = Mage::helper('ops/order_refund');
|
122 |
+
$creditmemo = array("creditmemo" => array("items" => "foo"));
|
123 |
+
$helper->setCreditMemoRequestParams($creditmemo);
|
124 |
+
$payment = new Varien_Object();
|
125 |
+
$order = Mage::getModel('sales/order')->load(11);
|
126 |
+
$payment->setOrder($order);
|
127 |
+
// order base_grand_total == grand_total == 119.00
|
128 |
+
|
129 |
+
$expected = array(
|
130 |
+
"items" => $creditmemo["creditmemo"]["items"],
|
131 |
+
"operation" => Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
|
132 |
+
"type" => "full",
|
133 |
+
"amount" => 119.00
|
134 |
+
);
|
135 |
+
|
136 |
+
$payment->setBaseAmountRefundedOnline(0.00);
|
137 |
+
$amount = 119.00;
|
138 |
+
$this->assertEquals($expected, $helper->prepareOperation($payment, $amount));
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/Order/RefundTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/OrderTest.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Helper_OrderTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
|
5 |
+
private $devPrefix = '';
|
6 |
+
|
7 |
+
public function setUp()
|
8 |
+
{
|
9 |
+
$this->devPrefix = Mage::getModel('ops/config')->getConfigData(
|
10 |
+
'devprefix'
|
11 |
+
);
|
12 |
+
parent::setUp();
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @loadFixture order.yaml
|
18 |
+
*/
|
19 |
+
public function testGetOpsOrderId()
|
20 |
+
{
|
21 |
+
$store = Mage::app()->getStore(0)->load(0);
|
22 |
+
$store->resetConfig();
|
23 |
+
$helper = Mage::helper('ops/order');
|
24 |
+
|
25 |
+
$store->setConfig(
|
26 |
+
'payment_services/ops/redirectOrderReference',
|
27 |
+
Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID
|
28 |
+
);
|
29 |
+
|
30 |
+
$order = Mage::getModel('sales/order')->load(1);
|
31 |
+
$delimiter = $helper::DELIMITER;
|
32 |
+
$this->assertEquals(
|
33 |
+
$this->devPrefix . $order->getQuoteId(),
|
34 |
+
$helper->getOpsOrderId($order)
|
35 |
+
);
|
36 |
+
|
37 |
+
|
38 |
+
$store->setConfig(
|
39 |
+
'payment_services/ops/redirectOrderReference',
|
40 |
+
Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
|
41 |
+
);
|
42 |
+
|
43 |
+
$order = Mage::getModel('sales/order')->load(2);
|
44 |
+
$this->assertEquals(
|
45 |
+
$this->devPrefix . $delimiter . $order->getIncrementId(),
|
46 |
+
$helper->getOpsOrderId($order)
|
47 |
+
);
|
48 |
+
|
49 |
+
$store->setConfig(
|
50 |
+
'payment_services/ops/redirectOrderReference',
|
51 |
+
Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID
|
52 |
+
);
|
53 |
+
$order = Mage::getModel('sales/order')->load(3);
|
54 |
+
$this->assertEquals(
|
55 |
+
$this->devPrefix . $order->getQuoteId(),
|
56 |
+
$helper->getOpsOrderId($order)
|
57 |
+
);
|
58 |
+
|
59 |
+
$store->setConfig(
|
60 |
+
'payment_services/ops/redirectOrderReference',
|
61 |
+
Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID
|
62 |
+
);
|
63 |
+
$order = Mage::getModel('sales/order')->load(3);
|
64 |
+
$this->assertEquals(
|
65 |
+
$this->devPrefix . $order->getQuoteId(),
|
66 |
+
$helper->getOpsOrderId($order, false)
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @loadFixture order.yaml
|
73 |
+
*/
|
74 |
+
public function testGetOrder()
|
75 |
+
{
|
76 |
+
$helper = Mage::helper('ops/order');
|
77 |
+
// old behaviour: load order from quote
|
78 |
+
$opsOrderId = $this->devPrefix . '5';
|
79 |
+
$order = $helper->getOrder($opsOrderId);
|
80 |
+
$this->assertEquals(4, $order->getId());
|
81 |
+
|
82 |
+
// new behaviour
|
83 |
+
$delimiter = $helper::DELIMITER;
|
84 |
+
$opsOrderId = $this->devPrefix . $delimiter . 2000;
|
85 |
+
$order = $helper->getOrder($opsOrderId);
|
86 |
+
$this->assertEquals(2, $order->getId());
|
87 |
+
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @loadFixture order.yaml
|
94 |
+
*/
|
95 |
+
public function testGetQuote()
|
96 |
+
{
|
97 |
+
$order = Mage::getModel('sales/order')->load(1);
|
98 |
+
$quote = Mage::helper('ops/order')->getQuote($order->getQuoteId());
|
99 |
+
$this->assertTrue($quote instanceof Mage_Sales_Model_Quote);
|
100 |
+
$this->assertEquals(1, $quote->getId());
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
105 |
+
*/
|
106 |
+
public function testCheckIfAddressAreSameWithSameAddressData()
|
107 |
+
{
|
108 |
+
$order = Mage::getModel('sales/order')->load(11);
|
109 |
+
$this->assertTrue(
|
110 |
+
(bool)Mage::helper('ops/order')->checkIfAddressesAreSame($order)
|
111 |
+
);
|
112 |
+
|
113 |
+
$order = Mage::getModel('sales/order')->load(27);
|
114 |
+
$this->assertFalse(
|
115 |
+
(bool)Mage::helper('ops/order')->checkIfAddressesAreSame($order)
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
121 |
+
*/
|
122 |
+
public function testCheckIfAddressAreSameWithDifferentAddressData()
|
123 |
+
{
|
124 |
+
$order = Mage::getModel('sales/order')->load(12);
|
125 |
+
$this->assertFalse(
|
126 |
+
(bool)Mage::helper('ops/order')->checkIfAddressesAreSame($order)
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
public function testSetDataHelper()
|
131 |
+
{
|
132 |
+
$dataHelper = $this->getHelperMock('ops/data');
|
133 |
+
$helper = Mage::helper('ops/order');
|
134 |
+
$helper->setDataHelper($dataHelper);
|
135 |
+
$this->assertEquals($dataHelper, $helper->getDataHelper());
|
136 |
+
}
|
137 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/OrderTest/fixtures/order.yaml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
sales/order:
|
3 |
+
- entity_id: 1
|
4 |
+
increment_id: 1000
|
5 |
+
quote_id: 1
|
6 |
+
|
7 |
+
- entity_id: 2
|
8 |
+
increment_id: 2000
|
9 |
+
quote_id: 2
|
10 |
+
|
11 |
+
- entity_id: 3
|
12 |
+
quote_id: 3
|
13 |
+
|
14 |
+
- id: 4
|
15 |
+
entity_id: 4
|
16 |
+
increment_id: 4000
|
17 |
+
quote_id: 5
|
18 |
+
|
19 |
+
- id: 5
|
20 |
+
entity_id: 5
|
21 |
+
increment_id: 1001
|
22 |
+
quote_id: 5
|
23 |
+
|
24 |
+
|
25 |
+
sales/quote:
|
26 |
+
- id: 1
|
27 |
+
entity_id: 1
|
28 |
+
parent_id: 1
|
29 |
+
|
30 |
+
- id: 5
|
31 |
+
entity_id: 5
|
32 |
+
parent_id: 1
|
33 |
+
|
34 |
+
sales/order_payment:
|
35 |
+
- parent_id: 4
|
36 |
+
method: 'ops_test'
|
37 |
+
|
38 |
+
- parent_id: 2
|
39 |
+
method: 'ops_test'
|
40 |
+
|
41 |
+
- parent_id: 5
|
42 |
+
method: 'ops_test'
|
app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Test_Helper_Payment_DirectLink_RequestTest extends EcomDev_PHPUnit_Test_Case_Controller
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @loadFixture ../../../../../var/fixtures/orders.yaml
|
14 |
+
*/
|
15 |
+
public function testGetBaseParams()
|
16 |
+
{
|
17 |
+
$order = Mage::getModel('sales/order')->load(11);
|
18 |
+
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
19 |
+
$quote->getPayment()->setMethod('ops_cc');
|
20 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
21 |
+
$configMock->expects($this->any())
|
22 |
+
->method('canSubmitExtraParameter')
|
23 |
+
->will($this->returnValue(false));
|
24 |
+
$paramHelper = Mage::helper('ops/creditcard');
|
25 |
+
$paramHelper->setConfig($configMock);
|
26 |
+
$paramHelper->getRequestHelper()->setConfig($configMock);
|
27 |
+
$params = $paramHelper->getDirectLinkRequestParams($quote, $order);
|
28 |
+
foreach ($this->getOwnerParams() as $ownerParam) {
|
29 |
+
$this->assertArrayNotHasKey($ownerParam, $params);
|
30 |
+
}
|
31 |
+
foreach ($this->getShippingParams() as $shippingParam) {
|
32 |
+
$this->assertArrayNotHasKey($shippingParam, $params);
|
33 |
+
}
|
34 |
+
$this->assertArrayHasKey('RTIMEOUT', $params);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @loadFixture ../../../../../var/fixtures/orders.yaml
|
39 |
+
*/
|
40 |
+
public function testGetExtraParams()
|
41 |
+
{
|
42 |
+
$order = Mage::getModel('sales/order')->load(11);
|
43 |
+
$quote = Mage::getModel('sales/quote');
|
44 |
+
$quote->getPayment()->setMethod('ops_cc');
|
45 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
46 |
+
$configMock->expects($this->any())
|
47 |
+
->method('canSubmitExtraParameter')
|
48 |
+
->will($this->returnValue(true));
|
49 |
+
$paramHelper = Mage::helper('ops/creditcard');
|
50 |
+
$paramHelper->setConfig($configMock);
|
51 |
+
$paramHelper->getRequestHelper()->setConfig($configMock);
|
52 |
+
$params = $paramHelper->getDirectLinkRequestParams($quote, $order);
|
53 |
+
foreach ($this->getOwnerParams() as $ownerParam) {
|
54 |
+
$this->assertArrayHasKey($ownerParam, $params);
|
55 |
+
}
|
56 |
+
foreach ($this->getShippingParams() as $shippingParam) {
|
57 |
+
$this->assertArrayHasKey($shippingParam, $params);
|
58 |
+
}
|
59 |
+
$this->assertArrayHasKey('RTIMEOUT', $params);
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function getOwnerParams()
|
64 |
+
{
|
65 |
+
return $ownerParams = array(
|
66 |
+
'OWNERADDRESS',
|
67 |
+
'OWNERTOWN',
|
68 |
+
'OWNERZIP',
|
69 |
+
'OWNERTELNO',
|
70 |
+
'OWNERCTY',
|
71 |
+
'ECOM_BILLTO_POSTAL_POSTALCODE',
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function getShippingParams()
|
76 |
+
{
|
77 |
+
$paramValues = array(
|
78 |
+
'ECOM_SHIPTO_POSTAL_NAME_FIRST',
|
79 |
+
'ECOM_SHIPTO_POSTAL_NAME_LAST',
|
80 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE1',
|
81 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE2',
|
82 |
+
'ECOM_SHIPTO_POSTAL_COUNTRYCODE',
|
83 |
+
'ECOM_SHIPTO_POSTAL_CITY',
|
84 |
+
'ECOM_SHIPTO_POSTAL_POSTALCODE'
|
85 |
+
);
|
86 |
+
|
87 |
+
return $paramValues;
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/Payment/DirectLink/RequestTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/Payment/RequestTest.php
ADDED
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Helper_Payment_RequestTest extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @return Netresearch_OPS_Helper_Payment_RequestTest
|
8 |
+
*/
|
9 |
+
protected function getRequestHelper()
|
10 |
+
{
|
11 |
+
return Mage::helper('ops/payment_request');
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function getShipToArrayKeys()
|
15 |
+
{
|
16 |
+
return array(
|
17 |
+
'ECOM_SHIPTO_POSTAL_NAME_FIRST',
|
18 |
+
'ECOM_SHIPTO_POSTAL_NAME_LAST',
|
19 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE1',
|
20 |
+
'ECOM_SHIPTO_POSTAL_STREET_LINE2',
|
21 |
+
'ECOM_SHIPTO_POSTAL_COUNTRYCODE',
|
22 |
+
'ECOM_SHIPTO_POSTAL_CITY',
|
23 |
+
'ECOM_SHIPTO_POSTAL_POSTALCODE',
|
24 |
+
'ECOM_SHIPTO_POSTAL_STATE',
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
public function testExtractShipToParameters()
|
29 |
+
{
|
30 |
+
$address = Mage::getModel('sales/quote_address');
|
31 |
+
$helper = $this->getRequestHelper();
|
32 |
+
$configMock = $this->getModelMock('ops/config', array('canSubmitExtraParameter'));
|
33 |
+
$configMock->expects($this->any())
|
34 |
+
->method('canSubmitExtraParameter')
|
35 |
+
->will($this->returnValue(true));
|
36 |
+
$helper->setConfig($configMock);
|
37 |
+
$params = $helper->extractShipToParameters($address, Mage::getModel('sales/quote'));
|
38 |
+
$this->assertTrue(is_array($params));
|
39 |
+
foreach ($this->getShipToArrayKeys() as $key) {
|
40 |
+
$this->assertArrayHasKey($key, $params);
|
41 |
+
}
|
42 |
+
|
43 |
+
$address->setFirstname('Hans');
|
44 |
+
$address->setLastname('Wurst');
|
45 |
+
$address->setStreet('Nonnenstrasse 11d');
|
46 |
+
$address->setCountry('DE');
|
47 |
+
$address->setCity('Leipzig');
|
48 |
+
$address->setPostcode('04229');
|
49 |
+
$params = $this->getRequestHelper()->extractShipToParameters($address, Mage::getModel('sales/quote'));
|
50 |
+
$this->assertEquals('Hans', $params['ECOM_SHIPTO_POSTAL_NAME_FIRST']);
|
51 |
+
$this->assertEquals('Wurst', $params['ECOM_SHIPTO_POSTAL_NAME_LAST']);
|
52 |
+
$this->assertEquals('Nonnenstrasse 11d', $params['ECOM_SHIPTO_POSTAL_STREET_LINE1']);
|
53 |
+
$this->assertEquals('', $params['ECOM_SHIPTO_POSTAL_STREET_LINE2']);
|
54 |
+
$this->assertEquals('DE', $params['ECOM_SHIPTO_POSTAL_COUNTRYCODE']);
|
55 |
+
$this->assertEquals('Leipzig', $params['ECOM_SHIPTO_POSTAL_CITY']);
|
56 |
+
$this->assertEquals('04229', $params['ECOM_SHIPTO_POSTAL_POSTALCODE']);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function testGetIsoRegionCodeWithIsoRegionCode()
|
60 |
+
{
|
61 |
+
$address = Mage::getModel('customer/address');
|
62 |
+
$address->setRegionCode('SN');
|
63 |
+
$address->setCountry('DE');
|
64 |
+
$this->assertEquals('SN', $this->getRequestHelper()->getIsoRegionCode($address));
|
65 |
+
}
|
66 |
+
|
67 |
+
public function testGetIsoRegionCodeWithIsoRegionCodeContainingTheCountryCode()
|
68 |
+
{
|
69 |
+
$address = Mage::getModel('customer/address');
|
70 |
+
$address->setRegionCode('ES-AB');
|
71 |
+
$address->setCountry('ES');
|
72 |
+
$this->assertEquals('AB', $this->getRequestHelper()->getIsoRegionCode($address));
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
public function testGetIsoRegionCodeWithGermanMageRegionCode()
|
77 |
+
{
|
78 |
+
$address = Mage::getModel('customer/address');
|
79 |
+
$address->setRegionCode('SAS');
|
80 |
+
$address->setCountry('DE');
|
81 |
+
$this->assertEquals('SN', $this->getRequestHelper()->getIsoRegionCode($address));
|
82 |
+
$address->setRegionCode('NDS');
|
83 |
+
$this->assertEquals('NI', $this->getRequestHelper()->getIsoRegionCode($address));
|
84 |
+
$address->setRegionCode('THE');
|
85 |
+
$this->assertEquals('TH', $this->getRequestHelper()->getIsoRegionCode($address));
|
86 |
+
}
|
87 |
+
|
88 |
+
public function testGetIsoRegionCodeWithAustrianMageRegionCode()
|
89 |
+
{
|
90 |
+
$address = Mage::getModel('customer/address');
|
91 |
+
$address->setRegionCode('WI');
|
92 |
+
$address->setCountry('AT');
|
93 |
+
$this->assertEquals('9', $this->getRequestHelper()->getIsoRegionCode($address));
|
94 |
+
$address->setRegionCode('NO');
|
95 |
+
$this->assertEquals('3', $this->getRequestHelper()->getIsoRegionCode($address));
|
96 |
+
$address->setRegionCode('VB');
|
97 |
+
$this->assertEquals('8', $this->getRequestHelper()->getIsoRegionCode($address));
|
98 |
+
}
|
99 |
+
|
100 |
+
public function testGetIsoRegionCodeWithSpanishMageRegionCode()
|
101 |
+
{
|
102 |
+
$address = Mage::getModel('customer/address');
|
103 |
+
$address->setRegionCode('A Coruсa');
|
104 |
+
$address->setCountry('ES');
|
105 |
+
$this->assertEquals('C', $this->getRequestHelper()->getIsoRegionCode($address));
|
106 |
+
$address->setRegionCode('Barcelona');
|
107 |
+
$this->assertEquals('B', $this->getRequestHelper()->getIsoRegionCode($address));
|
108 |
+
$address->setRegionCode('Madrid');
|
109 |
+
$this->assertEquals('M', $this->getRequestHelper()->getIsoRegionCode($address));
|
110 |
+
}
|
111 |
+
|
112 |
+
public function testGetIsoRegionCodeWithFinnishMageRegionCode()
|
113 |
+
{
|
114 |
+
$address = Mage::getModel('customer/address');
|
115 |
+
$address->setRegionCode('Lappi');
|
116 |
+
$address->setCountry('FI');
|
117 |
+
$this->assertEquals('10', $this->getRequestHelper()->getIsoRegionCode($address));
|
118 |
+
$address->setRegionCode('Etelä-Savo');
|
119 |
+
$this->assertEquals('04', $this->getRequestHelper()->getIsoRegionCode($address));
|
120 |
+
$address->setRegionCode('Itä-Uusimaa');
|
121 |
+
$this->assertEquals('19', $this->getRequestHelper()->getIsoRegionCode($address));
|
122 |
+
}
|
123 |
+
|
124 |
+
public function testGetIsoRegionCodeWithLatvianMageRegionCode()
|
125 |
+
{
|
126 |
+
$address = Mage::getModel('customer/address');
|
127 |
+
$address->setRegionCode('Ādažu novads');
|
128 |
+
$address->setCountry('LV');
|
129 |
+
$this->assertEquals('LV', $this->getRequestHelper()->getIsoRegionCode($address));
|
130 |
+
$address->setRegionCode('Engures novads');
|
131 |
+
$this->assertEquals('029', $this->getRequestHelper()->getIsoRegionCode($address));
|
132 |
+
$address->setRegionCode('Viļakas novads');
|
133 |
+
$this->assertEquals('108', $this->getRequestHelper()->getIsoRegionCode($address));
|
134 |
+
}
|
135 |
+
|
136 |
+
public function testGetIsoRegionCodeWithUnknownRegionCode()
|
137 |
+
{
|
138 |
+
$address = Mage::getModel('customer/address');
|
139 |
+
$address->setRegionCode('DEFG');
|
140 |
+
$address->setCountry('AB');
|
141 |
+
$this->assertEquals('AB', $this->getRequestHelper()->getIsoRegionCode($address));
|
142 |
+
$address->setRegionCode('DEF');
|
143 |
+
$this->assertEquals('DEF', $this->getRequestHelper()->getIsoRegionCode($address));
|
144 |
+
$address->setRegionCode('DF');
|
145 |
+
$this->assertEquals('DF', $this->getRequestHelper()->getIsoRegionCode($address));
|
146 |
+
}
|
147 |
+
|
148 |
+
public function testGetTemplateParamsIframeMode()
|
149 |
+
{
|
150 |
+
$config = $this->getModelMock('ops/config', array('getConfigData'));
|
151 |
+
$config->expects($this->any())
|
152 |
+
->method('getConfigData')
|
153 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_IFRAME));
|
154 |
+
$helper = Mage::helper('ops/payment_request');
|
155 |
+
$helper->setConfig($config);
|
156 |
+
|
157 |
+
$params = $helper->getTemplateParams();
|
158 |
+
|
159 |
+
$this->assertArrayHasKey('PARAMPLUS', $params);
|
160 |
+
$this->assertEquals('IFRAME=1', $params['PARAMPLUS']);
|
161 |
+
$this->assertArrayHasKey('TITLE', $params);
|
162 |
+
$this->assertArrayNotHasKey('TP', $params);
|
163 |
+
}
|
164 |
+
|
165 |
+
public function testGetTemplateParamsNoMode()
|
166 |
+
{
|
167 |
+
$config = $this->getModelMock('ops/config', array('getConfigData'));
|
168 |
+
$config->expects($this->any())
|
169 |
+
->method('getConfigData')
|
170 |
+
->will($this->returnValue(null));
|
171 |
+
$helper = Mage::helper('ops/payment_request');
|
172 |
+
$helper->setConfig($config);
|
173 |
+
|
174 |
+
$params = $helper->getTemplateParams();
|
175 |
+
|
176 |
+
$this->assertArrayNotHasKey('PARAMPLUS', $params);
|
177 |
+
$this->assertArrayNotHasKey('TITLE', $params);
|
178 |
+
$this->assertArrayNotHasKey('TP', $params);
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
public function testGetTemplateParamsRedirectMode()
|
183 |
+
{
|
184 |
+
$config = $this->getModelMock('ops/config', array('getConfigData'));
|
185 |
+
$config->expects($this->any())
|
186 |
+
->method('getConfigData')
|
187 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_REDIRECT));
|
188 |
+
$helper = Mage::helper('ops/payment_request');
|
189 |
+
$helper->setConfig($config);
|
190 |
+
|
191 |
+
$params = $helper->getTemplateParams();
|
192 |
+
$this->assertArrayNotHasKey('PARAMPLUS', $params);
|
193 |
+
$this->assertArrayHasKey('TITLE', $params);
|
194 |
+
$this->assertArrayNotHasKey('TP', $params);
|
195 |
+
}
|
196 |
+
|
197 |
+
public function testExtractOrderItemParametersWithAllItems()
|
198 |
+
{
|
199 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
200 |
+
->disableOriginalConstructor()
|
201 |
+
->setMethods(null)
|
202 |
+
->getMock();
|
203 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
204 |
+
|
205 |
+
// setup one item
|
206 |
+
$item = Mage::getModel('sales/order_item');
|
207 |
+
$item->setId(1);
|
208 |
+
$item->setName('Item');
|
209 |
+
$item->setBasePriceInclTax(10.00);
|
210 |
+
$item->setQtyOrdered(1);
|
211 |
+
$item->setTaxPercent(19.00);
|
212 |
+
$item->setProductType(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
|
213 |
+
|
214 |
+
$order = $this->getModelMock('sales/order', array('getAllItems'));
|
215 |
+
$order->expects($this->once())
|
216 |
+
->method('getAllItems')
|
217 |
+
->will($this->returnValue(array($item)));
|
218 |
+
|
219 |
+
// prepare discount item
|
220 |
+
$order->setBaseDiscountAmount(1.00)
|
221 |
+
->setCouponRuleName('DISCOUNT');
|
222 |
+
|
223 |
+
//prepare shipping Item
|
224 |
+
$order->setShippingDescription('SHIPPING')
|
225 |
+
->setBaseShippingInclTax(5.00)
|
226 |
+
->setIsVirtual(0);
|
227 |
+
|
228 |
+
$helper = Mage::helper('ops/payment_request');
|
229 |
+
|
230 |
+
$formFields = $helper->extractOrderItemParameters($order);
|
231 |
+
|
232 |
+
$this->assertArrayHasKey('ITEMID1', $formFields);
|
233 |
+
$this->assertArrayHasKey('ITEMID2', $formFields);
|
234 |
+
$this->assertArrayHasKey('ORDERSHIPCOST', $formFields);
|
235 |
+
}
|
236 |
+
|
237 |
+
public function testExtractOrderItemParametersWithNoItems()
|
238 |
+
{
|
239 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
240 |
+
->disableOriginalConstructor()
|
241 |
+
->setMethods(null)
|
242 |
+
->getMock();
|
243 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
244 |
+
|
245 |
+
// setup one item
|
246 |
+
$item = Mage::getModel('sales/order_item');
|
247 |
+
$item->setProductType(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE);
|
248 |
+
|
249 |
+
$order = $this->getModelMock('sales/order', array('getAllItems'));
|
250 |
+
$order->expects($this->once())
|
251 |
+
->method('getAllItems')
|
252 |
+
->will($this->returnValue(array($item)));
|
253 |
+
|
254 |
+
// prepare discount item
|
255 |
+
$order->setBaseDiscountAmount(0.00);
|
256 |
+
|
257 |
+
//prepare shipping Item
|
258 |
+
$order->setIsVirtual(true);
|
259 |
+
|
260 |
+
$helper = Mage::helper('ops/payment_request');
|
261 |
+
|
262 |
+
$formFields = $helper->extractOrderItemParameters($order);
|
263 |
+
|
264 |
+
$this->assertArrayNotHasKey('ITEMID1', $formFields);
|
265 |
+
$this->assertArrayNotHasKey('ITEMID2', $formFields);
|
266 |
+
$this->assertArrayNotHasKey('ITEMID3', $formFields);
|
267 |
+
}
|
268 |
+
|
269 |
+
public function testGetTemplateParamsTemplateMode()
|
270 |
+
{
|
271 |
+
$config = $this->getModelMock('ops/config', array('getConfigData'));
|
272 |
+
$config->expects($this->any())
|
273 |
+
->method('getConfigData')
|
274 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_OPS_TEMPLATE));
|
275 |
+
$helper = Mage::helper('ops/payment_request');
|
276 |
+
$helper->setConfig($config);
|
277 |
+
|
278 |
+
$params = $helper->getTemplateParams();
|
279 |
+
$this->assertArrayNotHasKey('PARAMPLUS', $params);
|
280 |
+
$this->assertArrayNotHasKey('TITLE', $params);
|
281 |
+
$this->assertArrayHasKey('TP', $params);
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
public function testGetTemplateParamsInternalTemplateMode()
|
286 |
+
{
|
287 |
+
$config = $this->getModelMock('ops/config', array('getConfigData'));
|
288 |
+
$config->expects($this->any())
|
289 |
+
->method('getConfigData')
|
290 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::TEMPLATE_MAGENTO_INTERNAL));
|
291 |
+
$helper = Mage::helper('ops/payment_request');
|
292 |
+
$helper->setConfig($config);
|
293 |
+
|
294 |
+
$params = $helper->getTemplateParams();
|
295 |
+
$this->assertArrayNotHasKey('PARAMPLUS', $params);
|
296 |
+
$this->assertArrayNotHasKey('TITLE', $params);
|
297 |
+
$this->assertArrayHasKey('TP', $params);
|
298 |
+
$this->assertEquals($config->getPayPageTemplate(), $params['TP']);
|
299 |
+
}
|
300 |
+
|
301 |
+
public function testGetMandatoryRequestFieldsWithFPActiveOff()
|
302 |
+
{
|
303 |
+
$payment = Mage::getModel('sales/order_payment');
|
304 |
+
$payment->setMethod('ops_cc');
|
305 |
+
$order = Mage::getModel('sales/order');
|
306 |
+
$order->setStoreId(0)->setPayment($payment);
|
307 |
+
$subject = Mage::helper('ops/payment_request');
|
308 |
+
$sessionMock = $this->mockSession('customer/session', array('getData'));
|
309 |
+
$sessionMock->expects($this->any())
|
310 |
+
->method('getData')
|
311 |
+
->with(Netresearch_OPS_Model_Payment_Abstract::FINGERPRINT_CONSENT_SESSION_KEY)
|
312 |
+
->will($this->returnValue(true));
|
313 |
+
|
314 |
+
$params = $subject->getMandatoryRequestFields($order);
|
315 |
+
|
316 |
+
$this->assertEquals(0, $params['FP_ACTIV']);
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/PaymentTest.php
ADDED
@@ -0,0 +1,777 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Helper_PaymentTest
|
3 |
+
extends Netresearch_OPS_Test_Model_Response_TestCase
|
4 |
+
{
|
5 |
+
private $_helper;
|
6 |
+
private $store;
|
7 |
+
|
8 |
+
public function setUp()
|
9 |
+
{
|
10 |
+
parent::setup();
|
11 |
+
$this->_helper = Mage::helper('ops/payment');
|
12 |
+
$this->store = Mage::app()->getStore(0)->load(0);
|
13 |
+
$this->store->resetConfig();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function testIsPaymentAuthorizeType()
|
17 |
+
{
|
18 |
+
$this->assertTrue(
|
19 |
+
$this->_helper->isPaymentAuthorizeType(
|
20 |
+
Netresearch_OPS_Model_Status::AUTHORIZED
|
21 |
+
)
|
22 |
+
);
|
23 |
+
$this->assertTrue(
|
24 |
+
$this->_helper->isPaymentAuthorizeType(
|
25 |
+
Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING
|
26 |
+
)
|
27 |
+
);
|
28 |
+
$this->assertTrue(
|
29 |
+
$this->_helper->isPaymentAuthorizeType(
|
30 |
+
Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN
|
31 |
+
)
|
32 |
+
);
|
33 |
+
$this->assertTrue(
|
34 |
+
$this->_helper->isPaymentAuthorizeType(
|
35 |
+
Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT
|
36 |
+
)
|
37 |
+
);
|
38 |
+
$this->assertFalse($this->_helper->isPaymentAuthorizeType(0));
|
39 |
+
}
|
40 |
+
|
41 |
+
public function testIsPaymentCaptureType()
|
42 |
+
{
|
43 |
+
$this->assertTrue(
|
44 |
+
$this->_helper->isPaymentCaptureType(
|
45 |
+
Netresearch_OPS_Model_Status::PAYMENT_REQUESTED
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$this->assertTrue(
|
49 |
+
$this->_helper->isPaymentCaptureType(
|
50 |
+
Netresearch_OPS_Model_Status::PAYMENT_PROCESSING
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$this->assertTrue(
|
54 |
+
$this->_helper->isPaymentCaptureType(
|
55 |
+
Netresearch_OPS_Model_Status::PAYMENT_UNCERTAIN
|
56 |
+
)
|
57 |
+
);
|
58 |
+
$this->assertFalse($this->_helper->isPaymentCaptureType(0));
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* send no invoice mail if it is denied by configuration
|
63 |
+
*/
|
64 |
+
public function testSendNoInvoiceToCustomerIfDenied()
|
65 |
+
{
|
66 |
+
$this->store->setConfig('payment_services/ops/send_invoice', 0);
|
67 |
+
$this->assertFalse(Mage::getModel('ops/config')->getSendInvoice());
|
68 |
+
$sentInvoice = $this->getModelMock(
|
69 |
+
'sales/order_invoice', array('getEmailSent', 'sendEmail')
|
70 |
+
);
|
71 |
+
$sentInvoice->expects($this->any())
|
72 |
+
->method('getEmailSent')
|
73 |
+
->will($this->returnValue(false));
|
74 |
+
$sentInvoice->expects($this->never())
|
75 |
+
->method('sendEmail');
|
76 |
+
$this->_helper->sendInvoiceToCustomer($sentInvoice);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* send no invoice mail if it was already sent
|
81 |
+
*/
|
82 |
+
public function testSendNoInvoiceToCustomerIfAlreadySent()
|
83 |
+
{
|
84 |
+
$this->store->setConfig('payment_services/ops/send_invoice', 1);
|
85 |
+
$this->assertTrue(Mage::getModel('ops/config')->getSendInvoice());
|
86 |
+
$someInvoice = $this->getModelMock(
|
87 |
+
'sales/order_invoice', array('getEmailSent', 'sendEmail')
|
88 |
+
);
|
89 |
+
$someInvoice->expects($this->any())
|
90 |
+
->method('getEmailSent')
|
91 |
+
->will($this->returnValue(true));
|
92 |
+
$someInvoice->expects($this->never())
|
93 |
+
->method('sendEmail');
|
94 |
+
$this->_helper->sendInvoiceToCustomer($someInvoice);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* send invoice mail
|
99 |
+
*/
|
100 |
+
public function testSendInvoiceToCustomerIfEnabled()
|
101 |
+
{
|
102 |
+
$this->store->setConfig('payment_services/ops/send_invoice', 1);
|
103 |
+
$this->assertTrue(Mage::getModel('ops/config')->getSendInvoice());
|
104 |
+
$anotherInvoice = $this->getModelMock(
|
105 |
+
'sales/order_invoice', array('getEmailSent', 'sendEmail')
|
106 |
+
);
|
107 |
+
$anotherInvoice->expects($this->any())
|
108 |
+
->method('getEmailSent')
|
109 |
+
->will($this->returnValue(false));
|
110 |
+
$anotherInvoice->expects($this->once())
|
111 |
+
->method('sendEmail')
|
112 |
+
->with($this->equalTo(true));
|
113 |
+
$this->_helper->sendInvoiceToCustomer($anotherInvoice);
|
114 |
+
}
|
115 |
+
|
116 |
+
public function testPrepareParamsAndSort()
|
117 |
+
{
|
118 |
+
$params = array(
|
119 |
+
'CVC' => '123',
|
120 |
+
'CARDNO' => '4111111111111111',
|
121 |
+
'CN' => 'JohnSmith',
|
122 |
+
'PSPID' => 'test1',
|
123 |
+
'ED' => '1212',
|
124 |
+
'ACCEPTURL' => 'https=//www.myshop.com/ok.html',
|
125 |
+
'EXCEPTIONURL' => 'https=//www.myshop.com/nok.html',
|
126 |
+
'BRAND' => 'VISA',
|
127 |
+
);
|
128 |
+
$sortedParams = array(
|
129 |
+
'ACCEPTURL' => array('key' => 'ACCEPTURL',
|
130 |
+
'value' => 'https=//www.myshop.com/ok.html'),
|
131 |
+
'BRAND' => array('key' => 'BRAND', 'value' => 'VISA'),
|
132 |
+
'CARDNO' => array('key' => 'CARDNO',
|
133 |
+
'value' => '4111111111111111'),
|
134 |
+
'CN' => array('key' => 'CN', 'value' => 'JohnSmith'),
|
135 |
+
'CVC' => array('key' => 'CVC', 'value' => '123'),
|
136 |
+
'ED' => array('key' => 'ED', 'value' => '1212'),
|
137 |
+
'EXCEPTIONURL' => array('key' => 'EXCEPTIONURL',
|
138 |
+
'value' => 'https=//www.myshop.com/nok.html'),
|
139 |
+
'PSPID' => array('key' => 'PSPID', 'value' => 'test1'),
|
140 |
+
);
|
141 |
+
$secret = 'Mysecretsig1875!?';
|
142 |
+
$shaInSet
|
143 |
+
=
|
144 |
+
'ACCEPTURL=https=//www.myshop.com/ok.htmlMysecretsig1875!?BRAND=VISAMysecretsig1875!?'
|
145 |
+
. 'CARDNO=4111111111111111Mysecretsig1875!?CN=JohnSmithMysecretsig1875!?CVC=123Mysecretsig1875!?'
|
146 |
+
. 'ED=1212Mysecretsig1875!?EXCEPTIONURL=https=//www.myshop.com/nok.htmlMysecretsig1875!?'
|
147 |
+
. 'PSPID=test1Mysecretsig1875!?';
|
148 |
+
$key = 'a28dc9fe69b63fe81da92471fefa80aca3f4851a';
|
149 |
+
$this->assertEquals(
|
150 |
+
$sortedParams, $this->_helper->prepareParamsAndSort($params)
|
151 |
+
);
|
152 |
+
$this->assertEquals(
|
153 |
+
$shaInSet, $this->_helper->getSHAInSet($params, $secret)
|
154 |
+
);
|
155 |
+
$this->assertEquals($key, $this->_helper->shaCrypt($shaInSet, $secret));
|
156 |
+
}
|
157 |
+
|
158 |
+
public function testHandleUnknownStatus()
|
159 |
+
{
|
160 |
+
$order = $this->getModelMock('sales/order', array('save'));
|
161 |
+
$order->expects($this->any())
|
162 |
+
->method('save')
|
163 |
+
->will($this->returnValue(true));
|
164 |
+
$order->setState(
|
165 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
166 |
+
Mage_Sales_Model_Order::STATE_NEW
|
167 |
+
);
|
168 |
+
$statusHistoryCount = $order->getStatusHistoryCollection()->count();
|
169 |
+
Mage::helper('ops/payment')->handleUnknownStatus($order);
|
170 |
+
$this->assertEquals(
|
171 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $order->getState()
|
172 |
+
);
|
173 |
+
$this->assertTrue(
|
174 |
+
$statusHistoryCount < $order->getStatusHistoryCollection()->count()
|
175 |
+
);
|
176 |
+
$statusHistoryCount = $order->getStatusHistoryCollection()->count();
|
177 |
+
$order->setState(
|
178 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
179 |
+
Mage_Sales_Model_Order::STATE_PROCESSING
|
180 |
+
);
|
181 |
+
|
182 |
+
Mage::helper('ops/payment')->handleUnknownStatus($order);
|
183 |
+
$this->assertEquals(
|
184 |
+
Mage_Sales_Model_Order::STATE_PROCESSING, $order->getState()
|
185 |
+
);
|
186 |
+
$this->assertTrue(
|
187 |
+
$statusHistoryCount < $order->getStatusHistoryCollection()->count()
|
188 |
+
);
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
193 |
+
*/
|
194 |
+
public function testGetBaseGrandTotalFromSalesObject()
|
195 |
+
{
|
196 |
+
$helper = Mage::helper('ops/payment');
|
197 |
+
$order = Mage::getModel('sales/order')->load(14);
|
198 |
+
$amount = $helper->getBaseGrandTotalFromSalesObject($order);
|
199 |
+
$this->assertEquals($order->getBaseGrandTotal(), $amount);
|
200 |
+
$order = Mage::getModel('sales/order')->load(15);
|
201 |
+
$amount = $helper->getBaseGrandTotalFromSalesObject($order);
|
202 |
+
$this->assertEquals($order->getBaseGrandTotal(), $amount);
|
203 |
+
$quote = Mage::getModel('sales/quote')->load(1);
|
204 |
+
$amount = $helper->getBaseGrandTotalFromSalesObject($quote);
|
205 |
+
$this->assertEquals($quote->getBaseGrandTotal(), $amount);
|
206 |
+
$quote = Mage::getModel('sales/quote')->load(2);
|
207 |
+
$amount = $helper->getBaseGrandTotalFromSalesObject($quote);
|
208 |
+
$this->assertEquals($quote->getBaseGrandTotal(), $amount);
|
209 |
+
$someOtherObject = new Varien_Object();
|
210 |
+
$this->setExpectedException('Mage_Core_Exception');
|
211 |
+
$helper->getBaseGrandTotalFromSalesObject($someOtherObject);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
216 |
+
*/
|
217 |
+
public function testSaveOpsRefundOperationCodeToPayment()
|
218 |
+
{
|
219 |
+
$order = Mage::getModel('sales/order')->load(11);
|
220 |
+
$payment = $order->getPayment();
|
221 |
+
$helper = Mage::helper('ops/payment');
|
222 |
+
|
223 |
+
// no last refund operation code is set if an empty string is passed
|
224 |
+
$helper->saveOpsRefundOperationCodeToPayment($payment, '');
|
225 |
+
$this->assertFalse(
|
226 |
+
array_key_exists(
|
227 |
+
'lastRefundOperationCode', $payment->getAdditionalInformation()
|
228 |
+
)
|
229 |
+
);
|
230 |
+
|
231 |
+
// no last refund operation code is set if it's no refund operation code
|
232 |
+
$helper->saveOpsRefundOperationCodeToPayment(
|
233 |
+
$payment, Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_FULL
|
234 |
+
);
|
235 |
+
$this->assertFalse(
|
236 |
+
array_key_exists(
|
237 |
+
'lastRefundOperationCode', $payment->getAdditionalInformation()
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
+
// last ops refund code is present if a valid refund code is passed
|
242 |
+
$helper->saveOpsRefundOperationCodeToPayment(
|
243 |
+
$payment, Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL
|
244 |
+
);
|
245 |
+
$this->assertTrue(
|
246 |
+
array_key_exists(
|
247 |
+
'lastRefundOperationCode', $payment->getAdditionalInformation()
|
248 |
+
)
|
249 |
+
);
|
250 |
+
$this->assertEquals(
|
251 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_PARTIAL,
|
252 |
+
$payment->getAdditionalInformation('lastRefundOperationCode')
|
253 |
+
);
|
254 |
+
|
255 |
+
// last ops refund code is present if a valid refund code is passed and will override a previous one
|
256 |
+
$helper->saveOpsRefundOperationCodeToPayment(
|
257 |
+
$payment, Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL
|
258 |
+
);
|
259 |
+
$this->assertTrue(
|
260 |
+
array_key_exists(
|
261 |
+
'lastRefundOperationCode', $payment->getAdditionalInformation()
|
262 |
+
)
|
263 |
+
);
|
264 |
+
$this->assertEquals(
|
265 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_REFUND_FULL,
|
266 |
+
$payment->getAdditionalInformation('lastRefundOperationCode')
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
272 |
+
*/
|
273 |
+
public function testSetCanRefundToPayment()
|
274 |
+
{
|
275 |
+
|
276 |
+
$helper = Mage::helper('ops/payment');
|
277 |
+
$order = Mage::getModel('sales/order')->load(11);
|
278 |
+
$payment = $order->getPayment();
|
279 |
+
$helper->setCanRefundToPayment($payment);
|
280 |
+
$this->assertFalse(
|
281 |
+
array_key_exists('canRefund', $payment->getAdditionalInformation())
|
282 |
+
);
|
283 |
+
|
284 |
+
$order = Mage::getModel('sales/order')->load(15);
|
285 |
+
$payment = $order->getPayment();
|
286 |
+
$helper->setCanRefundToPayment($payment);
|
287 |
+
$this->assertTrue($payment->getAdditionalInformation('canRefund'));
|
288 |
+
|
289 |
+
$order = Mage::getModel('sales/order')->load(16);
|
290 |
+
$payment = $order->getPayment();
|
291 |
+
$helper->setCanRefundToPayment($payment);
|
292 |
+
$this->assertFalse($payment->getAdditionalInformation('canRefund'));
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
297 |
+
*
|
298 |
+
*/
|
299 |
+
public function testSetPaymentTransactionInformation()
|
300 |
+
{
|
301 |
+
$order = Mage::getModel('sales/order')->load(15);
|
302 |
+
$reflectionClass = new ReflectionClass(get_class(
|
303 |
+
Mage::helper('ops/payment')
|
304 |
+
));
|
305 |
+
$method = $reflectionClass->getMethod(
|
306 |
+
'setPaymentTransactionInformation'
|
307 |
+
);
|
308 |
+
$method->setAccessible(true);
|
309 |
+
$paymentHelper = Mage::helper('ops/payment');
|
310 |
+
$params = array(
|
311 |
+
'PAYID' => '0815',
|
312 |
+
'STATUS' => 9
|
313 |
+
);
|
314 |
+
$method->invoke(
|
315 |
+
$paymentHelper, $order->getPayment(), $params, 'accept'
|
316 |
+
);
|
317 |
+
$this->assertEquals(
|
318 |
+
'0815', $order->getPayment()->getAdditionalInformation('paymentId')
|
319 |
+
);
|
320 |
+
$this->assertEquals(
|
321 |
+
9, $order->getPayment()->getAdditionalInformation('status')
|
322 |
+
);
|
323 |
+
|
324 |
+
$params = array(
|
325 |
+
'PAYID' => '0815',
|
326 |
+
'STATUS' => 9,
|
327 |
+
'ACCEPTANCE' => ''
|
328 |
+
);
|
329 |
+
$method->invoke(
|
330 |
+
$paymentHelper, $order->getPayment(), $params, 'accept'
|
331 |
+
);
|
332 |
+
$this->assertEquals(
|
333 |
+
'0815', $order->getPayment()->getAdditionalInformation('paymentId')
|
334 |
+
);
|
335 |
+
$this->assertEquals(
|
336 |
+
'', $order->getPayment()->getAdditionalInformation('acceptance')
|
337 |
+
);
|
338 |
+
|
339 |
+
$params = array(
|
340 |
+
'PAYID' => '0815',
|
341 |
+
'STATUS' => 9,
|
342 |
+
'ACCEPTANCE' => 'Akzeptanz'
|
343 |
+
);
|
344 |
+
$method->invoke(
|
345 |
+
$paymentHelper, $order->getPayment(), $params, 'accept'
|
346 |
+
);
|
347 |
+
$this->assertEquals(
|
348 |
+
'0815', $order->getPayment()->getAdditionalInformation('paymentId')
|
349 |
+
);
|
350 |
+
$this->assertEquals(
|
351 |
+
'Akzeptanz',
|
352 |
+
$order->getPayment()->getAdditionalInformation('acceptance')
|
353 |
+
);
|
354 |
+
|
355 |
+
$params = array(
|
356 |
+
'PAYID' => '0815',
|
357 |
+
'STATUS' => 9,
|
358 |
+
'ACCEPTANCE' => 'Akzeptanz',
|
359 |
+
'HTML_ANSWER' => '3D Secure',
|
360 |
+
'BRAND' => 'Brand'
|
361 |
+
);
|
362 |
+
$method->invoke(
|
363 |
+
$paymentHelper, $order->getPayment(), $params, 'accept'
|
364 |
+
);
|
365 |
+
$this->assertEquals(
|
366 |
+
'0815', $order->getPayment()->getAdditionalInformation('paymentId')
|
367 |
+
);
|
368 |
+
$this->assertEquals(
|
369 |
+
'Akzeptanz',
|
370 |
+
$order->getPayment()->getAdditionalInformation('acceptance')
|
371 |
+
);
|
372 |
+
$this->assertEquals(
|
373 |
+
'3D Secure',
|
374 |
+
$order->getPayment()->getAdditionalInformation('HTML_ANSWER')
|
375 |
+
);
|
376 |
+
$this->assertEquals(
|
377 |
+
'Brand',
|
378 |
+
$order->getPayment()->getAdditionalInformation('CC_BRAND')
|
379 |
+
);
|
380 |
+
}
|
381 |
+
|
382 |
+
|
383 |
+
/**
|
384 |
+
* @param int $opsStatus Incoming postBack status
|
385 |
+
* @param bool $sendMail Indicates whether opsStatus should trigger order confirmation mail
|
386 |
+
* @param string $feedbackStatus Indicates the route that the customer should get redirected to
|
387 |
+
*
|
388 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
389 |
+
* @dataProvider applyStateForOrderProvider
|
390 |
+
*/
|
391 |
+
public function testApplyStateForOrder($opsStatus, $sendMail, $feedbackStatus)
|
392 |
+
{
|
393 |
+
$this->mockEmailHelper($this->exactly(intval($sendMail)));
|
394 |
+
$this->mockOrderConfig();
|
395 |
+
|
396 |
+
$helperMock = $this->getHelperMock('ops', array('isAdminSession'));
|
397 |
+
$helperMock->expects($this->any())
|
398 |
+
->method('isAdminSession')
|
399 |
+
->will($this->returnValue(false));
|
400 |
+
$this->replaceByMock('helper', 'ops', $helperMock);
|
401 |
+
|
402 |
+
/** @var Netresearch_OPS_Helper_Payment $paymenthelperMock */
|
403 |
+
$paymenthelperMock = $this->getHelperMock('ops/payment', [
|
404 |
+
'acceptOrder', 'waitOrder', 'declineOrder', 'cancelOrder', 'handleException',
|
405 |
+
]);
|
406 |
+
|
407 |
+
$order = Mage::getModel('sales/order')->load(19);
|
408 |
+
$this->assertEquals(
|
409 |
+
$feedbackStatus,
|
410 |
+
$paymenthelperMock->applyStateForOrder($order, ['STATUS' => $opsStatus])
|
411 |
+
);
|
412 |
+
}
|
413 |
+
|
414 |
+
public function applyStateForOrderProvider()
|
415 |
+
{
|
416 |
+
return [
|
417 |
+
// assertion for WAITING_FOR_IDENTIFICATION = 46
|
418 |
+
[
|
419 |
+
$opsStatus = Netresearch_OPS_Model_Status::WAITING_FOR_IDENTIFICATION,
|
420 |
+
$sendMail = false,
|
421 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
422 |
+
],
|
423 |
+
// assertion for AUTHORIZED = 5
|
424 |
+
[
|
425 |
+
$opsStatus = Netresearch_OPS_Model_Status::AUTHORIZED,
|
426 |
+
$sendMail = true,
|
427 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
428 |
+
],
|
429 |
+
// assertion for AUTHORIZED_WAITING_EXTERNAL_RESULT = 50
|
430 |
+
[
|
431 |
+
$opsStatus = Netresearch_OPS_Model_Status::AUTHORIZED_WAITING_EXTERNAL_RESULT,
|
432 |
+
$sendMail = true,
|
433 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
434 |
+
],
|
435 |
+
// assertion for AUTHORIZATION_WAITING = 51
|
436 |
+
[
|
437 |
+
$opsStatus = Netresearch_OPS_Model_Status::AUTHORIZATION_WAITING,
|
438 |
+
$sendMail = true,
|
439 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
440 |
+
],
|
441 |
+
// assertion for AUTHORIZED_UNKNOWN = 52
|
442 |
+
[
|
443 |
+
$opsStatus = Netresearch_OPS_Model_Status::AUTHORIZED_UNKNOWN,
|
444 |
+
$sendMail = true,
|
445 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
446 |
+
],
|
447 |
+
// assertion for WAITING_CLIENT_PAYMENT = 41
|
448 |
+
[
|
449 |
+
$opsStatus = Netresearch_OPS_Model_Status::WAITING_CLIENT_PAYMENT,
|
450 |
+
$sendMail = true,
|
451 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
452 |
+
],
|
453 |
+
// assertion for PAYMENT_REQUESTED = 9
|
454 |
+
[
|
455 |
+
$opsStatus = Netresearch_OPS_Model_Status::PAYMENT_REQUESTED,
|
456 |
+
$sendMail = true,
|
457 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
458 |
+
],
|
459 |
+
// assertion for PAYMENT_PROCESSING = 91
|
460 |
+
[
|
461 |
+
$opsStatus = Netresearch_OPS_Model_Status::PAYMENT_PROCESSING,
|
462 |
+
$sendMail = true,
|
463 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_ACCEPT,
|
464 |
+
],
|
465 |
+
// assertion for AUTHORISATION_DECLINED = 2
|
466 |
+
[
|
467 |
+
$opsStatus = Netresearch_OPS_Model_Status::AUTHORISATION_DECLINED,
|
468 |
+
$sendMail = true,
|
469 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE,
|
470 |
+
],
|
471 |
+
// assertion for PAYMENT_REFUSED = 93
|
472 |
+
[
|
473 |
+
$opsStatus = Netresearch_OPS_Model_Status::PAYMENT_REFUSED,
|
474 |
+
$sendMail = true,
|
475 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_DECLINE,
|
476 |
+
],
|
477 |
+
// assertion for CANCELED_BY_CUSTOMER = 1
|
478 |
+
[
|
479 |
+
$opsStatus = Netresearch_OPS_Model_Status::CANCELED_BY_CUSTOMER,
|
480 |
+
$sendMail = false,
|
481 |
+
$feedbackStatus = Netresearch_OPS_Model_Status_Feedback::OPS_ORDER_FEEDBACK_STATUS_CANCEL,
|
482 |
+
],
|
483 |
+
];
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
488 |
+
*/
|
489 |
+
public function testForceAuthorize()
|
490 |
+
{
|
491 |
+
$helper = Mage::helper('ops/payment');
|
492 |
+
$reflectionClass = new ReflectionClass(get_class($helper));
|
493 |
+
$method = $reflectionClass->getMethod("forceAuthorize");
|
494 |
+
$method->setAccessible(true);
|
495 |
+
|
496 |
+
$order = Mage::getModel('sales/order')->load(11);
|
497 |
+
$this->assertFalse($method->invoke($helper, $order));
|
498 |
+
|
499 |
+
$order = Mage::getModel('sales/order')->load(27);
|
500 |
+
$this->assertTrue($method->invoke($helper, $order));
|
501 |
+
|
502 |
+
$order = Mage::getModel('sales/order')->load(28);
|
503 |
+
$this->assertTrue($method->invoke($helper, $order));
|
504 |
+
|
505 |
+
// $order = Mage::getModel('sales/order')->load(29);
|
506 |
+
// $this->assertTrue($method->invoke($helper, $order));
|
507 |
+
}
|
508 |
+
|
509 |
+
public function testCheckIfCCisInCheckoutMethodsFalse()
|
510 |
+
{
|
511 |
+
$testMethod = $this->getProtectedMethod($this->_helper,'checkIfCCisInCheckoutMethods');
|
512 |
+
$paymentMethods = new Varien_Object();
|
513 |
+
$paymentMethods->setCode('ops_iDeal');
|
514 |
+
$this->assertFalse($testMethod->invoke($this->_helper, array($paymentMethods)));
|
515 |
+
|
516 |
+
|
517 |
+
}
|
518 |
+
|
519 |
+
public function testCheckIfCCisInCheckoutMethodsTrue()
|
520 |
+
{
|
521 |
+
$testMethod = $this->getProtectedMethod($this->_helper,'checkIfCCisInCheckoutMethods');
|
522 |
+
$paymentMethods = new Varien_Object();
|
523 |
+
$paymentMethods->setCode('ops_cc');
|
524 |
+
$this->assertTrue($testMethod->invoke($this->_helper, array($paymentMethods)));
|
525 |
+
|
526 |
+
|
527 |
+
}
|
528 |
+
|
529 |
+
public function testAddCCForZeroAmountCheckout()
|
530 |
+
{
|
531 |
+
$block = new Mage_Payment_Block_Form_Container();
|
532 |
+
$method = new Varien_Object();
|
533 |
+
$method->setCode('ops_ideal');
|
534 |
+
$block->setData('methods',array($method));
|
535 |
+
$quote = Mage::getModel('sales/quote');
|
536 |
+
$block->setQuote($quote);
|
537 |
+
|
538 |
+
$featureModelMock = $this->getModelMock('ops/payment_features_zeroAmountAuth', array('isCCAndZeroAmountAuthAllowed'));
|
539 |
+
$featureModelMock->expects($this->any())
|
540 |
+
->method('isCCAndZeroAmountAuthAllowed')
|
541 |
+
->will($this->returnValue(true));
|
542 |
+
$this->replaceByMock('model', 'ops/payment_features_zeroAmountAuth', $featureModelMock);
|
543 |
+
|
544 |
+
$this->_helper->addCCForZeroAmountCheckout($block);
|
545 |
+
|
546 |
+
$methods = $block->getMethods();
|
547 |
+
$this->assertTrue( $methods[1] instanceof Netresearch_OPS_Model_Payment_Cc);
|
548 |
+
$this->assertFalse( $methods[0] instanceof Netresearch_OPS_Model_Payment_Cc);
|
549 |
+
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
protected function getProtectedMethod($class, $method)
|
554 |
+
{
|
555 |
+
$reflection_class = new ReflectionClass(get_class($class));
|
556 |
+
$method = $reflection_class->getMethod($method);
|
557 |
+
$method->setAccessible(true);
|
558 |
+
return $method;
|
559 |
+
}
|
560 |
+
|
561 |
+
|
562 |
+
public function testIsInlinePaymentWithOrderIdIsTrueForInlineCcWithOrderId()
|
563 |
+
{
|
564 |
+
$configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
|
565 |
+
|
566 |
+
$configMock->expects($this->any())
|
567 |
+
->method('getInlineOrderReference')
|
568 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID));
|
569 |
+
$this->replaceByMock('singleton', 'ops/config', $configMock);
|
570 |
+
|
571 |
+
$ccMock = $this->getModelMock('ops/payment_cc', array('hasBrandAliasInterfaceSupport'));
|
572 |
+
$ccMock->expects($this->once())
|
573 |
+
->method('hasBrandAliasInterfaceSupport')
|
574 |
+
->will($this->returnValue(true));
|
575 |
+
|
576 |
+
|
577 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
578 |
+
$payment->expects($this->any())
|
579 |
+
->method('getMethodInstance')
|
580 |
+
->will($this->returnValue($ccMock));
|
581 |
+
|
582 |
+
$this->assertTrue(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
|
583 |
+
}
|
584 |
+
|
585 |
+
public function testIsInlinePaymentWithOrderIdIsFalseForRedirectCcWithOrderId()
|
586 |
+
{
|
587 |
+
$ccMock = $this->getModelMock('ops/payment_cc', array('getConfigPaymentAction', 'hasBrandAliasInterfaceSupport'));
|
588 |
+
$ccMock->expects($this->any())
|
589 |
+
->method('getConfigPaymentAction')
|
590 |
+
->will($this->returnValue('authorize'));
|
591 |
+
$ccMock->expects($this->once())
|
592 |
+
->method('hasBrandAliasInterfaceSupport')
|
593 |
+
->will($this->returnValue(false));
|
594 |
+
|
595 |
+
|
596 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
597 |
+
$payment->expects($this->any())
|
598 |
+
->method('getMethodInstance')
|
599 |
+
->will($this->returnValue($ccMock));
|
600 |
+
|
601 |
+
$this->assertFalse(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
|
602 |
+
}
|
603 |
+
|
604 |
+
public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfigured()
|
605 |
+
{
|
606 |
+
$configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
|
607 |
+
|
608 |
+
$configMock->expects($this->any())
|
609 |
+
->method('getInlineOrderReference')
|
610 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID));
|
611 |
+
$this->replaceByMock('singleton', 'ops/config', $configMock);
|
612 |
+
|
613 |
+
$ccMock = $this->getModelMock('ops/payment_cc', array('hasBrandAliasInterfaceSupport', 'getConfig'));
|
614 |
+
$ccMock->expects($this->once())
|
615 |
+
->method('hasBrandAliasInterfaceSupport')
|
616 |
+
->will($this->returnValue(true));
|
617 |
+
|
618 |
+
|
619 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
620 |
+
$payment->expects($this->any())
|
621 |
+
->method('getMethodInstance')
|
622 |
+
->will($this->returnValue($ccMock));
|
623 |
+
|
624 |
+
$this->assertFalse(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
|
625 |
+
}
|
626 |
+
|
627 |
+
public function testIsInlinePaymentWithOrderIdIsFalseIfQuoteIdIsConfiguredForDirectDebit()
|
628 |
+
{
|
629 |
+
$configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
|
630 |
+
|
631 |
+
$configMock->expects($this->any())
|
632 |
+
->method('getInlineOrderReference')
|
633 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_QUOTE_ID));
|
634 |
+
$this->replaceByMock('singleton', 'ops/config', $configMock);
|
635 |
+
|
636 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
637 |
+
$payment->expects($this->any())
|
638 |
+
->method('getMethodInstance')
|
639 |
+
->will($this->returnValue(Mage::getModel('ops/payment_directDebit')));
|
640 |
+
|
641 |
+
$this->assertFalse(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
|
642 |
+
}
|
643 |
+
public function testIsInlinePaymentWithOrderIdIsTrueIfOrderIdIsConfiguredForDirectDebit()
|
644 |
+
{
|
645 |
+
$configMock = $this->getModelMock('ops/config', array('getInlineOrderReference'));
|
646 |
+
|
647 |
+
$configMock->expects($this->any())
|
648 |
+
->method('getInlineOrderReference')
|
649 |
+
->will($this->returnValue(Netresearch_OPS_Model_Payment_Abstract::REFERENCE_ORDER_ID));
|
650 |
+
$this->replaceByMock('singleton', 'ops/config', $configMock);
|
651 |
+
|
652 |
+
|
653 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
654 |
+
$payment->expects($this->any())
|
655 |
+
->method('getMethodInstance')
|
656 |
+
->will($this->returnValue(Mage::getModel('ops/payment_directDebit')));
|
657 |
+
|
658 |
+
$this->assertTrue(Mage::helper('ops/payment')->isInlinePaymentWithOrderId($payment));
|
659 |
+
}
|
660 |
+
|
661 |
+
public function testIsInlinePaymentWithQuoteId()
|
662 |
+
{
|
663 |
+
$directDebitMock = $this->getModelMock('ops/payment_directDebit', array('getConfigPaymentAction'));
|
664 |
+
$directDebitMock->expects($this->once())
|
665 |
+
->method('getConfigPaymentAction')
|
666 |
+
->will($this->returnValue(''));
|
667 |
+
|
668 |
+
$payment = $this->getModelMock('payment/info', array('getMethodInstance'));
|
669 |
+
$payment->expects($this->any())
|
670 |
+
->method('getMethodInstance')
|
671 |
+
->will($this->returnValue($directDebitMock));
|
672 |
+
|
673 |
+
$this->assertTrue(Mage::helper('ops/payment')->isInlinePaymentWithQuoteId($payment));
|
674 |
+
}
|
675 |
+
|
676 |
+
public function testSetInvoicesToPaid()
|
677 |
+
{
|
678 |
+
$order = $this->getModelMock('sales/order', array('save', 'getInvoiceCollection'));
|
679 |
+
$order->expects($this->any())
|
680 |
+
->method('getInvoiceCollection')
|
681 |
+
->will($this->returnValue(array($this->getModelMock('sales/order_invoice', array('save')))));
|
682 |
+
Mage::helper('ops/payment')->setInvoicesToPaid($order);
|
683 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
684 |
+
$this->assertEquals(Mage_Sales_Model_Order_Invoice::STATE_PAID, $invoice->getState());
|
685 |
+
}
|
686 |
+
}
|
687 |
+
|
688 |
+
|
689 |
+
/**
|
690 |
+
* @expectedException Mage_Core_Exception
|
691 |
+
*/
|
692 |
+
public function testCancelOrderWithException()
|
693 |
+
{
|
694 |
+
$params = array('status' => 2, 'payid' => 4711);
|
695 |
+
$status = Mage_Sales_Model_Order::STATE_CANCELED;
|
696 |
+
$comment = 'TestComment';
|
697 |
+
|
698 |
+
$order = $this->getModelMock('sales/order', array('save', 'cancel', 'setState'));
|
699 |
+
$order->expects($this->any())
|
700 |
+
->method('cancel')
|
701 |
+
->will($this->throwException(new Mage_Core_Exception('cancel failed')));
|
702 |
+
;
|
703 |
+
|
704 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('_getCheckout'));
|
705 |
+
|
706 |
+
$paymentHelperMock->expects($this->any())
|
707 |
+
->method('_getCheckout')
|
708 |
+
->will($this->returnValue($this->getModelMock('checkout/session', array('init', 'save'))))
|
709 |
+
;
|
710 |
+
|
711 |
+
$paymentHelperMock->cancelOrder($order, $params, $status, $comment);
|
712 |
+
Mage::unregister('ops_auto_void');
|
713 |
+
}
|
714 |
+
|
715 |
+
public function testDeclineOrder()
|
716 |
+
{
|
717 |
+
Mage::unregister('ops_auto_void');
|
718 |
+
$params = array('STATUS' => 2, 'PAYID' => 4711);
|
719 |
+
$status = Mage_Sales_Model_Order::STATE_CANCELED;
|
720 |
+
$comment = 'TestComment';
|
721 |
+
|
722 |
+
$order = $this->getModelMock('sales/order', array('save', 'cancel', 'setState', 'getPayment'));
|
723 |
+
$order->expects($this->once())
|
724 |
+
->method('cancel')
|
725 |
+
;
|
726 |
+
$order->expects($this->once())
|
727 |
+
->method('getPayment')
|
728 |
+
->will($this->returnValue($this->getModelMock('sales/order_payment', array('save'))));
|
729 |
+
;
|
730 |
+
|
731 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('setPaymentTransactionInformation', '_getCheckout', 'cancelInvoices'));
|
732 |
+
$paymentHelperMock->expects($this->once())
|
733 |
+
->method('setPaymentTransactionInformation');
|
734 |
+
$paymentHelperMock->expects($this->once())
|
735 |
+
->method('cancelInvoices');
|
736 |
+
|
737 |
+
$paymentHelperMock->expects($this->any())
|
738 |
+
->method('_getCheckout')
|
739 |
+
->will($this->returnValue($this->getModelMock('checkout/session', array('init', 'save'))))
|
740 |
+
;
|
741 |
+
|
742 |
+
$paymentHelperMock->declineOrder($order, $params);
|
743 |
+
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* @expectedException Mage_Core_Exception
|
748 |
+
*/
|
749 |
+
public function testDeclineOrderWithException()
|
750 |
+
{
|
751 |
+
Mage::unregister('ops_auto_void');
|
752 |
+
$params = array('STATUS' => 2, 'PAYID' => 4711);
|
753 |
+
$status = Mage_Sales_Model_Order::STATE_CANCELED;
|
754 |
+
$comment = 'TestComment';
|
755 |
+
|
756 |
+
$order = $this->getModelMock('sales/order', array('save', 'cancel', 'setState'));
|
757 |
+
$order->expects($this->once())
|
758 |
+
->method('cancel')
|
759 |
+
->will($this->throwException(new Mage_Core_Exception('exceptional case')));
|
760 |
+
|
761 |
+
|
762 |
+
$paymentHelperMock = $this->getHelperMock('ops/payment', array('setPaymentTransactionInformation', '_getCheckout', 'cancelInvoices'));
|
763 |
+
$paymentHelperMock->expects($this->never())
|
764 |
+
->method('setPaymentTransactionInformation');
|
765 |
+
$paymentHelperMock->expects($this->once())
|
766 |
+
->method('cancelInvoices');
|
767 |
+
|
768 |
+
|
769 |
+
$paymentHelperMock->expects($this->any())
|
770 |
+
->method('_getCheckout')
|
771 |
+
->will($this->returnValue($this->getModelMock('checkout/session', array('init', 'save'))))
|
772 |
+
;
|
773 |
+
|
774 |
+
$paymentHelperMock->declineOrder($order, $params);
|
775 |
+
|
776 |
+
}
|
777 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/PaymentTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Helper/QuoteTest.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @package Netresearch_OPS
|
6 |
+
* @copyright Copyright (c) 2013 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Netresearch_OPS_Test_Helper_QuoteTest extends EcomDev_PHPUnit_Test_Case
|
11 |
+
{
|
12 |
+
|
13 |
+
public function testGetDataHelper()
|
14 |
+
{
|
15 |
+
$this->assertTrue(Mage::helper('ops/quote')->getDataHelper() instanceof Netresearch_OPS_Helper_Data);
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @loadFixture ../../../var/fixtures/orders.yaml
|
20 |
+
*/
|
21 |
+
public function testCleanUpOldPaymentInformation()
|
22 |
+
{
|
23 |
+
$payment = Mage::getModel('sales/quote_payment')->load(3);
|
24 |
+
$this->assertArrayHasKey('cvc', $payment->getAdditionalInformation());
|
25 |
+
Mage::helper('ops/quote')->cleanUpOldPaymentInformation();
|
26 |
+
$payment = Mage::getModel('sales/quote_payment')->load(3);
|
27 |
+
$this->assertArrayNotHasKey(
|
28 |
+
'cvc', $payment->getAdditionalInformation()
|
29 |
+
);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function testGetQuoteCurrency()
|
33 |
+
{
|
34 |
+
$quote = Mage::getModel('sales/quote');
|
35 |
+
$this->assertEquals(
|
36 |
+
Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode(),
|
37 |
+
Mage::helper('ops/quote')->getQuoteCurrency($quote)
|
38 |
+
);
|
39 |
+
$forcedCurrency = new Varien_Object();
|
40 |
+
$forcedCurrency->setCode('USD');
|
41 |
+
$quote->setForcedCurrency($forcedCurrency);
|
42 |
+
$this->assertEquals(
|
43 |
+
'USD', Mage::helper('ops/quote')->getQuoteCurrency($quote)
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function testGetPaymentActionForAuthorize()
|
48 |
+
{
|
49 |
+
$order = Mage::getModel('sales/order');
|
50 |
+
$payment = Mage::getModel('sales/order_payment');
|
51 |
+
$order->setPayment($payment);
|
52 |
+
$modelMock = $this->getModelMock(
|
53 |
+
'ops/config', array('getPaymentAction')
|
54 |
+
);
|
55 |
+
$modelMock->expects($this->any())
|
56 |
+
->method('getPaymentAction')
|
57 |
+
->will(
|
58 |
+
$this->returnValue(
|
59 |
+
'Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION'
|
60 |
+
)
|
61 |
+
);
|
62 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
63 |
+
$helper = Mage::helper('ops/quote');
|
64 |
+
$this->assertEquals(
|
65 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION,
|
66 |
+
$helper->getPaymentAction($order)
|
67 |
+
);
|
68 |
+
$order->getPayment()->setAdditionalInformation(
|
69 |
+
'PM', 'Direct Debits DE'
|
70 |
+
);
|
71 |
+
$this->assertEquals(
|
72 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION,
|
73 |
+
$helper->getPaymentAction($order)
|
74 |
+
);
|
75 |
+
$order->getPayment()->setAdditionalInformation(
|
76 |
+
'PM', 'Direct Debits AT'
|
77 |
+
);
|
78 |
+
$this->assertEquals(
|
79 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION,
|
80 |
+
$helper->getPaymentAction($order)
|
81 |
+
);
|
82 |
+
$order->getPayment()->setAdditionalInformation(
|
83 |
+
'PM', 'Direct Debits NL'
|
84 |
+
);
|
85 |
+
$this->assertEquals(
|
86 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_ACTION,
|
87 |
+
$helper->getPaymentAction($order)
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
public function testGetPaymentActionForAuthorizeCapture()
|
92 |
+
{
|
93 |
+
$order = Mage::getModel('sales/order');
|
94 |
+
$payment = Mage::getModel('sales/order_payment');
|
95 |
+
$order->setPayment($payment);
|
96 |
+
$modelMock = $this->getModelMock(
|
97 |
+
'ops/config', array('getPaymentAction')
|
98 |
+
);
|
99 |
+
$modelMock->expects($this->any())
|
100 |
+
->method('getPaymentAction')
|
101 |
+
->will($this->returnValue('authorize_capture'));
|
102 |
+
$this->replaceByMock('model', 'ops/config', $modelMock);
|
103 |
+
$helper = Mage::helper('ops/quote');
|
104 |
+
$this->assertEquals(
|
105 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION,
|
106 |
+
$helper->getPaymentAction($order)
|
107 |
+
);
|
108 |
+
$order->getPayment()->setAdditionalInformation(
|
109 |
+
'PM', 'Direct Debits DE'
|
110 |
+
);
|
111 |
+
$this->assertEquals(
|
112 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION,
|
113 |
+
$helper->getPaymentAction($order)
|
114 |
+
);
|
115 |
+
$order->getPayment()->setAdditionalInformation(
|
116 |
+
'PM', 'Direct Debits AT'
|
117 |
+
);
|
118 |
+
$this->assertEquals(
|
119 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZE_CAPTURE_ACTION,
|
120 |
+
$helper->getPaymentAction($order)
|
121 |
+
);
|
122 |
+
$order->getPayment()->setAdditionalInformation(
|
123 |
+
'PM', 'Direct Debits NL'
|
124 |
+
);
|
125 |
+
$this->assertEquals(
|
126 |
+
Netresearch_OPS_Model_Payment_Abstract::OPS_CAPTURE_DIRECTDEBIT_NL,
|
127 |
+
$helper->getPaymentAction($order)
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
public function testGetQuoteWithAdminSession()
|
133 |
+
{
|
134 |
+
$fakeQuote = $this->getModelMock('sales/quote');
|
135 |
+
$this->replaceByMock('model', 'sales/quote', $fakeQuote);
|
136 |
+
|
137 |
+
$sessionMock = $this->getModelMockBuilder('adminhtml/session_quote')
|
138 |
+
->disableOriginalConstructor() // This one removes session_start and other methods usage
|
139 |
+
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
|
140 |
+
->getMock();
|
141 |
+
$sessionMock->setData('quote', $fakeQuote);
|
142 |
+
$this->replaceByMock('singleton', 'adminhtml/session_quote', $sessionMock);
|
143 |
+
$helper = Mage::helper('ops/quote');
|
144 |
+
$this->assertEquals($fakeQuote, $helper->getQuote());
|
145 |
+
}
|
146 |
+
|
147 |
+
public function testGetQuoteWithCheckoutSession()
|
148 |
+
{
|
149 |
+
Mage::app()->setCurrentStore(1);
|
150 |
+
|
151 |
+
$fakeQuote = $this->getModelMock('sales/quote', array('setStoreId'));
|
152 |
+
$fakeQuote->expects($this->any())
|
153 |
+
->method('setStoreId')
|
154 |
+
->will($this->returnValue($fakeQuote));
|
155 |
+
$this->replaceByMock('model', 'sales/quote', $fakeQuote);
|
156 |
+
|
157 |
+
|
158 |
+
$sessionMock = $this->getModelMockBuilder('customer/session')
|
159 |
+
->disableOriginalConstructor()
|
160 |
+
->setMethods(null)
|
161 |
+
->getMock();
|
162 |
+
$this->replaceByMock('singleton', 'customer/session', $sessionMock);
|
163 |
+
|
164 |
+
$sessionMock = $this->getModelMockBuilder('checkout/session')
|
165 |
+
->disableOriginalConstructor()
|
166 |
+
->setMethods(null)
|
167 |
+
->getMock();
|
168 |
+
$sessionMock->setData('quote', $fakeQuote);
|
169 |
+
$this->replaceByMock('singleton', 'checkout/session', $sessionMock);
|
170 |
+
/** @var Netresearch_OPS_Helper_Quote $helper */
|
171 |
+
$helper = Mage::helper('ops/quote');
|
172 |
+
$this->assertEquals($fakeQuote, $helper->getQuote());
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/QuoteTest/fixtures/.gitkeep
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
|
app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Netresearch_OPS
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* DISCLAIMER
|
13 |
+
*
|
14 |
+
* Do not edit or add to this file if you wish to upgrade this extension to
|
15 |
+
* newer versions in the future.
|
16 |
+
*
|
17 |
+
* @copyright Copyright (c) 2015 Netresearch GmbH & Co. KG (http://www.netresearch.de/)
|
18 |
+
* @license Open Software License (OSL 3.0)
|
19 |
+
* @link http://opensource.org/licenses/osl-3.0.php
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* SubscriptionTest.php
|
24 |
+
*
|
25 |
+
* @category Payment provider
|
26 |
+
* @package Netresearch_OPS
|
27 |
+
* @author Paul Siedler <paul.siedler@netresearch.de>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<?php
|
31 |
+
|
32 |
+
|
33 |
+
class Netresearch_OPS_Test_Helper_SubscriptionTest extends EcomDev_PHPUnit_Test_Case
|
34 |
+
{
|
35 |
+
|
36 |
+
|
37 |
+
public function testGenerateSubscriptionId()
|
38 |
+
{
|
39 |
+
$subject = Mage::helper('ops/subscription');
|
40 |
+
$profile = Mage::getModel('sales/recurring_profile');
|
41 |
+
$profile->setId(123)
|
42 |
+
->setTrialPeriodUnit(true);
|
43 |
+
$id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123';
|
44 |
+
$this->assertEquals($id, $subject->generateSubscriptionId($profile));
|
45 |
+
$id .= Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
|
46 |
+
$this->assertEquals($id, $subject->generateSubscriptionId($profile, true));
|
47 |
+
}
|
48 |
+
|
49 |
+
public function testIsSubscriptionFeedback()
|
50 |
+
{
|
51 |
+
$subject = Mage::helper('ops/subscription');
|
52 |
+
$id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123'
|
53 |
+
. Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
|
54 |
+
$params = array(
|
55 |
+
'orderID' => $id
|
56 |
+
);
|
57 |
+
$this->assertTrue($subject->isSubscriptionFeedback($params));
|
58 |
+
$params['orderID'] = '#10123123120';
|
59 |
+
$this->assertFalse($subject->isSubscriptionFeedback($params));
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @loadFixture profile.yaml
|
65 |
+
*/
|
66 |
+
public function testGetProfileForSubscription()
|
67 |
+
{
|
68 |
+
$subject = Mage::helper('ops/subscription');
|
69 |
+
|
70 |
+
$id = $subject::SUBSCRIPTION_PREFIX . 1;
|
71 |
+
|
72 |
+
$profile = $subject->getProfileForSubscription($id);
|
73 |
+
$this->assertEquals(1, $profile->getId());
|
74 |
+
|
75 |
+
$id = $subject::SUBSCRIPTION_PREFIX . 1 . $subject::TRIAL_SUFFIX;
|
76 |
+
|
77 |
+
$profile = $subject->getProfileForSubscription($id);
|
78 |
+
$this->assertEquals(1, $profile->getId());
|
79 |
+
}
|
80 |
+
/**
|
81 |
+
* @loadFixture profile.yaml
|
82 |
+
* @expectedException Mage_Core_Exception
|
83 |
+
* @expectedExceptionMessage Could find no subscription for id 2
|
84 |
+
*/
|
85 |
+
public function testGetProfileForSubscriptionWithException()
|
86 |
+
{
|
87 |
+
$subject = Mage::helper('ops/subscription');
|
88 |
+
|
89 |
+
$id = $subject::SUBSCRIPTION_PREFIX . 2;
|
90 |
+
|
91 |
+
$profile = $subject->getProfileForSubscription($id);
|
92 |
+
$this->assertEquals(1, $profile->getId());
|
93 |
+
}
|
94 |
+
|
95 |
+
public function testIsTrialFeedback()
|
96 |
+
{
|
97 |
+
$subject = Mage::helper('ops/subscription');
|
98 |
+
$id = Netresearch_OPS_Helper_Subscription::SUBSCRIPTION_PREFIX . '123';
|
99 |
+
$this->assertFalse($subject->isTrialFeedback($id));
|
100 |
+
$id .= Netresearch_OPS_Helper_Subscription::TRIAL_SUFFIX;
|
101 |
+
$this->assertTrue($subject->isTrialFeedback($id));
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
public function testGetBillingDayForPeriodUnit(){
|
106 |
+
$subject = Mage::helper('ops/subscription');
|
107 |
+
|
108 |
+
$this->assertEquals(1, $subject->getBillingDayForPeriodUnit('abc'));
|
109 |
+
$this->assertEquals(1, $subject->getBillingDayForPeriodUnit(Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_WEEK));
|
110 |
+
$this->assertEquals(15, $subject->getBillingDayForPeriodUnit(Netresearch_OPS_Model_Payment_Recurring_Cc_ParameterBag::PERIOD_UNIT_MONTH));
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
}
|
115 |
+
|
app/code/community/Netresearch/OPS/Test/Helper/SubscriptionTest/fixtures/profile.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
customer/entity:
|
3 |
+
- entity_id: 1
|
4 |
+
|
5 |
+
sales/recurring_profile:
|
6 |
+
- profile_id: 1
|
7 |
+
state: 'active'
|
8 |
+
customer_id: 1
|
9 |
+
store_id: 1
|
10 |
+
method_code: 'ops_recurring_cc'
|
11 |
+
reference_id: 'SUB-1'
|
app/code/community/Netresearch/OPS/Test/Helper/Validation/Checkout/StepTest.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
4 |
+
* @category Netresearch
|
5 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
class Netresearch_OPS_Test_Helper_Validation_Checkout_StepTest extends EcomDev_PHPUnit_Test_Case
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $stepHelper = null;
|
16 |
+
|
17 |
+
public function setUp()
|
18 |
+
{
|
19 |
+
parent::setUp();
|
20 |
+
$this->stepHelper = Mage::helper('ops/validation_checkout_step');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testHelperReturnsNoStep()
|
24 |
+
{
|
25 |
+
$this->assertEquals('', $this->stepHelper->getStep(array()));
|
26 |
+
$this->assertEquals('', $this->stepHelper->getStep(array('SOME_OTHER_FIELD')));
|
27 |
+
}
|
28 |
+
|
29 |
+
public function testHelperReturnsBillingStep()
|
30 |
+
{
|
31 |
+
$expectedStep = Netresearch_OPS_Helper_Validation_Checkout_Step::BILLING_STEP;
|
32 |
+
$this->assertEquals($expectedStep, $this->stepHelper->getStep(array('OWNERADDRESS')));
|
33 |
+
$this->assertEquals($expectedStep, $this->stepHelper->getStep(array('OWNERADDRESS', 'SOME_OTHER_FIELD')));
|
34 |
+
$this->assertEquals($expectedStep, $this->stepHelper->getStep(array('ECOM_SHIPTO_POSTAL_STATE', 'SOME_OTHER_FIELD', 'CN')));
|
35 |
+
}
|
36 |
+
|
37 |
+
public function testHelperReturnsShippingStep()
|
38 |
+
{
|
39 |
+
$expectedStep = Netresearch_OPS_Helper_Validation_Checkout_Step::SHIPPING_STEP;
|
40 |
+
$this->assertEquals($expectedStep, $this->stepHelper->getStep(array('ECOM_SHIPTO_POSTAL_STATE')));
|
41 |
+
$this->assertEquals($expectedStep, $this->stepHelper->getStep(array('ECOM_SHIPTO_POSTAL_STATE', 'SOME_OTHER_FIELD')));
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/Validation/ResultTest.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Michael Lühr <michael.luehr@netresearch.de>
|
5 |
+
* @category Netresearch
|
6 |
+
* @copyright Copyright (c) 2014 Netresearch GmbH & Co. KG (http://www.netresearch.de)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
class Netresearch_OPS_Test_Helper_Validation_ResultTest extends EcomDev_PHPUnit_Test_Case
|
10 |
+
{
|
11 |
+
|
12 |
+
protected $validationResultHelper = null;
|
13 |
+
|
14 |
+
public function setUp()
|
15 |
+
{
|
16 |
+
parent::setUp();
|
17 |
+
Mage::unregister('_helper/ops/validation_result');
|
18 |
+
$this->validationResultHelper = Mage::helper('ops/validation_result');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function testBaseErroneousFields()
|
22 |
+
{
|
23 |
+
$quote = Mage::getModel('sales/quote');
|
24 |
+
$messages = array('foo', 'bar');
|
25 |
+
$result = $this->validationResultHelper->getValidationFailedResult($messages, $quote);
|
26 |
+
$this->assertArrayHasKey('error', $result);
|
27 |
+
$this->assertArrayHasKey('goto_section', $result);
|
28 |
+
$this->assertArrayHasKey('opsError', $result);
|
29 |
+
$this->assertArrayHasKey('fields', $result);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function testGetValidationFailedResultWithFieldMapping()
|
33 |
+
{
|
34 |
+
$quote = Mage::getModel('sales/quote');
|
35 |
+
$configMock = $this->getModelMock('ops/config', array('getFrontendFieldMapping'));
|
36 |
+
$configMock->expects($this->once())
|
37 |
+
->method('getFrontendFieldMapping')
|
38 |
+
->will($this->returnValue(array('foo' => 'bar')));
|
39 |
+
$this->validationResultHelper->setConfig($configMock);
|
40 |
+
$this->validationResultHelper->setFormBlock(Mage::app()->getLayout()->createBlock('ops/form'));
|
41 |
+
$messages = array('foo' => 'bar');
|
42 |
+
$result = $this->validationResultHelper->getValidationFailedResult($messages, $quote);
|
43 |
+
$this->assertArrayHasKey('fields', $result);
|
44 |
+
$this->assertArrayHasKey('bar', $result['fields']);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @loadFixture quotes
|
49 |
+
*/
|
50 |
+
public function testGetValidationFailedResultWithExistingAddress()
|
51 |
+
{
|
52 |
+
$quote = Mage::getModel('sales/quote')->load(1);
|
53 |
+
$checkoutStepHelperMock = $this->getHelperMock('ops/validation_checkout_step', array('getStep'));
|
54 |
+
$checkoutStepHelperMock->expects($this->exactly(2))
|
55 |
+
->method('getStep')
|
56 |
+
->will($this->onConsecutiveCalls('billing', 'shipping'));
|
57 |
+
|
58 |
+
$configMock = $this->getModelMock('ops/config', array('getFrontendFieldMapping'));
|
59 |
+
$configMock->expects($this->exactly(2))
|
60 |
+
->method('getFrontendFieldMapping')
|
61 |
+
->will($this->returnValue(array('foo' => 'bar')));
|
62 |
+
$this->validationResultHelper->setConfig($configMock);
|
63 |
+
|
64 |
+
$messages = array('foo' => 'bar');
|
65 |
+
$this->validationResultHelper->setCheckoutStepHelper($checkoutStepHelperMock);
|
66 |
+
$this->validationResultHelper->setFormBlock(Mage::app()->getLayout()->createBlock('ops/form'));
|
67 |
+
$result = $this->validationResultHelper->getValidationFailedResult($messages, $quote);
|
68 |
+
$this->assertArrayHasKey('fields', $result);
|
69 |
+
$this->assertArrayHasKey('billing-address-select', $result['fields']);
|
70 |
+
|
71 |
+
$result = $this->validationResultHelper->getValidationFailedResult($messages, $quote);
|
72 |
+
$this->assertArrayHasKey('fields', $result);
|
73 |
+
$this->assertArrayHasKey('shipping-address-select', $result['fields']);
|
74 |
+
}
|
75 |
+
|
76 |
+
public function testCleanResult()
|
77 |
+
{
|
78 |
+
$quote = Mage::getModel('sales/quote');
|
79 |
+
$messages = array('foo' => 'bar');
|
80 |
+
$prevResult = array('update_section' => 'foo');
|
81 |
+
|
82 |
+
$configMock = $this->getModelMock('ops/config', array('getFrontendFieldMapping'));
|
83 |
+
$configMock->expects($this->once())
|
84 |
+
->method('getFrontendFieldMapping')
|
85 |
+
->will($this->returnValue(array('foo' => 'bar')));
|
86 |
+
$this->validationResultHelper->setConfig($configMock);
|
87 |
+
$this->validationResultHelper->setFormBlock(Mage::app()->getLayout()->createBlock('ops/form'));
|
88 |
+
|
89 |
+
$this->validationResultHelper->setResult($prevResult);
|
90 |
+
$result = $this->validationResultHelper->getValidationFailedResult($messages, $quote);
|
91 |
+
$this->assertArrayNotHasKey('update_section', $result);
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
app/code/community/Netresearch/OPS/Test/Helper/Validation/ResultTest/fixtures/quotes.yaml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tables:
|
2 |
+
sales/quote:
|
3 |
+
- entity_id: 1
|
4 |
+
increment_id: 100000001
|
5 |
+
base_grand_total: 119.00
|
6 |
+
grand_total: 119.00
|
7 |
+
currency: 'EUR'
|
8 |
+
customer_gender: 1
|
9 |
+
shipping_method: 'flatrate_flatrate'
|
10 |
+
|
11 |
+
sales/quote_address:
|
12 |
+
- entity_id: 42
|
13 |
+
quote_id: 1
|
14 |
+
address_type: 'billing'
|
15 |
+
firstname: 'Hubertus'
|
16 |
+
postcode: '04229'
|
17 |
+
lastname: 'Fürstenberg'
|
18 |
+
street: 'An der Tabaksmühle 3a'
|
19 |
+
city: 'Leipzig'
|
20 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
21 |
+
country_id: 'DE'
|
22 |
+
prefix: 'Prof. Dr.'
|
23 |
+
middlename: 'von'
|
24 |
+
suffix: 'MdL'
|
25 |
+
company: ''
|
26 |
+
fax: '12345678'
|
27 |
+
|
28 |
+
- entity_id: 43
|
29 |
+
quote_id: 1
|
30 |
+
address_type: 'shipping'
|
31 |
+
firstname: 'Hubertus'
|
32 |
+
postcode: '04229'
|
33 |
+
lastname: 'Fürstenberg'
|
34 |
+
street: 'An der Tabaksmühle 3a'
|
35 |
+
city: 'Leipzig'
|
36 |
+
email: 'hubertus.von.fuerstenberg@trash-mail.com'
|
37 |
+
country_id: 'DE'
|
38 |
+
prefix: 'Prof. Dr.'
|
39 |
+
middlename: 'von'
|
40 |
+
suffix: 'MdL'
|
41 |
+
company: ''
|
42 |
+
fax: '12345678'
|
app/code/community/Netresearch/OPS/Test/Helper/VersionTest.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Netresearch_OPS_Test_Helper_VersionTest extends EcomDev_PHPUnit_Test_Case
|
4 |
+
{
|
5 |
+
protected $helper;
|
6 |
+
|
7 |
+
|
8 |
+
public function setUp()
|
9 |
+
{
|
10 |
+
parent::setup();
|
11 |
+
$this->helper = Mage::helper('ops/version');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function testGetVersionForEditionEE()
|
15 |
+
{
|
16 |
+
$helperMethod = $this->getProtectedMethod($this->helper, 'getVersionForEdition');
|
17 |
+
$this->assertEquals(
|
18 |
+
Netresearch_OPS_Helper_Version::CAN_USE_APPLICABLE_FOR_QUOTE_EE_MINOR,
|
19 |
+
$helperMethod->invoke($this->helper, 'Enterprise')
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testGetVersionForEditionCE()
|
24 |
+
{
|
25 |
+
$helperMethod = $this->getProtectedMethod($this->helper, 'getVersionForEdition');
|
26 |
+
$this->assertEquals(
|
27 |
+
Netresearch_OPS_Helper_Version::CAN_USE_APPLICABLE_FOR_QUOTE_CE_MINOR,
|
28 |
+
$helperMethod->invoke($this->helper, 'Community')
|
29 |
+
);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function testGetVersionForEditionDefaultCE()
|
33 |
+
{
|
34 |
+
$helperMethod = $this->getProtectedMethod($this->helper, 'getVersionForEdition');
|
35 |
+
$this->assertEquals(
|
36 |
+
Netresearch_OPS_Helper_Version::CAN_USE_APPLICABLE_FOR_QUOTE_CE_MINOR,
|
37 |
+
$helperMethod->invoke($this->helper, null)
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function testCanUseApplicableForQuoteForEE()
|
42 |
+
{
|
43 |
+
$helperMock = $this->getHelperMock('ops/version', array('getVersionInfo'));
|
44 |
+
$helperMock->expects($this->any())
|
45 |
+
->method('getVersionInfo')
|
46 |
+
->will($this->returnValue(array('minor' => '14')));
|
47 |
+
|
48 |
+
$this->assertTrue($helperMock->canUseApplicableForQuote('Enterprise'));
|
49 |
+
|
50 |
+
$helperMock = $this->getHelperMock('ops/version', array('getVersionInfo'));
|
51 |
+
$helperMock->expects($this->any())
|
52 |
+
->method('getVersionInfo')
|
53 |
+
->will($this->returnValue(array('minor' => '13')));
|
54 |
+
|
55 |
+
$this->assertFalse($helperMock->canUseApplicableForQuote('Enterprise'));
|
56 |
+
}
|
57 |
+
|
58 |
+
public function testCanUseApplicableForQuoteForCE()
|
59 |
+
{
|
60 |
+
$helperMock = $this->getHelperMock('ops/version', array('getVersionInfo'));
|
61 |
+
$helperMock->expects($this->any())
|
62 |
+
->method('getVersionInfo')
|
63 |
+
->will($this->returnValue(array('minor' => '8')));
|
64 |
+
|
65 |
+
$this->assertTrue($helperMock->canUseApplicableForQuote('Community'));
|
66 |
+
|
67 |
+
$helperMock = $this->getHelperMock('ops/version', array('getVersionInfo'));
|
68 |
+
$helperMock->expects($this->any())
|
69 |
+
->method('getVersionInfo')
|
70 |
+
->will($this->returnValue(array('minor' => '7')));
|
71 |
+
|
72 |
+
$this->assertFalse($helperMock->canUseApplicableForQuote('Community'));
|
73 |
+
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
public function testGetVersionInfo()
|
78 |
+
{
|
79 |
+
$helperMethod = $this->getProtectedMethod($this->helper, 'getVersionInfo');
|
80 |
+
$this->assertEquals(Mage::getVersionInfo(), $helperMethod->invoke($this->helper));
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function getProtectedMethod($class, $method)
|
85 |
+
{
|
86 |
+
$reflection_class = new ReflectionClass(get_class($class));
|
87 |
+
$method = $reflection_class->getMethod($method);
|
88 |
+
$method->setAccessible(true);
|
89 |
+
return $method;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
app/code/community/Netresearch/OPS/Test/Model/AliasTest/fixtures/.gitkeep
ADDED
File without changes
|
app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkShaTest.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Model_Api_DirectLinkShaTest extends EcomDev_PHPUnit_Test_Case
|
3 |
+
{
|
4 |
+
private $_model;
|
5 |
+
private $_shaKey;
|
6 |
+
|
7 |
+
public function setUp()
|
8 |
+
{
|
9 |
+
parent::setup();
|
10 |
+
$this->_model = Mage::getModel('ops/api_directlink');
|
11 |
+
$this->_shaKey = 'ksdf239sdnkvs2e9';
|
12 |
+
}
|
13 |
+
|
14 |
+
public function testShaGenerationWithoutSpecialChars()
|
15 |
+
{
|
16 |
+
$params = array(
|
17 |
+
'ALIAS' => 'foo'
|
18 |
+
);
|
19 |
+
$expected = $params;
|
20 |
+
$expected['SHASIGN'] = '44194456a31b8ea1de461612b19f7255732438d5';
|
21 |
+
$this->assertEquals($expected, $this->_model->getEncodedParametersWithHash($params, $this->_shaKey, 0));
|
22 |
+
}
|
23 |
+
|
24 |
+
public function testShaGenerationWithSpecialChars()
|
25 |
+
{
|
26 |
+
$params = array(
|
27 |
+
'AMOUNT' => '36980',
|
28 |
+
'CARDNO' => '257354109BLZ86010090',
|
29 |
+
'CN' => 'André Herrn',
|
30 |
+
'CURRENCY' => 'EUR',
|
31 |
+
'ED' => '9999',
|
32 |
+
'OPERATION' => 'SAL',
|
33 |
+
'ORDERID' => '20190',
|
34 |
+
'PM' => 'Direct Debits DE',
|
35 |
+
'PSPID' => 'NRMAGENTO',
|
36 |
+
'PSWD' => 'magento1',
|
37 |
+
'USERID' => 'NRMAGENTO1API',
|
38 |
+
);
|
39 |
+
$expected = $params;
|
40 |
+
$expected['SHASIGN'] = 'eb95f7d66879e9801fdbdf75095ce23147202c30';
|
41 |
+
$result = $this->_model->getEncodedParametersWithHash($params, $this->_shaKey, 0);
|
42 |
+
$this->assertEquals($expected, $result);
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Netresearch/OPS/Test/Model/Api/DirectLinkTest.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Netresearch_OPS_Test_Model_Api_DirectLinkTest extends EcomDev_PHPUnit_Test_Case_Controller
|
3 |
+
{
|
4 |
+
private $_model;
|
5 |
+
|
6 |
+
public function setUp()
|
7 |
+
{
|
8 |
+
parent::setup();
|
9 |
+
$this->_model = Mage::getModel('ops/api_directlink');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function testCallInvalidUrl()
|
13 |
+
{
|
14 |
+
$response = $this->_model->call(array(), 'http://localhost');
|
15 |
+
$this->assertInternalType('string', $response);
|
16 |
+
}
|
17 |
+
|
18 |
+
public function testType()
|
19 |
+
{
|
20 |
+
$this->assertInstanceOf('Netresearch_OPS_Model_Api_DirectLink', $this->_model);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testXmlParser()
|
24 |
+
{
|
25 |
+
$xmlExample =
|
26 |
+
'<?xml version="1.0"?>
|
27 |
+
<ncresponse
|
28 |
+
orderID="1121212"
|
29 |
+
PAYID="232"
|
30 |
+
PAYIDSUB="0"
|
31 |
+
NCSTATUS="5"
|
32 |
+
NCERROR="50001111"
|
33 |
+
NCERRORPLUS="Some of the data entered is incorrect. Please retry."
|
34 |
+
ACCEPTANCE=""
|
35 |
+
STATUS="0"
|
36 |
+
amount=""
|
37 |
+
currency="">
|
38 |
+
</ncresponse>';
|
39 |
+
$arrParams = $this->_model->getParamArrFromXmlString($xmlExample);
|
40 |
+
$this->assertEquals("1121212", $arrParams['orderID']);
|
41 |
+
$this->assertEquals("232", $arrParams['PAYID']);
|
42 |
+
$this->assertEquals("0", $arrParams['PAYIDSUB']);
|
43 |
+
$this->assertEquals("5", $arrParams['NCSTATUS']);
|
44 |
+
$this->assertEquals("50001111", $arrParams['NCERROR']);
|
45 |
+
$this->assertEquals("Some of the data entered is incorrect. Please retry.", $arrParams['NCERRORPLUS']);
|
46 |
+
$this->assertEquals("", $arrParams['ACCEPTANCE']);
|
47 |
+
$this->assertEquals("0", $arrParams['STATUS']);
|
48 |
+
$this->assertEquals("", $arrParams['amount']);
|
49 |
+
$this->assertEquals("", $arrParams['currency']);
|
50 |
+
}
|
51 |
+
|
52 |
+
public function testXmlParserWithHtmlAnswer()
|
53 |
+
{
|
54 |
+
$xmlExample =
|
55 |
+
'<?xml version="1.0"?>
|
56 |
+
<ncresponse
|
57 |
+
orderID="1121212"
|
58 |
+
PAYID="232"
|
59 |
+
PAYIDSUB="0"
|
60 |
+
NCSTATUS="5"
|
61 |
+
NCERROR="50001111"
|
62 |
+
NCERRORPLUS="Some of the data entered is incorrect. Please retry."
|
63 |
+
ACCEPTANCE=""
|
64 |
+
STATUS="0"
|
65 |
+
amount=""
|
66 |
+
currency="">
|
67 |
+
<HTML_ANSWER>PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=</HTML_ANSWER>
|
68 |
+
</ncresponse>';
|
69 |
+
$arrParams = $this->_model->getParamArrFromXmlString($xmlExample);
|
70 |
+
$this->assertEquals("1121212", $arrParams['orderID']);
|
71 |
+
$this->assertEquals("232", $arrParams['PAYID']);
|
72 |
+
$this->assertEquals("PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=", $arrParams['HTML_ANSWER']);
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
public function testWithNoXmlResponse()
|
77 |
+
{
|
78 |
+
$xmlExample = '';
|
79 |
+
$this->assertTrue($this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'));
|
80 |
+
$arrParams = $this->_model->getParamArrFromXmlString($xmlExample);
|
81 |
+
$xmlExample = 'N';
|
82 |
+
$arrParams = $this->_model->getParamArrFromXmlString($xmlExample);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @expectedException Mage_Core_Exception
|
87 |
+
*/
|
88 |
+
public function testIsInvalidResponseWithEmptyData()
|
89 |
+
{
|
90 |
+
$this->_model->checkResponse(null);
|
91 |
+
}
|
92 |
+
|
93 |
+
public function testIsValidResponse()
|
94 |
+
{
|
95 |
+
$this->assertTrue(is_null($this->_model->checkResponse(array('NCERROR' => 0))));
|
96 |
+
}
|
97 |
+
|
98 |
+
public function testGetResponseParamsWithValidCallResponse()
|
99 |
+
{
|
100 |
+
$xmlExample =
|
101 |
+
'<?xml version="1.0"?>
|
102 |
+
<ncresponse
|
103 |
+
orderID="1121212"
|
104 |
+
PAYID="232"
|
105 |
+
PAYIDSUB="0"
|
106 |
+
NCSTATUS="5"
|
107 |
+
NCERROR="50001111"
|
108 |
+
NCERRORPLUS="Some of the data entered is incorrect. Please retry."
|
109 |
+
ACCEPTANCE=""
|
110 |
+
STATUS="0"
|
111 |
+
amount=""
|
112 |
+
currency="">
|
113 |
+
<HTML_ANSWER>PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=</HTML_ANSWER>
|
114 |
+
</ncresponse>';
|
115 |
+
$directLinkMock = $this->getModelMock('ops/api_directlink', array('call'));
|
116 |
+
$directLinkMock->expects($this->any())
|
117 |
+
->method('call')
|
118 |
+
->will($this->returnValue($xmlExample));
|
119 |
+
|
120 |
+
$class = new ReflectionClass(get_class(Mage::getModel('ops/api_directlink')));
|
121 |
+
$method = $class->getMethod('getResponseParams');
|
122 |
+
$method->setAccessible(true);
|
123 |
+
$result = $method->invokeArgs($directLinkMock, array(array('foo' => '111', 'ORDERID' => 4711), 'bar'));
|
124 |
+
$this->assertTrue(is_array($result));
|
125 |
+
$this->assertTrue(array_key_exists('orderID', $result));
|
126 |
+
$this->assertTrue(array_key_exists('PAYID', $result));
|
127 |
+
$this->assertTrue(array_key_exists('PAYIDSUB', $result));
|
128 |
+
$this->assertTrue(array_key_exists('NCSTATUS', $result));
|
129 |
+
$this->assertTrue(array_key_exists('NCERROR', $result));
|
130 |
+
$this->assertTrue(array_key_exists('NCERROR', $result));
|
131 |
+
$this->assertTrue(array_key_exists('NCERRORPLUS', $result));
|
132 |
+
$this->assertTrue(array_key_exists('ACCEPTANCE', $result));
|
133 |
+
$this->assertTrue(array_key_exists('STATUS', $result));
|
134 |
+
$this->assertTrue(array_key_exists('amount', $result));
|
135 |
+
$this->assertTrue(array_key_exists('currency', $result));
|
136 |
+
$this->assertTrue(array_key_exists('HTML_ANSWER', $result));
|
137 |
+
}
|
138 |
+
|
139 |
+
public function testGetResponseParamsWithValidCallButWrongEncodedResponse()
|
140 |
+
{
|
141 |
+
$xmlExample =
|
142 |
+
'<?xml version="1.0"?>
|
143 |
+
<ncresponse
|
144 |
+
orderID="1121212"
|
145 |
+
PAYID="232"
|
146 |
+
PAYIDSUB="0"
|
147 |
+
NCSTATUS="5"
|
148 |
+
NCERROR="50001111"
|
149 |
+
NCERRORPLUS="Some of the data entered is incorrect. Please retry."
|
150 |
+
ACCEPTANCE=""
|
151 |
+
STATUS="0"
|
152 |
+
amount=""
|
153 |
+
currency=""
|
154 |
+
CN="Max Mueller">
|
155 |
+
<HTML_ANSWER>PGZvcm0gbmFtZT0iZG93bmxvYWRmb3JtM0QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9UZXN0XzNEX0FDUy5hc3AiIG1ldGhvZD0icG9zdCI+DQo8Tk9TQ1JJUFQ+DQpKYXZhU2NyaXB0IGlzIGN1cnJlbnRseSBkaXNhYmxlZCBvciBpcyBub3Qgc3VwcG9ydGVkIGJ5IHlvdXIgYnJvd3Nlci48YnI+DQpQbGVhc2UgY2xpY2sgb24gdGhlICZxdW90O0NvbnRpbnVlJnF1b3Q7IGJ1dHRvbiB0byBjb250aW51ZSB0aGUgcHJvY2Vzc2luZyBvZiB5b3VyIDMtRCBzZWN1cmUgdHJhbnNhY3Rpb24uPGJyPg0KPGlucHV0IGNsYXNzPSJuY29sIiB0eXBlPSJzdWJtaXQiIHZhbHVlPSJDb250aW51ZSIgaWQ9InN1Ym1pdDEiIG5hbWU9InN1Ym1pdDEiIC8+DQo8L05PU0NSSVBUPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRktFWSIgdmFsdWU9IjA0MzA0MzI4NkE0M0ZDM0YyRDhFMDFCOUM2MzYwRTA1Qzg5NkZEMzYiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGVFMiIHZhbHVlPSIyMDExMDkxMjE2MjQ1MCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZTUCIgdmFsdWU9Ii9uY29sL3Rlc3Qvb3JkZXJkaXJlY3QuYXNwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGFSZXEiIHZhbHVlPSI8P3htbCB2ZXJzaW9uPSZxdW90OzEuMCZxdW90Oz8+PFRocmVlRFNlY3VyZT48TWVzc2FnZSBpZD0mcXVvdDsxMjMmcXVvdDs+PFBBUmVxPjx2ZXJzaW9uPjEuMDI8L3ZlcnNpb24+PE1lcmNoYW50PjxtZXJJRD5OUk1BR0VOVE8zPC9tZXJJRD48bmFtZT5OZXRyZXNlYXJjaCBHbWJIICZhbXA7YW1wOyBDby5LRzwvbmFtZT48dXJsPmh0dHA6Ly93d3cubmV0cmVzZWFyY2guZGU8L3VybD48L01lcmNoYW50PjxQdXJjaGFzZT48eGlkPjExNjI4OTgzPC94aWQ+PGFtb3VudD4xMjY4Ljc1PC9hbW91bnQ+PHB1cmNoQW1vdW50PjEyNjguNzU8L3B1cmNoQW1vdW50PjxjdXJyZW5jeT5FVVI8L2N1cnJlbmN5PjwvUHVyY2hhc2U+PENIPjxhY2N0SUQ+NDAwMDAwWFhYWFhYMDAwMjwvYWNjdElEPjxleHBpcnk+MDExNjwvZXhwaXJ5PjxzZWxCcmFuZD48L3NlbEJyYW5kPjwvQ0g+PC9QQVJlcT48L01lc3NhZ2U+PC9UaHJlZURTZWN1cmU+DQoiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJUZXJtVXJsIiB2YWx1ZT0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9BM0RTLmFzcCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Ik1EIiB2YWx1ZT0iTUFJTldQVEVTVDAwMDAxMTYyODk4MzAxKjEwNzUyNjIiIC8+DQo8L2Zvcm0+DQo8Zm9ybSBtZXRob2Q9InBvc3QiIGFjdGlvbj0iaHR0cHM6Ly9zZWN1cmUub2dvbmUuY29tL25jb2wvdGVzdC9vcmRlcl9hZ3JlZS5hc3AiIG5hbWU9InVwbG9hZEZvcm0zRCI+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDU1JGS0VZIiB2YWx1ZT0iMDZGM0MzMUQ2RkI1MzIzODg4NjhFRjlGNTA5RUNGNzlBQzIwRDJGMyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNTUkZUUyIgdmFsdWU9IjIwMTEwOTEyMTYyNDUwIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ1NSRlNQIiB2YWx1ZT0iL25jb2wvdGVzdC9vcmRlcmRpcmVjdC5hc3AiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJicmFuZGluZyIgdmFsdWU9Ik9nb25lIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0icGF5aWQiIHZhbHVlPSIxMTYyODk4MyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0b3JlYWxpYXMiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJoYXNoX3BhcmFtIiB2YWx1ZT0iOTFBMzA1MjFEMEI0QTA1MEFBRDkzRDM5RDY2RkEyM0Y5OEIzRDQ4RCIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InhpZF8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9InN0YXR1c18zRCIgdmFsdWU9IlhYIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iZWNpXzNEIiB2YWx1ZT0iNyIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhcmRudW1iZXIiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJFY29tX1BheW1lbnRfQ2FyZF9WZXJpZmljYXRpb24iIHZhbHVlPSIqMTA3NTI2MiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNWQ0ZsYWciIHZhbHVlPSIxIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY2F2dl8zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9ImNhdnZhbGdvcml0aG1fM0QiIHZhbHVlPSIiIC8+DQo8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaWduYXR1cmVPS18zRCIgdmFsdWU9IiIgLz4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Imhhc2hfcGFyYW1fM0QiIHZhbHVlPSIwMzAzREZDMkI1OTM0MjZCQTExRkQ5RjJBNkQ0NDk5ODEwN0JGN0YzIiAvPg0KPC9mb3JtPg0KPFNDUklQVCBMQU5HVUFHRT0iSmF2YXNjcmlwdCIgRk9SPSJ3aW5kb3ciIEVWRU5UPSJvbkxvYWQiPg0KdmFyIHBvcHVwV2luOw0KdmFyIHN1Ym1pdHBvcHVwV2luID0gMDsNCg0KZnVuY3Rpb24gTG9hZFBvcHVwKCkgew0KCWlmIChzZWxmLm5hbWUgPT0gbnVsbCkJew0KCQlzZWxmLm5hbWUgPSAib2dvbmVNYWluIjsNCgl9DQoJcG9wdXBXaW4gPSB3aW5kb3cub3BlbignYWJvdXQ6YmxhbmsnLCAncG9wdXBXaW4nLCAnaGVpZ2h0PTQwMCwgd2lkdGg9MzkwLCBzdGF0dXM9eWVzLCBkZXBlbmRlbnQ9bm8sIHNjcm9sbGJhcnM9eWVzLCByZXNpemFibGU9bm8nKTsNCglpZiAocG9wdXBXaW4gIT0gbnVsbCkgew0KCQlpZiAgKCFwb3B1cFdpbiB8fCBwb3B1cFdpbi5jbG9zZWQpIHsNCgkJCXJldHVybiAxOw0KCQl9IGVsc2Ugew0KCQkJaWYgKCFwb3B1cFdpbi5vcGVuZXIgfHwgcG9wdXBXaW4ub3BlbmVyID09IG51bGwpIHsNCgkJCQlwb3B1cFdpbi5vcGVuZXIgPSBzZWxmOw0KCQkJfQ0KCQkJc2VsZi5kb2N1bWVudC5mb3Jtcy5kb3dubG9hZGZvcm0zRC50YXJnZXQgPSAncG9wdXBXaW4nOw0KCQkJaWYgKHN1Ym1pdHBvcHVwV2luID09IDEpIHsNCgkJCQlzZWxmLmRvY3VtZW50LmZvcm1zLmRvd25sb2FkZm9ybTNELnN1Ym1pdCgpOw0KCQkJfQ0KCQkJcG9wdXBXaW4uZm9jdXMoKTsNCgkJCXJldHVybiAwOw0KCQl9DQoJfSBlbHNlIHsNCgkJcmV0dXJuIDE7DQoJfQ0KfQ0KCXNlbGYuZG9jdW1lbnQuZm9ybXMuZG93bmxvYWRmb3JtM0Quc3VibWl0KCk7DQovLy0tPg0KPC9TQ1JJUFQ+DQo=</HTML_ANSWER>
|
156 |
+
</ncresponse>';
|
157 |
+
$xmlExample = utf8_decode($xmlExample);
|
158 |
+
$directLinkMock = $this->getModelMock('ops/api_directlink', array('call'));
|
159 |
+
$directLinkMock->expects($this->any())
|
160 |
+
->method('call')
|
161 |
+
->will($this->returnValue($xmlExample));
|
162 |
+
|
163 |
+
$class = new ReflectionClass(get_class(Mage::getModel('ops/api_directlink')));
|
164 |
+
$method = $class->getMethod('getResponseParams');
|
165 |
+
$method->setAccessible(true);
|
166 |
+
$result = $method->invokeArgs($directLinkMock, array(array('foo' => '111', 'ORDERID' => 4711), 'bar'));
|
167 |
+
$this->assertTrue(is_array($result));
|
168 |
+
$this->assertTrue(array_key_exists('orderID', $result));
|
169 |
+
$this->assertTrue(array_key_exists('PAYID', $result));
|
170 |
+
$this->assertTrue(array_key_exists('PAYIDSUB', $result));
|
171 |
+
$this->assertTrue(array_key_exists('NCSTATUS', $result));
|
172 |
+
$this->assertTrue(array_key_exists('NCERROR', $result));
|
173 |
+
$this->assertTrue(array_key_exists('NCERROR', $result));
|
174 |
+
$this->assertTrue(array_key_exists('NCERRORPLUS', $result));
|
175 |
+
$this->assertTrue(array_key_exists('ACCEPTANCE', $result));
|
176 |
+
$this->assertTrue(array_key_exists('STATUS', $result));
|
177 |
+
$this->assertTrue(array_key_exists('amount', $result));
|
178 |
+
$this->assertTrue(array_key_exists('currency', $result));
|
179 |
+
$this->assertTrue(array_key_exists('HTML_ANSWER', $result));
|
180 |
+
$this->assertTrue(array_key_exists('CN', $result));
|
181 |
+
$this->assertEquals('Max Mueller', $result['CN']);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @expectedException Mage_Core_Exception
|
186 |
+
*/
|
187 |
+
public function testGetResponseParamsWithRetryCountExceeded()
|
188 |
+
{
|
189 |
+
$maxAllowedRetryCount = Netresearch_OPS_Model_Api_DirectLink::MAX_RETRY_COUNT;
|
190 |
+
$class = new ReflectionClass(get_class(Mage::getModel('ops/api_directlink')));
|
191 |
+
$method = $class->getMethod('getResponseParams');
|
192 |
+
$method->setAccessible(true);
|
193 |
+
$result = $method->invokeArgs(Mage::getModel('ops/api_directlink'), array(array('foo' => '123', 'ORDERID' => '4711'), 'bar', ++$maxAllowedRetryCount));
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* @expectedException Mage_Core_Exception
|
198 |
+
*/
|
199 |
+
public function testGetResponseParamsWithInvalidResponse()
|
200 |
+
{
|
201 |
+
$xmlExample = '';
|
202 |
+
$directLinkMock = $this->getModelMock('ops/api_directlink', array('call'));
|
203 |
+
$directLinkMock->expects($this->any())
|
204 |
+
->method('call')
|
205 |
+
->will($this->returnValue($xmlExample));
|
206 |
+
|
207 |
+
$class = new ReflectionClass(get_class(Mage::getModel('ops/api_directlink')));
|
208 |
+
$method = $class->getMethod('getResponseParams');
|
209 |
+
$method->setAccessible(true);
|
210 |
+
$result = $method->invokeArgs($directLinkMock, array(array('foo' => '12334', 'ORDERID' => 4711), 'bar'));
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
|