From 8e69d02a19cd709779a57ac0206e5ede50814e1b Mon Sep 17 00:00:00 2001 From: Daniel Kerr Date: Sun, 15 Oct 2023 15:02:41 +0800 Subject: [PATCH] updated paypal to latest version i'm upgrading version 3.x.x.x because its still the most used. i'm guessing its because most servers are still running PHP7 --- .../controller/extension/payment/paypal.php | 1637 ++++++-- .../extension/payment/pp_braintree.php | 1132 ------ .../extension/payment/pp_express.php | 1300 ------ .../extension/payment/pp_payflow.php | 177 - .../extension/payment/pp_payflow_iframe.php | 483 --- .../controller/extension/payment/pp_pro.php | 159 - .../extension/payment/pp_pro_iframe.php | 771 ---- .../extension/payment/pp_standard.php | 187 - .../en-gb/extension/payment/paypal.php | 397 +- .../en-gb/extension/payment/pp_braintree.php | 191 - .../en-gb/extension/payment/pp_express.php | 86 - .../extension/payment/pp_express_order.php | 52 - .../extension/payment/pp_express_refund.php | 21 - .../extension/payment/pp_express_search.php | 73 - .../extension/payment/pp_express_view.php | 85 - .../en-gb/extension/payment/pp_payflow.php | 39 - .../extension/payment/pp_payflow_iframe.php | 104 - .../en-gb/extension/payment/pp_pro.php | 33 - .../en-gb/extension/payment/pp_pro_iframe.php | 174 - .../en-gb/extension/payment/pp_standard.php | 44 - .../admin/model/extension/payment/paypal.php | 231 +- .../model/extension/payment/pp_braintree.php | 168 - .../model/extension/payment/pp_express.php | 371 -- .../extension/payment/pp_payflow_iframe.php | 136 - .../model/extension/payment/pp_pro_iframe.php | 261 -- .../view/image/payment/paypal/background.jpg | Bin 0 -> 15960 bytes .../payment/paypal/icon-all-settings-down.svg | 3 + .../payment/paypal/icon-all-settings-up.svg | 3 + .../payment/paypal/icon-applepay-button.svg | 29 + .../payment/paypal/icon-back-dashboard.svg | 3 + .../view/image/payment/paypal/icon-button.svg | 16 + .../view/image/payment/paypal/icon-card.svg | 8 + .../image/payment/paypal/icon-check-off.svg | 8 + .../image/payment/paypal/icon-check-on.svg | 8 + .../image/payment/paypal/icon-contact.svg | 29 + .../image/payment/paypal/icon-general.svg | 18 + .../view/image/payment/paypal/icon-logo.svg | 13 + .../image/payment/paypal/icon-message.svg | 19 + .../payment/paypal/icon-order-status.svg | 14 + .../paypal/icon-panel-sale-analytics.svg | 23 + .../payment/paypal/icon-panel-statistic.svg | 38 + .../image/payment/paypal/icon-product.svg | 7 + .../payment/paypal/icon-section-panel.svg | 3 + .../image/payment/paypal/icon-statistic.svg | 7 + .../javascript/paypal/bootstrap-switch.js | 784 ++++ upload/admin/view/javascript/paypal/paypal.js | 366 ++ .../stylesheet/paypal/bootstrap-switch.css | 187 + upload/admin/view/stylesheet/paypal/card.css | 130 + .../admin/view/stylesheet/paypal/paypal.css | 959 +++++ .../module/klarna_checkout_module.twig | 47 + .../extension/payment/klarna_checkout.twig | 641 +++ ..._order.twig => klarna_checkout_order.twig} | 8 +- .../payment/klarna_checkout_order_ajax.twig | 721 ++++ .../template/extension/payment/paypal.twig | 575 --- .../payment/paypal/applepay_button.twig | 280 ++ .../extension/payment/paypal/auth.twig | 107 + .../extension/payment/paypal/button.twig | 412 ++ .../extension/payment/paypal/card.twig | 239 ++ .../extension/payment/paypal/contact.twig | 210 + .../extension/payment/paypal/dashboard.twig | 253 ++ .../extension/payment/paypal/general.twig | 255 ++ .../extension/payment/paypal/message.twig | 429 ++ .../payment/paypal/order_status.twig | 110 + .../extension/payment/pp_braintree.twig | 1031 ----- .../payment/pp_braintree_order_ajax.twig | 213 - .../payment/pp_braintree_preferred.twig | 39 - .../extension/payment/pp_express.twig | 461 --- .../extension/payment/pp_express_order.twig | 153 - .../payment/pp_express_preferred.twig | 40 - .../extension/payment/pp_express_refund.twig | 75 - .../extension/payment/pp_express_search.twig | 264 -- .../payment/pp_express_transaction.twig | 39 - .../extension/payment/pp_express_view.twig | 473 --- .../extension/payment/pp_payflow.twig | 155 - .../extension/payment/pp_payflow_iframe.twig | 212 - .../payment/pp_payflow_iframe_order.twig | 155 - .../payment/pp_payflow_iframe_refund.twig | 69 - .../template/extension/payment/pp_pro.twig | 146 - .../extension/payment/pp_pro_iframe.twig | 315 -- .../payment/pp_pro_iframe_order.twig | 271 -- .../payment/pp_pro_iframe_refund.twig | 74 - .../payment/pp_pro_iframe_transaction.twig | 422 -- .../extension/payment/pp_standard.twig | 278 -- .../module/klarna_checkout_module.php | 138 + .../extension/payment/klarna_checkout.php | 1963 +++++++++ .../controller/extension/payment/paypal.php | 3085 ++++++++++++-- .../extension/payment/paypal_paylater.php | 159 + .../extension/payment/pp_braintree.php | 1635 -------- .../extension/payment/pp_express.php | 1935 --------- .../extension/payment/pp_payflow.php | 199 - .../extension/payment/pp_payflow_iframe.php | 158 - .../controller/extension/payment/pp_pro.php | 186 - .../extension/payment/pp_pro_iframe.php | 311 -- .../extension/payment/pp_standard.php | 240 -- .../extension/payment/klarna_checkout.php | 14 + .../en-gb/extension/payment/paypal.php | 112 +- .../en-gb/extension/payment/pp_braintree.php | 48 - .../en-gb/extension/payment/pp_express.php | 27 - .../en-gb/extension/payment/pp_payflow.php | 24 - .../extension/payment/pp_payflow_iframe.php | 7 - .../en-gb/extension/payment/pp_pro.php | 17 - .../en-gb/extension/payment/pp_pro_iframe.php | 7 - .../en-gb/extension/payment/pp_standard.php | 5 - .../model/extension/payment/paypal.php | 90 +- .../extension/payment/paypal_paylater.php | 51 + .../model/extension/payment/pp_braintree.php | 191 - .../model/extension/payment/pp_express.php | 354 -- .../model/extension/payment/pp_payflow.php | 31 - .../extension/payment/pp_payflow_iframe.php | 119 - .../model/extension/payment/pp_pro.php | 31 - .../model/extension/payment/pp_pro_iframe.php | 41 - .../model/extension/payment/pp_standard.php | 63 - .../catalog/view/javascript/paypal/paypal.js | 696 ++++ .../theme/default/stylesheet/paypal/card.css | 130 + .../default/stylesheet/paypal/paypal.css | 66 + .../template/extension/payment/paypal.twig | 630 --- .../extension/payment/paypal/confirm.twig | 600 +++ .../extension/payment/paypal/message.twig | 8 + .../payment/paypal/payment_address.twig | 312 ++ .../extension/payment/paypal/paypal.twig | 71 + .../payment/paypal/paypal_modal.twig | 47 + .../payment/paypal/paypal_paylater.twig | 43 + .../payment/paypal/paypal_paylater_modal.twig | 19 + .../payment/paypal/shipping_address.twig | 195 + .../extension/payment/pp_braintree.twig | 681 ---- .../payment/pp_braintree_confirm.twig | 146 - .../extension/payment/pp_express.twig | 27 - .../extension/payment/pp_express_confirm.twig | 128 - .../extension/payment/pp_payflow.twig | 123 - .../extension/payment/pp_payflow_iframe.twig | 9 - .../payment/pp_payflow_iframe_return.twig | 3 - .../template/extension/payment/pp_pro.twig | 119 - .../extension/payment/pp_pro_iframe.twig | 15 - .../extension/payment/pp_pro_iframe_body.twig | 20 - .../extension/payment/pp_standard.twig | 54 - upload/system/config/paypal.php | 640 ++- upload/system/library/config.php | 4 +- upload/system/library/paypal/paypal.php | 159 +- .../vendor/klarna/kco_rest/.coveralls.yml | 3 + .../storage/vendor/klarna/kco_rest/.gitignore | 3 + .../vendor/klarna/kco_rest/.travis.yml | 29 + .../vendor/klarna/kco_rest/CHANGELOG.md | 17 + .../storage/vendor/klarna/kco_rest/README.md | 67 + .../vendor/klarna/kco_rest/composer.json | 46 + .../vendor/klarna/kco_rest/composer.lock | 3569 +++++++++++++++++ .../examples/capture/add_shipping_info.php | 34 + .../examples/capture/trigger_send_out.php | 22 + .../capture/update_customer_details.php | 27 + .../examples/checkout/create_checkout.php | 60 + .../checkout/create_checkout_attachment.php | 79 + .../docs/examples/checkout/fetch_checkout.php | 19 + .../examples/checkout/update_checkout.php | 56 + .../docs/examples/order/acknowledge_order.php | 22 + .../docs/examples/order/cancel_order.php | 21 + .../docs/examples/order/create_capture.php | 49 + .../order/extend_authorization_time.php | 19 + .../docs/examples/order/fetch_capture.php | 21 + .../docs/examples/order/fetch_order.php | 19 + .../docs/examples/order/refund_order.php | 37 + .../order/release_remaining_authorization.php | 21 + .../order/update_customer_details.php | 30 + .../order/update_merchant_references.php | 25 + .../examples/order/update_order_lines.php | 37 + .../klarna/kco_rest/git_hooks/README.md | 14 + .../klarna/kco_rest/git_hooks/coffeelint | 103 + .../git_hooks/commit-msg/message-format | 34 + .../git_hooks/commit-msg/ticket-number | 30 + .../vendor/klarna/kco_rest/git_hooks/jshint | 69 + .../git_hooks/pre-commit/check-coffee | 59 + .../kco_rest/git_hooks/pre-commit/check-js | 59 + .../kco_rest/git_hooks/pre-commit/check-php | 65 + .../git_hooks/pre-commit/check-python | 48 + .../storage/vendor/klarna/kco_rest/phpmd.xml | 32 + .../vendor/klarna/kco_rest/phpunit.xml.dist | 40 + .../src/Klarna/Rest/Checkout/Order.php | 112 + .../Klarna/Rest/OrderManagement/Capture.php | 149 + .../src/Klarna/Rest/OrderManagement/Order.php | 317 ++ .../kco_rest/src/Klarna/Rest/Resource.php | 200 + .../src/Klarna/Rest/Transport/Connector.php | 186 + .../Rest/Transport/ConnectorInterface.php | 94 + .../Exception/ConnectorException.php | 110 + .../Rest/Transport/ResponseValidator.php | 137 + .../src/Klarna/Rest/Transport/UserAgent.php | 130 + .../Rest/Transport/UserAgentInterface.php | 117 + .../tests/Component/Checkout/OrderTest.php | 135 + .../Component/OrderManagement/CaptureTest.php | 168 + .../Component/OrderManagement/OrderTest.php | 451 +++ .../tests/Component/ResourceTestCase.php | 45 + .../kco_rest/tests/Component/TestCase.php | 80 + .../Component/Transport/ConnectorTest.php | 144 + .../tests/Unit/Checkout/OrderTest.php | 418 ++ .../Unit/OrderManagement/CaptureTest.php | 512 +++ .../tests/Unit/OrderManagement/OrderTest.php | 921 +++++ .../klarna/kco_rest/tests/Unit/TestCase.php | 57 + .../tests/Unit/Transport/ConnectorTest.php | 343 ++ .../Exception/ConnectorExceptionTest.php | 80 + .../Unit/Transport/ResponseValidatorTest.php | 249 ++ .../tests/Unit/Transport/UserAgentTest.php | 125 + .../klarna/kco_rest/tests/bootstrap.php | 23 + 199 files changed, 26519 insertions(+), 20014 deletions(-) delete mode 100644 upload/admin/controller/extension/payment/pp_braintree.php delete mode 100644 upload/admin/controller/extension/payment/pp_express.php delete mode 100644 upload/admin/controller/extension/payment/pp_payflow.php delete mode 100644 upload/admin/controller/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/admin/controller/extension/payment/pp_pro.php delete mode 100644 upload/admin/controller/extension/payment/pp_pro_iframe.php delete mode 100644 upload/admin/controller/extension/payment/pp_standard.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_braintree.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_express.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_express_order.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_express_refund.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_express_search.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_express_view.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_payflow.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_pro.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_pro_iframe.php delete mode 100644 upload/admin/language/en-gb/extension/payment/pp_standard.php delete mode 100644 upload/admin/model/extension/payment/pp_braintree.php delete mode 100644 upload/admin/model/extension/payment/pp_express.php delete mode 100644 upload/admin/model/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/admin/model/extension/payment/pp_pro_iframe.php create mode 100644 upload/admin/view/image/payment/paypal/background.jpg create mode 100644 upload/admin/view/image/payment/paypal/icon-all-settings-down.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-all-settings-up.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-applepay-button.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-back-dashboard.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-button.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-card.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-check-off.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-check-on.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-contact.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-general.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-logo.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-message.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-order-status.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-panel-sale-analytics.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-panel-statistic.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-product.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-section-panel.svg create mode 100644 upload/admin/view/image/payment/paypal/icon-statistic.svg create mode 100644 upload/admin/view/javascript/paypal/bootstrap-switch.js create mode 100644 upload/admin/view/javascript/paypal/paypal.js create mode 100644 upload/admin/view/stylesheet/paypal/bootstrap-switch.css create mode 100644 upload/admin/view/stylesheet/paypal/card.css create mode 100644 upload/admin/view/stylesheet/paypal/paypal.css create mode 100644 upload/admin/view/template/extension/module/klarna_checkout_module.twig create mode 100644 upload/admin/view/template/extension/payment/klarna_checkout.twig rename upload/admin/view/template/extension/payment/{pp_braintree_order.twig => klarna_checkout_order.twig} (53%) create mode 100644 upload/admin/view/template/extension/payment/klarna_checkout_order_ajax.twig delete mode 100644 upload/admin/view/template/extension/payment/paypal.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/applepay_button.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/auth.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/button.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/card.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/contact.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/dashboard.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/general.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/message.twig create mode 100644 upload/admin/view/template/extension/payment/paypal/order_status.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_braintree.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_braintree_order_ajax.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_braintree_preferred.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_order.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_preferred.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_refund.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_search.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_transaction.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_express_view.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_payflow.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_payflow_iframe.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_payflow_iframe_order.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_payflow_iframe_refund.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_pro.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_pro_iframe.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_pro_iframe_order.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_pro_iframe_refund.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_pro_iframe_transaction.twig delete mode 100644 upload/admin/view/template/extension/payment/pp_standard.twig create mode 100644 upload/catalog/controller/extension/module/klarna_checkout_module.php create mode 100644 upload/catalog/controller/extension/payment/klarna_checkout.php create mode 100644 upload/catalog/controller/extension/payment/paypal_paylater.php delete mode 100644 upload/catalog/controller/extension/payment/pp_braintree.php delete mode 100644 upload/catalog/controller/extension/payment/pp_express.php delete mode 100644 upload/catalog/controller/extension/payment/pp_payflow.php delete mode 100644 upload/catalog/controller/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/catalog/controller/extension/payment/pp_pro.php delete mode 100644 upload/catalog/controller/extension/payment/pp_pro_iframe.php delete mode 100644 upload/catalog/controller/extension/payment/pp_standard.php create mode 100644 upload/catalog/language/en-gb/extension/payment/klarna_checkout.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_braintree.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_express.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_payflow.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_pro.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_pro_iframe.php delete mode 100644 upload/catalog/language/en-gb/extension/payment/pp_standard.php create mode 100644 upload/catalog/model/extension/payment/paypal_paylater.php delete mode 100644 upload/catalog/model/extension/payment/pp_braintree.php delete mode 100644 upload/catalog/model/extension/payment/pp_express.php delete mode 100644 upload/catalog/model/extension/payment/pp_payflow.php delete mode 100644 upload/catalog/model/extension/payment/pp_payflow_iframe.php delete mode 100644 upload/catalog/model/extension/payment/pp_pro.php delete mode 100644 upload/catalog/model/extension/payment/pp_pro_iframe.php delete mode 100644 upload/catalog/model/extension/payment/pp_standard.php create mode 100644 upload/catalog/view/javascript/paypal/paypal.js create mode 100644 upload/catalog/view/theme/default/stylesheet/paypal/card.css create mode 100644 upload/catalog/view/theme/default/stylesheet/paypal/paypal.css delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/confirm.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/message.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/payment_address.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/paypal.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_modal.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater_modal.twig create mode 100644 upload/catalog/view/theme/default/template/extension/payment/paypal/shipping_address.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_braintree.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_braintree_confirm.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_express.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_express_confirm.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_payflow.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe_return.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_pro.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe_body.twig delete mode 100644 upload/catalog/view/theme/default/template/extension/payment/pp_standard.twig create mode 100644 upload/system/storage/vendor/klarna/kco_rest/.coveralls.yml create mode 100644 upload/system/storage/vendor/klarna/kco_rest/.gitignore create mode 100644 upload/system/storage/vendor/klarna/kco_rest/.travis.yml create mode 100644 upload/system/storage/vendor/klarna/kco_rest/CHANGELOG.md create mode 100644 upload/system/storage/vendor/klarna/kco_rest/README.md create mode 100644 upload/system/storage/vendor/klarna/kco_rest/composer.json create mode 100644 upload/system/storage/vendor/klarna/kco_rest/composer.lock create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/add_shipping_info.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/trigger_send_out.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/update_customer_details.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout_attachment.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/fetch_checkout.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/update_checkout.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/acknowledge_order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/cancel_order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/create_capture.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/extend_authorization_time.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_capture.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/refund_order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/release_remaining_authorization.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_customer_details.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_merchant_references.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_order_lines.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/README.md create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/coffeelint create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/message-format create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/ticket-number create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/jshint create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-coffee create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-js create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-python create mode 100644 upload/system/storage/vendor/klarna/kco_rest/phpmd.xml create mode 100644 upload/system/storage/vendor/klarna/kco_rest/phpunit.xml.dist create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Checkout/Order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Capture.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Order.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Resource.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/Connector.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ConnectorInterface.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/Exception/ConnectorException.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ResponseValidator.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgent.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgentInterface.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/Checkout/OrderTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/CaptureTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/OrderTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/ResourceTestCase.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/TestCase.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Component/Transport/ConnectorTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Checkout/OrderTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/CaptureTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/OrderTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/TestCase.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ConnectorTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/Exception/ConnectorExceptionTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ResponseValidatorTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/UserAgentTest.php create mode 100644 upload/system/storage/vendor/klarna/kco_rest/tests/bootstrap.php diff --git a/upload/admin/controller/extension/payment/paypal.php b/upload/admin/controller/extension/payment/paypal.php index 23668425903..c414bbe29f1 100644 --- a/upload/admin/controller/extension/payment/paypal.php +++ b/upload/admin/controller/extension/payment/paypal.php @@ -1,68 +1,35 @@ load->language('extension/payment/paypal'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('extension/payment/paypal'); - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_paypal', $this->request->post); - - $this->session->data['success'] = $this->language->get('success_save'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extensions'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['action'] = $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true); - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - $data['partner_url'] = str_replace('&', '%26', $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); - $data['callback_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/callback', 'user_token=' . $this->session->data['user_token'], true)); - $data['configure_smart_button_url'] = $this->url->link('extension/payment/paypal/configureSmartButton', 'user_token=' . $this->session->data['user_token'], true); - + public function index() { if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { - $data['server'] = HTTPS_SERVER; - $data['catalog'] = HTTPS_CATALOG; + $server = HTTPS_SERVER; + $catalog = HTTPS_CATALOG; } else { - $data['server'] = HTTP_SERVER; - $data['catalog'] = HTTP_CATALOG; + $server = HTTP_SERVER; + $catalog = HTTP_CATALOG; } // Setting $_config = new Config(); $_config->load('paypal'); - $data['setting'] = $_config->get('paypal_setting'); - - if (isset($this->session->data['environment']) && isset($this->session->data['authorization_code']) && isset($this->session->data['shared_id']) && isset($this->session->data['seller_nonce']) && isset($this->request->get['merchantIdInPayPal'])) { + $config_setting = $_config->get('paypal_setting'); + + if (!empty($this->session->data['environment']) && !empty($this->session->data['authorization_code']) && !empty($this->session->data['shared_id']) && !empty($this->session->data['seller_nonce']) && !empty($this->request->get['merchantIdInPayPal'])) { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + $environment = $this->session->data['environment']; require_once DIR_SYSTEM . 'library/paypal/paypal.php'; $paypal_info = array( 'client_id' => $this->session->data['shared_id'], - 'environment' => $environment + 'environment' => $environment, + 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] ); $paypal = new PayPal($paypal_info); @@ -74,16 +41,35 @@ public function index() { ); $paypal->setAccessToken($token_info); - - $result = $paypal->getSellerCredentials($data['setting']['partner'][$environment]['partner_id']); + + $result = $paypal->getSellerCredentials($config_setting['partner'][$environment]['partner_id']); + + $client_id = ''; + $secret = ''; if (isset($result['client_id']) && isset($result['client_secret'])) { $client_id = $result['client_id']; $secret = $result['client_secret']; } - + + $paypal_info = array( + 'partner_id' => $config_setting['partner'][$environment]['partner_id'], + 'client_id' => $client_id, + 'secret' => $secret, + 'environment' => $environment, + 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + $webhook_info = array( - 'url' => $data['catalog'] . 'index.php?route=extension/payment/paypal/webhook', + 'url' => $catalog . 'index.php?route=extension/payment/paypal', 'event_types' => array( array('name' => 'PAYMENT.AUTHORIZATION.CREATED'), array('name' => 'PAYMENT.AUTHORIZATION.VOIDED'), @@ -92,24 +78,23 @@ public function index() { array('name' => 'PAYMENT.CAPTURE.PENDING'), array('name' => 'PAYMENT.CAPTURE.REFUNDED'), array('name' => 'PAYMENT.CAPTURE.REVERSED'), - array('name' => 'CHECKOUT.ORDER.COMPLETED'), - array('name' => 'CHECKOUT.ORDER.APPROVED') + array('name' => 'CHECKOUT.ORDER.COMPLETED') ) ); $result = $paypal->createWebhook($webhook_info); - + $webhook_id = ''; if (isset($result['id'])) { $webhook_id = $result['id']; } - + if ($paypal->hasErrors()) { $error_messages = array(); $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); @@ -117,7 +102,7 @@ public function index() { if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; - } else { + } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } @@ -128,177 +113,264 @@ public function index() { } $merchant_id = $this->request->get['merchantIdInPayPal']; + + $this->load->model('setting/setting'); + + $setting = $this->model_setting_setting->getSetting('payment_paypal'); + $setting['payment_paypal_environment'] = $environment; + $setting['payment_paypal_client_id'] = $client_id; + $setting['payment_paypal_secret'] = $secret; + $setting['payment_paypal_merchant_id'] = $merchant_id; + $setting['payment_paypal_webhook_id'] = $webhook_id; + $setting['payment_paypal_status'] = 1; + $setting['payment_paypal_total'] = 0; + $setting['payment_paypal_geo_zone_id'] = 0; + $setting['payment_paypal_sort_order'] = 0; + + $this->load->model('localisation/country'); + + $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); + + $setting['payment_paypal_setting']['general']['country_code'] = $country['iso_code_2']; + + $currency_code = $this->config->get('config_currency'); + $currency_value = $this->currency->getValue($this->config->get('config_currency')); + + if (!empty($config_setting['currency'][$currency_code]['status'])) { + $setting['payment_paypal_setting']['general']['currency_code'] = $currency_code; + $setting['payment_paypal_setting']['general']['currency_value'] = $currency_value; + } + + if (!empty($config_setting['currency'][$currency_code]['card_status'])) { + $setting['payment_paypal_setting']['general']['card_currency_code'] = $currency_code; + $setting['payment_paypal_setting']['general']['card_currency_value'] = $currency_value; + } + + $this->model_setting_setting->editSetting('payment_paypal', $setting); + unset($this->session->data['authorization_code']); unset($this->session->data['shared_id']); unset($this->session->data['seller_nonce']); + + if (!$this->error) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } } - if (isset($environment)) { - $data['environment'] = $environment; - } elseif (isset($this->request->post['payment_paypal_environment'])) { - $data['environment'] = $this->request->post['payment_paypal_environment']; - } elseif ($this->config->get('payment_paypal_environment')) { - $data['environment'] = $this->config->get('payment_paypal_environment'); + if (!$this->config->get('payment_paypal_client_id')) { + $this->auth(); } else { - $data['environment'] = 'production'; + $this->dashboard(); + } + } + + public function auth() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['partner_url'] = str_replace('&', '%26', $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + $data['callback_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/callback', 'user_token=' . $this->session->data['user_token'], true)); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + if (isset($this->session->data['environment'])) { + $data['environment'] = $this->session->data['environment']; + } else { + $data['environment'] = 'production'; + } + $data['seller_nonce'] = $this->token(50); $data['configure_url'] = array( 'production' => array( - 'ppcp' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND&product=ppcp&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], - 'express_checkout' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND&product=EXPRESS_CHECKOUT&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] + 'ppcp' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION&product=ppcp&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], + 'express_checkout' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION&product=EXPRESS_CHECKOUT&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] ), 'sandbox' => array( - 'ppcp' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND&product=ppcp&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], - 'express_checkout' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND&product=EXPRESS_CHECKOUT&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] + 'ppcp' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION&product=ppcp&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], + 'express_checkout' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION&product=EXPRESS_CHECKOUT&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] ) ); - $data['help_checkout_express'] = sprintf($this->language->get('help_checkout_express'), $data['configure_url'][$data['environment']]['express_checkout']); + $data['text_checkout_express'] = sprintf($this->language->get('text_checkout_express'), $data['configure_url'][$data['environment']]['express_checkout']); + $data['text_support'] = sprintf($this->language->get('text_support'), $this->request->server['HTTP_HOST']); - if (isset($client_id)) { - $data['client_id'] = $client_id; - } elseif (isset($this->request->post['payment_paypal_client_id'])) { - $data['client_id'] = $this->request->post['payment_paypal_client_id']; - } else { - $data['client_id'] = $this->config->get('payment_paypal_client_id'); - } - - if (isset($secret)) { - $data['secret'] = $secret; - } elseif (isset($this->request->post['payment_paypal_secret'])) { - $data['secret'] = $this->request->post['payment_paypal_secret']; - } else { - $data['secret'] = $this->config->get('payment_paypal_secret'); - } + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - if (isset($merchant_id)) { - $data['merchant_id'] = $merchant_id; - } elseif (isset($this->request->post['payment_paypal_merchant_id'])) { - $data['merchant_id'] = $this->request->post['payment_paypal_merchant_id']; + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { - $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['text_version'] = ''; } - $data['text_connect'] = sprintf($this->language->get('text_connect'), $data['client_id'], $data['secret'], $data['merchant_id']); + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - if (isset($webhook_id)) { - $data['webhook_id'] = $webhook_id; - } elseif (isset($this->request->post['payment_paypal_webhook_id'])) { - $data['webhook_id'] = $this->request->post['payment_paypal_webhook_id']; - } else { - $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); } - - if (isset($this->request->post['payment_paypal_debug'])) { - $data['debug'] = $this->request->post['payment_paypal_debug']; - } else { - $data['debug'] = $this->config->get('payment_paypal_debug'); - } - - if (isset($this->request->post['payment_paypal_transaction_method'])) { - $data['transaction_method'] = $this->request->post['payment_paypal_transaction_method']; + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; } else { - $data['transaction_method'] = $this->config->get('payment_paypal_transaction_method'); + $data['error_warning'] = ''; } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); - if (isset($this->request->post['payment_paypal_total'])) { - $data['total'] = $this->request->post['payment_paypal_total']; - } else { - $data['total'] = $this->config->get('payment_paypal_total'); + $this->response->setOutput($this->load->view('extension/payment/paypal/auth', $data)); + } + + public function dashboard() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); } - $this->load->model('localisation/order_status'); + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + $this->load->model('setting/setting'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); + $this->document->setTitle($this->language->get('heading_title_main')); - if (isset($this->request->post['payment_paypal_geo_zone_id'])) { - $data['geo_zone_id'] = $this->request->post['payment_paypal_geo_zone_id']; - } else { - $data['geo_zone_id'] = $this->config->get('payment_paypal_geo_zone_id'); - } + $data['breadcrumbs'] = array(); - $this->load->model('localisation/geo_zone'); + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); - if (isset($this->request->post['payment_paypal_status'])) { - $data['status'] = $this->request->post['payment_paypal_status']; + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['sale_analytics_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/getSaleAnalytics', 'user_token=' . $this->session->data['user_token'], true)); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + if ($this->config->get('payment_paypal_status') != null) { $data['status'] = $this->config->get('payment_paypal_status'); + } else { + $data['status'] = 1; } - - if (isset($this->request->post['payment_paypal_sort_order'])) { - $data['sort_order'] = $this->request->post['payment_paypal_sort_order']; + + if ($data['setting']['button']['product']['status'] || $data['setting']['button']['cart']['status'] || $data['setting']['button']['checkout']['status']) { + $data['button_status'] = 1; } else { - $data['sort_order'] = $this->config->get('payment_paypal_sort_order'); + $data['button_status'] = 0; } - if (isset($this->request->post['payment_paypal_currency_code'])) { - $data['currency_code'] = $this->request->post['payment_paypal_currency_code']; + if ($data['setting']['applepay_button']['status']) { + $data['applepay_button_status'] = 1; } else { - $data['currency_code'] = $this->config->get('payment_paypal_currency_code'); + $data['applepay_button_status'] = 0; } - if (isset($this->request->post['payment_paypal_currency_value'])) { - $data['currency_value'] = $this->request->post['payment_paypal_currency_value']; - } elseif ($this->config->get('payment_paypal_currency_value')) { - $data['currency_value'] = $this->config->get('payment_paypal_currency_value'); + if ($data['setting']['card']['status']) { + $data['card_status'] = 1; } else { - $data['currency_value'] = '1'; + $data['card_status'] = 0; } - - if (isset($this->request->post['payment_paypal_setting'])) { - $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->request->post['payment_paypal_setting']); + + if ($data['setting']['message']['home']['status'] || $data['setting']['message']['product']['status'] || $data['setting']['message']['cart']['status'] || $data['setting']['message']['checkout']['status']) { + $data['message_status'] = 1; } else { - $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + $data['message_status'] = 0; } - if ($data['client_id'] && $data['secret']) { - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = array( - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'] - ); + $paypal_sale_total = $this->model_extension_payment_paypal->getTotalSales(); - $paypal = new PayPal($paypal_info); - - $token_info = array( - 'grant_type' => 'client_credentials' - ); - - $paypal->setAccessToken($token_info); + $data['paypal_sale_total'] = $this->currency->format($paypal_sale_total, $this->config->get('config_currency')); - $data['client_token'] = $paypal->getClientToken(); - - if ($paypal->hasErrors()) { - $error_messages = array(); - - $errors = $paypal->getErrors(); - - foreach ($errors as $error) { - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { - $error['message'] = $this->language->get('error_timeout'); - } - - if (isset($error['details'][0]['description'])) { - $error_messages[] = $error['details'][0]['description']; - } else { - $error_messages[] = $error['message']; - } - - $this->model_extension_payment_paypal->log($error, $error['message']); - } - - $this->error['warning'] = implode(' ', $error_messages); - } + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; } + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { @@ -309,73 +381,1182 @@ public function index() { $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - $this->response->setOutput($this->load->view('extension/payment/paypal', $data)); + $this->response->setOutput($this->load->view('extension/payment/paypal/dashboard', $data)); } - - public function callback() { - if (isset($this->request->post['environment']) && isset($this->request->post['authorization_code']) && isset($this->request->post['shared_id']) && isset($this->request->post['seller_nonce'])) { - $this->session->data['environment'] = $this->request->post['environment']; - $this->session->data['authorization_code'] = $this->request->post['authorization_code']; - $this->session->data['shared_id'] = $this->request->post['shared_id']; - $this->session->data['seller_nonce'] = $this->request->post['seller_nonce']; - } - - $data['error'] = $this->error; - - $this->response->setOutput(json_encode($data)); - } - public function configureSmartButton() { - $this->load->model('extension/payment/paypal'); - - $this->model_extension_payment_paypal->configureSmartButton(); - - $this->response->redirect($this->url->link('extension/module/paypal_smart_button', 'user_token=' . $this->session->data['user_token'], true)); - } - - protected function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/paypal')) { - $this->error['warning'] = $this->language->get('error_permission'); + public function general() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); } - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( - 'client_id' => $this->request->post['payment_paypal_client_id'], - 'secret' => $this->request->post['payment_paypal_secret'], - 'environment' => $this->request->post['payment_paypal_environment'] - ); + $this->load->language('extension/payment/paypal'); - $paypal = new PayPal($paypal_info); + $this->load->model('extension/payment/paypal'); - $token_info = array( - 'grant_type' => 'client_credentials' - ); - - $paypal->setAccessToken($token_info); - - if ($paypal->hasErrors()) { - $error_messages = array(); - - $errors = $paypal->getErrors(); + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['disconnect_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/disconnect', 'user_token=' . $this->session->data['user_token'], true)); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + if ($this->config->get('payment_paypal_status') != null) { + $data['status'] = $this->config->get('payment_paypal_status'); + } else { + $data['status'] = 1; + } + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + + $data['text_connect'] = sprintf($this->language->get('text_connect'), $data['client_id'], $data['secret'], $data['merchant_id'], $data['webhook_id'], $data['environment']); + + $data['total'] = $this->config->get('payment_paypal_total'); + $data['geo_zone_id'] = $this->config->get('payment_paypal_geo_zone_id'); + $data['sort_order'] = $this->config->get('payment_paypal_sort_order'); + + $this->load->model('localisation/geo_zone'); + + $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); + + $this->load->model('localisation/country'); + + $data['countries'] = $this->model_localisation_country->getCountries(); + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/general', $data)); + } + + public function button() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/paypal.js'); + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; + + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); + + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; + + $data['currency_code'] = $data['setting']['general']['currency_code']; + $data['currency_value'] = $data['setting']['general']['currency_value']; + + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; + + if ($data['client_id'] && $data['secret']) { + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + } + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/button', $data)); + } + + public function applepay_button() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/paypal.js'); + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); + $this->document->addScript('https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['applepay_download_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/downloadAssociationFile', 'user_token=' . $this->session->data['user_token'], true)); + $data['applepay_download_host_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/downloadHostAssociationFile', 'user_token=' . $this->session->data['user_token'], true)); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; + + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); + + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; + + $data['currency_code'] = $data['setting']['general']['currency_code']; + $data['currency_value'] = $data['setting']['general']['currency_value']; + + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; + + if ($data['client_id'] && $data['secret']) { + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); - foreach ($errors as $error) { - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { - $error['message'] = $this->language->get('error_timeout'); + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + } + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/applepay_button', $data)); + } + + public function card() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/card.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/paypal.js'); + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; + + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); + + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; + + $data['currency_code'] = $data['setting']['general']['currency_code']; + $data['currency_value'] = $data['setting']['general']['currency_value']; + + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; + + if ($data['client_id'] && $data['secret']) { + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + } + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/card', $data)); + } + + public function message() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); + + $this->document->addScript('view/javascript/paypal/paypal.js'); + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['webhook_id'] = $this->config->get('payment_paypal_webhook_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; + + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); + + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; + + $data['currency_code'] = $data['setting']['general']['currency_code']; + $data['currency_value'] = $data['setting']['general']['currency_value']; + + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; + + if ($country['iso_code_2'] == 'GB') { + $data['text_message_alert'] = $this->language->get('text_message_alert_uk'); + $data['text_message_footnote'] = $this->language->get('text_message_footnote_uk'); + } elseif ($country['iso_code_2'] == 'US') { + $data['text_message_alert'] = $this->language->get('text_message_alert_us'); + $data['text_message_footnote'] = $this->language->get('text_message_footnote_us'); + } + + if ($data['client_id'] && $data['secret']) { + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + } + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/message', $data)); + } + + public function order_status() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $this->load->model('localisation/order_status'); + + $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/order_status', $data)); + } + + public function contact() { + if (!$this->config->get('payment_paypal_client_id')) { + $this->response->redirect($this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); + } + + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); + + $this->document->setTitle($this->language->get('heading_title_main')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_extensions'), + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('heading_title_main'), + 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) + ); + + // Action + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); + $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); + $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_applepay_button'] = $this->url->link('extension/payment/paypal/applepay_button', 'user_token=' . $this->session->data['user_token'], true); + $data['href_card'] = $this->url->link('extension/payment/paypal/card', 'user_token=' . $this->session->data['user_token'], true); + $data['href_message'] = $this->url->link('extension/payment/paypal/message', 'user_token=' . $this->session->data['user_token'], true); + $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'user_token=' . $this->session->data['user_token'], true); + $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'user_token=' . $this->session->data['user_token'], true); + + $data['action'] = $this->url->link('extension/payment/paypal/save', 'user_token=' . $this->session->data['user_token'], true); + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); + $data['contact_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/sendContact', 'user_token=' . $this->session->data['user_token'], true)); + $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'user_token=' . $this->session->data['user_token'], true)); + + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { + $data['server'] = HTTPS_SERVER; + $data['catalog'] = HTTPS_CATALOG; + } else { + $data['server'] = HTTP_SERVER; + $data['catalog'] = HTTP_CATALOG; + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $data['setting'] = $_config->get('paypal_setting'); + + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('payment_paypal_setting')); + + $this->load->model('localisation/country'); + + $data['countries'] = $this->model_localisation_country->getCountries(); + + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); + + if (!empty($result['href'])) { + $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); + } else { + $data['text_version'] = ''; + } + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if (!$agree_status) { + $this->error['warning'] = $this->language->get('error_agree'); + } + + if (isset($this->error['warning'])) { + $data['error_warning'] = $this->error['warning']; + } else { + $data['error_warning'] = ''; + } + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/contact', $data)); + } + + public function save() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('setting/setting'); + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { + $setting = $this->model_setting_setting->getSetting('payment_paypal'); + + $setting = array_replace_recursive($setting, $this->request->post); + + $this->model_setting_setting->editSetting('payment_paypal', $setting); + + $data['success'] = $this->language->get('success_save'); + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function disconnect() { + $this->load->model('setting/setting'); + + $setting = $this->model_setting_setting->getSetting('payment_paypal'); + + $setting['payment_paypal_client_id'] = ''; + $setting['payment_paypal_secret'] = ''; + $setting['payment_paypal_merchant_id'] = ''; + $setting['payment_paypal_webhook_id'] = ''; + + $this->model_setting_setting->editSetting('payment_paypal', $setting); + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function callback() { + if (isset($this->request->post['environment']) && isset($this->request->post['authorization_code']) && isset($this->request->post['shared_id']) && isset($this->request->post['seller_nonce'])) { + $this->session->data['environment'] = $this->request->post['environment']; + $this->session->data['authorization_code'] = $this->request->post['authorization_code']; + $this->session->data['shared_id'] = $this->request->post['shared_id']; + $this->session->data['seller_nonce'] = $this->request->post['seller_nonce']; + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function getSaleAnalytics() { + $this->load->language('extension/payment/paypal'); + + $data = array(); + + $this->load->model('extension/payment/paypal'); + + $data['all_sale'] = array(); + $data['paypal_sale'] = array(); + $data['xaxis'] = array(); + + $data['all_sale']['label'] = $this->language->get('text_all_sales'); + $data['paypal_sale']['label'] = $this->language->get('text_paypal_sales'); + $data['all_sale']['data'] = array(); + $data['paypal_sale']['data'] = array(); + + if (isset($this->request->get['range'])) { + $range = $this->request->get['range']; + } else { + $range = 'day'; + } + + switch ($range) { + default: + case 'day': + $results = $this->model_extension_payment_paypal->getTotalSalesByDay(); + + foreach ($results as $key => $value) { + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + } + + for ($i = 0; $i < 24; $i++) { + $data['xaxis'][] = array($i, $i); } - if (isset($error['details'][0]['description'])) { - $error_messages[] = $error['details'][0]['description']; - } else { - $error_messages[] = $error['message']; + break; + case 'week': + $results = $this->model_extension_payment_paypal->getTotalSalesByWeek(); + + foreach ($results as $key => $value) { + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); } - - $this->model_extension_payment_paypal->log($error, $error['message']); + + $date_start = strtotime('-' . date('w') . ' days'); + + for ($i = 0; $i < 7; $i++) { + $date = date('Y-m-d', $date_start + ($i * 86400)); + + $data['xaxis'][] = array(date('w', strtotime($date)), date('D', strtotime($date))); + } + + break; + case 'month': + $results = $this->model_extension_payment_paypal->getTotalSalesByMonth(); + + foreach ($results as $key => $value) { + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + } + + for ($i = 1; $i <= date('t'); $i++) { + $date = date('Y') . '-' . date('m') . '-' . $i; + + $data['xaxis'][] = array(date('j', strtotime($date)), date('d', strtotime($date))); + } + + break; + case 'year': + $results = $this->model_extension_payment_paypal->getTotalSalesByYear(); + + foreach ($results as $key => $value) { + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + } + + for ($i = 1; $i <= 12; $i++) { + $data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i))); + } + + break; + } + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function downloadAssociationFile() { + $environment = $this->config->get('payment_paypal_environment'); + + if ($environment == 'production') { + $file = 'https://www.paypalobjects.com/.well-known/apple-developer-merchantid-domain-association'; + + $file_headers = @get_headers($file); + + if (strpos($file_headers[0], '404') !== false) { + $file = 'https://www.paypalobjects.com/.well-known/apple-developer-merchantid-domain-association.txt'; + } + } else { + $file = 'https://www.paypalobjects.com/sandbox/apple-developer-merchantid-domain-association'; + } + + header('Content-Description: File Transfer'); + header('Content-Type: text/plain'); + header('Content-Disposition: attachment; filename="' . basename($file, '.txt') . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + + readfile($file); + } + + public function downloadHostAssociationFile() { + $this->load->language('extension/payment/paypal'); + + $environment = $this->config->get('payment_paypal_environment'); + + if ($environment == 'production') { + $file = 'https://www.paypalobjects.com/.well-known/apple-developer-merchantid-domain-association'; + + $file_headers = @get_headers($file); + + if (strpos($file_headers[0], '404') !== false) { + $file = 'https://www.paypalobjects.com/.well-known/apple-developer-merchantid-domain-association.txt'; + } + } else { + $file = 'https://www.paypalobjects.com/sandbox/apple-developer-merchantid-domain-association'; + } + + $content = file_get_contents($file); + + if ($content) { + $dir = str_replace('admin/', '.well-known/', DIR_APPLICATION); + + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } + + if (file_exists($dir)) { + $fh = fopen($dir . basename($file, '.txt'), 'w'); + fwrite($fh, $content); + fclose($fh); } + + $data['success'] = $this->language->get('success_download_host'); + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } - $this->error['warning'] = implode(' ', $error_messages); + public function sendContact() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + if (isset($this->request->post['payment_paypal_setting']['contact'])) { + $this->model_extension_payment_paypal->sendContact($this->request->post['payment_paypal_setting']['contact']); + + $data['success'] = $this->language->get('success_send'); } + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function agree() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + $this->model_extension_payment_paypal->setAgreeStatus(); + + $data['success'] = $this->language->get('success_agree'); + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function install() { + $this->load->model('setting/event'); + + $this->model_setting_event->deleteEventByCode('paypal_header'); + $this->model_setting_event->deleteEventByCode('paypal_extension_get_extensions'); + + $this->model_setting_event->addEvent('paypal_header', 'catalog/controller/common/header/before', 'extension/payment/paypal/header_before'); + $this->model_setting_event->addEvent('paypal_extension_get_extensions', 'catalog/model/setting/extension/getExtensions/after', 'extension/payment/paypal/extension_get_extensions_after'); + } + + public function uninstall() { + $this->load->model('setting/event'); + + $this->model_setting_event->deleteEventByCode('paypal_header'); + $this->model_setting_event->deleteEventByCode('paypal_extension_get_extensions'); + } + + private function validate() { + if (!$this->user->hasPermission('modify', 'extension/payment/paypal')) { + $this->error['warning'] = $this->language->get('error_permission'); + } + return !$this->error; } diff --git a/upload/admin/controller/extension/payment/pp_braintree.php b/upload/admin/controller/extension/payment/pp_braintree.php deleted file mode 100644 index 825d7d29fe2..00000000000 --- a/upload/admin/controller/extension/payment/pp_braintree.php +++ /dev/null @@ -1,1132 +0,0 @@ -load->language('extension/payment/pp_braintree'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - foreach ($this->request->post['payment_pp_braintree_account'] as $currency => $account) { - if (!isset($account['status'])) { - $this->request->post['payment_pp_braintree_account'][$currency]['status'] = 0; - } - } - - $this->model_setting_setting->editSetting('payment_pp_braintree', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - $data['button_configure'] = $this->url->link('extension/module/pp_braintree_button/configure', 'user_token=' . $this->session->data['user_token'], true); - - $data['user_token'] = $this->session->data['user_token']; - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - $this->load->model('localisation/currency'); - - $data['currencies'] = $this->model_localisation_currency->getCurrencies(); - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['account'])) { - $data['error_account'] = $this->error['account']; - } else { - $data['error_account'] = array(); - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['action'] = $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_braintree_merchant_id'])) { - $data['payment_pp_braintree_merchant_id'] = $this->request->post['payment_pp_braintree_merchant_id']; - } else { - $data['payment_pp_braintree_merchant_id'] = $this->config->get('payment_pp_braintree_merchant_id'); - } - - if (isset($this->request->post['payment_pp_braintree_public_key'])) { - $data['payment_pp_braintree_public_key'] = $this->request->post['payment_pp_braintree_public_key']; - } else { - $data['payment_pp_braintree_public_key'] = $this->config->get('payment_pp_braintree_public_key'); - } - - if (isset($this->request->post['payment_pp_braintree_private_key'])) { - $data['payment_pp_braintree_private_key'] = $this->request->post['payment_pp_braintree_private_key']; - } else { - $data['payment_pp_braintree_private_key'] = $this->config->get('payment_pp_braintree_private_key'); - } - - if (isset($this->request->post['payment_pp_braintree_access_token'])) { - $data['payment_pp_braintree_access_token'] = $this->request->post['payment_pp_braintree_access_token']; - } else { - $data['payment_pp_braintree_access_token'] = $this->config->get('payment_pp_braintree_access_token'); - } - - if (isset($this->request->post['payment_pp_braintree_refresh_token'])) { - $data['payment_pp_braintree_refresh_token'] = $this->request->post['payment_pp_braintree_refresh_token']; - } else { - $data['payment_pp_braintree_refresh_token'] = $this->config->get('payment_pp_braintree_refresh_token'); - } - - if (isset($this->request->post['payment_pp_braintree_environment'])) { - $data['payment_pp_braintree_environment'] = $this->request->post['payment_pp_braintree_environment']; - } else { - $data['payment_pp_braintree_environment'] = $this->config->get('payment_pp_braintree_environment'); - } - - if (isset($this->request->post['payment_pp_braintree_settlement_immediate'])) { - $data['payment_pp_braintree_settlement_immediate'] = $this->request->post['payment_pp_braintree_settlement_immediate']; - } else { - $data['payment_pp_braintree_settlement_immediate'] = $this->config->get('payment_pp_braintree_settlement_immediate'); - } - - if (isset($this->request->post['payment_pp_braintree_card_vault'])) { - $data['payment_pp_braintree_card_vault'] = $this->request->post['payment_pp_braintree_card_vault']; - } else { - $data['payment_pp_braintree_card_vault'] = $this->config->get('payment_pp_braintree_card_vault'); - } - - if (isset($this->request->post['payment_pp_braintree_card_check_vault'])) { - $data['payment_pp_braintree_card_check_vault'] = $this->request->post['payment_pp_braintree_card_check_vault']; - } else { - $data['payment_pp_braintree_card_check_vault'] = $this->config->get('payment_pp_braintree_card_check_vault'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_vault'])) { - $data['payment_pp_braintree_paypal_vault'] = $this->request->post['payment_pp_braintree_paypal_vault']; - } else { - $data['payment_pp_braintree_paypal_vault'] = $this->config->get('payment_pp_braintree_paypal_vault'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_check_vault'])) { - $data['payment_pp_braintree_paypal_check_vault'] = $this->request->post['payment_pp_braintree_paypal_check_vault']; - } else { - $data['payment_pp_braintree_paypal_check_vault'] = $this->config->get('payment_pp_braintree_paypal_check_vault'); - } - - if (isset($this->request->post['payment_pp_braintree_vault_cvv_3ds'])) { - $data['payment_pp_braintree_vault_cvv_3ds'] = $this->request->post['payment_pp_braintree_vault_cvv_3ds']; - } else { - $data['payment_pp_braintree_vault_cvv_3ds'] = $this->config->get('payment_pp_braintree_vault_cvv_3ds'); - } - - if (isset($this->request->post['payment_pp_braintree_debug'])) { - $data['payment_pp_braintree_debug'] = $this->request->post['payment_pp_braintree_debug']; - } else { - $data['payment_pp_braintree_debug'] = $this->config->get('payment_pp_braintree_debug'); - } - - if (isset($this->request->post['payment_pp_braintree_total'])) { - $data['payment_pp_braintree_total'] = $this->request->post['payment_pp_braintree_total']; - } else { - $data['payment_pp_braintree_total'] = $this->config->get('payment_pp_braintree_total'); - } - - if (isset($this->request->post['payment_pp_braintree_geo_zone_id'])) { - $data['payment_pp_braintree_geo_zone_id'] = $this->request->post['payment_pp_braintree_geo_zone_id']; - } else { - $data['payment_pp_braintree_geo_zone_id'] = $this->config->get('payment_pp_braintree_geo_zone_id'); - } - - if (isset($this->request->post['payment_pp_braintree_status'])) { - $data['payment_pp_braintree_status'] = $this->request->post['payment_pp_braintree_status']; - } else { - $data['payment_pp_braintree_status'] = $this->config->get('payment_pp_braintree_status'); - } - - if (isset($this->request->post['payment_pp_braintree_sort_order'])) { - $data['payment_pp_braintree_sort_order'] = $this->request->post['payment_pp_braintree_sort_order']; - } else { - $data['payment_pp_braintree_sort_order'] = $this->config->get('payment_pp_braintree_sort_order'); - } - - if (isset($this->request->post['payment_pp_braintree_account'])) { - $data['payment_pp_braintree_account'] = $this->request->post['payment_pp_braintree_account']; - } else { - $data['payment_pp_braintree_account'] = $this->config->get('payment_pp_braintree_account'); - } - - if (isset($this->request->post['payment_pp_braintree_authorization_expired_id'])) { - $data['payment_pp_braintree_authorization_expired_id'] = $this->request->post['payment_pp_braintree_authorization_expired_id']; - } else { - $data['payment_pp_braintree_authorization_expired_id'] = $this->config->get('payment_pp_braintree_authorization_expired_id'); - } - - if (isset($this->request->post['payment_pp_braintree_authorized_id'])) { - $data['payment_pp_braintree_authorized_id'] = $this->request->post['payment_pp_braintree_authorized_id']; - } else { - $data['payment_pp_braintree_authorized_id'] = $this->config->get('payment_pp_braintree_authorized_id'); - } - - if (isset($this->request->post['payment_pp_braintree_authorizing_id'])) { - $data['payment_pp_braintree_authorizing_id'] = $this->request->post['payment_pp_braintree_authorizing_id']; - } else { - $data['payment_pp_braintree_authorizing_id'] = $this->config->get('payment_pp_braintree_authorizing_id'); - } - - if (isset($this->request->post['payment_pp_braintree_settlement_pending_id'])) { - $data['payment_pp_braintree_settlement_pending_id'] = $this->request->post['payment_pp_braintree_settlement_pending_id']; - } else { - $data['payment_pp_braintree_settlement_pending_id'] = $this->config->get('payment_pp_braintree_settlement_pending_id'); - } - - if (isset($this->request->post['payment_pp_braintree_failed_id'])) { - $data['payment_pp_braintree_failed_id'] = $this->request->post['payment_pp_braintree_failed_id']; - } else { - $data['payment_pp_braintree_failed_id'] = $this->config->get('payment_pp_braintree_failed_id'); - } - - if (isset($this->request->post['payment_pp_braintree_gateway_rejected_id'])) { - $data['payment_pp_braintree_gateway_rejected_id'] = $this->request->post['payment_pp_braintree_gateway_rejected_id']; - } else { - $data['payment_pp_braintree_gateway_rejected_id'] = $this->config->get('payment_pp_braintree_gateway_rejected_id'); - } - - if (isset($this->request->post['payment_pp_braintree_processor_declined_id'])) { - $data['payment_pp_braintree_processor_declined_id'] = $this->request->post['payment_pp_braintree_processor_declined_id']; - } else { - $data['payment_pp_braintree_processor_declined_id'] = $this->config->get('payment_pp_braintree_processor_declined_id'); - } - - if (isset($this->request->post['payment_pp_braintree_settled_id'])) { - $data['payment_pp_braintree_settled_id'] = $this->request->post['payment_pp_braintree_settled_id']; - } else { - $data['payment_pp_braintree_settled_id'] = $this->config->get('payment_pp_braintree_settled_id'); - } - - if (isset($this->request->post['payment_pp_braintree_settling_id'])) { - $data['payment_pp_braintree_settling_id'] = $this->request->post['payment_pp_braintree_settling_id']; - } else { - $data['payment_pp_braintree_settling_id'] = $this->config->get('payment_pp_braintree_settling_id'); - } - - if (isset($this->request->post['payment_pp_braintree_submitted_for_settlement_id'])) { - $data['payment_pp_braintree_submitted_for_settlement_id'] = $this->request->post['payment_pp_braintree_submitted_for_settlement_id']; - } else { - $data['payment_pp_braintree_submitted_for_settlement_id'] = $this->config->get('payment_pp_braintree_submitted_for_settlement_id'); - } - - if (isset($this->request->post['payment_pp_braintree_voided_id'])) { - $data['payment_pp_braintree_voided_id'] = $this->request->post['payment_pp_braintree_voided_id']; - } else { - $data['payment_pp_braintree_voided_id'] = $this->config->get('payment_pp_braintree_voided_id'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_status'])) { - $data['payment_pp_braintree_3ds_status'] = $this->request->post['payment_pp_braintree_3ds_status']; - } else { - $data['payment_pp_braintree_3ds_status'] = $this->config->get('payment_pp_braintree_3ds_status'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_unsupported_card'])) { - $data['payment_pp_braintree_3ds_unsupported_card'] = $this->request->post['payment_pp_braintree_3ds_unsupported_card']; - } else { - $data['payment_pp_braintree_3ds_unsupported_card'] = $this->config->get('payment_pp_braintree_3ds_unsupported_card'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_lookup_error'])) { - $data['payment_pp_braintree_3ds_lookup_error'] = $this->request->post['payment_pp_braintree_3ds_lookup_error']; - } else { - $data['payment_pp_braintree_3ds_lookup_error'] = $this->config->get('payment_pp_braintree_3ds_lookup_error'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_lookup_enrolled'])) { - $data['payment_pp_braintree_3ds_lookup_enrolled'] = $this->request->post['payment_pp_braintree_3ds_lookup_enrolled']; - } else { - $data['payment_pp_braintree_3ds_lookup_enrolled'] = $this->config->get('payment_pp_braintree_3ds_lookup_enrolled'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_lookup_not_enrolled'])) { - $data['payment_pp_braintree_3ds_lookup_not_enrolled'] = $this->request->post['payment_pp_braintree_3ds_lookup_not_enrolled']; - } else { - $data['payment_pp_braintree_3ds_lookup_not_enrolled'] = $this->config->get('payment_pp_braintree_3ds_lookup_not_enrolled'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_not_participating'])) { - $data['payment_pp_braintree_3ds_not_participating'] = $this->request->post['payment_pp_braintree_3ds_not_participating']; - } else { - $data['payment_pp_braintree_3ds_not_participating'] = $this->config->get('payment_pp_braintree_3ds_not_participating'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_unavailable'])) { - $data['payment_pp_braintree_3ds_unavailable'] = $this->request->post['payment_pp_braintree_3ds_unavailable']; - } else { - $data['payment_pp_braintree_3ds_unavailable'] = $this->config->get('payment_pp_braintree_3ds_unavailable'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_signature_failed'])) { - $data['payment_pp_braintree_3ds_signature_failed'] = $this->request->post['payment_pp_braintree_3ds_signature_failed']; - } else { - $data['payment_pp_braintree_3ds_signature_failed'] = $this->config->get('payment_pp_braintree_3ds_signature_failed'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_successful'])) { - $data['payment_pp_braintree_3ds_successful'] = $this->request->post['payment_pp_braintree_3ds_successful']; - } else { - $data['payment_pp_braintree_3ds_successful'] = $this->config->get('payment_pp_braintree_3ds_successful'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_attempt_successful'])) { - $data['payment_pp_braintree_3ds_attempt_successful'] = $this->request->post['payment_pp_braintree_3ds_attempt_successful']; - } else { - $data['payment_pp_braintree_3ds_attempt_successful'] = $this->config->get('payment_pp_braintree_3ds_attempt_successful'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_failed'])) { - $data['payment_pp_braintree_3ds_failed'] = $this->request->post['payment_pp_braintree_3ds_failed']; - } else { - $data['payment_pp_braintree_3ds_failed'] = $this->config->get('payment_pp_braintree_3ds_failed'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_unable_to_auth'])) { - $data['payment_pp_braintree_3ds_unable_to_auth'] = $this->request->post['payment_pp_braintree_3ds_unable_to_auth']; - } else { - $data['payment_pp_braintree_3ds_unable_to_auth'] = $this->config->get('payment_pp_braintree_3ds_unable_to_auth'); - } - - if (isset($this->request->post['payment_pp_braintree_3ds_error'])) { - $data['payment_pp_braintree_3ds_error'] = $this->request->post['payment_pp_braintree_3ds_error']; - } else { - $data['payment_pp_braintree_3ds_error'] = $this->config->get('payment_pp_braintree_3ds_error'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_option'])) { - $data['payment_pp_braintree_paypal_option'] = $this->request->post['payment_pp_braintree_paypal_option']; - } else { - $data['payment_pp_braintree_paypal_option'] = $this->config->get('payment_pp_braintree_paypal_option'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_button_colour'])) { - $data['payment_pp_braintree_paypal_button_colour'] = $this->request->post['payment_pp_braintree_paypal_button_colour']; - } else { - $data['payment_pp_braintree_paypal_button_colour'] = $this->config->get('payment_pp_braintree_paypal_button_colour'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_button_size'])) { - $data['payment_pp_braintree_paypal_button_size'] = $this->request->post['payment_pp_braintree_paypal_button_size']; - } else { - $data['payment_pp_braintree_paypal_button_size'] = $this->config->get('payment_pp_braintree_paypal_button_size'); - } - - if (isset($this->request->post['payment_pp_braintree_paypal_button_shape'])) { - $data['payment_pp_braintree_paypal_button_shape'] = $this->request->post['payment_pp_braintree_paypal_button_shape']; - } else { - $data['payment_pp_braintree_paypal_button_shape'] = $this->config->get('payment_pp_braintree_paypal_button_shape'); - } - - if (isset($this->request->post['payment_pp_braintree_billing_agreement'])) { - $data['payment_pp_braintree_billing_agreement'] = $this->request->post['payment_pp_braintree_billing_agreement']; - } else { - $data['payment_pp_braintree_billing_agreement'] = $this->config->get('payment_pp_braintree_billing_agreement'); - } - - $data['transaction_statuses'] = array( - 'authorization_expired', - 'authorized', - 'authorizing', - 'settlement_pending', - 'failed', - 'gateway_rejected', - 'processor_declined', - 'settled', - 'settling', - 'submitted_for_settlement', - 'voided' - ); - - $data['card_types'] = array( - 'Visa', - 'MasterCard', - 'American Express', - 'Discover', - 'JCB', - 'Maestro' - ); - - if (isset($this->request->get['retrieve_code'])) { - $data['retrieve_code'] = $this->request->get['retrieve_code']; - - $curl = curl_init($this->opencart_retrieve_url); - - $post_data = array( - 'return_url' => $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true), - 'retrieve_code' => $this->request->get['retrieve_code'], - 'store_version' => VERSION, - ); - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); - - $curl_response = curl_exec($curl); - $config_response = json_decode($curl_response, true); - curl_close($curl); - - if (isset($config_response['merchant_id']) && isset($config_response['access_token']) && isset($config_response['refresh_token'])) { - $braintree_settings = $this->model_setting_setting->getSetting('payment_pp_braintree'); - $braintree_settings['payment_pp_braintree_merchant_id'] = $config_response['merchant_id']; - $braintree_settings['payment_pp_braintree_access_token'] = $config_response['access_token']; - $braintree_settings['payment_pp_braintree_refresh_token'] = $config_response['refresh_token']; - $braintree_settings['payment_pp_braintree_environment'] = $config_response['environment']; - $braintree_settings['payment_pp_braintree_public_key'] = ''; - $braintree_settings['payment_pp_braintree_private_key'] = ''; - - $this->model_setting_setting->editSetting('payment_pp_braintree', $braintree_settings); - - $data['payment_pp_braintree_merchant_id'] = $config_response['merchant_id']; - $data['payment_pp_braintree_access_token'] = $config_response['access_token']; - $data['payment_pp_braintree_refresh_token'] = $config_response['refresh_token']; - $data['payment_pp_braintree_environment'] = $config_response['environment']; - $data['payment_pp_braintree_public_key'] = ''; - $data['payment_pp_braintree_private_key'] = ''; - - $data['success'] = $this->language->get('text_success_connect'); - } - } - - $data['auth_connect_url'] = ''; - - // If Braintree is not setup yet, request auth token for merchant on-boarding flow - if ($data['payment_pp_braintree_merchant_id'] == '') { - $curl = curl_init($this->opencart_connect_url); - - $this->load->model('localisation/country'); - $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - - $post_data = array( - 'return_url' => $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true), - 'store_url' => HTTPS_CATALOG, - 'store_version' => VERSION, - 'store_country' => (isset($country['iso_code_3']) ? $country['iso_code_3'] : ''), - ); - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); - - $curl_response = curl_exec($curl); - - $curl_response = json_decode($curl_response, true); - - curl_close($curl); - - if (isset($curl_response['url']) ? $curl_response['url'] : '') { - $data['auth_connect_url'] = $curl_response['url']; - } - } - - $data['braintree_config'] = array(); - $data['braintree_config']['three_d_secure_enabled'] = 0; - $data['braintree_config']['paypal_enabled'] = 0; - - $data['error_braintree_account_3ds'] = $this->language->get('error_braintree_account_3ds'); - $data['error_braintree_account_paypal'] = $this->language->get('error_braintree_account_paypal'); - - // load the account info from braintree if the config has been added yet. - if (!empty($data['payment_pp_braintree_access_token']) || (!empty($data['payment_pp_braintree_environment']) && !empty($data['payment_pp_braintree_merchant_id']) && !empty($data['payment_pp_braintree_public_key']) && !empty($data['payment_pp_braintree_private_key']))) { - $this->initialise($data['payment_pp_braintree_access_token'], array( - 'payment_pp_braintree_environment' => $data['payment_pp_braintree_environment'], - 'payment_pp_braintree_merchant_id' => $data['payment_pp_braintree_merchant_id'], - 'payment_pp_braintree_public_key' => $data['payment_pp_braintree_public_key'], - 'payment_pp_braintree_private_key' => $data['payment_pp_braintree_private_key'], - )); - - $verify_credentials = $this->model_extension_payment_pp_braintree->verifyCredentials($this->gateway); - - if (!$verify_credentials) { - $this->error['warning'] = $this->language->get('error_connection'); - } else { - $merchant_config = json_decode(base64_decode($verify_credentials), true); - - if (isset($merchant_config['threeDSecureEnabled']) && $merchant_config['threeDSecureEnabled'] == 1) { - $data['braintree_config']['three_d_secure_enabled'] = 1; - } - - if (isset($merchant_config['paypalEnabled']) && $merchant_config['paypalEnabled'] == 1) { - $data['braintree_config']['paypal_enabled'] = 1; - } - } - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_braintree', $data)); - } - - public function install() { - $this->load->model('setting/setting'); - - $defaults = array(); - - // 3D secure defaults - $defaults['payment_pp_braintree_3ds_unsupported_card'] = 1; - $defaults['payment_pp_braintree_3ds_lookup_error'] = 1; - $defaults['payment_pp_braintree_3ds_lookup_enrolled'] = 1; - $defaults['payment_pp_braintree_3ds_lookup_not_enrolled'] = 1; - $defaults['payment_pp_braintree_3ds_not_participating'] = 1; - $defaults['payment_pp_braintree_3ds_unavailable'] = 1; - $defaults['payment_pp_braintree_3ds_signature_failed'] = 0; - $defaults['payment_pp_braintree_3ds_successful'] = 1; - $defaults['payment_pp_braintree_3ds_attempt_successful'] = 1; - $defaults['payment_pp_braintree_3ds_failed'] = 0; - $defaults['payment_pp_braintree_3ds_unable_to_auth'] = 1; - $defaults['payment_pp_braintree_3ds_error'] = 1; - - // Order Status defaults - $defaults['payment_pp_braintree_authorization_expired_id'] = 14; - $defaults['payment_pp_braintree_authorized_id'] = 2; - $defaults['payment_pp_braintree_authorizing_id'] = 1; - $defaults['payment_pp_braintree_failed_id'] = 10; - $defaults['payment_pp_braintree_gateway_rejected_id'] = 8; - $defaults['payment_pp_braintree_processor_declined_id'] = 8; - $defaults['payment_pp_braintree_settled_id'] = 2; - $defaults['payment_pp_braintree_settling_id'] = 2; - $defaults['payment_pp_braintree_settlement_pending_id'] = 2; - $defaults['payment_pp_braintree_submitted_for_settlement_id'] = 2; - $defaults['payment_pp_braintree_voided_id'] = 16; - - $defaults['payment_pp_braintree_settlement_immediate'] = 1; - - // PayPal options - $defaults['payment_pp_braintree_paypal_option'] = 1; - $defaults['payment_pp_braintree_paypal_button_size'] = 'small'; - $defaults['payment_pp_braintree_paypal_button_shape'] = 'rect'; - - // Vault options - $defaults['payment_pp_braintree_card_vault'] = 1; - $defaults['payment_pp_braintree_paypal_vault'] = 0; - $defaults['payment_pp_braintree_card_check_vault'] = 1; - $defaults['payment_pp_braintree_paypal_check_vault'] = 0; - - $this->model_setting_setting->editSetting('payment_pp_braintree', $defaults); - } - - public function order() { - $this->load->language('extension/payment/pp_braintree'); - - $data['user_token'] = $this->session->data['user_token']; - - $data['order_id'] = (int)$this->request->get['order_id']; - - return $this->load->view('extension/payment/pp_braintree_order', $data); - } - - public function getTransaction() { - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('extension/payment/pp_braintree'); - $this->load->model('sale/order'); - - if (!$this->config->get('payment_pp_braintree_status') || (!isset($this->request->get['order_id']) && !isset($this->request->get['transaction_id']))) { - return; - } - - $this->initialise($this->config->get('payment_pp_braintree_access_token'), array( - 'payment_pp_braintree_environment' => $this->config->get('payment_pp_braintree_environment'), - 'payment_pp_braintree_merchant_id' => $this->config->get('payment_pp_braintree_merchant_id'), - 'payment_pp_braintree_public_key' => $this->config->get('payment_pp_braintree_public_key'), - 'payment_pp_braintree_private_key' => $this->config->get('payment_pp_braintree_private_key') - )); - - if (isset($this->request->get['order_id'])) { - $search = array( - Braintree_TransactionSearch::orderId()->is($this->request->get['order_id']) - ); - } elseif (isset($this->request->get['transaction_id'])) { - $search = array( - Braintree_TransactionSearch::id()->is($this->request->get['transaction_id']) - ); - } - - $search_transactions = $this->model_extension_payment_pp_braintree->getTransactions($this->gateway, $search); - - $transaction = array(); - - foreach ($search_transactions as $search_transaction) { - $transaction = $search_transaction; - } - - $data['transaction'] = array(); - - if ($transaction) { - $data['transaction_id'] = $transaction->id; - - $data['user_token'] = $this->session->data['user_token']; - - $data['void_action'] = $data['settle_action'] = $data['refund_action'] = false; - - switch ($transaction->status) { - case 'authorized': - $data['void_action'] = true; - $data['settle_action'] = true; - break; - case 'submitted_for_settlement': - $data['void_action'] = true; - break; - case 'settling': - $data['refund_action'] = true; - break; - case 'settled': - $data['refund_action'] = true; - break; - } - - $statuses = array(); - - foreach ($transaction->statusHistory as $status_history) { - $created_at = $status_history->timestamp; - - $statuses[] = array( - 'status' => $status_history->status, - 'date_added' => date($this->language->get('datetime_format'), strtotime($created_at->format('Y-m-d H:i:s e'))) - ); - } - - $data['statuses'] = $statuses; - - $max_settle_amount = $transaction->amount; - - $max_refund_amount = $transaction->amount; - - $data['refunds'] = array(); - - foreach (array_reverse($transaction->refundIds) as $refund_id) { - $refund = $this->model_extension_payment_pp_braintree->getTransaction($this->gateway, $refund_id); - - $successful_statuses = array( - 'authorized', - 'authorizing', - 'settlement_pending', - 'settlement_confirmed', - 'settled', - 'settling', - 'submitted_for_settlement' - ); - - if (in_array($refund->status, $successful_statuses)) { - $max_refund_amount -= $refund->amount; - } - - $created_at = $refund->createdAt; - - $data['refunds'][] = array( - 'date_added' => date($this->language->get('datetime_format'), strtotime($created_at->format('Y-m-d H:i:s e'))), - 'amount' => $this->currency->format($refund->amount, $refund->currencyIsoCode, '1.00000000', true), - 'status' => $refund->status - ); - } - - //If nothing left to refund, disable refund action - if (!$max_refund_amount) { - $data['refund_action'] = false; - } - - $data['max_settle_amount'] = $this->currency->format($max_settle_amount, $transaction->currencyIsoCode, '1.00000000', false); - - $data['max_refund_amount'] = $this->currency->format($max_refund_amount, $transaction->currencyIsoCode, '1.00000000', false); - - $amount = $this->currency->format($transaction->amount, $transaction->currencyIsoCode, '1.00000000', true); - - $data['symbol_left'] = $this->currency->getSymbolLeft($transaction->currencyIsoCode); - $data['symbol_right'] = $this->currency->getSymbolRight($transaction->currencyIsoCode); - - $created_at = $transaction->createdAt; - - if ($transaction->threeDSecureInfo) { - if ($transaction->threeDSecureInfo->liabilityShifted) { - $liability_shifted = $this->language->get('text_yes'); - } else { - $liability_shifted = $this->language->get('text_no'); - } - } - - if ($transaction->threeDSecureInfo) { - if ($transaction->threeDSecureInfo->liabilityShiftPossible) { - $liability_shift_possible = $this->language->get('text_yes'); - } else { - $liability_shift_possible = $this->language->get('text_no'); - } - } - - $data['transaction'] = array( - 'status' => $transaction->status, - 'transaction_id' => $transaction->id, - 'type' => $transaction->type, - 'date_added' => date($this->language->get('datetime_format'), strtotime($created_at->format('Y-m-d H:i:s e'))), - 'merchant_account_id' => $transaction->merchantAccountId, - 'payment_type' => $transaction->paymentInstrumentType, - 'currency' => $transaction->currencyIsoCode, - 'amount' => $amount, - 'order_id' => $transaction->orderId, - 'processor_code' => $transaction->processorAuthorizationCode, - 'cvv_response' => $transaction->cvvResponseCode, - 'avs_response' => sprintf($this->language->get('text_avs_response'), $transaction->avsStreetAddressResponseCode, $transaction->avsPostalCodeResponseCode), - 'threeds_enrolled' => ($transaction->threeDSecureInfo ? $transaction->threeDSecureInfo->enrolled : ''), - 'threeds_status' => ($transaction->threeDSecureInfo ? $transaction->threeDSecureInfo->status : ''), - 'threeds_shifted' => ($transaction->threeDSecureInfo ? $liability_shifted : ''), - 'threeds_shift_possible' => ($transaction->threeDSecureInfo ? $liability_shift_possible : '') - ); - - $data['text_confirm_void'] = $this->language->get('text_confirm_void'); - $data['text_confirm_settle'] = $this->language->get('text_confirm_settle'); - $data['text_confirm_refund'] = $this->language->get('text_confirm_refund'); - - $this->response->setOutput($this->load->view('extension/payment/pp_braintree_order_ajax', $data)); - } - } - - public function transactionCommand() { - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('extension/payment/pp_braintree'); - - $this->initialise($this->config->get('payment_pp_braintree_access_token'), array( - 'payment_pp_braintree_environment' => $this->config->get('payment_pp_braintree_environment'), - 'payment_pp_braintree_merchant_id' => $this->config->get('payment_pp_braintree_merchant_id'), - 'payment_pp_braintree_public_key' => $this->config->get('payment_pp_braintree_public_key'), - 'payment_pp_braintree_private_key' => $this->config->get('payment_pp_braintree_private_key') - )); - - $json = array(); - - $success = $error = ''; - - if ($this->request->post['type'] == 'void') { - $action = $this->model_extension_payment_pp_braintree->voidTransaction($this->gateway, $this->request->post['transaction_id']); - } elseif ($this->request->post['type'] == 'settle' && $this->request->post['amount']) { - $action = $this->model_extension_payment_pp_braintree->settleTransaction($this->gateway, $this->request->post['transaction_id'], $this->request->post['amount']); - } elseif ($this->request->post['type'] == 'refund' && $this->request->post['amount']) { - $action = $this->model_extension_payment_pp_braintree->refundTransaction($this->gateway, $this->request->post['transaction_id'], $this->request->post['amount']); - } else { - $error = true; - } - - if (!$error && $action && $action->success) { - $success = $this->language->get('text_success_action'); - } elseif (!$error && $action && isset($action->message)) { - $error = sprintf($this->language->get('text_error_settle'), $action->message); - } else { - $error = $this->language->get('text_error_generic'); - } - - $json['success'] = $success; - $json['error'] = $error; - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function search() { - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('extension/payment/pp_braintree'); - $this->load->model('customer/customer'); - $this->load->model('sale/order'); - - $this->initialise($this->config->get('payment_pp_braintree_access_token'), array( - 'payment_pp_braintree_environment' => $this->config->get('payment_pp_braintree_environment'), - 'payment_pp_braintree_merchant_id' => $this->config->get('payment_pp_braintree_merchant_id'), - 'payment_pp_braintree_public_key' => $this->config->get('payment_pp_braintree_public_key'), - 'payment_pp_braintree_private_key' => $this->config->get('payment_pp_braintree_private_key') - )); - - $json = array(); - - $success = $error = ''; - - if (isset($this->request->get['filter_transaction_id'])) { - $filter_transaction_id = $this->request->get['filter_transaction_id']; - } else { - $filter_transaction_id = null; - } - - if (isset($this->request->get['filter_transaction_type'])) { - $filter_transaction_type = $this->request->get['filter_transaction_type']; - } else { - $filter_transaction_type = null; - } - - if (isset($this->request->get['filter_payment_type'])) { - $filter_payment_type = $this->request->get['filter_payment_type']; - } else { - $filter_payment_type = null; - } - - if (isset($this->request->get['filter_card_type'])) { - $filter_card_type = $this->request->get['filter_card_type']; - } else { - $filter_card_type = null; - } - - if (isset($this->request->get['filter_merchant_account_id'])) { - $filter_merchant_account_id = $this->request->get['filter_merchant_account_id']; - } else { - $filter_merchant_account_id = null; - } - - if (isset($this->request->get['filter_transaction_status'])) { - $filter_transaction_status = $this->request->get['filter_transaction_status']; - } else { - $filter_transaction_status = null; - } - - if (isset($this->request->get['filter_date_from'])) { - $filter_date_from = $this->request->get['filter_date_from']; - } else { - $filter_date_from = null; - } - - if (isset($this->request->get['filter_date_to'])) { - $filter_date_to = $this->request->get['filter_date_to']; - } else { - $filter_date_to = null; - } - - if (isset($this->request->get['filter_amount_from'])) { - $filter_amount_from = $this->request->get['filter_amount_from']; - } else { - $filter_amount_from = null; - } - - if (isset($this->request->get['filter_amount_to'])) { - $filter_amount_to = $this->request->get['filter_amount_to']; - } else { - $filter_amount_to = null; - } - - $json['transactions'] = array(); - - $search = array(); - - if ($filter_transaction_id) { - $search[] = Braintree_TransactionSearch::id()->is($filter_transaction_id); - } - - if ($filter_transaction_type) { - if ($filter_transaction_type == 'sale') { - $transaction_type = Braintree_Transaction::SALE; - } elseif ($filter_transaction_type == 'credit') { - $transaction_type = Braintree_Transaction::CREDIT; - } - - $search[] = Braintree_TransactionSearch::type()->is($transaction_type); - } - - if ($filter_payment_type) { - if ($filter_payment_type == 'Credit Card') { - $payment_type = 'CreditCardDetail'; - } elseif ($filter_payment_type == 'PayPal') { - $payment_type = 'PayPalDetail'; - } - - $search[] = Braintree_TransactionSearch::paymentInstrumentType()->is($payment_type); - } - - if ($filter_card_type) { - switch ($filter_card_type) { - case 'Visa': - $card_type = Braintree_CreditCard::VISA; - break; - case 'MasterCard': - $card_type = Braintree_CreditCard::MASTER_CARD; - break; - case 'American Express': - $card_type = Braintree_CreditCard::AMEX; - break; - case 'Discover': - $card_type = Braintree_CreditCard::DISCOVER; - break; - case 'JCB': - $card_type = Braintree_CreditCard::JCB; - break; - case 'Maestro': - $card_type = Braintree_CreditCard::MAESTRO; - break; - } - - $search[] = Braintree_TransactionSearch::creditCardCardType()->is($card_type); - } - - if ($filter_merchant_account_id) { - $search[] = Braintree_TransactionSearch::merchantAccountId()->is($filter_merchant_account_id); - } - - if ($filter_transaction_status) { - $search[] = Braintree_TransactionSearch::status()->in($filter_transaction_status); - } - - if ($filter_date_from || $filter_date_to) { - if ($filter_date_from) { - $date_from = new DateTime($filter_date_from); - } else { - $date_from = new DateTime('2012-01-01 00:00'); - } - - if ($filter_date_to) { - $date_to = new DateTime($filter_date_to . ' +1 day -1 minute'); - } else { - $date_to = new DateTime('tomorrow -1 minute'); - } - - $search[] = Braintree_TransactionSearch::createdAt()->between($date_from, $date_to); - } - - if ($filter_amount_from) { - $amount_from = $filter_amount_from; - } else { - $amount_from = 0; - } - - if ($filter_amount_to) { - $amount_to = $filter_amount_to; - } else { - $amount_to = 9999999; - } - - $search[] = Braintree_TransactionSearch::amount()->between((float)$amount_from, (float)$amount_to); - - $transactions = $this->model_extension_payment_pp_braintree->getTransactions($this->gateway, $search); - - if ($transactions) { - foreach ($transactions as $transaction) { - $customer_url = false; - - if ($transaction->customer['id']) { - $braintree_customer_id = explode('_', $transaction->customer['id']); - - if (isset($braintree_customer_id[2]) && is_numeric($braintree_customer_id[2])) { - $customer_info = $this->model_customer_customer->getCustomer($braintree_customer_id[2]); - - if ($customer_info && $customer_info['email'] == $transaction->customer['email']) { - $customer_url = $this->url->link('sale/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . (int)$braintree_customer_id[2], true); - } - } - } - - $order = false; - - if ($transaction->orderId) { - $order_info = $this->model_sale_order->getOrder($transaction->orderId); - - if ($order_info && $order_info['email'] == $transaction->customer['email']) { - $order = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . (int)$transaction->orderId, true); - } - } - - $created_at = $transaction->createdAt; - - $json['transactions'][] = array( - 'transaction_id' => $transaction->id, - 'amount' => $transaction->amount, - 'currency_iso' => $transaction->currencyIsoCode, - 'status' => $transaction->status, - 'type' => $transaction->type, - 'merchant_account_id' => $transaction->merchantAccountId, - 'customer' => $transaction->customer['firstName'] . ' ' . $transaction->customer['lastName'], - 'customer_url' => $customer_url, - 'order' => $order, - 'date_added' => date($this->language->get('datetime_format'), strtotime($created_at->format('Y-m-d H:i:s e'))) - ); - } - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function connectRedirect() { - if ($this->user->hasPermission('modify', 'extension/extension/payment')) { - // Install the module before doing the redirect - $this->load->model('setting/extension'); - - $this->model_setting_extension->install('payment', 'pp_braintree'); - - $this->install(); - - $curl = curl_init($this->opencart_connect_url); - - $this->load->model('localisation/country'); - $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - - $post_data = array( - 'return_url' => $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true), - 'store_url' => HTTPS_CATALOG, - 'store_version' => VERSION, - 'store_country' => (isset($country['iso_code_3']) ? $country['iso_code_3'] : ''), - ); - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); - - $curl_response = curl_exec($curl); - - $curl_response = json_decode($curl_response, true); - - curl_close($curl); - - if ($curl_response['url']) { - $this->response->redirect($curl_response['url']); - } else { - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true)); - } - } else { - $this->response->redirect($this->url->link('error/permission', 'user_token=' . $this->session->data['user_token'], true)); - } - } - - public function promotion() { - $this->load->language('extension/payment/pp_braintree'); - - $data['connect_link'] = ''; - $data['module_link'] = ''; - - if ($this->config->get('payment_pp_braintree_status') || $this->config->get('payment_pp_braintree_merchant_id') || $this->config->get('payment_pp_braintree_access_token')) { - $data['module_link'] = $this->url->link('extension/payment/pp_braintree', 'user_token=' . $this->session->data['user_token'], true); - } else { - if ($this->user->hasPermission('modify', 'extension/extension/payment')) { - $data['connect_link'] = $this->url->link('extension/payment/pp_braintree/connectRedirect', 'user_token=' . $this->session->data['user_token'], true); - } - } - - if ($this->config->get("payment_pp_braintree_status") == 1) { - $data['payment_pp_braintree_status'] = "enabled"; - } elseif ($this->config->get("payment_pp_braintree_status") == null) { - $data['payment_pp_braintree_status'] = ""; - } else { - $data['payment_pp_braintree_status'] = "disabled"; - } - - return $this->load->view('extension/payment/pp_braintree_promotion', $data); - } - - protected function validate() { - $this->load->model('extension/payment/pp_braintree'); - - $check_credentials = true; - - if (version_compare(phpversion(), '7.3', '<')) { - $this->error['warning'] = $this->language->get('error_php_version'); - } - - if (!$this->user->hasPermission('modify', 'extension/payment/pp_braintree')) { - $this->error['warning'] = $this->language->get('error_permission'); - - $check_credentials = false; - } - - if ($check_credentials && $this->request->post['payment_pp_braintree_status'] == 1) { - $this->initialise($this->request->post['payment_pp_braintree_access_token'], array( - 'payment_pp_braintree_environment' => $this->request->post['payment_pp_braintree_environment'], - 'payment_pp_braintree_merchant_id' => $this->request->post['payment_pp_braintree_merchant_id'], - 'payment_pp_braintree_public_key' => $this->request->post['payment_pp_braintree_public_key'], - 'payment_pp_braintree_private_key' => $this->request->post['payment_pp_braintree_private_key'], - )); - - $verify_credentials = $this->model_extension_payment_pp_braintree->verifyCredentials($this->gateway); - - if (!$verify_credentials) { - $this->error['warning'] = $this->language->get('error_connection'); - } else { - foreach ($this->request->post['payment_pp_braintree_account'] as $currency => $pp_braintree_account) { - if (!empty($pp_braintree_account['merchant_account_id'])) { - $verify_merchant_account_id = $this->model_extension_payment_pp_braintree->verifyMerchantAccount($this->gateway, $pp_braintree_account['merchant_account_id']); - - if (!$verify_merchant_account_id) { - $this->error['account'][$currency] = $this->language->get('error_account'); - } - } - } - - $merchant_config = json_decode(base64_decode($verify_credentials), true); - - // verify the Braintree account is ready to accept 3DS transactions - if (isset($merchant_config['threeDSecureEnabled']) && ($this->request->post['payment_pp_braintree_3ds_status'] == 1 && $merchant_config['threeDSecureEnabled'] != 1)) { - $this->error['warning'] = $this->language->get('error_3ds_not_ready'); - } - - // verify the Braintree account is ready to use PayPal Billing Agreements - if (isset($merchant_config['paypal']['billingAgreementEnabled']) && ($this->request->post['payment_pp_braintree_billing_agreement'] == 1 && $merchant_config['paypal']['billingAgreementEnabled'] != 1)) { - $this->error['warning'] = $this->language->get('error_paypal_billing_not_ready'); - } - - // verify the Braintree account is ready to accept PayPal transactions - if (isset($merchant_config['paypalEnabled']) && ($this->request->post['payment_pp_braintree_paypal_option'] == 1 && $merchant_config['paypalEnabled'] != 1)) { - $this->error['warning'] = $this->language->get('error_paypal_not_ready'); - } - - // verify the environment matches with the token the system is using - if (isset($merchant_config['environment']) && ($this->request->post['payment_pp_braintree_environment'] != $merchant_config['environment'])) { - $this->error['warning'] = sprintf($this->language->get('error_environment'), $this->request->post['payment_pp_braintree_environment'], $merchant_config['environment']); - } - } - } - - if ($this->error && !isset($this->error['warning'])) { - $this->error['warning'] = $this->language->get('error_warning'); - } - - return !$this->error; - } - - private function initialise($access_token = '', $credentials = array()) { - $this->load->model('extension/payment/pp_braintree'); - - if ($access_token != '') { - $this->gateway = $this->model_extension_payment_pp_braintree->setGateway($access_token); - } else { - Braintree_Configuration::environment(isset($credentials['payment_pp_braintree_environment']) ? $credentials['payment_pp_braintree_environment'] : ''); - Braintree_Configuration::merchantId(isset($credentials['payment_pp_braintree_merchant_id']) ? $credentials['payment_pp_braintree_merchant_id'] : ''); - Braintree_Configuration::publicKey(isset($credentials['payment_pp_braintree_public_key']) ? $credentials['payment_pp_braintree_public_key'] : ''); - Braintree_Configuration::privateKey(isset($credentials['payment_pp_braintree_private_key']) ? $credentials['payment_pp_braintree_private_key'] : ''); - } - } -} diff --git a/upload/admin/controller/extension/payment/pp_express.php b/upload/admin/controller/extension/payment/pp_express.php deleted file mode 100644 index 36a34c581bc..00000000000 --- a/upload/admin/controller/extension/payment/pp_express.php +++ /dev/null @@ -1,1300 +0,0 @@ -load->language('extension/payment/pp_express'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_express', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - $data['user_token'] = $this->session->data['user_token']; - - $data['button_configure'] = $this->url->link('extension/module/pp_button/configure', 'user_token=' . $this->session->data['user_token'], true); - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['username'])) { - $data['error_username'] = $this->error['username']; - } else { - $data['error_username'] = ''; - } - - if (isset($this->error['password'])) { - $data['error_password'] = $this->error['password']; - } else { - $data['error_password'] = ''; - } - - if (isset($this->error['signature'])) { - $data['error_signature'] = $this->error['signature']; - } else { - $data['error_signature'] = ''; - } - - if (isset($this->error['sandbox_username'])) { - $data['error_sandbox_username'] = $this->error['sandbox_username']; - } else { - $data['error_sandbox_username'] = ''; - } - - if (isset($this->error['sandbox_password'])) { - $data['error_sandbox_password'] = $this->error['sandbox_password']; - } else { - $data['error_sandbox_password'] = ''; - } - - if (isset($this->error['sandbox_signature'])) { - $data['error_sandbox_signature'] = $this->error['sandbox_signature']; - } else { - $data['error_sandbox_signature'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['action'] = $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - $data['search'] = $this->url->link('extension/payment/pp_express/search', 'user_token=' . $this->session->data['user_token'], true); - - if (isset($this->request->post['payment_pp_express_username'])) { - $data['payment_pp_express_username'] = $this->request->post['payment_pp_express_username']; - } else { - $data['payment_pp_express_username'] = $this->config->get('payment_pp_express_username'); - } - - if (isset($this->request->post['payment_pp_express_password'])) { - $data['payment_pp_express_password'] = $this->request->post['payment_pp_express_password']; - } else { - $data['payment_pp_express_password'] = $this->config->get('payment_pp_express_password'); - } - - if (isset($this->request->post['payment_pp_express_signature'])) { - $data['payment_pp_express_signature'] = $this->request->post['payment_pp_express_signature']; - } else { - $data['payment_pp_express_signature'] = $this->config->get('payment_pp_express_signature'); - } - - if (isset($this->request->post['payment_pp_express_sandbox_username'])) { - $data['payment_pp_express_sandbox_username'] = $this->request->post['payment_pp_express_sandbox_username']; - } else { - $data['payment_pp_express_sandbox_username'] = $this->config->get('payment_pp_express_sandbox_username'); - } - - if (isset($this->request->post['payment_pp_express_sandbox_password'])) { - $data['payment_pp_express_sandbox_password'] = $this->request->post['payment_pp_express_sandbox_password']; - } else { - $data['payment_pp_express_sandbox_password'] = $this->config->get('payment_pp_express_sandbox_password'); - } - - if (isset($this->request->post['payment_pp_express_sandbox_signature'])) { - $data['payment_pp_express_sandbox_signature'] = $this->request->post['payment_pp_express_sandbox_signature']; - } else { - $data['payment_pp_express_sandbox_signature'] = $this->config->get('payment_pp_express_sandbox_signature'); - } - - $data['ipn_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_express/ipn'; - - if (isset($this->request->post['payment_pp_express_test'])) { - $data['payment_pp_express_test'] = $this->request->post['payment_pp_express_test']; - } else { - $data['payment_pp_express_test'] = $this->config->get('payment_pp_express_test'); - } - - if (isset($this->request->post['payment_pp_express_debug'])) { - $data['payment_pp_express_debug'] = $this->request->post['payment_pp_express_debug']; - } else { - $data['payment_pp_express_debug'] = $this->config->get('payment_pp_express_debug'); - } - - if (isset($this->request->post['payment_pp_express_incontext_disable'])) { - $data['payment_pp_express_incontext_disable'] = $this->request->post['payment_pp_express_incontext_disable']; - } else { - $data['payment_pp_express_incontext_disable'] = $this->config->get('payment_pp_express_incontext_disable'); - } - - if (isset($this->request->post['payment_pp_express_currency'])) { - $data['payment_pp_express_currency'] = $this->request->post['payment_pp_express_currency']; - } else { - $data['payment_pp_express_currency'] = $this->config->get('payment_pp_express_currency'); - } - - $this->load->model('extension/payment/pp_express'); - - $data['currencies'] = $this->model_extension_payment_pp_express->getCurrencies(); - - if (isset($this->request->post['payment_pp_express_recurring_cancel'])) { - $data['payment_pp_express_recurring_cancel'] = $this->request->post['payment_pp_express_recurring_cancel']; - } else { - $data['payment_pp_express_recurring_cancel'] = $this->config->get('payment_pp_express_recurring_cancel'); - } - - if (isset($this->request->post['payment_pp_express_transaction'])) { - $data['payment_pp_express_transaction'] = $this->request->post['payment_pp_express_transaction']; - } else { - $data['payment_pp_express_transaction'] = $this->config->get('payment_pp_express_transaction'); - } - - if (isset($this->request->post['payment_pp_express_total'])) { - $data['payment_pp_express_total'] = $this->request->post['payment_pp_express_total']; - } else { - $data['payment_pp_express_total'] = $this->config->get('payment_pp_express_total'); - } - - if (isset($this->request->post['payment_pp_express_geo_zone_id'])) { - $data['payment_pp_express_geo_zone_id'] = $this->request->post['payment_pp_express_geo_zone_id']; - } else { - $data['payment_pp_express_geo_zone_id'] = $this->config->get('payment_pp_express_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_express_status'])) { - $data['payment_pp_express_status'] = $this->request->post['payment_pp_express_status']; - } else { - $data['payment_pp_express_status'] = $this->config->get('payment_pp_express_status'); - } - - if (isset($this->request->post['payment_pp_express_sort_order'])) { - $data['payment_pp_express_sort_order'] = $this->request->post['payment_pp_express_sort_order']; - } else { - $data['payment_pp_express_sort_order'] = $this->config->get('payment_pp_express_sort_order'); - } - - if (isset($this->request->post['payment_pp_express_canceled_reversal_status_id'])) { - $data['payment_pp_express_canceled_reversal_status_id'] = $this->request->post['payment_pp_express_canceled_reversal_status_id']; - } else { - $data['payment_pp_express_canceled_reversal_status_id'] = $this->config->get('payment_pp_express_canceled_reversal_status_id'); - } - - if (isset($this->request->post['payment_pp_express_completed_status_id'])) { - $data['payment_pp_express_completed_status_id'] = $this->request->post['payment_pp_express_completed_status_id']; - } else { - $data['payment_pp_express_completed_status_id'] = $this->config->get('payment_pp_express_completed_status_id'); - } - - if (isset($this->request->post['payment_pp_express_denied_status_id'])) { - $data['payment_pp_express_denied_status_id'] = $this->request->post['payment_pp_express_denied_status_id']; - } else { - $data['payment_pp_express_denied_status_id'] = $this->config->get('payment_pp_express_denied_status_id'); - } - - if (isset($this->request->post['payment_pp_express_expired_status_id'])) { - $data['payment_pp_express_expired_status_id'] = $this->request->post['payment_pp_express_expired_status_id']; - } else { - $data['payment_pp_express_expired_status_id'] = $this->config->get('payment_pp_express_expired_status_id'); - } - - if (isset($this->request->post['payment_pp_express_failed_status_id'])) { - $data['payment_pp_express_failed_status_id'] = $this->request->post['payment_pp_express_failed_status_id']; - } else { - $data['payment_pp_express_failed_status_id'] = $this->config->get('payment_pp_express_failed_status_id'); - } - - if (isset($this->request->post['payment_pp_express_pending_status_id'])) { - $data['payment_pp_express_pending_status_id'] = $this->request->post['payment_pp_express_pending_status_id']; - } else { - $data['payment_pp_express_pending_status_id'] = $this->config->get('payment_pp_express_pending_status_id'); - } - - if (isset($this->request->post['payment_pp_express_processed_status_id'])) { - $data['payment_pp_express_processed_status_id'] = $this->request->post['payment_pp_express_processed_status_id']; - } else { - $data['payment_pp_express_processed_status_id'] = $this->config->get('payment_pp_express_processed_status_id'); - } - - if (isset($this->request->post['payment_pp_express_refunded_status_id'])) { - $data['payment_pp_express_refunded_status_id'] = $this->request->post['payment_pp_express_refunded_status_id']; - } else { - $data['payment_pp_express_refunded_status_id'] = $this->config->get('payment_pp_express_refunded_status_id'); - } - - if (isset($this->request->post['payment_pp_express_reversed_status_id'])) { - $data['payment_pp_express_reversed_status_id'] = $this->request->post['payment_pp_express_reversed_status_id']; - } else { - $data['payment_pp_express_reversed_status_id'] = $this->config->get('payment_pp_express_reversed_status_id'); - } - - if (isset($this->request->post['payment_pp_express_voided_status_id'])) { - $data['payment_pp_express_voided_status_id'] = $this->request->post['payment_pp_express_voided_status_id']; - } else { - $data['payment_pp_express_voided_status_id'] = $this->config->get('payment_pp_express_voided_status_id'); - } - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_express_allow_note'])) { - $data['payment_pp_express_allow_note'] = $this->request->post['payment_pp_express_allow_note']; - } else { - $data['payment_pp_express_allow_note'] = $this->config->get('payment_pp_express_allow_note'); - } - - if (isset($this->request->post['payment_pp_express_colour'])) { - $data['payment_pp_express_colour'] = str_replace('#', '', $this->request->post['payment_pp_express_colour']); - } else { - $data['payment_pp_express_colour'] = $this->config->get('payment_pp_express_colour'); - } - - if (isset($this->request->post['payment_pp_express_logo'])) { - $data['payment_pp_express_logo'] = $this->request->post['payment_pp_express_logo']; - } else { - $data['payment_pp_express_logo'] = $this->config->get('payment_pp_express_logo'); - } - - $this->load->model('tool/image'); - - if (isset($this->request->post['payment_pp_express_logo']) && is_file(DIR_IMAGE . $this->request->post['payment_pp_express_logo'])) { - $data['thumb'] = $this->model_tool_image->resize($this->request->post['payment_pp_express_logo'], 750, 90); - } elseif (is_file(DIR_IMAGE . $this->config->get('payment_pp_express_logo'))) { - $data['thumb'] = $this->model_tool_image->resize($this->config->get('payment_pp_express_logo'), 750, 90); - } else { - $data['thumb'] = $this->model_tool_image->resize('no_image.png', 750, 90); - } - - $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 750, 90); - - if (isset($this->request->get['retrieve_code']) && isset($this->request->get['merchant_id'])) { - $curl = curl_init($this->opencart_retrieve_url); - - $post_data = array( - 'merchant_id' => $this->request->get['merchant_id'], - 'retrieve_code' => $this->request->get['retrieve_code'], - ); - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); - - $curl_response = curl_exec($curl); - $config_response = json_decode($curl_response, true); - curl_close($curl); - - if (isset($config_response['api_user_name']) && isset($config_response['api_password']) && isset($config_response['signature'])) { - $pp_express_settings = $this->model_setting_setting->getSetting('payment_pp_express'); - - if ($config_response['environment'] == 'sandbox') { - $pp_express_settings['payment_pp_express_sandbox_username'] = $config_response['api_user_name']; - $pp_express_settings['payment_pp_express_sandbox_password'] = $config_response['api_password']; - $pp_express_settings['payment_pp_express_sandbox_signature'] = $config_response['signature']; - $pp_express_settings['payment_pp_express_test'] = 1; - - $data['payment_pp_express_sandbox_username'] = $config_response['api_user_name']; - $data['payment_pp_express_sandbox_password'] = $config_response['api_password']; - $data['payment_pp_express_sandbox_signature'] = $config_response['signature']; - $data['payment_pp_express_test'] = 1; - } else { - $pp_express_settings['payment_pp_express_username'] = $config_response['api_user_name']; - $pp_express_settings['payment_pp_express_password'] = $config_response['api_password']; - $pp_express_settings['payment_pp_express_signature'] = $config_response['signature']; - $pp_express_settings['payment_pp_express_test'] = 0; - - $data['payment_pp_express_username'] = $config_response['api_user_name']; - $data['payment_pp_express_password'] = $config_response['api_password']; - $data['payment_pp_express_signature'] = $config_response['signature']; - $data['payment_pp_express_test'] = 0; - } - - $data['retrieve_success'] = 1; - $data['text_retrieve'] = $this->language->get('text_retrieve'); - - $this->model_setting_setting->editSetting('payment_pp_express', $pp_express_settings); - } - } - - $this->load->model('localisation/country'); - - $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - - $post_data = array( - 'return_url' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - 'store_url' => HTTPS_CATALOG, - 'store_version' => VERSION, - 'store_country' => (isset($country['iso_code_3']) ? $country['iso_code_3'] : ''), - ); - - // Create sandbox link - $curl = curl_init($this->opencart_connect_url); - - $post_data['environment'] = 'sandbox'; - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data)); - - $curl_response = curl_exec($curl); - $curl_response = json_decode($curl_response, true); - - curl_close($curl); - - $data['auth_connect_url_sandbox'] = ''; - if (isset($curl_response['url']) && !empty($curl_response['url'])) { - $data['auth_connect_url_sandbox'] = $curl_response['url']; - } - - // Create Live link - $curl = curl_init($this->opencart_connect_url); - - $post_data['environment'] = 'live'; - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data)); - - $curl_response = curl_exec($curl); - $curl_response = json_decode($curl_response, true); - - curl_close($curl); - - $data['auth_connect_url_live'] = ''; - if (isset($curl_response['url']) && !empty($curl_response['url'])) { - $data['auth_connect_url_live'] = $curl_response['url']; - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_express', $data)); - } - - protected function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_express')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if ($this->request->post['payment_pp_express_test']) { - if (!$this->request->post['payment_pp_express_sandbox_username']) { - $this->error['sandbox_username'] = $this->language->get('error_sandbox_username'); - } - - if (!$this->request->post['payment_pp_express_sandbox_password']) { - $this->error['sandbox_password'] = $this->language->get('error_sandbox_password'); - } - - if (!$this->request->post['payment_pp_express_sandbox_signature']) { - $this->error['sandbox_signature'] = $this->language->get('error_sandbox_signature'); - } - } else { - if (!$this->request->post['payment_pp_express_username']) { - $this->error['username'] = $this->language->get('error_username'); - } - - if (!$this->request->post['payment_pp_express_password']) { - $this->error['password'] = $this->language->get('error_password'); - } - - if (!$this->request->post['payment_pp_express_signature']) { - $this->error['signature'] = $this->language->get('error_signature'); - } - } - - return !$this->error; - } - - public function install() { - $this->load->model('extension/payment/pp_express'); - - $this->model_extension_payment_pp_express->install(); - } - - public function uninstall() { - $this->load->model('extension/payment/pp_express'); - - $this->model_extension_payment_pp_express->uninstall(); - } - - public function order() { - if ($this->config->get('payment_pp_express_status')) { - $this->load->language('extension/payment/pp_express_order'); - - if (isset($this->request->get['order_id'])) { - $order_id = $this->request->get['order_id']; - } else { - $order_id = 0; - } - - $this->load->model('extension/payment/pp_express'); - - $paypal_info = $this->model_extension_payment_pp_express->getPayPalOrder($order_id); - - if ($paypal_info) { - $data['user_token'] = $this->session->data['user_token']; - - $data['order_id'] = (int)$this->request->get['order_id']; - - $data['capture_status'] = $paypal_info['capture_status']; - - $data['total'] = $paypal_info['total']; - - $captured = number_format($this->model_extension_payment_pp_express->getCapturedTotal($paypal_info['paypal_order_id']), 2); - - $data['captured'] = $captured; - - $data['capture_remaining'] = number_format($paypal_info['total'] - $captured, 2); - - $refunded = number_format($this->model_extension_payment_pp_express->getRefundedTotal($paypal_info['paypal_order_id']), 2); - - $data['refunded'] = $refunded; - - return $this->load->view('extension/payment/pp_express_order', $data); - } - } - } - - public function transaction() { - $this->load->language('extension/payment/pp_express_order'); - - $data['transactions'] = array(); - - if (isset($this->request->get['order_id'])) { - $order_id = $this->request->get['order_id']; - } else { - $order_id = 0; - } - - $this->load->model('extension/payment/pp_express'); - - $paypal_info = $this->model_extension_payment_pp_express->getOrder($order_id); - - if ($paypal_info) { - $results = $this->model_extension_payment_pp_express->getTransactions($paypal_info['paypal_order_id']); - - foreach ($results as $result) { - $data['transactions'][] = array( - 'transaction_id' => $result['transaction_id'], - 'amount' => $result['amount'], - 'payment_type' => $result['payment_type'], - 'payment_status' => $result['payment_status'], - 'pending_reason' => $result['pending_reason'], - 'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added'])), - 'view' => $this->url->link('extension/payment/pp_express/info', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $result['transaction_id'], true), - 'refund' => $this->url->link('extension/payment/pp_express/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $result['transaction_id'], true), - 'resend' => $this->url->link('extension/payment/pp_express/resend', 'user_token=' . $this->session->data['user_token'] . '&paypal_order_transaction_id=' . $result['paypal_order_transaction_id'], true) - ); - } - } - - $this->response->setOutput($this->load->view('extension/payment/pp_express_transaction', $data)); - } - - public function capture() { - $json = array(); - - $this->load->language('extension/payment/pp_express_order'); - - if (!isset($this->request->post['amount']) && $this->request->post['amount'] > 0) { - $json['error'] = $this->language->get('error_capture'); - } - - if (!$json) { - $this->load->model('extension/payment/pp_express'); - - if (isset($this->request->get['order_id'])) { - $order_id = $this->request->get['order_id']; - } else { - $order_id = 0; - } - - $paypal_info = $this->model_extension_payment_pp_express->getOrder($order_id); - - if ($paypal_info) { - // If this is the final amount to capture or not - if ($this->request->post['complete'] == 1) { - $complete = 'Complete'; - } else { - $complete = 'NotComplete'; - } - - $request = array( - 'METHOD' => 'DoCapture', - 'AUTHORIZATIONID' => $paypal_info['authorization_id'], - 'AMT' => number_format($this->request->post['amount'], 2), - 'CURRENCYCODE' => $paypal_info['currency_code'], - 'COMPLETETYPE' => $complete, - 'MSGSUBID' => uniqid(mt_rand(), true) - ); - - $response = $this->model_extension_payment_pp_express->call($request); - - if (isset($response['ACK']) && ($response['ACK'] != 'Failure') && ($response['ACK'] != 'FailureWithWarning')) { - $transaction_data = array( - 'paypal_order_id' => $paypal_info['paypal_order_id'], - 'transaction_id' => $response['TRANSACTIONID'], - 'parent_id' => $paypal_info['authorization_id'], - 'note' => '', - 'msgsubid' => $response['MSGSUBID'], - 'receipt_id' => '', - 'payment_type' => $response['PAYMENTTYPE'], - 'payment_status' => $response['PAYMENTSTATUS'], - 'pending_reason' => (isset($response['PENDINGREASON']) ? $response['PENDINGREASON'] : ''), - 'transaction_entity' => 'payment', - 'amount' => $response['AMT'], - 'debug_data' => json_encode($response) - ); - - $this->model_extension_payment_pp_express->addTransaction($transaction_data); - - $captured = number_format($this->model_extension_payment_pp_express->getCapturedTotal($paypal_info['paypal_order_id']), 2); - $refunded = number_format($this->model_extension_payment_pp_express->getRefundedTotal($paypal_info['paypal_order_id']), 2); - - $json['captured'] = $captured; - $json['refunded'] = $refunded; - $json['remaining'] = number_format($paypal_info['total'] - $captured, 2); - - if ($this->request->post['complete'] == 1 || $json['remaining'] == 0.00) { - $json['capture_status'] = $this->language->get('text_complete'); - - $this->model_extension_payment_pp_express->editPayPalOrderStatus($order_id, 'Complete'); - } - - $json['success'] = $this->language->get('text_success'); - } else { - $json['error'] = (isset($response_info['L_SHORTMESSAGE0']) ? $response_info['L_SHORTMESSAGE0'] : $this->language->get('error_transaction')); - } - } else { - $json['error'] = $this->language->get('error_not_found'); - } - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function refund() { - $this->load->language('extension/payment/pp_express_refund'); - - $this->document->setTitle($this->language->get('heading_title')); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_pp_express'), - 'href' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_express/refund', 'user_token=' . $this->session->data['user_token'], true), - ); - - //button actions - $data['action'] = $this->url->link('extension/payment/pp_express/doRefund', 'user_token=' . $this->session->data['user_token'], true); - $data['cancel'] = $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true); - - $data['transaction_id'] = $this->request->get['transaction_id']; - - $this->load->model('extension/payment/pp_express'); - $pp_transaction = $this->model_extension_payment_pp_express->getTransaction($this->request->get['transaction_id']); - - $data['amount_original'] = $pp_transaction['AMT']; - $data['currency_code'] = $pp_transaction['CURRENCYCODE']; - - $refunded = number_format($this->model_extension_payment_pp_express->getRefundedTotalByParentId($this->request->get['transaction_id']), 2); - - if ($refunded != 0.00) { - $data['refund_available'] = number_format($data['amount_original'] + $refunded, 2); - $data['attention'] = $this->language->get('text_current_refunds') . ': ' . $data['refund_available']; - } else { - $data['refund_available'] = ''; - $data['attention'] = ''; - } - - $data['user_token'] = $this->session->data['user_token']; - - if (isset($this->session->data['error'])) { - $data['error'] = $this->session->data['error']; - unset($this->session->data['error']); - } else { - $data['error'] = ''; - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_express_refund', $data)); - } - - public function doRefund() { - /** - * used to issue a refund for a captured payment - * - * refund can be full or partial - */ - if (isset($this->request->post['transaction_id']) && isset($this->request->post['refund_full'])) { - - $this->load->model('extension/payment/pp_express'); - $this->load->language('extension/payment/pp_express_refund'); - - if ($this->request->post['refund_full'] == 0 && $this->request->post['amount'] == 0) { - $this->session->data['error'] = $this->language->get('error_partial_amt'); - } else { - $order_id = $this->model_extension_payment_pp_express->getOrderId($this->request->post['transaction_id']); - $paypal_order = $this->model_extension_payment_pp_express->getOrder($order_id); - - if ($paypal_order) { - $call_data = array(); - $call_data['METHOD'] = 'RefundTransaction'; - $call_data['TRANSACTIONID'] = $this->request->post['transaction_id']; - $call_data['NOTE'] = urlencode($this->request->post['refund_message']); - $call_data['MSGSUBID'] = uniqid(mt_rand(), true); - - $current_transaction = $this->model_extension_payment_pp_express->getLocalTransaction($this->request->post['transaction_id']); - - if ($this->request->post['refund_full'] == 1) { - $call_data['REFUNDTYPE'] = 'Full'; - } else { - $call_data['REFUNDTYPE'] = 'Partial'; - $call_data['AMT'] = number_format($this->request->post['amount'], 2); - $call_data['CURRENCYCODE'] = $this->request->post['currency_code']; - } - - $result = $this->model_extension_payment_pp_express->call($call_data); - - $transaction = array( - 'paypal_order_id' => $paypal_order['paypal_order_id'], - 'transaction_id' => '', - 'parent_transaction_id' => $this->request->post['transaction_id'], - 'note' => $this->request->post['refund_message'], - 'msgsubid' => $call_data['MSGSUBID'], - 'receipt_id' => '', - 'payment_type' => '', - 'payment_status' => 'Refunded', - 'transaction_entity' => 'payment', - 'pending_reason' => '', - 'amount' => '-' . (isset($call_data['AMT']) ? $call_data['AMT'] : $current_transaction['amount']), - 'debug_data' => json_encode($result) - ); - - if ($result == false) { - $transaction['payment_status'] = 'Failed'; - $this->model_extension_payment_pp_express->addTransaction($transaction, $call_data); - $this->response->redirect($this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $paypal_order['order_id'], true)); - } else if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') { - - $transaction['transaction_id'] = $result['REFUNDTRANSACTIONID']; - $transaction['payment_type'] = $result['REFUNDSTATUS']; - $transaction['pending_reason'] = $result['PENDINGREASON']; - $transaction['amount'] = '-' . $result['GROSSREFUNDAMT']; - - $this->model_extension_payment_pp_express->addTransaction($transaction); - - //edit transaction to refunded status - if ($result['TOTALREFUNDEDAMOUNT'] == $this->request->post['amount_original']) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Refunded' WHERE `transaction_id` = '" . $this->db->escape($this->request->post['transaction_id']) . "' LIMIT 1"); - } else { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Partially-Refunded' WHERE `transaction_id` = '" . $this->db->escape($this->request->post['transaction_id']) . "' LIMIT 1"); - } - - //redirect back to the order - $this->response->redirect($this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $paypal_order['order_id'], true)); - } else { - $this->model_extension_payment_pp_express->log(json_encode($result)); - $this->session->data['error'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : 'There was an error') . (isset($result['L_LONGMESSAGE0']) ? '
' . $result['L_LONGMESSAGE0'] : ''); - $this->response->redirect($this->url->link('extension/payment/pp_express/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } else { - $this->session->data['error'] = $this->language->get('error_data_missing'); - $this->response->redirect($this->url->link('extension/payment/pp_express/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } - } else { - $this->session->data['error'] = $this->language->get('error_data'); - $this->response->redirect($this->url->link('extension/payment/pp_express/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } - - /** - * used to void an authorised payment - */ - public function void() { - $json = array(); - - $this->load->language('extension/payment/pp_express_order'); - - if (isset($this->request->get['order_id'])) { - $order_id = $this->request->get['order_id']; - } else { - $order_id = 0; - } - - $this->load->model('extension/payment/pp_express'); - - $paypal_info = $this->model_extension_payment_pp_express->getOrder($order_id); - - if ($paypal_info) { - $request = array( - 'METHOD' => 'DoVoid', - 'AUTHORIZATIONID' => $paypal_info['authorization_id'], - 'MSGSUBID' => uniqid(mt_rand(), true) - ); - - $response_info = $this->model_extension_payment_pp_express->call($request); - - if (isset($response_info['ACK']) && ($response_info['ACK'] != 'Failure') && ($response_info['ACK'] != 'FailureWithWarning')) { - $transaction = array( - 'paypal_order_id' => $paypal_info['paypal_order_id'], - 'transaction_id' => '', - 'parent_id' => $paypal_info['authorization_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => '', - 'payment_type' => 'void', - 'payment_status' => 'Void', - 'pending_reason' => '', - 'transaction_entity' => 'auth', - 'amount' => '', - 'debug_data' => json_encode($response_info) - ); - - $this->model_extension_payment_pp_express->addTransaction($transaction); - - $this->model_extension_payment_pp_express->editPayPalOrderStatus($order_id, 'Complete'); - - $json['capture_status'] = 'Complete'; - - $json['success'] = $this->language->get('text_success'); - } else { - $json['error'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : $this->language->get('error_transaction')); - } - } else { - $json['error'] = $this->language->get('error_not_found'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - // Cancel an active recurring - public function recurringCancel() { - $json = array(); - - $this->load->language('extension/recurring/pp_express'); - - //cancel an active recurring - $this->load->model('account/recurring'); - - if (isset($this->request->get['order_recurring_id'])) { - $order_recurring_id = $this->request->get['order_recurring_id']; - } else { - $order_recurring_id = 0; - } - - $recurring_info = $this->model_account_recurring->getOrderRecurring($order_recurring_id); - - if ($recurring_info && $recurring_info['reference']) { - if ($this->config->get('payment_pp_express_test')) { - $api_url = 'https://api-3t.sandbox.paypal.com/nvp'; - $api_username = $this->config->get('payment_pp_express_sandbox_username'); - $api_password = $this->config->get('payment_pp_express_sandbox_password'); - $api_signature = $this->config->get('payment_pp_express_sandbox_signature'); - } else { - $api_url = 'https://api-3t.paypal.com/nvp'; - $api_username = $this->config->get('payment_pp_express_username'); - $api_password = $this->config->get('payment_pp_express_password'); - $api_signature = $this->config->get('payment_pp_express_signature'); - } - - $request = array( - 'USER' => $api_username, - 'PWD' => $api_password, - 'SIGNATURE' => $api_signature, - 'VERSION' => '109.0', - 'BUTTONSOURCE' => 'OpenCart_2.0_EC', - 'METHOD' => 'SetExpressCheckout', - 'METHOD' => 'ManageRecurringPaymentsProfileStatus', - 'PROFILEID' => $recurring_info['reference'], - 'ACTION' => 'Cancel' - ); - - $curl = curl_init($api_url); - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = curl_exec($curl); - - if (!$response) { - $this->log(sprintf($this->language->get('error_curl'), curl_errno($curl), curl_error($curl))); - } - - curl_close($curl); - - $response_info = array(); - - parse_str($response, $response_info); - - if (isset($response_info['PROFILEID'])) { - $this->model_account_recurring->editOrderRecurringStatus($order_recurring_id, 4); - $this->model_account_recurring->addOrderRecurringTransaction($order_recurring_id, 5); - - $json['success'] = $this->language->get('text_cancelled'); - } else { - $json['error'] = sprintf($this->language->get('error_not_cancelled'), $response_info['L_LONGMESSAGE0']); - } - } else { - $json['error'] = $this->language->get('error_not_found'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function resend() { - $json = array(); - - $this->load->language('extension/payment/pp_express'); - - if (isset($this->request->get['paypal_order_transaction_id'])) { - $paypal_order_transaction_id = $this->request->get['paypal_order_transaction_id']; - } else { - $paypal_order_transaction_id = 0; - } - - $this->load->model('extension/payment/pp_express'); - - $transaction = $this->model_extension_payment_pp_express->getFailedTransaction($paypal_order_transaction_id); - - if ($transaction) { - - $call_data = json_decode($transaction['call_data'], true); - - $result = $this->model_extension_payment_pp_express->call($call_data); - - if ($result) { - - $parent_transaction = $this->model_extension_payment_pp_express->getLocalTransaction($transaction['parent_id']); - - if ($parent_transaction['amount'] == abs($transaction['amount'])) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Refunded' WHERE `transaction_id` = '" . $this->db->escape($transaction['parent_id']) . "' LIMIT 1"); - } else { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Partially-Refunded' WHERE `transaction_id` = '" . $this->db->escape($transaction['parent_id']) . "' LIMIT 1"); - } - - if (isset($result['REFUNDTRANSACTIONID'])) { - $transaction['transaction_id'] = $result['REFUNDTRANSACTIONID']; - } else { - $transaction['transaction_id'] = $result['TRANSACTIONID']; - } - - if (isset($result['PAYMENTTYPE'])) { - $transaction['payment_type'] = $result['PAYMENTTYPE']; - } else { - $transaction['payment_type'] = $result['REFUNDSTATUS']; - } - - if (isset($result['PAYMENTSTATUS'])) { - $transaction['payment_status'] = $result['PAYMENTSTATUS']; - } else { - $transaction['payment_status'] = 'Refunded'; - } - - if (isset($result['AMT'])) { - $transaction['amount'] = $result['AMT']; - } else { - $transaction['amount'] = $transaction['amount']; - } - - $transaction['pending_reason'] = (isset($result['PENDINGREASON']) ? $result['PENDINGREASON'] : ''); - - $this->model_extension_payment_pp_express->updateTransaction($transaction); - - $json['success'] = $this->language->get('success_transaction_resent'); - } else { - $json['error'] = $this->language->get('error_timeout'); - } - } else { - $json['error'] = $this->language->get('error_transaction_missing'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function search() { - $this->load->language('extension/payment/pp_express_search'); - - $this->document->setTitle($this->language->get('heading_title')); - - $data['user_token'] = $this->session->data['user_token']; - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_pp_express'), - 'href' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_express/search', 'user_token=' . $this->session->data['user_token'], true), - ); - - $this->load->model('extension/payment/pp_express'); - - $data['currency_codes'] = $this->model_extension_payment_pp_express->getCurrencies(); - - $data['default_currency'] = $this->config->get('payment_pp_express_currency'); - - $data['date_start'] = date("Y-m-d", strtotime('-30 days')); - $data['date_end'] = date("Y-m-d"); - $data['view_link'] = $this->url->link('extension/payment/pp_express/info', 'user_token=' . $this->session->data['user_token'], true); - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_express_search', $data)); - } - - public function info() { - $this->load->language('extension/payment/pp_express_view'); - - $this->document->setTitle($this->language->get('heading_title')); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_pp_express'), - 'href' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_express/info', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->get['transaction_id'], true), - ); - - $this->load->model('extension/payment/pp_express'); - - $data['transaction'] = $this->model_extension_payment_pp_express->getTransaction($this->request->get['transaction_id']); - $data['lines'] = $this->formatRows($data['transaction']); - $data['view_link'] = $this->url->link('extension/payment/pp_express/info', 'user_token=' . $this->session->data['user_token'], true); - $data['cancel'] = $this->url->link('extension/payment/pp_express/search', 'user_token=' . $this->session->data['user_token'], true); - $data['user_token'] = $this->session->data['user_token']; - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_express_view', $data)); - } - - public function doSearch() { - /** - * used to search for transactions from a user account - */ - if (isset($this->request->post['date_start'])) { - - $this->load->model('extension/payment/pp_express'); - - $call_data = array(); - $call_data['METHOD'] = 'TransactionSearch'; - $call_data['STARTDATE'] = gmdate($this->request->post['date_start'] . "\TH:i:s\Z"); - - if (!empty($this->request->post['date_end'])) { - $call_data['ENDDATE'] = gmdate($this->request->post['date_end'] . "\TH:i:s\Z"); - } - - if (!empty($this->request->post['transaction_class'])) { - $call_data['TRANSACTIONCLASS'] = $this->request->post['transaction_class']; - } - - if (!empty($this->request->post['status'])) { - $call_data['STATUS'] = $this->request->post['status']; - } - - if (!empty($this->request->post['buyer_email'])) { - $call_data['EMAIL'] = $this->request->post['buyer_email']; - } - - if (!empty($this->request->post['merchant_email'])) { - $call_data['RECEIVER'] = $this->request->post['merchant_email']; - } - - if (!empty($this->request->post['receipt_id'])) { - $call_data['RECEIPTID'] = $this->request->post['receipt_id']; - } - - if (!empty($this->request->post['transaction_id'])) { - $call_data['TRANSACTIONID'] = $this->request->post['transaction_id']; - } - - if (!empty($this->request->post['invoice_number'])) { - $call_data['INVNUM'] = $this->request->post['invoice_number']; - } - - if (!empty($this->request->post['auction_item_number'])) { - $call_data['AUCTIONITEMNUMBER'] = $this->request->post['auction_item_number']; - } - - if (!empty($this->request->post['amount'])) { - $call_data['AMT'] = number_format($this->request->post['amount'], 2); - $call_data['CURRENCYCODE'] = $this->request->post['currency_code']; - } - - if (!empty($this->request->post['recurring_id'])) { - $call_data['PROFILEID'] = $this->request->post['recurring_id']; - } - - if (!empty($this->request->post['name_salutation'])) { - $call_data['SALUTATION'] = $this->request->post['name_salutation']; - } - - if (!empty($this->request->post['name_first'])) { - $call_data['FIRSTNAME'] = $this->request->post['name_first']; - } - - if (!empty($this->request->post['name_middle'])) { - $call_data['MIDDLENAME'] = $this->request->post['name_middle']; - } - - if (!empty($this->request->post['name_last'])) { - $call_data['LASTNAME'] = $this->request->post['name_last']; - } - - if (!empty($this->request->post['name_suffix'])) { - $call_data['SUFFIX'] = $this->request->post['name_suffix']; - } - - $result = $this->model_extension_payment_pp_express->call($call_data); - - if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning' && $result['ACK'] != 'Warning') { - $response['error'] = false; - $response['result'] = $this->formatRows($result); - } else { - $response['error'] = true; - $response['error_msg'] = $result['L_LONGMESSAGE0']; - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($response)); - } else { - $response['error'] = true; - $response['error_msg'] = 'Enter a start date'; - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($response)); - } - } - - public function live() { - if (isset($this->request->get['merchantId'])) { - $this->load->language('extension/payment/pp_express'); - - $this->load->model('extension/payment/pp_express'); - $this->load->model('setting/setting'); - - $token = $this->model_extension_payment_pp_express->getTokens('live'); - - if (isset($token->access_token)) { - $user_info = $this->model_extension_payment_pp_express->getUserInfo($this->request->get['merchantId'], 'live', $token->access_token); - } else { - $this->session->data['error_api'] = $this->language->get('error_api'); - } - - if (isset($user_info->api_user_name)) { - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_username', $user_info->api_user_name); - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_password', $user_info->api_password); - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_signature', $user_info->signature); - } else { - $this->session->data['error_api'] = $this->language->get('error_api'); - } - } - - $this->response->redirect($this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true)); - } - - public function sandbox() { - if (isset($this->request->get['merchantId'])) { - $this->load->language('extension/payment/pp_express'); - - $this->load->model('extension/payment/pp_express'); - $this->load->model('setting/setting'); - - $token = $this->model_extension_payment_pp_express->getTokens('sandbox'); - - if (isset($token->access_token)) { - $user_info = $this->model_extension_payment_pp_express->getUserInfo($this->request->get['merchantId'], 'sandbox', $token->access_token); - } else { - $this->session->data['error_api'] = $this->language->get('error_api_sandbox'); - } - - if (isset($user_info->api_user_name)) { - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_sandbox_username', $user_info->api_user_name); - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_sandbox_password', $user_info->api_password); - $this->model_setting_setting->editSettingValue('payment_pp_express', 'payment_pp_express_sandbox_signature', $user_info->signature); - } else { - $this->session->data['error_api'] = $this->language->get('error_api_sandbox'); - } - } - $this->response->redirect($this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true)); - } - - private function formatRows($data) { - $return = array(); - - foreach ($data as $k => $v) { - $elements = preg_split("/(\d+)/", $k, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); - if (isset($elements[1]) && isset($elements[0])) { - if ($elements[0] == 'L_TIMESTAMP') { - $v = str_replace('T', ' ', $v); - $v = str_replace('Z', '', $v); - } - $return[$elements[1]][$elements[0]] = $v; - } - } - - return $return; - } - - public function recurringButtons() { - $this->load->model('sale/recurring'); - - $recurring = $this->model_sale_recurring->getRecurring($this->request->get['order_recurring_id']); - - $data['buttons'] = array(); - - if ($recurring['status'] == 2 || $recurring['status'] == 3) { - $data['buttons'][] = array( - 'text' => $this->language->get('button_cancel_recurring'), - 'link' => $this->url->link('extension/payment/pp_express/recurringCancel', 'order_recurring_id=' . $this->request->get['order_recurring_id'] . '&user_token=' . $this->request->get['user_token'], true) - ); - } - - return $this->load->view('sale/recurring_button', $data); - } - - public function connectRedirect() { - if ($this->user->hasPermission('modify', 'extension/extension/payment') && $this->user->hasPermission('modify', 'extension/payment/pp_express')) { - // Install the module before doing the redirect - $this->load->model('setting/extension'); - - $this->model_setting_extension->install('payment', 'pp_express'); - - $this->install(); - - $this->load->model('localisation/country'); - - $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - - $post_data = array( - 'return_url' => $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true), - 'store_url' => HTTPS_CATALOG, - 'store_version' => VERSION, - 'store_country' => (isset($country['iso_code_3']) ? $country['iso_code_3'] : ''), - ); - - // Create Live link - $curl = curl_init($this->opencart_connect_url); - - $post_data['environment'] = 'live'; - - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data)); - - $curl_response = curl_exec($curl); - $curl_response = json_decode($curl_response, true); - - curl_close($curl); - - if (isset($curl_response['url']) && !empty($curl_response['url'])) { - $this->response->redirect($curl_response['url']); - } else { - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true)); - } - } else { - $this->response->redirect($this->url->link('error/permission', 'user_token=' . $this->session->data['user_token'], true)); - } - } - - public function preferredSolution() { - $this->load->language('extension/payment/pp_express'); - - $data['connect_link'] = ''; - $data['module_link'] = ''; - - if ($this->config->get('payment_pp_express_username') || $this->config->get('payment_pp_express_sandbox_username')) { - $data['module_link'] = $this->url->link('extension/payment/pp_express', 'user_token=' . $this->session->data['user_token'], true); - } else { - if ($this->user->hasPermission('modify', 'extension/extension/payment')) { - $data['connect_link'] = $this->url->link('extension/payment/pp_express/connectRedirect', 'user_token=' . $this->session->data['user_token'], true); - } - } - - if ($this->config->get("payment_pp_express_status") == 1) { - $data['payment_pp_express_status'] = "enabled"; - } elseif ($this->config->get("payment_pp_express_status") == null) { - $data['payment_pp_express_status'] = ""; - } else { - $data['payment_pp_express_status'] = "disabled"; - } - - return $this->load->view('extension/payment/pp_express_preferred', $data); - } -} diff --git a/upload/admin/controller/extension/payment/pp_payflow.php b/upload/admin/controller/extension/payment/pp_payflow.php deleted file mode 100644 index 815d6ae4024..00000000000 --- a/upload/admin/controller/extension/payment/pp_payflow.php +++ /dev/null @@ -1,177 +0,0 @@ -load->language('extension/payment/pp_payflow'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_payflow', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['vendor'])) { - $data['error_vendor'] = $this->error['vendor']; - } else { - $data['error_vendor'] = ''; - } - - if (isset($this->error['user'])) { - $data['error_user'] = $this->error['user']; - } else { - $data['error_user'] = ''; - } - - if (isset($this->error['password'])) { - $data['error_password'] = $this->error['password']; - } else { - $data['error_password'] = ''; - } - - if (isset($this->error['partner'])) { - $data['error_partner'] = $this->error['partner']; - } else { - $data['error_partner'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_payflow', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['action'] = $this->url->link('extension/payment/pp_payflow', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_payflow_vendor'])) { - $data['payment_pp_payflow_vendor'] = $this->request->post['payment_pp_payflow_vendor']; - } else { - $data['payment_pp_payflow_vendor'] = $this->config->get('payment_pp_payflow_vendor'); - } - - if (isset($this->request->post['payment_pp_payflow_user'])) { - $data['payment_pp_payflow_user'] = $this->request->post['payment_pp_payflow_user']; - } else { - $data['payment_pp_payflow_user'] = $this->config->get('payment_pp_payflow_user'); - } - - if (isset($this->request->post['payment_pp_payflow_password'])) { - $data['payment_pp_payflow_password'] = $this->request->post['payment_pp_payflow_password']; - } else { - $data['payment_pp_payflow_password'] = $this->config->get('payment_pp_payflow_password'); - } - - if (isset($this->request->post['payment_pp_payflow_partner'])) { - $data['payment_pp_payflow_partner'] = $this->request->post['payment_pp_payflow_partner']; - } elseif ($this->config->has('payment_pp_payflow_partner')) { - $data['payment_pp_payflow_partner'] = $this->config->get('payment_pp_payflow_partner'); - } else { - $data['payment_pp_payflow_partner'] = 'PayPal'; - } - - if (isset($this->request->post['payment_pp_payflow_test'])) { - $data['payment_pp_payflow_test'] = $this->request->post['payment_pp_payflow_test']; - } else { - $data['payment_pp_payflow_test'] = $this->config->get('payment_pp_payflow_test'); - } - - if (isset($this->request->post['payment_pp_payflow_transaction'])) { - $data['payment_pp_payflow_transaction'] = $this->request->post['payment_pp_payflow_transaction']; - } else { - $data['payment_pp_payflow_transaction'] = $this->config->get('payment_pp_payflow_transaction'); - } - - if (isset($this->request->post['payment_pp_payflow_total'])) { - $data['payment_pp_payflow_total'] = $this->request->post['payment_pp_payflow_total']; - } else { - $data['payment_pp_payflow_total'] = $this->config->get('payment_pp_payflow_total'); - } - - if (isset($this->request->post['payment_pp_payflow_order_status_id'])) { - $data['payment_pp_payflow_order_status_id'] = $this->request->post['payment_pp_payflow_order_status_id']; - } else { - $data['payment_pp_payflow_order_status_id'] = $this->config->get('payment_pp_payflow_order_status_id'); - } - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_payflow_geo_zone_id'])) { - $data['payment_pp_payflow_geo_zone_id'] = $this->request->post['payment_pp_payflow_geo_zone_id']; - } else { - $data['payment_pp_payflow_geo_zone_id'] = $this->config->get('payment_pp_payflow_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_payflow_status'])) { - $data['payment_pp_payflow_status'] = $this->request->post['payment_pp_payflow_status']; - } else { - $data['payment_pp_payflow_status'] = $this->config->get('payment_pp_payflow_status'); - } - - if (isset($this->request->post['payment_pp_payflow_sort_order'])) { - $data['payment_pp_payflow_sort_order'] = $this->request->post['payment_pp_payflow_sort_order']; - } else { - $data['payment_pp_payflow_sort_order'] = $this->config->get('payment_pp_payflow_sort_order'); - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow', $data)); - } - - private function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_payflow')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if (!$this->request->post['payment_pp_payflow_vendor']) { - $this->error['vendor'] = $this->language->get('error_vendor'); - } - - if (!$this->request->post['payment_pp_payflow_user']) { - $this->error['user'] = $this->language->get('error_user'); - } - - if (!$this->request->post['payment_pp_payflow_password']) { - $this->error['password'] = $this->language->get('error_password'); - } - - if (!$this->request->post['payment_pp_payflow_partner']) { - $this->error['partner'] = $this->language->get('error_partner'); - } - - return !$this->error; - } -} \ No newline at end of file diff --git a/upload/admin/controller/extension/payment/pp_payflow_iframe.php b/upload/admin/controller/extension/payment/pp_payflow_iframe.php deleted file mode 100644 index 269b404b9e7..00000000000 --- a/upload/admin/controller/extension/payment/pp_payflow_iframe.php +++ /dev/null @@ -1,483 +0,0 @@ -load->language('extension/payment/pp_payflow_iframe'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_payflow_iframe', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['vendor'])) { - $data['error_vendor'] = $this->error['vendor']; - } else { - $data['error_vendor'] = ''; - } - - if (isset($this->error['user'])) { - $data['error_user'] = $this->error['user']; - } else { - $data['error_user'] = ''; - } - - if (isset($this->error['password'])) { - $data['error_password'] = $this->error['password']; - } else { - $data['error_password'] = ''; - } - - if (isset($this->error['partner'])) { - $data['error_partner'] = $this->error['partner']; - } else { - $data['error_partner'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true), - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe', 'user_token=' . $this->session->data['user_token'], true), - ); - - $data['action'] = $this->url->link('extension/payment/pp_payflow_iframe', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_payflow_iframe_vendor'])) { - $data['payment_pp_payflow_iframe_vendor'] = $this->request->post['payment_pp_payflow_iframe_vendor']; - } else { - $data['payment_pp_payflow_iframe_vendor'] = $this->config->get('payment_pp_payflow_iframe_vendor'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_user'])) { - $data['payment_pp_payflow_iframe_user'] = $this->request->post['payment_pp_payflow_iframe_user']; - } else { - $data['payment_pp_payflow_iframe_user'] = $this->config->get('payment_pp_payflow_iframe_user'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_password'])) { - $data['payment_pp_payflow_iframe_password'] = $this->request->post['payment_pp_payflow_iframe_password']; - } else { - $data['payment_pp_payflow_iframe_password'] = $this->config->get('payment_pp_payflow_iframe_password'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_partner'])) { - $data['payment_pp_payflow_iframe_partner'] = $this->request->post['payment_pp_payflow_iframe_partner']; - } else { - $data['payment_pp_payflow_iframe_partner'] = $this->config->get('payment_pp_payflow_iframe_partner'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_transaction_method'])) { - $data['payment_pp_payflow_iframe_transaction_method'] = $this->request->post['payment_pp_payflow_iframe_transaction_method']; - } else { - $data['payment_pp_payflow_iframe_transaction_method'] = $this->config->get('payment_pp_payflow_iframe_transaction_method'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_test'])) { - $data['payment_pp_payflow_iframe_test'] = $this->request->post['payment_pp_payflow_iframe_test']; - } else { - $data['payment_pp_payflow_iframe_test'] = $this->config->get('payment_pp_payflow_iframe_test'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_total'])) { - $data['payment_pp_payflow_iframe_total'] = $this->request->post['payment_pp_payflow_iframe_total']; - } else { - $data['payment_pp_payflow_iframe_total'] = $this->config->get('payment_pp_payflow_iframe_total'); - } - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_payflow_iframe_order_status_id'])) { - $data['payment_pp_payflow_iframe_order_status_id'] = $this->request->post['payment_pp_payflow_iframe_order_status_id']; - } else { - $data['payment_pp_payflow_iframe_order_status_id'] = $this->config->get('payment_pp_payflow_iframe_order_status_id'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_geo_zone_id'])) { - $data['payment_pp_payflow_iframe_geo_zone_id'] = $this->request->post['payment_pp_payflow_iframe_geo_zone_id']; - } else { - $data['payment_pp_payflow_iframe_geo_zone_id'] = $this->config->get('payment_pp_payflow_iframe_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_payflow_iframe_status'])) { - $data['payment_pp_payflow_iframe_status'] = $this->request->post['payment_pp_payflow_iframe_status']; - } else { - $data['payment_pp_payflow_iframe_status'] = $this->config->get('payment_pp_payflow_iframe_status'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_sort_order'])) { - $data['payment_pp_payflow_iframe_sort_order'] = $this->request->post['payment_pp_payflow_iframe_sort_order']; - } else { - $data['payment_pp_payflow_iframe_sort_order'] = $this->config->get('payment_pp_payflow_iframe_sort_order'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_checkout_method'])) { - $data['payment_pp_payflow_iframe_checkout_method'] = $this->request->post['payment_pp_payflow_iframe_checkout_method']; - } else { - $data['payment_pp_payflow_iframe_checkout_method'] = $this->config->get('payment_pp_payflow_iframe_checkout_method'); - } - - if (isset($this->request->post['payment_pp_payflow_iframe_debug'])) { - $data['payment_pp_payflow_iframe_debug'] = $this->request->post['payment_pp_payflow_iframe_debug']; - } else { - $data['payment_pp_payflow_iframe_debug'] = $this->config->get('payment_pp_payflow_iframe_debug'); - } - - $data['post_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_payflow_iframe/paymentipn'; - $data['cancel_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_payflow_iframe/paymentcancel'; - $data['error_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_payflow_iframe/paymenterror'; - $data['return_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_payflow_iframe/paymentreturn'; - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow_iframe', $data)); - } - - public function install() { - $this->load->model('extension/payment/pp_payflow_iframe'); - - $this->model_extension_payment_pp_payflow_iframe->install(); - } - - public function uninstall() { - $this->load->model('extension/payment/pp_payflow_iframe'); - - $this->model_extension_payment_pp_payflow_iframe->uninstall(); - } - - public function refund() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->model('sale/order'); - $this->load->language('extension/payment/pp_payflow_iframe'); - - $transaction = $this->model_extension_payment_pp_payflow_iframe->getTransaction($this->request->get['transaction_reference']); - - if ($transaction) { - $this->document->setTitle($this->language->get('heading_refund')); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_refund'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe/refund', 'transaction_reference=' . $this->request->get['transaction_reference'] . '&user_token=' . $this->session->data['user_token'], true) - ); - - $data['transaction_reference'] = $transaction['transaction_reference']; - $data['transaction_amount'] = number_format($transaction['amount'], 2); - $data['cancel'] = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $transaction['order_id'], true); - - $data['user_token'] = $this->session->data['user_token']; - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow_iframe_refund', $data)); - } else { - return $this->forward('error/not_found'); - } - } - - public function doRefund() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->language('extension/payment/pp_payflow_iframe'); - $json = array(); - - if (isset($this->request->post['transaction_reference']) && isset($this->request->post['amount'])) { - - $transaction = $this->model_extension_payment_pp_payflow_iframe->getTransaction($this->request->post['transaction_reference']); - - if ($transaction) { - $call_data = array( - 'TRXTYPE' => 'C', - 'TENDER' => 'C', - 'ORIGID' => $transaction['transaction_reference'], - 'AMT' => $this->request->post['amount'], - ); - - $result = $this->model_extension_payment_pp_payflow_iframe->call($call_data); - - if ($result['RESULT'] == 0) { - $json['success'] = $this->language->get('text_refund_issued'); - - $data = array( - 'order_id' => $transaction['order_id'], - 'type' => 'C', - 'transaction_reference' => $result['PNREF'], - 'amount' => $this->request->post['amount'], - ); - - $this->model_extension_payment_pp_payflow_iframe->addTransaction($data); - } else { - $json['error'] = $result['RESPMSG']; - } - } else { - $json['error'] = $this->language->get('error_missing_order'); - } - } else { - $json['error'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function capture() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->model('sale/order'); - $this->load->language('extension/payment/pp_payflow_iframe'); - - if (isset($this->request->post['order_id']) && isset($this->request->post['amount']) && isset($this->request->post['complete'])) { - $order_id = $this->request->post['order_id']; - $paypal_order = $this->model_extension_payment_pp_payflow_iframe->getOrder($order_id); - $paypal_transactions = $this->model_extension_payment_pp_payflow_iframe->getTransactions($order_id); - $order_info = $this->model_sale_order->getOrder($order_id); - - if ($paypal_order && $order_info) { - if ($this->request->post['complete'] == 1) { - $complete = 'Y'; - } else { - $complete = 'N'; - } - - $call_data = array( - 'TRXTYPE' => 'D', - 'TENDER' => 'C', - 'ORIGID' => $paypal_order['transaction_reference'], - 'AMT' => $this->request->post['amount'], - 'CAPTURECOMPLETE' => $complete - ); - - $result = $this->model_extension_payment_pp_payflow_iframe->call($call_data); - - if ($result['RESULT'] == 0) { - - $data = array( - 'order_id' => $order_id, - 'type' => 'D', - 'transaction_reference' => $result['PNREF'], - 'amount' => $this->request->post['amount'] - ); - - $this->model_extension_payment_pp_payflow_iframe->addTransaction($data); - $this->model_extension_payment_pp_payflow_iframe->updateOrderStatus($order_id, $this->request->post['complete']); - - $actions = array(); - - $actions[] = array( - 'title' => $this->language->get('text_capture'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe/refund', 'transaction_reference=' . $result['PNREF'] . '&user_token=' . $this->session->data['user_token'], true), - ); - - $json['success'] = array( - 'transaction_type' => $this->language->get('text_capture'), - 'transaction_reference' => $result['PNREF'], - 'time' => date('Y-m-d H:i:s'), - 'amount' => number_format($this->request->post['amount'], 2), - 'actions' => $actions, - ); - } else { - $json['error'] = $result['RESPMSG']; - } - } else { - $json['error'] = $this->language->get('error_missing_order'); - } - } else { - $json['error'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function void() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->language('extension/payment/pp_payflow_iframe'); - - if (isset($this->request->post['order_id']) && $this->request->post['order_id'] != '') { - $order_id = $this->request->post['order_id']; - $paypal_order = $this->model_extension_payment_pp_payflow_iframe->getOrder($order_id); - - if ($paypal_order) { - $call_data = array( - 'TRXTYPE' => 'V', - 'TENDER' => 'C', - 'ORIGID' => $paypal_order['transaction_reference'], - ); - - $result = $this->model_extension_payment_pp_payflow_iframe->call($call_data); - - if ($result['RESULT'] == 0) { - $json['success'] = $this->language->get('text_void_success'); - $this->model_extension_payment_pp_payflow_iframe->updateOrderStatus($order_id, 1); - - $data = array( - 'order_id' => $order_id, - 'type' => 'V', - 'transaction_reference' => $result['PNREF'], - 'amount' => '', - ); - - $this->model_extension_payment_pp_payflow_iframe->addTransaction($data); - $this->model_extension_payment_pp_payflow_iframe->updateOrderStatus($order_id, 1); - - $json['success'] = array( - 'transaction_type' => $this->language->get('text_void'), - 'transaction_reference' => $result['PNREF'], - 'time' => date('Y-m-d H:i:s'), - 'amount' => '0.00', - ); - } else { - $json['error'] = $result['RESPMSG']; - } - } else { - $json['error'] = $this->language->get('error_missing_order'); - } - } else { - $json['error'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function order() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->language('extension/payment/pp_payflow_iframe'); - - $order_id = $this->request->get['order_id']; - - $paypal_order = $this->model_extension_payment_pp_payflow_iframe->getOrder($order_id); - - if ($paypal_order) { - $data['complete'] = $paypal_order['complete']; - - $data['order_id'] = (int)$this->request->get['order_id']; - - $data['user_token'] = $this->session->data['user_token']; - - $data['transactions'] = array(); - - $transactions = $this->model_extension_payment_pp_payflow_iframe->getTransactions($order_id); - - foreach ($transactions as $transaction) { - $actions = array(); - - switch ($transaction['transaction_type']) { - case 'V': - $transaction_type = $this->language->get('text_void'); - break; - case 'S': - $transaction_type = $this->language->get('text_sale'); - - $actions[] = array( - 'title' => $this->language->get('text_refund'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe/refund', 'transaction_reference=' . $transaction['transaction_reference'] . '&user_token=' . $this->session->data['user_token'], true), - ); - break; - case 'D': - $transaction_type = $this->language->get('text_capture'); - - $actions[] = array( - 'title' => $this->language->get('text_refund'), - 'href' => $this->url->link('extension/payment/pp_payflow_iframe/refund', 'transaction_reference=' . $transaction['transaction_reference'] . '&user_token=' . $this->session->data['user_token'], true), - ); - break; - case 'A': - $transaction_type = $this->language->get('text_authorise'); - break; - - case 'C': - $transaction_type = $this->language->get('text_refund');# - break; - - default: - $transaction_type = ''; - break; - } - - $data['transactions'][] = array( - 'transaction_reference' => $transaction['transaction_reference'], - 'transaction_type' => $transaction_type, - 'time' => $transaction['time'], - 'amount' => $transaction['amount'], - 'actions' => $actions - ); - } - - return $this->load->view('extension/payment/pp_payflow_iframe_order', $data); - } - } - - protected function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_payflow_iframe')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if (!$this->request->post['payment_pp_payflow_iframe_vendor']) { - $this->error['vendor'] = $this->language->get('error_vendor'); - } - - if (!$this->request->post['payment_pp_payflow_iframe_user']) { - $this->error['user'] = $this->language->get('error_user'); - } - - if (!$this->request->post['payment_pp_payflow_iframe_password']) { - $this->error['password'] = $this->language->get('error_password'); - } - - if (!$this->request->post['payment_pp_payflow_iframe_partner']) { - $this->error['partner'] = $this->language->get('error_partner'); - } - - return !$this->error; - } -} diff --git a/upload/admin/controller/extension/payment/pp_pro.php b/upload/admin/controller/extension/payment/pp_pro.php deleted file mode 100644 index 77ab2d7be27..00000000000 --- a/upload/admin/controller/extension/payment/pp_pro.php +++ /dev/null @@ -1,159 +0,0 @@ -load->language('extension/payment/pp_pro'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_pro', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['username'])) { - $data['error_username'] = $this->error['username']; - } else { - $data['error_username'] = ''; - } - - if (isset($this->error['password'])) { - $data['error_password'] = $this->error['password']; - } else { - $data['error_password'] = ''; - } - - if (isset($this->error['signature'])) { - $data['error_signature'] = $this->error['signature']; - } else { - $data['error_signature'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_pro', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['action'] = $this->url->link('extension/payment/pp_pro', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_pro_username'])) { - $data['payment_pp_pro_username'] = $this->request->post['payment_pp_pro_username']; - } else { - $data['payment_pp_pro_username'] = $this->config->get('payment_pp_pro_username'); - } - - if (isset($this->request->post['payment_pp_pro_password'])) { - $data['payment_pp_pro_password'] = $this->request->post['payment_pp_pro_password']; - } else { - $data['payment_pp_pro_password'] = $this->config->get('payment_pp_pro_password'); - } - - if (isset($this->request->post['payment_pp_pro_signature'])) { - $data['payment_pp_pro_signature'] = $this->request->post['payment_pp_pro_signature']; - } else { - $data['payment_pp_pro_signature'] = $this->config->get('payment_pp_pro_signature'); - } - - if (isset($this->request->post['payment_pp_pro_test'])) { - $data['payment_pp_pro_test'] = $this->request->post['payment_pp_pro_test']; - } else { - $data['payment_pp_pro_test'] = $this->config->get('payment_pp_pro_test'); - } - - if (isset($this->request->post['payment_pp_pro_transaction'])) { - $data['payment_pp_pro_transaction'] = $this->request->post['payment_pp_pro_transaction']; - } else { - $data['payment_pp_pro_transaction'] = $this->config->get('payment_pp_pro_transaction'); - } - - if (isset($this->request->post['payment_pp_pro_total'])) { - $data['payment_pp_pro_total'] = $this->request->post['payment_pp_pro_total']; - } else { - $data['payment_pp_pro_total'] = $this->config->get('payment_pp_pro_total'); - } - - if (isset($this->request->post['payment_pp_pro_order_status_id'])) { - $data['payment_pp_pro_order_status_id'] = $this->request->post['payment_pp_pro_order_status_id']; - } else { - $data['payment_pp_pro_order_status_id'] = $this->config->get('payment_pp_pro_order_status_id'); - } - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_pro_geo_zone_id'])) { - $data['payment_pp_pro_geo_zone_id'] = $this->request->post['payment_pp_pro_geo_zone_id']; - } else { - $data['payment_pp_pro_geo_zone_id'] = $this->config->get('payment_pp_pro_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_pro_status'])) { - $data['payment_pp_pro_status'] = $this->request->post['payment_pp_pro_status']; - } else { - $data['payment_pp_pro_status'] = $this->config->get('payment_pp_pro_status'); - } - - if (isset($this->request->post['payment_pp_pro_sort_order'])) { - $data['payment_pp_pro_sort_order'] = $this->request->post['payment_pp_pro_sort_order']; - } else { - $data['payment_pp_pro_sort_order'] = $this->config->get('payment_pp_pro_sort_order'); - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_pro', $data)); - } - - protected function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_pro')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if (!$this->request->post['payment_pp_pro_username']) { - $this->error['username'] = $this->language->get('error_username'); - } - - if (!$this->request->post['payment_pp_pro_password']) { - $this->error['password'] = $this->language->get('error_password'); - } - - if (!$this->request->post['payment_pp_pro_signature']) { - $this->error['signature'] = $this->language->get('error_signature'); - } - - return !$this->error; - } -} \ No newline at end of file diff --git a/upload/admin/controller/extension/payment/pp_pro_iframe.php b/upload/admin/controller/extension/payment/pp_pro_iframe.php deleted file mode 100644 index 8b90c59b6c5..00000000000 --- a/upload/admin/controller/extension/payment/pp_pro_iframe.php +++ /dev/null @@ -1,771 +0,0 @@ -load->language('extension/payment/pp_pro_iframe'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_pro_iframe', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } else { - $data['error'] = @$this->error; - } - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_pro_iframe', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['action'] = $this->url->link('extension/payment/pp_pro_iframe', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_pro_iframe_sig'])) { - $data['payment_pp_pro_iframe_sig'] = $this->request->post['payment_pp_pro_iframe_sig']; - } else { - $data['payment_pp_pro_iframe_sig'] = $this->config->get('payment_pp_pro_iframe_sig'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_user'])) { - $data['payment_pp_pro_iframe_user'] = $this->request->post['payment_pp_pro_iframe_user']; - } else { - $data['payment_pp_pro_iframe_user'] = $this->config->get('payment_pp_pro_iframe_user'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_password'])) { - $data['payment_pp_pro_iframe_password'] = $this->request->post['payment_pp_pro_iframe_password']; - } else { - $data['payment_pp_pro_iframe_password'] = $this->config->get('payment_pp_pro_iframe_password'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_transaction_method'])) { - $data['payment_pp_pro_iframe_transaction_method'] = $this->request->post['payment_pp_pro_iframe_transaction_method']; - } else { - $data['payment_pp_pro_iframe_transaction_method'] = $this->config->get('payment_pp_pro_iframe_transaction_method'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_test'])) { - $data['payment_pp_pro_iframe_test'] = $this->request->post['payment_pp_pro_iframe_test']; - } else { - $data['payment_pp_pro_iframe_test'] = $this->config->get('payment_pp_pro_iframe_test'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_total'])) { - $data['payment_pp_pro_iframe_total'] = $this->request->post['payment_pp_pro_iframe_total']; - } else { - $data['payment_pp_pro_iframe_total'] = $this->config->get('payment_pp_pro_iframe_total'); - } - - $this->load->model('localisation/order_status'); - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_pro_iframe_canceled_reversal_status_id'])) { - $data['payment_pp_pro_iframe_canceled_reversal_status_id'] = $this->request->post['payment_pp_pro_iframe_canceled_reversal_status_id']; - } else { - $data['payment_pp_pro_iframe_canceled_reversal_status_id'] = $this->config->get('payment_pp_pro_iframe_canceled_reversal_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_completed_status_id'])) { - $data['payment_pp_pro_iframe_completed_status_id'] = $this->request->post['payment_pp_pro_iframe_completed_status_id']; - } else { - $data['payment_pp_pro_iframe_completed_status_id'] = $this->config->get('payment_pp_pro_iframe_completed_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_denied_status_id'])) { - $data['payment_pp_pro_iframe_denied_status_id'] = $this->request->post['payment_pp_pro_iframe_denied_status_id']; - } else { - $data['payment_pp_pro_iframe_denied_status_id'] = $this->config->get('payment_pp_pro_iframe_denied_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_expired_status_id'])) { - $data['payment_pp_pro_iframe_expired_status_id'] = $this->request->post['payment_pp_pro_iframe_expired_status_id']; - } else { - $data['payment_pp_pro_iframe_expired_status_id'] = $this->config->get('payment_pp_pro_iframe_expired_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_failed_status_id'])) { - $data['payment_pp_pro_iframe_failed_status_id'] = $this->request->post['payment_pp_pro_iframe_failed_status_id']; - } else { - $data['payment_pp_pro_iframe_failed_status_id'] = $this->config->get('payment_pp_pro_iframe_failed_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_pending_status_id'])) { - $data['payment_pp_pro_iframe_pending_status_id'] = $this->request->post['payment_pp_pro_iframe_pending_status_id']; - } else { - $data['payment_pp_pro_iframe_pending_status_id'] = $this->config->get('payment_pp_pro_iframe_pending_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_processed_status_id'])) { - $data['payment_pp_pro_iframe_processed_status_id'] = $this->request->post['payment_pp_pro_iframe_processed_status_id']; - } else { - $data['payment_pp_pro_iframe_processed_status_id'] = $this->config->get('payment_pp_pro_iframe_processed_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_processed_status_id'])) { - $data['payment_pp_pro_iframe_processed_status_id'] = $this->request->post['payment_pp_pro_iframe_processed_status_id']; - } else { - $data['payment_pp_pro_iframe_processed_status_id'] = $this->config->get('payment_pp_pro_iframe_processed_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_reversed_status_id'])) { - $data['payment_pp_pro_iframe_reversed_status_id'] = $this->request->post['payment_pp_pro_iframe_reversed_status_id']; - } else { - $data['payment_pp_pro_iframe_reversed_status_id'] = $this->config->get('payment_pp_pro_iframe_reversed_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_voided_status_id'])) { - $data['payment_pp_pro_iframe_voided_status_id'] = $this->request->post['payment_pp_pro_iframe_voided_status_id']; - } else { - $data['payment_pp_pro_iframe_voided_status_id'] = $this->config->get('payment_pp_pro_iframe_voided_status_id'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_geo_zone_id'])) { - $data['payment_pp_pro_iframe_geo_zone_id'] = $this->request->post['payment_pp_pro_iframe_geo_zone_id']; - } else { - $data['payment_pp_pro_iframe_geo_zone_id'] = $this->config->get('payment_pp_pro_iframe_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_pro_iframe_status'])) { - $data['payment_pp_pro_iframe_status'] = $this->request->post['payment_pp_pro_iframe_status']; - } else { - $data['payment_pp_pro_iframe_status'] = $this->config->get('payment_pp_pro_iframe_status'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_sort_order'])) { - $data['payment_pp_pro_iframe_sort_order'] = $this->request->post['payment_pp_pro_iframe_sort_order']; - } else { - $data['payment_pp_pro_iframe_sort_order'] = $this->config->get('payment_pp_pro_iframe_sort_order'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_checkout_method'])) { - $data['payment_pp_pro_iframe_checkout_method'] = $this->request->post['payment_pp_pro_iframe_checkout_method']; - } else { - $data['payment_pp_pro_iframe_checkout_method'] = $this->config->get('payment_pp_pro_iframe_checkout_method'); - } - - if (isset($this->request->post['payment_pp_pro_iframe_debug'])) { - $data['payment_pp_pro_iframe_debug'] = $this->request->post['payment_pp_pro_iframe_debug']; - } else { - $data['payment_pp_pro_iframe_debug'] = $this->config->get('payment_pp_pro_iframe_debug'); - } - - $data['ipn_url'] = HTTPS_CATALOG . 'index.php?route=extension/payment/pp_pro_iframe/notify'; - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_pro_iframe', $data)); - } - - public function install() { - $this->load->model('extension/payment/pp_pro_iframe'); - - $this->model_extension_payment_pp_pro_iframe->install(); - } - - public function uninstall() { - $this->load->model('extension/payment/pp_pro_iframe'); - - $this->model_extension_payment_pp_pro_iframe->uninstall(); - } - - protected function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_pro_iframe')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if (!$this->request->post['payment_pp_pro_iframe_sig']) { - $this->error['sig'] = $this->language->get('error_sig'); - } - - if (!$this->request->post['payment_pp_pro_iframe_user']) { - $this->error['user'] = $this->language->get('error_user'); - } - - if (!$this->request->post['payment_pp_pro_iframe_password']) { - $this->error['password'] = $this->language->get('error_password'); - } - - return !$this->error; - } - - public function order() { - $this->load->model('extension/payment/pp_pro_iframe'); - $this->load->language('extension/payment/pp_pro_iframe'); - - $paypal_order = $this->model_extension_payment_pp_pro_iframe->getOrder($this->request->get['order_id']); - - if ($paypal_order) { - $data['paypal_order'] = $paypal_order; - - $data['user_token'] = $this->session->data['user_token']; - - $data['order_id'] = (int)$this->request->get['order_id']; - - $captured = number_format($this->model_extension_payment_pp_pro_iframe->getTotalCaptured($data['paypal_order']['paypal_iframe_order_id']), 2); - $refunded = number_format($this->model_extension_payment_pp_pro_iframe->getTotalRefunded($data['paypal_order']['paypal_iframe_order_id']), 2); - - $data['paypal_order']['captured'] = $captured; - $data['paypal_order']['refunded'] = $refunded; - $data['paypal_order']['remaining'] = number_format($data['paypal_order']['total'] - $captured, 2); - - $data['transactions'] = array(); - - $data['view_link'] = $this->url->link('extension/payment/pp_pro_iframe/info', 'user_token=' . $this->session->data['user_token'], true); - $data['refund_link'] = $this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'], true); - $data['resend_link'] = $this->url->link('extension/payment/pp_pro_iframe/resend', 'user_token=' . $this->session->data['user_token'], true); - - $captured = number_format($this->model_extension_payment_pp_pro_iframe->getTotalCaptured($paypal_order['paypal_iframe_order_id']), 2); - $refunded = number_format($this->model_extension_payment_pp_pro_iframe->getTotalRefunded($paypal_order['paypal_iframe_order_id']), 2); - - $data['paypal_order'] = $paypal_order; - - $data['paypal_order']['captured'] = $captured; - $data['paypal_order']['refunded'] = $refunded; - $data['paypal_order']['remaining'] = number_format($paypal_order['total'] - $captured, 2); - - foreach ($paypal_order['transactions'] as $transaction) { - $data['transactions'][] = array( - 'paypal_iframe_order_transaction_id' => $transaction['paypal_iframe_order_transaction_id'], - 'transaction_id' => $transaction['transaction_id'], - 'amount' => $transaction['amount'], - 'date_added' => $transaction['date_added'], - 'payment_type' => $transaction['payment_type'], - 'payment_status' => $transaction['payment_status'], - 'pending_reason' => $transaction['pending_reason'], - 'view' => $this->url->link('extension/payment/pp_pro_iframe/info', 'user_token=' . $this->session->data['user_token'] . "&transaction_id=" . $transaction['transaction_id'] . '&order_id=' . $this->request->get['order_id'], true), - 'refund' => $this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'] . "&transaction_id=" . $transaction['transaction_id'] . "&order_id=" . $this->request->get['order_id'], true), - 'resend' => $this->url->link('extension/payment/pp_pro_iframe/resend', 'user_token=' . $this->session->data['user_token'] . "&paypal_iframe_order_transaction_id=" . $transaction['paypal_iframe_order_transaction_id'], true), - ); - } - - $data['reauthorise_link'] = $this->url->link('extension/payment/pp_pro_iframe/reauthorise', 'user_token=' . $this->session->data['user_token'], true); - - return $this->load->view('extension/payment/pp_pro_iframe_order', $data); - } - } - - public function refund() { - $this->load->language('extension/payment/pp_pro_iframe'); - $this->load->model('extension/payment/pp_pro_iframe'); - - $this->document->setTitle($this->language->get('text_refund')); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_pro_iframe', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_refund'), - 'href' => $this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'], true) - ); - - //button actions - $data['action'] = $this->url->link('extension/payment/pp_pro_iframe/doRefund', 'user_token=' . $this->session->data['user_token'], true); - - if (isset($this->request->get['order_id'])) { - $data['cancel'] = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $this->request->get['order_id'], true); - } else { - $data['cancel'] = ''; - } - - $data['transaction_id'] = $this->request->get['transaction_id']; - - $pp_transaction = $this->model_extension_payment_pp_pro_iframe->getTransaction($this->request->get['transaction_id']); - - $data['amount_original'] = $pp_transaction['AMT']; - $data['currency_code'] = $pp_transaction['CURRENCYCODE']; - - $refunded = number_format($this->model_extension_payment_pp_pro_iframe->getTotalRefundedTransaction($this->request->get['transaction_id']), 2); - - if ($refunded != 0.00) { - $data['refund_available'] = number_format($data['amount_original'] + $refunded, 2); - $data['attention'] = $this->language->get('text_current_refunds') . ': ' . $data['refund_available']; - } else { - $data['refund_available'] = ''; - $data['attention'] = ''; - } - - $data['user_token'] = $this->session->data['user_token']; - - if (isset($this->session->data['error'])) { - $data['error'] = $this->session->data['error']; - unset($this->session->data['error']); - } else { - $data['error'] = ''; - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_pro_iframe_refund', $data)); - } - - public function doRefund() { - /** - * used to issue a refund for a captured payment - * - * refund can be full or partial - */ - if (isset($this->request->post['transaction_id']) && isset($this->request->post['refund_full'])) { - - $this->load->model('extension/payment/pp_pro_iframe'); - $this->load->language('extension/payment/pp_pro_iframe'); - - if ($this->request->post['refund_full'] == 0 && $this->request->post['amount'] == 0) { - $this->session->data['error'] = $this->language->get('error_capture'); - $this->response->redirect($this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } else { - $order_id = $this->model_extension_payment_pp_pro_iframe->getOrderId($this->request->post['transaction_id']); - $paypal_order = $this->model_extension_payment_pp_pro_iframe->getOrder($order_id); - - if ($paypal_order) { - $call_data = array(); - $call_data['METHOD'] = 'RefundTransaction'; - $call_data['TRANSACTIONID'] = $this->request->post['transaction_id']; - $call_data['NOTE'] = urlencode($this->request->post['refund_message']); - $call_data['MSGSUBID'] = uniqid(mt_rand(), true); - - $current_transaction = $this->model_extension_payment_pp_pro_iframe->getLocalTransaction($this->request->post['transaction_id']); - - if ($this->request->post['refund_full'] == 1) { - $call_data['REFUNDTYPE'] = 'Full'; - } else { - $call_data['REFUNDTYPE'] = 'Partial'; - $call_data['AMT'] = number_format($this->request->post['amount'], 2); - $call_data['CURRENCYCODE'] = $this->request->post['currency_code']; - } - - $result = $this->model_extension_payment_pp_pro_iframe->call($call_data); - - $transaction = array( - 'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'], - 'transaction_id' => '', - 'parent_id' => $this->request->post['transaction_id'], - 'note' => $this->request->post['refund_message'], - 'msgsubid' => $call_data['MSGSUBID'], - 'receipt_id' => '', - 'payment_type' => '', - 'payment_status' => 'Refunded', - 'transaction_entity' => 'payment', - 'pending_reason' => '', - 'amount' => '-' . (isset($call_data['AMT']) ? $call_data['AMT'] : $current_transaction['amount']), - 'debug_data' => json_encode($result) - ); - - if ($result == false) { - $transaction['payment_status'] = 'Failed'; - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction, $call_data); - $this->response->redirect($this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $paypal_order['order_id'], true)); - } else if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') { - - $transaction['transaction_id'] = $result['REFUNDTRANSACTIONID']; - $transaction['payment_type'] = $result['REFUNDSTATUS']; - $transaction['pending_reason'] = $result['PENDINGREASON']; - $transaction['amount'] = '-' . $result['GROSSREFUNDAMT']; - - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction); - - if ($result['TOTALREFUNDEDAMOUNT'] == $this->request->post['amount_original']) { - $this->model_extension_payment_pp_pro_iframe->updateRefundTransaction($this->request->post['transaction_id'], 'Refunded'); - } else { - $this->model_extension_payment_pp_pro_iframe->updateRefundTransaction($this->request->post['transaction_id'], 'Partially-Refunded'); - } - - //redirect back to the order - $this->response->redirect($this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $paypal_order['order_id'], true)); - } else { - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write(json_encode($result)); - } - - $this->session->data['error'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : 'There was an error') . (isset($result['L_LONGMESSAGE0']) ? '
' . $result['L_LONGMESSAGE0'] : ''); - $this->response->redirect($this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } else { - $this->session->data['error'] = $this->language->get('error_data_missing'); - $this->response->redirect($this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } - } else { - $this->session->data['error'] = $this->language->get('error_data'); - $this->response->redirect($this->url->link('extension/payment/pp_pro_iframe/refund', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->post['transaction_id'], true)); - } - } - - public function reauthorise() { - $this->load->language('extension/payment/pp_pro_iframe'); - $this->load->model('extension/payment/pp_pro_iframe'); - - $json = array(); - - if (isset($this->request->post['order_id'])) { - $paypal_order = $this->model_extension_payment_pp_pro_iframe->getOrder($this->request->post['order_id']); - - $call_data = array(); - $call_data['METHOD'] = 'DoReauthorization'; - $call_data['AUTHORIZATIONID'] = $paypal_order['authorization_id']; - $call_data['AMT'] = number_format($paypal_order['total'], 2); - $call_data['CURRENCYCODE'] = $paypal_order['currency_code']; - - $result = $this->model_extension_payment_pp_pro_iframe->call($call_data); - - if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') { - $this->model_extension_payment_pp_pro_iframe->updateAuthorizationId($paypal_order['paypal_iframe_order_id'], $result['AUTHORIZATIONID']); - - $transaction = array( - 'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'], - 'transaction_id' => '', - 'parent_id' => $paypal_order['authorization_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => '', - 'payment_type' => 'instant', - 'payment_status' => $result['PAYMENTSTATUS'], - 'transaction_entity' => 'auth', - 'pending_reason' => $result['PENDINGREASON'], - 'amount' => '-' . '', - 'debug_data' => json_encode($result) - ); - - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction); - - $transaction['date_added'] = date("Y-m-d H:i:s"); - - $json['data'] = $transaction; - $json['error'] = false; - $json['msg'] = 'Ok'; - } else { - $json['error'] = true; - $json['msg'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : $this->language->get('error_general')); - } - } else { - $json['error'] = true; - $json['msg'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function info() { - $this->load->model('extension/payment/pp_pro_iframe'); - $this->load->language('extension/payment/pp_pro_iframe'); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_pro_iframe', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_transaction'), - 'href' => $this->url->link('extension/payment/pp_pro_iframe/info', 'user_token=' . $this->session->data['user_token'] . '&transaction_id=' . $this->request->get['transaction_id'], true) - ); - - $transaction = $this->model_extension_payment_pp_pro_iframe->getTransaction($this->request->get['transaction_id']); - $transaction = array_map('urldecode', $transaction); - - $data['transaction'] = $transaction; - $data['view_link'] = $this->url->link('extension/payment/pp_pro_iframe/info', 'user_token=' . $this->session->data['user_token'], true); - $data['user_token'] = $this->session->data['user_token']; - - $this->document->setTitle($this->language->get('text_transaction')); - - if (isset($this->request->get['order_id'])) { - $data['back'] = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $this->request->get['order_id'], true); - } else { - $data['back'] = ''; - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_pro_iframe_transaction', $data)); - } - - public function capture() { - $this->load->language('extension/payment/pp_pro_iframe'); - /* - * used to capture authorised payments - * capture can be full or partial amounts - */ - if (isset($this->request->post['order_id']) && $this->request->post['amount'] > 0 && isset($this->request->post['order_id']) && isset($this->request->post['complete'])) { - - $this->load->model('extension/payment/pp_pro_iframe'); - - $paypal_order = $this->model_extension_payment_pp_pro_iframe->getOrder($this->request->post['order_id']); - - if ($this->request->post['complete'] == 1) { - $complete = 'Complete'; - } else { - $complete = 'NotComplete'; - } - - $call_data = array(); - $call_data['METHOD'] = 'DoCapture'; - $call_data['AUTHORIZATIONID'] = $paypal_order['authorization_id']; - $call_data['AMT'] = number_format($this->request->post['amount'], 2); - $call_data['CURRENCYCODE'] = $paypal_order['currency_code']; - $call_data['COMPLETETYPE'] = $complete; - $call_data['MSGSUBID'] = uniqid(mt_rand(), true); - - $result = $this->model_extension_payment_pp_pro_iframe->call($call_data); - - $transaction = array( - 'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'], - 'transaction_id' => '', - 'parent_id' => $paypal_order['authorization_id'], - 'note' => '', - 'msgsubid' => $call_data['MSGSUBID'], - 'receipt_id' => '', - 'payment_type' => '', - 'payment_status' => '', - 'pending_reason' => '', - 'transaction_entity' => 'payment', - 'amount' => '', - 'debug_data' => json_encode($result) - ); - - if ($result == false) { - $transaction['amount'] = number_format($this->request->post['amount'], 2); - $paypal_iframe_order_transaction_id = $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction, $call_data); - - $json['error'] = true; - - $json['failed_transaction']['paypal_iframe_order_transaction_id'] = $paypal_iframe_order_transaction_id; - $json['failed_transaction']['amount'] = $transaction['amount']; - $json['failed_transaction']['date_added'] = date("Y-m-d H:i:s"); - - $json['msg'] = $this->language->get('error_timeout'); - } else if (isset($result['ACK']) && $result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') { - $transaction['transaction_id'] = $result['TRANSACTIONID']; - $transaction['payment_type'] = $result['PAYMENTTYPE']; - $transaction['payment_status'] = $result['PAYMENTSTATUS']; - $transaction['pending_reason'] = (isset($result['PENDINGREASON']) ? $result['PENDINGREASON'] : ''); - $transaction['amount'] = $result['AMT']; - - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction); - - unset($transaction['debug_data']); - $transaction['date_added'] = date("Y-m-d H:i:s"); - - $captured = number_format($this->model_extension_payment_pp_pro_iframe->getTotalCaptured($paypal_order['paypal_iframe_order_id']), 2); - $refunded = number_format($this->model_extension_payment_pp_pro_iframe->getTotalRefunded($paypal_order['paypal_iframe_order_id']), 2); - - $transaction['captured'] = $captured; - $transaction['refunded'] = $refunded; - $transaction['remaining'] = number_format($paypal_order['total'] - $captured, 2); - - $transaction['status'] = 0; - if ($transaction['remaining'] == 0.00) { - $transaction['status'] = 1; - $this->model_extension_payment_pp_pro_iframe->updateOrder('Complete', $this->request->post['order_id']); - } - - $transaction['void'] = ''; - - if ($this->request->post['complete'] == 1 && $transaction['remaining'] > 0) { - $transaction['void'] = array( - 'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'], - 'transaction_id' => '', - 'parent_id' => $paypal_order['authorization_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => '', - 'payment_type' => '', - 'payment_status' => 'Void', - 'pending_reason' => '', - 'amount' => '', - 'debug_data' => 'Voided after capture', - 'transaction_entity' => 'auth', - ); - - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction['void']); - $this->model_extension_payment_pp_pro_iframe->updateOrder('Complete', $this->request->post['order_id']); - $transaction['void']['date_added'] = date("Y-m-d H:i:s"); - $transaction['status'] = 1; - } - - $json['data'] = $transaction; - $json['error'] = false; - $json['msg'] = 'Ok'; - } else { - $json['error'] = true; - $json['msg'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : 'There was an error'); - } - } else { - $json['error'] = true; - $json['msg'] = 'Missing data'; - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function void() { - $this->load->language('extension/payment/pp_pro_iframe'); - - if (isset($this->request->post['order_id']) && $this->request->post['order_id'] != '') { - $this->load->model('extension/payment/pp_pro_iframe'); - - $paypal_order = $this->model_extension_payment_pp_pro_iframe->getOrder($this->request->post['order_id']); - - $call_data = array(); - $call_data['METHOD'] = 'DoVoid'; - $call_data['AUTHORIZATIONID'] = $paypal_order['authorization_id']; - - $result = $this->model_extension_payment_pp_pro_iframe->call($call_data); - - if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') { - $transaction = array( - 'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'], - 'transaction_id' => '', - 'parent_id' => $paypal_order['authorization_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => '', - 'payment_type' => 'void', - 'payment_status' => 'Void', - 'pending_reason' => '', - 'transaction_entity' => 'auth', - 'amount' => '', - 'debug_data' => json_encode($result) - ); - - $this->model_extension_payment_pp_pro_iframe->addTransaction($transaction); - $this->model_extension_payment_pp_pro_iframe->updateOrder('Complete', $this->request->post['order_id']); - - unset($transaction['debug_data']); - $transaction['date_added'] = date("Y-m-d H:i:s"); - - $json['data'] = $transaction; - $json['error'] = false; - $json['msg'] = 'Transaction void'; - } else { - $json['error'] = true; - $json['msg'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : $this->language->get('error_general')); - } - } else { - $json['error'] = true; - $json['msg'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function resend() { - $this->load->model('extension/payment/pp_pro_iframe'); - $this->load->language('extension/payment/pp_pro_iframe'); - - $json = array(); - - if (isset($this->request->get['paypal_iframe_order_transaction_id'])) { - $transaction = $this->model_extension_payment_pp_pro_iframe->getFailedTransaction($this->request->get['paypal_iframe_order_transaction_id']); - - if ($transaction) { - $call_data = json_decode($transaction['call_data'], true); - - $result = $this->model_extension_payment_pp_pro_iframe->call($call_data); - - if ($result) { - $parent_transaction = $this->model_extension_payment_pp_pro_iframe->getLocalTransaction($transaction['parent_id']); - - if ($parent_transaction['amount'] == abs($transaction['amount'])) { - $this->model_extension_payment_pp_pro_iframe->updateRefundTransaction($transaction['parent_id'], 'Refunded'); - } else { - $this->model_extension_payment_pp_pro_iframe->updateRefundTransaction($transaction['parent_id'], 'Partially-Refunded'); - } - - if (isset($result['REFUNDTRANSACTIONID'])) { - $transaction['transaction_id'] = $result['REFUNDTRANSACTIONID']; - } else { - $transaction['transaction_id'] = $result['TRANSACTIONID']; - } - - if (isset($result['PAYMENTTYPE'])) { - $transaction['payment_type'] = $result['PAYMENTTYPE']; - } else { - $transaction['payment_type'] = $result['REFUNDSTATUS']; - } - - if (isset($result['PAYMENTSTATUS'])) { - $transaction['payment_status'] = $result['PAYMENTSTATUS']; - } else { - $transaction['payment_status'] = 'Refunded'; - } - - if (isset($result['AMT'])) { - $transaction['amount'] = $result['AMT']; - } else { - $transaction['amount'] = $transaction['amount']; - } - - $transaction['pending_reason'] = (isset($result['PENDINGREASON']) ? $result['PENDINGREASON'] : ''); - - $this->model_extension_payment_pp_pro_iframe->updateTransaction($transaction); - - $json['success'] = $this->language->get('success_transaction_resent'); - } else { - $json['error'] = $this->language->get('error_timeout'); - } - } else { - $json['error'] = $this->language->get('error_transaction_missing'); - } - } else { - $json['error'] = $this->language->get('error_missing_data'); - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } -} \ No newline at end of file diff --git a/upload/admin/controller/extension/payment/pp_standard.php b/upload/admin/controller/extension/payment/pp_standard.php deleted file mode 100644 index ba9acd898cb..00000000000 --- a/upload/admin/controller/extension/payment/pp_standard.php +++ /dev/null @@ -1,187 +0,0 @@ -load->language('extension/payment/pp_standard'); - - $this->document->setTitle($this->language->get('heading_title')); - - $this->load->model('setting/setting'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { - $this->model_setting_setting->editSetting('payment_pp_standard', $this->request->post); - - $this->session->data['success'] = $this->language->get('text_success'); - - $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)); - } - - if (isset($this->error['warning'])) { - $data['error_warning'] = $this->error['warning']; - } else { - $data['error_warning'] = ''; - } - - if (isset($this->error['email'])) { - $data['error_email'] = $this->error['email']; - } else { - $data['error_email'] = ''; - } - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_home'), - 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_extension'), - 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('heading_title'), - 'href' => $this->url->link('extension/payment/pp_standard', 'user_token=' . $this->session->data['user_token'], true) - ); - - $data['action'] = $this->url->link('extension/payment/pp_standard', 'user_token=' . $this->session->data['user_token'], true); - - $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); - - if (isset($this->request->post['payment_pp_standard_email'])) { - $data['payment_pp_standard_email'] = $this->request->post['payment_pp_standard_email']; - } else { - $data['payment_pp_standard_email'] = $this->config->get('payment_pp_standard_email'); - } - - if (isset($this->request->post['payment_pp_standard_test'])) { - $data['payment_pp_standard_test'] = $this->request->post['payment_pp_standard_test']; - } else { - $data['payment_pp_standard_test'] = $this->config->get('payment_pp_standard_test'); - } - - if (isset($this->request->post['payment_pp_standard_transaction'])) { - $data['payment_pp_standard_transaction'] = $this->request->post['payment_pp_standard_transaction']; - } else { - $data['payment_pp_standard_transaction'] = $this->config->get('payment_pp_standard_transaction'); - } - - if (isset($this->request->post['payment_pp_standard_debug'])) { - $data['payment_pp_standard_debug'] = $this->request->post['payment_pp_standard_debug']; - } else { - $data['payment_pp_standard_debug'] = $this->config->get('payment_pp_standard_debug'); - } - - if (isset($this->request->post['payment_pp_standard_total'])) { - $data['payment_pp_standard_total'] = $this->request->post['payment_pp_standard_total']; - } else { - $data['payment_pp_standard_total'] = $this->config->get('payment_pp_standard_total'); - } - - if (isset($this->request->post['payment_pp_standard_canceled_reversal_status_id'])) { - $data['payment_pp_standard_canceled_reversal_status_id'] = $this->request->post['payment_pp_standard_canceled_reversal_status_id']; - } else { - $data['payment_pp_standard_canceled_reversal_status_id'] = $this->config->get('payment_pp_standard_canceled_reversal_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_completed_status_id'])) { - $data['payment_pp_standard_completed_status_id'] = $this->request->post['payment_pp_standard_completed_status_id']; - } else { - $data['payment_pp_standard_completed_status_id'] = $this->config->get('payment_pp_standard_completed_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_denied_status_id'])) { - $data['payment_pp_standard_denied_status_id'] = $this->request->post['payment_pp_standard_denied_status_id']; - } else { - $data['payment_pp_standard_denied_status_id'] = $this->config->get('payment_pp_standard_denied_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_expired_status_id'])) { - $data['payment_pp_standard_expired_status_id'] = $this->request->post['payment_pp_standard_expired_status_id']; - } else { - $data['payment_pp_standard_expired_status_id'] = $this->config->get('payment_pp_standard_expired_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_failed_status_id'])) { - $data['payment_pp_standard_failed_status_id'] = $this->request->post['payment_pp_standard_failed_status_id']; - } else { - $data['payment_pp_standard_failed_status_id'] = $this->config->get('payment_pp_standard_failed_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_pending_status_id'])) { - $data['payment_pp_standard_pending_status_id'] = $this->request->post['payment_pp_standard_pending_status_id']; - } else { - $data['payment_pp_standard_pending_status_id'] = $this->config->get('payment_pp_standard_pending_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_processed_status_id'])) { - $data['payment_pp_standard_processed_status_id'] = $this->request->post['payment_pp_standard_processed_status_id']; - } else { - $data['payment_pp_standard_processed_status_id'] = $this->config->get('payment_pp_standard_processed_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_refunded_status_id'])) { - $data['payment_pp_standard_refunded_status_id'] = $this->request->post['payment_pp_standard_refunded_status_id']; - } else { - $data['payment_pp_standard_refunded_status_id'] = $this->config->get('payment_pp_standard_refunded_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_reversed_status_id'])) { - $data['payment_pp_standard_reversed_status_id'] = $this->request->post['payment_pp_standard_reversed_status_id']; - } else { - $data['payment_pp_standard_reversed_status_id'] = $this->config->get('payment_pp_standard_reversed_status_id'); - } - - if (isset($this->request->post['payment_pp_standard_voided_status_id'])) { - $data['payment_pp_standard_voided_status_id'] = $this->request->post['payment_pp_standard_voided_status_id']; - } else { - $data['payment_pp_standard_voided_status_id'] = $this->config->get('payment_pp_standard_voided_status_id'); - } - - $this->load->model('localisation/order_status'); - - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - - if (isset($this->request->post['payment_pp_standard_geo_zone_id'])) { - $data['payment_pp_standard_geo_zone_id'] = $this->request->post['payment_pp_standard_geo_zone_id']; - } else { - $data['payment_pp_standard_geo_zone_id'] = $this->config->get('payment_pp_standard_geo_zone_id'); - } - - $this->load->model('localisation/geo_zone'); - - $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - - if (isset($this->request->post['payment_pp_standard_status'])) { - $data['payment_pp_standard_status'] = $this->request->post['payment_pp_standard_status']; - } else { - $data['payment_pp_standard_status'] = $this->config->get('payment_pp_standard_status'); - } - - if (isset($this->request->post['payment_pp_standard_sort_order'])) { - $data['payment_pp_standard_sort_order'] = $this->request->post['payment_pp_standard_sort_order']; - } else { - $data['payment_pp_standard_sort_order'] = $this->config->get('payment_pp_standard_sort_order'); - } - - $data['header'] = $this->load->controller('common/header'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['footer'] = $this->load->controller('common/footer'); - - $this->response->setOutput($this->load->view('extension/payment/pp_standard', $data)); - } - - private function validate() { - if (!$this->user->hasPermission('modify', 'extension/payment/pp_standard')) { - $this->error['warning'] = $this->language->get('error_permission'); - } - - if (!$this->request->post['payment_pp_standard_email']) { - $this->error['email'] = $this->language->get('error_email'); - } - - return !$this->error; - } -} \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/paypal.php b/upload/admin/language/en-gb/extension/payment/paypal.php index 0fb4226ca68..cec43fbdc00 100644 --- a/upload/admin/language/en-gb/extension/payment/paypal.php +++ b/upload/admin/language/en-gb/extension/payment/paypal.php @@ -1,138 +1,287 @@ PayPal Checkout Integration (Highly Recommended)'; +$_['heading_title_main'] = 'PayPal Checkout Integration'; // Text -$_['text_paypal'] = 'PayPal Commerce Platform'; -$_['text_extensions'] = 'Extensions'; -$_['text_edit'] = 'Edit PayPal'; -$_['text_general'] = 'General'; -$_['text_order_status'] = 'Order Status'; -$_['text_checkout_express'] = 'Checkout'; -$_['text_checkout_card'] = 'Advanced Card'; -$_['text_checkout_message'] = 'Pay Later Message'; -$_['text_production'] = 'Production'; -$_['text_sandbox'] = 'Sandbox'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; -$_['text_connect'] = 'Your seller account has been connected.
Client ID = %s
Secret = %s
Merchant ID = %s
If you would like to connect another account, please, disconnect.'; -$_['text_currency_aud'] = 'Australian Dollar'; -$_['text_currency_brl'] = 'Brazilian Real'; -$_['text_currency_cad'] = 'Canadian Dollar'; -$_['text_currency_czk'] = 'Czech Krone'; -$_['text_currency_dkk'] = 'Danish Krone'; -$_['text_currency_eur'] = 'Euro'; -$_['text_currency_hkd'] = 'Hong Kong Dollar'; -$_['text_currency_huf'] = 'Hungarian Forint'; -$_['text_currency_inr'] = 'Indian Rupee'; -$_['text_currency_ils'] = 'Israeli New Shekel'; -$_['text_currency_jpy'] = 'Japanese Yen'; -$_['text_currency_myr'] = 'Malaysian Ringgit'; -$_['text_currency_mxn'] = 'Mexican Peso'; -$_['text_currency_twd'] = 'New Taiwan Dollar'; -$_['text_currency_nzd'] = 'New Zealand Dollar'; -$_['text_currency_nok'] = 'Norwegian Krone'; -$_['text_currency_php'] = 'Philippine peso'; -$_['text_currency_pln'] = 'Polish Zloty'; -$_['text_currency_gbp'] = 'Pound Sterling'; -$_['text_currency_rub'] = 'Russian Ruble'; -$_['text_currency_sgd'] = 'Singapore Dollar'; -$_['text_currency_sek'] = 'Swedish Krone'; -$_['text_currency_chf'] = 'Swiss Frank'; -$_['text_currency_thb'] = 'Thai Baht'; -$_['text_currency_usd'] = 'US Dollar'; -$_['text_completed_status'] = 'Completed Status'; -$_['text_denied_status'] = 'Denied Status'; -$_['text_failed_status'] = 'Failed Status'; -$_['text_pending_status'] = 'Pending Status'; -$_['text_refunded_status'] = 'Refunded Status'; -$_['text_reversed_status'] = 'Reversed Status'; -$_['text_voided_status'] = 'Voided Status'; -$_['text_align_left'] = 'Align Left'; -$_['text_align_center'] = 'Align Center'; -$_['text_align_right'] = 'Align Right'; -$_['text_small'] = 'Small'; -$_['text_medium'] = 'Medium'; -$_['text_large'] = 'Large'; -$_['text_responsive'] = 'Responsive'; -$_['text_gold'] = 'Gold'; -$_['text_blue'] = 'Blue'; -$_['text_silver'] = 'Silver'; -$_['text_white'] = 'White'; -$_['text_black'] = 'Black'; -$_['text_pill'] = 'Pill'; -$_['text_rect'] = 'Rect'; -$_['text_checkout'] = 'Checkout'; -$_['text_pay'] = 'Pay'; -$_['text_buy_now'] = 'Buy Now'; -$_['text_pay_pal'] = 'PayPal'; -$_['text_installment'] = 'Installment'; -$_['text_text'] = 'Text Message'; -$_['text_flex'] = 'Flexible Banner'; -$_['text_accept'] = 'Accept'; -$_['text_decline'] = 'Decline'; -$_['text_recommended'] = '(recommended)'; -$_['text_3ds_undefined'] = 'You have not required 3D Secure for the buyer or the card network did not require a 3D Secure.'; -$_['text_3ds_error'] = 'An error occurred with the 3DS authentication system.'; -$_['text_3ds_skipped_by_buyer'] = 'Buyer was presented the 3D Secure challenge but chose to skip the authentication.'; -$_['text_3ds_failure'] = 'Buyer may have failed the challenge or the device was not verified.'; -$_['text_3ds_bypassed'] = '3D Secure was skipped as authentication system did not require a challenge.'; -$_['text_3ds_attempted'] = 'Card is not enrolled in 3D Secure as card issuing bank is not participating in 3D Secure.'; -$_['text_3ds_unavailable'] = 'Issuing bank is not able to complete authentication.'; -$_['text_3ds_card_ineligible'] = 'Card is not eligible for 3DS Secure authentication.'; -$_['text_confirm'] = 'Are you sure?'; +$_['text_paypal'] = 'PayPal Checkout Integration (Highly Recommended)'; +$_['text_extensions'] = 'Extensions'; +$_['text_edit'] = 'Edit PayPal'; +$_['text_welcome'] = 'PayPal Checkout lets you offer PayPal, Venmo (US only), Pay Later options, debit & credit cards, plus local payment methods — all designed to help you maximize conversion.'; +$_['text_checkout_express'] = 'If your country is not available in the list when going through the PayPal onboarding experience please click here.'; +$_['text_support'] = 'If you face any issue during the onboarding process, please try other browser (e.g. Chrome) or clear your browser cache. If it doesn\'t help, please contact our support team.'; +$_['text_version'] = 'New PayPal Checkout Integration version available. You can download it here!'; +$_['text_tab_dashboard'] = 'Back to the dashboard'; +$_['text_tab_general'] = 'General'; +$_['text_tab_button'] = 'Buttons'; +$_['text_tab_applepay_button'] = 'ApplePay'; +$_['text_tab_card'] = 'Advanced Cards'; +$_['text_tab_message'] = 'Pay Later messaging'; +$_['text_tab_order_status'] = 'Order Statuses'; +$_['text_tab_contact'] = 'Contact PayPal'; +$_['text_all_sales'] = 'All Sales'; +$_['text_paypal_sales'] = 'PayPal Sales'; +$_['text_panel_statistic'] = 'Statistic'; +$_['text_panel_sale_analytics'] = 'Sales Analytics'; +$_['text_statistic_title'] = 'The platform that grows with you'; +$_['text_statistic_description'] = 'The platform has 416 million customers'; +$_['text_button_settings'] = 'Button settings'; +$_['text_applepay_button_settings'] = 'ApplePay Button settings'; +$_['text_card_settings'] = 'Card settings'; +$_['text_message_settings'] = 'Message settings'; +$_['text_day'] = 'Today'; +$_['text_week'] = 'Week'; +$_['text_month'] = 'Month'; +$_['text_year'] = 'Year'; +$_['text_on'] = 'On'; +$_['text_off'] = 'Off'; +$_['text_home'] = 'Home'; +$_['text_product'] = 'Product'; +$_['text_cart'] = 'Cart'; +$_['text_checkout'] = 'Checkout'; +$_['text_production'] = 'Production'; +$_['text_sandbox'] = 'Sandbox'; +$_['text_multi_button'] = 'Multi Button'; +$_['text_one_button'] = 'One Button'; +$_['text_authorization'] = 'Authorization'; +$_['text_sale'] = 'Sale'; +$_['text_connect'] = 'Your seller account has been connected.
Client ID = %s
Secret = %s
Merchant ID = %s
Webhook ID = %s
Environment = %s
If you would like to connect another account, please, disconnect.'; +$_['text_applepay_alert'] = 'You need to verify any domain names in your environment that will show an Apple Pay button.

If Apple hasn’t verified a domain, they will reject any payments from that domain. The Apple Pay payment method won’t work if the domain isn’t registered.'; +$_['text_applepay_step_1'] = 'Download and host live domain association file
1. Download the domain association file for your live environment.
2. Host the file on your production site at /.well-known/apple-developer-merchantid-domain-association.'; +$_['text_applepay_step_2'] = 'Register your live domain
1. Go to the Payment Methods page on your PayPal account.
2. Register all high-level domains such as business.example.com, and subdomains such as checkout.business.example.com, that show the Apple Pay button.'; +$_['text_message_alert_uk'] = 'Turn browsers into buyers with Pay in 3.¹ Help increase sales while giving your customers flexible payments and more buying power. With Pay in 3, customers can pay over time in three interest-free payments while you get paid in full, up front on purchases — at no additional cost.'; +$_['text_message_footnote_uk'] = '¹Pay in 3 availability is subject to merchant status, sector and integration. Consumer eligibility is subject to status and approval. See product terms for more details.'; +$_['text_message_alert_us'] = 'Help increase your sales with our built-in Pay Later options. With PayPal Pay Later, your business can offer Pay in 4 and Pay Monthly¹ — two valuable ways for your customers to make a purchase and pay for it over time while you get paid in full, up front. Both are included at no additional cost to your business.'; +$_['text_message_footnote_us'] = '¹About Pay in 4: Loans to California residents are made or arranged pursuant to a California Financing Law License. PayPal, Inc. is a Georgia Installment Lender Licensee, NMLS #910457. Rhode Island Small Loan Lender Licensee.
Pay Monthly is subject to consumer credit approval. 9.99-29.99% APR based on the customer’s creditworthiness. PayPal, Inc.: RI Loan Broker Licensee. The lender for Pay Monthly is WebBank.'; +$_['text_currency_aud'] = 'Australian Dollar'; +$_['text_currency_brl'] = 'Brazilian Real'; +$_['text_currency_cad'] = 'Canadian Dollar'; +$_['text_currency_czk'] = 'Czech Krone'; +$_['text_currency_dkk'] = 'Danish Krone'; +$_['text_currency_eur'] = 'Euro'; +$_['text_currency_hkd'] = 'Hong Kong Dollar'; +$_['text_currency_huf'] = 'Hungarian Forint'; +$_['text_currency_inr'] = 'Indian Rupee'; +$_['text_currency_ils'] = 'Israeli New Shekel'; +$_['text_currency_jpy'] = 'Japanese Yen'; +$_['text_currency_myr'] = 'Malaysian Ringgit'; +$_['text_currency_mxn'] = 'Mexican Peso'; +$_['text_currency_twd'] = 'New Taiwan Dollar'; +$_['text_currency_nzd'] = 'New Zealand Dollar'; +$_['text_currency_nok'] = 'Norwegian Krone'; +$_['text_currency_php'] = 'Philippine peso'; +$_['text_currency_pln'] = 'Polish Zloty'; +$_['text_currency_gbp'] = 'Pound Sterling'; +$_['text_currency_rub'] = 'Russian Ruble'; +$_['text_currency_sgd'] = 'Singapore Dollar'; +$_['text_currency_sek'] = 'Swedish Krone'; +$_['text_currency_chf'] = 'Swiss Frank'; +$_['text_currency_thb'] = 'Thai Baht'; +$_['text_currency_usd'] = 'US Dollar'; +$_['text_completed_status'] = 'Completed Status'; +$_['text_denied_status'] = 'Denied Status'; +$_['text_failed_status'] = 'Failed Status'; +$_['text_pending_status'] = 'Pending Status'; +$_['text_refunded_status'] = 'Refunded Status'; +$_['text_reversed_status'] = 'Reversed Status'; +$_['text_voided_status'] = 'Voided Status'; +$_['text_insert_prepend'] = 'Insert Into Begin'; +$_['text_insert_append'] = 'Insert Into End'; +$_['text_insert_before'] = 'Insert Before'; +$_['text_insert_after'] = 'Insert After'; +$_['text_align_left'] = 'Align Left'; +$_['text_align_center'] = 'Align Center'; +$_['text_align_right'] = 'Align Right'; +$_['text_small'] = 'Small'; +$_['text_medium'] = 'Medium'; +$_['text_large'] = 'Large'; +$_['text_responsive'] = 'Responsive'; +$_['text_gold'] = 'Gold'; +$_['text_blue'] = 'Blue'; +$_['text_silver'] = 'Silver'; +$_['text_white'] = 'White'; +$_['text_white_outline'] = 'White Outline'; +$_['text_black'] = 'Black'; +$_['text_pill'] = 'Pill'; +$_['text_rect'] = 'Rect'; +$_['text_checkout'] = 'Checkout'; +$_['text_pay'] = 'Pay'; +$_['text_buy_now'] = 'Buy Now'; +$_['text_pay_pal'] = 'PayPal'; +$_['text_installment'] = 'Installment'; +$_['text_buy'] = 'Buy'; +$_['text_donate'] = 'Donate'; +$_['text_plain'] = 'Plain'; +$_['text_check_out'] = 'Check out'; +$_['text_card'] = 'Credit or debit cards'; +$_['text_credit'] = 'PayPal Credit'; +$_['text_bancontact'] = 'Bancontact'; +$_['text_blik'] = 'BLIK'; +$_['text_eps'] = 'Eps'; +$_['text_giropay'] = 'Giropay'; +$_['text_ideal'] = 'iDEAL'; +$_['text_mercadopago'] = 'Mercado Pago'; +$_['text_mybank'] = 'MyBank'; +$_['text_p24'] = 'Przelewy24'; +$_['text_sepa'] = 'SEPA-Lastschrift'; +$_['text_sofort'] = 'Sofort'; +$_['text_venmo'] = 'Venmo'; +$_['text_paylater'] = 'Pay Later'; +$_['text_auto'] = 'Auto'; +$_['text_text'] = 'Text Message'; +$_['text_flex'] = 'Flexible Banner'; +$_['text_accept'] = 'Accept'; +$_['text_decline'] = 'Decline'; +$_['text_recommended'] = '(recommended)'; +$_['text_3ds_failed_authentication'] = 'Failed authentication.'; +$_['text_3ds_rejected_authentication'] = 'Rejected authentication.'; +$_['text_3ds_attempted_authentication'] = 'Attempted authentication.'; +$_['text_3ds_unable_authentication'] = 'Unable to complete authentication.'; +$_['text_3ds_challenge_authentication'] = 'Challenge required for authentication.'; +$_['text_3ds_card_ineligible'] = 'Card type and issuing bank are not ready to complete a 3D Secure authentication.'; +$_['text_3ds_system_unavailable'] = 'System is unavailable at the time of the request.'; +$_['text_3ds_system_bypassed'] = 'System has bypassed authentication.'; +$_['text_payment_method_paypal'] = 'PayPal (Pay with PayPal, Card)'; +$_['text_payment_method_paypal_paylater'] = 'Buy Now Pay Later with PayPal'; +$_['text_payment_method_cod'] = 'Cash On Delivery'; +$_['text_contact_book'] = 'Book a contact with PayPal'; +$_['text_contact_form'] = 'Fill out the form to request a call back from a PayPal sales expert'; +$_['text_contact_business'] = 'Business Information'; +$_['text_contact_product'] = 'Product Interest'; +$_['text_none'] = ' --- None --- '; +$_['text_bt_dcc'] = 'Credit Card/Debit Card Processing'; +$_['text_express_checkout'] = 'PayPal Button'; +$_['text_credit_installments'] = 'PayPal Credit'; +$_['text_point_of_sale'] = 'PayPal InStore'; +$_['text_invoicing_api'] = 'Invoicing'; +$_['text_paypal_working_capital'] = 'Working Capital/Bsuiness Loans'; +$_['text_risk_servicing'] = 'Risk Servicing'; +$_['text_paypal_here'] = 'Subscriptions'; +$_['text_payouts'] = 'Payouts'; +$_['text_marketing_solutions'] = 'Marketing Solutions'; +$_['text_confirm'] = 'Are you sure?'; +$_['text_menu_desktops'] = 'Desktops'; +$_['text_menu_laptops'] = 'Laptops'; +$_['text_menu_components'] = 'Components'; +$_['text_menu_tablets'] = 'Tablets'; +$_['text_menu_software'] = 'Software'; +$_['text_menu_cameras'] = 'Cameras'; +$_['text_product_name'] = 'Product Name'; +$_['text_product_price'] = '$33.00'; +$_['text_product_manufacturer'] = 'Brand: DLX-sd'; +$_['text_product_model'] = 'Product Code: product 11'; +$_['text_product_stock'] = 'Availability: In Stock'; +$_['text_cart_product_image'] = 'Image'; +$_['text_cart_product_name'] = 'Product Name'; +$_['text_cart_product_model'] = 'Model'; +$_['text_cart_product_quantity'] = 'Quantity'; +$_['text_cart_product_price'] = 'Unit Price'; +$_['text_cart_product_total'] = 'Total'; +$_['text_cart_product_name_value'] = 'Phone'; +$_['text_cart_product_model_value'] = 'product 11'; +$_['text_cart_product_quantity_value'] = '1'; +$_['text_cart_product_price_value'] = '$33.00'; +$_['text_cart_product_total_value'] = '$33.00'; +$_['text_cart_sub_total'] = 'Sub-Total:'; +$_['text_cart_total'] = 'Total:'; +$_['text_step_coupon'] = 'Use Coupon Code'; +$_['text_step_shipping'] = 'Estimate Shipping & Taxes'; +$_['text_step_payment_method'] = 'Step 5: Payment Method'; +$_['text_step_confirm_order'] = 'Step 6: Confirm Order'; // Entry -$_['entry_connect'] = 'Connect'; -$_['entry_checkout_express_status'] = 'Checkout'; -$_['entry_checkout_card_status'] = 'Advanced Card'; -$_['entry_checkout_message_status'] = 'Pay Later Message'; -$_['entry_environment'] = 'Environment'; -$_['entry_debug'] = 'Debug Logging'; -$_['entry_transaction_method'] = 'Settlement Method'; -$_['entry_total'] = 'Total'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; -$_['entry_currency_code'] = 'Currency'; -$_['entry_currency_value'] = 'Currency Value'; -$_['entry_smart_button'] = 'Smart Button'; -$_['entry_button_align'] = 'Button Align'; -$_['entry_button_size'] = 'Button Size'; -$_['entry_button_color'] = 'Button Color'; -$_['entry_button_shape'] = 'Button Shape'; -$_['entry_button_label'] = 'Button Label'; -$_['entry_form_align'] = 'Form Align'; -$_['entry_form_size'] = 'Form Size'; -$_['entry_secure_status'] = '3D Secure Status'; -$_['entry_secure_scenario'] = '3D Secure Scenarios'; -$_['entry_message_align'] = 'Message Align'; -$_['entry_message_size'] = 'Message Size'; -$_['entry_message_layout'] = 'Message Layout'; -$_['entry_message_text_color'] = 'Message Text Color'; -$_['entry_message_text_size'] = 'Message Text Size'; -$_['entry_message_flex_color'] = 'Message Banner Color'; -$_['entry_message_flex_ratio'] = 'Message Banner Ratio'; +$_['entry_connect'] = 'Connect'; +$_['entry_environment'] = 'Environment'; +$_['entry_debug'] = 'Debug Logging'; +$_['entry_sale_analytics_range'] = 'Sales Analytics Range'; +$_['entry_checkout_mode'] = 'Checkout Mode'; +$_['entry_transaction_method'] = 'Settlement Method'; +$_['entry_total'] = 'Total'; +$_['entry_geo_zone'] = 'Geo Zone'; +$_['entry_status'] = 'Status'; +$_['entry_sort_order'] = 'Sort Order'; +$_['entry_country_code'] = 'Country'; +$_['entry_currency_code'] = 'Currency'; +$_['entry_currency_value'] = 'Currency Value'; +$_['entry_card_currency_code'] = 'Card Currency'; +$_['entry_card_currency_value'] = 'Card Currency Value'; +$_['entry_button_insert_tag'] = 'Button Insert Tag'; +$_['entry_button_insert_type'] = 'Button Insert Type'; +$_['entry_button_align'] = 'Button Align'; +$_['entry_button_size'] = 'Button Size'; +$_['entry_button_color'] = 'Button Color'; +$_['entry_button_shape'] = 'Button Shape'; +$_['entry_button_label'] = 'Button Label'; +$_['entry_button_tagline'] = 'Button Tagline'; +$_['entry_applepay_button_align'] = 'Button Align'; +$_['entry_applepay_button_size'] = 'Button Size'; +$_['entry_applepay_button_color'] = 'Button Color'; +$_['entry_applepay_button_shape'] = 'Button Shape'; +$_['entry_applepay_button_type'] = 'Button Type'; +$_['entry_card_align'] = 'Card Align'; +$_['entry_card_size'] = 'Card Size'; +$_['entry_card_secure_status'] = 'Card 3D Secure Status'; +$_['entry_card_secure_scenario'] = 'Card 3D Secure Scenarios'; +$_['entry_card_number'] = 'Card Number'; +$_['entry_expiration_date'] = 'Expiration Date'; +$_['entry_cvv'] = 'CVV'; +$_['entry_message_insert_tag'] = 'Message Insert Tag'; +$_['entry_message_insert_type'] = 'Message Insert Type'; +$_['entry_message_align'] = 'Message Align'; +$_['entry_message_size'] = 'Message Size'; +$_['entry_message_layout'] = 'Message Layout'; +$_['entry_message_text_color'] = 'Message Text Color'; +$_['entry_message_text_size'] = 'Message Text Size'; +$_['entry_message_flex_color'] = 'Message Banner Color'; +$_['entry_message_flex_ratio'] = 'Message Banner Ratio'; +$_['entry_contact_company'] = 'Company'; +$_['entry_contact_first_name'] = 'First Name'; +$_['entry_contact_last_name'] = 'Last Name'; +$_['entry_contact_email'] = 'E-mail'; +$_['entry_contact_url'] = 'Website'; +$_['entry_contact_sales'] = 'Annual Online Sales'; +$_['entry_contact_phone'] = 'Telephone'; +$_['entry_contact_country'] = 'Country'; +$_['entry_contact_notes'] = 'Tell us more about your needs'; +$_['entry_contact_merchant'] = 'Completed on Behalf of Merchant'; +$_['entry_contact_merchant_name'] = 'Completed by'; +$_['entry_contact_product'] = 'Target Product'; +$_['entry_contact_send'] = 'Submit Form'; // Help -$_['help_checkout_express'] = 'If your country is not available in the list when going through the PayPal onboarding experience please click here.'; -$_['help_checkout_express_status'] = 'When activated PayPal will display personalized Smart Buttons avalible to your customers based on their location.'; -$_['help_checkout_card_status'] = 'PayPal verifies if you are eligible for advanced card payment and will display this option on the checkout step if available.'; -$_['help_checkout_message_status'] = 'Add pay later messaging to your site.'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.'; -$_['help_currency_code'] = 'Select the default currency for PayPal.'; -$_['help_currency_value'] = 'Set to 1.00000 if this is your default currency.'; -$_['help_secure_status'] = '3D Secure enables you to authenticate card holders through card issuers. It reduces the likelihood of fraud when you use supported cards and improves transaction perfomance. A successful 3D Secure authentication can shift liability for chargebacks due to fraud from you -the merchant- to the card issuer.'; -$_['help_secure_scenario'] = '3D Secure authentication is perfomed only if the card is enrolled for the service. In scenarios where the 3D Secure authentication has not been successful, you have the option to complete the payment at your own risk, meaning that you -the merchant- will be liable in case of a chargeback.'; +$_['help_status'] = 'Enable/Disable extension.'; +$_['help_button_status'] = 'When activated PayPal will display personalized Smart Buttons avalible to your customers based on their location.'; +$_['help_applepay_button_status'] = 'PayPal verifies if you are eligible for Apple Pay payment and will display this option on the checkout step if available.'; +$_['help_card_status'] = 'PayPal verifies if you are eligible for advanced card payment and will display this option on the checkout step if available.'; +$_['help_message_status'] = 'Add pay later messaging to your site.'; +$_['help_checkout_mode'] = 'If your checkout is incompatible with this payment, then we advise you to set the "One Button" mode.'; +$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.'; +$_['help_country_code'] = 'Select the default country for PayPal.'; +$_['help_currency_code'] = 'Select the default currency for PayPal.'; +$_['help_currency_value'] = 'Set to 1.00000 if this is your default currency.'; +$_['help_card_currency_code'] = 'Select the default currency for PayPal Card.'; +$_['help_card_currency_value'] = 'Set to 1.00000 if this is your default currency.'; +$_['help_card_secure_status'] = '3D Secure enables you to authenticate card holders through card issuers. It reduces the likelihood of fraud when you use supported cards and improves transaction perfomance. A successful 3D Secure authentication can shift liability for chargebacks due to fraud from you -the merchant- to the card issuer.'; +$_['help_card_secure_scenario'] = '3D Secure authentication is perfomed only if the card is enrolled for the service. In scenarios where the 3D Secure authentication has not been successful, you have the option to complete the payment at your own risk, meaning that you -the merchant- will be liable in case of a chargeback.'; // Button -$_['button_connect'] = 'Connect with PayPal'; -$_['button_disconnect'] = 'Disconnect'; -$_['button_smart_button'] = 'Smart Button Configure'; +$_['button_connect'] = 'Connect'; +$_['button_disconnect'] = 'Disconnect'; +$_['button_all_settings'] = 'All Settings'; +$_['button_download'] = 'Download'; +$_['button_download_host'] = 'Download and host'; +$_['button_send'] = 'Submit'; +$_['button_cart'] = 'Add to cart'; +$_['button_checkout'] = 'Checkout'; +$_['button_pay'] = 'Pay with Card'; // Success -$_['success_save'] = 'Success: You have modified PayPal!'; +$_['success_save'] = 'Success: You have modified PayPal!'; +$_['success_send'] = 'Success: Your contact details have been successfully sent to paypal!'; +$_['success_download_host'] = 'Success: Association file has been successfully uploaded and hosted!'; +$_['success_agree'] = 'Success: Deactivation was successful!'; // Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal!'; -$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; \ No newline at end of file +$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal!'; +$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; +$_['error_agree'] = 'We discovered that a few countries under sanctions are featured on your website. Please click the button to deactivate them (Cuba, Iran, Syria, North Korea, Crimea, Donetsk, and Lugansk regions of Ukraine).

'; \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/pp_braintree.php b/upload/admin/language/en-gb/extension/payment/pp_braintree.php deleted file mode 100644 index 65027e61370..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_braintree.php +++ /dev/null @@ -1,191 +0,0 @@ -'; -$_['text_payment'] = 'Payment'; -$_['text_success'] = 'Success: You have modified Braintree account details!'; -$_['text_success_connect'] = 'Success: You have connected your PayPal (Powered by Braintree) account!'; -$_['text_edit'] = 'Edit PayPal (Powered by Braintree)'; -$_['text_production'] = 'Production'; -$_['text_sandbox'] = 'Sandbox'; -$_['text_currency'] = 'Currency'; -$_['text_immediate'] = 'Immediate'; -$_['text_deferred'] = 'Deferred'; -$_['text_merchant_account_id'] = 'Merchant Account ID (Leave blank to use default merchant account)'; -$_['text_payment_info'] = 'Payment information'; -$_['text_confirm_void'] = 'Are you sure you want to void this transaction?'; -$_['text_avs_response'] = 'Street Address: %s, Postal Code: %s'; -$_['text_confirm_settle'] = 'Are you sure you want to settle/capture'; -$_['text_confirm_refund'] = 'Are you sure you want to refund'; -$_['text_success_action'] = 'Success'; -$_['text_error_settle'] = 'Error: %s'; -$_['text_error_generic'] = 'Error: There was an error with your request.'; -$_['text_na'] = 'N/A'; -$_['text_all'] = 'All'; -$_['text_sale'] = 'Sale'; -$_['text_credit'] = 'Credit'; -$_['text_credit_card'] = 'Credit Card'; -$_['text_paypal'] = 'PayPal'; -$_['text_enable_transactions'] = 'Please enable Braintree before viewing transactions.'; -$_['text_yes'] = 'Yes'; -$_['text_no'] = 'No'; -$_['text_no_refund'] = 'No refund history'; -$_['text_app_connected'] = 'Module is connected via Braintree auth'; -$_['text_braintree'] = 'PayPal powered by Braintree'; -$_['text_paypal_gold'] = 'Gold'; -$_['text_paypal_blue'] = 'Blue'; -$_['text_paypal_silver'] = 'Silver'; -$_['text_paypal_tiny'] = 'Tiny'; -$_['text_paypal_small'] = 'Small'; -$_['text_paypal_medium'] = 'Medium'; -$_['text_paypal_pill'] = 'Pill'; -$_['text_paypal_rectangular'] = 'Rectangular'; -$_['text_paypal_preview'] = 'Button preview
Save to view changes'; -$_['text_braintree_learn'] = 'To start accepting credit/debit cards and PayPal, click Connect with Braintree. Learn more'; -$_['text_3ds'] = '3D Secure'; -$_['text_cvv'] = 'CVV Number'; -$_['text_promotion_main'] = 'Designed for businesses of all sizes, from small to large enterprise, easily accept and process payments to help maximise business opportunities and revenue growth, with no setup or monthly fees'; -$_['text_promotion_li_1'] = 'All the benefits of PayPal, plus cards acceptance on your checkout page'; -$_['text_promotion_li_2'] = 'Fast configuration and setup'; -$_['text_promotion_li_3'] = 'Achieve PCI DSS v3.0 SAQ-A compliance using Hosted Fields'; -$_['text_promotion_li_4'] = 'Allow customers to vault card details'; -$_['text_learn_more'] = '(Learn more)'; -$_['text_accept'] = 'Accept'; -$_['text_decline'] = 'Decline'; -$_['text_merchant_connected'] = 'Connected Merchant ID: '; -$_['text_enable_button'] = 'We recommend offering PayPal Express Shortcut to maximise checkout conversion, this allows customers to use their PayPal address book and checkout is as little as three taps from the basket page. Click enable to install the extension and access the layout manager, you will ned to add "PayPal (Powered by Braintree) Button" to the checkout layout'; -$_['text_3ds_ssl'] = '3D Secure requires the store to be using an SSL certificate'; -$_['text_unlink'] = 'Delete link'; - -// Column -$_['column_void'] = 'Void'; -$_['column_settle'] = 'Settle'; -$_['column_refund'] = 'Refund'; -$_['column_transaction_id'] = 'Transaction ID'; -$_['column_transaction_type'] = 'Transaction Type'; -$_['column_transaction_date'] = 'Transaction Date'; -$_['column_merchant_account'] = 'Merchant Account'; -$_['column_payment_type'] = 'Payment Type'; -$_['column_order_id'] = 'Order ID'; -$_['column_processor_code'] = 'Processor Authorization Code'; -$_['column_cvv_response'] = 'CVV Response'; -$_['column_avs_response'] = 'AVS Response'; -$_['column_3ds_enrolled'] = '3DS Enrolled'; -$_['column_3ds_status'] = '3DS Status'; -$_['column_3ds_shifted'] = '3DS Liability Shifted'; -$_['column_3ds_shift_possible'] = '3DS Liability Shift Possible'; -$_['column_transaction_history'] = 'Transaction Status History'; -$_['column_date'] = 'Date'; -$_['column_refund_history'] = 'Refund History'; -$_['column_action'] = 'Action'; -$_['column_amount'] = 'Amount'; -$_['column_status'] = 'Status'; -$_['column_type'] = 'Type'; -$_['column_customer'] = 'Customer'; -$_['column_order'] = 'Order'; -$_['column_date_added'] = 'Date Added'; - -// Entry -$_['entry_merchant_id'] = 'Merchant ID'; -$_['entry_public_key'] = 'Public Key'; -$_['entry_private_key'] = 'Private Key'; -$_['entry_environment'] = 'Environment'; -$_['entry_settlement_type'] = 'Settlement Type'; -$_['entry_card_vault'] = 'Enable card vault'; -$_['entry_card_check_vault'] = 'Card vault is pre-checked'; -$_['entry_paypal_vault'] = 'Enable PayPal vault'; -$_['entry_paypal_check_vault'] = 'PayPal vault is pre-checked'; -$_['entry_vault_cvv_3ds'] = 'Require CVV2 or 3D secure?'; -$_['entry_debug'] = 'Debug Logging'; -$_['entry_total'] = 'Total'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; -$_['entry_authorization_expired'] = 'Authorization Expired'; -$_['entry_authorized'] = 'Authorized'; -$_['entry_authorizing'] = 'Authorizing'; -$_['entry_settlement_pending'] = 'Settlement Pending'; -$_['entry_failed'] = 'Failed'; -$_['entry_gateway_rejected'] = 'Gateway Rejected'; -$_['entry_processor_declined'] = 'Processor Declined'; -$_['entry_settled'] = 'Settled'; -$_['entry_settling'] = 'Settling'; -$_['entry_submitted_for_settlement'] = 'Submitted For Settlement'; -$_['entry_voided'] = 'Voided'; -$_['entry_transaction_id'] = 'Transaction ID'; -$_['entry_transaction_type'] = 'Transaction Type'; -$_['entry_date_from'] = 'Date From'; -$_['entry_date_to'] = 'Date To'; -$_['entry_payment_type'] = 'Payment Type'; -$_['entry_card_type'] = 'Card Type'; -$_['entry_amount_from'] = 'Amount From'; -$_['entry_amount_to'] = 'Amount To'; -$_['entry_transaction_status'] = 'Transaction Status'; -$_['entry_merchant_account_id'] = 'Merchant Account ID'; -$_['entry_connection'] = 'API Connection Status'; -$_['entry_paypal_option'] = 'Display PayPal Option'; -$_['entry_paypal_button_colour'] = 'Button Colour'; -$_['entry_paypal_button_shape'] = 'Button Shape'; -$_['entry_paypal_button_size'] = 'Button Size'; -$_['entry_paypal_billing_agreement'] = 'Billing agreement description'; -$_['entry_3ds_status'] = 'Enable 3-D Secure'; - -$_['entry_3ds_unsupported_card'] = 'Unsupported Card
Default: Accept'; -$_['entry_3ds_lookup_error'] = 'Lookup Error
Default: Accept'; -$_['entry_3ds_lookup_enrolled'] = 'Lookup Enrolled
Default: Accept'; -$_['entry_3ds_lookup_not_enrolled'] = 'Lookup Not Enrolled
Default: Accept'; -$_['entry_3ds_not_participating'] = 'Auth Success, Issuer Not Participating
Default: Accept'; -$_['entry_3ds_unavailable'] = 'Auth Unavailable
Default: Accept'; -$_['entry_3ds_signature_failed'] = 'Auth Signature Verification Failed
Default: Decline'; -$_['entry_3ds_successful'] = 'Auth Successful
Default: Accept'; -$_['entry_3ds_attempt_successful'] = 'Auth Attempt Successful
Default: Accept'; -$_['entry_3ds_failed'] = 'Auth Failed
Default: Decline'; -$_['entry_3ds_unable_to_auth'] = 'Unable To Authenticate
Default: Accept'; -$_['entry_3ds_error'] = 'Authentication Error
Default: Accept'; - -// Help -$_['help_settlement_type'] = 'Immediate will Submit For Settlement straight away. Deferred will set the transaction to Authorized and the merchant must Submit For Settlement manually in the OpenCart order details.'; -$_['help_card_vault'] = 'Allow customer to remember their card'; -$_['help_paypal_vault'] = 'Allow customer to remember their PayPal account'; -$_['help_card_check_vault'] = 'The checkbox for card vault is already checked when the page loads'; -$_['help_paypal_check_vault'] = 'The checkbox for PayPal vault is already checked when the page loads'; -$_['help_vault_cvv_3ds'] = 'This will require customers using a vaulted card to re-enter the CVV2 number or use 3D secure. It is not possible to enable both options for a vaulted card.'; -$_['help_debug'] = 'Enabling debug will write sensitive data to a log file. You should always disable unless instructed otherwise'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; -$_['help_paypal_option'] = 'If you have your PayPal account linked with Braintree you can display the PayPal payment option as well'; -$_['help_paypal_billing_agreement'] = 'You can add a billing agreement description that will be shown to users in the PayPal window when opting to vault their PayPal account'; - -// Button -$_['button_void'] = 'Void'; -$_['button_settle'] = 'Settle'; -$_['button_refund'] = 'Refund'; -$_['button_filter'] = 'Filter'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment Braintree!'; -$_['error_php_version'] = 'Minimum version of PHP 5.4.0 is required!'; -$_['error_merchant_id'] = 'Merchant ID Required!'; -$_['error_public_key'] = 'Public Key Required!'; -$_['error_private_key'] = 'Private Key Required!'; -$_['error_connection'] = 'There was a problem establishing a connection to the Braintree API. Please check your Merchant ID, Public Key, Private Key and Environment settings.'; -$_['error_account'] = 'Please enter a valid Merchant Account ID as specified in your Braintree Account'; -$_['error_warning'] = 'Warning: Please check the form carefully for errors!'; -$_['error_3ds_not_ready'] = 'You have enabled 3D secure however your Braintree account does not have it configured, please check your Braintree Control Panel or contact Braintree support'; -$_['error_paypal_not_ready'] = 'You have enabled PayPal however your Braintree account does not have it configured, please check your Braintree Control Panel or contact Braintree support'; -$_['error_paypal_billing_not_ready'] = 'You have enabled PayPal vaulting/billing agreements however your Braintree account does not have it configured, please check your Braintree Control Panel or contact Braintree support'; -$_['error_braintree_account_3ds'] = '3DS is not enabled in your Braintree account yet, however it is not available for all countries. Please check your Braintree Control Panel or contact Braintree support'; -$_['error_braintree_account_paypal'] = 'PayPal is not enabled in your Braintree account yet. Please check your Braintree Control Panel or contact Braintree support'; -$_['error_braintree_account_billing'] = 'Billing agreements are not enabled in your Braintree account yet. Please check your Braintree Control Panel or contact Braintree support'; -$_['error_environment'] = 'You cannot set your environment to %s when your credentials are for the %s environment in Braintree'; - -// Tab -$_['tab_setting'] = 'Settings'; -$_['tab_currency'] = 'Currencies'; -$_['tab_order_status'] = 'Order Statuses (New Orders)'; -$_['tab_3ds'] = '3-D Secure'; -$_['tab_transaction'] = 'Transaction Search'; -$_['tab_vault'] = 'Vault'; -$_['tab_paypal'] = 'PayPal'; diff --git a/upload/admin/language/en-gb/extension/payment/pp_express.php b/upload/admin/language/en-gb/extension/payment/pp_express.php deleted file mode 100644 index f377abaff11..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_express.php +++ /dev/null @@ -1,86 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; -$_['text_signup'] = 'Sign up for PayPal - save your settings first as this page will be refreshed'; -$_['text_sandbox'] = 'Sign up for PayPal Sandbox - save your settings first as this page will be refreshed'; -$_['text_configure_live'] = 'Configure Live'; -$_['text_configure_sandbox'] = 'Configure Sandbox'; -$_['text_show_advanced'] = 'Show Advanced'; -$_['text_show_quick_setup'] = 'Show Quick Setup'; -$_['text_quick_setup'] = 'Quick setup - Link an existing or create a new PayPal account to start accepting payments in minutes'; -$_['text_paypal_consent'] = 'By using the quick setup tool you allow PayPal to receive information about your store'; -$_['text_success_connect'] = 'Success: You have connected your PayPal account!'; -$_['text_preferred_main'] = 'Gives your buyers a simplified checkout experience on multiple devices that keeps them local to your website throughout the payment authorization process'; -$_['text_learn_more'] = '(Learn more)'; -$_['text_preferred_li_1'] = 'Start accepting PayPal in three clicks'; -$_['text_preferred_li_2'] = 'Accept payments from around the world'; -$_['text_preferred_li_3'] = 'Offer Express Checkout Shortcut, letting buyers checkout directly from your basket page'; -$_['text_preferred_li_4'] = 'Improve conversion with PayPal One Touch and In-Context checkout'; -$_['text_connect_paypal'] = 'Connect with PayPal'; -$_['text_incontext_not_supported'] = '* Not supported with In-Context Checkout'; -$_['text_retrieve'] = 'Your details have been entered from PayPal'; -$_['text_enable_button'] = 'We recommend offering PayPal Express Shortcut to maximise checkout conversion, this allows customers to use their PayPal address book and checkout is as little as three taps from the basket page. Click enable to install the extension and access the layout manager, you will ned to add "PayPal Express Checkout Button" to the checkout layout'; - -// Entry -$_['entry_username'] = 'API Username'; -$_['entry_password'] = 'API Password'; -$_['entry_signature'] = 'API Signature'; -$_['entry_sandbox_username'] = 'API Sandbox Username'; -$_['entry_sandbox_password'] = 'API Sandbox Password'; -$_['entry_sandbox_signature'] = 'API Sandbox Signature'; -$_['entry_ipn'] = 'IPN URL'; -$_['entry_test'] = 'Test (Sandbox) Mode'; -$_['entry_debug'] = 'Debug logging'; -$_['entry_currency'] = 'Default currency'; -$_['entry_recurring_cancel'] = 'Allow customers to cancel recurring payments from account area'; -$_['entry_transaction'] = 'Settlement Type'; -$_['entry_total'] = 'Total'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; -$_['entry_canceled_reversal_status'] = 'Canceled Reversal Status'; -$_['entry_completed_status'] = 'Completed Status'; -$_['entry_denied_status'] = 'Denied Status'; -$_['entry_expired_status'] = 'Expired Status'; -$_['entry_failed_status'] = 'Failed Status'; -$_['entry_pending_status'] = 'Pending Status'; -$_['entry_processed_status'] = 'Processed Status'; -$_['entry_refunded_status'] = 'Refunded Status'; -$_['entry_reversed_status'] = 'Reversed Status'; -$_['entry_voided_status'] = 'Voided Status'; -$_['entry_allow_notes'] = 'Allow Notes'; -$_['entry_colour'] = 'Page Background Colour'; -$_['entry_logo'] = 'Logo'; -$_['entry_incontext'] = 'Disable In-Context Checkout'; - -// Tab -$_['tab_api'] = 'API Details'; -$_['tab_order_status'] = 'Order status'; -$_['tab_checkout'] = 'Checkout'; - -// Help -$_['help_ipn'] = 'Required for subscriptions'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; -$_['help_logo'] = 'Max 750px(w) x 90px(h)
You should only use a logo if you have SSL set up.'; -$_['help_colour'] = '6 character HTML colour code'; -$_['help_currency'] = 'Used for transaction searches'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal Express Checkout!'; -$_['error_username'] = 'API Username Required!'; -$_['error_password'] = 'API Password Required!'; -$_['error_signature'] = 'API Signature Required!'; -$_['error_sandbox_username'] = 'API Sandbox Username Required!'; -$_['error_sandbox_password'] = 'API Sandbox Password Required!'; -$_['error_sandbox_signature'] = 'API Sandbox Signature Required!'; -$_['error_api'] = 'Paypal Authorization Error'; -$_['error_api_sandbox'] = 'Paypal Sandbox Authorization Error'; -$_['error_consent'] = 'To use quick setup you need to permit PayPal to use your store information'; diff --git a/upload/admin/language/en-gb/extension/payment/pp_express_order.php b/upload/admin/language/en-gb/extension/payment/pp_express_order.php deleted file mode 100644 index 8782d77ee0b..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_express_order.php +++ /dev/null @@ -1,52 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; - -// Entry -$_['entry_vendor'] = 'Vendor'; -$_['entry_user'] = 'User'; -$_['entry_password'] = 'Password'; -$_['entry_partner'] = 'Partner'; -$_['entry_test'] = 'Test Mode'; -$_['entry_transaction'] = 'Transaction Method'; -$_['entry_total'] = 'Total'; -$_['entry_order_status'] = 'Order Status'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; - -// Help -$_['help_vendor'] = 'Your merchant login ID that you created when you registered for the Website Payments Pro account'; -$_['help_user'] = 'If you set up one or more additional users on the account, this value is the ID of the user authorised to process transactions. If, however, you have not set up additional users on the account, USER has the same value as VENDOR'; -$_['help_password'] = 'The 6 to 32 character password that you defined while registering for the account'; -$_['help_partner'] = 'The ID provided to you by the authorised PayPal Reseller who registered you for the Payflow SDK. If you purchased your account directly from PayPal, use the PayPal Pro instead'; -$_['help_test'] = 'Use the live or testing (sandbox) gateway server to process transactions?'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal Website Payment Pro (UK)!'; -$_['error_vendor'] = 'Vendor Required!'; -$_['error_user'] = 'User Required!'; -$_['error_password'] = 'Password Required!'; -$_['error_partner'] = 'Partner Required!'; \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/pp_payflow_iframe.php b/upload/admin/language/en-gb/extension/payment/pp_payflow_iframe.php deleted file mode 100644 index 85d23ad09ce..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_payflow_iframe.php +++ /dev/null @@ -1,104 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; -$_['text_authorise'] = 'Authorise'; -$_['text_capture'] = 'Delayed Capture'; -$_['text_void'] = 'Void'; -$_['text_payment_info'] = 'Payment information'; -$_['text_complete'] = 'Complete'; -$_['text_incomplete'] = 'Incomplete'; -$_['text_transaction'] = 'Transaction'; -$_['text_confirm_void'] = 'If you void you cannot capture any further funds'; -$_['text_refund'] = 'Refund'; -$_['text_refund_issued'] = 'Refund was issued successfully'; -$_['text_redirect'] = 'Redirect'; -$_['text_iframe'] = 'Iframe'; -$_['help_checkout_method'] = 'Please use Redirect method if do not have SSL installed or if you do not have Pay with PayPal option disabled on your hosted payment page.'; - -// Column -$_['column_transaction_id'] = 'Transaction ID'; -$_['column_transaction_type'] = 'Transaction Type'; -$_['column_amount'] = 'Amount'; -$_['column_time'] = 'Time'; -$_['column_actions'] = 'Actions'; - -// Tab -$_['tab_settings'] = 'Settings'; -$_['tab_order_status'] = 'Order Status'; -$_['tab_checkout_customisation'] = 'Checkout Customisation'; - -// Entry -$_['entry_vendor'] = 'Vendor'; -$_['entry_user'] = 'User'; -$_['entry_password'] = 'Password'; -$_['entry_partner'] = 'Partner'; -$_['entry_test'] = 'Test Mode'; -$_['entry_transaction'] = 'Transaction Method'; -$_['entry_total'] = 'Total'; -$_['entry_order_status'] = 'Order Status'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; -$_['entry_transaction_id'] = 'Transaction ID'; -$_['entry_full_refund'] = 'Full refund'; -$_['entry_amount'] = 'Amount'; -$_['entry_message'] = 'Message'; -$_['entry_ipn_url'] = 'IPN URL'; -$_['entry_checkout_method'] = 'Checkout Method'; -$_['entry_debug'] = 'Debug mode'; -$_['entry_transaction_reference'] = 'Transaction Reference'; -$_['entry_transaction_amount'] = 'Transaction Amount'; -$_['entry_refund_amount'] = 'Refund Amount'; -$_['entry_capture_status'] = 'Capture Status'; -$_['entry_void'] = 'Void'; -$_['entry_capture'] = 'Capture'; -$_['entry_transactions'] = 'Transactions'; -$_['entry_complete_capture'] = 'Complete Capture'; -$_['entry_canceled_reversal_status'] = 'Canceled Reversal Status:'; -$_['entry_completed_status'] = 'Completed Status:'; -$_['entry_denied_status'] = 'Denied Status:'; -$_['entry_expired_status'] = 'Expired Status:'; -$_['entry_failed_status'] = 'Failed Status:'; -$_['entry_pending_status'] = 'Pending Status:'; -$_['entry_processed_status'] = 'Processed Status:'; -$_['entry_refunded_status'] = 'Refunded Status:'; -$_['entry_reversed_status'] = 'Reversed Status:'; -$_['entry_voided_status'] = 'Voided Status:'; -$_['entry_cancel_url'] = 'Cancel URL:'; -$_['entry_error_url'] = 'Error URL:'; -$_['entry_return_url'] = 'Return URL:'; -$_['entry_post_url'] = 'Silent POST URL:'; - -// Help -$_['help_vendor'] = 'Your merchant login ID that you created when you registered for the Website Payments Pro account'; -$_['help_user'] = 'If you set up one or more additional users on the account, this value is the ID of the user authorised to process transactions. If, however, you have not set up additional users on the account, USER has the same value as VENDOR'; -$_['help_password'] = 'The 6 to 32 character password that you defined while registering for the account'; -$_['help_partner'] = 'The ID provided to you by the authorised PayPal Reseller who registered you for the Payflow SDK. If you purchased your account directly from PayPal, use the PayPal Pro instead'; -$_['help_test'] = 'Use the live or testing (sandbox) gateway server to process transactions?'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; -$_['help_debug'] = 'Logs additional information'; - -// Button -$_['button_refund'] = 'Refund'; -$_['button_void'] = 'Void'; -$_['button_capture'] = 'Capture'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal Website Payment Pro iFrame (UK)!'; -$_['error_vendor'] = 'Vendor Required!'; -$_['error_user'] = 'User Required!'; -$_['error_password'] = 'Password Required!'; -$_['error_partner'] = 'Partner Required!'; -$_['error_missing_data'] = 'Missing data'; -$_['error_missing_order'] = 'Could not find the order'; -$_['error_general'] = 'There was an error'; -$_['error_capture'] = 'Enter an amount to capture'; \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/pp_pro.php b/upload/admin/language/en-gb/extension/payment/pp_pro.php deleted file mode 100644 index 66ad5a83c44..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_pro.php +++ /dev/null @@ -1,33 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; - -// Entry -$_['entry_username'] = 'API Username'; -$_['entry_password'] = 'API Password'; -$_['entry_signature'] = 'API Signature'; -$_['entry_test'] = 'Test Mode'; -$_['entry_transaction'] = 'Transaction Method:'; -$_['entry_total'] = 'Total'; -$_['entry_order_status'] = 'Order Status'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; - -// Help -$_['help_test'] = 'Use the live or testing (sandbox) gateway server to process transactions?'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal Website Payment Pro Checkout!'; -$_['error_username'] = 'API Username Required!'; -$_['error_password'] = 'API Password Required!'; -$_['error_signature'] = 'API Signature Required!'; \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/pp_pro_iframe.php b/upload/admin/language/en-gb/extension/payment/pp_pro_iframe.php deleted file mode 100644 index f5a33e3e378..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_pro_iframe.php +++ /dev/null @@ -1,174 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; -$_['text_payment_info'] = 'Payment information'; -$_['text_capture_status'] = 'Capture status'; -$_['text_amount_auth'] = 'Amount authorised'; -$_['text_amount_captured'] = 'Amount captured'; -$_['text_amount_refunded'] = 'Amount refunded'; -$_['text_capture_amount'] = 'Capture amount'; -$_['text_complete_capture'] = 'Complete capture'; -$_['text_transactions'] = 'Transactions'; -$_['text_complete'] = 'Complete'; -$_['text_confirm_void'] = 'If you void you cannot capture any further funds'; -$_['text_view'] = 'View'; -$_['text_refund'] = 'Refund'; -$_['text_resend'] = 'Resend'; -$_['text_reauthorise'] = 'Reauthorise'; -$_['text_reauthorised'] = 'Transaction was reauthorised'; -$_['text_transaction'] = 'Transaction'; -$_['text_product_lines'] = 'Product lines'; -$_['text_ebay_txn_id'] = 'eBay transaction ID'; -$_['text_name'] = 'Name'; -$_['text_qty'] = 'Quantity'; -$_['text_price'] = 'Price'; -$_['text_number'] = 'Number'; -$_['text_coupon_id'] = 'Coupon ID'; -$_['text_coupon_amount'] = 'Coupon amount'; -$_['text_coupon_currency'] = 'Coupon currency'; -$_['text_loyalty_disc_amt'] = 'Loyalty card disc amount'; -$_['text_loyalty_currency'] = 'Loyalty card currency'; -$_['text_options_name'] = 'Options name'; -$_['text_tax_amt'] = 'Tax amount'; -$_['text_currency_code'] = 'Currency code'; -$_['text_amount'] = 'Amount'; -$_['text_gift_msg'] = 'Gift message'; -$_['text_gift_receipt'] = 'Gift receipt'; -$_['text_gift_wrap_name'] = 'Gift wrap name'; -$_['text_gift_wrap_amt'] = 'Gift wrap amount'; -$_['text_buyer_email_market'] = 'Buyer marketing email'; -$_['text_survey_question'] = 'Survey question'; -$_['text_survey_chosen'] = 'Survey choice selected'; -$_['text_receiver_business'] = 'Receiver business'; -$_['text_receiver_email'] = 'Receiver email'; -$_['text_receiver_id'] = 'Receiver ID'; -$_['text_buyer_email'] = 'Buyer email'; -$_['text_payer_id'] = 'Payer ID'; -$_['text_payer_status'] = 'Payer status'; -$_['text_country_code'] = 'Country code'; -$_['text_payer_business'] = 'Payer business'; -$_['text_payer_salute'] = 'Payer salutation'; -$_['text_payer_firstname'] = 'Payer first name'; -$_['text_payer_middlename'] = 'Payer middle name'; -$_['text_payer_lastname'] = 'Payer last name'; -$_['text_payer_suffix'] = 'Payer suffix'; -$_['text_address_owner'] = 'Address owner'; -$_['text_address_status'] = 'Address status'; -$_['text_ship_sec_name'] = 'Ship to secondary name'; -$_['text_ship_name'] = 'Ship to name'; -$_['text_ship_street1'] = 'Ship to address 1'; -$_['text_ship_street2'] = 'Ship to address 2'; -$_['text_ship_city'] = 'Ship to city'; -$_['text_ship_state'] = 'Ship to state'; -$_['text_ship_zip'] = 'Ship to ZIP'; -$_['text_ship_country'] = 'Ship to country code'; -$_['text_ship_phone'] = 'Ship to phone number'; -$_['text_ship_sec_add1'] = 'Ship to secondary address 1'; -$_['text_ship_sec_add2'] = 'Ship to secondary address 2'; -$_['text_ship_sec_city'] = 'Ship to secondary city'; -$_['text_ship_sec_state'] = 'Ship to secondary state'; -$_['text_ship_sec_zip'] = 'Ship to secondary ZIP'; -$_['text_ship_sec_country'] = 'Ship to secondary country code'; -$_['text_ship_sec_phone'] = 'Ship to secondary phone'; -$_['text_trans_id'] = 'Transaction ID'; -$_['text_receipt_id'] = 'Receipt ID'; -$_['text_parent_trans_id'] = 'Parent transaction ID'; -$_['text_trans_type'] = 'Transaction type'; -$_['text_payment_type'] = 'Payment type'; -$_['text_order_time'] = 'Order time'; -$_['text_fee_amount'] = 'Fee amount'; -$_['text_settle_amount'] = 'Settle amount'; -$_['text_tax_amount'] = 'Tax amount'; -$_['text_exchange'] = 'Exchange rate'; -$_['text_payment_status'] = 'Payment status'; -$_['text_pending_reason'] = 'Pending reason'; -$_['text_reason_code'] = 'Reason code'; -$_['text_protect_elig'] = 'Protection eligibility'; -$_['text_protect_elig_type'] = 'Protection eligibility type'; -$_['text_store_id'] = 'Store ID'; -$_['text_terminal_id'] = 'Terminal ID'; -$_['text_invoice_number'] = 'Invoice number'; -$_['text_custom'] = 'Custom'; -$_['text_note'] = 'Note'; -$_['text_sales_tax'] = 'Sales tax'; -$_['text_buyer_id'] = 'Buyer ID'; -$_['text_close_date'] = 'Closing date'; -$_['text_multi_item'] = 'Multi item'; -$_['text_sub_amt'] = 'Subscription amount'; -$_['text_sub_period'] = 'Subscription period'; -$_['text_redirect'] = 'Redirect'; -$_['text_iframe'] = 'Iframe'; -$_['help_checkout_method'] = 'Please use Redirect method if do not have SSL installed or if you do not have Pay with PayPal option disabled on your hosted payment page.'; -$_['help_debug'] = 'Logs additional information.'; - -// Column -$_['column_trans_id'] = 'Transaction ID'; -$_['column_amount'] = 'Amount'; -$_['column_type'] = 'Payment type'; -$_['column_status'] = 'Status'; -$_['column_pending_reason'] = 'Pending reason'; -$_['column_date_added'] = 'Created'; -$_['column_action'] = 'Action'; - -// Tab -$_['tab_settings'] = 'Settings'; -$_['tab_order_status'] = 'Order Status'; -$_['tab_checkout_customisation'] = 'Checkout Customisation'; - -// Entry -$_['entry_username'] = 'API Username'; -$_['entry_password'] = 'API Password'; -$_['entry_signature'] = 'API Signature'; -$_['entry_test'] = 'Test Mode'; -$_['entry_total'] = 'Total'; -$_['entry_order_status'] = 'Order Status:'; -$_['entry_geo_zone'] = 'Geo Zone:'; -$_['entry_status'] = 'Status:'; -$_['entry_sort_order'] = 'Sort Order:'; -$_['entry_transaction_method'] = 'Transaction method:'; -$_['entry_transaction_id'] = 'Transaction ID'; -$_['entry_full_refund'] = 'Full refund'; -$_['entry_amount'] = 'Amount'; -$_['entry_message'] = 'Message'; -$_['entry_ipn_url'] = 'IPN URL:'; -$_['entry_checkout_method'] = 'Checkout Method:'; -$_['entry_debug'] = 'Debug mode:'; -$_['entry_canceled_reversal_status'] = 'Canceled Reversal Status:'; -$_['entry_completed_status'] = 'Completed Status:'; -$_['entry_denied_status'] = 'Denied Status:'; -$_['entry_expired_status'] = 'Expired Status:'; -$_['entry_failed_status'] = 'Failed Status:'; -$_['entry_pending_status'] = 'Pending Status:'; -$_['entry_processed_status'] = 'Processed Status:'; -$_['entry_refunded_status'] = 'Refunded Status:'; -$_['entry_reversed_status'] = 'Reversed Status:'; -$_['entry_voided_status'] = 'Voided Status:'; - -// Help -$_['help_test'] = 'Use the live or testing (sandbox) gateway server to process transactions? Test may fail in Internet Explorer'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; - -// Button -$_['button_refund'] = 'Refund'; -$_['button_void'] = 'Void'; -$_['button_capture'] = 'Capture'; -$_['button_reauthorise'] = 'Reauthorise'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal Website Payment Pro iFrame (UK)!'; -$_['error_sig'] = 'Signature Required!'; -$_['error_user'] = 'User Required!'; -$_['error_password'] = 'Password Required!'; -$_['error_timeout'] = 'Request timed out'; -$_['error_transaction_missing'] = 'Could not find the transaction'; -$_['error_missing_data'] = 'Missing data'; -$_['error_general'] = 'There was an error'; -$_['error_capture'] = 'Enter an amount to capture'; \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/pp_standard.php b/upload/admin/language/en-gb/extension/payment/pp_standard.php deleted file mode 100644 index e820c0affbb..00000000000 --- a/upload/admin/language/en-gb/extension/payment/pp_standard.php +++ /dev/null @@ -1,44 +0,0 @@ -PayPal Website Payment Pro'; -$_['text_authorization'] = 'Authorization'; -$_['text_sale'] = 'Sale'; - -// Entry -$_['entry_email'] = 'E-Mail'; -$_['entry_test'] = 'Sandbox Mode'; -$_['entry_transaction'] = 'Transaction Method'; -$_['entry_debug'] = 'Debug Mode'; -$_['entry_total'] = 'Total'; -$_['entry_canceled_reversal_status'] = 'Canceled Reversal Status'; -$_['entry_completed_status'] = 'Completed Status'; -$_['entry_denied_status'] = 'Denied Status'; -$_['entry_expired_status'] = 'Expired Status'; -$_['entry_failed_status'] = 'Failed Status'; -$_['entry_pending_status'] = 'Pending Status'; -$_['entry_processed_status'] = 'Processed Status'; -$_['entry_refunded_status'] = 'Refunded Status'; -$_['entry_reversed_status'] = 'Reversed Status'; -$_['entry_voided_status'] = 'Voided Status'; -$_['entry_geo_zone'] = 'Geo Zone'; -$_['entry_status'] = 'Status'; -$_['entry_sort_order'] = 'Sort Order'; - -// Tab -$_['tab_general'] = 'General'; -$_['tab_order_status'] = 'Order Status'; - -// Help -$_['help_test'] = 'Use the live or testing (sandbox) gateway server to process transactions?'; -$_['help_debug'] = 'Logs additional information to the system log'; -$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active'; - -// Error -$_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal!'; -$_['error_email'] = 'E-Mail required!'; \ No newline at end of file diff --git a/upload/admin/model/extension/payment/paypal.php b/upload/admin/model/extension/payment/paypal.php index 9e6a602b6dc..f8e2559c2bd 100644 --- a/upload/admin/model/extension/payment/paypal.php +++ b/upload/admin/model/extension/payment/paypal.php @@ -1,25 +1,226 @@ load->model('user/user_group'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "extension WHERE `code` = 'paypal_smart_button'"); - - if (empty($query->row)) { - $this->db->query("INSERT INTO " . DB_PREFIX . "extension SET `type` = 'module', `code` = 'paypal_smart_button'"); - - $user_group_id = $this->user->getGroupId(); - - $this->model_user_user_group->addPermission($user_group_id, 'access', 'extension/module/paypal_smart_button'); - $this->model_user_user_group->addPermission($user_group_id, 'modify', 'extension/module/paypal_smart_button'); + public function getTotalSales() { + $implode = array(); + + foreach ($this->config->get('config_complete_status') as $order_status_id) { + $implode[] = "'" . (int)$order_status_id . "'"; + } + + $query = $this->db->query("SELECT SUM(total) AS paypal_total FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND payment_code = 'paypal'"); + + return $query->row['paypal_total']; + } + + public function getTotalSalesByDay() { + $implode = array(); + + foreach ($this->config->get('config_complete_status') as $order_status_id) { + $implode[] = "'" . (int)$order_status_id . "'"; + } + + $sale_data = array(); + + for ($i = 0; $i < 24; $i++) { + $sale_data[$i] = array( + 'hour' => $i, + 'total' => 0, + 'paypal_total' => 0 + ); + } + + $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC"); + + foreach ($query->rows as $result) { + $sale_data[$result['hour']] = array( + 'hour' => $result['hour'], + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); + } + + return $sale_data; + } + + public function getTotalSalesByWeek() { + $implode = array(); + + foreach ($this->config->get('config_complete_status') as $order_status_id) { + $implode[] = "'" . (int)$order_status_id . "'"; + } + + $sale_data = array(); + + $date_start = strtotime('-' . date('w') . ' days'); + + for ($i = 0; $i < 7; $i++) { + $date = date('Y-m-d', $date_start + ($i * 86400)); + + $sale_data[date('w', strtotime($date))] = array( + 'day' => date('D', strtotime($date)), + 'total' => 0, + 'paypal_total' => 0 + ); + } + + $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)"); + + foreach ($query->rows as $result) { + $sale_data[date('w', strtotime($result['date_added']))] = array( + 'day' => date('D', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); + } + + return $sale_data; + } + + public function getTotalSalesByMonth() { + $implode = array(); + + foreach ($this->config->get('config_complete_status') as $order_status_id) { + $implode[] = "'" . (int)$order_status_id . "'"; + } + + $sale_data = array(); + + for ($i = 1; $i <= date('t'); $i++) { + $date = date('Y') . '-' . date('m') . '-' . $i; + + $sale_data[date('j', strtotime($date))] = array( + 'day' => date('d', strtotime($date)), + 'total' => 0, + 'paypal_total' => 0 + ); + } + + $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)"); + + foreach ($query->rows as $result) { + $sale_data[date('j', strtotime($result['date_added']))] = array( + 'day' => date('d', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); + } + + return $sale_data; + } + + public function getTotalSalesByYear() { + $implode = array(); + + foreach ($this->config->get('config_complete_status') as $order_status_id) { + $implode[] = "'" . (int)$order_status_id . "'"; + } + + $sale_data = array(); + + for ($i = 1; $i <= 12; $i++) { + $sale_data[$i] = array( + 'month' => date('M', mktime(0, 0, 0, $i)), + 'total' => 0, + 'paypal_total' => 0 + ); + } + + $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)"); + + foreach ($query->rows as $result) { + $sale_data[date('n', strtotime($result['date_added']))] = array( + 'month' => date('M', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); + } + + return $sale_data; + } + + public function getCountryByCode($code) { + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE iso_code_2 = '" . $this->db->escape($code) . "'"); + + return $query->row; + } + + public function setAgreeStatus() { + $this->db->query("UPDATE " . DB_PREFIX . "country SET status = '0' WHERE (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); + $this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '0' WHERE country_id = '220' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); + } + + public function getAgreeStatus() { + $agree_status = true; + + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' AND (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); + + if ($query->rows) { + $agree_status = false; + } + + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '220' AND status = '1' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); + + if ($query->rows) { + $agree_status = false; + } + + return $agree_status; + } + + public function checkVersion($opencart_version, $paypal_version) { + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_URL, 'https://www.opencart.com/index.php?route=api/promotion/paypalCheckoutIntegration&opencart=' . $opencart_version . '&paypal=' . $paypal_version); + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); + curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); + curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); + + $response = curl_exec($curl); - $this->load->controller('extension/module/paypal_smart_button/install'); - } + curl_close($curl); + + $result = json_decode($response, true); + + if ($result) { + return $result; + } else { + return false; + } + } + + public function sendContact($data) { + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_URL, 'https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'); + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); + curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); + curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); + + $response = curl_exec($curl); + + curl_close($curl); } public function log($data, $title = null) { - if ($this->config->get('payment_paypal_debug')) { + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + if ($setting['general']['debug']) { $log = new Log('paypal.log'); $log->write('PayPal debug (' . $title . '): ' . json_encode($data)); } diff --git a/upload/admin/model/extension/payment/pp_braintree.php b/upload/admin/model/extension/payment/pp_braintree.php deleted file mode 100644 index af0e604151b..00000000000 --- a/upload/admin/model/extension/payment/pp_braintree.php +++ /dev/null @@ -1,168 +0,0 @@ -clientToken()->generate($data); - } else { - $client_token = Braintree_ClientToken::generate($data); - } - - return $client_token; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function getTransaction($gateway, $transaction_id) { - try { - if ($gateway != null) { - $transaction = $gateway->transaction()->find($transaction_id); - } else { - $transaction = Braintree_Transaction::find($transaction_id); - } - - if ($transaction) { - return $transaction; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function getTransactions($gateway, $data = array()) { - try { - if ($gateway != null) { - $transactions = $gateway->transaction()->search($data); - } else { - $transactions = Braintree_Transaction::search($data); - } - - if ($transactions) { - return $transactions; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function voidTransaction($gateway, $transaction_id) { - try { - if ($gateway != null) { - $transaction = $gateway->transaction()->void($transaction_id); - } else { - $transaction = Braintree_Transaction::void($transaction_id); - } - - if ($transaction) { - return $transaction; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function settleTransaction($gateway, $transaction_id, $amount) { - try { - if ($gateway != null) { - $transaction = $gateway->transaction()->submitForSettlement($transaction_id, $amount); - } else { - $transaction = Braintree_Transaction::submitForSettlement($transaction_id, $amount); - } - - if ($transaction) { - return $transaction; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function refundTransaction($gateway, $transaction_id, $amount) { - try { - if ($gateway != null) { - $transaction = $gateway->transaction()->refund($transaction_id, $amount); - } else { - $transaction = Braintree_Transaction::refund($transaction_id, $amount); - } - - if ($transaction) { - return $transaction; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function verifyCredentials($gateway) { - try { - //Try API call, if no exception is thrown, the credentials are correct - if ($gateway != null) { - $client_token = $gateway->clientToken()->generate(); - } else { - $client_token = Braintree_ClientToken::generate(); - } - - return $client_token; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function verifyMerchantAccount($gateway, $merchant_account_id) { - try { - //Try API call, if no exception is thrown, the above credentials are correct - if ($gateway != null) { - $merchant_account = $gateway->merchantAccount()->find($merchant_account_id); - } else { - $merchant_account = Braintree_MerchantAccount::find($merchant_account_id); - } - - if ($merchant_account && $merchant_account->status == 'active') { - return $merchant_account; - } else { - return false; - } - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function setGateway($access_token) { - return new Braintree_Gateway(array('accessToken' => $access_token)); - } - - public function log($data) { - if ($this->config->get('payment_pp_braintree_debug')) { - $backtrace = debug_backtrace(); - $log = new Log('braintree.log'); - $log->write('(' . $backtrace[1]['class'] . '::' . $backtrace[1]['function'] . ') - ' . print_r($data, true)); - } - } -} diff --git a/upload/admin/model/extension/payment/pp_express.php b/upload/admin/model/extension/payment/pp_express.php deleted file mode 100644 index 67c5c59058c..00000000000 --- a/upload/admin/model/extension/payment/pp_express.php +++ /dev/null @@ -1,371 +0,0 @@ -db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_order` ( - `paypal_order_id` int(11) NOT NULL AUTO_INCREMENT, - `order_id` int(11) NOT NULL, - `date_added` DATETIME NOT NULL, - `date_modified` DATETIME NOT NULL, - `capture_status` ENUM('Complete','NotComplete') DEFAULT NULL, - `currency_code` CHAR(3) NOT NULL, - `authorization_id` VARCHAR(30) NOT NULL, - `total` DECIMAL( 10, 2 ) NOT NULL, - PRIMARY KEY (`paypal_order_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci - "); - - $this->db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_order_transaction` ( - `paypal_order_transaction_id` int(11) NOT NULL AUTO_INCREMENT, - `paypal_order_id` int(11) NOT NULL, - `transaction_id` CHAR(20) NOT NULL, - `parent_id` CHAR(20) NOT NULL, - `date_added` DATETIME NOT NULL, - `note` VARCHAR(255) NOT NULL, - `msgsubid` CHAR(38) NOT NULL, - `receipt_id` CHAR(20) NOT NULL, - `payment_type` ENUM('none','echeck','instant', 'refund', 'void') DEFAULT NULL, - `payment_status` CHAR(20) NOT NULL, - `pending_reason` CHAR(50) NOT NULL, - `transaction_entity` CHAR(50) NOT NULL, - `amount` DECIMAL( 10, 2 ) NOT NULL, - `debug_data` TEXT NOT NULL, - `call_data` TEXT NOT NULL, - PRIMARY KEY (`paypal_order_transaction_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci - "); - - $this->load->model('setting/setting'); - - $defaults = array(); - - // Order Status defaults - $defaults['payment_pp_express_canceled_reversal_status_id'] = 9; - $defaults['payment_pp_express_completed_status_id'] = 5; - $defaults['payment_pp_express_denied_status_id'] = 8; - $defaults['payment_pp_express_expired_status_id'] = 14; - $defaults['payment_pp_express_failed_status_id'] = 10; - $defaults['payment_pp_express_pending_status_id'] = 1; - $defaults['payment_pp_express_processed_status_id'] = 15; - $defaults['payment_pp_express_refunded_status_id'] = 11; - $defaults['payment_pp_express_reversed_status_id'] = 12; - $defaults['payment_pp_express_voided_status_id'] = 16; - - $defaults['payment_pp_express_incontext_disable'] = 0; - $defaults['payment_pp_express_status'] = 0; - $defaults['payment_pp_express_currency'] = "USD"; - - $this->model_setting_setting->editSetting('payment_pp_express', $defaults); - } - - public function uninstall() { - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_order_transaction`"); - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_order`"); - } - - public function getPayPalOrder($order_id) { - $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_order` WHERE `order_id` = '" . (int)$order_id . "'"); - - return $query->row; - } - - public function editPayPalOrderStatus($order_id, $capture_status) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order` SET `capture_status` = '" . $this->db->escape($capture_status) . "', `date_modified` = NOW() WHERE `order_id` = '" . (int)$order_id . "'"); - } - - public function addTransaction($transaction_data, $request_data = array()) { - if ($request_data) { - $serialized_data = json_encode($request_data); - - $this->db->query("UPDATE " . DB_PREFIX . "paypal_order_transaction SET call_data = '" . $this->db->escape($serialized_data) . "' WHERE paypal_order_transaction_id = " . (int)$paypal_order_transaction_id . " LIMIT 1"); - } - - - - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_order_transaction` SET `paypal_order_id` = '" . (int)$transaction_data['paypal_order_id'] . "', `transaction_id` = '" . $this->db->escape($transaction_data['transaction_id']) . "', `parent_id` = '" . $this->db->escape($transaction_data['parent_id']) . "', `date_added` = NOW(), `note` = '" . $this->db->escape($transaction_data['note']) . "', `msgsubid` = '" . $this->db->escape($transaction_data['msgsubid']) . "', `receipt_id` = '" . $this->db->escape($transaction_data['receipt_id']) . "', `payment_type` = '" . $this->db->escape($transaction_data['payment_type']) . "', `payment_status` = '" . $this->db->escape($transaction_data['payment_status']) . "', `pending_reason` = '" . $this->db->escape($transaction_data['pending_reason']) . "', `transaction_entity` = '" . $this->db->escape($transaction_data['transaction_entity']) . "', `amount` = '" . (float)$transaction_data['amount'] . "', `debug_data` = '" . $this->db->escape($transaction_data['debug_data']) . "'"); - - return $this->db->getLastId(); - } - - public function updateTransaction($transaction) { - $this->db->query("UPDATE " . DB_PREFIX . "paypal_order_transaction SET paypal_order_id = " . (int)$transaction['paypal_order_id'] . ", transaction_id = '" . $this->db->escape($transaction['transaction_id']) . "', parent_id = '" . $this->db->escape($transaction['parent_id']) . "', date_added = '" . $this->db->escape($transaction['date_added']) . "', note = '" . $this->db->escape($transaction['note']) . "', msgsubid = '" . $this->db->escape($transaction['msgsubid']) . "', receipt_id = '" . $this->db->escape($transaction['receipt_id']) . "', payment_type = '" . $this->db->escape($transaction['payment_type']) . "', payment_status = '" . $this->db->escape($transaction['payment_status']) . "', pending_reason = '" . $this->db->escape($transaction['pending_reason']) . "', transaction_entity = '" . $this->db->escape($transaction['transaction_entity']) . "', amount = '" . $this->db->escape($transaction['amount']) . "', debug_data = '" . $this->db->escape($transaction['debug_data']) . "', call_data = '" . $this->db->escape($transaction['call_data']) . "' WHERE paypal_order_transaction_id = '" . (int)$transaction['paypal_order_transaction_id'] . "'"); - } - - public function getPaypalOrderByTransactionId($transaction_id) { - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "paypal_order_transaction WHERE transaction_id = '" . $this->db->escape($transaction_id) . "'"); - - return $query->rows; - } - - public function getFailedTransaction($paypal_order_transaction_id) { - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "paypal_order_transaction WHERE paypal_order_transaction_id = '" . (int)$paypal_order_transaction_id . "'"); - - return $query->row; - } - - public function getLocalTransaction($transaction_id) { - $result = $this->db->query("SELECT * FROM " . DB_PREFIX . "paypal_order_transaction WHERE transaction_id = '" . $this->db->escape($transaction_id) . "'")->row; - - if ($result) { - return $result; - } else { - return false; - } - } - - public function getTransaction($transaction_id) { - $call_data = array( - 'METHOD' => 'GetTransactionDetails', - 'TRANSACTIONID' => $transaction_id, - ); - - return $this->call($call_data); - } - - public function getCurrencies() { - return array( - 'AUD', - 'BRL', - 'CAD', - 'CZK', - 'DKK', - 'EUR', - 'HKD', - 'HUF', - 'ILS', - 'JPY', - 'MYR', - 'MXN', - 'NOK', - 'NZD', - 'PHP', - 'PLN', - 'GBP', - 'SGD', - 'SEK', - 'CHF', - 'TWD', - 'THB', - 'TRY', - 'USD', - ); - } - - public function getOrderId($transaction_id) { - $query = $this->db->query("SELECT `o`.`order_id` FROM `" . DB_PREFIX . "paypal_order_transaction` `ot` LEFT JOIN `" . DB_PREFIX . "paypal_order` `o` ON `o`.`paypal_order_id` = `ot`.`paypal_order_id` WHERE `ot`.`transaction_id` = '" . $this->db->escape($transaction_id) . "' LIMIT 1"); - - return $query->row['order_id']; - } - - public function getCapturedTotal($paypal_order_id) { - $query = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' AND `pending_reason` != 'authorization' AND (`payment_status` = 'Partially-Refunded' OR `payment_status` = 'Completed' OR `payment_status` = 'Pending') AND `transaction_entity` = 'payment'"); - - return $query->row['amount']; - } - - public function getRefundedTotal($paypal_order_id) { - $query = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' AND `payment_status` = 'Refunded' AND `parent_id` != ''"); - - return $query->row['amount']; - } - - public function getRefundedTotalByParentId($transaction_id) { - $query = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `parent_id` = '" . $this->db->escape($transaction_id) . "' AND `payment_type` = 'refund'"); - - return $query->row['amount']; - } - - public function cleanReturn($data) { - $data = explode('&', $data); - - $arr = array(); - - foreach ($data as $k => $v) { - $tmp = explode('=', $v); - $arr[$tmp[0]] = urldecode($tmp[1]); - } - - return $arr; - } - - public function log($data, $title = null) { - if ($this->config->get('payment_pp_express_debug')) { - $this->log->write('PayPal Express debug (' . $title . '): ' . json_encode($data)); - } - } - - public function getOrder($order_id) { - $qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_order` WHERE `order_id` = '" . (int)$order_id . "' LIMIT 1"); - - if ($qry->num_rows) { - $order = $qry->row; - $order['transactions'] = $this->getTransactions($order['paypal_order_id']); - $order['captured'] = $this->totalCaptured($order['paypal_order_id']); - return $order; - } else { - return false; - } - } - - public function totalCaptured($paypal_order_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' AND `pending_reason` != 'authorization' AND (`payment_status` = 'Partially-Refunded' OR `payment_status` = 'Completed' OR `payment_status` = 'Pending') AND `transaction_entity` = 'payment'"); - - return $qry->row['amount']; - } - - public function getTransactions($paypal_order_id) { - $query = $this->db->query("SELECT `ot`.*, (SELECT COUNT(`ot2`.`paypal_order_id`) FROM `" . DB_PREFIX . "paypal_order_transaction` `ot2` WHERE `ot2`.`parent_id` = `ot`.`transaction_id`) AS `children` FROM `" . DB_PREFIX . "paypal_order_transaction` `ot` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' ORDER BY `date_added` ASC"); - - return $query->rows; - } - - public function getTokens($test) { - if ($test == 'sandbox') { - $endpoint = 'https://api.sandbox.paypal.com/v1/oauth2/token'; - $client_id = 'Ad3QTBAHwhuNI_blejO4_RqvES74yWRUC61c5QVNDbxkq9csbLpDZogWp_0n'; - $client_secret = 'EGqgGxCqjs1GIa5l1Ex_Flq0Mb2oMT3rJu2kwz6FuF9QKyxCg6qNqyddxCCW'; - } else { - $endpoint = 'https://api.paypal.com/v1/oauth2/token'; - $client_id = 'AWyAiBCUYsE156N8YpiiISQpSpep2HPoXXPrf33VBeYleE0SQJg40pgEqZvq'; - $client_secret = 'EEkc6xB30fDkgUO_YldWWHxKDquY7LBRId6FJ-parAR1CsVpK35zB6U0SIh4'; - } - - $request = ''; - $request .= 'client_id=' . $client_id; - $request .= '&client_secret=' . $client_secret; - $request .= '&grant_type=client_credentials'; - - $additional_opts = array( - CURLOPT_USERPWD => $client_id . ':' . $client_secret, - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => $request - ); - - $curl = $this->curl($endpoint, $additional_opts); - - $this->log('cURL Response 1: ' . print_r($curl, 1)); - - return $curl; - } - - public function getUserInfo($merchant_id, $test, $access_token) { - if ($test == 'sandbox') { - $endpoint = 'https://api.sandbox.paypal.com/v1/customer/partners/T4E8WSXT43QPJ/merchant-integrations'; - } else { - $endpoint = 'https://api.paypal.com/v1/customer/partners/9PDNYE4RZBVFJ/merchant-integrations'; - } - - $endpoint1 = $endpoint . '?tracking_id=' . $merchant_id; - - $header = array(); - $header[] = 'Content-Type: application/json'; - $header[] = 'Authorization: Bearer ' . $access_token; - $header[] = 'PAYPAL_SERVICE_VERSION:1.2.0'; - - $additional_opts = array( - CURLOPT_HTTPHEADER => $header, - ); - - $curl = $this->curl($endpoint1, $additional_opts); - - $this->log('cURL Response 2: ' . print_r($curl, 1)); - - if (isset($curl->merchant_id)) { - $endpoint2 = $endpoint . '/' . $curl->merchant_id; - $curl2 = $this->curl($endpoint2, $additional_opts); - - $this->log('cURL Response 3: ' . print_r($curl2, 1)); - - if (isset($curl2->api_credentials->signature)) { - return $curl2->api_credentials->signature; - } else { - return; - } - } else { - return; - } - } - - public function call($data) { - if ($this->config->get('payment_pp_express_test') == 1) { - $api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp'; - $user = $this->config->get('payment_pp_express_sandbox_username'); - $password = $this->config->get('payment_pp_express_sandbox_password'); - $signature = $this->config->get('payment_pp_express_sandbox_signature'); - } else { - $api_endpoint = 'https://api-3t.paypal.com/nvp'; - $user = $this->config->get('payment_pp_express_username'); - $password = $this->config->get('payment_pp_express_password'); - $signature = $this->config->get('payment_pp_express_signature'); - } - - $settings = array( - 'USER' => $user, - 'PWD' => $password, - 'SIGNATURE' => $signature, - 'VERSION' => '84', - 'BUTTONSOURCE' => 'OpenCart_Cart_EC', - ); - - $this->log($data, 'Call data'); - - $defaults = array( - CURLOPT_POST => 1, - CURLOPT_HEADER => 0, - CURLOPT_URL => $api_endpoint, - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1", - CURLOPT_FRESH_CONNECT => 1, - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_FORBID_REUSE => 1, - CURLOPT_TIMEOUT => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_POSTFIELDS => http_build_query(array_merge($data, $settings), '', "&") - ); - - $ch = curl_init(); - - curl_setopt_array($ch, $defaults); - - if (!$result = curl_exec($ch)) { - $log_data = array( - 'curl_error' => curl_error($ch), - 'curl_errno' => curl_errno($ch) - ); - - $this->log($log_data, 'CURL failed'); - return false; - } - - $this->log($result, 'Result'); - - curl_close($ch); - - return $this->cleanReturn($result); - } - - private function curl($endpoint, $additional_opts = array()) { - $default_opts = array( - CURLOPT_PORT => 443, - CURLOPT_HEADER => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_FORBID_REUSE => 1, - CURLOPT_FRESH_CONNECT => 1, - CURLOPT_URL => $endpoint, - ); - - $ch = curl_init($endpoint); - - $opts = $default_opts + $additional_opts; - - curl_setopt_array($ch, $opts); - - $response = json_decode(curl_exec($ch)); - - curl_close($ch); - - return $response; - } -} diff --git a/upload/admin/model/extension/payment/pp_payflow_iframe.php b/upload/admin/model/extension/payment/pp_payflow_iframe.php deleted file mode 100644 index 6dc509decbe..00000000000 --- a/upload/admin/model/extension/payment/pp_payflow_iframe.php +++ /dev/null @@ -1,136 +0,0 @@ -db->query(" - CREATE TABLE `" . DB_PREFIX . "paypal_payflow_iframe_order` ( - `order_id` int(11) NOT NULL, - `secure_token_id` varchar(255) NOT NULL, - `transaction_reference` varchar(255) DEFAULT NULL, - `transaction_type` varchar(1) DEFAULT NULL, - `complete` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY(`order_id`), - KEY `secure_token_id` (`secure_token_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci"); - - $this->db->query(" - CREATE TABLE `" . DB_PREFIX . "paypal_payflow_iframe_order_transaction` ( - `order_id` int(11) NOT NULL, - `transaction_reference` varchar(255) NOT NULL, - `transaction_type` char(1) NOT NULL, - `time` datetime NOT NULL, - `amount` decimal(10,4) DEFAULT NULL, - PRIMARY KEY (`transaction_reference`), - KEY `order_id` (`order_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - } - - public function uninstall() { - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_payflow_iframe_order`;"); - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_payflow_iframe_order_transaction`;"); - } - - public function log($message) { - if ($this->config->get('payment_pp_payflow_iframe_debug')) { - $log = new Log('payflow-iframe.log'); - $log->write($message); - } - } - - public function getOrder($order_id) { - $result = $this->db->query("SELECT * FROM " . DB_PREFIX . "paypal_payflow_iframe_order WHERE order_id = " . (int)$order_id); - - if ($result->num_rows) { - $order = $result->row; - } else { - $order = false; - } - - return $order; - } - - public function updateOrderStatus($order_id, $status) { - $this->db->query(" - UPDATE " . DB_PREFIX . "paypal_payflow_iframe_order - SET `complete` = " . (int)$status . " - WHERE order_id = '" . (int)$order_id . "' - "); - } - - public function addTransaction($data) { - $this->db->query(" - INSERT INTO " . DB_PREFIX . "paypal_payflow_iframe_order_transaction - SET order_id = " . (int)$data['order_id'] . ", - transaction_reference = '" . $this->db->escape($data['transaction_reference']) . "', - transaction_type = '" . $this->db->escape($data['type']) . "', - `time` = NOW(), - `amount` = '" . $this->db->escape($data['amount']) . "' - "); - } - - public function getTransactions($order_id) { - return $this->db->query(" - SELECT * - FROM " . DB_PREFIX . "paypal_payflow_iframe_order_transaction - WHERE order_id = " . (int)$order_id . " - ORDER BY `time` ASC")->rows; - } - - public function getTransaction($transaction_reference) { - $result = $this->db->query(" - SELECT * - FROM " . DB_PREFIX . "paypal_payflow_iframe_order_transaction - WHERE transaction_reference = '" . $this->db->escape($transaction_reference) . "'")->row; - - if ($result) { - $transaction = $result; - } else { - $transaction = false; - } - - return $transaction; - } - - public function call($data) { - $default_parameters = array( - 'USER' => $this->config->get('payment_pp_payflow_iframe_user'), - 'VENDOR' => $this->config->get('payment_pp_payflow_iframe_vendor'), - 'PWD' => $this->config->get('payment_pp_payflow_iframe_password'), - 'PARTNER' => $this->config->get('payment_pp_payflow_iframe_partner'), - 'BUTTONSOURCE' => 'OpenCart_Cart_PFP', - ); - - $call_parameters = array_merge($data, $default_parameters); - - if ($this->config->get('payment_pp_payflow_iframe_test')) { - $url = 'https://pilot-payflowpro.paypal.com'; - } else { - $url = 'https://payflowpro.paypal.com'; - } - - $query_params = array(); - - foreach ($call_parameters as $key => $value) { - $query_params[] = $key . '=' . utf8_decode($value); - } - - $this->log('Call data: ' . implode('&', $query_params)); - - $curl = curl_init($url); - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, implode('&', $query_params)); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = curl_exec($curl); - - $this->log('Response data: ' . $response); - - $response_params = array(); - parse_str($response, $response_params); - - return $response_params; - } -} \ No newline at end of file diff --git a/upload/admin/model/extension/payment/pp_pro_iframe.php b/upload/admin/model/extension/payment/pp_pro_iframe.php deleted file mode 100644 index f1df3b50805..00000000000 --- a/upload/admin/model/extension/payment/pp_pro_iframe.php +++ /dev/null @@ -1,261 +0,0 @@ -db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_iframe_order` ( - `paypal_iframe_order_id` int(11) NOT NULL AUTO_INCREMENT, - `order_id` int(11) NOT NULL, - `date_added` DATETIME NOT NULL, - `date_modified` DATETIME NOT NULL, - `capture_status` ENUM('Complete','NotComplete') DEFAULT NULL, - `currency_code` CHAR(3) NOT NULL, - `authorization_id` VARCHAR(30) NOT NULL, - `total` DECIMAL( 10, 2 ) NOT NULL, - PRIMARY KEY (`paypal_iframe_order_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); - - $this->db->query(" - CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_iframe_order_transaction` ( - `paypal_iframe_order_transaction_id` int(11) NOT NULL AUTO_INCREMENT, - `paypal_iframe_order_id` int(11) NOT NULL, - `transaction_id` CHAR(20) NOT NULL, - `parent_id` CHAR(20) NOT NULL, - `date_added` DATETIME NOT NULL, - `note` VARCHAR(255) NOT NULL, - `msgsubid` CHAR(38) NOT NULL, - `receipt_id` CHAR(20) NOT NULL, - `payment_type` ENUM('none','echeck','instant', 'refund', 'void') DEFAULT NULL, - `payment_status` CHAR(20) NOT NULL, - `pending_reason` CHAR(50) NOT NULL, - `transaction_entity` CHAR(50) NOT NULL, - `amount` DECIMAL( 10, 2 ) NOT NULL, - `debug_data` TEXT NOT NULL, - `call_data` TEXT NOT NULL, - PRIMARY KEY (`paypal_iframe_order_transaction_id`) - ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci;"); - } - - public function uninstall() { - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_iframe_order_transaction`;"); - $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_iframe_order`;"); - } - - private function getTransactions($paypal_iframe_order_id) { - $qry = $this->db->query("SELECT `ot`.*, ( SELECT count(`ot2`.`paypal_iframe_order_id`) FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` `ot2` WHERE `ot2`.`parent_id` = `ot`.`transaction_id` ) AS `children` FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` `ot` WHERE `paypal_iframe_order_id` = '" . (int)$paypal_iframe_order_id . "'"); - - if ($qry->num_rows) { - return $qry->rows; - } else { - return false; - } - } - - public function getTotalCaptured($paypal_iframe_order_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` WHERE `paypal_iframe_order_id` = '" . (int)$paypal_iframe_order_id . "' AND `pending_reason` != 'authorization' AND (`payment_status` = 'Partially-Refunded' OR `payment_status` = 'Completed' OR `payment_status` = 'Pending') AND `transaction_entity` = 'payment'"); - - return $qry->row['amount']; - } - - public function getTotalRefunded($paypal_iframe_order_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` WHERE `paypal_iframe_order_id` = '" . (int)$paypal_iframe_order_id . "' AND `payment_status` = 'Refunded'"); - - return $qry->row['amount']; - } - - public function getTotalRefundedTransaction($transaction_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` WHERE `parent_id` = '" . $this->db->escape($transaction_id) . "' AND `payment_type` = 'refund'"); - - return $qry->row['amount']; - } - - public function getOrder($order_id) { - $qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_iframe_order` WHERE `order_id` = '" . (int)$order_id . "' LIMIT 1"); - - if ($qry->num_rows) { - $order = $qry->row; - $order['transactions'] = $this->getTransactions($order['paypal_iframe_order_id']); - $order['captured'] = $this->getTotalCaptured($order['paypal_iframe_order_id']); - return $order; - } else { - return false; - } - } - - public function call($data) { - - if ($this->config->get('payment_pp_pro_iframe_test') == 1) { - $api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp'; - } else { - $api_endpoint = 'https://api-3t.paypal.com/nvp'; - } - - $settings = array( - 'USER' => $this->config->get('payment_pp_pro_iframe_user'), - 'PWD' => $this->config->get('payment_pp_pro_iframe_password'), - 'SIGNATURE' => $this->config->get('payment_pp_pro_iframe_sig'), - 'VERSION' => '84', - 'BUTTONSOURCE' => 'WM_PRO_OPENCART_UK_' . VERSION, - ); - - $this->log($data, 'Call data'); - - $defaults = array( - CURLOPT_POST => 1, - CURLOPT_HEADER => 0, - CURLOPT_URL => $api_endpoint, - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1", - CURLOPT_FRESH_CONNECT => 1, - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_FORBID_REUSE => 1, - CURLOPT_TIMEOUT => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_POSTFIELDS => http_build_query(array_merge($data, $settings), '', "&") - ); - - $ch = curl_init(); - - curl_setopt_array($ch, $defaults); - - if (!$result = curl_exec($ch)) { - - $log_data = array( - 'curl_error' => curl_error($ch), - 'curl_errno' => curl_errno($ch) - ); - - $this->log($log_data, 'CURL failed'); - - return false; - } - - $this->log($result, 'Result'); - - curl_close($ch); - - return $this->cleanReturn($result); - } - - public function updateOrder($capture_status, $order_id) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_iframe_order` SET `date_modified` = now(), `capture_status` = '" . $this->db->escape($capture_status) . "' WHERE `order_id` = '" . (int)$order_id . "'"); - } - - public function updateTransaction($transaction) { - $this->db->query(" - UPDATE " . DB_PREFIX . "paypal_iframe_order_transaction - SET paypal_iframe_order_id = " . (int)$transaction['paypal_iframe_order_id'] . ", - transaction_id = '" . $this->db->escape($transaction['transaction_id']) . "', - parent_id = '" . $this->db->escape($transaction['parent_id']) . "', - date_added = '" . $this->db->escape($transaction['date_added']) . "', - note = '" . $this->db->escape($transaction['note']) . "', - msgsubid = '" . $this->db->escape($transaction['msgsubid']) . "', - receipt_id = '" . $this->db->escape($transaction['receipt_id']) . "', - payment_type = '" . $this->db->escape($transaction['payment_type']) . "', - payment_status = '" . $this->db->escape($transaction['payment_status']) . "', - pending_reason = '" . $this->db->escape($transaction['pending_reason']) . "', - transaction_entity = '" . $this->db->escape($transaction['transaction_entity']) . "', - amount = '" . $this->db->escape($transaction['amount']) . "', - debug_data = '" . $this->db->escape($transaction['debug_data']) . "', - call_data = '" . $this->db->escape($transaction['call_data']) . "' - WHERE paypal_iframe_order_transaction_id = " . (int)$transaction['paypal_iframe_order_transaction_id'] . " - "); - } - - public function addTransaction($transaction_data, $request_data = array()) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_iframe_order_transaction` SET `paypal_iframe_order_id` = '" . (int)$transaction_data['paypal_iframe_order_id'] . "', `transaction_id` = '" . $this->db->escape($transaction_data['transaction_id']) . "', `parent_id` = '" . $this->db->escape($transaction_data['parent_id']) . "', `date_added` = NOW(), `note` = '" . $this->db->escape($transaction_data['note']) . "', `msgsubid` = '" . $this->db->escape($transaction_data['msgsubid']) . "', `receipt_id` = '" . $this->db->escape($transaction_data['receipt_id']) . "', `payment_type` = '" . $this->db->escape($transaction_data['payment_type']) . "', `payment_status` = '" . $this->db->escape($transaction_data['payment_status']) . "', `pending_reason` = '" . $this->db->escape($transaction_data['pending_reason']) . "', `transaction_entity` = '" . $this->db->escape($transaction_data['transaction_entity']) . "', `amount` = '" . (float)$transaction_data['amount'] . "', `debug_data` = '" . $this->db->escape($transaction_data['debug_data']) . "'"); - - $paypal_iframe_order_transaction_id = $this->db->getLastId(); - - if ($request_data) { - $serialized_data = json_encode($request_data); - - $this->db->query(" - UPDATE " . DB_PREFIX . "paypal_iframe_order_transaction - SET call_data = '" . $this->db->escape($serialized_data) . "' - WHERE paypal_iframe_order_transaction_id = " . (int)$paypal_iframe_order_transaction_id . " - LIMIT 1 - "); - } - - return $paypal_iframe_order_transaction_id; - } - - public function log($data, $title = null) { - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write($title . ': ' . json_encode($data)); - } - } - - public function getTransaction($transaction_id) { - $call_data = array( - 'METHOD' => 'GetTransactionDetails', - 'TRANSACTIONID' => $transaction_id, - ); - - return $this->call($call_data); - } - - public function getOrderId($transaction_id) { - $qry = $this->db->query("SELECT `o`.`order_id` FROM `" . DB_PREFIX . "paypal_iframe_order_transaction` `ot` LEFT JOIN `" . DB_PREFIX . "paypal_iframe_order` `o` ON `o`.`paypal_iframe_order_id` = `ot`.`paypal_iframe_order_id` WHERE `ot`.`transaction_id` = '" . $this->db->escape($transaction_id) . "' LIMIT 1"); - - if ($qry->num_rows) { - return $qry->row['order_id']; - } else { - return false; - } - } - - public function updateAuthorizationId($paypal_iframe_order_id, $authorization_id) { - $this->db->query(" - UPDATE `" . DB_PREFIX . "paypal_iframe_order` - SET `authorization_id` = '" . $this->db->escape($authorization_id) . "' - WHERE `paypal_iframe_order_id` = '" . $this->db->escape($paypal_iframe_order_id) . "' - "); - } - - public function updateRefundTransaction($transaction_id, $transaction_type) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_iframe_order_transaction` SET `payment_status` = '" . $this->db->escape($transaction_type) . "' WHERE `transaction_id` = '" . $this->db->escape($transaction_id) . "' LIMIT 1"); - } - - public function getFailedTransaction($paypl_iframe_order_transaction_id) { - $result = $this->db->query(" - SELECT * - FROM " . DB_PREFIX . "paypal_iframe_order_transaction - WHERE paypal_iframe_order_transaction_id = " . (int)$paypl_iframe_order_transaction_id . " - ")->row; - - if ($result) { - return $result; - } else { - return false; - } - } - - public function getLocalTransaction($transaction_id) { - $result = $this->db->query(" - SELECT * - FROM " . DB_PREFIX . "paypal_iframe_order_transaction - WHERE transaction_id = '" . $this->db->escape($transaction_id) . "' - ")->row; - - if ($result) { - return $result; - } else { - return false; - } - } - - protected function cleanReturn($data) { - $data = explode('&', $data); - - $arr = array(); - - foreach ($data as $k => $v) { - $tmp = explode('=', $v); - $arr[$tmp[0]] = urldecode($tmp[1]); - } - - return $arr; - } -} \ No newline at end of file diff --git a/upload/admin/view/image/payment/paypal/background.jpg b/upload/admin/view/image/payment/paypal/background.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1a93db60d5702561615b915705d671236e843e85 GIT binary patch literal 15960 zcmeI0cTm&Yw#S3m6_A5~fWT1{r5ggGQgUn{HEL*5guI-&_s!ut^JbWN_pkS|^UrV1@B3S8?a$hKXYbAH z=Y0hnFf%qa1_%iO07Cp9fJXydecj379>2-cK=}_2VfHKD%74PNDC0RKbA=&xBT*xz6X03ne99rZVHn zSBycO>PlUV+UdT_cx$`B(YA?de@3lG?X;a!v(B~42b-uiNE@J~4n;!OqUn-Fdx8!0 zvaX%8b@yeRP8%ERW*v$pkXT$?9C8UNE&&1o#l?x?Suc>D?4tGSk?5-65skbErSHD2 zMT}csa&h3PL5GHE<`3$_Z%LSRa#>x&D?9<&R8{>8WN!tKqoEu1@oIuvym490b6ZK* zUa_85g(oL&7UI8YlyWbO2E$BUEWz#FMpzBpKzu~DYErzaV>=!g65^PHg4<@fnpF}# zZ+;`-aC-_K?zx3`kkrDaaOIaC7x@h|yUk`qfbQ2E?6aiL*P+YOXxW3o^X*d8BPUCP zW@3RAUvpn9#4h_Y{Skzs3E$k}AN`~dy{2xW@}RS&o;uVz9N*$p%!n=GvRx;eEFh_r z21~=Y3_|gMZ%|D{51m1z8CcAd4W3!P?F~a1kKmGX7CJSi^FG4-3ek|c&b?((q^#eY z_V-Da$lC8sp^(_L3Ac*R2o7;86tiIxrdhP50L}({TUd&O9Ex>q~B7V*; zPiR%yebEue#=hz(lMcB=ot5#B-r;{@+!8Dv(@M3zv~n3bG#9b4H)J|iSfYxKv?0Iy zW^Zl{pXX#bv)CQsg^_K&vPV5<7;?*S1~CMVsj+Oi_^_kg*nV}W-@ZkBR59Ad(ttFj zQx$-|9r-HWb(NIue%ERF-K)WC&?Qq7F~~y^#STpRY#R@t#F{qPfY5C3t)Ea?56H=| zX?>Zv56d|%*QOfzfu;0*oG9{WJ~rpI*_ks}yVpM!q4t-~8xco3*SyK7s8R3}(8As~ z?4%(Cb7y1dWylx#&2e_^l?6Z3)f!6MFzKU*lKgJW%x2-{S|VNT6kZ!>-uv1QKUuV< z^mn|EC%+C|G+9tCSl1?fSY1oho5CAzNThC@A$O>b^qM>*hs%kKN`l>yf5$t1`0&Zw z8}2=%M|LZUE&*fQN>9@Jz?@c@m4{AYA7*Q29=O)$;(k2&JKnLp2mjuCX4T7Ojun(M z0zQRLyrCd%IP0sIYRygB6fpJ9o#%NgDc3h-T)ss_v}P_*u{^+@Hq>FyG0A{Ukk0)b zG5Lw;K^>H~w@ahidSdCDg~)+&=FnNlNc{Ty($q7gJJg0`-7;*+X__8feGX^Xi>;z! zVn3&OxvEnfd+Xj!)IY40d*+VKHYF5Olj|#rKjUTZ;B2!fp|v%$zics1`w@XpxZmU8hw!L2W zSF`g8(;A*d2k4zF4>?ju1;a1vsl=+39JlHbTU5Cp0v=5&n8acjL8aE9t z7cB`tyO#5rsP$%}1F{$v4)ATwLXJB^mb6>~#)sz`Dio}{8w_UZUhJTfqrr$(yXIxZ zFVS{Jhq>el7il`m(^p{+gOSp61E{hv{y>$ZogcN7qjas+-gn;Q8HpGo(>K!QB3hT+P|x4)>}4ciQ%z4zjyLAiaMgy_5`Q%D02l9zWGpIKHJDf)3*Jb<6PDC$Q} z|2hwl#{+n{XuwKV`HOq&zm`yy?@aD9X7E*o!;W`@TGO?x&s}6Ku1+xCrZ29pJ6t$S z>N0q~vLWVXrJkkljnXPM6c=L;>sEq!080(kNa6T@dL{i}86qUurN83Wm6UPo^a-vW zduGkSs-o(UN;f>PDd|Hi8#%pV$LKb9 zLroQ+s|1>g5@#M$6==@`OdZxansZ=fk_RxECgav*$L%SKou0=^*I~jYEBfELXOQ`* z(A>oamuWYIH<&DrV9m@F0rp?hw*Su_$Ak%b?0rqGAhq3~KD?(+9Cugup^zvJwyW7b`;Qm+7+Mxj`TOFBX3xduf5t%c zd!O}6ANg=9<#EffXR|ZXqWjUip(2di5=bsgrC8n7_wqH}KA;W1N%?jMb7{8tdBjVW z<_GPyFKEw5^`R-_?=cJ;+OjwEYnj_1Co{do0`e#$BPOP}b~2YC*=Kbt;QWZ;MCqdz zQDXXs9$XzZ|Mi=XaGk2=i7diCpL##JT40gu3q5_q<8qS@5|+Jaoyjks37!!}<@44! zBe5L;32VVHIYW|DmMPaUV0SNK(&cJqQfO$QZ)x$Mmwevm1?S&S=Ug-gcc4>G$(oth z#fF5Q3sNP+?X11^Uyi-3ua4I!Sx6&zeX7oTxJt5{Y!vEadyRAMK0YtoL z+qbITl1?mj2D^A$%&N|?Mt`CYavN1ik~KmwKyBkS2J5p^K+ zn}_?Y#AK}Q+O>IT`3CfU!VFKQmQ9tpEva&|PRml;Iq{ci!Rj|EE&77lEGosHiVuQH z*o0`>+2~xe1cGd!{M!L1O{Z!PMth%6A>*GH4r400j9L{8o?oOOsHIL5)ta2jzi5CS z_U90WId^>JHT0{~-_R3_3Ex}4&DEJdD%Ggu8j3tD=xW!k8;Fy0kW_)V{sVvgw1bJ_ z(*nbid@6It*{Q%YPNFXg;GhWeBBW?}&y6W(JR;QDyclT=JN^QxoZIE%^ljk=ecEll z>Y_$QyL+jsZ5`>OJG?}VF*xW%ExI{2Txmx2#DtE;2g3Tq@KYbzlt~{%gsDHW*(}u1 zFCB}1*vkoK9WTqgW6#;vxxWi5E4t7~QLZ1JD_Ugh5Z zx5`IIcm*)SrmYexIguw#G1VlD3rkb=#(WAQdVIIJ=b=uq_ot#l7oxits(uUeZH*`o z$P1APZI5~9Uh1mjx`-|aC6v8>FTP%g$!6QXSIl}%<|=ey8^dqjOLZMHu%>t1NpXr? zv%Z--%3KMu#_2|azUovxZ*JmvSEj;-=^L!RQ_C9szmIHZ#f{T|ZO}iT{#$xmHMZpg zbaB21wkqF>PPh;^=de2Xrg35_e^ER)aIV177Fs^Ym`m;&K81-ejQ_wGsVcwX@;=og zxnTd3KU>Fj3n7XD^CcQAFM@b7PQ6F#7{-58SJl+abdriS3!3<-YnG;Jx#t+}*wc6l z*~Y0{(KM}@x%V+NL=9{9yO#rRY; z%}_-)%*1c107o9}#yU$rcyCjWj(-isClNxChl~rFO~;a4@@$i;U+8vr%t(7{{$7EV z%8CHm7^$8(-Ar|kFHwD*(0$r%5G3bKSeqa{C)XOBAy6dR~CBu&G9FAGNBW8@?9lm?Uq{e&?eZ6&i1*L z6c;CkIeBpk*+wvS{r+;#<`a&v6#ZaC|&VebV&x zR1lfW^^Ug*P@HjiPcKBFZ$15b%uL~@6t`%q{wC}Y{BDclt;yb6snDp76s9Q2K9g`O zME8-4SXpf&WTJf)X=GzAa^p>K&(io6=5?%iR3s9Oqh@4cv@e`WFssPN?S2osprUbd zWc}*eGj8-yoQnzN%?dIkJ#qfgxL*K#qD`s?%P|eceArnWc6snAaY3ihk_I}gSjv}42Kbuh>`cY(|!BD zG`yI#KZ%d1m$LIO!l9PnZl!}I4HNMf-@l5d#_9i|I2wz>N-|{l~<@ePWgw&v<~uY-V2wL!b294wmtqpR(SXx#J4J z$EyF=t%JUb@V%$ zZ_jg#$U4V4#Ir<&6wP**=F2rXG*P8CrtDtuAR>Bv%__S(3UTX*lMp|hiPcn$PBel zh&_5=nXQty5f?WAx&UThux+*@-|B~#f1K+tN}$AaDAOTbw;TH_fks&UzN1EECu^z= zJO?J#@xl_sECr}^al(c*qs6VX`C8pF7c1Kd1)nL-p#y60$9_t2i{^iR-^8AtCcO0X zhnK2Rs>;i&2}mTu;kK#q;J{!O72k(9h)jkSn3)zsbRv`6)nSVHie(ZYad8kxKUb;C z!*e<&G3(=U#Drr&6`efe5{n}knrgHTsJMoB=zE$E1x@uLCXP#&xan&0wM%-(_gZOTC?6yXBk4%dXOV_ zSun+CvNb9r;4>{?X`_Jf&h#mLbc-c!UOiW-QN|X6zSV6JPTaKvCQ`Q=k-X32O-<|A zGxRyn@DU)V!@&q2h@B^&Uz_Z0CYtk*G`w@Q6gS_z} zPPlxmf9v|C!5r53c)gIF#`m9c+?x5H-&mX)j|m<_A+S+~uKv#YiLaSn5KCHfXcS>? zo#=pOT^K8?y_wV6C7!IymYmj%QclmBO|S|y*Wm&7mvwl=kz!Z~a2-)%Z6dB9V9EE< z#3Z4BW`Mk6IZM`~>51*aFG$T_%rXL3PGrkvSKzf&NTV!U%z>y|QJ<-@N*dgNmlY*; zI-D1+lZSKm1?$0M%0d*Q3%O9mbGOTv(x~edSnG-dmSdxx|CI3{m=xY~^&3198J1_E2}>^Vg4J-dWVWDduB_#`$_z#s2P2G<@n zO1eZ5UyK2SiT(O>id(XUt^;H#RlB#O-I_?=o)o9AbkF2dD{lRk8YcCJ7T3;Ivs9xX z{>bsp@W}4zCNz|qsP*Lb)ragJ_mtt40BrsVtSJs>=C$qn58I=`xZGhkWv~NPzff<5 z@}SuQlGCMp)GZP!4jkXBcN+xE192%p9w0Dgettf4$qn||&Ev#!(==pu=e1AYe#-IQ z-IZf_6wE6B6~-(b{TZT;+LMp1NbXceU3m|TLUqWabCsvwWH2QHV={7TVa*EHCmTRg l{v8%g&G-}v1*pV9tBJ=e7N=R9NWk$Ch5J9b->S*`@?QtTsLlWY literal 0 HcmV?d00001 diff --git a/upload/admin/view/image/payment/paypal/icon-all-settings-down.svg b/upload/admin/view/image/payment/paypal/icon-all-settings-down.svg new file mode 100644 index 00000000000..170630429f8 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-all-settings-down.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/admin/view/image/payment/paypal/icon-all-settings-up.svg b/upload/admin/view/image/payment/paypal/icon-all-settings-up.svg new file mode 100644 index 00000000000..eb6b703fab5 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-all-settings-up.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/admin/view/image/payment/paypal/icon-applepay-button.svg b/upload/admin/view/image/payment/paypal/icon-applepay-button.svg new file mode 100644 index 00000000000..ce5347ed454 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-applepay-button.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-back-dashboard.svg b/upload/admin/view/image/payment/paypal/icon-back-dashboard.svg new file mode 100644 index 00000000000..06d179f42a9 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-back-dashboard.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/admin/view/image/payment/paypal/icon-button.svg b/upload/admin/view/image/payment/paypal/icon-button.svg new file mode 100644 index 00000000000..7af7c52e397 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-button.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-card.svg b/upload/admin/view/image/payment/paypal/icon-card.svg new file mode 100644 index 00000000000..b87751bd3df --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-card.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-check-off.svg b/upload/admin/view/image/payment/paypal/icon-check-off.svg new file mode 100644 index 00000000000..69b40f07748 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-check-off.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-check-on.svg b/upload/admin/view/image/payment/paypal/icon-check-on.svg new file mode 100644 index 00000000000..72fd5295d70 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-check-on.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-contact.svg b/upload/admin/view/image/payment/paypal/icon-contact.svg new file mode 100644 index 00000000000..bb61bc66f3d --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-contact.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-general.svg b/upload/admin/view/image/payment/paypal/icon-general.svg new file mode 100644 index 00000000000..8d36092abd6 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-general.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-logo.svg b/upload/admin/view/image/payment/paypal/icon-logo.svg new file mode 100644 index 00000000000..2c49ebee0bd --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-logo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-message.svg b/upload/admin/view/image/payment/paypal/icon-message.svg new file mode 100644 index 00000000000..80d40d379d0 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-message.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-order-status.svg b/upload/admin/view/image/payment/paypal/icon-order-status.svg new file mode 100644 index 00000000000..9c274406fe7 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-order-status.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-panel-sale-analytics.svg b/upload/admin/view/image/payment/paypal/icon-panel-sale-analytics.svg new file mode 100644 index 00000000000..48a07a57387 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-panel-sale-analytics.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-panel-statistic.svg b/upload/admin/view/image/payment/paypal/icon-panel-statistic.svg new file mode 100644 index 00000000000..a2aec6153d3 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-panel-statistic.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-product.svg b/upload/admin/view/image/payment/paypal/icon-product.svg new file mode 100644 index 00000000000..16a729dde8d --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-product.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/upload/admin/view/image/payment/paypal/icon-section-panel.svg b/upload/admin/view/image/payment/paypal/icon-section-panel.svg new file mode 100644 index 00000000000..06c6b1344ff --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-section-panel.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/admin/view/image/payment/paypal/icon-statistic.svg b/upload/admin/view/image/payment/paypal/icon-statistic.svg new file mode 100644 index 00000000000..7d494bee8d3 --- /dev/null +++ b/upload/admin/view/image/payment/paypal/icon-statistic.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/upload/admin/view/javascript/paypal/bootstrap-switch.js b/upload/admin/view/javascript/paypal/bootstrap-switch.js new file mode 100644 index 00000000000..511f08fa8da --- /dev/null +++ b/upload/admin/view/javascript/paypal/bootstrap-switch.js @@ -0,0 +1,784 @@ +/** + * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches. + * + * @version v3.3.4 + * @homepage https://bttstrp.github.io/bootstrap-switch + * @author Mattia Larentis (http://larentis.eu) + * @license Apache-2.0 + */ + +(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(['jquery'], factory); + } else if (typeof exports !== "undefined") { + factory(require('jquery')); + } else { + var mod = { + exports: {} + }; + factory(global.jquery); + global.bootstrapSwitch = mod.exports; + } +})(this, function (_jquery) { + 'use strict'; + + var _jquery2 = _interopRequireDefault(_jquery); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var $ = _jquery2.default || window.jQuery || window.$; + + var BootstrapSwitch = function () { + function BootstrapSwitch(element) { + var _this = this; + + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, BootstrapSwitch); + + this.$element = $(element); + this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, this._getElementOptions(), options); + this.prevOptions = {}; + this.$wrapper = $('
', { + class: function _class() { + var classes = []; + classes.push(_this.options.state ? 'on' : 'off'); + if (_this.options.size) { + classes.push(_this.options.size); + } + if (_this.options.disabled) { + classes.push('disabled'); + } + if (_this.options.readonly) { + classes.push('readonly'); + } + if (_this.options.indeterminate) { + classes.push('indeterminate'); + } + if (_this.options.inverse) { + classes.push('inverse'); + } + if (_this.$element.attr('id')) { + classes.push('id-' + _this.$element.attr('id')); + } + return classes.map(_this._getClass.bind(_this)).concat([_this.options.baseClass], _this._getClasses(_this.options.wrapperClass)).join(' '); + } + }); + this.$container = $('
', { class: this._getClass('container') }); + this.$on = $('', { + html: this.options.onText, + class: this._getClass('handle-on') + ' ' + this._getClass(this.options.onColor) + }); + this.$off = $('', { + html: this.options.offText, + class: this._getClass('handle-off') + ' ' + this._getClass(this.options.offColor) + }); + this.$label = $('', { + html: this.options.labelText, + class: this._getClass('label') + }); + + this.$element.on('init.bootstrapSwitch', this.options.onInit.bind(this, element)); + this.$element.on('switchChange.bootstrapSwitch', function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (_this.options.onSwitchChange.apply(element, args) === false) { + if (_this.$element.is(':radio')) { + $('[name="' + _this.$element.attr('name') + '"]').trigger('previousState.bootstrapSwitch', true); + } else { + _this.$element.trigger('previousState.bootstrapSwitch', true); + } + } + }); + + this.$container = this.$element.wrap(this.$container).parent(); + this.$wrapper = this.$container.wrap(this.$wrapper).parent(); + this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off); + + if (this.options.indeterminate) { + this.$element.prop('indeterminate', true); + } + + this._init(); + this._elementHandlers(); + this._handleHandlers(); + this._labelHandlers(); + this._formHandler(); + this._externalLabelHandler(); + this.$element.trigger('init.bootstrapSwitch', this.options.state); + } + + _createClass(BootstrapSwitch, [{ + key: 'setPrevOptions', + value: function setPrevOptions() { + this.prevOptions = _extends({}, this.options); + } + }, { + key: 'state', + value: function state(value, skip) { + if (typeof value === 'undefined') { + return this.options.state; + } + if (this.options.disabled || this.options.readonly || this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) { + return this.$element; + } + if (this.$element.is(':radio')) { + $('[name="' + this.$element.attr('name') + '"]').trigger('setPreviousOptions.bootstrapSwitch'); + } else { + this.$element.trigger('setPreviousOptions.bootstrapSwitch'); + } + if (this.options.indeterminate) { + this.indeterminate(false); + } + this.$element.prop('checked', Boolean(value)).trigger('change.bootstrapSwitch', skip); + return this.$element; + } + }, { + key: 'toggleState', + value: function toggleState(skip) { + if (this.options.disabled || this.options.readonly) { + return this.$element; + } + if (this.options.indeterminate) { + this.indeterminate(false); + return this.state(true); + } else { + return this.$element.prop('checked', !this.options.state).trigger('change.bootstrapSwitch', skip); + } + } + }, { + key: 'size', + value: function size(value) { + if (typeof value === 'undefined') { + return this.options.size; + } + if (this.options.size != null) { + this.$wrapper.removeClass(this._getClass(this.options.size)); + } + if (value) { + this.$wrapper.addClass(this._getClass(value)); + } + this._width(); + this._containerPosition(); + this.options.size = value; + return this.$element; + } + }, { + key: 'animate', + value: function animate(value) { + if (typeof value === 'undefined') { + return this.options.animate; + } + if (this.options.animate === Boolean(value)) { + return this.$element; + } + return this.toggleAnimate(); + } + }, { + key: 'toggleAnimate', + value: function toggleAnimate() { + this.options.animate = !this.options.animate; + this.$wrapper.toggleClass(this._getClass('animate')); + return this.$element; + } + }, { + key: 'disabled', + value: function disabled(value) { + if (typeof value === 'undefined') { + return this.options.disabled; + } + if (this.options.disabled === Boolean(value)) { + return this.$element; + } + return this.toggleDisabled(); + } + }, { + key: 'toggleDisabled', + value: function toggleDisabled() { + this.options.disabled = !this.options.disabled; + this.$element.prop('disabled', this.options.disabled); + this.$wrapper.toggleClass(this._getClass('disabled')); + return this.$element; + } + }, { + key: 'readonly', + value: function readonly(value) { + if (typeof value === 'undefined') { + return this.options.readonly; + } + if (this.options.readonly === Boolean(value)) { + return this.$element; + } + return this.toggleReadonly(); + } + }, { + key: 'toggleReadonly', + value: function toggleReadonly() { + this.options.readonly = !this.options.readonly; + this.$element.prop('readonly', this.options.readonly); + this.$wrapper.toggleClass(this._getClass('readonly')); + return this.$element; + } + }, { + key: 'indeterminate', + value: function indeterminate(value) { + if (typeof value === 'undefined') { + return this.options.indeterminate; + } + if (this.options.indeterminate === Boolean(value)) { + return this.$element; + } + return this.toggleIndeterminate(); + } + }, { + key: 'toggleIndeterminate', + value: function toggleIndeterminate() { + this.options.indeterminate = !this.options.indeterminate; + this.$element.prop('indeterminate', this.options.indeterminate); + this.$wrapper.toggleClass(this._getClass('indeterminate')); + this._containerPosition(); + return this.$element; + } + }, { + key: 'inverse', + value: function inverse(value) { + if (typeof value === 'undefined') { + return this.options.inverse; + } + if (this.options.inverse === Boolean(value)) { + return this.$element; + } + return this.toggleInverse(); + } + }, { + key: 'toggleInverse', + value: function toggleInverse() { + this.$wrapper.toggleClass(this._getClass('inverse')); + var $on = this.$on.clone(true); + var $off = this.$off.clone(true); + this.$on.replaceWith($off); + this.$off.replaceWith($on); + this.$on = $off; + this.$off = $on; + this.options.inverse = !this.options.inverse; + return this.$element; + } + }, { + key: 'onColor', + value: function onColor(value) { + if (typeof value === 'undefined') { + return this.options.onColor; + } + if (this.options.onColor) { + this.$on.removeClass(this._getClass(this.options.onColor)); + } + this.$on.addClass(this._getClass(value)); + this.options.onColor = value; + return this.$element; + } + }, { + key: 'offColor', + value: function offColor(value) { + if (typeof value === 'undefined') { + return this.options.offColor; + } + if (this.options.offColor) { + this.$off.removeClass(this._getClass(this.options.offColor)); + } + this.$off.addClass(this._getClass(value)); + this.options.offColor = value; + return this.$element; + } + }, { + key: 'onText', + value: function onText(value) { + if (typeof value === 'undefined') { + return this.options.onText; + } + this.$on.html(value); + this._width(); + this._containerPosition(); + this.options.onText = value; + return this.$element; + } + }, { + key: 'offText', + value: function offText(value) { + if (typeof value === 'undefined') { + return this.options.offText; + } + this.$off.html(value); + this._width(); + this._containerPosition(); + this.options.offText = value; + return this.$element; + } + }, { + key: 'labelText', + value: function labelText(value) { + if (typeof value === 'undefined') { + return this.options.labelText; + } + this.$label.html(value); + this._width(); + this.options.labelText = value; + return this.$element; + } + }, { + key: 'handleWidth', + value: function handleWidth(value) { + if (typeof value === 'undefined') { + return this.options.handleWidth; + } + this.options.handleWidth = value; + this._width(); + this._containerPosition(); + return this.$element; + } + }, { + key: 'labelWidth', + value: function labelWidth(value) { + if (typeof value === 'undefined') { + return this.options.labelWidth; + } + this.options.labelWidth = value; + this._width(); + this._containerPosition(); + return this.$element; + } + }, { + key: 'baseClass', + value: function baseClass(value) { + return this.options.baseClass; + } + }, { + key: 'wrapperClass', + value: function wrapperClass(value) { + if (typeof value === 'undefined') { + return this.options.wrapperClass; + } + if (!value) { + value = $.fn.bootstrapSwitch.defaults.wrapperClass; + } + this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' ')); + this.$wrapper.addClass(this._getClasses(value).join(' ')); + this.options.wrapperClass = value; + return this.$element; + } + }, { + key: 'radioAllOff', + value: function radioAllOff(value) { + if (typeof value === 'undefined') { + return this.options.radioAllOff; + } + var val = Boolean(value); + if (this.options.radioAllOff === val) { + return this.$element; + } + this.options.radioAllOff = val; + return this.$element; + } + }, { + key: 'onInit', + value: function onInit(value) { + if (typeof value === 'undefined') { + return this.options.onInit; + } + if (!value) { + value = $.fn.bootstrapSwitch.defaults.onInit; + } + this.options.onInit = value; + return this.$element; + } + }, { + key: 'onSwitchChange', + value: function onSwitchChange(value) { + if (typeof value === 'undefined') { + return this.options.onSwitchChange; + } + if (!value) { + value = $.fn.bootstrapSwitch.defaults.onSwitchChange; + } + this.options.onSwitchChange = value; + return this.$element; + } + }, { + key: 'destroy', + value: function destroy() { + var $form = this.$element.closest('form'); + if ($form.length) { + $form.off('reset.bootstrapSwitch').removeData('bootstrap-switch'); + } + this.$container.children().not(this.$element).remove(); + this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch'); + return this.$element; + } + }, { + key: '_getElementOptions', + value: function _getElementOptions() { + return { + state: this.$element.is(':checked'), + size: this.$element.data('size'), + animate: this.$element.data('animate'), + disabled: this.$element.is(':disabled'), + readonly: this.$element.is('[readonly]'), + indeterminate: this.$element.data('indeterminate'), + inverse: this.$element.data('inverse'), + radioAllOff: this.$element.data('radio-all-off'), + onColor: this.$element.data('on-color'), + offColor: this.$element.data('off-color'), + onText: this.$element.data('on-text'), + offText: this.$element.data('off-text'), + labelText: this.$element.data('label-text'), + handleWidth: this.$element.data('handle-width'), + labelWidth: this.$element.data('label-width'), + baseClass: this.$element.data('base-class'), + wrapperClass: this.$element.data('wrapper-class') + }; + } + }, { + key: '_width', + value: function _width() { + var _this2 = this; + + var $handles = this.$on.add(this.$off).add(this.$label).css('width', ''); + var handleWidth = this.options.handleWidth === 'auto' ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth; + $handles.width(handleWidth); + this.$label.width(function (index, width) { + if (_this2.options.labelWidth !== 'auto') { + return _this2.options.labelWidth; + } + if (width < handleWidth) { + return handleWidth; + } + return width; + }); + this._handleWidth = this.$on.outerWidth(); + this._labelWidth = this.$label.outerWidth(); + this.$container.width(this._handleWidth * 2 + this._labelWidth); + return this.$wrapper.width(this._handleWidth + this._labelWidth); + } + }, { + key: '_containerPosition', + value: function _containerPosition() { + var _this3 = this; + + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.state; + var callback = arguments[1]; + + this.$container.css('margin-left', function () { + var values = [0, '-' + _this3._handleWidth + 'px']; + if (_this3.options.indeterminate) { + return '-' + _this3._handleWidth / 2 + 'px'; + } + if (state) { + if (_this3.options.inverse) { + return values[1]; + } else { + return values[0]; + } + } else { + if (_this3.options.inverse) { + return values[0]; + } else { + return values[1]; + } + } + }); + } + }, { + key: '_init', + value: function _init() { + var _this4 = this; + + var init = function init() { + _this4.setPrevOptions(); + _this4._width(); + _this4._containerPosition(); + setTimeout(function () { + if (_this4.options.animate) { + return _this4.$wrapper.addClass(_this4._getClass('animate')); + } + }, 50); + }; + if (this.$wrapper.is(':visible')) { + init(); + return; + } + var initInterval = window.setInterval(function () { + if (_this4.$wrapper.is(':visible')) { + init(); + return window.clearInterval(initInterval); + } + }, 50); + } + }, { + key: '_elementHandlers', + value: function _elementHandlers() { + var _this5 = this; + + return this.$element.on({ + 'setPreviousOptions.bootstrapSwitch': this.setPrevOptions.bind(this), + + 'previousState.bootstrapSwitch': function previousStateBootstrapSwitch() { + _this5.options = _this5.prevOptions; + if (_this5.options.indeterminate) { + _this5.$wrapper.addClass(_this5._getClass('indeterminate')); + } + _this5.$element.prop('checked', _this5.options.state).trigger('change.bootstrapSwitch', true); + }, + + 'change.bootstrapSwitch': function changeBootstrapSwitch(event, skip) { + event.preventDefault(); + event.stopImmediatePropagation(); + var state = _this5.$element.is(':checked'); + _this5._containerPosition(state); + if (state === _this5.options.state) { + return; + } + _this5.options.state = state; + _this5.$wrapper.toggleClass(_this5._getClass('off')).toggleClass(_this5._getClass('on')); + if (!skip) { + if (_this5.$element.is(':radio')) { + $('[name="' + _this5.$element.attr('name') + '"]').not(_this5.$element).prop('checked', false).trigger('change.bootstrapSwitch', true); + } + _this5.$element.trigger('switchChange.bootstrapSwitch', [state]); + } + }, + + 'focus.bootstrapSwitch': function focusBootstrapSwitch(event) { + event.preventDefault(); + _this5.$wrapper.addClass(_this5._getClass('focused')); + }, + + 'blur.bootstrapSwitch': function blurBootstrapSwitch(event) { + event.preventDefault(); + _this5.$wrapper.removeClass(_this5._getClass('focused')); + }, + + 'keydown.bootstrapSwitch': function keydownBootstrapSwitch(event) { + if (!event.which || _this5.options.disabled || _this5.options.readonly) { + return; + } + if (event.which === 37 || event.which === 39) { + event.preventDefault(); + event.stopImmediatePropagation(); + _this5.state(event.which === 39); + } + } + }); + } + }, { + key: '_handleHandlers', + value: function _handleHandlers() { + var _this6 = this; + + this.$on.on('click.bootstrapSwitch', function (event) { + event.preventDefault(); + event.stopPropagation(); + _this6.state(false); + return _this6.$element.trigger('focus.bootstrapSwitch'); + }); + return this.$off.on('click.bootstrapSwitch', function (event) { + event.preventDefault(); + event.stopPropagation(); + _this6.state(true); + return _this6.$element.trigger('focus.bootstrapSwitch'); + }); + } + }, { + key: '_labelHandlers', + value: function _labelHandlers() { + var _this7 = this; + + var handlers = { + click: function click(event) { + event.stopPropagation(); + }, + + + 'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': function mousedownBootstrapSwitchTouchstartBootstrapSwitch(event) { + if (_this7._dragStart || _this7.options.disabled || _this7.options.readonly) { + return; + } + event.preventDefault(); + event.stopPropagation(); + _this7._dragStart = (event.pageX || event.originalEvent.touches[0].pageX) - parseInt(_this7.$container.css('margin-left'), 10); + if (_this7.options.animate) { + _this7.$wrapper.removeClass(_this7._getClass('animate')); + } + _this7.$element.trigger('focus.bootstrapSwitch'); + }, + + 'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': function mousemoveBootstrapSwitchTouchmoveBootstrapSwitch(event) { + if (_this7._dragStart == null) { + return; + } + var difference = (event.pageX || event.originalEvent.touches[0].pageX) - _this7._dragStart; + event.preventDefault(); + if (difference < -_this7._handleWidth || difference > 0) { + return; + } + _this7._dragEnd = difference; + _this7.$container.css('margin-left', _this7._dragEnd + 'px'); + }, + + 'mouseup.bootstrapSwitch touchend.bootstrapSwitch': function mouseupBootstrapSwitchTouchendBootstrapSwitch(event) { + if (!_this7._dragStart) { + return; + } + event.preventDefault(); + if (_this7.options.animate) { + _this7.$wrapper.addClass(_this7._getClass('animate')); + } + if (_this7._dragEnd) { + var state = _this7._dragEnd > -(_this7._handleWidth / 2); + _this7._dragEnd = false; + _this7.state(_this7.options.inverse ? !state : state); + } else { + _this7.state(!_this7.options.state); + } + _this7._dragStart = false; + }, + + 'mouseleave.bootstrapSwitch': function mouseleaveBootstrapSwitch() { + _this7.$label.trigger('mouseup.bootstrapSwitch'); + } + }; + this.$label.on(handlers); + } + }, { + key: '_externalLabelHandler', + value: function _externalLabelHandler() { + var _this8 = this; + + var $externalLabel = this.$element.closest('label'); + $externalLabel.on('click', function (event) { + event.preventDefault(); + event.stopImmediatePropagation(); + if (event.target === $externalLabel[0]) { + _this8.toggleState(); + } + }); + } + }, { + key: '_formHandler', + value: function _formHandler() { + var $form = this.$element.closest('form'); + if ($form.data('bootstrap-switch')) { + return; + } + $form.on('reset.bootstrapSwitch', function () { + window.setTimeout(function () { + $form.find('input').filter(function () { + return $(this).data('bootstrap-switch'); + }).each(function () { + return $(this).bootstrapSwitch('state', this.checked); + }); + }, 1); + }).data('bootstrap-switch', true); + } + }, { + key: '_getClass', + value: function _getClass(name) { + return this.options.baseClass + '-' + name; + } + }, { + key: '_getClasses', + value: function _getClasses(classes) { + if (!$.isArray(classes)) { + return [this._getClass(classes)]; + } + return classes.map(this._getClass.bind(this)); + } + }]); + + return BootstrapSwitch; + }(); + + $.fn.bootstrapSwitch = function (option) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + function reducer(ret, next) { + var $this = $(next); + var existingData = $this.data('bootstrap-switch'); + var data = existingData || new BootstrapSwitch(next, option); + if (!existingData) { + $this.data('bootstrap-switch', data); + } + if (typeof option === 'string') { + return data[option].apply(data, args); + } + return ret; + } + return Array.prototype.reduce.call(this, reducer, this); + }; + $.fn.bootstrapSwitch.Constructor = BootstrapSwitch; + $.fn.bootstrapSwitch.defaults = { + state: true, + size: null, + animate: true, + disabled: false, + readonly: false, + indeterminate: false, + inverse: false, + radioAllOff: false, + onColor: 'primary', + offColor: 'default', + onText: 'ON', + offText: 'OFF', + labelText: ' ', + handleWidth: 'auto', + labelWidth: 'auto', + baseClass: 'bootstrap-switch', + wrapperClass: 'wrapper', + onInit: function onInit() {}, + onSwitchChange: function onSwitchChange() {} + }; +}); diff --git a/upload/admin/view/javascript/paypal/paypal.js b/upload/admin/view/javascript/paypal/paypal.js new file mode 100644 index 00000000000..eb4b1043f2e --- /dev/null +++ b/upload/admin/view/javascript/paypal/paypal.js @@ -0,0 +1,366 @@ +var PayPalAPI = (function () { + var paypal_data = []; + var paypal_script = []; + var paypal_sdk = []; + var paypal_callback; + + var readyPayPalSDK = function() { + if (typeof PayPalSDK === 'undefined') { + setTimeout(readyPayPalSDK, 100); + } else { + paypal_sdk[paypal_script.length - 1] = PayPalSDK; + + initPayPalSDK(); + } + }; + + var loadPayPalSDK = function() { + if (paypal_data['components'].includes('buttons')) { + $('#paypal_button_' + paypal_data['page_code'] + '_container').html(''); + $('#paypal_button_' + paypal_data['page_code'] + '_container').addClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('applepay')) { + $('#applepay_button_container').html(''); + $('#applepay_button_container').addClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('hosted-fields')) { + $('#paypal_card_container').find('iframe').remove(); + $('#paypal_card_container').addClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('messages')) { + $('#paypal_message_' + paypal_data['page_code'] + '_container').html(''); + $('#paypal_message_' + paypal_data['page_code'] + '_container').addClass('paypal-spinner'); + } + + var src_data = {}; + + src_data['components'] = paypal_data['components'].join(','); + src_data['client-id'] = paypal_data['client_id']; + src_data['merchant-id'] = paypal_data['merchant_id']; + src_data['currency'] = paypal_data['currency_code']; + src_data['intent'] = paypal_data['transaction_method']; + + if (paypal_data['button_enable_funding'] && paypal_data['button_enable_funding'].length) { + src_data['enable-funding'] = paypal_data['button_enable_funding'].join(','); + } + + if (paypal_data['button_disable_funding'] && paypal_data['button_disable_funding'].length) { + src_data['disable-funding'] = paypal_data['button_disable_funding'].join(','); + } + + var src = 'https://www.paypal.com/sdk/js?' + $.param(src_data); + var script_count = paypal_script.length; + var script_load_status = 0; + + for (var i = 0; i < script_count; i++) { + if (paypal_script[i].src == src) { + script_load_status = 1; + + break; + } + } + + if (!script_load_status) { + if (typeof PayPalSDK !== 'undefined') { + delete PayPalSDK; + } + + paypal_script[script_count] = document.createElement('script'); + paypal_script[script_count].type = 'text/javascript'; + paypal_script[script_count].src = src; + paypal_script[script_count].setAttribute('data-partner-attribution-id', paypal_data['partner_attribution_id']); + paypal_script[script_count].setAttribute('data-client-token', paypal_data['client_token']); + paypal_script[script_count].setAttribute('data-namespace', 'PayPalSDK'); + + paypal_script[script_count].async = false; + paypal_script[script_count].onload = readyPayPalSDK(); + + document.querySelector('body').appendChild(paypal_script[script_count]); + } else if (paypal_sdk[i]) { + PayPalSDK = paypal_sdk[i]; + + initPayPalSDK(); + } + }; + + var initPayPalSDK = function() { + if (paypal_data['components'].includes('buttons') && $('#paypal_button_' + paypal_data['page_code']).length) { + $('#paypal_button_' + paypal_data['page_code']).css('text-align', paypal_data['button_align']); + + if (paypal_data['button_width']) { + $('#paypal_button_' + paypal_data['page_code'] + '_container').css('display', 'inline-block'); + $('#paypal_button_' + paypal_data['page_code'] + '_container').css('width', paypal_data['button_width']); + } else { + $('#paypal_button_' + paypal_data['page_code'] + '_container').css('display', 'block'); + $('#paypal_button_' + paypal_data['page_code'] + '_container').css('width', 'auto'); + } + + try { + var paypal_button_data = { + env: paypal_data['environment'], + locale: paypal_data['locale'], + style: { + layout: ((paypal_data['page_code'] != 'checkout') ? 'horizontal' : 'vertical'), + size: paypal_data['button_size'], + color: paypal_data['button_color'], + shape: paypal_data['button_shape'], + label: paypal_data['button_label'], + tagline: ((paypal_data['page_code'] != 'checkout') ? paypal_data['button_tagline'] : 'false') + } + }; + + var paypal_button = PayPalSDK.Buttons(paypal_button_data); + + if (paypal_button.isEligible()) { + paypal_button.render('#paypal_button_' + paypal_data['page_code'] + '_container'); + } + } catch (error) { + console.error('PayPal Button failed during startup', error); + } + + $('#paypal_button_' + paypal_data['page_code'] + '_container').removeClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('applepay') && $('#applepay_button').length && !$('#applepay_button_container').html()) { + $('#applepay_button').css('text-align', paypal_data['applepay_button_align']); + + var applepay_button_style = []; + + if (paypal_data['applepay_button_width']) { + $('#applepay_button_container').css('display', 'inline-block'); + $('#applepay_button_container').css('width', paypal_data['applepay_button_width']); + } else { + $('#applepay_button_container').css('display', 'block'); + $('#applepay_button_container').css('width', 'auto'); + } + + var applepay_button = document.createElement('apple-pay-button'); + + applepay_button.setAttribute('id', 'apple-pay-button'); + applepay_button.setAttribute('buttonstyle', paypal_data['applepay_button_color']); + applepay_button.setAttribute('type', paypal_data['applepay_button_type']); + applepay_button.setAttribute('locale', paypal_data['locale']); + + var applepay_button_style = []; + + applepay_button_style.push('display: inline-block'); + + if (paypal_data['applepay_button_width']) { + applepay_button_style.push('--apple-pay-button-width: ' + paypal_data['applepay_button_width']); + } else { + applepay_button_style.push('--apple-pay-button-width: 100%'); + } + + applepay_button_style.push('--apple-pay-button-height: calc(var(--apple-pay-button-width) / 7.5)'); + + if (paypal_data['applepay_button_shape'] == 'pill') { + applepay_button_style.push('--apple-pay-button-border-radius: 1000px'); + } else { + applepay_button_style.push('--apple-pay-button-border-radius: 4px'); + } + + applepay_button.setAttribute('style', applepay_button_style.join('; ')); + + document.querySelector('#applepay_button_container').appendChild(applepay_button); + + $('#applepay_button_container').removeClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('hosted-fields') && $('#paypal_card').length) { + $('#paypal_card').css('text-align', paypal_data['card_align']); + + if (paypal_data['card_width']) { + $('#paypal_card_container').css('display', 'inline-block'); + $('#paypal_card_container').css('width', paypal_data['card_width']); + } else { + $('#paypal_card_container').css('display', 'block'); + $('#paypal_card_container').css('width', 'auto'); + } + + try { + // Check if card fields are eligible to render for the buyer's country. The card fields are not eligible in all countries where buyers are located. + if (PayPalSDK.HostedFields.isEligible() === true) { + var paypal_card_form = document.querySelector('#paypal_card_form'); + var paypal_button_submit = document.querySelector('#paypal_button_submit'); + + PayPalSDK.HostedFields.render({ + styles: { + 'input': { + 'color': '#282c37', + 'transition': 'color 0.1s', + 'line-height': '3' + }, + 'input.invalid': { + 'color': '#E53A40' + }, + ':-ms-input-placeholder': { + 'color': 'rgba(0,0,0,0.6)' + }, + ':-moz-placeholder': { + 'color': 'rgba(0,0,0,0.6)' + } + }, + fields: { + number: { + selector: '#card_number', + placeholder: '#### #### #### ####' + }, + cvv: { + selector: '#cvv', + placeholder: '###' + }, + expirationDate: { + selector: '#expiration_date', + placeholder: 'MM / YYYY' + } + }, + createOrder: function(data, actions) { + paypal_order_id = false; + + return paypal_order_id; + } + }).then(function(hostedFieldsInstance) { + hostedFieldsInstance.on('blur', function (event) { + console.log('CCF Event "blur", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('focus', function (event) { + console.log('CCF Event "focus", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('validityChange', function (event) { + console.log('CCF Event "validityChange", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + // Check if all fields are valid, then show submit button + var formValid = Object.keys(event.fields).every(function (key) { + return event.fields[key].isValid; + }); + + if (formValid) { + $('#paypal_button_submit').addClass('show-button'); + } else { + $('#paypal_button_submit').removeClass('show-button'); + } + }); + + hostedFieldsInstance.on('notEmpty', function (event) { + console.log('CCF Event "notEmpty", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('empty', function (event) { + console.log('CCF Event "empty", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + $(paypal_card_form).removeClass().addClass('well'); + $('#card_image').removeClass(); + }); + + hostedFieldsInstance.on('cardTypeChange', function (event) { + console.log('CCF Event "cardTypeChange", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + $(paypal_card_form).removeClass().addClass('well'); + $('#card_image').removeClass(); + + // Change card bg depending on card type + if (event.cards.length === 1) { + $(paypal_card_form).addClass(event.cards[0].type); + $('#card_image').addClass(event.cards[0].type); + + // Change the CVV length for AmericanExpress cards + if (event.cards[0].code.size === 4) { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '####' + }); + } else { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '###' + }); + } + } else { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '###' + }); + } + }); + }); + } else { + console.log('Not eligible for CCF'); + } + } catch (error) { + console.error('PayPal Card failed during startup', error); + } + + $('#paypal_card_container').removeClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('messages') && $('#paypal_message_' + paypal_data['page_code']).length) { + $('#paypal_message_' + paypal_data['page_code']).css('text-align', paypal_data['message_align']); + + if (paypal_data['message_width']) { + $('#paypal_message_' + paypal_data['page_code'] + '_container').css('display', 'inline-block'); + $('#paypal_message_' + paypal_data['page_code'] + '_container').css('width', paypal_data['message_width']); + } else { + $('#paypal_message_' + paypal_data['page_code'] + '_container').css('display', 'block'); + $('#paypal_message_' + paypal_data['page_code'] + '_container').css('width', 'auto'); + } + + var paypal_message = document.createElement('div'); + + paypal_message.setAttribute('data-pp-message', ''); + + if (paypal_data['page_code'] == 'home') { + paypal_message.setAttribute('data-pp-placement', 'home'); + } + + if (paypal_data['page_code'] == 'product') { + paypal_message.setAttribute('data-pp-placement', 'product'); + } + + if (paypal_data['page_code'] == 'cart') { + paypal_message.setAttribute('data-pp-placement', 'cart'); + } + + if (paypal_data['page_code'] == 'checkout') { + paypal_message.setAttribute('data-pp-placement', 'payment'); + } + + paypal_message.setAttribute('data-pp-amount', '33.00'); + paypal_message.setAttribute('data-pp-style-layout', paypal_data['message_layout']); + + if (paypal_data['message_layout'] == 'text') { + paypal_message.setAttribute('data-pp-style-text-color', paypal_data['message_text_color']); + paypal_message.setAttribute('data-pp-style-text-size', paypal_data['message_text_size']); + } else { + paypal_message.setAttribute('data-pp-style-color', paypal_data['message_flex_color']); + paypal_message.setAttribute('data-pp-style-ratio', paypal_data['message_flex_ratio']); + } + + document.querySelector('#paypal_message_' + paypal_data['page_code'] + '_container').appendChild(paypal_message); + + $('#paypal_message_' + paypal_data['page_code'] + '_container').removeClass('paypal-spinner'); + } + + if (paypal_callback && typeof paypal_callback == 'function') { + paypal_callback(); + } + }; + + var init = function(data, callback = '') { + paypal_data = data; + paypal_callback = callback; + + loadPayPalSDK(); + }; + + return { + init: init + }; +}()); \ No newline at end of file diff --git a/upload/admin/view/stylesheet/paypal/bootstrap-switch.css b/upload/admin/view/stylesheet/paypal/bootstrap-switch.css new file mode 100644 index 00000000000..097b800d475 --- /dev/null +++ b/upload/admin/view/stylesheet/paypal/bootstrap-switch.css @@ -0,0 +1,187 @@ +/** + * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches. + * + * @version v3.3.4 + * @homepage https://bttstrp.github.io/bootstrap-switch + * @author Mattia Larentis (http://larentis.eu) + * @license Apache-2.0 + */ + +.bootstrap-switch { + display: inline-block; + direction: ltr; + cursor: pointer; + border-radius: 3px; + border: 1px solid; + border-color: #C5D5FF; + position: relative; + text-align: left; + overflow: hidden; + line-height: 8px; + z-index: 0; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + vertical-align: middle; + -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; +} +.bootstrap-switch .bootstrap-switch-container { + display: inline-block; + top: 0; + border-radius: 3px; + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); +} +.bootstrap-switch .bootstrap-switch-handle-on, +.bootstrap-switch .bootstrap-switch-handle-off, +.bootstrap-switch .bootstrap-switch-label { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + cursor: pointer; + display: table-cell; + vertical-align: middle; + padding: 12px 15px; + font-size: 13px; + line-height: 18px; +} +.bootstrap-switch .bootstrap-switch-handle-on, +.bootstrap-switch .bootstrap-switch-handle-off { + text-align: center; + z-index: 1; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary { + color: #fff; + background: #337ab7; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info { + color: #fff; + background: #5bc0de; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success { + color: #fff; + background: #30986c; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning { + background: #f0ad4e; + color: #fff; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger { + color: #fff; + background: #d9534f; +} +.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default, +.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default { + color: #717171; + background: #eeeeee; +} +.bootstrap-switch .bootstrap-switch-label { + text-align: center; + margin-top: -1px; + margin-bottom: -1px; + z-index: 100; + color: #333; + background: #fff; +} +.bootstrap-switch span::before { + content: "\200b"; +} +.bootstrap-switch .bootstrap-switch-handle-on { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} +.bootstrap-switch .bootstrap-switch-handle-off { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.bootstrap-switch input[type='radio'], +.bootstrap-switch input[type='checkbox'] { + position: absolute !important; + top: 0; + left: 0; + margin: 0; + z-index: -1; + opacity: 0; + filter: alpha(opacity=0); + visibility: hidden; +} +.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; +} +.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label { + padding: 5px 10px; + font-size: 12px; + line-height: 1.5; +} +.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label { + padding: 6px 16px; + font-size: 18px; + line-height: 1.3333333; +} +.bootstrap-switch.bootstrap-switch-disabled, +.bootstrap-switch.bootstrap-switch-readonly, +.bootstrap-switch.bootstrap-switch-indeterminate { + cursor: default !important; +} +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label { + opacity: 0.5; + filter: alpha(opacity=50); + cursor: default !important; +} +.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container { + -webkit-transition: margin-left 0.5s; + -o-transition: margin-left 0.5s; + transition: margin-left 0.5s; +} +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on { + border-bottom-left-radius: 0; + border-top-left-radius: 0; + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off { + border-bottom-right-radius: 0; + border-top-right-radius: 0; + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-focused { + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); +} +.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} diff --git a/upload/admin/view/stylesheet/paypal/card.css b/upload/admin/view/stylesheet/paypal/card.css new file mode 100644 index 00000000000..2e30a933677 --- /dev/null +++ b/upload/admin/view/stylesheet/paypal/card.css @@ -0,0 +1,130 @@ +#paypal_card_form { + color: #717171; + text-align: center; + transition: all 600ms cubic-bezier(0.2, 1.3, 0.7, 1); + -webkit-animation: cardIntro 500ms cubic-bezier(0.2, 1.3, 0.7, 1); + animation: cardIntro 500ms cubic-bezier(0.2, 1.3, 0.7, 1); + z-index: 1; +} +#paypal_card_form.visa { + color: #fff; + background-color: #0D4AA2; +} +#paypal_card_form.master-card { + color: #fff; + background-color: #363636; + background: linear-gradient(115deg, #d82332, #d82332 50%, #f1ad3d 50%, #f1ad3d); +} +#paypal_card_form.maestro { + color: #fff; + background-color: #363636; + background: linear-gradient(115deg, #009ddd, #009ddd 50%, #ed1c2e 50%, #ed1c2e); +} +#paypal_card_form.american-express { + color: #fff; + background-color: #007CC3; +} +#paypal_card_form.discover { + color: #fff; + background-color: #ff6000; + background: linear-gradient(#d14310, #f7961e); +} +#paypal_card_form.unionpay, #paypal_card_form.jcb, #paypal_card_form.diners-club { + color: #fff; + background-color: #363636; +} +#paypal_card_form .card-info-number, +#paypal_card_form .card-info-date-cvv { + position: relative; + text-align: left; +} +#paypal_card_form .card-info-date { + width: 48%; + float: left; + margin-bottom: 0.5em; +} +#paypal_card_form .card-info-cvv { + width: 48%; + float: right; + margin-bottom: 0.5em; +} +#paypal_card_form .card-info-number, +#paypal_card_form .card-info-date, +#paypal_card_form .card-info-cvv { + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; +} +#paypal_card_form .card-label { + display: block; + margin-bottom: 0.5em; + text-transform: uppercase; +} +#paypal_card_form .card-input-container { + position: relative; + height: 2.75em; + padding: 5px 10px; + margin-bottom: 1em; + background: rgba(255, 255, 255, 0.86); + border: 1px solid #eee; + border-radius: 2px; +} +#paypal_card_form #card_image { + position: absolute; + top: 0px; + right: 2px; + width: 44px; + height: 28px; + background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/346994/card_sprite.png); + background-size: 86px 458px; + border-radius: 4px; + background-position: -100px 0; + background-repeat: no-repeat; +} +#paypal_card_form #card_image.visa { + background-position: 0 -398px; +} +#paypal_card_form #card_image.master-card { + background-position: 0 -281px; +} +#paypal_card_form #card_image.american-express { + background-position: 0 -370px; +} +#paypal_card_form #card_image.discover { + background-position: 0 -163px; +} +#paypal_card_form #card_image.maestro { + background-position: 0 -251px; +} +#paypal_card_form #card_image.jcb { + background-position: 0 -221px; +} +#paypal_card_form #card_image.diners-club { + background-position: 0 -133px; +} +#paypal_card_form #paypal_button_submit { + width: 100%; + padding: 1em 1em; + color: #fff; + background: #282c37; + font-size: 15px; + box-shadow: none; + -moz-box-shadow: none; + -webkit-box-shadow: none; + border: 0; + z-index: 0; + opacity: 0.1; + outline: 0; + -webkit-appearance: none; +} +#paypal_card_form #paypal_button_submit:hover { + background: #535b72; +} +#paypal_card_form #paypal_button_submit:active { + -webkit-animation: cardIntro 200ms cubic-bezier(0.2, 1.3, 0.7, 1); + animation: cardIntro 200ms cubic-bezier(0.2, 1.3, 0.7, 1); +} +#paypal_card_form #paypal_button_submit.show-button { + opacity: 1; + cursor: pointer; +} \ No newline at end of file diff --git a/upload/admin/view/stylesheet/paypal/paypal.css b/upload/admin/view/stylesheet/paypal/paypal.css new file mode 100644 index 00000000000..2ff5760d69a --- /dev/null +++ b/upload/admin/view/stylesheet/paypal/paypal.css @@ -0,0 +1,959 @@ +.payment-paypal { + font-size: 13px; + line-height: 1.4; +} +.payment-paypal .hidden, .payment-paypal [hidden] { + display: none !important; +} +.payment-paypal [tabindex="-1"]:focus { + outline: 0 !important; +} +.payment-paypal a { + background-color: transparent; +} +.payment-paypal a:active, .payment-paypal a:focus, .payment-paypal a:hover { + outline: 0 !important; +} +.payment-paypal button:active, .payment-paypal button:focus, .payment-paypal button:hover { + outline: 0 !important; +} +.payment-paypal button, .payment-paypal input { + overflow: visible; +} +.payment-paypal button, .payment-paypal select { + text-transform: none; +} +.payment-paypal button, .payment-paypal input[type="button"], .payment-paypal input[type="submit"] { + -webkit-appearance: button; + cursor: pointer; +} +.payment-paypal button[disabled], .payment-paypal innput[disabled] { + cursor: default; +} +.payment-paypal button::-moz-focus-inner, .payment-paypal input::-moz-focus-inner { + padding: 0; + border: 0; +} +.payment-paypal [role="button"] { + cursor: pointer; +} +@media (min-width: 1200px) { + .payment-paypal .flex-row { + display: flex; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + } + .payment-paypal .flex-row > .col { + display: flex; + flex-direction: column; + } +} +.payment-paypal .dropdown-menu { + padding: 0px 0px; + border: 1px solid #919697; + border-radius: 3px; + box-shadow: none; +} +.payment-paypal .dropdown-item { + display: block; + padding: 5px 20px; + clear: both; + font-weight: normal; + line-height: 1.42857; + color: #000000; + background-color: transparent; + white-space: nowrap; +} +.payment-paypal .dropdown-item:hover, .payment-paypal .dropdown-item:focus { + color: #000000; + background-color: transparent; +} +.payment-paypal .dropdown-item.active, .dropdown-item:active { + color: #FFFFFF; + text-decoration: none; + background-color: #306EB9; +} +.payment-paypal .legend { + font-size: 15px; + font-weight: 700; + color: #000000; + margin: 0px 0px; + border: none; +} +.payment-paypal .alert { + position: relative; + padding: 18px 30px 18px 15px; + margin-bottom: 22px; + font-size: 13px; + border: 1px solid transparent; + border-radius: 3px; +} +.payment-paypal .alert-info { + background-color: #F2F6FF; + border-color: #C5D5FF; + color: #000000; +} +.payment-paypal .alert-info .alert-link { + color: #000000; +} +.payment-paypal .alert .close { + position: absolute; + top: 15px; + right: 10px; + font-size: 25px; +} +.payment-paypal .footnote { + color: #000000; +} +.payment-paypal .footnote a { + color: #2F6ED9; +} +.payment-paypal .panel-default { + border: none; + border-radius: 0px; + box-shadow: none; + -webkit-box-shadow: none; +} +.payment-paypal .panel-default .panel-heading { + background: transparent linear-gradient(270deg, #1D4896 0%, #4396D5 50%, #2150A3 100%); + border: none; + border-radius: 0px; + box-shadow: none; +} +.payment-paypal .panel-default .panel-heading .panel-title { + color: #FFFFFF; +} +.payment-paypal .panel-default .panel-body { + padding: 24px 30px 37px 30px; + background-color: #F5F7FA; + border: 1px solid #D1D8EB; + border-radius: 0px; +} +.payment-paypal .panel-default .row { + margin: 0px -11px; +} +.payment-paypal .panel-default .col { + padding: 0px 11px; +} +.payment-paypal .panel-default .form-group { + padding-top: 11px; + padding-bottom: 11px; + margin-bottom: 0px; + border: none; +} +.payment-paypal .panel-default .form-group .alert { + margin-bottom: 0px; +} +.payment-paypal .panel-default .btn { + padding: 11px 33px; + font-size: 13px; + font-weight: 600; + line-height: 1.2; + letter-spacing: 0.45px; + border-radius: 25px; +} +.payment-paypal .panel-default .btn-primary { + color: #FFFFFF; + background: #102F82; + border-color: transparent; +} +.payment-paypal .panel-default .btn-danger { + color: #FFFFFF; + background: #BE3737; + border-color: transparent; +} +.payment-paypal .panel-default .btn-default { + color: #2F6ED9; + background: transparent; + border-color: #306ED8; +} +.payment-paypal .panel-default .control-label { + font-size: 13px; + font-weight: 400; + color: #000000; +} +.payment-paypal .panel-default .form-control { + height: 42px; + padding: 10px 10px; + font-size: 13px; + color: #000000; + border: 1px solid #919697; + border-radius: 3px; +} +.payment-paypal .panel-default .form-control:focus { + border-color: #488DE6; + -webkit-box-shadow: none; + box-shadow: none; +} +.payment-paypal .panel-default textarea.form-control, .payment-paypal .panel-default .form-control[multiple] { + height: auto; +} +.payment-paypal .panel-default .form-check-input { + display: inline-block; + width: 27px; + height: 27px; + margin: 0px 15px 0px 0px; + vertical-align: middle; + background-color: #FFFFFF; + background-repeat: no-repeat; + background-size: contain; + background-position: center; + border: 1px solid #919697; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + -webkit-print-color-adjust: exact; + color-adjust: exact; + cursor: pointer; +} +.payment-paypal .panel-default .form-check-input[type=radio] { + border-radius: 50%; +} +.payment-paypal .panel-default .form-check-input:checked[type="checkbox"] { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e"); +} +.payment-paypal .panel-default .form-check-input:checked[type="radio"] { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e"); +} +.payment-paypal .panel-default .form-check-input:checked { + background-color: #306EB9; + border-color: #306EB9; +} +.payment-paypal .panel-default .form-check-input:checked:after { + display: none; +} +.payment-paypal .panel-default .form-check-input + .control-label { + display: inline-block; + margin: 0px 0px; + vertical-align: middle; +} +.payment-paypal .panel-default .hr { + display: inline-block; + width: 100%; + height: 1px; + margin: 11px 0px; + background: #C5D5FF; + border: none; + opacity: 1; +} +.payment-paypal .panel-default .back-dashboard { + display: inline-block; + font-size: 13px; + font-weight: 700; + color: #102F82; + margin-bottom: 20px; +} +.payment-paypal .panel-default .back-dashboard .icon-back-dashboard { + display: inline-block; + width: 14px; + height: 12px; + vertical-align: middle; + background-image: url('../../image/payment/paypal/icon-back-dashboard.svg'); + background-size: contain; + background-repeat: no-repeat; + margin: 0px 7px 0px 0px; +} +.payment-paypal .panel-default .nav-tabs { + position: relative; + margin: 0px 0px 13px 0px; + overflow-x: auto; + overflow-y: hidden; + scrollbar-color: #003087 #FFFFFF; + border: none; + white-space: nowrap; +} +.payment-paypal .panel-default .nav-tabs::-webkit-scrollbar-track { + background-color: #FFFFFF; + border: 1px solid #C5D5FF; + border-radius: 7px; + margin-bottom: 17px; +} +.payment-paypal .panel-default .nav-tabs::-webkit-scrollbar { + height: 7px; + background-color: #FFFFFF; +} +.payment-paypal .panel-default .nav-tabs::-webkit-scrollbar-thumb { + border-radius: 7px; + background-color: #003087; +} +.payment-paypal .panel-default .nav-tab { + display: inline-block; + float: none; + margin: 0px 0px 13px 0px; + border-bottom: 3px solid transparent; +} +.payment-paypal .panel-default .nav-tab.active { + border-bottom: 3px solid #2F6ED9; +} +.payment-paypal .panel-default .nav-tab .tab { + padding: 10px 15px; + background: transparent; + border: none; +} +.payment-paypal .panel-default .nav-tab .tab .tab-title { + display: inline-block; + font-size: 13px; + font-weight: 400; + color: #000000; + vertical-align: middle; +} +.payment-paypal .panel-default .nav-tab.active .tab .tab-title { + font-weight: 700; +} +.payment-paypal .panel-default .tab .tab-icon { + display: inline-block; + height: 29px; + vertical-align: middle; + background-size: contain; + background-repeat: no-repeat; + margin: 0px 11px 0px 0px; +} +.payment-paypal .panel-default .tab .tab-icon-general { + width: 37px; + background-image: url('../../image/payment/paypal/icon-general.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-button { + width: 37px; + background-image: url('../../image/payment/paypal/icon-button.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-applepay-button { + width: 37px; + background-image: url('../../image/payment/paypal/icon-applepay-button.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-card { + width: 33px; + background-image: url('../../image/payment/paypal/icon-card.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-message { + width: 37px; + background-image: url('../../image/payment/paypal/icon-message.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-order-status { + width: 28px; + background-image: url('../../image/payment/paypal/icon-order-status.svg'); +} +.payment-paypal .panel-default .tab .tab-icon-contact { + width: 37px; + background-image: url('../../image/payment/paypal/icon-contact.svg'); +} +.payment-paypal .panel-default .section-content { + padding: 33px 33px; + background: #FFFFFF; + border: 1px solid #C5D5FF; +} +.payment-paypal .panel-default .nav-pills { + margin: 0px 0px 4px 0px; +} +.payment-paypal .panel-default .nav-pill { + background: transparent; + border: 1px solid #2F6ED9; + border-radius: 25px; + margin: 0px 15px 0px 0px; +} +.payment-paypal .panel-default .nav-pill.active { + background: #2F6ED9; +} +.payment-paypal .panel-default .nav-pill .pill { + padding: 10px 19px; + font-size: 13px; + font-weight: 600; + color: #2F6ED9; + background: transparent; + border: none; +} +.payment-paypal .panel-default .nav-pill.active .pill { + color: #FFFFFF; +} +.payment-paypal .panel-default .tab-content { + padding: 11px 0px; +} +.payment-paypal .panel-default .button-disconnect { + display: block; + margin: 0px 0px 11px 0px; +} +.payment-paypal .panel-default .button-all-settings { + display: block; + margin: 11px 0px 11px 0px; +} +.payment-paypal .panel-default .button-all-settings .icon-all-settings { + display: inline-block; + width: 10px; + height: 7px; + margin-left: 5px; + background-image: url('../../image/payment/paypal/icon-all-settings-up.svg'); + background-size: 10px 10px; + background-position: top; + background-repeat: no-repeat; +} +.payment-paypal .panel-default .button-all-settings.collapsed .icon-all-settings { + background-image: url('../../image/payment/paypal/icon-all-settings-down.svg'); + background-position: bottom; +} +.payment-paypal .panel-default .section-button-setting { + padding: 0px 0px; +} +.payment-paypal .panel-default .section-button-setting .legend { + padding: 10px 0px; +} +.payment-paypal .panel-default .section-applepay-button-setting { + padding: 0px 0px; +} +.payment-paypal .panel-default .section-applepay-button-setting .legend { + padding: 10px 0px; +} +.payment-paypal .panel-default .section-card-setting { + padding: 0px 0px; +} +.payment-paypal .panel-default .section-card-setting .legend { + padding: 10px 0px; +} +.payment-paypal .panel-default .section-message-setting { + padding: 0px 0px; +} +.payment-paypal .panel-default .section-message-setting .legend { + padding: 10px 0px; +} +.payment-paypal .panel-default .form-group-status { + text-align: right; + margin-bottom: 15px; +} +.payment-paypal .panel-default .form-group-status .control-label { + margin-right: 20px; +} +.payment-paypal .panel-default .button-send { + display: inline-block; + margin: 22px 0px 0px 0px; +} +.payment-paypal .panel-default .section-checkout .section-title { + font-size: 15px; + font-weight: 700; + color: #717171; + margin-bottom: 11px; +} +.payment-paypal .panel-default .section-checkout .section-panel { + display: block; + width: 100%; + padding: 15px 15px; + background: #F5F5F5; + border: 1px solid #CECECE; + border-radius: 3px; + margin-bottom: 6px; +} +.payment-paypal .panel-default .section-checkout .section-panel .section-panel-title { + font-size: 12px; + color: #717171; +} +.payment-paypal .panel-default .section-checkout .section-panel .section-panel-title .icon-section-panel { + display: inline-block; + width: 8px; + height: 8px; + margin-left: 9px; + background-image: url('../../image/payment/paypal/icon-section-panel.svg'); + background-size: 8px 8px; + background-position: center; + background-repeat: no-repeat; +} +.payment-paypal .panel-default .section-checkout .radio-payments { + padding: 15px 15px; +} +.payment-paypal .panel-default .section-checkout .radio-payment { + margin-bottom: 10px; +} +.payment-paypal .panel-default .section-checkout .radio-payment .form-check-input { + width: 16px; + height: 16px; + border-radius: 50%; +} +.payment-paypal .panel-default .section-checkout .radio-payment .form-check-input.checked { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e"); + background-color: #515657; + border-color: #515657; +} +.payment-paypal .panel-default .section-checkout .radio-payment .form-check-input + .payment-label { + display: inline-block; + margin: 0px 0px; + vertical-align: top; + font-size: 13px; + font-weight: 400; + color: #000000; +} +.payment-paypal .panel-default .section-checkout .table-totals { + margin-bottom: 40px; +} +.payment-paypal .panel-default .section-checkout .table-totals .row-total { + margin: 0px 0px; + border-bottom: 1px solid #CECECE; +} +.payment-paypal .panel-default .section-checkout .table-totals .col-title { + padding: 15px 15px 15px 0px; + font-size: 13px; + font-weight: 700; + color: #717171; + text-align: left; +} +.payment-paypal .panel-default .section-checkout .table-totals .col-price { + padding: 15px 15px 15px 0px; + font-size: 12px; + color: #717171; + text-align: left; +} +.payment-paypal .panel-default .section-home .section-title { + font-size: 15px; + font-weight: 700; + color: #717171; + margin-bottom: 11px; +} +.payment-paypal .panel-default .section-home .table-menu { + display: table; + width: 100%; + margin-bottom: 15px; +} +.payment-paypal .panel-default .section-home .table-menu .table-row { + display: table-row; +} +.payment-paypal .panel-default .section-home .table-menu .table-row .table-col { + display: table-cell; + padding: 5px 5px; + font-size: 10px; + background: #D7DADF; + color: #777777; + text-align: center; + vertical-align: middle; + border: none; + border-radius: 0px; +} +.payment-paypal .panel-default .section-home .table-menu .table-row .table-col:first-child { + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; +} +.payment-paypal .panel-default .section-home .table-menu .table-row .table-col:last-child { + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; +} +.payment-paypal .panel-default .section-product .product-image { + display: block; + width: 305px; + height: 305px; + max-width: 100%; + background-image: url('../../image/payment/paypal/icon-product.svg'); + background-size: contain; + background-repeat: no-repeat; +} +.payment-paypal .panel-default .section-product .product-name { + font-size: 15px; + font-weight: 700; + color: #717171; + margin: 15px 0px 4px 0px; +} +.payment-paypal .panel-default .section-product .product-price { + font-size: 15px; + color: #717171; + margin-bottom: 10px; +} +.payment-paypal .panel-default .section-product .product-manufacturer, +.payment-paypal .panel-default .section-product .product-model, +.payment-paypal .panel-default .section-product .product-stock { + font-size: 13px; + color: #717171; + margin-bottom: 10px; +} +.payment-paypal .panel-default .section-product .product-stock { + margin-bottom: 20px; +} +.payment-paypal .panel-default .section-product .button-cart { + display: block; + width: 100%; + font-size: 13px; + font-weight: 600; + background: #D7DADF; + color: #777777; + border-radius: 3px; + margin-bottom: 15px; +} +.payment-paypal .panel-default .section-cart .section-title { + font-size: 15px; + font-weight: 700; + color: #717171; + margin-bottom: 11px; +} +.payment-paypal .panel-default .section-cart .table-cart { + display: table; + width: 100%; +} +.payment-paypal .panel-default .section-cart .table-cart .table-row { + display: table-row; +} +.payment-paypal .panel-default .section-cart .table-cart .table-row .table-col { + display: table-cell; + padding: 9px 9px; + font-size: 10px; + color: #717171; + text-align: center; + vertical-align: middle; + border: none; +} +.payment-paypal .panel-default .section-cart .table-cart .table-row-header .table-col { + padding: 5px 5px; + font-weight: 400; + border: 1px solid #CECECE; + border-right: none; + border-radius: 0px; +} +.payment-paypal .panel-default .section-cart .table-cart .table-row-header .table-col:first-child { + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; +} +.payment-paypal .panel-default .section-cart .table-cart .table-row-header .table-col:last-child { + border-right: 1px solid #CECECE; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; +} +.payment-paypal .panel-default .section-cart .product-image { + display: inline-block; + width: 80px; + height: 80px; + max-width: 100%; + background-image: url('../../image/payment/paypal/icon-product.svg'); + background-size: contain; + background-repeat: no-repeat; +} +@media (max-width: 767px) { + .payment-paypal .panel-default .section-cart .table-cart .table-row .table-col-product-image, + .payment-paypal .panel-default .section-cart .table-cart .table-row .table-col-product-model, + .payment-paypal .panel-default .section-cart .table-cart .table-row .table-col-product-quantity, + .payment-paypal .panel-default .section-cart .table-cart .table-row .table-col-product-price { + display: none; + } +} +.payment-paypal .panel-default .section-cart .section-panel { + display: block; + width: 100%; + padding: 15px 15px; + background: #F5F5F5; + border: 1px solid #CECECE; + border-radius: 3px; + margin-bottom: 6px; +} +.payment-paypal .panel-default .section-cart .section-panel .section-panel-title { + font-size: 12px; + color: #717171; +} +.payment-paypal .panel-default .section-cart .section-panel .section-panel-title .icon-section-panel { + display: inline-block; + width: 8px; + height: 8px; + margin-left: 9px; + background-image: url('../../image/payment/paypal/icon-section-panel.svg'); + background-size: 8px 8px; + background-position: center; + background-repeat: no-repeat; +} +.payment-paypal .panel-default .section-cart .table-totals { + margin-bottom: 40px; +} +.payment-paypal .panel-default .section-cart .table-totals .row-total { + margin: 0px 0px; + border-bottom: 1px solid #CECECE; +} +.payment-paypal .panel-default .section-cart .table-totals .col-title { + padding: 15px 15px 15px 0px; + font-size: 13px; + font-weight: 700; + color: #717171; + text-align: left; +} +.payment-paypal .panel-default .section-cart .table-totals .col-price { + padding: 15px 15px 15px 0px; + font-size: 12px; + color: #717171; + text-align: left; +} +.payment-paypal .panel-default .section-cart .button-cart { + display: block; + width: 100%; + font-size: 13px; + font-weight: 600; + background: #D7DADF; + color: #777777; + border-radius: 3px; + margin-bottom: 15px; +} +.payment-paypal .panel-default .paypal-button { + position: relative; +} +@media (max-width: 476px) { + .payment-paypal .panel-default .paypal-button .paypal-button-container { + width: 100% !important; + } +} +.payment-paypal .panel-default .applepay-button { + position: relative; +} +@media (max-width: 476px) { + .payment-paypal .panel-default .applepay-button .applepay-button-container { + width: 100% !important; + } + .payment-paypal .panel-default .applepay-button #apple-pay-button { + width: 100% !important; + } +} +.payment-paypal .panel-default .paypal-card { + position: relative; +} +.payment-paypal .panel-default .paypal-card-container { + position: relative; +} +@media (max-width: 476px) { + .payment-paypal .panel-default .paypal-card-container { + width: 100% !important; + } +} +.payment-paypal .panel-default .paypal-message { + position: relative; +} +.payment-paypal .panel-default .paypal-spinner { + position: relative; + min-height: 20px; +} +.payment-paypal .panel-default .paypal-spinner:before { + content: ''; + position: absolute; + display: block; + width: 20px; + height: 20px; + top: 50%; + left: 50%; + margin-top: -10px; + margin-left: -10px; + border: 2.5px solid #545454; + border-right-color: #545454; + border-right-color: transparent; + border-radius: 50%; + -webkit-animation: paypal-spinner .75s linear infinite; + animation: paypal-spinner .75s linear infinite; + z-index: 1000; +} +.payment-paypal .panel-auth .panel-body { + background: url('../../image/payment/paypal/background.jpg'); + background-color: #FFFFFF; + background-size: contain; + background-position: bottom right; + background-repeat: no-repeat; + border: 1px solid #F5F5F5; +} +.payment-paypal .panel-auth .section-connect { + position: relative; + max-width: 525px; + margin: 0px auto; + padding: 56px 0px 150px 0px; + text-align: center; +} +.payment-paypal .panel-auth .section-connect .icon-logo { + display: inline-block; + width: 106px; + height: 106px; + background: url('../../image/payment/paypal/icon-logo.svg'); + background-size: contain; + background-repeat: no-repeat; + margin-bottom: 20px; +} +.payment-paypal .panel-auth .section-connect .welcome { + font-size: 18px; + color: #1D1D1D; + margin-bottom: 37px; +} +.payment-paypal .panel-auth .section-connect .checkout-express { + font-size: 13px; + color: #1D1D1D; + margin-bottom: 37px; +} +.payment-paypal .panel-auth .section-connect .button-connect-ppcp { + display: inline-block; + vertical-align: top; + font-family: 'Open Sans', sans-serif; + margin-bottom: 37px; +} +.payment-paypal .panel-auth .section-connect .button-connect-ppcp::before { + display: none; +} +.payment-paypal .panel-auth .section-connect .button-connect-express-checkout { + display: inline; + padding: 0px 0px; + vertical-align: top; + font-family: 'Open Sans', sans-serif; + font-size: 13px; + color: #2F6ED9; + background: none; + border: none; +} +.payment-paypal .panel-auth .section-connect .button-connect-express-checkout::before { + display: none; +} +.payment-paypal .panel-auth .section-connect .control-label { + font-size: 13px; + color: #787878; +} +.payment-paypal .panel-auth .section-connect .form-control { + border: 1px solid #919697; + border-radius: 3px; +} +.payment-paypal .panel-auth .section-connect .support { + font-size: 13px; + color: #1D1D1D; + margin-bottom: 37px; +} +.payment-paypal .panel-auth .section-connect .support a { + color: #2F6ED9; +} +.payment-paypal .panel-dashboard .row { + margin: 0px -7px; +} +.payment-paypal .panel-dashboard .col { + padding: 0px 7px; +} +.payment-paypal .panel-dashboard .paypal-sale { + padding: 11px 0px; +} +.payment-paypal .panel-dashboard .paypal-sale .paypal-sale-title { + font-size: 20px; + font-weight: 700; + color: #000000; +} +.payment-paypal .panel-dashboard .paypal-sale .paypal-sale-total { + font-size: 20px; + color: #000000; +} +.payment-paypal .panel-dashboard .form-group-status { + text-align: right; + margin-bottom: 11px; +} +.payment-paypal .panel-dashboard .form-group-status .control-label { + font-weight: 400; + margin-right: 18px; +} +.payment-paypal .panel-dashboard .tab { + position: relative; + display: block; + padding: 37px 7px 30px 7px; + text-align: center; + background: #FFFFFF; + box-shadow: 0px 2px 6px #00000029; + border: 1px solid #C5D5FF; + border-radius: 5px; + margin-bottom: 15px; +} +.payment-paypal .panel-dashboard .tab .tab-icon-status { + position: absolute; + display: block; + width: 21px; + height: 21px; + top: 11px; + right: 11px; + background-size: contain; + background-position: center center; + background-repeat: no-repeat; + margin-bottom: 10px; +} +.payment-paypal .panel-dashboard .tab .tab-icon-status-on { + background-image: url('../../image/payment/paypal/icon-check-on.svg'); +} +.payment-paypal .panel-dashboard .tab .tab-icon-status-off { + background-image: url('../../image/payment/paypal/icon-check-off.svg'); +} +.payment-paypal .panel-dashboard .tab .tab-icon { + margin: 0px 0px 10px 0px; +} +.payment-paypal .panel-dashboard .tab .tab-title { + display: block; + height: 16px; + font-size: 13px; + font-weight: 600; + color: #000000; +} +.payment-paypal .panel-statistic, +.payment-paypal .panel-sale-analytics { + height: 100%; +} +.payment-paypal .panel-statistic .panel-heading, +.payment-paypal .panel-sale-analytics .panel-heading { + border-top-left-radius: 5px; + border-top-right-radius: 5px; +} +.payment-paypal .panel-statistic .panel-body, +.payment-paypal .panel-sale-analytics .panel-body { + height: calc(100% - 50px); + background: #FFFFFF; + box-shadow: 0px 2px 6px #00000029; + -webkit-box-shadow: 0px 2px 6px #00000029; + border-color: #C5D5FF; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; +} +.payment-paypal .panel-statistic .panel-body { + display: table; +} +.payment-paypal .panel-statistic .statistic { + display: table-cell; + text-align: center; + vertical-align: middle; +} +.payment-paypal .panel-statistic .icon-panel-statistic { + display: inline-block; + width: 26px; + height: 26px; + vertical-align: middle; + background-image: url('../../image/payment/paypal/icon-panel-statistic.svg'); + background-size: contain; + background-repeat: no-repeat; +} +.payment-paypal .panel-statistic .icon-statistic { + display: inline-block; + width: 56px; + height: 72px; + vertical-align: middle; + background-image: url('../../image/payment/paypal/icon-statistic.svg'); + background-size: contain; + background-repeat: no-repeat; + margin-bottom: 17px; +} +.payment-paypal .panel-statistic .statistic .statistic-title { + display: block; + font-size: 15px; + font-weight: 600; + color: #000000; + margin-bottom: 17px; +} +.payment-paypal .panel-statistic .statistic .statistic-description { + display: block; + font-size: 13px; + color: #000000; +} +.payment-paypal .panel-sale-analytics .icon-panel-sale-analytics { + display: inline-block; + width: 21px; + height: 26px; + vertical-align: middle; + background-image: url('../../image/payment/paypal/icon-panel-sale-analytics.svg'); + background-size: contain; + background-repeat: no-repeat; +} +.payment-paypal .panel-sale-analytics .dropdown-toggle, +.payment-paypal .panel-sale-analytics .dropdown-toggle:hover, +.payment-paypal .panel-sale-analytics .dropdown-toggle:focus { + color: #FFFFFF; +} +.payment-paypal .panel-sale-analytics .dropdown-toggle .fa { + display: inline-block; + vertical-align: middle; + font-size: 25px; +} +.payment-paypal .panel-sale-analytics .sale-analytics { + width: 100%; + height: 260px; +} +@keyframes paypal-spinner { + to { + transform: rotate(360deg); + } +} \ No newline at end of file diff --git a/upload/admin/view/template/extension/module/klarna_checkout_module.twig b/upload/admin/view/template/extension/module/klarna_checkout_module.twig new file mode 100644 index 00000000000..0d86bf70679 --- /dev/null +++ b/upload/admin/view/template/extension/module/klarna_checkout_module.twig @@ -0,0 +1,47 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }} + +
+ {% endif %} +
+
+

{{ heading_title }}

+
+
+
+
+ +
+ +
+
+
+
+
+
+
+{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/klarna_checkout.twig b/upload/admin/view/template/extension/payment/klarna_checkout.twig new file mode 100644 index 00000000000..46a09833f58 --- /dev/null +++ b/upload/admin/view/template/extension/payment/klarna_checkout.twig @@ -0,0 +1,641 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }} + +
+ {% endif %} + {% if error_tax_warning %} +
{{ error_tax_warning }} + +
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ +
+
+
+ +
+ {{ text_version }} +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ {% if error_account_warning %} +
{{ error_account_warning }}
+ {% endif %} + + + + + + + + + + + + + + + + {% set account_row = 0 %} + {% for key, account in klarna_checkout_account %} + + + + + + + + + + + + {% set account_row = account_row + 1 %} + {% endfor %} + + + + + + + +
{{ entry_merchant_id }}{{ entry_secret }}{{ entry_environment }}{{ entry_country }}{{ entry_shipping }}{{ entry_currency }}{{ entry_locale }}{{ entry_api }}
+ + {% if error_account[key].merchant_id is defined %} +
{{ error_account[key].merchant_id }}
+ {% endif %} +
+ + {% if error_account[key].secret is defined %} +
{{ error_account[key].secret }}
+ {% endif %} +
+ + + + + + + + + + {% if error_account[key].locale is defined %} +
{{ error_account[key].locale }}
+ {% endif %} +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ +{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_braintree_order.twig b/upload/admin/view/template/extension/payment/klarna_checkout_order.twig similarity index 53% rename from upload/admin/view/template/extension/payment/pp_braintree_order.twig rename to upload/admin/view/template/extension/payment/klarna_checkout_order.twig index bc6d2c88899..a636a8a0406 100644 --- a/upload/admin/view/template/extension/payment/pp_braintree_order.twig +++ b/upload/admin/view/template/extension/payment/klarna_checkout_order.twig @@ -1,11 +1,11 @@

{{ text_payment_info }}

- +
+//--> \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/klarna_checkout_order_ajax.twig b/upload/admin/view/template/extension/payment/klarna_checkout_order_ajax.twig new file mode 100644 index 00000000000..834a5a49409 --- /dev/null +++ b/upload/admin/view/template/extension/payment/klarna_checkout_order_ajax.twig @@ -0,0 +1,721 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if transaction.authorization_expiry %} + + + + + {% endif %} + + + + + + + + +
{{ column_order_id }} + {{ transaction.order_id }} + {% if cancel_action %} + {{ button_cancel }} + {% endif %} +
{{ column_merchant_id }}{{ transaction.merchant_id }}
{{ column_reference }}{{ transaction.reference }}
{{ column_status }}{{ transaction.status }}
{{ column_fraud_status }}{{ transaction.fraud_status }}
{{ column_merchant_reference_1 }} + {% if merchant_reference_action %} +
+ +
+ {{ button_update }} + {% else %} + {{ transaction.merchant_reference_1 }} + {% endif %} +
{{ column_customer_details }} + + + + + + + + + + + + {% if address_action %} + + + + + {% endif %} +
{{ column_billing_address }}{{ column_shipping_address }}
{{ transaction.billing_address_formatted }}{{ transaction.shipping_address_formatted }}
+ {{ button_edit }} + + {{ button_edit }} +
+
{{ column_order_lines }} + + + + + + + + + + + + + + + + + {% for order_line in transaction.order_lines %} + + + + + + + + + + + + + {% endfor %} + +
{{ column_item_reference }}{{ column_type }}{{ column_quantity }}{{ column_quantity_unit }}{{ column_name }}{{ column_total_amount }}{{ column_unit_price }}{{ column_total_discount_amount }}{{ column_tax_rate }}{{ column_total_tax_amount }}
{{ order_line.reference }}{{ order_line.type }}{{ order_line.quantity }}{{ order_line.quantity_unit }}{{ order_line.name }}{{ order_line.total_amount }}{{ order_line.unit_price }}{{ order_line.total_discount_amount }}{{ order_line.tax_rate }}{{ order_line.total_tax_amount }}
+
{{ column_amount }}{{ transaction.amount }}
{{ column_authorization_remaining }} + {{ transaction.authorization_remaining }} + {% if release_authorization_action %} + {{ button_release_authorization }} + {% endif %} +
{{ column_authorization_expiry }} + {{ transaction.authorization_expiry }} + {% if extend_authorization_action %} + {{ button_extend_authorization }} + {% endif %} +
{{ column_capture }} + + + + + + + + + + + + {% if captures %} + {% for capture in captures %} + + + + + + + + {% endfor %} + {% else %} + + + + {% endif %} + + {% if capture_action %} + + + + + + + {% endif %} +
{{ column_capture_id }}{{ column_date }}{{ column_amount }}{{ column_reference }}{{ column_action }}
{{ capture.capture_id }}{{ capture.date_added }}{{ capture.amount }}{{ capture.reference }} + {{ button_trigger_send_out }} + {{ button_edit_shipping_info }} + {{ button_edit_billing_address }} +
{{ text_no_capture }}
{{ button_new_capture }}
+
{{ column_refund }} + + + + + + + + + + {% if refunds %} + {% for refund in refunds %} + + + + + {% endfor %} + {% endif %} + + {% if refund_action %} + + + + + + + {% endif %} +
{{ column_date }}{{ column_amount }}{{ column_action }}
{{ refund.date_added }}{{ refund.amount }}
+ {{ button_new_refund }} +
+
+ + + + + + + + + + +{% for capture in captures %} + + +{% endfor %} + + \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal.twig b/upload/admin/view/template/extension/payment/paypal.twig deleted file mode 100644 index 63672e741cf..00000000000 --- a/upload/admin/view/template/extension/payment/paypal.twig +++ /dev/null @@ -1,575 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
- - -
-
-
- -
- -
-
-
- -
-
- - {{ button_connect }}
-

{{ help_checkout_express }}

-
- {% if client_id and secret and merchant_id %} -
-

{{ text_connect }}

- {{ button_disconnect }} -
- {% endif %} - - - - -
-
- {% if client_id and secret and merchant_id %} -
- -
- -
-
-
- -
- - -
-
-
- -
- -
-
- {% endif %} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - -
-
-
- {% for paypal_order_status in setting['order_status'] %} -
- -
- -
-
- {% endfor %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
-
-
-{% if client_id and secret and merchant_id %} - - -{% endif %} - - - -{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/applepay_button.twig b/upload/admin/view/template/extension/payment/paypal/applepay_button.twig new file mode 100644 index 00000000000..a51e38c47d7 --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/applepay_button.twig @@ -0,0 +1,280 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+
+
+
+
{{ text_checkout }}
+
+
{{ text_step_payment_method }}
+
+
+
{{ text_step_confirm_order }}
+
+
+
+
+
+
{{ text_cart_sub_total }}
+
{{ text_cart_product_total_value }}
+
+
+
{{ text_cart_total }}
+
{{ text_cart_product_total_value }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ text_applepay_button_settings }} +
+
+
+ + + +
+
+
+ {% if text_applepay_alert %} +
+

{{ text_applepay_alert }}

+
+
+

{{ text_applepay_step_1 }}

+
+ +
+ +
+
+
+
+

{{ text_applepay_step_2 }}

+
+ {% endif %} +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/auth.twig b/upload/admin/view/template/extension/payment/paypal/auth.twig new file mode 100644 index 00000000000..d738429b332 --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/auth.twig @@ -0,0 +1,107 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ +
{{ text_welcome }}
+ {{ button_connect }} +
{{ text_checkout_express }}
+
{{ text_support }}
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/button.twig b/upload/admin/view/template/extension/payment/paypal/button.twig new file mode 100644 index 00000000000..9864d01032e --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/button.twig @@ -0,0 +1,412 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+ +
+
+ {% for button in setting['button'] %} +
+
+
+ {% if (button['page_code'] == 'checkout') %} +
+
{{ text_checkout }}
+
+
{{ text_step_payment_method }}
+
+
+
{{ text_step_confirm_order }}
+
+
+
+
+
+
{{ text_cart_sub_total }}
+
{{ text_cart_product_total_value }}
+
+
+
{{ text_cart_total }}
+
{{ text_cart_product_total_value }}
+
+
+
+
+
+
+
+
+ {% endif %} + {% if (button['page_code'] == 'product') %} +
+
+
+
+
+
+
{{ text_product_name }}
+
{{ text_product_price }}
+
{{ text_product_manufacturer }}
+
{{ text_product_model }}
+
{{ text_product_stock }}
+ +
+
+
+
+
+
+ {% endif %} + {% if (button['page_code'] == 'cart') %} +
+
{{ text_cart }}
+
+
+
{{ text_cart_product_image }}
+
{{ text_cart_product_name }}
+
{{ text_cart_product_model }}
+
{{ text_cart_product_quantity }}
+
{{ text_cart_product_price }}
+
{{ text_cart_product_total }}
+
+
+
+
{{ text_cart_product_name_value }}
+
{{ text_cart_product_model_value }}
+
{{ text_cart_product_quantity_value }}
+
{{ text_cart_product_price_value }}
+
{{ text_cart_product_total_value }}
+
+
+
+
{{ text_step_coupon }}
+
+
+
{{ text_step_shipping }}
+
+
+
+
+
+
{{ text_cart_sub_total }}
+
{{ text_cart_product_total_value }}
+
+
+
{{ text_cart_total }}
+
{{ text_cart_product_total_value }}
+
+
+
+
+
+
+ +
+
+
+
+
+
+ {% endif %} +
+
+
+
+
+ {{ text_button_settings }} +
+
+
+ + + +
+
+
+ {% if (button['page_code'] != 'checkout') %} +
+
+
+ + +
+
+
+
+ + +
+
+
+ {% endif %} +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+ {% if (button['page_code'] != 'checkout') %} +
+ + +
+ {% endif %} +
+
+
+ +
+
+ {% for column_button_funding in setting['button_funding']|batch(setting['button_funding']|length / 2|round(1, 'ceil')) %} +
+ {% for button_funding in column_button_funding %} +
+ + +
+ {% endfor %} +
+ {% endfor %} +
+
+
+
+
+
+ {% endfor %} +
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/card.twig b/upload/admin/view/template/extension/payment/paypal/card.twig new file mode 100644 index 00000000000..0bbcf67fccb --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/card.twig @@ -0,0 +1,239 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+
+
+
+
{{ text_checkout }}
+
+
{{ text_step_payment_method }}
+
+
+
{{ text_step_confirm_order }}
+
+
+
+
+
+
{{ text_cart_sub_total }}
+
{{ text_cart_product_total_value }}
+
+
+
{{ text_cart_total }}
+
{{ text_cart_product_total_value }}
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ {{ text_card_settings }} +
+
+
+ + + +
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+ +

{{ help_card_secure_scenario }}

+
+ {% for card_secure_scenario in setting['card_secure_scenario'] %} +
+ + +
+ {% endfor %} +
+
+
+
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/contact.twig b/upload/admin/view/template/extension/payment/paypal/contact.twig new file mode 100644 index 00000000000..f898a738dfa --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/contact.twig @@ -0,0 +1,210 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+
+
+ {{ text_contact_business }} +
+
+ + + + + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ {{ text_contact_product }} +
+ + +
+
+ +
+
+
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/dashboard.twig b/upload/admin/view/template/extension/payment/paypal/dashboard.twig new file mode 100644 index 00000000000..08c4cb062e9 --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/dashboard.twig @@ -0,0 +1,253 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+
+
+
+ {{ text_paypal_sales }}: {{ paypal_sale_total }} +
+
+
+
+ + + +
+
+
+ +
+
+
+
+

{{ text_panel_statistic }}

+
+
+
+ +
{{ text_statistic_title }}
+
{{ text_statistic_description }}
+
+
+
+
+
+
+
+
+ + +
+

{{ text_panel_sale_analytics }}

+
+
+
+
+
+
+
+
+
+
+
+
+ + + +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/general.twig b/upload/admin/view/template/extension/payment/paypal/general.twig new file mode 100644 index 00000000000..1e81e85c229 --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/general.twig @@ -0,0 +1,255 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+ +
+ +
+
+ +

{{ text_connect }}

+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/message.twig b/upload/admin/view/template/extension/payment/paypal/message.twig new file mode 100644 index 00000000000..9f7d6ae4119 --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/message.twig @@ -0,0 +1,429 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + + +
+ +
+
+ {% for message in setting['message'] %} +
+
+
+ {% if (message['page_code'] == 'checkout') %} +
+
{{ text_checkout }}
+
+
{{ text_step_payment_method }}
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ {% endif %} + {% if (message['page_code'] == 'home') %} +
+
{{ text_home }}
+
+
+
{{ text_menu_desktops }}
+
{{ text_menu_laptops }}
+
{{ text_menu_components }}
+
{{ text_menu_tablets }}
+
{{ text_menu_software }}
+
{{ text_menu_cameras }}
+
+
+
+
+
+
+ {% endif %} + {% if (message['page_code'] == 'product') %} +
+
+
+
+
+
+
{{ text_product_name }}
+
{{ text_product_price }}
+
+
+
+
{{ text_product_manufacturer }}
+
{{ text_product_model }}
+
{{ text_product_stock }}
+ +
+
+
+ {% endif %} + {% if (message['page_code'] == 'cart') %} +
+
{{ text_cart }}
+
+
+
{{ text_cart_product_image }}
+
{{ text_cart_product_name }}
+
{{ text_cart_product_model }}
+
{{ text_cart_product_quantity }}
+
{{ text_cart_product_price }}
+
{{ text_cart_product_total }}
+
+
+
+
{{ text_cart_product_name_value }}
+
{{ text_cart_product_model_value }}
+
{{ text_cart_product_quantity_value }}
+
{{ text_cart_product_price_value }}
+
{{ text_cart_product_total_value }}
+
+
+
+
{{ text_step_coupon }}
+
+
+
{{ text_step_shipping }}
+
+
+
+
+
+
{{ text_cart_sub_total }}
+
{{ text_cart_product_total_value }}
+
+
+
{{ text_cart_total }}
+
{{ text_cart_product_total_value }}
+
+
+
+
+
+
+ +
+
+
+
+
+
+ {% endif %} +
+
+
+
+
+ {{ text_message_settings }} +
+
+
+ + + +
+
+
+ {% if text_message_alert %} +
+

{{ text_message_alert }}

+
+
+

{{ text_message_footnote }}

+
+ {% endif %} + {% if (message['page_code'] != 'checkout') %} +
+
+
+ + +
+
+
+
+ + +
+
+
+ {% endif %} +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+ {% endfor %} +
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/paypal/order_status.twig b/upload/admin/view/template/extension/payment/paypal/order_status.twig new file mode 100644 index 00000000000..c756de4811f --- /dev/null +++ b/upload/admin/view/template/extension/payment/paypal/order_status.twig @@ -0,0 +1,110 @@ +{{ header }}{{ column_left }} +
+ +
+ {% if error_warning %} +
{{ error_warning }}
+ {% endif %} + {% if text_version %} +
{{ text_version }}
+ {% endif %} +
+
+

{{ text_edit }}

+
+
+
+ {{ text_tab_dashboard }} + +
+
+ {% for column_paypal_order_status in setting['order_status']|batch(setting['order_status']|length / 2|round(1, 'ceil')) %} +
+ {% for paypal_order_status in column_paypal_order_status %} +
+ + +
+ {% endfor %} +
+ {% endfor %} +
+
+
+
+
+
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_braintree.twig b/upload/admin/view/template/extension/payment/pp_braintree.twig deleted file mode 100644 index 64bb36ef9eb..00000000000 --- a/upload/admin/view/template/extension/payment/pp_braintree.twig +++ /dev/null @@ -1,1031 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} - {% if success %} -
{{ success }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
- -
-
- {% if payment_pp_braintree_access_token is not empty %} - - - - - - -
- -
-
{{ text_app_connected }} ({{ text_merchant_connected }}{{ payment_pp_braintree_merchant_id }})
-
-
- {% else %} - - -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {% endif %} - -
- -
- {% if payment_pp_braintree_access_token is not empty and payment_pp_braintree_environment is not empty %} - - - {% else %} - - {% endif %} -
-
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- - - - - - - - - - {% for currency in currencies %} - - - - - - {% endfor %} - -
{{ text_enabled }}{{ text_currency }}{{ text_merchant_account_id }}
- {% if payment_pp_braintree_account[currency.code].status == 1 %} - - {% else %} - - {% endif %} - {{ currency.code }} - - {% if error_account[currency.code] %} -
{{ error_account[currency.code] }}
- {% endif %} -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- {% if braintree_config.three_d_secure_enabled == 0 %} -
{{ error_braintree_account_3ds }}
- - {% else %} -
- -
- -

{{ text_3ds_ssl }}

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- - {% if braintree_config.paypal_enabled == 1 %} -
- -
- -
-
-
- -
- -
-
- {% else %} - - - {% endif %} -
-
- {% if braintree_config.paypal_enabled == 0 %} -
{{ error_braintree_account_paypal }}
- - {% else %} -
- -
- -
-
- - - - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -

{{ text_enable_button }}

-
- {% endif %} -
-
- {% if braintree_config.paypal_enabled == 0 %} -
{{ error_braintree_account_paypal }}
- {% else %} - {% if payment_pp_braintree_status == 1 %} -
-
-
-
- - -
-
- - -
-
-
- -
- - - - -
-
-
- -
- - - - -
-
-
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
-
-
- -
- {% for transaction_status in transaction_statuses %} -
- -
- {% endfor %} -
-
-
-
-
- - -
- -
-
-
-
- {% else %} - {{ text_enable_transactions }} - {% endif %} - {% endif %} -
-
-
-
-
-
-
- - - -{% if auth_connect_url %} - - -{% endif %} -{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_braintree_order_ajax.twig b/upload/admin/view/template/extension/payment/pp_braintree_order_ajax.twig deleted file mode 100644 index 04706c27dea..00000000000 --- a/upload/admin/view/template/extension/payment/pp_braintree_order_ajax.twig +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{% if transaction.processor_code %} - - - - -{% endif %} - - - - - - - - -{% if transaction.threeds_status %} - - - - - - - - - - - - - - - - -{% endif %} - - - - - - - - - - - - -
{{ column_status }}{{ transaction.status }}
{{ column_transaction_id }}{{ transaction.transaction_id }}
{{ column_transaction_type }}{{ transaction.type }}
{{ column_transaction_date }}{{ transaction.date_added }}
{{ column_merchant_account }}{{ transaction.merchant_account_id }}
{{ column_payment_type }}{{ transaction.payment_type }}
{{ column_amount }}{{ transaction.amount }} {{ transaction.currency }}
{{ column_order_id }}{{ transaction.order_id }}
{{ column_processor_code }}{{ transaction.processor_code }}
{{ column_cvv_response }}{{ transaction.cvv_response }}
{{ column_avs_response }}{{ transaction.avs_response }}
{{ column_3ds_enrolled }}{{ transaction.threeds_enrolled }}
{{ column_3ds_status }}{{ transaction.threeds_status }}
{{ column_3ds_shifted }}{{ transaction.threeds_shifted }}
{{ column_3ds_shift_possible }}{{ transaction.threeds_shift_possible }}
{{ column_transaction_history }} - - - - - - - - - {% for status in statuses %} - - - - - {% endfor %} - -
{{ column_date }}{{ column_status }}
{{ status.date_added }}{{ status.status }}
-
{{ column_refund_history }} - - - - - - - - - - {% if refunds is not empty %} - {% for refund in refunds %} - - - - - - {% endfor %} - {% else %} - - - - {% endif %} - -
{{ column_date }}{{ column_amount }}{{ column_status }}
{{ refund.date_added }}{{ refund.amount }}{{ refund.status }}
{{ text_no_refund }}
-
{{ column_action }} - - - - - - - - - - - - - - - -
{{ column_void }}{{ column_settle }}{{ column_refund }}
- {% if void_action is not empty %} - {{ button_void }} - {% else %} - {{ text_na }} - {% endif %} - - {% if settle_action is not empty %} - - {{ button_settle }} - {% else %} - {{ text_na }} - {% endif %} - - {% if refund_action is not empty %} - - {{ button_refund }} - {% else %} - {{ text_na }} - {% endif %} -
-
- - diff --git a/upload/admin/view/template/extension/payment/pp_braintree_preferred.twig b/upload/admin/view/template/extension/payment/pp_braintree_preferred.twig deleted file mode 100644 index c1c09e58101..00000000000 --- a/upload/admin/view/template/extension/payment/pp_braintree_preferred.twig +++ /dev/null @@ -1,39 +0,0 @@ -
-
-
-

PayPal powered by Braintree

- {% if payment_pp_braintree_status == "enabled" %} -
{{ text_enabled }}
- {% endif %} - {% if payment_pp_braintree_status == "disabled" %} -
{{ text_disabled }}
- {% endif %} -
-
-
-
-

{{ text_preferred_main }} {{ text_learn_more }}

-
-
-
-
-
    -
  • {{ text_preferred_li_1 }}
  • -
  • {{ text_preferred_li_2 }}
  • -
  • {{ text_preferred_li_3 }}
  • -
  • {{ text_preferred_li_4 }}
  • -
-
-
- Accept Visa, Mastercard, Discover, American Express, and PayPal payments - {% if connect_link is not empty %} -

Connect with Braintree - {% endif %} - {% if module_link is not empty %} -

- {% endif %} -
-
-
-
-
diff --git a/upload/admin/view/template/extension/payment/pp_express.twig b/upload/admin/view/template/extension/payment/pp_express.twig deleted file mode 100644 index 3e6d5f688dc..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express.twig +++ /dev/null @@ -1,461 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
- {% if retrieve_success == 1 %} -
{{ text_retrieve }}
- {% endif %} -
- -
-
- - -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
{{ text_incontext_not_supported }} -
-
-
- -
- -
{{ text_incontext_not_supported }} -
-
-
- -
- -
-
-
- -
- -
-
-
- -

{{ text_enable_button }}

-
-
-
-
-
-
-
-
- - - -{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_express_order.twig b/upload/admin/view/template/extension/payment/pp_express_order.twig deleted file mode 100644 index c2d423235a8..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_order.twig +++ /dev/null @@ -1,153 +0,0 @@ -
- {{ text_transaction }} -
-
- -
- {{ text_payment }} - - - - - - - - - - - - - - - - - -
{{ text_capture_status }}{{ capture_status }}
{{ text_amount_authorised }}{{ total }} - {% if capture_status != 'Complete' %} -     - - {% endif %}
{{ text_amount_captured }}{{ captured }}
{{ text_amount_refunded }}{{ refunded }}
-
- -{% if capture_status != 'Complete' %} -
- {{ tab_capture }} -
-
- -
- -
-
-
- -
- -
-
-
- -
-
-
-{% endif %} - diff --git a/upload/admin/view/template/extension/payment/pp_express_preferred.twig b/upload/admin/view/template/extension/payment/pp_express_preferred.twig deleted file mode 100644 index 2ea09c77bad..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_preferred.twig +++ /dev/null @@ -1,40 +0,0 @@ -
-
-
-

PayPal Logo

- {% if payment_pp_express_status == "enabled" %} -
{{ text_enabled }}
- {% endif %} - {% if payment_pp_express_status == "disabled" %} -
{{ text_disabled }}
- {% endif %} -
-
-
-
-

{{ text_preferred_main }} {{ text_learn_more }}

-
-
-
-
-
    -
  • {{ text_preferred_li_1 }}
  • -
  • {{ text_preferred_li_2 }}
  • -
  • {{ text_preferred_li_3 }}
  • -
  • {{ text_preferred_li_4 }}
  • -
-
-
-

PayPal Express

- - {% if connect_link is not empty %} -

{{ text_connect_paypal }}

- {% endif %} - {% if module_link is not empty %} -

- {% endif %} -
-
-
-
-
diff --git a/upload/admin/view/template/extension/payment/pp_express_refund.twig b/upload/admin/view/template/extension/payment/pp_express_refund.twig deleted file mode 100644 index ad0ff73de28..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_refund.twig +++ /dev/null @@ -1,75 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error is not '' %} -
{{ error }} - -
- {% endif %} - {% if attention is not '' %} -
{{ attention }} - -
- {% endif %} -
-
-

{{ text_refund }}

-
-
-
- - -
- -
- -
-
-
- -
- - -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
-
-
- -{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_express_search.twig b/upload/admin/view/template/extension/payment/pp_express_search.twig deleted file mode 100644 index dfe390793d2..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_search.twig +++ /dev/null @@ -1,264 +0,0 @@ -{{ header }}{{ column_left }} -
- -
-
-
-

{{ heading_title }}

-
-
-
-
-

{{ text_date_search }}

-
- -
-
- - - -
-
-
-
- -
-
- - - -
-
-
-

{{ entry_transaction }}

-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
- -
-
-
- -
- -
-
-

{{ text_buyer_info }}

-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_express_transaction.twig b/upload/admin/view/template/extension/payment/pp_express_transaction.twig deleted file mode 100644 index aae4e8feff7..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_transaction.twig +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - {% if transactions %} - {% for transaction in transactions %} - - - - - - - - - - {% endfor %} - {% else %} - - - - {% endif %} - - -
{{ column_transaction }}{{ column_amount }}{{ column_type }}{{ column_status }}{{ column_pending_reason }}{{ column_date_added }}{{ column_action }}
{{ transaction.transaction_id }}{{ transaction.amount }}{{ transaction.payment_type }}{{ transaction.payment_status }}{{ transaction.pending_reason }}{{ transaction.date_added }} {% if transaction.transaction_id %} - {% if transaction.payment_type == 'instant' and (transaction.payment_status == 'Completed' or transaction.payment_status == 'Partially-Refunded') %} -   - {% else %} - - {% endif %}{% endif %}
{{ text_no_results }}
diff --git a/upload/admin/view/template/extension/payment/pp_express_view.twig b/upload/admin/view/template/extension/payment/pp_express_view.twig deleted file mode 100644 index 2bd20deac1e..00000000000 --- a/upload/admin/view/template/extension/payment/pp_express_view.twig +++ /dev/null @@ -1,473 +0,0 @@ -{{ header }}{{ column_left }} -
- -
-
-
-

{{ heading_title }}

-
-
- - {% if lines %} - - - - - {% endif %} - {% if transaction.GIFTMESSAGE %} - - - - - {% endif %} - {% if transaction.GIFTRECEIPTENABLE %} - - - - - {% endif %} - {% if transaction.GIFTWRAPNAME %} - - - - - {% endif %} - {% if transaction.GIFTWRAPAMOUNT %} - - - - - {% endif %} - {% if transaction.BUYERMARKETINGEMAIL %} - - - - - {% endif %} - {% if transaction.SURVEYQUESTION %} - - - - - {% endif %} - {% if transaction.SURVEYCHOICESELECTED %} - - - - - {% endif %} - {% if transaction.RECEIVERBUSINESS %} - - - - - {% endif %} - {% if transaction.RECEIVEREMAIL %} - - - - - {% endif %} - {% if transaction.RECEIVERID %} - - - - - {% endif %} - {% if transaction.EMAIL %} - - - - - {% endif %} - {% if transaction.PAYERID %} - - - - - {% endif %} - {% if transaction.PAYERSTATUS %} - - - - - {% endif %} - {% if transaction.COUNTRYCODE %} - - - - - {% endif %} - {% if transaction.PAYERBUSINESS %} - - - - - {% endif %} - {% if transaction.SALUTATION %} - - - - - {% endif %} - {% if transaction.FIRSTNAME %} - - - - - {% endif %} - {% if transaction.MIDDLENAME %} - - - - - {% endif %} - {% if transaction.LASTNAME %} - - - - - {% endif %} - {% if transaction.SUFFIX %} - - - - - {% endif %} - {% if transaction.ADDRESSOWNER %} - - - - - {% endif %} - {% if transaction.ADDRESSSTATUS %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYNAME %} - - - - - {% endif %} - {% if transaction.SHIPTONAME %} - - - - - {% endif %} - {% if transaction.SHIPTOSTREET %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYADDRESSLINE1 %} - - - - - {% endif %} - {% if transaction.SHIPTOSTREET2 %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYADDRESSLINE2 %} - - - - - {% endif %} - {% if transaction.SHIPTOCITY %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYCITY %} - - - - - {% endif %} - {% if transaction.SHIPTOSTATE %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYSTATE %} - - - - - {% endif %} - {% if transaction.SHIPTOZIP %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYZIP %} - - - - - {% endif %} - {% if transaction.SHIPTOCOUNTRYCODE %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYCOUNTRYCODE %} - - - - - {% endif %} - {% if transaction.SHIPTOPHONENUM %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYPHONENUM %} - - - - - {% endif %} - {% if transaction.TRANSACTIONID %} - - - - - {% endif %} - {% if transaction.PARENTTRANSACTIONID %} - - - - - {% endif %} - {% if transaction.RECEIPTID %} - - - - - {% endif %} - {% if transaction.TRANSACTIONTYPE %} - - - - - {% endif %} - {% if transaction.PAYMENTTYPE %} - - - - - {% endif %} - {% if transaction.ORDERTIME %} - - - - - {% endif %} - {% if transaction.AMT %} - - - - - {% endif %} - {% if transaction.CURRENCYCODE %} - - - - - {% endif %} - {% if transaction.FEEAMT %} - - - - - {% endif %} - {% if transaction.SETTLEAMT %} - - - - - {% endif %} - {% if transaction.TAXAMT %} - - - - - {% endif %} - {% if transaction.EXCHANGERATE %} - - - - - {% endif %} - {% if transaction.PAYMENTSTATUS %} - - - - - {% endif %} - {% if transaction.PENDINGREASON %} - - - - - {% endif %} - {% if transaction.REASONCODE %} - - - - - {% endif %} - {% if transaction.PROTECTIONELIGIBILITY %} - - - - - {% endif %} - {% if transaction.PROTECTIONELIGIBILITYTYPE %} - - - - - {% endif %} - {% if transaction.STOREID %} - - - - - {% endif %} - {% if transaction.TERMINALID %} - - - - - {% endif %} - {% if transaction.INVNUM %} - - - - - {% endif %} - {% if transaction.CUSTOM %} - - - - - {% endif %} - {% if transaction.NOTE %} - - - - - {% endif %} - {% if transaction.SALESTAX %} - - - - - {% endif %} - {% if transaction.BUYERID %} - - - - - {% endif %} - {% if transaction.CLOSINGDATE %} - - - - - {% endif %} - {% if transaction.MULTIITEM %} - - - - - {% endif %} - {% if transaction.AMOUNT %} - - - - - {% endif %} - {% if transaction.PERIOD %} - - - - - {% endif %} -
{{ text_product_lines }} - {% set i = 0 %} - {% for k,v in lines %} - {% if i == 0 %} - - - {% for k,row in v %} - {% if k == 'L_EBAYITEMTXNID' %} {% endif %} - {% if k == 'L_NAME' %} {% endif %} - {% if k == 'L_NUMBER' %} {% endif %} - {% if k == 'L_QTY' %} {% endif %} - {% if k == 'L_COUPONID' %} {% endif %} - {% if k == 'L_COUPONAMOUNT' %} {% endif %} - {% if k == 'L_COUPONAMOUNTCURRENCY' %} {% endif %} - {% if k == 'L_LOYALTYCARDDISCOUNTAMOUNT' %} {% endif %} - {% if k == 'L_LOYALTYCARDISCOUNTCURRENCY' %} {% endif %} - {% if k == 'L_AMT' %} {% endif %} - {% if k == 'L_OPTIONSNAME' %} {% endif %} - {% if k == 'L_TAXAMT' %} {% endif %} - {% if k == 'L_CURRENCYCODE' %} {% endif %} - {% endfor %} - {% set i = i + 1 %} - - - {% endif %} - - {% for k,row in v %} - {% if k == 'L_EBAYITEMTXNID' %} {% endif %} - {% if k == 'L_NAME' %} {% endif %} - {% if k == 'L_NUMBER' %} {% endif %} - {% if k == 'L_QTY' %} {% endif %} - {% if k == 'L_COUPONID' %} {% endif %} - {% if k == 'L_COUPONAMOUNT' %} {% endif %} - {% if k == 'L_COUPONAMOUNTCURRENCY' %} {% endif %} - {% if k == 'L_LOYALTYCARDDISCOUNTAMOUNT' %} {% endif %} - {% if k == 'L_LOYALTYCARDISCOUNTCURRENCY' %} {% endif %} - {% if k == 'L_AMT' %} {% endif %} - {% if k == 'L_OPTIONSNAME' %} {% endif %} - {% if k == 'L_OPTIONSVALUE' %} {% endif %} - {% if k == 'L_TAXAMT' %} {% endif %} - {% if k == 'L_CURRENCYCODE' %} {% endif %} - {% endfor %} - {% set i = i + 1 %} - - {% endfor %} -
{{ text_ebay_txn_id }}{{ text_name }}{{ text_number }}{{ text_qty }}{{ text_coupon_id }}{{ text_coupon_amount }}{{ text_coupon_currency }}{{ text_loyalty_disc_amt }}{{ text_loyalty_currency }}{{ text_amount }}{{ text_options_name }}{{ text_tax_amt }}{{ text_currency_code }}
{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}{{ row }}
{{ text_gift_msg }}{{ transaction.GIFTMESSAGE }}
{{ text_gift_receipt }}{{ transaction.GIFTRECEIPTENABLE }}
{{ text_gift_wrap_name }}{{ transaction.GIFTWRAPNAME }}
{{ text_gift_wrap_amt }}{{ transaction.GIFTWRAPAMOUNT }}
{{ text_buyer_email_market }}{{ transaction.BUYERMARKETINGEMAIL }}
{{ text_survey_question }}{{ transaction.SURVEYQUESTION }}
{{ text_survey_chosen }}{{ transaction.SURVEYCHOICESELECTED }}
{{ text_receiver_business }}{{ transaction.RECEIVERBUSINESS }}
{{ text_receiver_email }}{{ transaction.RECEIVEREMAIL }}
{{ text_receiver_id }}{{ transaction.RECEIVERID }}
{{ text_buyer_email }}{{ transaction.EMAIL }}
{{ text_payer_id }}{{ transaction.PAYERID }}
{{ text_payer_status }}{{ transaction.PAYERSTATUS }}
{{ text_country_code }}{{ transaction.COUNTRYCODE }}
{{ text_payer_business }}{{ transaction.PAYERBUSINESS }}
{{ text_payer_salute }}{{ transaction.SALUTATION }}
{{ text_payer_firstname }}{{ transaction.FIRSTNAME }}
{{ text_payer_middlename }}{{ transaction.MIDDLENAME }}
{{ text_payer_lastname }}{{ transaction.LASTNAME }}
{{ text_payer_suffix }}{{ transaction.SUFFIX }}
{{ text_address_owner }}{{ transaction.ADDRESSOWNER }}
{{ text_address_status }}{{ transaction.ADDRESSSTATUS }}
{{ text_ship_sec_name }}{{ transaction.SHIPTOSECONDARYNAME }}
{{ text_ship_name }}{{ transaction.SHIPTONAME }}
{{ text_ship_street1 }}{{ transaction.SHIPTOSTREET }}
{{ text_ship_sec_add1 }}{{ transaction.SHIPTOSECONDARYADDRESSLINE1 }}
{{ text_ship_street2 }}{{ transaction.SHIPTOSTREET2 }}
{{ text_ship_sec_add2 }}{{ transaction.SHIPTOSECONDARYADDRESSLINE2 }}
{{ text_ship_city }}{{ transaction.SHIPTOCITY }}
{{ text_ship_sec_city }}{{ transaction.SHIPTOSECONDARYCITY }}
{{ text_ship_state }}{{ transaction.SHIPTOSTATE }}
{{ text_ship_sec_state }}{{ transaction.SHIPTOSECONDARYSTATE }}
{{ text_ship_zip }}{{ transaction.SHIPTOZIP }}
{{ text_ship_sec_zip }}{{ transaction.SHIPTOSECONDARYZIP }}
{{ text_ship_country }}{{ transaction.SHIPTOCOUNTRYCODE }}
{{ text_ship_sec_country }}{{ transaction.SHIPTOSECONDARYCOUNTRYCODE }}
{{ text_ship_phone }}{{ transaction.SHIPTOPHONENUM }}
{{ text_ship_sec_phone }}{{ transaction.SHIPTOSECONDARYPHONENUM }}
{{ text_trans_id }}{{ transaction.TRANSACTIONID }}
{{ text_parent_trans_id }}{{ transaction.PARENTTRANSACTIONID }}
{{ text_receipt_id }}{{ transaction.RECEIPTID }}
{{ text_trans_type }}{{ transaction.TRANSACTIONTYPE }}
{{ text_payment_type }}{{ transaction.PAYMENTTYPE }}
{{ text_order_time }}{{ transaction.ORDERTIME }}
{{ text_amount }}{{ transaction.AMT }}
{{ text_currency_code }}{{ transaction.CURRENCYCODE }}
{{ text_fee_amount }}{{ transaction.FEEAMT }}
{{ text_settle_amount }}{{ transaction.SETTLEAMT }}
{{ text_tax_amount }}{{ transaction.TAXAMT }}
{{ text_exchange }}{{ transaction.EXCHANGERATE }}
{{ text_payment_status }}{{ transaction.PAYMENTSTATUS }}
{{ text_pending_reason }}{{ transaction.PENDINGREASON }}
{{ text_reason_code }}{{ transaction.REASONCODE }}
{{ text_protect_elig }}{{ transaction.PROTECTIONELIGIBILITY }}
{{ text_protect_elig_type }}{{ transaction.PROTECTIONELIGIBILITYTYPE }}
{{ text_store_id }}{{ transaction.STOREID }}
{{ text_terminal_id }}{{ transaction.TERMINALID }}
{{ text_invoice_number }}{{ transaction.INVNUM }}
{{ text_custom }}{{ transaction.CUSTOM }}
{{ text_note }}{{ transaction.NOTE }}
{{ text_sales_tax }}{{ transaction.SALESTAX }}
{{ text_buyer_id }}{{ transaction.BUYERID }}
{{ text_close_date }}{{ transaction.CLOSINGDATE }}
{{ text_multi_item }}{{ transaction.MULTIITEM }}
{{ text_sub_amt }}{{ transaction.AMOUNT }}
{{ text_sub_period }}{{ transaction.PERIOD }}
-
-
-
-
-{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_payflow.twig b/upload/admin/view/template/extension/payment/pp_payflow.twig deleted file mode 100644 index 0f452aba857..00000000000 --- a/upload/admin/view/template/extension/payment/pp_payflow.twig +++ /dev/null @@ -1,155 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
-
- -
- - {% if error_vendor %} -
{{ error_vendor }}
- {% endif %} -
-
-
- -
- - {% if error_user %} -
{{ error_user }}
- {% endif %} -
-
-
- -
- - {% if error_password %} -
{{ error_password }}
- {% endif %} -
-
-
- -
- - {% if error_partner %} -
{{ error_partner }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
-{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_payflow_iframe.twig b/upload/admin/view/template/extension/payment/pp_payflow_iframe.twig deleted file mode 100644 index 966219d69a9..00000000000 --- a/upload/admin/view/template/extension/payment/pp_payflow_iframe.twig +++ /dev/null @@ -1,212 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
-
- -
- - {% if error_vendor %} -
{{ error_vendor }}
- {% endif %} -
-
-
- -
- - {% if error_user %} -
{{ error_user }}
- {% endif %} -
-
-
- -
- - {% if error_password %} -
{{ error_password }}
- {% endif %} -
-
-
- -
- - {% if error_partner %} -
{{ error_partner }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_payflow_iframe_order.twig b/upload/admin/view/template/extension/payment/pp_payflow_iframe_order.twig deleted file mode 100644 index d265c741971..00000000000 --- a/upload/admin/view/template/extension/payment/pp_payflow_iframe_order.twig +++ /dev/null @@ -1,155 +0,0 @@ -

{{ text_payment_info }}

- - - - - - - - - - - - - - - - - -
{{ entry_capture_status }}: {% if complete %} - {{ text_complete }} - {% else %} - {{ text_incomplete }} - {% endif %}
{{ entry_capture }}{% if complete %} - - - {% else %} - {{ entry_complete_capture }} - -
- - {{ button_capture }} - {% endif %}
{{ entry_void }}{% if complete %} - - - {% else %} - {{ button_void }} - {% endif %}
{{ entry_transactions }} - - - - - - - - - - - {% for transaction in transactions %} - - - - - - - - {% endfor %} - -
{{ column_transaction_id }}{{ column_transaction_type }}{{ column_amount }}{{ column_time }}{{ column_actions }}
{{ transaction.transaction_reference }}{{ transaction.transaction_type }}{{ transaction.amount|number_format(2) }}{{ transaction.time }}{% for action in transaction.actions %} - [{{ action.title }}] - {% endfor %}
- \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_payflow_iframe_refund.twig b/upload/admin/view/template/extension/payment/pp_payflow_iframe_refund.twig deleted file mode 100644 index 6423fbd3f0d..00000000000 --- a/upload/admin/view/template/extension/payment/pp_payflow_iframe_refund.twig +++ /dev/null @@ -1,69 +0,0 @@ -{{ header }}{{ column_left }} -
- -
-
-
-

{{ heading_title }}

-
-
- - - - - - - - - - - - - -
{{ entry_transaction_reference }}{{ transaction_reference }}
{{ entry_transaction_amount }}{{ transaction_amount }}
{{ entry_refund_amount }} - {{ button_refund }}
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_pro.twig b/upload/admin/view/template/extension/payment/pp_pro.twig deleted file mode 100644 index 6a3e4d9bae6..00000000000 --- a/upload/admin/view/template/extension/payment/pp_pro.twig +++ /dev/null @@ -1,146 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
-
- -
- - {% if error_username %} -
{{ error_username }}
- {% endif %} -
-
-
- -
- - {% if error_password %} -
{{ error_password }}
- {% endif %} -
-
-
- -
- - {% if error_signature %} -
{{ error_signature }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_pro_iframe.twig b/upload/admin/view/template/extension/payment/pp_pro_iframe.twig deleted file mode 100644 index f296a29c1b0..00000000000 --- a/upload/admin/view/template/extension/payment/pp_pro_iframe.twig +++ /dev/null @@ -1,315 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error.error_warning %} -
{{ error.error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
- -
-
-
- -
- - {% if error.username %} -
{{ error.username }}
- {% endif %} -
-
-
- -
- - {% if error.password %} -
{{ error.password }}
- {% endif %} -
-
-
- -
- - {% if error.signature %} -
{{ error.signature }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_pro_iframe_order.twig b/upload/admin/view/template/extension/payment/pp_pro_iframe_order.twig deleted file mode 100644 index 8a31e28eca8..00000000000 --- a/upload/admin/view/template/extension/payment/pp_pro_iframe_order.twig +++ /dev/null @@ -1,271 +0,0 @@ -

{{ text_payment_info }}

- - - - - - - - - - - - - - - - - - {% if paypal_order.capture_status != 'Complete' %} - - - - - {% endif %} - {% if paypal_order.capture_status != 'Complete' %} - - - - - {% endif %} - - - - -
{{ text_capture_status }}{{ paypal_order.capture_status }}
{{ text_amount_auth }}{{ paypal_order.total }} - {% if paypal_order.capture_status != 'Complete' %} -    {{ button_void }} - {% endif %}
{{ text_amount_captured }}{{ paypal_order.captured }}
{{ text_amount_refunded }}{{ paypal_order.refunded }}
{{ text_capture_amount }}

- - {{ text_complete_capture }}

-

- - {{ button_capture }}

{{ text_reauthorise }}{{ button_reauthorise }}
{{ text_transactions }}: - - - - - - - - - - - - - {% for transaction in transactions %} - - - - - - - - - - {% endfor %} - -
{{ column_trans_id }}{{ column_amount }}{{ column_type }}{{ column_status }}{{ column_pending_reason }}{{ column_date_added }}{{ column_action }}
{{ transaction.transaction_id }}{{ transaction.amount }}{{ transaction.payment_type }}{{ transaction.payment_status }}{{ transaction.pending_reason }}{{ transaction.date_added }}{% if transaction.transaction_id %} - {{ text_view }} - {% if transaction.payment_type == 'instant' and (transaction.payment_status == 'Completed' or transaction.payment_status == 'Partially-Refunded') %} -  {{ text_refund }} - {% endif %} - {% else %} - {{ text_resend }} - {% endif %}
- diff --git a/upload/admin/view/template/extension/payment/pp_pro_iframe_refund.twig b/upload/admin/view/template/extension/payment/pp_pro_iframe_refund.twig deleted file mode 100644 index cbac73ecd4d..00000000000 --- a/upload/admin/view/template/extension/payment/pp_pro_iframe_refund.twig +++ /dev/null @@ -1,74 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error != '' %} -
{{ error }} - -
- {% endif %} - {% if attention != '' %} -
{{ attention }} - -
- {% endif %} -
-
-

{{ heading_title }}

-
-
-
- - -
- -
- -
-
-
- -
- - -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
-
-
-{{ footer }} diff --git a/upload/admin/view/template/extension/payment/pp_pro_iframe_transaction.twig b/upload/admin/view/template/extension/payment/pp_pro_iframe_transaction.twig deleted file mode 100644 index 3b2243d2ab4..00000000000 --- a/upload/admin/view/template/extension/payment/pp_pro_iframe_transaction.twig +++ /dev/null @@ -1,422 +0,0 @@ -{{ header }}{{ column_left }} -
- -
-
-
-

{{ heading_title }}

-
-
- - {% if transaction.GIFTMESSAGE %} - - - - - {% endif %} - {% if transaction.GIFTRECEIPTENABLE %} - - - - - {% endif %} - {% if transaction.GIFTWRAPNAME %} - - - - - {% endif %} - {% if transaction.GIFTWRAPAMOUNT %} - - - - - {% endif %} - {% if transaction.BUYERMARKETINGEMAIL %} - - - - - {% endif %} - {% if transaction.SURVEYQUESTION %} - - - - - {% endif %} - {% if transaction.SURVEYCHOICESELECTED %} - - - - - {% endif %} - {% if transaction.RECEIVERBUSINESS %} - - - - - {% endif %} - {% if transaction.RECEIVEREMAIL %} - - - - - {% endif %} - {% if transaction.RECEIVERID %} - - - - - {% endif %} - {% if transaction.EMAIL %} - - - - - {% endif %} - {% if transaction.PAYERID %} - - - - - {% endif %} - {% if transaction.PAYERSTATUS %} - - - - - {% endif %} - {% if transaction.COUNTRYCODE %} - - - - - {% endif %} - {% if transaction.PAYERBUSINESS %} - - - - - {% endif %} - {% if transaction.SALUTATION %} - - - - - {% endif %} - {% if transaction.FIRSTNAME %} - - - - - {% endif %} - {% if transaction.MIDDLENAME %} - - - - - {% endif %} - {% if transaction.LASTNAME %} - - - - - {% endif %} - {% if transaction.SUFFIX %} - - - - - {% endif %} - {% if transaction.ADDRESSOWNER %} - - - - - {% endif %} - {% if transaction.ADDRESSSTATUS %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYNAME %} - - - - - {% endif %} - {% if transaction.SHIPTONAME %} - - - - - {% endif %} - {% if transaction.SHIPTOSTREET %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYADDRESSLINE1 %} - - - - - {% endif %} - {% if transaction.SHIPTOSTREET2 %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYADDRESSLINE2 %} - - - - - {% endif %} - {% if transaction.SHIPTOCITY %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYCITY %} - - - - - {% endif %} - {% if transaction.SHIPTOSTATE %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYSTATE %} - - - - - {% endif %} - {% if transaction.SHIPTOZIP %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYZIP %} - - - - - {% endif %} - {% if transaction.SHIPTOCOUNTRYCODE %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYCOUNTRYCODE %} - - - - - {% endif %} - {% if transaction.SHIPTOPHONENUM %} - - - - - {% endif %} - {% if transaction.SHIPTOSECONDARYPHONENUM %} - - - - - {% endif %} - {% if transaction.TRANSACTIONID %} - - - - - {% endif %} - {% if transaction.PARENTTRANSACTIONID %} - - - - - {% endif %} - {% if transaction.RECEIPTID %} - - - - - {% endif %} - {% if transaction.TRANSACTIONTYPE %} - - - - - {% endif %} - {% if transaction.PAYMENTTYPE %} - - - - - {% endif %} - {% if transaction.ORDERTIME %} - - - - - {% endif %} - {% if transaction.AMT %} - - - - - {% endif %} - {% if transaction.CURRENCYCODE %} - - - - - {% endif %} - {% if transaction.FEEAMT %} - - - - - {% endif %} - {% if transaction.SETTLEAMT %} - - - - - {% endif %} - {% if transaction.TAXAMT %} - - - - - {% endif %} - {% if transaction.EXCHANGERATE %} - - - - - {% endif %} - {% if transaction.PAYMENTSTATUS %} - - - - - {% endif %} - {% if transaction.PENDINGREASON %} - - - - - {% endif %} - {% if transaction.REASONCODE %} - - - - - {% endif %} - {% if transaction.PROTECTIONELIGIBILITY %} - - - - - {% endif %} - {% if transaction.PROTECTIONELIGIBILITYTYPE %} - - - - - {% endif %} - {% if transaction.STOREID %} - - - - - {% endif %} - {% if transaction.TERMINALID %} - - - - - {% endif %} - {% if transaction.INVNUM %} - - - - - {% endif %} - {% if transaction.CUSTOM %} - - - - - {% endif %} - {% if transaction.NOTE %} - - - - - {% endif %} - {% if transaction.SALESTAX %} - - - - - {% endif %} - {% if transaction.BUYERID %} - - - - - {% endif %} - {% if transaction.CLOSINGDATE %} - - - - - {% endif %} - {% if transaction.MULTIITEM %} - - - - - {% endif %} - {% if transaction.AMOUNT %} - - - - - {% endif %} - {% if transaction.PERIOD %} - - - - - {% endif %} -
{{ text_gift_msg }}{{ transaction.GIFTMESSAGE }}
{{ text_gift_receipt }}{{ transaction.GIFTRECEIPTENABLE }}
{{ text_gift_wrap_name }}{{ transaction.GIFTWRAPNAME }}
{{ text_gift_wrap_amt }}{{ transaction.GIFTWRAPAMOUNT }}
{{ text_buyer_email_market }}{{ transaction.BUYERMARKETINGEMAIL }}
{{ text_survey_question }}{{ transaction.SURVEYQUESTION }}
{{ text_survey_chosen }}{{ transaction.SURVEYCHOICESELECTED }}
{{ text_receiver_business }}{{ transaction.RECEIVERBUSINESS }}
{{ text_receiver_email }}{{ transaction.RECEIVEREMAIL }}
{{ text_receiver_id }}{{ transaction.RECEIVERID }}
{{ text_buyer_email }}{{ transaction.EMAIL }}
{{ text_payer_id }}{{ transaction.PAYERID }}
{{ text_payer_status }}{{ transaction.PAYERSTATUS }}
{{ text_country_code }}{{ transaction.COUNTRYCODE }}
{{ text_payer_business }}{{ transaction.PAYERBUSINESS }}
{{ text_payer_salute }}{{ transaction.SALUTATION }}
{{ text_payer_firstname }}{{ transaction.FIRSTNAME }}
{{ text_payer_middlename }}{{ transaction.MIDDLENAME }}
{{ text_payer_lastname }}{{ transaction.LASTNAME }}
{{ text_payer_suffix }}{{ transaction.SUFFIX }}
{{ text_address_owner }}{{ transaction.ADDRESSOWNER }}
{{ text_address_status }}{{ transaction.ADDRESSSTATUS }}
{{ text_ship_sec_name }}{{ transaction.SHIPTOSECONDARYNAME }}
{{ text_ship_name }}{{ transaction.SHIPTONAME }}
{{ text_ship_street1 }}{{ transaction.SHIPTOSTREET }}
{{ text_ship_sec_add1 }}{{ transaction.SHIPTOSECONDARYADDRESSLINE1 }}
{{ text_ship_street2 }}{{ transaction.SHIPTOSTREET2 }}
{{ text_ship_sec_add2 }}{{ transaction.SHIPTOSECONDARYADDRESSLINE2 }}
{{ text_ship_city }}{{ transaction.SHIPTOCITY }}
{{ text_ship_sec_city }}{{ transaction.SHIPTOSECONDARYCITY }}
{{ text_ship_state }}{{ transaction.SHIPTOSTATE }}
{{ text_ship_sec_state }}{{ transaction.SHIPTOSECONDARYSTATE }}
{{ text_ship_zip }}{{ transaction.SHIPTOZIP }}
{{ text_ship_sec_zip }}{{ transaction.SHIPTOSECONDARYZIP }}
{{ text_ship_country }}{{ transaction.SHIPTOCOUNTRYCODE }}
{{ text_ship_sec_country }}{{ transaction.SHIPTOSECONDARYCOUNTRYCODE }}
{{ text_ship_phone }}{{ transaction.SHIPTOPHONENUM }}
{{ text_ship_sec_phone }}{{ transaction.SHIPTOSECONDARYPHONENUM }}
{{ text_trans_id }}{{ transaction.TRANSACTIONID }}
{{ text_parent_trans_id }}{{ transaction.PARENTTRANSACTIONID }}
{{ text_receipt_id }}{{ transaction.RECEIPTID }}
{{ text_trans_type }}{{ transaction.TRANSACTIONTYPE }}
{{ text_payment_type }}{{ transaction.PAYMENTTYPE }}
{{ text_order_time }}{{ transaction.ORDERTIME }}
{{ text_amount }}{{ transaction.AMT }}
{{ text_currency_code }}{{ transaction.CURRENCYCODE }}
{{ text_fee_amount }}{{ transaction.FEEAMT }}
{{ text_settle_amount }}{{ transaction.SETTLEAMT }}
{{ text_tax_amount }}{{ transaction.TAXAMT }}
{{ text_exchange }}{{ transaction.EXCHANGERATE }}
{{ text_payment_status }}{{ transaction.PAYMENTSTATUS }}
{{ text_pending_reason }}{{ transaction.PENDINGREASON }}
{{ text_reason_code }}{{ transaction.REASONCODE }}
{{ text_protect_elig }}{{ transaction.PROTECTIONELIGIBILITY }}
{{ text_protect_elig_type }}{{ transaction.PROTECTIONELIGIBILITYTYPE }}
{{ text_store_id }}{{ transaction.STOREID }}
{{ text_terminal_id }}{{ transaction.TERMINALID }}
{{ text_invoice_number }}{{ transaction.INVNUM }}
{{ text_custom }}{{ transaction.CUSTOM }}
{{ text_note }}{{ transaction.NOTE }}
{{ text_sales_tax }}{{ transaction.SALESTAX }}
{{ text_buyer_id }}{{ transaction.BUYERID }}
{{ text_close_date }}{{ transaction.CLOSINGDATE }}
{{ text_multi_item }}{{ transaction.MULTIITEM }}
{{ text_sub_amt }}{{ transaction.AMOUNT }}
{{ text_sub_period }}{{ transaction.PERIOD }}
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/pp_standard.twig b/upload/admin/view/template/extension/payment/pp_standard.twig deleted file mode 100644 index d86d7711a9a..00000000000 --- a/upload/admin/view/template/extension/payment/pp_standard.twig +++ /dev/null @@ -1,278 +0,0 @@ -{{ header }}{{ column_left }} -
- -
- {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
-
-

{{ text_edit }}

-
-
-
- -
-
-
- -
- - {% if error_email %} -
{{ error_email }}
- {% endif %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
-
-
-
-{{ footer }} \ No newline at end of file diff --git a/upload/catalog/controller/extension/module/klarna_checkout_module.php b/upload/catalog/controller/extension/module/klarna_checkout_module.php new file mode 100644 index 00000000000..079207f1452 --- /dev/null +++ b/upload/catalog/controller/extension/module/klarna_checkout_module.php @@ -0,0 +1,138 @@ +load->model('extension/payment/klarna_checkout'); + + // If Payment Method or Module is disabled + if (!$this->config->get('module_klarna_checkout_status') || !$this->config->get('klarna_checkout_status')) { + $this->model_extension_payment_klarna_checkout->log('Not shown due to Payment Method or Module being disabled'); + return false; + } + + // Validate cart has products and has stock. + if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { + $this->model_extension_payment_klarna_checkout->log('Not shown due to empty cart'); + return false; + } + + // Validate minimum quantity requirements. + $products = $this->cart->getProducts(); + + foreach ($products as $product) { + $product_total = 0; + + foreach ($products as $product_2) { + if ($product_2['product_id'] == $product['product_id']) { + $product_total += $product_2['quantity']; + } + } + + if ($product['minimum'] > $product_total) { + $this->model_extension_payment_klarna_checkout->log('Not shown due to cart not meeting minimum quantity reqs.'); + return false; + } + } + + // Validate cart has recurring products + if ($this->cart->hasRecurringProducts()) { + $this->model_extension_payment_klarna_checkout->log('Not shown due to cart having recurring products.'); + return false; + } + + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + if ($this->config->get('klarna_checkout_total') > 0 && $this->config->get('klarna_checkout_total') > $total) { + return false; + } + + if ($this->model_extension_payment_klarna_checkout->checkForPaymentTaxes($products)) { + $this->model_extension_payment_klarna_checkout->log('Payment Address based taxes used.'); + return false; + } + + $this->setShipping(); + + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $this->session->data['currency']); + + if (!$klarna_account || !$connector) { + $this->model_extension_payment_klarna_checkout->log('Couldn\'t secure connection to Klarna API.'); + return false; + } + + $data['klarna_checkout'] = $this->url->link('extension/payment/klarna_checkout', '', true); + + return $this->load->view('extension/module/klarna_checkout_module', $data); + } + + private function setShipping() { + $this->load->model('account/address'); + $this->load->model('localisation/country'); + $this->load->model('localisation/zone'); + + if (isset($this->session->data['shipping_address']) && !empty($this->session->data['shipping_address'])) { + $this->session->data['shipping_address'] = $this->session->data['shipping_address']; + } elseif ($this->customer->isLogged() && $this->customer->getAddressId()) { + $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); + } else { + $country_info = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); + + $zone_info = $this->model_localisation_zone->getZone($this->config->get('config_zone_id')); + + $this->session->data['shipping_address'] = array( + 'address_id' => null, + 'firstname' => null, + 'lastname' => null, + 'company' => null, + 'address_1' => null, + 'address_2' => null, + 'postcode' => null, + 'city' => null, + 'zone_id' => $zone_info['zone_id'], + 'zone' => $zone_info['name'], + 'zone_code' => $zone_info['code'], + 'country_id' => $country_info['country_id'], + 'country' => $country_info['name'], + 'iso_code_2' => $country_info['iso_code_2'], + 'iso_code_3' => $country_info['iso_code_3'], + 'address_format' => '', + 'custom_field' => null, + ); + } + + if (isset($this->session->data['shipping_address'])) { + // Shipping Methods + $method_data = array(); + + $this->load->model('setting/extension'); + + $results = $this->model_setting_extension->getExtensions('shipping'); + + foreach ($results as $result) { + if ($this->config->get('shipping_' . $result['code'] . '_status')) { + $this->load->model('extension/shipping/' . $result['code']); + + $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); + + if ($quote) { + $method_data[$result['code']] = array( + 'title' => $quote['title'], + 'quote' => $quote['quote'], + 'sort_order' => $quote['sort_order'], + 'error' => $quote['error'] + ); + } + } + } + + $sort_order = array(); + + foreach ($method_data as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $method_data); + + $this->session->data['shipping_methods'] = $method_data; + } + } +} diff --git a/upload/catalog/controller/extension/payment/klarna_checkout.php b/upload/catalog/controller/extension/payment/klarna_checkout.php new file mode 100644 index 00000000000..675ea81f77b --- /dev/null +++ b/upload/catalog/controller/extension/payment/klarna_checkout.php @@ -0,0 +1,1963 @@ +load->language('extension/payment/klarna_checkout'); + + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('localisation/country'); + + $this->document->setTitle($this->language->get('heading_title')); + + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + + $this->response->setOutput($this->load->view('extension/payment/klarna_checkout', $data)); + } + + public function main() { + $this->load->language('extension/payment/klarna_checkout'); + + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('localisation/country'); + + $redirect = false; + $html_snippet = ''; + + // Validate cart has products and has stock. + if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { + $redirect = $this->url->link('checkout/cart'); + } + + // Validate minimum quantity requirements. + $products = $this->cart->getProducts(); + + foreach ($products as $product) { + $product_total = 0; + + foreach ($products as $product_2) { + if ($product_2['product_id'] == $product['product_id']) { + $product_total += $product_2['quantity']; + } + } + + if ($product['minimum'] > $product_total) { + $redirect = $this->url->link('checkout/cart'); + } + } + + // Validate cart has recurring products + if ($this->cart->hasRecurringProducts()) { + $redirect = $this->url->link('checkout/cart'); + } + + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + if ($this->config->get('klarna_checkout_total') > 0 && $this->config->get('klarna_checkout_total') > $total) { + $redirect = $this->url->link('checkout/cart'); + } + + if (!$this->config->get('klarna_checkout_status')) { + $redirect = $this->url->link('checkout/cart'); + } + + if ($this->model_extension_payment_klarna_checkout->checkForPaymentTaxes($products)) { + $redirect = $this->url->link('checkout/cart'); + } + + $text_title = $this->language->get('text_title'); + + unset($this->session->data['success']); + + $this->setPayment(); + $this->setShipping(); + + $this->session->data['payment_method'] = array( + 'code' => 'klarna_checkout', + 'title' => $text_title, + 'terms' => $this->url->link('information/information', 'information_id=' . $this->config->get('klarna_checkout_terms'), true), + 'sort_order' => '1' + ); + + // Shipping + $unset_shipping_method = true; + if (isset($this->session->data['shipping_method']) && isset($this->session->data['shipping_methods'])) { + foreach ($this->session->data['shipping_methods'] as $shipping_method) { + if ($shipping_method['quote']) { + foreach ($shipping_method['quote'] as $quote) { + if ($quote['code'] == $this->session->data['shipping_method']['code']) { + $unset_shipping_method = false; + break 2; + } + } + } + } + } + + if ($unset_shipping_method) { + unset($this->session->data['shipping_method']); + } + + if ((!isset($this->session->data['shipping_method']) || empty($this->session->data['shipping_method'])) && (isset($this->session->data['shipping_methods']) && !empty($this->session->data['shipping_methods']))) { + $this->session->data['shipping_method'] = $this->model_extension_payment_klarna_checkout->getDefaultShippingMethod($this->session->data['shipping_methods']); + } + + //Klarna Connector + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $this->session->data['currency']); + + if (!$klarna_account || !$connector) { + $redirect = $this->url->link('checkout/cart'); + } + + if (!$redirect) { + // Get currency code and currency value to use to calculate taxes + + // Build order_lines + $create_order = true; + $klarna_checkout = false; + + $this->createOrder(); + + list($klarna_order_data, $encrypted_order_data) = $this->klarnaOrderData($klarna_account); + + if (isset($this->session->data['klarna_checkout_currency']) && $this->session->data['klarna_checkout_currency'] != $this->session->data['currency']) { + $this->model_extension_payment_klarna_checkout->log('Currency changed, unsetting kc order id'); + unset($this->session->data['klarna_checkout_order_id']); + unset($this->session->data['klarna_checkout_data']); + } + + $this->session->data['klarna_checkout_currency'] = $this->session->data['currency']; + + // Fetch or create order + if (isset($this->session->data['klarna_checkout_order_id'])) { + $retrieve = $this->model_extension_payment_klarna_checkout->orderRetrieve($connector, $this->session->data['klarna_checkout_order_id']); + + if ($retrieve) { + //If address has changed, unset klarna_checkout_order_id and create new order + $address_change = false; + + if (isset($this->session->data['klarna_checkout_data']) && $this->session->data['klarna_checkout_data']) { + if (isset($this->session->data['klarna_checkout_data']['zone_code'])) { + $kc_region = $this->session->data['klarna_checkout_data']['zone_code']; + } else { + $kc_region = ''; + } + + if (isset($this->session->data['klarna_checkout_data']['iso_code_2'])) { + $kc_country = $this->session->data['klarna_checkout_data']['iso_code_2']; + } else { + $kc_country = ''; + } + + if (isset($this->session->data['shipping_address']['zone_code'])) { + $oc_region = $this->session->data['shipping_address']['zone_code']; + } else { + $oc_region = ''; + } + + if (isset($this->session->data['shipping_address']['iso_code_2'])) { + $oc_country = $this->session->data['shipping_address']['iso_code_2']; + } else { + $oc_country = ''; + } + + $kc_address = array( + 'region' => $kc_region, + 'country' => $kc_country, + ); + + $oc_address = array( + 'region' => $oc_region, + 'country' => $oc_country, + ); + + //If address has changed, dont use retrieved order, create new one instead + if (array_diff(array_map('strtolower', $kc_address), array_map('strtolower', $oc_address))) { + $address_change = true; + } + } + + if (!$address_change) { + $this->model_extension_payment_klarna_checkout->log('Order Updated'); + $this->model_extension_payment_klarna_checkout->log($klarna_order_data); + + $create_order = false; + + $update = $this->model_extension_payment_klarna_checkout->orderUpdate($connector, $this->session->data['klarna_checkout_order_id'], $klarna_order_data); + + if ($update) { + $klarna_checkout = $update->fetch(); + + $this->model_extension_payment_klarna_checkout->updateOrder($this->session->data['order_id'], $klarna_checkout['order_id'], $encrypted_order_data); + } + } + } + } + + if ($create_order) { + $this->model_extension_payment_klarna_checkout->log('Order Created'); + $this->model_extension_payment_klarna_checkout->log($klarna_order_data); + + unset($this->session->data['klarna_checkout_data']); + + $create = $this->model_extension_payment_klarna_checkout->orderCreate($connector, $klarna_order_data); + + if ($create) { + $klarna_checkout = $create->fetch(); + + $this->model_extension_payment_klarna_checkout->addOrder($this->session->data['order_id'], $klarna_checkout['order_id'], $encrypted_order_data); + } + } + + if ($klarna_checkout) { + $this->session->data['klarna_checkout_order_id'] = $klarna_checkout['order_id']; + + $html_snippet = $klarna_checkout['html_snippet']; + } + } + + if (isset($this->request->post['response']) && $this->request->post['response'] == 'template') { + $data['redirect'] = $redirect; + + $data['klarna_checkout'] = $html_snippet; + + $this->response->setOutput($this->load->view('extension/payment/klarna_checkout_main', $data)); + } elseif (isset($this->request->post['response']) && $this->request->post['response'] == 'json') { + $json['redirect'] = $redirect; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + } + + public function sidebar() { + $this->load->language('checkout/checkout'); + $this->load->language('extension/payment/klarna_checkout'); + + $this->load->model('extension/payment/klarna_checkout'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + $this->setPayment(); + $this->setShipping(); + + // Shipping + $unset_shipping_method = true; + if (isset($this->session->data['shipping_method']) && isset($this->session->data['shipping_methods'])) { + foreach ($this->session->data['shipping_methods'] as $shipping_method) { + if ($shipping_method['quote']) { + foreach ($shipping_method['quote'] as $quote) { + if ($quote['code'] == $this->session->data['shipping_method']['code']) { + $unset_shipping_method = false; + break 2; + } + } + } + } + } + + if ($unset_shipping_method) { + unset($this->session->data['shipping_method']); + } + + if ((!isset($this->session->data['shipping_method']) || empty($this->session->data['shipping_method'])) && (isset($this->session->data['shipping_methods']) && !empty($this->session->data['shipping_methods']))) { + $this->session->data['shipping_method'] = $this->model_extension_payment_klarna_checkout->getDefaultShippingMethod($this->session->data['shipping_methods']); + } + + $data['shipping_required'] = $this->cart->hasShipping(); + + if (isset($this->session->data['shipping_methods'])) { + $data['shipping_methods'] = $this->session->data['shipping_methods']; + } else { + unset($data['shipping_method']); + + $data['shipping_methods'] = array(); + } + + if (isset($this->session->data['shipping_method']['code'])) { + $data['code'] = $this->session->data['shipping_method']['code']; + } else { + $data['code'] = ''; + } + + $this->load->model('tool/image'); + $this->load->model('tool/upload'); + + $data['products'] = array(); + + foreach ($this->cart->getProducts() as $product) { + if ($product['image']) { + $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); + } else { + $image = ''; + } + + $option_data = array(); + + foreach ($product['option'] as $option) { + if ($option['type'] != 'file') { + $value = $option['value']; + } else { + $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); + + if ($upload_info) { + $value = $upload_info['name']; + } else { + $value = ''; + } + } + + $option_data[] = array( + 'name' => $option['name'], + 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value), + 'type' => $option['type'] + ); + } + + // Display prices + if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { + $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); + } else { + $price = false; + } + + // Display prices + if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { + $total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity'], $this->session->data['currency']); + } else { + $total = false; + } + + $data['products'][] = array( + 'cart_id' => $product['cart_id'], + 'thumb' => $image, + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''), + 'quantity' => $product['quantity'], + 'price' => $price, + 'total' => $total, + 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']) + ); + } + + // Gift Voucher + $data['vouchers'] = array(); + + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $key => $voucher) { + $data['vouchers'][] = array( + 'key' => $key, + 'description' => $voucher['description'], + 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']) + ); + } + } + + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + $this->load->model('setting/extension'); + + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get($result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + + $data['totals'] = array(); + + foreach ($totals as $total) { + $data['totals'][] = array( + 'title' => $total['title'], + 'text' => $this->currency->format($total['value'], $this->session->data['currency']) + ); + } + + $this->response->setOutput($this->load->view('extension/payment/klarna_checkout_sidebar', $data)); + } + + public function shippingAddress() { + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('localisation/zone'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + $json = array(); + + unset($this->session->data['shipping_address']); + unset($this->session->data['shipping_methods']); + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['country'])) { + $country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode3($this->request->post['country']); + + if ($country_info) { + // Set default zone for shipping calculations. Get overwritten by correct data when order is confirmed + $zones = $this->model_localisation_zone->getZonesByCountryId($country_info['country_id']); + + $zone = array(); + if (isset($this->request->post['region']) && !empty($this->request->post['region'])) { + $zone = $this->model_extension_payment_klarna_checkout->getZoneByCode($this->request->post['region'], $country_info['country_id']); + } + + if ($zone || $zones) { + $this->session->data['shipping_address'] = array( + 'address_id' => null, + 'firstname' => utf8_substr($this->request->post['given_name'], 0, 32), + 'lastname' => utf8_substr($this->request->post['family_name'], 0, 32), + 'company' => null, + 'address_1' => utf8_substr($this->request->post['street_address'], 0, 128), + 'address_2' => utf8_substr($this->request->post['street_address'], 129, 256), + 'postcode' => utf8_substr($this->request->post['postal_code'], 0, 10), + 'city' => utf8_substr($this->request->post['city'], 0, 128), + 'zone_id' => ($zone ? $zone['zone_id'] : $zones[0]['zone_id']), + 'zone' => ($zone ? $zone['name'] : $zones[0]['name']), + 'zone_code' => ($zone ? $zone['code'] : $zones[0]['code']), + 'country_id' => $country_info['country_id'], + 'country' => $country_info['name'], + 'iso_code_2' => $country_info['iso_code_2'], + 'iso_code_3' => $country_info['iso_code_3'], + 'address_format' => $country_info['address_format'], + 'custom_field' => array(), + ); + + $this->tax->unsetRates(); + $this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']); + $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); + } + } else { + $this->model_extension_payment_klarna_checkout->log('Couldnt find country: ' . $this->request->post['country']); + } + } + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + + public function cartTotal() { + $this->load->language('checkout/cart'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + // Totals + $this->load->model('setting/extension'); + + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + // Display prices + if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get($result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + + $total = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->session->data['currency'])); + } + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($total)); + } + + public function addressUpdate() { + $this->load->language('extension/payment/klarna_checkout'); + + $this->load->model('account/customer'); + $this->load->model('checkout/order'); + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('localisation/zone'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + $process = true; + + $request = json_decode(file_get_contents('php://input')); + + $json = array(); + + $http_response_code = 400; + + // Check to see if request data is complete + if (!$request || !isset($request->order_lines) || empty($request->order_lines) || !isset($request->shipping_address) || empty($request->shipping_address)) { + $this->model_extension_payment_klarna_checkout->log('Request data incomplete. Full request below:'); + $this->model_extension_payment_klarna_checkout->log($request); + $process = false; + } + + // Get Klarna order info from db + if ($process) { + $order_id = null; + + foreach ($request->order_lines as $order_line) { + if ($order_line->type == 'physical' || $order_line->type == 'digital' || $order_line->type == 'gift_card') { + $order_id = $this->encryption->decrypt($this->config->get('config_encryption'), $order_line->merchant_data); + break; + } + } + + if ($order_id) { + // Get klarna order data from db + $klarna_checkout_order = $this->model_extension_payment_klarna_checkout->getOrderByOrderId($order_id); + + if (!$klarna_checkout_order || !$klarna_checkout_order['data']) { + $this->model_extension_payment_klarna_checkout->log('No klarna order found using order_id: ' . $order_id); + $process = false; + } + } else { + $process = false; + } + } + + if ($process) { + $klarna_checkout_order_data = json_decode($this->encryption->decrypt($this->config->get('config_encryption'), $klarna_checkout_order['data']), true); + + // Check credentials in request with ones stored in db + $valid_request = false; + foreach ($this->config->get('klarna_checkout_account') as $account) { + if (($account['merchant_id'] == $klarna_checkout_order_data['merchant_id']) && ($account['secret'] == $klarna_checkout_order_data['secret'])) { + $valid_request = true; + break; + } + } + + if (!$valid_request) { + $this->model_extension_payment_klarna_checkout->log('Cannot validate request. Terminating.'); + $process = false; + } + } + + // Request is valid, we can spoof/simulate the customer to calculate shipping + if ($process) { + session_destroy(); + session_id($klarna_checkout_order_data['session_id']); + session_start(); + $this->session->start('default', $klarna_checkout_order_data['session_key']); + + if ($klarna_checkout_order_data['customer_id']) { + $customer_info = $this->model_account_customer->getCustomer($klarna_checkout_order_data['customer_id']); + + if ($customer_info) { + $this->customer->login($customer_info['email'], '', true); + } + } + + $order_info = $this->model_checkout_order->getOrder($order_id); + + if (!$order_info) { + $this->model_extension_payment_klarna_checkout->log('No order found using order_id: ' . $order_id . '. Full request below:'); + $this->model_extension_payment_klarna_checkout->log($request); + $process = false; + } + + // Set more session data from the order + $this->session->data['currency'] = $order_info['currency_code']; + $this->session->data['language'] = $order_info['language_code']; + + $country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode2($request->shipping_address->country); + + if (!$country_info) { + $this->model_extension_payment_klarna_checkout->log('No country found using: ' . $request->shipping_address->country . '. Full request below:'); + $this->model_extension_payment_klarna_checkout->log($request); + } + + if ($order_info && $country_info) { + $zones = $this->model_localisation_zone->getZonesByCountryId($country_info['country_id']); + + $zone = array(); + if (isset($request->shipping_address->region) && !empty($request->shipping_address->region)) { + $zone = $this->model_extension_payment_klarna_checkout->getZoneByCode($request->shipping_address->region, $country_info['country_id']); + } + + if ($zone || $zones) { + $this->session->data['shipping_address'] = array( + 'address_id' => null, + 'firstname' => null, + 'lastname' => null, + 'company' => null, + 'address_1' => null, + 'address_2' => null, + 'postcode' => null, + 'city' => null, + 'zone_id' => ($zone ? $zone['zone_id'] : $zones[0]['zone_id']), + 'zone' => ($zone ? $zone['name'] : $zones[0]['name']), + 'zone_code' => ($zone ? $zone['code'] : $zones[0]['code']), + 'country_id' => $country_info['country_id'], + 'country' => $country_info['name'], + 'iso_code_2' => $country_info['iso_code_2'], + 'iso_code_3' => $country_info['iso_code_3'], + 'address_format' => '', + 'custom_field' => array() + ); + + $this->session->data['klarna_checkout_data'] = array( + 'email' => $request->billing_address->email, + 'firstname' => $request->billing_address->given_name, + 'lastname' => $request->billing_address->family_name, + 'telephone' => $request->billing_address->phone, + 'iso_code_2' => $this->session->data['shipping_address']['iso_code_2'], + 'zone_code' => $this->session->data['shipping_address']['zone_code'] + ); + + // Unset $tax_rates + $this->tax->unsetRates(); + $this->tax->setShippingAddress($country_info['country_id'], ($zone ? $zone['zone_id'] : $zones[0]['zone_id'])); + $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); + + //Check if customer is US. If so, send taxes differently + if ($this->session->data['shipping_address']['iso_code_2'] === 'US') { + $include_taxes = false; + } else { + $include_taxes = true; + } + + $method_data = array(); + + $this->load->model('setting/extension'); + + $results = $this->model_setting_extension->getExtensions('shipping'); + + foreach ($results as $result) { + if ($this->config->get('shipping_' . $result['code'] . '_status')) { + $this->load->model('extension/shipping/' . $result['code']); + + $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); + + if ($quote) { + $method_data[$result['code']] = array( + 'title' => $quote['title'], + 'quote' => $quote['quote'], + 'sort_order' => $quote['sort_order'], + 'error' => $quote['error'] + ); + } + } + } + + $sort_order = array(); + + foreach ($method_data as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $method_data); + + $shipping_methods = $method_data; + + if ($shipping_methods) { + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $this->session->data['currency']); + + if ($klarna_account && $connector) { + list($klarna_order_data, $encrypted_order_data) = $this->klarnaOrderData($klarna_account); + + if ($this->cart->hasShipping()) { + $shipping_method = array(); + + if (isset($this->session->data['shipping_method']) && !empty($this->session->data['shipping_method'])) { + foreach ($shipping_methods as $individual_shipping_method) { + if ($individual_shipping_method['quote']) { + foreach ($individual_shipping_method['quote'] as $quote) { + if (($this->session->data['shipping_method']['code'] == $quote['code']) && ($this->session->data['shipping_method']['title'] == $quote['title']) && ($this->session->data['shipping_method']['cost'] == $quote['cost']) && ($this->session->data['shipping_method']['tax_class_id'] == $quote['tax_class_id'])) { + $shipping_method = $quote; + break 2; + } + } + } + } + } + + // If the current shipping method isn't in the available shipping methods, assign default + if (!$shipping_method) { + $this->session->data['shipping_method'] = $this->model_extension_payment_klarna_checkout->getDefaultShippingMethod($shipping_methods); + } + + $total_amount = $this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $include_taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100; + + if ($include_taxes) { + $total_tax_amount = $this->currency->format($this->tax->getTax($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']), $order_info['currency_code'], $order_info['currency_value'], false) * 100; + } else { + $total_tax_amount = 0; + } + + $total_sub_amount = $this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], false), $order_info['currency_code'], $order_info['currency_value'], false) * 100; + + $tax_rate = 0; + + if ($include_taxes && $total_tax_amount && $total_sub_amount) { + $tax_rate = ($total_tax_amount / $total_sub_amount) * 100; + } + + foreach ($klarna_order_data['order_lines'] as $key => $order_line) { + if ($order_line['type'] == 'shipping_fee') { + unset($klarna_order_data['order_lines'][$key]); + break; + } + } + + $klarna_order_data['order_lines'][] = array( + 'type' => 'shipping_fee', + 'name' => $this->session->data['shipping_method']['title'], + 'quantity' => '1', + 'unit_price' => round($this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $include_taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100), + 'tax_rate' => round($tax_rate * 100), + 'total_amount' => round($total_amount), + 'total_tax_amount' => round($total_tax_amount), + 'total_discount_amount' => 0 + ); + } + + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + //If $include_taxes is false, means customer is US so we add a new sales_tax order line with all the tax + if (!$include_taxes) { + foreach ($klarna_order_data['order_lines'] as $key => $order_line) { + if ($order_line['type'] == 'sales_tax') { + unset($klarna_order_data['order_lines'][$key]); + break; + } + } + + $klarna_order_data['order_lines'][] = array( + 'type' => 'sales_tax', + 'name' => $this->language->get('text_sales_tax'), + 'quantity' => '1', + 'unit_price' => round($this->currency->format(array_sum($taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100), + 'tax_rate' => 0, + 'total_amount' => round($this->currency->format(array_sum($taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100), + 'total_tax_amount' => 0, + 'total_discount_amount' => 0 + ); + } + + $http_response_code = 200; + + $json = array( + 'order_amount' => round($this->currency->format($total, $order_info['currency_code'], $order_info['currency_value'], false) * 100), + 'order_tax_amount' => round($this->currency->format(array_sum($taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100), + 'order_lines' => array_values($klarna_order_data['order_lines']) + ); + } + } + } + } + } + + $this->model_extension_payment_klarna_checkout->log($http_response_code); + $this->model_extension_payment_klarna_checkout->log($json); + + http_response_code($http_response_code); + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + + public function notification() { + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('checkout/order'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + $request = json_decode(file_get_contents('php://input')); + + if (isset($request->order_id)) { + $klarna_checkout_order = $this->model_extension_payment_klarna_checkout->getOrder($request->order_id); + + if ($klarna_checkout_order) { + $order_info = $this->model_checkout_order->getOrder($klarna_checkout_order['order_id']); + + if ($order_info) { + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $order_info['currency_code']); + + if (!$klarna_account || !$connector) { + $this->model_extension_payment_klarna_checkout->log('Could not getConnector'); + } + + $retrieve = $this->model_extension_payment_klarna_checkout->omOrderRetrieve($connector, $request->order_id); + + $order_status_id = false; + if ($retrieve) { + switch ($request->event_type) { + case 'FRAUD_RISK_ACCEPTED': + $order_status_id = $this->config->get('klarna_checkout_order_status_fraud_accepted_id'); + break; + case 'FRAUD_RISK_REJECTED': + $order_status_id = $this->config->get('klarna_checkout_order_status_fraud_rejected_id'); + break; + } + } + + if ($order_status_id) { + $this->model_checkout_order->addOrderHistory($klarna_checkout_order['order_id'], $order_status_id); + } + } + } else { + $this->model_extension_payment_klarna_checkout->log('Could not find order id using ' . $request->order_id); + } + } else { + $this->model_extension_payment_klarna_checkout->log('$request->order_id is not set'); + } + } + + public function validation() { + $this->load->model('account/customer'); + $this->load->model('checkout/order'); + $this->load->model('extension/payment/klarna_checkout'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + $validate = true; + + $request = json_decode(file_get_contents('php://input')); + + $json = array(); + + // Check to see if request data is complete + if (!$request || !isset($request->order_lines) || empty($request->order_lines) || !isset($request->shipping_address) || empty($request->shipping_address) || !isset($request->billing_address) || empty($request->billing_address)) { + $this->model_extension_payment_klarna_checkout->log('Request data incomplete. Full request below:'); + $this->model_extension_payment_klarna_checkout->log($request); + $validate = false; + } + + // Get Klarna order info from db + if ($validate) { + $order_id = null; + + foreach ($request->order_lines as $order_line) { + if ($order_line->type == 'physical' || $order_line->type == 'digital' || $order_line->type == 'gift_card') { + $order_id = $this->encryption->decrypt($this->config->get('config_encryption'), $order_line->merchant_data); + break; + } + } + + if ($order_id) { + // Get klarna order data from db + $klarna_checkout_order = $this->model_extension_payment_klarna_checkout->getOrderByOrderId($order_id); + + if (!$klarna_checkout_order || !$klarna_checkout_order['data']) { + $this->model_extension_payment_klarna_checkout->log('No klarna order found using order_id: ' . $order_id); + $validate = false; + } + } else { + $this->model_extension_payment_klarna_checkout->log('Cannot get decrypted order_id'); + $validate = false; + } + } + + if ($validate) { + $klarna_checkout_order_data = json_decode($this->encryption->decrypt($klarna_checkout_order['data']), true); + + // Check credentials in request with ones stored in db + $valid_request = false; + foreach ($this->config->get('klarna_checkout_account') as $account) { + if (($account['merchant_id'] == $klarna_checkout_order_data['merchant_id']) && ($account['secret'] == $klarna_checkout_order_data['secret'])) { + $valid_request = true; + break; + } + } + + if (!$valid_request) { + $this->model_extension_payment_klarna_checkout->log('Cannot validate request. Terminating.'); + $validate = false; + } + } + + // Spoof/simulate the customer to calculate shipping + if ($validate) { + session_destroy(); + session_id($klarna_checkout_order_data['session_id']); + session_start(); + $this->session->start('default', $klarna_checkout_order_data['session_key']); + + if ($klarna_checkout_order_data['customer_id']) { + $customer_info = $this->model_account_customer->getCustomer($klarna_checkout_order_data['customer_id']); + + if ($customer_info) { + $this->customer->login($customer_info['email'], '', true); + } + } + + // Validate cart has products and has stock. + if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { + $this->model_extension_payment_klarna_checkout->log('Cart has no products or cart has no stock'); + $validate = false; + } + + // Validate minimum quantity requirements. + $products = $this->cart->getProducts(); + + foreach ($products as $product) { + $product_total = 0; + + foreach ($products as $product_2) { + if ($product_2['product_id'] == $product['product_id']) { + $product_total += $product_2['quantity']; + } + } + + if ($product['minimum'] > $product_total) { + $this->model_extension_payment_klarna_checkout->log('Cart doesnt meet minimum quantities'); + $validate = false; + } + } + + // Validate cart has recurring products + if ($this->cart->hasRecurringProducts()) { + $this->model_extension_payment_klarna_checkout->log('Cart has recurring products'); + $validate = false; + } + } + + // Check order total to see if session matches post data + if ($validate) { + $order_info = $this->model_checkout_order->getOrder($order_id); + + if ($order_info) { + // Unset $tax_rates and set them again using correct shipping data + $this->tax->unsetRates(); + $this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']); + $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); + + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + // Check order_amount + if (round($this->currency->format($total, $order_info['currency_code'], $order_info['currency_value'], false) * 100) != $request->order_amount) { + $this->model_extension_payment_klarna_checkout->log('Klarna Checkout order_amount does not match session order total. Klarna Request: ' . $request->order_amount . '. OpenCart: ' . round($this->currency->format($total, $order_info['currency_code'], $order_info['currency_value'], false) * 100)); + $this->model_extension_payment_klarna_checkout->log($order_info); + $this->model_extension_payment_klarna_checkout->log($this->cart->getTaxes()); + $validate = false; + } + + // Check order_tax_amount + if (round($this->currency->format(array_sum($taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100) != $request->order_tax_amount) { + $this->model_extension_payment_klarna_checkout->log('Klarna Checkout order_tax_amount does not match session tax total. Totals below:'); + $this->model_extension_payment_klarna_checkout->log('Session taxes:'); + $this->model_extension_payment_klarna_checkout->log(round($this->currency->format(array_sum($taxes), $order_info['currency_code'], $order_info['currency_value'], false) * 100)); + $this->model_extension_payment_klarna_checkout->log('Request taxes:'); + $this->model_extension_payment_klarna_checkout->log($request->order_tax_amount); + $validate = false; + } + } else { + $this->model_extension_payment_klarna_checkout->log('Cannot find order using: ' . $order_id); + $validate = false; + } + } + + // If validates, add customer's email (if guest checkout) and then send 200 response + if ($validate) { + if (!$this->customer->isLogged()) { + $this->model_extension_payment_klarna_checkout->updateOcOrderEmail($order_id, utf8_substr($request->shipping_address->email, 0, 96)); + } + + // Update OpenCart order with payment and shipping details + $payment_country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode2($request->billing_address->country); + $shipping_country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode2($request->shipping_address->country); + + //If region is passed, try to update OpenCart order with correct region/zone + $payment_zone_info = array(); + if ($payment_country_info && isset($request->billing_address->region)) { + $payment_zone_info = $this->model_extension_payment_klarna_checkout->getZoneByCode($request->billing_address->region, $payment_country_info['country_id']); + } + + $shipping_zone_info = array(); + if ($shipping_country_info && isset($request->shipping_address->region)) { + $shipping_zone_info = $this->model_extension_payment_klarna_checkout->getZoneByCode($request->shipping_address->region, $shipping_country_info['country_id']); + } + + $order_data = array( + 'firstname' => utf8_substr($request->billing_address->given_name, 0, 32), + 'lastname' => utf8_substr($request->billing_address->family_name, 0, 32), + 'telephone' => utf8_substr($request->billing_address->phone, 0, 32), + 'payment_firstname' => utf8_substr($request->billing_address->given_name, 0, 32), + 'payment_lastname' => utf8_substr($request->billing_address->family_name, 0, 32), + 'payment_address_1' => utf8_substr($request->billing_address->street_address, 0, 128), + 'payment_address_2' => (isset($request->billing_address->street_address2) ? utf8_substr($request->billing_address->street_address2, 0, 128) : ''), + 'payment_city' => utf8_substr($request->billing_address->city, 0, 128), + 'payment_postcode' => utf8_substr($request->billing_address->postal_code, 0, 10), + 'payment_zone' => ($payment_zone_info ? $payment_zone_info['name'] : ''), + 'payment_zone_id' => ($payment_zone_info ? $payment_zone_info['zone_id'] : ''), + 'payment_country' => ($payment_country_info ? $payment_country_info['name'] : ''), + 'payment_country_id' => ($payment_country_info ? $payment_country_info['country_id'] : ''), + 'payment_address_format' => ($payment_country_info ? $payment_country_info['address_format'] : ''), + 'shipping_firstname' => utf8_substr($request->shipping_address->given_name, 0, 32), + 'shipping_lastname' => utf8_substr($request->shipping_address->family_name, 0, 32), + 'shipping_address_1' => utf8_substr($request->shipping_address->street_address, 0, 128), + 'shipping_address_2' => (isset($request->shipping_address->street_address2) ? utf8_substr($request->shipping_address->street_address2, 0, 128) : ''), + 'shipping_city' => utf8_substr($request->shipping_address->city, 0, 128), + 'shipping_postcode' => utf8_substr($request->shipping_address->postal_code, 0, 10), + 'shipping_zone' => ($shipping_zone_info ? $shipping_zone_info['name'] : ''), + 'shipping_zone_id' => ($shipping_zone_info ? $shipping_zone_info['zone_id'] : ''), + 'shipping_country' => ($shipping_country_info ? $shipping_country_info['name'] : ''), + 'shipping_country_id' => ($shipping_country_info ? $shipping_country_info['country_id'] : ''), + 'shipping_address_format' => ($shipping_country_info ? $shipping_country_info['address_format'] : '') + ); + + $this->model_extension_payment_klarna_checkout->updateOcOrder($order_id, $order_data); + + $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id')); + + http_response_code(200); + } else { + http_response_code(303); + $this->response->addHeader('Location: ' . $this->url->link('checkout/failure', '', true)); + } + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($json)); + } + + public function confirmation() { + $this->load->language('extension/payment/klarna_checkout'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + if (isset($this->session->data['order_id'])) { + $this->cart->clear(); + + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + unset($this->session->data['payment_method']); + unset($this->session->data['payment_methods']); + unset($this->session->data['guest']); + unset($this->session->data['comment']); + unset($this->session->data['order_id']); + unset($this->session->data['coupon']); + unset($this->session->data['reward']); + unset($this->session->data['voucher']); + unset($this->session->data['vouchers']); + unset($this->session->data['totals']); + + unset($this->session->data['klarna_checkout_order_id']); + unset($this->session->data['klarna_checkout_data']); + } + + $this->document->setTitle($this->language->get('heading_title_success')); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/home') + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_basket'), + 'href' => $this->url->link('checkout/cart') + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_checkout'), + 'href' => $this->url->link('checkout/checkout', '', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_success'), + 'href' => $this->url->link('checkout/success') + ); + + $data['continue'] = $this->url->link('common/home'); + + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('checkout/order'); + + $klarna_checkout = false; + $html_snippet = ''; + + if (isset($this->request->get['klarna_order_id'])) { + $klarna_checkout_order = $this->model_extension_payment_klarna_checkout->getOrder($this->request->get['klarna_order_id']); + + if ($klarna_checkout_order) { + $order_info = $this->model_checkout_order->getOrder($klarna_checkout_order['order_id']); + + if ($order_info) { + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $order_info['currency_code']); + + if (!$klarna_account || !$connector) { + $this->model_extension_payment_klarna_checkout->log('Could not getConnector'); + $this->response->redirect($this->url->link('checkout/failure', '', true)); + } + + $retrieve = $this->model_extension_payment_klarna_checkout->orderRetrieve($connector, $this->request->get['klarna_order_id']); + + if ($retrieve) { + $klarna_checkout = $retrieve->fetch(); + + if ($klarna_checkout && $klarna_checkout['html_snippet']) { + $html_snippet = $klarna_checkout['html_snippet']; + } + } else { + $this->response->redirect($this->url->link('checkout/cart', '', true)); + } + } + } else { + $this->model_extension_payment_klarna_checkout->log('Could not find order id using ' . $this->request->get['klarna_order_id']); + $this->response->redirect($this->url->link('checkout/failure', '', true)); + } + } else { + $this->model_extension_payment_klarna_checkout->log('$this->request->get[\'klarna_order_id\'] is not set'); + $this->response->redirect($this->url->link('checkout/failure', '', true)); + } + + $data['klarna_checkout'] = $html_snippet; + + $this->response->setOutput($this->load->view('extension/payment/klarna_checkout_success', $data)); + } + + public function push() { + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('checkout/order'); + + if (!$this->config->get('klarna_checkout_status')) { + return false; + } + + if (isset($this->request->get['klarna_order_id'])) { + $klarna_checkout_order = $this->model_extension_payment_klarna_checkout->getOrder($this->request->get['klarna_order_id']); + + if ($klarna_checkout_order) { + $order_info = $this->model_checkout_order->getOrder($klarna_checkout_order['order_id']); + + if ($order_info) { + list($klarna_account, $connector) = $this->model_extension_payment_klarna_checkout->getConnector($this->config->get('klarna_checkout_account'), $order_info['currency_code']); + + if ($klarna_account && $connector) { + $order = $this->model_extension_payment_klarna_checkout->omOrderRetrieve($connector, $this->request->get['klarna_order_id']); + + $this->model_extension_payment_klarna_checkout->log('Order details from push:'); + $this->model_extension_payment_klarna_checkout->log($order); + + if ($order) { + if ($order->acknowledge()) { + // Update OpenCart order with payment and shipping details + $payment_country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode2($order['billing_address']['country']); + $shipping_country_info = $this->model_extension_payment_klarna_checkout->getCountryByIsoCode2($order['shipping_address']['country']); + + //If region is passed, try to update OpenCart order with correct region/zone + $payment_zone_info = array(); + if ($payment_country_info && isset($order['billing_address']['region'])) { + $payment_zone_info = $this->model_extension_payment_klarna_checkout->getZoneByCode($order['billing_address']['region'], $payment_country_info['country_id']); + } + + $shipping_zone_info = array(); + if ($shipping_country_info && isset($order['shipping_address']['region'])) { + $shipping_zone_info = $this->model_extension_payment_klarna_checkout->getZoneByCode($order['shipping_address']['region'], $shipping_country_info['country_id']); + } + + $order_data = array( + 'firstname' => utf8_substr($order['billing_address']['given_name'], 0, 32), + 'lastname' => utf8_substr($order['billing_address']['family_name'], 0, 32), + 'telephone' => utf8_substr($order['billing_address']['phone'], 0, 32), + 'payment_firstname' => utf8_substr($order['billing_address']['given_name'], 0, 32), + 'payment_lastname' => utf8_substr($order['billing_address']['family_name'], 0, 32), + 'payment_address_1' => utf8_substr($order['billing_address']['street_address'], 0, 128), + 'payment_address_2' => (isset($order['billing_address']['street_address2']) ? utf8_substr($order['billing_address']['street_address2'], 0, 128) : ''), + 'payment_city' => utf8_substr($order['billing_address']['city'], 0, 128), + 'payment_postcode' => utf8_substr($order['billing_address']['postal_code'], 0, 10), + 'payment_zone' => ($payment_zone_info ? $payment_zone_info['name'] : ''), + 'payment_zone_id' => ($payment_zone_info ? $payment_zone_info['zone_id'] : ''), + 'payment_country' => ($payment_country_info ? $payment_country_info['name'] : ''), + 'payment_country_id' => ($payment_country_info ? $payment_country_info['country_id'] : ''), + 'payment_address_format' => ($payment_country_info ? $payment_country_info['address_format'] : ''), + 'shipping_firstname' => utf8_substr($order['shipping_address']['given_name'], 0, 32), + 'shipping_lastname' => utf8_substr($order['shipping_address']['family_name'], 0, 32), + 'shipping_address_1' => utf8_substr($order['shipping_address']['street_address'], 0, 128), + 'shipping_address_2' => (isset($order['shipping_address']['street_address2']) ? utf8_substr($order['shipping_address']['street_address2'], 0, 128) : ''), + 'shipping_city' => utf8_substr($order['shipping_address']['city'], 0, 128), + 'shipping_postcode' => utf8_substr($order['shipping_address']['postal_code'], 0, 10), + 'shipping_zone' => ($shipping_zone_info ? $shipping_zone_info['name'] : ''), + 'shipping_zone_id' => ($shipping_zone_info ? $shipping_zone_info['zone_id'] : ''), + 'shipping_country' => ($shipping_country_info ? $shipping_country_info['name'] : ''), + 'shipping_country_id' => ($shipping_country_info ? $shipping_country_info['country_id'] : ''), + 'shipping_address_format' => ($shipping_country_info ? $shipping_country_info['address_format'] : '') + ); + + $this->model_extension_payment_klarna_checkout->updateOcOrder($klarna_checkout_order['order_id'], $order_data); + + $order_status_id = false; + switch ($order['status']) { + case 'AUTHORIZED': + $order_status_id = $this->config->get('klarna_checkout_order_status_authorised_id'); + + if ($order['fraud_status'] == 'PENDING') { + $order_status_id = $this->config->get('klarna_checkout_order_status_fraud_pending_id'); + } elseif ($order['fraud_status'] == 'REJECTED') { + $order_status_id = $this->config->get('klarna_checkout_order_status_fraud_rejected_id'); + } + break; + case 'PART_CAPTURED': + $order_status_id = $this->config->get('klarna_checkout_order_status_part_captured_id'); + break; + case 'CAPTURED': + $order_status_id = $this->config->get('klarna_checkout_order_status_captured_id'); + break; + case 'CANCELLED': + $order_status_id = $this->config->get('klarna_checkout_order_status_cancelled_id'); + break; + } + + if ($order_status_id) { + $this->model_checkout_order->addOrderHistory($klarna_checkout_order['order_id'], $order_status_id); + } + } + } else { + $this->model_extension_payment_klarna_checkout->log('Cannot retrieve KC order using order_id: ' . $this->request->get['klarna_order_id']); + } + } + } + } else { + $this->model_extension_payment_klarna_checkout->log('Cannot find KC order using order_id: ' . $this->request->get['klarna_order_id']); + } + } + } + + private function setPayment() { + $this->load->model('account/address'); + $this->load->model('localisation/country'); + $this->load->model('localisation/zone'); + + if (isset($this->session->data['payment_address']) && !empty($this->session->data['payment_address'])) { + $this->session->data['payment_address'] = $this->session->data['payment_address']; + } elseif ($this->customer->isLogged() && $this->customer->getAddressId()) { + $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); + } else { + $country_info = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); + + $zone_info = $this->model_localisation_zone->getZone($this->config->get('config_zone_id')); + + $this->session->data['payment_address'] = array( + 'address_id' => null, + 'firstname' => null, + 'lastname' => null, + 'company' => null, + 'address_1' => null, + 'address_2' => null, + 'postcode' => null, + 'city' => null, + 'zone_id' => $zone_info['zone_id'], + 'zone' => $zone_info['name'], + 'zone_code' => $zone_info['code'], + 'country_id' => $country_info['country_id'], + 'country' => $country_info['name'], + 'iso_code_2' => $country_info['iso_code_2'], + 'iso_code_3' => $country_info['iso_code_3'], + 'address_format' => '', + 'custom_field' => array() + ); + } + + $this->tax->setPaymentAddress($this->session->data['payment_address']['country_id'], $this->session->data['payment_address']['zone_id']); + $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); + } + + private function setShipping() { + $this->load->model('account/address'); + $this->load->model('localisation/country'); + $this->load->model('localisation/zone'); + + if (isset($this->session->data['shipping_address']) && !empty($this->session->data['shipping_address'])) { + $this->session->data['shipping_address'] = $this->session->data['shipping_address']; + } elseif ($this->customer->isLogged() && $this->customer->getAddressId()) { + $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); + } else { + $country_info = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); + + $zone_info = $this->model_localisation_zone->getZone($this->config->get('config_zone_id')); + + $this->session->data['shipping_address'] = array( + 'address_id' => null, + 'firstname' => null, + 'lastname' => null, + 'company' => null, + 'address_1' => null, + 'address_2' => null, + 'postcode' => null, + 'city' => null, + 'zone_id' => $zone_info['zone_id'], + 'zone' => $zone_info['name'], + 'zone_code' => $zone_info['code'], + 'country_id' => $country_info['country_id'], + 'country' => $country_info['name'], + 'iso_code_2' => $country_info['iso_code_2'], + 'iso_code_3' => $country_info['iso_code_3'], + 'address_format' => '', + 'custom_field' => array() + ); + } + + $this->tax->unsetRates(); + $this->tax->setShippingAddress($this->session->data['shipping_address']['country_id'], $this->session->data['shipping_address']['zone_id']); + $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); + + if (isset($this->session->data['shipping_address'])) { + // Shipping Methods + $method_data = array(); + + $this->load->model('setting/extension'); + + $results = $this->model_setting_extension->getExtensions('shipping'); + + foreach ($results as $result) { + if ($this->config->get('shipping_' . $result['code'] . '_status')) { + $this->load->model('extension/shipping/' . $result['code']); + + $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); + + if ($quote) { + $method_data[$result['code']] = array( + 'title' => $quote['title'], + 'quote' => $quote['quote'], + 'sort_order' => $quote['sort_order'], + 'error' => $quote['error'] + ); + } + } + } + + $sort_order = array(); + + foreach ($method_data as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $method_data); + + $this->session->data['shipping_methods'] = $method_data; + } + } + + private function createOrder() { + //Klarna defaults: + $this->session->data['comment'] = ''; + + if (!$this->customer->isLogged()) { + $this->session->data['guest'] = array( + 'customer_group_id' => $this->config->get('config_customer_group_id'), + 'firstname' => '', + 'lastname' => '', + 'email' => '', + 'telephone' => '', + 'fax' => '', + 'custom_field' => array(), + ); + } + + //OpenCart: + $order_data = array(); + + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + $order_data['totals'] = $totals; + + $this->load->language('checkout/checkout'); + + $order_data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); + $order_data['store_id'] = $this->config->get('config_store_id'); + $order_data['store_name'] = $this->config->get('config_name'); + + if ($order_data['store_id']) { + $order_data['store_url'] = $this->config->get('config_url'); + } else { + $order_data['store_url'] = HTTP_SERVER; + } + + if ($this->customer->isLogged()) { + $this->load->model('account/customer'); + + $customer_info = $this->model_account_customer->getCustomer($this->customer->getId()); + + $order_data['customer_id'] = $this->customer->getId(); + $order_data['customer_group_id'] = $customer_info['customer_group_id']; + $order_data['firstname'] = $customer_info['firstname']; + $order_data['lastname'] = $customer_info['lastname']; + $order_data['email'] = $customer_info['email']; + $order_data['telephone'] = $customer_info['telephone']; + $order_data['custom_field'] = json_decode($customer_info['custom_field'], true); + } elseif (isset($this->session->data['guest'])) { + $order_data['customer_id'] = 0; + $order_data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; + $order_data['firstname'] = $this->session->data['guest']['firstname']; + $order_data['lastname'] = $this->session->data['guest']['lastname']; + $order_data['email'] = $this->session->data['guest']['email']; + $order_data['telephone'] = $this->session->data['guest']['telephone']; + $order_data['custom_field'] = $this->session->data['guest']['custom_field']; + } + + $order_data['payment_firstname'] = $this->session->data['payment_address']['firstname']; + $order_data['payment_lastname'] = $this->session->data['payment_address']['lastname']; + $order_data['payment_company'] = $this->session->data['payment_address']['company']; + $order_data['payment_address_1'] = $this->session->data['payment_address']['address_1']; + $order_data['payment_address_2'] = $this->session->data['payment_address']['address_2']; + $order_data['payment_city'] = $this->session->data['payment_address']['city']; + $order_data['payment_postcode'] = $this->session->data['payment_address']['postcode']; + $order_data['payment_zone'] = $this->session->data['payment_address']['zone']; + $order_data['payment_zone_id'] = $this->session->data['payment_address']['zone_id']; + $order_data['payment_country'] = $this->session->data['payment_address']['country']; + $order_data['payment_country_id'] = $this->session->data['payment_address']['country_id']; + $order_data['payment_address_format'] = $this->session->data['payment_address']['address_format']; + $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']) ? $this->session->data['payment_address']['custom_field'] : array()); + + if (isset($this->session->data['payment_method']['title'])) { + $order_data['payment_method'] = $this->session->data['payment_method']['title']; + } else { + $order_data['payment_method'] = ''; + } + + if (isset($this->session->data['payment_method']['code'])) { + $order_data['payment_code'] = $this->session->data['payment_method']['code']; + } else { + $order_data['payment_code'] = ''; + } + + if ($this->cart->hasShipping()) { + $order_data['shipping_firstname'] = $this->session->data['shipping_address']['firstname']; + $order_data['shipping_lastname'] = $this->session->data['shipping_address']['lastname']; + $order_data['shipping_company'] = $this->session->data['shipping_address']['company']; + $order_data['shipping_address_1'] = $this->session->data['shipping_address']['address_1']; + $order_data['shipping_address_2'] = $this->session->data['shipping_address']['address_2']; + $order_data['shipping_city'] = $this->session->data['shipping_address']['city']; + $order_data['shipping_postcode'] = $this->session->data['shipping_address']['postcode']; + $order_data['shipping_zone'] = $this->session->data['shipping_address']['zone']; + $order_data['shipping_zone_id'] = $this->session->data['shipping_address']['zone_id']; + $order_data['shipping_country'] = $this->session->data['shipping_address']['country']; + $order_data['shipping_country_id'] = $this->session->data['shipping_address']['country_id']; + $order_data['shipping_address_format'] = $this->session->data['shipping_address']['address_format']; + $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']) ? $this->session->data['shipping_address']['custom_field'] : array()); + + if (isset($this->session->data['shipping_method']['title'])) { + $order_data['shipping_method'] = $this->session->data['shipping_method']['title']; + } else { + $order_data['shipping_method'] = ''; + } + + if (isset($this->session->data['shipping_method']['code'])) { + $order_data['shipping_code'] = $this->session->data['shipping_method']['code']; + } else { + $order_data['shipping_code'] = ''; + } + } else { + $order_data['shipping_firstname'] = ''; + $order_data['shipping_lastname'] = ''; + $order_data['shipping_company'] = ''; + $order_data['shipping_address_1'] = ''; + $order_data['shipping_address_2'] = ''; + $order_data['shipping_city'] = ''; + $order_data['shipping_postcode'] = ''; + $order_data['shipping_zone'] = ''; + $order_data['shipping_zone_id'] = ''; + $order_data['shipping_country'] = ''; + $order_data['shipping_country_id'] = ''; + $order_data['shipping_address_format'] = ''; + $order_data['shipping_custom_field'] = array(); + $order_data['shipping_method'] = ''; + $order_data['shipping_code'] = ''; + } + + $order_data['products'] = array(); + + foreach ($this->cart->getProducts() as $product) { + $option_data = array(); + + foreach ($product['option'] as $option) { + $option_data[] = array( + 'product_option_id' => $option['product_option_id'], + 'product_option_value_id' => $option['product_option_value_id'], + 'option_id' => $option['option_id'], + 'option_value_id' => $option['option_value_id'], + 'name' => $option['name'], + 'value' => $option['value'], + 'type' => $option['type'] + ); + } + + $order_data['products'][] = array( + 'product_id' => $product['product_id'], + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'download' => $product['download'], + 'quantity' => $product['quantity'], + 'subtract' => $product['subtract'], + 'price' => $product['price'], + 'total' => $product['total'], + 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), + 'reward' => $product['reward'] + ); + } + + // Gift Voucher + $order_data['vouchers'] = array(); + + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $voucher) { + $order_data['vouchers'][] = array( + 'description' => $voucher['description'], + 'code' => token(10), + 'to_name' => $voucher['to_name'], + 'to_email' => $voucher['to_email'], + 'from_name' => $voucher['from_name'], + 'from_email' => $voucher['from_email'], + 'voucher_theme_id' => $voucher['voucher_theme_id'], + 'message' => $voucher['message'], + 'amount' => $voucher['amount'] + ); + } + } + + $order_data['comment'] = $this->session->data['comment']; + $order_data['total'] = $total; + + if (isset($this->request->cookie['tracking'])) { + $order_data['tracking'] = $this->request->cookie['tracking']; + + $subtotal = $this->cart->getSubTotal(); + + // Affiliate + $this->load->model('affiliate/affiliate'); + + $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']); + + if ($affiliate_info) { + $order_data['affiliate_id'] = $affiliate_info['affiliate_id']; + $order_data['commission'] = ($subtotal / 100) * $affiliate_info['commission']; + } else { + $order_data['affiliate_id'] = 0; + $order_data['commission'] = 0; + } + + // Marketing + $this->load->model('checkout/marketing'); + + $marketing_info = $this->model_checkout_marketing->getMarketingByCode($this->request->cookie['tracking']); + + if ($marketing_info) { + $order_data['marketing_id'] = $marketing_info['marketing_id']; + } else { + $order_data['marketing_id'] = 0; + } + } else { + $order_data['affiliate_id'] = 0; + $order_data['commission'] = 0; + $order_data['marketing_id'] = 0; + $order_data['tracking'] = ''; + } + + $order_data['language_id'] = $this->config->get('config_language_id'); + $order_data['currency_id'] = $this->currency->getId($this->session->data['currency']); + $order_data['currency_code'] = $this->session->data['currency']; + $order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']); + $order_data['ip'] = $this->request->server['REMOTE_ADDR']; + + if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) { + $order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR']; + } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) { + $order_data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP']; + } else { + $order_data['forwarded_ip'] = ''; + } + + if (isset($this->request->server['HTTP_USER_AGENT'])) { + $order_data['user_agent'] = $this->request->server['HTTP_USER_AGENT']; + } else { + $order_data['user_agent'] = ''; + } + + if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { + $order_data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE']; + } else { + $order_data['accept_language'] = ''; + } + + $this->load->model('checkout/order'); + + $this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data); + } + + private function klarnaOrderData($klarna_account) { + $this->load->language('extension/payment/klarna_checkout'); + + $this->load->model('extension/payment/klarna_checkout'); + $this->load->model('localisation/country'); + + $currency_code = $this->session->data['currency']; + $currency_value = $this->currency->getValue($this->session->data['currency']); + + // Shipping + $unset_shipping_method = true; + if (isset($this->session->data['shipping_method']) && isset($this->session->data['shipping_methods'])) { + foreach ($this->session->data['shipping_methods'] as $shipping_method) { + if ($shipping_method['quote']) { + foreach ($shipping_method['quote'] as $quote) { + if ($quote == $this->session->data['shipping_method']) { + $unset_shipping_method = false; + break 2; + } + } + } + } + } + + if ($unset_shipping_method) { + unset($this->session->data['shipping_method']); + } + + if ((!isset($this->session->data['shipping_method']) || empty($this->session->data['shipping_method'])) && (isset($this->session->data['shipping_methods']) && !empty($this->session->data['shipping_methods']))) { + $this->session->data['shipping_method'] = $this->model_extension_payment_klarna_checkout->getDefaultShippingMethod($this->session->data['shipping_methods']); + } + + //Check if customer is US. If so, send taxes differently + if ($this->session->data['shipping_address']['iso_code_2'] === 'US') { + $include_taxes = false; + } else { + $include_taxes = true; + } + + if ($this->cart->hasShipping() && isset($this->session->data['shipping_method']) && !empty($this->session->data['shipping_method'])) { + $total_amount = $this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $include_taxes), $currency_code, $currency_value, false) * 100; + + if ($include_taxes) { + $total_tax_amount = $this->currency->format($this->tax->getTax($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']), $currency_code, $currency_value, false) * 100; + } else { + $total_tax_amount = 0; + } + + $total_sub_amount = $this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], false), $currency_code, $currency_value, false) * 100; + + $tax_rate = 0; + + if ($include_taxes && $total_tax_amount && $total_sub_amount) { + $tax_rate = ($total_tax_amount / $total_sub_amount) * 100; + } + + $klarna_order_data['order_lines'][] = array( + 'type' => 'shipping_fee', + 'name' => $this->session->data['shipping_method']['title'], + 'quantity' => '1', + 'unit_price' => round($this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $include_taxes), $currency_code, $currency_value, false) * 100), + 'tax_rate' => round($tax_rate * 100), + 'total_amount' => round($total_amount), + 'total_tax_amount' => round($total_tax_amount), + 'total_discount_amount' => 0 + ); + } + + // Billing Address + if (isset($this->session->data['klarna_checkout_data'])) { + $klarna_order_data['billing_address'] = array( + 'given_name' => $this->session->data['klarna_checkout_data']['firstname'], + 'family_name' => $this->session->data['klarna_checkout_data']['lastname'], + 'email' => $this->session->data['klarna_checkout_data']['email'], + 'phone' => $this->session->data['klarna_checkout_data']['telephone'], + 'postal_code' => $this->session->data['shipping_address']['postcode'], + 'region' => $this->session->data['shipping_address']['zone_code'], + 'country' => $this->session->data['shipping_address']['iso_code_2'], + ); + } else { + $klarna_order_data['billing_address'] = array( + 'given_name' => $this->session->data['shipping_address']['firstname'], + 'family_name' => $this->session->data['shipping_address']['lastname'], + 'email' => ($this->customer->isLogged() ? $this->customer->getEmail() : null), + 'phone' => ($this->customer->isLogged() ? $this->customer->getTelephone() : null) + ); + } + + // Order Total + list($totals, $taxes, $total) = $this->model_extension_payment_klarna_checkout->getTotals(); + + $merchant_urls = array( + 'checkout' => html_entity_decode($this->url->link('extension/payment/klarna_checkout', 'klarna_order_id={checkout.order.id}', true)), + 'confirmation' => html_entity_decode($this->url->link('extension/payment/klarna_checkout/confirmation', 'klarna_order_id={checkout.order.id}', true)), + 'push' => html_entity_decode($this->url->link('extension/payment/klarna_checkout/push', 'klarna_order_id={checkout.order.id}', true)), + 'validation' => html_entity_decode($this->url->link('extension/payment/klarna_checkout/validation', 'klarna_order_id={checkout.order.id}', true)), + 'address_update' => html_entity_decode($this->url->link('extension/payment/klarna_checkout/addressUpdate', 'klarna_order_id={checkout.order.id}', true)), + 'notification' => html_entity_decode($this->url->link('extension/payment/klarna_checkout/notification', 'klarna_order_id={checkout.order.id}', true)), + ); + + if ($this->config->get('klarna_checkout_terms')) { + $merchant_urls['terms'] = html_entity_decode($this->url->link('information/information', 'information_id=' . $this->config->get('klarna_checkout_terms'), true)); + } + + $country_info = $this->model_localisation_country->getCountry($klarna_account['country']); + + if ($country_info) { + $klarna_order_data['purchase_country'] = $country_info['iso_code_2']; + } + + $klarna_order_data['purchase_currency'] = $currency_code; + $klarna_order_data['locale'] = $klarna_account['locale']; + + $klarna_order_data['order_amount'] = round($this->currency->format($total, $currency_code, $currency_value, false) * 100); + $klarna_order_data['order_tax_amount'] = round($this->currency->format(array_sum($taxes), $currency_code, $currency_value, false) * 100); + + $klarna_order_data['merchant_urls'] = $merchant_urls; + + // Callback data to be used to spoof/simulate customer to accurately calculate shipping + $encrypted_order_data = $this->encryption->encrypt($this->config->get('config_encryption'), json_encode(array( + 'session_id' => session_id(), + 'session_key' => $this->session->getId(), + 'customer_id' => $this->customer->getId(), + 'order_id' => $this->session->data['order_id'], + 'merchant_id' => $klarna_account['merchant_id'], + 'secret' => $klarna_account['secret'] + ))); + + $encrypted_order_id = $this->encryption->encrypt($this->config->get('config_encryption'), $this->session->data['order_id']); + + $klarna_order_data['merchant_reference1'] = $this->session->data['order_id']; + + $klarna_order_data['options'] = array(); + + if ($this->config->get('klarna_checkout_colour_button')) { + $klarna_order_data['options']['color_button'] = $this->config->get('klarna_checkout_colour_button'); + } + + if ($this->config->get('klarna_checkout_colour_button_text')) { + $klarna_order_data['options']['color_button_text'] = $this->config->get('klarna_checkout_colour_button_text'); + } + + if ($this->config->get('klarna_checkout_colour_checkbox')) { + $klarna_order_data['options']['color_checkbox'] = $this->config->get('klarna_checkout_colour_checkbox'); + } + + if ($this->config->get('klarna_checkout_colour_checkbox_checkmark')) { + $klarna_order_data['options']['color_checkbox_checkmark'] = $this->config->get('klarna_checkout_colour_checkbox_checkmark'); + } + + if ($this->config->get('klarna_checkout_colour_header')) { + $klarna_order_data['options']['color_header'] = $this->config->get('klarna_checkout_colour_header'); + } + + if ($this->config->get('klarna_checkout_colour_link')) { + $klarna_order_data['options']['color_link'] = $this->config->get('klarna_checkout_colour_link'); + } + + if ($this->config->get('klarna_checkout_separate_shipping_address')) { + $klarna_order_data['options']['allow_separate_shipping_address'] = true; + } + + // Only pass DOB/title mandatory for UK stores + if ($country_info['iso_code_2'] == 'GB') { + if ($this->config->get('klarna_checkout_dob_mandatory')) { + $klarna_order_data['options']['date_of_birth_mandatory'] = true; + } + + if ($this->config->get('klarna_checkout_title_mandatory')) { + $klarna_order_data['options']['title_mandatory'] = true; + } + } + + if ($this->config->get('klarna_checkout_additional_text_box') && $this->customer->isLogged() && !$this->customer->getNewsletter()) { + $klarna_order_data['options']['additional_checkbox'] = array( + 'text' => $this->language->get('text_newsletter'), + 'checked' => false, + 'required' => false + ); + } + + $shipping_countries = $this->model_extension_payment_klarna_checkout->getCountriesByGeoZone($klarna_account['shipping']); + + $klarna_shipping_countries = array(); + foreach ($shipping_countries as $shipping_country) { + $country_info = $this->model_localisation_country->getCountry($shipping_country['country_id']); + + if ($country_info && $country_info['iso_code_2']) { + $klarna_shipping_countries[] = $country_info['iso_code_2']; + } + } + + $klarna_order_data['shipping_countries'] = $klarna_shipping_countries; + + $average_product_tax_rate = array(); + + // Products (Add these last because we send encrypted session order_id) + foreach ($this->cart->getProducts() as $product) { + $total_amount = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $include_taxes) * $product['quantity'], $currency_code, $currency_value, false) * 100; + + if ($include_taxes) { + $total_tax_amount = $this->currency->format($this->tax->getTax($product['price'], $product['tax_class_id']) * $product['quantity'], $currency_code, $currency_value, false) * 100; + } else { + $total_tax_amount = 0; + } + + $total_sub_amount = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], false) * $product['quantity'], $currency_code, $currency_value, false) * 100; + + $tax_rate = 0; + + if ($include_taxes && $total_tax_amount && $total_sub_amount) { + $tax_rate = ($total_tax_amount / $total_sub_amount) * 100; + } + + $average_product_tax_rate[] = round($tax_rate * 100); + + $klarna_order_data['order_lines'][] = array( + 'type' => ($product['shipping'] ? 'physical' : 'digital'), + 'reference' => $product['model'], + 'name' => $product['name'], + 'quantity' => $product['quantity'], + 'quantity_unit' => 'pcs', + 'unit_price' => round($this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $include_taxes), $currency_code, $currency_value, false) * 100), + 'tax_rate' => round($tax_rate * 100), + 'total_amount' => round($total_amount), + 'total_tax_amount' => round($total_tax_amount), + 'merchant_data' => $encrypted_order_id, + 'total_discount_amount' => 0 + ); + } + + // Gift Voucher + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $key => $voucher) { + $klarna_order_data['order_lines'][] = array( + 'type' => 'gift_card', + 'reference' => '', + 'name' => $voucher['description'], + 'quantity' => 1, + 'quantity_unit' => 'pcs', + 'unit_price' => round($this->currency->format($voucher['amount'], $currency_code, $currency_value, false) * 100), + 'tax_rate' => 0, + 'total_amount' => round($this->currency->format($voucher['amount'], $currency_code, $currency_value, false) * 100), + 'total_tax_amount' => 0, + 'merchant_data' => $encrypted_order_id, + 'total_discount_amount' => 0 + ); + } + } + + foreach ($totals as $result) { + if ($result['code'] == 'coupon') { + $discount_total_price = 0; + $discount_sub_total_price = 0; + foreach ($this->cart->getProducts() as $product) { + $discount_total_price += $this->tax->calculate($result['value'], $product['tax_class_id'], $include_taxes); + $discount_sub_total_price += $result['value']; + } + + $average_discount_total_price = $discount_total_price / count($average_product_tax_rate); + + $average_discount_sub_total_price = $discount_sub_total_price / count($average_product_tax_rate); + + $total_tax_amount = ($average_discount_sub_total_price / 100) * (array_sum($average_product_tax_rate) / count($average_product_tax_rate)); + + $klarna_order_data['order_lines'][] = array( + 'type' => 'discount', + 'name' => $result['title'], + 'quantity' => '1', + 'unit_price' => round($this->currency->format($average_discount_total_price, $currency_code, $currency_value, false) * 100), + 'tax_rate' => array_sum($average_product_tax_rate) / count($average_product_tax_rate), + 'total_amount' => round($this->currency->format($average_discount_total_price, $currency_code, $currency_value, false) * 100), + 'total_tax_amount' => round($total_tax_amount), + 'total_discount_amount' => 0 + ); + } + + if ($result['code'] == 'voucher') { + $klarna_order_data['order_lines'][] = array( + 'type' => 'discount', + 'name' => $result['title'], + 'quantity' => '1', + 'unit_price' => round($this->currency->format($result['value'], $currency_code, $currency_value, false) * 100), + 'tax_rate' => 0, + 'total_amount' => round($this->currency->format($result['value'], $currency_code, $currency_value, false) * 100), + 'total_tax_amount' => 0, + 'total_discount_amount' => 0 + ); + } + } + + //If $include_taxes is false, means customer is US so we add a new sales_tax order line with all the tax + if (!$include_taxes) { + $klarna_order_data['order_lines'][] = array( + 'type' => 'sales_tax', + 'name' => $this->language->get('text_sales_tax'), + 'quantity' => '1', + 'unit_price' => round($this->currency->format(array_sum($taxes), $currency_code, $currency_value, false) * 100), + 'tax_rate' => 0, + 'total_amount' => round($this->currency->format(array_sum($taxes), $currency_code, $currency_value, false) * 100), + 'total_tax_amount' => 0, + 'total_discount_amount' => 0 + ); + } + + return array($klarna_order_data, $encrypted_order_data); + } +} diff --git a/upload/catalog/controller/extension/payment/paypal.php b/upload/catalog/controller/extension/payment/paypal.php index 0abdbc60fc5..44a32e60a04 100644 --- a/upload/catalog/controller/extension/payment/paypal.php +++ b/upload/catalog/controller/extension/payment/paypal.php @@ -11,15 +11,96 @@ public function __construct($registry) { } } - public function index() { - $this->load->language('extension/payment/paypal'); - + public function index() { $this->load->model('extension/payment/paypal'); - $this->load->model('localisation/country'); - $this->load->model('checkout/order'); + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && !$this->webhook() && $agree_status) { + $this->load->language('extension/payment/paypal'); + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; + $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; + $data['checkout_mode'] = $setting['general']['checkout_mode']; + $data['transaction_method'] = $setting['general']['transaction_method']; + + if ($setting['button']['checkout']['status']) { + $data['button_status'] = $setting['button']['checkout']['status']; + } + + if ($setting['applepay_button']['status']) { + $data['applepay_button_status'] = $setting['applepay_button']['status']; + } + + if ($setting['card']['status']) { + $data['card_status'] = $setting['card']['status']; + } + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $data['partner_id'], + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } - $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + return $this->load->view('extension/payment/paypal/paypal', $data); + } + } + + public function modal() { + $this->load->language('extension/payment/paypal'); + // Setting $_config = new Config(); $_config->load('paypal'); @@ -33,60 +114,29 @@ public function index() { $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); $data['environment'] = $this->config->get('payment_paypal_environment'); $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; - $data['transaction_method'] = $this->config->get('payment_paypal_transaction_method'); - $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - $data['currency_code'] = $this->config->get('payment_paypal_currency_code'); - $data['currency_value'] = $this->config->get('payment_paypal_currency_value'); - $data['decimal_place'] = $setting['currency'][$data['currency_code']]['decimal_place']; - - $data['express_status'] = $setting['checkout']['express']['status']; - - if (!$setting['currency'][$data['currency_code']]['express_status']) { - $data['express_status'] = $setting['currency'][$data['currency_code']]['express_status']; + $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; + $data['transaction_method'] = $setting['general']['transaction_method']; + + if ($setting['button']['checkout']['status']) { + $data['button_status'] = $setting['button']['checkout']['status']; } - $data['button_align'] = $setting['checkout']['express']['button_align']; - $data['button_size'] = $setting['checkout']['express']['button_size']; - $data['button_color'] = $setting['checkout']['express']['button_color']; - $data['button_shape'] = $setting['checkout']['express']['button_shape']; - $data['button_label'] = $setting['checkout']['express']['button_label']; - $data['button_width'] = $setting['button_width'][$data['button_size']]; - - $data['card_status'] = $setting['checkout']['card']['status']; - - if (!$setting['currency'][$data['currency_code']]['card_status']) { - $data['card_status'] = $setting['currency'][$data['currency_code']]['card_status']; + if ($setting['applepay_button']['status']) { + $data['applepay_button_status'] = $setting['applepay_button']['status']; } - - $data['form_align'] = $setting['checkout']['card']['form_align']; - $data['form_size'] = $setting['checkout']['card']['form_size']; - $data['form_width'] = $setting['form_width'][$data['form_size']]; - $data['secure_status'] = $setting['checkout']['card']['secure_status']; - - $data['message_status'] = $setting['checkout']['message']['status']; - $data['message_align'] = $setting['checkout']['message']['message_align']; - $data['message_size'] = $setting['checkout']['message']['message_size']; - $data['message_width'] = $setting['message_width'][$data['message_size']]; - $data['message_layout'] = $setting['checkout']['message']['message_layout']; - $data['message_text_color'] = $setting['checkout']['message']['message_text_color']; - $data['message_text_size'] = $setting['checkout']['message']['message_text_size']; - $data['message_flex_color'] = $setting['checkout']['message']['message_flex_color']; - $data['message_flex_ratio'] = $setting['checkout']['message']['message_flex_ratio']; - $data['message_placement'] = 'payment'; - $data['order_id'] = $this->session->data['order_id']; - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $data['message_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); - + if ($setting['card']['status']) { + $data['card_status'] = $setting['card']['status']; + } + require_once DIR_SYSTEM .'library/paypal/paypal.php'; $paypal_info = array( 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], - 'environment' => $data['environment'] + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['partner_attribution_id'] ); $paypal = new PayPal($paypal_info); @@ -111,7 +161,7 @@ public function index() { if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; - } else { + } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } @@ -119,352 +169,2344 @@ public function index() { } $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } + + $data['error'] = $this->error; - return $this->load->view('extension/payment/paypal', $data); + $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_modal', $data)); } - - public function createOrder() { - $this->load->language('extension/payment/paypal'); - + + public function getData() { $this->load->model('extension/payment/paypal'); - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - // Setting - $_config = new Config(); - $_config->load('paypal'); - - $config_setting = $_config->get('paypal_setting'); - $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); - - $client_id = $this->config->get('payment_paypal_client_id'); - $secret = $this->config->get('payment_paypal_secret'); - $merchant_id = $this->config->get('payment_paypal_merchant_id'); - $environment = $this->config->get('payment_paypal_environment'); - $partner_id = $setting['partner'][$environment]['partner_id']; - $transaction_method = $this->config->get('payment_paypal_transaction_method'); - $currency_code = $this->config->get('payment_paypal_currency_code'); - $currency_value = $this->config->get('payment_paypal_currency_value'); - $decimal_place = $setting['currency'][$currency_code]['decimal_place']; + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && $agree_status && !empty($this->request->post['page_code'])) { + $this->load->language('extension/payment/paypal'); - $paypal_info = array( - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment - ); + $this->load->model('localisation/country'); + $this->load->model('checkout/order'); - $paypal = new PayPal($paypal_info); + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); - $token_info = array( - 'grant_type' => 'client_credentials' - ); + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $data['page_code'] = $this->request->post['page_code']; + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; + $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; + $data['transaction_method'] = $setting['general']['transaction_method']; + + $country = $this->model_extension_payment_paypal->getCountryByCode($setting['general']['country_code']); + + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; + + $data['currency_code'] = $this->session->data['currency']; + $data['currency_value'] = $this->currency->getValue($this->session->data['currency']); - $paypal->setAccessToken($token_info); + if (empty($setting['currency'][$data['currency_code']]['status'])) { + $data['currency_code'] = $setting['general']['currency_code']; + $data['currency_value'] = $setting['general']['currency_value']; + } - $shipping_info = array(); - - if ($this->cart->hasShipping()) { - $shipping_info['name']['full_name'] = $order_info['shipping_firstname']; - $shipping_info['name']['full_name'] .= $order_info['shipping_lastname']; - $shipping_info['address']['address_line_1'] = $order_info['shipping_address_1']; - $shipping_info['address']['address_line_2'] = $order_info['shipping_address_2']; - $shipping_info['address']['admin_area_1'] = $order_info['shipping_zone']; - $shipping_info['address']['admin_area_2'] = $order_info['shipping_city']; - $shipping_info['address']['postal_code'] = $order_info['shipping_postcode']; + $data['decimal_place'] = $setting['currency'][$data['currency_code']]['decimal_place']; - if ($order_info['shipping_country_id']) { - $this->load->model('localisation/country'); - - $country_info = $this->model_localisation_country->getCountry($order_info['shipping_country_id']); + $data['components'] = array(); + + if ($this->request->post['page_code'] == 'home') { + if ($setting['message']['home']['status'] && ($data['currency_code'] == $setting['general']['currency_code'])) { + $data['components'][] = 'messages'; + $data['message_status'] = $setting['message']['home']['status']; + $data['message_insert_tag'] = html_entity_decode($setting['message']['home']['insert_tag']); + $data['message_insert_type'] = $setting['message']['home']['insert_type']; + $data['message_align'] = $setting['message']['home']['align']; + $data['message_size'] = $setting['message']['home']['size']; + $data['message_width'] = $setting['message_width'][$data['message_size']]; + $data['message_layout'] = $setting['message']['home']['layout']; + $data['message_text_color'] = $setting['message']['home']['text_color']; + $data['message_text_size'] = $setting['message']['home']['text_size']; + $data['message_flex_color'] = $setting['message']['home']['flex_color']; + $data['message_flex_ratio'] = $setting['message']['home']['flex_ratio']; + + $item_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); + + $item_total += $product_price * $product['quantity']; + } - if ($country_info) { - $shipping_info['address']['country_code'] = $country_info['iso_code_2']; + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - $shipping_preference = 'SET_PROVIDED_ADDRESS'; - } else { - $shipping_preference = 'NO_SHIPPING'; - } - - $item_info = array(); - - $item_total = 0; + if (($this->request->post['page_code'] == 'product') && !empty($this->request->post['product_id'])) { + if ($setting['button']['product']['status']) { + $data['components'][] = 'buttons'; + $data['button_status'] = $setting['button']['product']['status']; + $data['button_insert_tag'] = html_entity_decode($setting['button']['product']['insert_tag']); + $data['button_insert_type'] = $setting['button']['product']['insert_type']; + $data['button_align'] = $setting['button']['product']['align']; + $data['button_size'] = $setting['button']['product']['size']; + $data['button_width'] = $setting['button_width'][$data['button_size']]; + $data['button_color'] = $setting['button']['product']['color']; + $data['button_shape'] = $setting['button']['product']['shape']; + $data['button_label'] = $setting['button']['product']['label']; + $data['button_tagline'] = $setting['button']['product']['tagline']; + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); - foreach ($this->cart->getProducts() as $product) { - $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); - - $item_info[] = array( - 'name' => $product['name'], - 'sku' => $product['model'], - 'url' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true), - 'quantity' => $product['quantity'], - 'unit_amount' => array( - 'currency_code' => $currency_code, - 'value' => $product_price - ) - ); - - $item_total += $product_price * $product['quantity']; - } + foreach ($setting['button_funding'] as $button_funding) { + if ($setting['button']['product']['funding'][$button_funding['code']] == 1) { + $data['button_enable_funding'][] = $button_funding['code']; + } - $item_total = number_format($item_total, $decimal_place, '.', ''); - $sub_total = $this->cart->getSubTotal(); - $total = $this->cart->getTotal(); - $tax_total = number_format(($total - $sub_total) * $currency_value, $decimal_place, '.', ''); - - $discount_total = 0; - $handling_total = 0; - $shipping_total = 0; - - if (isset($this->session->data['shipping_method'])) { - $shipping_total = $this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $this->config->get('config_tax')); - $shipping_total = number_format($shipping_total * $currency_value, $decimal_place, '.', ''); - } - - $order_total = number_format($order_info['total'] * $currency_value, $decimal_place, '.', ''); - - $rebate = number_format($item_total + $tax_total + $shipping_total - $order_total, $decimal_place, '.', ''); + if ($setting['button']['product']['funding'][$button_funding['code']] == 2) { + $data['button_disable_funding'][] = $button_funding['code']; + } + } + } + + if ($setting['message']['product']['status'] && ($data['currency_code'] == $setting['general']['currency_code'])) { + $data['components'][] = 'messages'; + $data['message_status'] = $setting['message']['product']['status']; + $data['message_insert_tag'] = html_entity_decode($setting['message']['product']['insert_tag']); + $data['message_insert_type'] = $setting['message']['product']['insert_type']; + $data['message_align'] = $setting['message']['product']['align']; + $data['message_size'] = $setting['message']['product']['size']; + $data['message_width'] = $setting['message_width'][$data['message_size']]; + $data['message_layout'] = $setting['message']['product']['layout']; + $data['message_text_color'] = $setting['message']['product']['text_color']; + $data['message_text_size'] = $setting['message']['product']['text_size']; + $data['message_flex_color'] = $setting['message']['product']['flex_color']; + $data['message_flex_ratio'] = $setting['message']['product']['flex_ratio']; + + $product_id = (int)$this->request->post['product_id']; - if ($rebate > 0) { - $discount_total = $rebate; - } elseif ($rebate < 0) { - $handling_total = -$rebate; - } + $this->load->model('catalog/product'); - $amount_info = array( - 'currency_code' => $currency_code, - 'value' => $order_total, - 'breakdown' => array( - 'item_total' => array( - 'currency_code' => $currency_code, - 'value' => $item_total - ), - 'tax_total' => array( - 'currency_code' => $currency_code, - 'value' => $tax_total - ), - 'shipping' => array( - 'currency_code' => $currency_code, - 'value' => $shipping_total - ), - 'handling' => array( - 'currency_code' => $currency_code, - 'value' => $handling_total - ), - 'discount' => array( - 'currency_code' => $currency_code, - 'value' => $discount_total - ) - ) - ); - - if ($this->cart->hasShipping()) { - $order_info = array( - 'intent' => strtoupper($transaction_method), - 'purchase_units' => array( - array( - 'reference_id' => 'default', - 'description' => 'Your order ' . $order_info['order_id'], - 'invoice_id' => $order_info['order_id'], - 'shipping' => $shipping_info, - 'items' => $item_info, - 'amount' => $amount_info - ) - ), - 'application_context' => array( - 'shipping_preference' => $shipping_preference - ) - ); - } else { - $order_info = array( - 'intent' => strtoupper($transaction_method), - 'purchase_units' => array( - array( - 'reference_id' => 'default', - 'description' => 'Your order ' . $order_info['order_id'], - 'invoice_id' => $order_info['order_id'], - 'items' => $item_info, - 'amount' => $amount_info - ) - ), - 'application_context' => array( - 'shipping_preference' => $shipping_preference - ) - ); - } + $product_info = $this->model_catalog_product->getProduct($product_id); - $result = $paypal->createOrder($order_info); + if ($product_info) { + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + if ((float)$product_info['special']) { + $product_price = $this->tax->calculate($product_info['special'], $product_info['tax_class_id'], true); + } else { + $product_price = $this->tax->calculate($product_info['price'], $product_info['tax_class_id'], true); + } + + $data['message_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); + } + } + } + } - $data['order_id'] = ''; - - if (isset($result['id'])) { - $data['order_id'] = $result['id']; - } - - if ($paypal->hasErrors()) { - $error_messages = array(); + if (($this->request->post['page_code'] == 'cart') && $this->cart->getTotal()) { + if ($setting['button']['cart']['status']) { + $data['components'][] = 'buttons'; + $data['button_status'] = $setting['button']['cart']['status']; + $data['button_insert_tag'] = html_entity_decode($setting['button']['cart']['insert_tag']); + $data['button_insert_type'] = $setting['button']['cart']['insert_type']; + $data['button_align'] = $setting['button']['cart']['align']; + $data['button_size'] = $setting['button']['cart']['size']; + $data['button_width'] = $setting['button_width'][$data['button_size']]; + $data['button_color'] = $setting['button']['cart']['color']; + $data['button_shape'] = $setting['button']['cart']['shape']; + $data['button_label'] = $setting['button']['cart']['label']; + $data['button_tagline'] = $setting['button']['cart']['tagline']; + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); - $errors = $paypal->getErrors(); - - foreach ($errors as $error) { - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { - $error['message'] = $this->language->get('error_timeout'); - } + foreach ($setting['button_funding'] as $button_funding) { + if ($setting['button']['cart']['funding'][$button_funding['code']] == 1) { + $data['button_enable_funding'][] = $button_funding['code']; + } - if (isset($error['details'][0]['description'])) { - $error_messages[] = $error['details'][0]['description']; - } else { - $error_messages[] = $error['message']; + if ($setting['button']['cart']['funding'][$button_funding['code']] == 2) { + $data['button_disable_funding'][] = $button_funding['code']; + } + } + } + + if ($setting['message']['cart']['status'] && ($data['currency_code'] == $setting['general']['currency_code'])) { + $data['components'][] = 'messages'; + $data['message_status'] = $setting['message']['cart']['status']; + $data['message_insert_tag'] = html_entity_decode($setting['message']['cart']['insert_tag']); + $data['message_insert_type'] = $setting['message']['cart']['insert_type']; + $data['message_align'] = $setting['message']['cart']['align']; + $data['message_size'] = $setting['message']['cart']['size']; + $data['message_width'] = $setting['message_width'][$data['message_size']]; + $data['message_layout'] = $setting['message']['cart']['layout']; + $data['message_text_color'] = $setting['message']['cart']['text_color']; + $data['message_text_size'] = $setting['message']['cart']['text_size']; + $data['message_flex_color'] = $setting['message']['cart']['flex_color']; + $data['message_flex_ratio'] = $setting['message']['cart']['flex_ratio']; + + $item_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); + + $item_total += $product_price * $product['quantity']; + } + + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } - - $this->model_extension_payment_paypal->log($error, $error['message']); } + + if (($this->request->post['page_code'] == 'checkout') && $this->cart->getTotal()) { + if ($setting['button']['checkout']['status']) { + $data['components'][] = 'buttons'; + $data['components'][] = 'funding-eligibility'; + $data['button_status'] = $setting['button']['checkout']['status']; + $data['button_align'] = $setting['button']['checkout']['align']; + $data['button_size'] = $setting['button']['checkout']['size']; + $data['button_width'] = $setting['button_width'][$data['button_size']]; + $data['button_color'] = $setting['button']['checkout']['color']; + $data['button_shape'] = $setting['button']['checkout']['shape']; + $data['button_label'] = $setting['button']['checkout']['label']; + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); - $this->error['warning'] = implode(' ', $error_messages); - } + foreach ($setting['button_funding'] as $button_funding) { + if ($setting['button']['checkout']['funding'][$button_funding['code']] == 1) { + $data['button_enable_funding'][] = $button_funding['code']; + } - $data['error'] = $this->error; + if ($setting['button']['checkout']['funding'][$button_funding['code']] == 2) { + $data['button_disable_funding'][] = $button_funding['code']; + } + } + + if (isset($this->session->data['payment_method']['code']) && ($this->session->data['payment_method']['code'] == 'paypal_paylater')) { + $data['button_funding_source'] = 'paylater'; + } + } - $this->response->setOutput(json_encode($data)); - } - - public function approveOrder() { - $this->load->language('extension/payment/paypal'); - - $this->load->model('extension/payment/paypal'); + if ($setting['applepay_button']['status']) { + $data['components'][] = 'applepay'; + $data['applepay_button_status'] = $setting['applepay_button']['status']; + $data['applepay_button_align'] = $setting['applepay_button']['align']; + $data['applepay_button_size'] = $setting['applepay_button']['size']; + $data['applepay_button_width'] = $setting['applepay_button_width'][$data['applepay_button_size']]; + $data['applepay_button_color'] = $setting['applepay_button']['color']; + $data['applepay_button_shape'] = $setting['applepay_button']['shape']; + $data['applepay_button_type'] = $setting['applepay_button']['type']; + + if (!empty($this->session->data['order_id'])) { + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - // Setting - $_config = new Config(); - $_config->load('paypal'); + $data['applepay_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); + } else { + $item_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); + + $item_total += $product_price * $product['quantity']; + } - $config_setting = $_config->get('paypal_setting'); - - $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + $data['applepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); + } + } - if (isset($this->request->post['order_id'])) { - $order_id = $this->request->post['order_id']; - } + if ($setting['card']['status']) { + $data['components'][] = 'hosted-fields'; + $data['card_status'] = $setting['card']['status']; + $data['card_align'] = $setting['card']['align']; + $data['card_size'] = $setting['card']['size']; + $data['card_width'] = $setting['card_width'][$data['card_size']]; + $data['card_secure_status'] = $setting['card']['secure_status']; + } + + if ($setting['message']['checkout']['status'] && ($data['currency_code'] == $setting['general']['currency_code'])) { + $data['components'][] = 'messages'; + $data['message_status'] = $setting['message']['checkout']['status']; + $data['message_align'] = $setting['message']['checkout']['align']; + $data['message_size'] = $setting['message']['checkout']['size']; + $data['message_width'] = $setting['message_width'][$data['message_size']]; + $data['message_layout'] = $setting['message']['checkout']['layout']; + $data['message_text_color'] = $setting['message']['checkout']['text_color']; + $data['message_text_size'] = $setting['message']['checkout']['text_size']; + $data['message_flex_color'] = $setting['message']['checkout']['flex_color']; + $data['message_flex_ratio'] = $setting['message']['checkout']['flex_ratio']; + + if (!empty($this->session->data['order_id'])) { + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - if (isset($this->request->post['payload'])) { - $payload = json_decode(htmlspecialchars_decode($this->request->post['payload']), true); + $data['message_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); + } else { + $item_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); + + $item_total += $product_price * $product['quantity']; + } - if (isset($payload['orderId'])) { - $order_id = $payload['orderId']; - - if ($setting['checkout']['card']['secure_status']) { - $secure_scenario_code = isset($payload['authenticationReason']) ? strtolower($payload['authenticationReason']) : 'undefined'; - - if (isset($setting['secure_scenario'][$secure_scenario_code]) && isset($setting['checkout']['card']['secure_scenario'][$secure_scenario_code]) && !$setting['checkout']['card']['secure_scenario'][$secure_scenario_code]) { - $this->error['warning'] = $this->language->get($setting['secure_scenario'][$secure_scenario_code]['error']); + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - - if ($this->error && isset($this->error['warning'])) { - $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } } - } - - if (isset($order_id) && !$this->error) { - $client_id = $this->config->get('payment_paypal_client_id'); - $secret = $this->config->get('payment_paypal_secret'); - $environment = $this->config->get('payment_paypal_environment'); - $partner_id = $setting['partner'][$environment]['partner_id']; - $transaction_method = $this->config->get('payment_paypal_transaction_method'); require_once DIR_SYSTEM .'library/paypal/paypal.php'; $paypal_info = array( - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment + 'partner_id' => $data['partner_id'], + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['partner_attribution_id'] ); $paypal = new PayPal($paypal_info); - + $token_info = array( 'grant_type' => 'client_credentials' ); - + $paypal->setAccessToken($token_info); - if ($transaction_method == 'authorize') { - $result = $paypal->setOrderAuthorize($order_id); - - if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection'])) { - $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; - } - } else { - $result = $paypal->setOrderCapture($order_id); - - if (isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection'])) { - $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; - } - } - - if (!$this->cart->hasShipping()) { - $seller_protection_status = 'NOT_ELIGIBLE'; - } - + $data['client_token'] = $paypal->getClientToken(); + if ($paypal->hasErrors()) { $error_messages = array(); $errors = $paypal->getErrors(); foreach ($errors as $error) { - if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { - $data['restart'] = true; - } - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; - } else { + } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } $this->error['warning'] = implode(' ', $error_messages); } - - if (!$this->error) { - $this->load->model('checkout/order'); - - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('config_order_status_id'), $message); - - $data['success'] = $this->url->link('checkout/success', '', true); + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } } - - $data['error'] = $this->error; + $data['error'] = $this->error; + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } + + public function createOrder() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + if (!empty($this->request->post['page_code']) && !empty($this->request->post['payment_type'])) { + $page_code = $this->request->post['page_code']; + $payment_type = $this->request->post['payment_type']; + + $errors = array(); + + $data['order_id'] = ''; + + if (!empty($this->request->post['product'])) { + $this->request->post['product'] = $this->unserialize($this->request->post['product']); + } + + if (($page_code == 'product') && (!empty($this->request->post['product']['product_id']))) { + $product = $this->request->post['product']; + $product_id = (int)$product['product_id']; + + $this->load->model('catalog/product'); + + $product_info = $this->model_catalog_product->getProduct($product_id); + + if ($product_info) { + if (isset($product['quantity'])) { + $quantity = (int)$product['quantity']; + } else { + $quantity = 1; + } + + if (isset($product['option'])) { + $option = array_filter($product['option']); + } else { + $option = array(); + } + + $product_options = $this->model_catalog_product->getProductOptions($product_id); + + foreach ($product_options as $product_option) { + if ($product_option['required'] && empty($option[$product_option['product_option_id']])) { + $errors[] = sprintf($this->language->get('error_required'), $product_option['name']); + } + } + + if (isset($product['recurring_id'])) { + $recurring_id = $product['recurring_id']; + } else { + $recurring_id = 0; + } + + $recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']); + + if ($recurrings) { + $recurring_ids = array(); + + foreach ($recurrings as $recurring) { + $recurring_ids[] = $recurring['recurring_id']; + } + + if (!in_array($recurring_id, $recurring_ids)) { + $errors[] = $this->language->get('error_recurring_required'); + } + } + + if (!$errors) { + if (!$this->model_extension_payment_paypal->hasProductInCart($product_id, $option, $recurring_id)) { + $this->cart->add($product_id, $quantity, $option, $recurring_id); + } + + // Unset all shipping and payment methods + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + unset($this->session->data['payment_method']); + unset($this->session->data['payment_methods']); + } + } + } + + if ($page_code == 'checkout') { + $this->load->model('checkout/order'); + + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); + + $shipping_info = array(); + + if ($this->cart->hasShipping()) { + $shipping_info['name']['full_name'] = $order_info['shipping_firstname']; + $shipping_info['name']['full_name'] .= ($order_info['shipping_lastname'] ? (' ' . $order_info['shipping_lastname']) : ''); + $shipping_info['address']['address_line_1'] = $order_info['shipping_address_1']; + $shipping_info['address']['address_line_2'] = $order_info['shipping_address_2']; + $shipping_info['address']['admin_area_1'] = $order_info['shipping_zone']; + $shipping_info['address']['admin_area_2'] = $order_info['shipping_city']; + $shipping_info['address']['postal_code'] = $order_info['shipping_postcode']; + + if ($order_info['shipping_country_id']) { + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($order_info['shipping_country_id']); + + if ($country_info) { + $shipping_info['address']['country_code'] = $country_info['iso_code_2']; + } + } + } + } + + if (!$errors) { + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $client_id = $this->config->get('payment_paypal_client_id'); + $secret = $this->config->get('payment_paypal_secret'); + $merchant_id = $this->config->get('payment_paypal_merchant_id'); + $environment = $this->config->get('payment_paypal_environment'); + $partner_id = $setting['partner'][$environment]['partner_id']; + $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; + $transaction_method = $setting['general']['transaction_method']; + + $currency_code = $this->session->data['currency']; + $currency_value = $this->currency->getValue($this->session->data['currency']); + + if (($payment_type == 'button') && empty($setting['currency'][$currency_code]['status'])) { + $currency_code = $setting['general']['currency_code']; + $currency_value = $setting['general']['currency_value']; + } + + if (($payment_type == 'applepay_button') && empty($setting['currency'][$currency_code]['status'])) { + $transaction_method = 'capture'; + $currency_code = $setting['general']['currency_code']; + $currency_value = $setting['general']['currency_value']; + } + + if (($payment_type == 'card') && empty($setting['currency'][$currency_code]['card_status'])) { + $currency_code = $setting['general']['card_currency_code']; + $currency_value = $setting['general']['card_currency_value']; + } + + $decimal_place = $setting['currency'][$currency_code]['decimal_place']; + + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $partner_id, + 'client_id' => $client_id, + 'secret' => $secret, + 'environment' => $environment, + 'partner_attribution_id' => $partner_attribution_id + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $item_info = array(); + + $item_total = 0; + $tax_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); + + $item_info[] = array( + 'name' => $product['name'], + 'sku' => $product['model'], + 'url' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true), + 'quantity' => $product['quantity'], + 'unit_amount' => array( + 'currency_code' => $currency_code, + 'value' => $product_price + ) + ); + + $item_total += $product_price * $product['quantity']; + + if ($product['tax_class_id']) { + $tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']); + + foreach ($tax_rates as $tax_rate) { + $tax_total += ($tax_rate['amount'] * $product['quantity']); + } + } + } + + $item_total = number_format($item_total, $decimal_place, '.', ''); + $tax_total = number_format($tax_total * $currency_value, $decimal_place, '.', ''); + $order_total = number_format($item_total + $tax_total, $decimal_place, '.', ''); + + if ($page_code == 'checkout') { + $discount_total = 0; + $handling_total = 0; + $shipping_total = 0; + + if (isset($this->session->data['shipping_method'])) { + $shipping_total = $this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], true); + $shipping_total = number_format($shipping_total * $currency_value, $decimal_place, '.', ''); + } + + $order_total = number_format($order_info['total'] * $currency_value, $decimal_place, '.', ''); + + $rebate = number_format($item_total + $tax_total + $shipping_total - $order_total, $decimal_place, '.', ''); + + if ($rebate > 0) { + $discount_total = $rebate; + } elseif ($rebate < 0) { + $handling_total = -$rebate; + } + } + + $amount_info = array(); + + $amount_info['currency_code'] = $currency_code; + $amount_info['value'] = $order_total; + + $amount_info['breakdown']['item_total'] = array( + 'currency_code' => $currency_code, + 'value' => $item_total + ); + + $amount_info['breakdown']['tax_total'] = array( + 'currency_code' => $currency_code, + 'value' => $tax_total + ); + + if ($page_code == 'checkout') { + $amount_info['breakdown']['shipping'] = array( + 'currency_code' => $currency_code, + 'value' => $shipping_total + ); + + $amount_info['breakdown']['handling'] = array( + 'currency_code' => $currency_code, + 'value' => $handling_total + ); + + $amount_info['breakdown']['discount'] = array( + 'currency_code' => $currency_code, + 'value' => $discount_total + ); + } + + $paypal_order_info = array(); + + $paypal_order_info['intent'] = strtoupper($transaction_method); + $paypal_order_info['purchase_units'][0]['reference_id'] = 'default'; + $paypal_order_info['purchase_units'][0]['items'] = $item_info; + $paypal_order_info['purchase_units'][0]['amount'] = $amount_info; + + if ($page_code == 'checkout') { + $paypal_order_info['purchase_units'][0]['description'] = 'Your order ' . $order_info['order_id']; + $paypal_order_info['purchase_units'][0]['invoice_id'] = $order_info['order_id'] . '_' . date('Ymd_His'); + + if ($this->cart->hasShipping()) { + $paypal_order_info['purchase_units'][0]['shipping'] = $shipping_info; + } + } + + if ($this->cart->hasShipping()) { + $shipping_preference = 'GET_FROM_FILE'; + } else { + $shipping_preference = 'NO_SHIPPING'; + } + + $paypal_order_info['application_context']['shipping_preference'] = $shipping_preference; + + $result = $paypal->createOrder($paypal_order_info); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + $data['paypal_order_id'] = ''; + + if (isset($result['id']) && isset($result['status']) && !$this->error) { + $this->model_extension_payment_paypal->log($result, 'Create Order'); + + if ($result['status'] == 'VOIDED') { + $this->error['warning'] = sprintf($this->language->get('error_order_voided'), $this->url->link('information/contact', '', true)); + } + + if ($result['status'] == 'COMPLETED') { + $this->error['warning'] = sprintf($this->language->get('error_order_completed'), $this->url->link('information/contact', '', true)); + } + + if (!$this->error) { + $data['paypal_order_id'] = $result['id']; + } + } + } else { + $this->error['warning'] = implode(' ', $errors); + } + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function approveOrder() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + if (!empty($this->request->post['page_code']) && !empty($this->request->post['payment_type'])) { + $page_code = $this->request->post['page_code']; + $payment_type = $this->request->post['payment_type']; + + if ($page_code != 'checkout') { + if (isset($this->request->post['paypal_order_id'])) { + $this->session->data['paypal_order_id'] = $this->request->post['paypal_order_id']; + } else { + $data['url'] = $this->url->link('checkout/cart', '', true); + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + // check checkout can continue due to stock checks or vouchers + if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { + $data['url'] = $this->url->link('checkout/cart', '', true); + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + // if user not logged in check that the guest checkout is allowed + if (!$this->customer->isLogged() && (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload() || $this->cart->hasRecurringProducts())) { + $data['url'] = $this->url->link('checkout/cart', '', true); + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + } + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $client_id = $this->config->get('payment_paypal_client_id'); + $secret = $this->config->get('payment_paypal_secret'); + $environment = $this->config->get('payment_paypal_environment'); + $partner_id = $setting['partner'][$environment]['partner_id']; + $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; + $transaction_method = $setting['general']['transaction_method']; + + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $partner_id, + 'client_id' => $client_id, + 'secret' => $secret, + 'environment' => $environment, + 'partner_attribution_id' => $partner_attribution_id + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + if ($page_code != 'checkout') { + $paypal_order_id = $this->session->data['paypal_order_id']; + + $paypal_order_info = $paypal->getOrder($paypal_order_id); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + if ($paypal_order_info && !$this->error) { + $this->load->model('account/customer'); + $this->load->model('account/address'); + + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + unset($this->session->data['payment_method']); + unset($this->session->data['payment_methods']); + + if ($this->customer->isLogged()) { + $customer_info = $this->model_account_customer->getCustomer($this->customer->getId()); + + $this->session->data['guest']['customer_id'] = $this->customer->getId(); + $this->session->data['guest']['customer_group_id'] = $customer_info['customer_group_id']; + $this->session->data['guest']['firstname'] = $customer_info['firstname']; + $this->session->data['guest']['lastname'] = $customer_info['lastname']; + $this->session->data['guest']['email'] = $customer_info['email']; + $this->session->data['guest']['telephone'] = $customer_info['telephone']; + $this->session->data['guest']['custom_field'] = json_decode($customer_info['custom_field'], true); + } else { + $this->session->data['guest']['customer_id'] = 0; + $this->session->data['guest']['customer_group_id'] = $this->config->get('config_customer_group_id'); + $this->session->data['guest']['firstname'] = (isset($paypal_order_info['payer']['name']['given_name']) ? $paypal_order_info['payer']['name']['given_name'] : ''); + $this->session->data['guest']['lastname'] = (isset($paypal_order_info['payer']['name']['surname']) ? $paypal_order_info['payer']['name']['surname'] : ''); + $this->session->data['guest']['email'] = (isset($paypal_order_info['payer']['email_address']) ? $paypal_order_info['payer']['email_address'] : ''); + $this->session->data['guest']['telephone'] = ''; + $this->session->data['guest']['custom_field'] = array(); + } + + if ($this->customer->isLogged() && $this->customer->getAddressId()) { + $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); + } else { + $this->session->data['payment_address']['firstname'] = (isset($paypal_order_info['payer']['name']['given_name']) ? $paypal_order_info['payer']['name']['given_name'] : ''); + $this->session->data['payment_address']['lastname'] = (isset($paypal_order_info['payer']['name']['surname']) ? $paypal_order_info['payer']['name']['surname'] : ''); + $this->session->data['payment_address']['company'] = ''; + $this->session->data['payment_address']['address_1'] = ''; + $this->session->data['payment_address']['address_2'] = ''; + $this->session->data['payment_address']['city'] = ''; + $this->session->data['payment_address']['postcode'] = ''; + $this->session->data['payment_address']['country'] = ''; + $this->session->data['payment_address']['country_id'] = 0; + $this->session->data['payment_address']['address_format'] = ''; + $this->session->data['payment_address']['zone'] = ''; + $this->session->data['payment_address']['zone_id'] = 0; + $this->session->data['payment_address']['custom_field'] = array(); + + if (isset($paypal_order_info['payer']['address']['country_code'])) { + $country_info = $this->model_extension_payment_paypal->getCountryByCode($paypal_order_info['payer']['address']['country_code']); + + if ($country_info) { + $this->session->data['payment_address']['country'] = $country_info['name']; + $this->session->data['payment_address']['country_id'] = $country_info['country_id']; + } + } + } + + if ($this->cart->hasShipping()) { + if ($this->customer->isLogged() && $this->customer->getAddressId()) { + $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); + } else { + if (isset($paypal_order_info['purchase_units'][0]['shipping']['name']['full_name'])) { + $shipping_name = explode(' ', $paypal_order_info['purchase_units'][0]['shipping']['name']['full_name']); + $shipping_firstname = $shipping_name[0]; + unset($shipping_name[0]); + $shipping_lastname = implode(' ', $shipping_name); + } + + $this->session->data['shipping_address']['firstname'] = (isset($shipping_firstname) ? $shipping_firstname : ''); + $this->session->data['shipping_address']['lastname'] = (isset($shipping_lastname) ? $shipping_lastname : ''); + $this->session->data['shipping_address']['company'] = ''; + $this->session->data['shipping_address']['address_1'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_1']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_1'] : ''); + $this->session->data['shipping_address']['address_2'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_2']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_2'] : ''); + $this->session->data['shipping_address']['city'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_2']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_2'] : ''); + $this->session->data['shipping_address']['postcode'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['postal_code']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['postal_code'] : ''); + $this->session->data['shipping_address']['country'] = ''; + $this->session->data['shipping_address']['country_id'] = 0; + $this->session->data['shipping_address']['address_format'] = ''; + $this->session->data['shipping_address']['zone'] = ''; + $this->session->data['shipping_address']['zone_id'] = 0; + $this->session->data['shipping_address']['custom_field'] = array(); + + if (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['country_code'])) { + $country_info = $this->model_extension_payment_paypal->getCountryByCode($paypal_order_info['purchase_units'][0]['shipping']['address']['country_code']); + + if ($country_info) { + $this->session->data['shipping_address']['country_id'] = $country_info['country_id']; + $this->session->data['shipping_address']['country'] = $country_info['name']; + $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; + + if (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_1'])) { + $zone_info = $this->model_extension_payment_paypal->getZoneByCode($country_info['country_id'], $paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_1']); + + if ($zone_info) { + $this->session->data['shipping_address']['zone_id'] = $zone_info['zone_id']; + $this->session->data['shipping_address']['zone'] = $zone_info['name']; + } + } + } + } + } + } + + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); + } + } else { + if ((($payment_type == 'button') || ($payment_type == 'applepay_button')) && !empty($this->request->post['paypal_order_id'])) { + $paypal_order_id = $this->request->post['paypal_order_id']; + } + + if (($payment_type == 'card') && !empty($this->request->post['payload'])) { + $payload = json_decode(htmlspecialchars_decode($this->request->post['payload']), true); + + if (isset($payload['orderId'])) { + $paypal_order_id = $payload['orderId']; + + if ($setting['card']['secure_status']) { + $paypal_order_info = $paypal->getOrder($paypal_order_id); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (isset($paypal_order_info['payment_source']['card']) && !$this->error) { + $this->model_extension_payment_paypal->log($paypal_order_info['payment_source']['card'], 'Card'); + + $liability_shift = (isset($paypal_order_info['payment_source']['card']['authentication_result']['liability_shift']) ? $paypal_order_info['payment_source']['card']['authentication_result']['liability_shift'] : ''); + $enrollment_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status'] : ''); + $authentication_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status'] : ''); + + if ($enrollment_status == 'Y') { + if (($authentication_status == 'N') && !$setting['card']['secure_scenario']['failed_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['failed_authentication']['error']); + } + + if (($authentication_status == 'R') && !$setting['card']['secure_scenario']['rejected_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['rejected_authentication']['error']); + } + + if (($authentication_status == 'A') && !$setting['card']['secure_scenario']['attempted_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['attempted_authentication']['error']); + } + + if (($authentication_status == 'U') && !$setting['card']['secure_scenario']['unable_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['unable_authentication']['error']); + } + + if (($authentication_status == 'C') && !$setting['card']['secure_scenario']['challenge_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['challenge_authentication']['error']); + } + } + + if (($enrollment_status == 'N') && !$setting['card']['secure_scenario']['card_ineligible']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['card_ineligible']['error']); + } + + if (($enrollment_status == 'U') && !$setting['card']['secure_scenario']['system_unavailable']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_unavailable']['error']); + } + + if (($enrollment_status == 'B') && !$setting['card']['secure_scenario']['system_bypassed']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_bypassed']['error']); + } + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + } + } + } + + if (isset($paypal_order_id) && !$this->error) { + if ($transaction_method == 'authorize') { + $result = $paypal->setOrderAuthorize($paypal_order_id); + } else { + $result = $paypal->setOrderCapture($paypal_order_id); + } + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { + $data['restart'] = true; + } + + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + if (!$this->error) { + if ($transaction_method == 'authorize') { + $this->model_extension_payment_paypal->log($result, 'Authorize Order'); + + if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { + $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; + $order_status_id = 0; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; + } + + if ($authorization_status == 'CREATED') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if ($authorization_status == 'CAPTURED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'DENIED') { + $order_status_id = $setting['order_status']['denied']['id']; + + $this->error['warning'] = $this->language->get('error_authorization_denied'); + } + + if ($authorization_status == 'EXPIRED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->load->model('checkout/order'); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'VOIDED') || ($authorization_status == 'PENDING')) { + $data['url'] = $this->url->link('checkout/success', '', true); + } + } + } else { + $this->model_extension_payment_paypal->log($result, 'Capture Order'); + + if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { + $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; + $order_status_id = 0; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; + } + + if ($capture_status == 'COMPLETED') { + $order_status_id = $setting['order_status']['completed']['id']; + } + + if ($capture_status == 'DECLINED') { + $order_status_id = $setting['order_status']['denied']['id']; + + $this->error['warning'] = $this->language->get('error_capture_declined'); + } + + if ($capture_status == 'FAILED') { + $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); + } + + if ($capture_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->load->model('checkout/order'); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PARTIALLY_REFUNDED') || ($capture_status == 'REFUNDED') || ($capture_status == 'PENDING')) { + $data['url'] = $this->url->link('checkout/success', '', true); + } + } + } + } + } + } + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + + public function confirmOrder() { + $this->load->language('extension/payment/paypal'); + $this->load->language('checkout/cart'); + + $this->load->model('tool/image'); + + if (!isset($this->session->data['paypal_order_id'])) { + $this->response->redirect($this->url->link('checkout/cart', '', true)); + } + + // Coupon + if (isset($this->request->post['coupon']) && $this->validateCoupon()) { + $this->session->data['coupon'] = $this->request->post['coupon']; + + $this->session->data['success'] = $this->language->get('text_coupon'); + + $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); + } + + // Voucher + if (isset($this->request->post['voucher']) && $this->validateVoucher()) { + $this->session->data['voucher'] = $this->request->post['voucher']; + + $this->session->data['success'] = $this->language->get('text_voucher'); + + $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); + } + + // Reward + if (isset($this->request->post['reward']) && $this->validateReward()) { + $this->session->data['reward'] = abs($this->request->post['reward']); + + $this->session->data['success'] = $this->language->get('text_reward'); + + $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); + } + + $this->document->setTitle($this->language->get('text_paypal')); + + $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment/moment.min.js'); + $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js'); + $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); + $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); + + $data['heading_title'] = $this->language->get('text_paypal'); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_home'), + 'href' => $this->url->link('common/home', '', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_cart'), + 'href' => $this->url->link('checkout/cart', '', true) + ); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_paypal'), + 'href' => $this->url->link('extension/payment/paypal/confirmOrder', '', true) + ); + + $points_total = 0; + + foreach ($this->cart->getProducts() as $product) { + if ($product['points']) { + $points_total += $product['points']; + } + } + + if (isset($this->request->post['next'])) { + $data['next'] = $this->request->post['next']; + } else { + $data['next'] = ''; + } + + $this->load->model('tool/upload'); + + $products = $this->cart->getProducts(); + + if (empty($products)) { + $this->response->redirect($this->url->link('checkout/cart', '', true)); + } + + foreach ($products as $product) { + $product_total = 0; + + foreach ($products as $product_2) { + if ($product_2['product_id'] == $product['product_id']) { + $product_total += $product_2['quantity']; + } + } + + if ($product['minimum'] > $product_total) { + $data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']); + } + + if ($product['image']) { + $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); + } else { + $image = ''; + } + + $option_data = array(); + + foreach ($product['option'] as $option) { + if ($option['type'] != 'file') { + $value = $option['value']; + } else { + $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); + + if ($upload_info) { + $value = $upload_info['name']; + } else { + $value = ''; + } + } + + $option_data[] = array( + 'name' => $option['name'], + 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) + ); + } + + // Display prices + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')); + + $price = $this->currency->format($unit_price, $this->session->data['currency']); + $total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']); + } else { + $price = false; + $total = false; + } + + $recurring = ''; + + if ($product['recurring']) { + $frequencies = array( + 'day' => $this->language->get('text_day'), + 'week' => $this->language->get('text_week'), + 'semi_month' => $this->language->get('text_semi_month'), + 'month' => $this->language->get('text_month'), + 'year' => $this->language->get('text_year'), + ); + + if ($product['recurring']['trial']) { + $recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' '; + } + + if ($product['recurring']['duration']) { + $recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']); + } else { + $recurring .= sprintf($this->language->get('text_payment_cancel'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']); + } + } + + $data['products'][] = array( + 'cart_id' => $product['cart_id'], + 'thumb' => $image, + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'recurring' => $recurring, + 'quantity' => $product['quantity'], + 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), + 'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''), + 'price' => $price, + 'total' => $total, + 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true) + ); + } + + // Gift Voucher + $data['vouchers'] = array(); + + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $key => $voucher) { + $data['vouchers'][] = array( + 'key' => $key, + 'description' => $voucher['description'], + 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']), + 'remove' => $this->url->link('checkout/cart', 'remove=' . $key, true) + ); + } + } + + $this->load->model('setting/extension'); + + if ($this->cart->hasShipping()) { + $data['has_shipping'] = true; + + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + + if (!empty($data['shipping_address'])) { + // Shipping Methods + $quote_data = array(); + + $results = $this->model_setting_extension->getExtensions('shipping'); + + if (!empty($results)) { + foreach ($results as $result) { + if ($this->config->get('shipping_' . $result['code'] . '_status')) { + $this->load->model('extension/shipping/' . $result['code']); + + $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($data['shipping_address']); + + if ($quote) { + $quote_data[$result['code']] = array( + 'title' => $quote['title'], + 'quote' => $quote['quote'], + 'sort_order' => $quote['sort_order'], + 'error' => $quote['error'] + ); + } + } + } + + if (!empty($quote_data)) { + $sort_order = array(); + + foreach ($quote_data as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $quote_data); + + $this->session->data['shipping_methods'] = $quote_data; + $data['shipping_methods'] = $quote_data; + + if (!isset($this->session->data['shipping_method'])) { + //default the shipping to the very first option. + $key1 = key($quote_data); + $key2 = key($quote_data[$key1]['quote']); + $this->session->data['shipping_method'] = $quote_data[$key1]['quote'][$key2]; + } + + $data['code'] = $this->session->data['shipping_method']['code']; + $data['action_shipping'] = $this->url->link('extension/payment/paypal/confirmShipping', '', true); + } else { + unset($this->session->data['shipping_methods']); + unset($this->session->data['shipping_method']); + + $data['error_no_shipping'] = $this->language->get('error_no_shipping'); + } + } else { + unset($this->session->data['shipping_methods']); + unset($this->session->data['shipping_method']); + + $data['error_no_shipping'] = $this->language->get('error_no_shipping'); + } + } + } else { + $data['has_shipping'] = false; + } + + $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : array(); + $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : array(); + + // Totals + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + // Display prices + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get('total_' . $result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + } + + /** + * Payment methods + */ + $method_data = array(); + + $results = $this->model_setting_extension->getExtensions('payment'); + + foreach ($results as $result) { + if ($this->config->get('payment_' . $result['code'] . '_status')) { + $this->load->model('extension/payment/' . $result['code']); + + $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($data['payment_address'], $total); + + if ($method) { + $method_data[$result['code']] = $method; + } + } + } + + $sort_order = array(); + + foreach ($method_data as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $method_data); + + $this->session->data['payment_methods'] = $method_data; + $data['payment_methods'] = $method_data; + + if (!isset($method_data['paypal'])) { + $this->session->data['error_warning'] = $this->language->get('error_unavailable'); + + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + + $this->session->data['payment_method'] = $method_data['paypal']; + + // Custom Fields + $this->load->model('account/custom_field'); + + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); + + // Totals + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + // Display prices + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get('total_' . $result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + } + + $data['totals'] = array(); + + foreach ($totals as $total) { + $data['totals'][] = array( + 'title' => $total['title'], + 'text' => $this->currency->format($total['value'], $this->session->data['currency']), + ); + } + + $data['action_confirm'] = $this->url->link('extension/payment/paypal/completeOrder', '', true); + + if (isset($this->session->data['error_warning'])) { + $data['error_warning'] = $this->session->data['error_warning']; + unset($this->session->data['error_warning']); + } else { + $data['error_warning'] = ''; + } + + if (isset($this->session->data['success'])) { + $data['success'] = $this->session->data['success']; + unset($this->session->data['success']); + } else { + $data['success'] = ''; + } + + if (isset($this->session->data['attention'])) { + $data['attention'] = $this->session->data['attention']; + unset($this->session->data['attention']); + } else { + $data['attention'] = ''; + } + + $data['coupon'] = $this->load->controller('extension/total/coupon'); + $data['voucher'] = $this->load->controller('extension/total/voucher'); + $data['reward'] = $this->load->controller('extension/total/reward'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + + $this->response->setOutput($this->load->view('extension/payment/paypal/confirm', $data)); + } + + public function completeOrder() { + $this->load->language('extension/payment/paypal'); + + $this->load->model('extension/payment/paypal'); + + // Validate if payment address has been set. + if (empty($this->session->data['payment_address'])) { + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + + // Validate if payment method has been set. + if (!isset($this->session->data['payment_method'])) { + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + + if ($this->cart->hasShipping()) { + // Validate if shipping address has been set. + if (empty($this->session->data['shipping_address'])) { + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + + // Validate if shipping method has been set. + if (!isset($this->session->data['shipping_method'])) { + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + } else { + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + } + + // Validate cart has products and has stock. + if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { + $this->response->redirect($this->url->link('checkout/cart', '', true)); + } + + if (isset($this->session->data['paypal_order_id'])) { + $order_data = array(); + + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + $this->load->model('setting/extension'); + + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get('total_' . $result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + + $order_data['totals'] = $totals; + + $order_data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); + $order_data['store_id'] = $this->config->get('config_store_id'); + $order_data['store_name'] = $this->config->get('config_name'); + + if ($order_data['store_id']) { + $order_data['store_url'] = $this->config->get('config_url'); + } else { + if ($this->request->server['HTTPS']) { + $order_data['store_url'] = HTTPS_SERVER; + } else { + $order_data['store_url'] = HTTP_SERVER; + } + } + + $order_data['customer_id'] = $this->session->data['guest']['customer_id']; + $order_data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; + $order_data['firstname'] = $this->session->data['guest']['firstname']; + $order_data['lastname'] = $this->session->data['guest']['lastname']; + $order_data['email'] = $this->session->data['guest']['email']; + $order_data['telephone'] = $this->session->data['guest']['telephone']; + $order_data['custom_field'] = $this->session->data['guest']['custom_field']; + + $order_data['payment_firstname'] = $this->session->data['payment_address']['firstname']; + $order_data['payment_lastname'] = $this->session->data['payment_address']['lastname']; + $order_data['payment_company'] = $this->session->data['payment_address']['company']; + $order_data['payment_address_1'] = $this->session->data['payment_address']['address_1']; + $order_data['payment_address_2'] = $this->session->data['payment_address']['address_2']; + $order_data['payment_city'] = $this->session->data['payment_address']['city']; + $order_data['payment_postcode'] = $this->session->data['payment_address']['postcode']; + $order_data['payment_zone'] = $this->session->data['payment_address']['zone']; + $order_data['payment_zone_id'] = $this->session->data['payment_address']['zone_id']; + $order_data['payment_country'] = $this->session->data['payment_address']['country']; + $order_data['payment_country_id'] = $this->session->data['payment_address']['country_id']; + $order_data['payment_address_format'] = $this->session->data['payment_address']['address_format']; + $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']) ? $this->session->data['payment_address']['custom_field'] : array()); + + if (isset($this->session->data['payment_method']['title'])) { + $order_data['payment_method'] = $this->session->data['payment_method']['title']; + } else { + $order_data['payment_method'] = ''; + } + + if (isset($this->session->data['payment_method']['code'])) { + $order_data['payment_code'] = $this->session->data['payment_method']['code']; + } else { + $order_data['payment_code'] = ''; + } + + if ($this->cart->hasShipping()) { + $order_data['shipping_firstname'] = $this->session->data['shipping_address']['firstname']; + $order_data['shipping_lastname'] = $this->session->data['shipping_address']['lastname']; + $order_data['shipping_company'] = $this->session->data['shipping_address']['company']; + $order_data['shipping_address_1'] = $this->session->data['shipping_address']['address_1']; + $order_data['shipping_address_2'] = $this->session->data['shipping_address']['address_2']; + $order_data['shipping_city'] = $this->session->data['shipping_address']['city']; + $order_data['shipping_postcode'] = $this->session->data['shipping_address']['postcode']; + $order_data['shipping_zone'] = $this->session->data['shipping_address']['zone']; + $order_data['shipping_zone_id'] = $this->session->data['shipping_address']['zone_id']; + $order_data['shipping_country'] = $this->session->data['shipping_address']['country']; + $order_data['shipping_country_id'] = $this->session->data['shipping_address']['country_id']; + $order_data['shipping_address_format'] = $this->session->data['shipping_address']['address_format']; + $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']) ? $this->session->data['shipping_address']['custom_field'] : array()); + + if (isset($this->session->data['shipping_method']['title'])) { + $order_data['shipping_method'] = $this->session->data['shipping_method']['title']; + } else { + $order_data['shipping_method'] = ''; + } + + if (isset($this->session->data['shipping_method']['code'])) { + $order_data['shipping_code'] = $this->session->data['shipping_method']['code']; + } else { + $order_data['shipping_code'] = ''; + } + } else { + $order_data['shipping_firstname'] = ''; + $order_data['shipping_lastname'] = ''; + $order_data['shipping_company'] = ''; + $order_data['shipping_address_1'] = ''; + $order_data['shipping_address_2'] = ''; + $order_data['shipping_city'] = ''; + $order_data['shipping_postcode'] = ''; + $order_data['shipping_zone'] = ''; + $order_data['shipping_zone_id'] = 0; + $order_data['shipping_country'] = ''; + $order_data['shipping_country_id'] = 0; + $order_data['shipping_address_format'] = ''; + $order_data['shipping_custom_field'] = array(); + $order_data['shipping_method'] = ''; + $order_data['shipping_code'] = ''; + } + + $order_data['products'] = array(); + + foreach ($this->cart->getProducts() as $product) { + $option_data = array(); + + foreach ($product['option'] as $option) { + $option_data[] = array( + 'product_option_id' => $option['product_option_id'], + 'product_option_value_id' => $option['product_option_value_id'], + 'option_id' => $option['option_id'], + 'option_value_id' => $option['option_value_id'], + 'name' => $option['name'], + 'value' => $option['value'], + 'type' => $option['type'] + ); + } + + $order_data['products'][] = array( + 'product_id' => $product['product_id'], + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'download' => $product['download'], + 'quantity' => $product['quantity'], + 'subtract' => $product['subtract'], + 'price' => $product['price'], + 'total' => $product['total'], + 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), + 'reward' => $product['reward'] + ); + } + + // Gift Voucher + $order_data['vouchers'] = array(); + + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $voucher) { + $order_data['vouchers'][] = array( + 'description' => $voucher['description'], + 'code' => token(10), + 'to_name' => $voucher['to_name'], + 'to_email' => $voucher['to_email'], + 'from_name' => $voucher['from_name'], + 'from_email' => $voucher['from_email'], + 'voucher_theme_id' => $voucher['voucher_theme_id'], + 'message' => $voucher['message'], + 'amount' => $voucher['amount'] + ); + } + } + + $order_data['comment'] = (isset($this->session->data['comment']) ? $this->session->data['comment'] : ''); + $order_data['total'] = $total_data['total']; + + if (isset($this->request->cookie['tracking'])) { + $order_data['tracking'] = $this->request->cookie['tracking']; + + $sub_total = $this->cart->getSubTotal(); + + // Affiliate + $this->load->model('account/customer'); + + $affiliate_info = $this->model_account_customer->getAffiliateByTracking($this->request->cookie['tracking']); + + if ($affiliate_info) { + $order_data['affiliate_id'] = $affiliate_info['customer_id']; + $order_data['commission'] = ($sub_total / 100) * $affiliate_info['commission']; + } else { + $order_data['affiliate_id'] = 0; + $order_data['commission'] = 0; + } + + // Marketing + $this->load->model('checkout/marketing'); + + $marketing_info = $this->model_checkout_marketing->getMarketingByCode($this->request->cookie['tracking']); + + if ($marketing_info) { + $order_data['marketing_id'] = $marketing_info['marketing_id']; + } else { + $order_data['marketing_id'] = 0; + } + } else { + $order_data['affiliate_id'] = 0; + $order_data['commission'] = 0; + $order_data['marketing_id'] = 0; + $order_data['tracking'] = ''; + } + + $order_data['language_id'] = $this->config->get('config_language_id'); + $order_data['currency_id'] = $this->currency->getId($this->session->data['currency']); + $order_data['currency_code'] = $this->session->data['currency']; + $order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']); + $order_data['ip'] = $this->request->server['REMOTE_ADDR']; + + if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) { + $order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR']; + } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) { + $order_data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP']; + } else { + $order_data['forwarded_ip'] = ''; + } + + if (isset($this->request->server['HTTP_USER_AGENT'])) { + $order_data['user_agent'] = $this->request->server['HTTP_USER_AGENT']; + } else { + $order_data['user_agent'] = ''; + } + + if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { + $order_data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE']; + } else { + $order_data['accept_language'] = ''; + } + + $this->load->model('checkout/order'); + + $this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data); + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $client_id = $this->config->get('payment_paypal_client_id'); + $secret = $this->config->get('payment_paypal_secret'); + $environment = $this->config->get('payment_paypal_environment'); + $partner_id = $setting['partner'][$environment]['partner_id']; + $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; + $transaction_method = $setting['general']['transaction_method']; + + $currency_code = $this->session->data['currency']; + $currency_value = $this->currency->getValue($this->session->data['currency']); + + if (empty($setting['currency'][$currency_code]['status'])) { + $currency_code = $setting['general']['currency_code']; + $currency_value = $setting['general']['currency_value']; + } + + $decimal_place = $setting['currency'][$currency_code]['decimal_place']; + + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $partner_id, + 'client_id' => $client_id, + 'secret' => $secret, + 'environment' => $environment, + 'partner_attribution_id' => $partner_attribution_id + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $paypal_order_id = $this->session->data['paypal_order_id']; + + $paypal_order_info = array(); + + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/description', + 'value' => 'Your order ' . $this->session->data['order_id'] + ); + + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/invoice_id', + 'value' => $this->session->data['order_id'] . '_' . date('Ymd_His') + ); + + $shipping_info = array(); + + if ($this->cart->hasShipping()) { + $shipping_info['name']['full_name'] = (isset($this->session->data['shipping_address']['firstname']) ? $this->session->data['shipping_address']['firstname'] : ''); + $shipping_info['name']['full_name'] .= (isset($this->session->data['shipping_address']['lastname']) ? (' ' . $this->session->data['shipping_address']['lastname']) : ''); + $shipping_info['address']['address_line_1'] = (isset($this->session->data['shipping_address']['address_1']) ? $this->session->data['shipping_address']['address_1'] : ''); + $shipping_info['address']['address_line_2'] = (isset($this->session->data['shipping_address']['address_2']) ? $this->session->data['shipping_address']['address_2'] : ''); + $shipping_info['address']['admin_area_1'] = (isset($this->session->data['shipping_address']['zone']) ? $this->session->data['shipping_address']['zone'] : ''); + $shipping_info['address']['admin_area_2'] = (isset($this->session->data['shipping_address']['city']) ? $this->session->data['shipping_address']['city'] : ''); + $shipping_info['address']['postal_code'] = (isset($this->session->data['shipping_address']['postcode']) ? $this->session->data['shipping_address']['postcode'] : ''); + + if (isset($this->session->data['shipping_address']['country_id'])) { + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($this->session->data['shipping_address']['country_id']); + + if ($country_info) { + $shipping_info['address']['country_code'] = $country_info['iso_code_2']; + } + } + + $paypal_order_info[] = array( + 'op' => 'replace', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', + 'value' => $shipping_info['name'] + ); + + $paypal_order_info[] = array( + 'op' => 'replace', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', + 'value' => $shipping_info['address'] + ); + } + + $item_total = 0; + $tax_total = 0; + + foreach ($this->cart->getProducts() as $product) { + $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); + + $item_total += $product_price * $product['quantity']; + + if ($product['tax_class_id']) { + $tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']); + + foreach ($tax_rates as $tax_rate) { + $tax_total += ($tax_rate['amount'] * $product['quantity']); + } + } + } + + $item_total = number_format($item_total, $decimal_place, '.', ''); + $tax_total = number_format($tax_total * $currency_value, $decimal_place, '.', ''); + + $discount_total = 0; + $handling_total = 0; + $shipping_total = 0; + + if (isset($this->session->data['shipping_method'])) { + $shipping_total = $this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], true); + $shipping_total = number_format($shipping_total * $currency_value, $decimal_place, '.', ''); + } + + $order_total = number_format($order_data['total'] * $currency_value, $decimal_place, '.', ''); + + $rebate = number_format($item_total + $tax_total + $shipping_total - $order_total, $decimal_place, '.', ''); + + if ($rebate > 0) { + $discount_total = $rebate; + } elseif ($rebate < 0) { + $handling_total = -$rebate; + } + + $amount_info = array(); + + $amount_info['currency_code'] = $currency_code; + $amount_info['value'] = $order_total; + + $amount_info['breakdown']['item_total'] = array( + 'currency_code' => $currency_code, + 'value' => $item_total + ); + + $amount_info['breakdown']['tax_total'] = array( + 'currency_code' => $currency_code, + 'value' => $tax_total + ); + + $amount_info['breakdown']['shipping'] = array( + 'currency_code' => $currency_code, + 'value' => $shipping_total + ); + + $amount_info['breakdown']['handling'] = array( + 'currency_code' => $currency_code, + 'value' => $handling_total + ); + + $amount_info['breakdown']['discount'] = array( + 'currency_code' => $currency_code, + 'value' => $discount_total + ); + + $paypal_order_info[] = array( + 'op' => 'replace', + 'path' => '/purchase_units/@reference_id==\'default\'/amount', + 'value' => $amount_info + ); + + $result = $paypal->updateOrder($paypal_order_id, $paypal_order_info); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + if ($paypal_order_id && !$this->error) { + if ($transaction_method == 'authorize') { + $result = $paypal->setOrderAuthorize($paypal_order_id); + } else { + $result = $paypal->setOrderCapture($paypal_order_id); + } + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { + $data['restart'] = true; + } + + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + if (!$this->error) { + if ($transaction_method == 'authorize') { + $this->model_extension_payment_paypal->log($result, 'Authorize Order'); + + if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { + $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; + $order_status_id = 0; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; + } + + if ($authorization_status == 'CREATED') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if ($authorization_status == 'CAPTURED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'DENIED') { + $order_status_id = $setting['order_status']['denied']['id']; + + $this->error['warning'] = $this->language->get('error_authorization_denied'); + } + + if ($authorization_status == 'EXPIRED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'VOIDED') || ($authorization_status == 'PENDING')) { + $this->response->redirect($this->url->link('checkout/success', '', true)); + } + } + } else { + $this->model_extension_payment_paypal->log($result, 'Capture Order'); + + if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { + $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; + $order_status_id = 0; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; + } + + if ($capture_status == 'COMPLETED') { + $order_status_id = $setting['order_status']['completed']['id']; + } + + if ($capture_status == 'DECLINED') { + $order_status_id = $setting['order_status']['denied']['id']; + + $this->error['warning'] = $this->language->get('error_capture_declined'); + } + + if ($capture_status == 'FAILED') { + $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); + } + + if ($capture_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PARTIALLY_REFUNDED') || ($capture_status == 'REFUNDED') || ($capture_status == 'PENDING')) { + $this->response->redirect($this->url->link('checkout/success', '', true)); + } + } + } + } + } + + unset($this->session->data['paypal_order_id']); + + if ($this->error) { + $this->session->data['error'] = $this->error['warning']; + + $this->response->redirect($this->url->link('checkout/checkout', '', true)); + } + } + + $this->response->redirect($this->url->link('checkout/cart', '', true)); + } + + public function paymentAddress() { + $this->load->language('extension/payment/paypal'); + + $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : array(); + $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : array(); + + $this->load->model('localisation/country'); + + $data['countries'] = $this->model_localisation_country->getCountries(); + + $this->load->model('account/custom_field'); + + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); + + $this->response->setOutput($this->load->view('extension/payment/paypal/payment_address', $data)); + } + + public function shippingAddress() { + $this->load->language('extension/payment/paypal'); + + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + + $this->load->model('localisation/country'); + + $data['countries'] = $this->model_localisation_country->getCountries(); + + $this->load->model('account/custom_field'); + + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); + + $this->response->setOutput($this->load->view('extension/payment/paypal/shipping_address', $data)); + } + + public function confirmShipping() { + $this->validateShipping($this->request->post['shipping_method']); + + $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); + } + + public function confirmPaymentAddress() { + $this->load->language('extension/payment/paypal'); + + $data['url'] = ''; + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validatePaymentAddress()) { + $this->session->data['guest']['firstname'] = $this->request->post['firstname']; + $this->session->data['guest']['lastname'] = $this->request->post['lastname']; + $this->session->data['guest']['email'] = $this->request->post['email']; + $this->session->data['guest']['telephone'] = $this->request->post['telephone']; + + if (isset($this->request->post['custom_field']['account'])) { + $this->session->data['guest']['custom_field'] = $this->request->post['custom_field']['account']; + } else { + $this->session->data['guest']['custom_field'] = array(); + } + + $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; + $this->session->data['payment_address']['lastname'] = $this->request->post['lastname']; + $this->session->data['payment_address']['company'] = $this->request->post['company']; + $this->session->data['payment_address']['address_1'] = $this->request->post['address_1']; + $this->session->data['payment_address']['address_2'] = $this->request->post['address_2']; + $this->session->data['payment_address']['postcode'] = $this->request->post['postcode']; + $this->session->data['payment_address']['city'] = $this->request->post['city']; + $this->session->data['payment_address']['country_id'] = $this->request->post['country_id']; + $this->session->data['payment_address']['zone_id'] = $this->request->post['zone_id']; + + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); + + if ($country_info) { + $this->session->data['payment_address']['country'] = $country_info['name']; + $this->session->data['payment_address']['iso_code_2'] = $country_info['iso_code_2']; + $this->session->data['payment_address']['iso_code_3'] = $country_info['iso_code_3']; + $this->session->data['payment_address']['address_format'] = $country_info['address_format']; + } else { + $this->session->data['payment_address']['country'] = ''; + $this->session->data['payment_address']['iso_code_2'] = ''; + $this->session->data['payment_address']['iso_code_3'] = ''; + $this->session->data['payment_address']['address_format'] = ''; + } + + if (isset($this->request->post['custom_field']['address'])) { + $this->session->data['payment_address']['custom_field'] = $this->request->post['custom_field']['address']; + } else { + $this->session->data['payment_address']['custom_field'] = array(); + } + + $this->load->model('localisation/zone'); + + $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); + + if ($zone_info) { + $this->session->data['payment_address']['zone'] = $zone_info['name']; + $this->session->data['payment_address']['zone_code'] = $zone_info['code']; + } else { + $this->session->data['payment_address']['zone'] = ''; + $this->session->data['payment_address']['zone_code'] = ''; + } + + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + public function confirmShippingAddress() { + $this->load->language('extension/payment/paypal'); + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateShippingAddress()) { + $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; + $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; + $this->session->data['shipping_address']['company'] = $this->request->post['company']; + $this->session->data['shipping_address']['address_1'] = $this->request->post['address_1']; + $this->session->data['shipping_address']['address_2'] = $this->request->post['address_2']; + $this->session->data['shipping_address']['postcode'] = $this->request->post['postcode']; + $this->session->data['shipping_address']['city'] = $this->request->post['city']; + $this->session->data['shipping_address']['country_id'] = $this->request->post['country_id']; + $this->session->data['shipping_address']['zone_id'] = $this->request->post['zone_id']; + + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); + + if ($country_info) { + $this->session->data['shipping_address']['country'] = $country_info['name']; + $this->session->data['shipping_address']['iso_code_2'] = $country_info['iso_code_2']; + $this->session->data['shipping_address']['iso_code_3'] = $country_info['iso_code_3']; + $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; + } else { + $this->session->data['shipping_address']['country'] = ''; + $this->session->data['shipping_address']['iso_code_2'] = ''; + $this->session->data['shipping_address']['iso_code_3'] = ''; + $this->session->data['shipping_address']['address_format'] = ''; + } + + $this->load->model('localisation/zone'); + + $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); + + if ($zone_info) { + $this->session->data['shipping_address']['zone'] = $zone_info['name']; + $this->session->data['shipping_address']['zone_code'] = $zone_info['code']; + } else { + $this->session->data['shipping_address']['zone'] = ''; + $this->session->data['shipping_address']['zone_code'] = ''; + } + + if (isset($this->request->post['custom_field'])) { + $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']['address']; + } else { + $this->session->data['shipping_address']['custom_field'] = array(); + } + + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); + } + + $data['error'] = $this->error; + + $this->response->addHeader('Content-Type: application/json'); + $this->response->setOutput(json_encode($data)); + } + public function webhook() { $this->load->model('extension/payment/paypal'); - $webhook_data = json_decode(html_entity_decode(file_get_contents('php://input')), true); - - $this->model_extension_payment_paypal->log($webhook_data, 'Webhook'); - - if (isset($webhook_data['event_type']) && isset($webhook_data['resource']['invoice_id'])) { + $webhook_info = json_decode(html_entity_decode(file_get_contents('php://input')), true); + + if (isset($webhook_info['id']) && isset($webhook_info['event_type'])) { + $this->model_extension_payment_paypal->log($webhook_info, 'Webhook'); + + $webhook_event_id = $webhook_info['id']; + // Setting $_config = new Config(); $_config->load('paypal'); @@ -472,48 +2514,401 @@ public function webhook() { $config_setting = $_config->get('paypal_setting'); $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $client_id = $this->config->get('payment_paypal_client_id'); + $secret = $this->config->get('payment_paypal_secret'); + $environment = $this->config->get('payment_paypal_environment'); + $partner_id = $setting['partner'][$environment]['partner_id']; + $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; + $transaction_method = $setting['general']['transaction_method']; + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $partner_id, + 'client_id' => $client_id, + 'secret' => $secret, + 'environment' => $environment, + 'partner_attribution_id' => $partner_attribution_id + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $webhook_repeat = 1; + + while ($webhook_repeat) { + $webhook_event = $paypal->getWebhookEvent($webhook_event_id); + + $errors = array(); + + $webhook_repeat = 0; - $order_id = $webhook_data['resource']['invoice_id']; + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $webhook_repeat = 1; + } + } + } + } - if ($webhook_data['event_type'] == 'PAYMENT.AUTHORIZATION.CREATED') { - $order_status_id = $setting['order_status']['pending']['id']; + if (isset($webhook_event['resource']['invoice_id']) && !$errors) { + $invoice_id = explode('_', $webhook_event['resource']['invoice_id']); + $order_id = reset($invoice_id); + + $order_status_id = 0; + + if ($webhook_event['event_type'] == 'PAYMENT.AUTHORIZATION.CREATED') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.AUTHORIZATION.VOIDED') { + $order_status_id = $setting['order_status']['voided']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.COMPLETED') { + $order_status_id = $setting['order_status']['completed']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.DENIED') { + $order_status_id = $setting['order_status']['denied']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.REFUNDED') { + $order_status_id = $setting['order_status']['refunded']['id']; + } + + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.REVERSED') { + $order_status_id = $setting['order_status']['reversed']['id']; + } + + if ($webhook_event['event_type'] == 'CHECKOUT.ORDER.COMPLETED') { + $order_status_id = $setting['order_status']['completed']['id']; + } + + if ($order_status_id) { + $this->load->model('checkout/order'); + + $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); + } } + + return true; + } + + return false; + } + + public function header_before($route, &$data) { + $this->load->model('extension/payment/paypal'); + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - if ($webhook_data['event_type'] == 'PAYMENT.AUTHORIZATION.VOIDED') { - $order_status_id = $setting['order_status']['voided']['id']; + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && $agree_status) { + if (isset($this->request->get['route'])) { + $route = $this->request->get['route']; + } else { + $route = 'common/home'; + } + + $params = array(); + + if ($route == 'common/home') { + $params['page_code'] = 'home'; } - if ($webhook_data['event_type'] == 'PAYMENT.CAPTURE.COMPLETED') { - $order_status_id = $setting['order_status']['completed']['id']; + if (($route == 'product/product') && !empty($this->request->get['product_id'])) { + $params['page_code'] = 'product'; + $params['product_id'] = $this->request->get['product_id']; } - - if ($webhook_data['event_type'] == 'PAYMENT.CAPTURE.DENIED') { - $order_status_id = $setting['order_status']['denied']['id']; + + if ($route == 'checkout/cart') { + $params['page_code'] = 'cart'; } - - if ($webhook_data['event_type'] == 'PAYMENT.CAPTURE.PENDING') { - $order_status_id = $setting['order_status']['pending']['id']; + + if ($route == 'checkout/checkout') { + $params['page_code'] = 'checkout'; } - - if ($webhook_data['event_type'] == 'PAYMENT.CAPTURE.REFUNDED') { - $order_status_id = $setting['order_status']['refunded']['id']; + + if ($params) { + $theme = $this->config->get('theme_' . $this->config->get('config_theme') . '_directory'); + + if (file_exists(DIR_TEMPLATE . $theme . '/stylesheet/paypal/paypal.css')) { + $this->document->addStyle('catalog/view/theme/' . $theme . '/stylesheet/paypal/paypal.css'); + } else { + $this->document->addStyle('catalog/view/theme/default/stylesheet/paypal/paypal.css'); + } + + if ($params['page_code'] == 'checkout') { + if (file_exists(DIR_TEMPLATE . $theme . '/stylesheet/paypal/card.css')) { + $this->document->addStyle('catalog/view/theme/' . $theme . '/stylesheet/paypal/card.css'); + } else { + $this->document->addStyle('catalog/view/theme/default/stylesheet/paypal/card.css'); + } + + $this->document->addScript('https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'); + } + + $this->document->addScript('catalog/view/javascript/paypal/paypal.js?' . http_build_query($params)); } + } + } + + public function extension_get_extensions_after($route, $data, &$output) { + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret')) { + $type = $data[0]; + + if ($type == 'payment') { + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); - if ($webhook_data['event_type'] == 'PAYMENT.CAPTURE.REVERSED') { - $order_status_id = $setting['order_status']['reversed']['id']; + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + if (!empty($setting['paylater_country'][$setting['general']['country_code']]) && ($setting['button']['checkout']['funding']['paylater'] != 2)) { + $this->config->set('payment_paypal_paylater_status', 1); + + $output[] = array( + 'extension_id' => 0, + 'type' => 'payment', + 'code' => 'paypal_paylater' + ); + } } - - if ($webhook_data['event_type'] == 'CHECKOUT.ORDER.COMPLETED') { - $order_status_id = $setting['order_status']['completed']['id']; + } + } + + private function validateShipping($code) { + $this->load->language('checkout/cart'); + $this->load->language('extension/payment/paypal'); + + if (empty($code)) { + $this->session->data['error_warning'] = $this->language->get('error_shipping'); + + return false; + } else { + $shipping = explode('.', $code); + + if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { + $this->session->data['error_warning'] = $this->language->get('error_shipping'); + + return false; + } else { + $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; + $this->session->data['success'] = $this->language->get('text_shipping_updated'); + + return true; } + } + } + + private function validatePaymentAddress() { + if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) { + $this->error['firstname'] = $this->language->get('error_firstname'); + } + + if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) { + $this->error['lastname'] = $this->language->get('error_lastname'); + } + + if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { + $this->error['email'] = $this->language->get('error_email'); + } + + if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) { + $this->error['telephone'] = $this->language->get('error_telephone'); + } + + if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) { + $this->error['address_1'] = $this->language->get('error_address_1'); + } + + if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) { + $this->error['city'] = $this->language->get('error_city'); + } + + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); + + if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) { + $this->error['postcode'] = $this->language->get('error_postcode'); + } + + if ($this->request->post['country_id'] == '') { + $this->error['country'] = $this->language->get('error_country'); + } + + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { + $this->error['zone'] = $this->language->get('error_zone'); + } + + // Customer Group + if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { + $customer_group_id = $this->request->post['customer_group_id']; + } else { + $customer_group_id = $this->config->get('config_customer_group_id'); + } + + // Custom field validation + $this->load->model('account/custom_field'); + + $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); + + foreach ($custom_fields as $custom_field) { + if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { + $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { + $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); + } + } + + return !$this->error; + } + + private function validateShippingAddress() { + if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) { + $this->error['firstname'] = $this->language->get('error_firstname'); + } + + if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) { + $this->error['lastname'] = $this->language->get('error_lastname'); + } + + if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) { + $this->error['address_1'] = $this->language->get('error_address_1'); + } + + if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) { + $this->error['city'] = $this->language->get('error_city'); + } + + $this->load->model('localisation/country'); + + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); + + if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) { + $this->error['postcode'] = $this->language->get('error_postcode'); + } + + if ($this->request->post['country_id'] == '') { + $this->error['country'] = $this->language->get('error_country'); + } + + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { + $this->error['zone'] = $this->language->get('error_zone'); + } + + // Customer Group + if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { + $customer_group_id = $this->request->post['customer_group_id']; + } else { + $customer_group_id = $this->config->get('config_customer_group_id'); + } - if ($webhook_data['event_type'] == 'CHECKOUT.ORDER.APPROVED') { - $order_status_id = $setting['order_status']['pending']['id']; + // Custom field validation + $this->load->model('account/custom_field'); + + $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); + + foreach ($custom_fields as $custom_field) { + if ($custom_field['location'] == 'address') { + if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { + $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { + $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); + } } + } + + return !$this->error; + } + + private function validateCoupon() { + $this->load->model('extension/total/coupon'); + + $coupon_info = $this->model_extension_total_coupon->getCoupon($this->request->post['coupon']); + + if ($coupon_info) { + return true; + } else { + $this->session->data['error_warning'] = $this->language->get('error_coupon'); - $this->load->model('checkout/order'); + return false; + } + } + + private function validateVoucher() { + $this->load->model('extension/total/voucher'); + + $voucher_info = $this->model_extension_total_voucher->getVoucher($this->request->post['voucher']); + + if ($voucher_info) { + return true; + } else { + $this->session->data['error_warning'] = $this->language->get('error_voucher'); + + return false; + } + } + + private function validateReward() { + $points = $this->customer->getRewardPoints(); + + $points_total = 0; + + foreach ($this->cart->getProducts() as $product) { + if ($product['points']) { + $points_total += $product['points']; + } + } + + $error = ''; + + if (empty($this->request->post['reward'])) { + $error = $this->language->get('error_reward'); + } + + if ($this->request->post['reward'] > $points) { + $error = sprintf($this->language->get('error_points'), $this->request->post['reward']); + } + + if ($this->request->post['reward'] > $points_total) { + $error = sprintf($this->language->get('error_maximum'), $points_total); + } - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); + if (!$error) { + return true; + } else { + $this->session->data['error_warning'] = $error; + + return false; } } + + private function unserialize($str) { + $data = array(); + + $str = str_replace('&', '&', $str); + + parse_str($str, $data); + + return $data; + } } \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/paypal_paylater.php b/upload/catalog/controller/extension/payment/paypal_paylater.php new file mode 100644 index 00000000000..59fffefb8fd --- /dev/null +++ b/upload/catalog/controller/extension/payment/paypal_paylater.php @@ -0,0 +1,159 @@ +load->model('extension/payment/paypal'); + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && $agree_status) { + $this->load->language('extension/payment/paypal'); + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; + $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; + $data['checkout_mode'] = $setting['general']['checkout_mode']; + $data['transaction_method'] = $setting['general']['transaction_method']; + + if ($setting['button']['checkout']['status']) { + $data['button_status'] = $setting['button']['checkout']['status']; + } + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $data['partner_id'], + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + $data['error'] = $this->error; + + return $this->load->view('extension/payment/paypal/paypal_paylater', $data); + } + } + + public function modal() { + $this->load->language('extension/payment/paypal'); + + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + $data['client_id'] = $this->config->get('payment_paypal_client_id'); + $data['secret'] = $this->config->get('payment_paypal_secret'); + $data['merchant_id'] = $this->config->get('payment_paypal_merchant_id'); + $data['environment'] = $this->config->get('payment_paypal_environment'); + $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; + $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; + $data['transaction_method'] = $setting['general']['transaction_method']; + + if ($setting['button']['checkout']['status']) { + $data['button_status'] = $setting['button']['checkout']['status']; + } + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + 'partner_id' => $data['partner_id'], + 'client_id' => $data['client_id'], + 'secret' => $data['secret'], + 'environment' => $data['environment'], + 'partner_attribution_id' => $data['partner_attribution_id'] + ); + + $paypal = new PayPal($paypal_info); + + $token_info = array( + 'grant_type' => 'client_credentials' + ); + + $paypal->setAccessToken($token_info); + + $data['client_token'] = $paypal->getClientToken(); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); + } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + $data['error'] = $this->error; + + $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_paylater_modal', $data)); + } +} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/pp_braintree.php b/upload/catalog/controller/extension/payment/pp_braintree.php deleted file mode 100644 index 60872bb3db7..00000000000 --- a/upload/catalog/controller/extension/payment/pp_braintree.php +++ /dev/null @@ -1,1635 +0,0 @@ -initialise(); - - $this->load->language('extension/payment/pp_braintree'); - - $data['payment_url'] = $this->url->link('extension/payment/pp_braintree/payment', '', true); - $data['vaulted_url'] = $this->url->link('extension/payment/pp_braintree/vaulted', '', true); - - $data['payment_pp_braintree_3ds_status'] = $this->config->get('payment_pp_braintree_3ds_status'); - $data['payment_pp_braintree_vault_cvv_3ds'] = $this->config->get('payment_pp_braintree_vault_cvv_3ds'); - $data['payment_pp_braintree_paypal_option'] = $this->config->get('payment_pp_braintree_paypal_option'); - $data['payment_pp_braintree_vault_cvv'] = $this->config->get('payment_pp_braintree_vault_cvv'); - $data['payment_pp_braintree_settlement_immediate'] = $this->config->get('payment_pp_braintree_settlement_immediate'); - $data['payment_pp_braintree_paypal_button_colour'] = $this->config->get('payment_pp_braintree_paypal_button_colour'); - $data['payment_pp_braintree_paypal_button_size'] = $this->config->get('payment_pp_braintree_paypal_button_size'); - $data['payment_pp_braintree_paypal_button_shape'] = $this->config->get('payment_pp_braintree_paypal_button_shape'); - - if (!isset($this->session->data['order_id'])) { - return false; - } - - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $create_token = array(); - $merchant_id = $this->config->get('payment_pp_braintree_merchant_id'); - - if ($this->gateway == '') { - $merchant_accounts = $this->config->get('payment_pp_braintree_account'); - - foreach ($merchant_accounts as $merchant_account_currency => $merchant_account) { - if (($merchant_account_currency == $order_info['currency_code']) && !empty($merchant_account['merchant_account_id'])) { - $create_token['merchantAccountId'] = $merchant_account['merchant_account_id']; - - $merchant_id = $merchant_account['merchant_account_id']; - - break; - } - } - } - - $data['merchant_id'] = $merchant_id; - - if ($this->customer->isLogged() && ($this->config->get('payment_pp_braintree_card_vault') || $this->config->get('payment_pp_braintree_paypal_vault'))) { - $data['payment_pp_braintree_card_vault'] = $this->config->get('payment_pp_braintree_card_vault'); - $data['payment_pp_braintree_paypal_vault'] = $this->config->get('payment_pp_braintree_paypal_vault'); - $data['payment_pp_braintree_card_check_vault'] = $this->config->get('payment_pp_braintree_card_check_vault'); - $data['payment_pp_braintree_paypal_check_vault'] = $this->config->get('payment_pp_braintree_paypal_check_vault'); - $vaulted_customer_info = $this->model_extension_payment_pp_braintree->getCustomer($this->gateway, $this->customer_id_prefix . $this->customer->getId(), false); - } else { - $data['payment_pp_braintree_card_vault'] = 0; - $data['payment_pp_braintree_paypal_vault'] = 0; - $data['payment_pp_braintree_card_check_vault'] = 0; - $data['payment_pp_braintree_paypal_check_vault'] = 0; - $vaulted_customer_info = false; - } - - $data['client_token'] = $this->model_extension_payment_pp_braintree->generateToken($this->gateway, $create_token); - $data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); - - $data['currency_code'] = $order_info['currency_code']; - - // disable paypal option if currency is not in supported array - if (!in_array($order_info['currency_code'], array('USD', 'EUR', 'GBP', 'CAD', 'AUD', 'DKK', 'NOK', 'PLN', 'SEK', 'CHF', 'TRY'))) { - $data['payment_pp_braintree_paypal_option'] = false; - } - - // pass shipping info to paypal if set - if ($data['payment_pp_braintree_paypal_option'] && $this->cart->hasShipping()) { - $data['customer_shipping_address'] = array( - 'name' => addslashes($order_info['shipping_firstname']) . ' ' . addslashes($order_info['shipping_lastname']), - 'line_1' => addslashes($order_info['shipping_address_1']), - 'line_2' => addslashes($order_info['shipping_address_2']), - 'city' => addslashes($order_info['shipping_city']), - 'state' => addslashes($order_info['shipping_zone_code']), - 'post_code' => addslashes($order_info['shipping_postcode']), - 'country_code' => addslashes($order_info['shipping_iso_code_2']), - 'phone' => addslashes($order_info['telephone']), - ); - } - - $vaulted_payment_methods = array('cards', 'paypal'); - $vaulted_payment_count = 0; - - if ($vaulted_customer_info) { - $vaulted_card_count = 0; - $vaulted_paypal_count = 0; - - if ($vaulted_customer_info->creditCards && $this->config->get('payment_pp_braintree_card_vault') == 1) { - $vaulted_card_count = count($vaulted_customer_info->creditCards); - - foreach ($vaulted_customer_info->creditCards as $credit_card) { - $vaulted_payment_methods['cards'][] = array( - 'image' => $credit_card->imageUrl, - 'name' => sprintf($this->language->get('text_vaulted_payment_method_name'), $credit_card->cardType, $credit_card->last4, $credit_card->expirationDate), - 'token' => $credit_card->token, - 'expired' => $credit_card->expired, - 'default' => $credit_card->default - ); - } - } - - if ($vaulted_customer_info->paypalAccounts && $this->config->get('payment_pp_braintree_paypal_vault') == 1) { - $vaulted_paypal_count = count($vaulted_customer_info->paypalAccounts); - - foreach ($vaulted_customer_info->paypalAccounts as $paypal_account) { - $vaulted_payment_methods['paypal'][] = array( - 'image' => $paypal_account->imageUrl, - 'name' => $paypal_account->email, - 'token' => $paypal_account->token, - 'default' => $paypal_account->default - ); - } - } - - $vaulted_payment_count = $vaulted_card_count + $vaulted_paypal_count; - } - - $data['vaulted_payment_methods'] = $vaulted_payment_methods; - $data['vaulted_payment_count'] = $vaulted_payment_count; - - $data['form_styles'] = json_encode("{ - 'input': { 'font-size': '12px', 'font-family': 'Source Sans Pro, sans-serif', 'color': '#7A8494' }, - 'input.invalid': { 'color': 'red' }, - 'input.valid': { 'color': 'green' } - }"); - - if ($this->customer->isLogged()) { - $data['guest'] = false; - } else { - $data['guest'] = true; - } - - return $this->load->view('extension/payment/pp_braintree', $data); - } - - public function payment() { - //set_time_limit(120); - - $this->initialise(); - - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('checkout/order'); - $this->load->model('extension/payment/pp_braintree'); - - $this->model_extension_payment_pp_braintree->log('Starting payment'); - $this->model_extension_payment_pp_braintree->log($this->request->post); - - $success = true; - - if (!isset($this->session->data['order_id'])) { - $this->model_extension_payment_pp_braintree->log('Session data: order_id not found'); - - $success = false; - } - - if (isset($this->request->post['device_data'])) { - $device_data = $this->request->post['device_data']; - } else { - $this->model_extension_payment_pp_braintree->log('Post data: device_data not found'); - - $device_data = ''; - - $success = false; - } - - if (isset($this->request->post['payment_method_token'])) { - $payment_method_token = $this->request->post['payment_method_token']; - } else { - $this->model_extension_payment_pp_braintree->log('Post data: payment_method_token not found'); - $payment_method_token = ''; - } - - if (isset($this->request->post['payment_method_nonce'])) { - $payment_method_nonce = $this->request->post['payment_method_nonce']; - } else { - $this->model_extension_payment_pp_braintree->log('Post data: payment_method_nonce not found'); - $payment_method_nonce = ''; - } - - if ($payment_method_nonce == '' && $payment_method_token == '') { - $success = false; - } - - //Start creating transaction array - if ($success) { - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $create_sale = array( - 'amount' => $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false), - 'channel' => 'OpenCart_Cart_vzero', - 'orderId' => $order_info['order_id'], - 'deviceData' => $device_data, - 'customer' => array( - 'firstName' => $order_info['firstname'], - 'lastName' => $order_info['lastname'], - 'phone' => $order_info['telephone'], - 'email' => $order_info['email'] - ), - 'billing' => array( - 'firstName' => $order_info['payment_firstname'], - 'lastName' => $order_info['payment_lastname'], - 'company' => $order_info['payment_company'], - 'streetAddress' => $order_info['payment_address_1'], - 'extendedAddress' => $order_info['payment_address_2'], - 'locality' => $order_info['payment_city'], - 'countryCodeAlpha2' => $order_info['payment_iso_code_2'], - 'postalCode' => $order_info['payment_postcode'], - 'region' => $order_info['payment_zone_code'] - ), - 'options' => array('three_d_secure' => array('required' => false)) - ); - - //Add shipping details - if ($this->cart->hasShipping()) { - $create_sale['shipping'] = array( - 'firstName' => $order_info['shipping_firstname'], - 'lastName' => $order_info['shipping_lastname'], - 'company' => $order_info['shipping_company'], - 'streetAddress' => $order_info['shipping_address_1'], - 'extendedAddress' => $order_info['shipping_address_2'], - 'locality' => $order_info['shipping_city'], - 'countryCodeAlpha2' => $order_info['shipping_iso_code_2'], - 'postalCode' => $order_info['shipping_postcode'], - 'region' => $order_info['shipping_zone_code'] - ); - } - - if ($this->customer->isLogged() && ($this->config->get('payment_pp_braintree_card_vault') || $this->config->get('payment_pp_braintree_paypal_vault'))) { - $customer_id = $this->customer_id_prefix . $this->customer->getId(); - - $vaulted_customer_info = $this->model_extension_payment_pp_braintree->getCustomer($this->gateway, $customer_id, false); - - if ($vaulted_customer_info) { - $create_sale['customerId'] = $customer_id; - } else { - $create_sale['customer']['id'] = $customer_id; - } - - if (isset($this->request->post['vault_method']) && $this->request->post['vault_method'] == '1') { - $create_sale['options']['storeInVaultOnSuccess'] = true; - } - } - - if ($payment_method_token != '') { - $create_sale['paymentMethodToken'] = $payment_method_token; - - // unset the billing info for a vaulted payment - $create_sale['billing'] = array(); - } - - if ($payment_method_nonce != '') { - $create_sale['paymentMethodNonce'] = $payment_method_nonce; - } - - if ($this->gateway == '') { - $merchant_accounts = $this->config->get('payment_pp_braintree_account'); - - foreach ($merchant_accounts as $merchant_account_currency => $merchant_account) { - if (($merchant_account_currency == $order_info['currency_code']) && !empty($merchant_account['merchant_account_id'])) { - $create_sale['merchantAccountId'] = $merchant_account['merchant_account_id']; - } - } - } - - if ($this->config->get('payment_pp_braintree_settlement_immediate') == 1) { - $create_sale['options']['submitForSettlement'] = true; - } else { - $create_sale['options']['submitForSettlement'] = false; - } - } - - // If the $payment_method_token is not empty it indicates the vaulted payment used CVV or was set to none - if ($success && (($this->config->get('payment_pp_braintree_3ds_status') == 1 && $payment_method_token == '') || ($this->config->get('payment_pp_braintree_vault_cvv_3ds') == '3ds' && $payment_method_token != ''))) { - $nonce_info = $this->model_extension_payment_pp_braintree->getPaymentMethodNonce($this->gateway, $payment_method_nonce); - - $this->model_extension_payment_pp_braintree->log($nonce_info); - - if ($nonce_info->type == 'CreditCard' && $this->config->get('payment_pp_braintree_3ds_status') == 1) { - $create_sale['options']['three_d_secure'] = array( - 'required' => true - ); - - $three_ds_info = array(); - - if (isset($nonce_info->threeDSecureInfo) && !empty($nonce_info->threeDSecureInfo)) { - $three_ds_info = $nonce_info->threeDSecureInfo; - } - - if (!empty($three_ds_info)) { - $success = false; - - switch ($three_ds_info->status) { - case 'unsupported_card': - if ($nonce_info->details['cardType'] == 'American Express') { - $success = true; - } else { - $success = $this->config->get('payment_pp_braintree_3ds_unsupported_card'); - } - break; - case 'lookup_error': - $success = $this->config->get('payment_pp_braintree_3ds_lookup_error'); - break; - case 'lookup_enrolled': - $success = $this->config->get('payment_pp_braintree_3ds_lookup_enrolled'); - break; - case 'lookup_not_enrolled': - $success = $this->config->get('payment_pp_braintree_3ds_lookup_not_enrolled'); - break; - case 'authenticate_successful_issuer_not_participating': - $success = $this->config->get('payment_pp_braintree_3ds_not_participating'); - break; - case 'authentication_unavailable': - $success = $this->config->get('payment_pp_braintree_3ds_unavailable'); - break; - case 'authenticate_signature_verification_failed': - $success = $this->config->get('payment_pp_braintree_3ds_signature_failed'); - break; - case 'authenticate_successful': - $success = $this->config->get('payment_pp_braintree_3ds_successful'); - break; - case 'authenticate_attempt_successful': - $success = $this->config->get('payment_pp_braintree_3ds_attempt_successful'); - break; - case 'authenticate_failed': - $success = $this->config->get('payment_pp_braintree_3ds_failed'); - break; - case 'authenticate_unable_to_authenticate': - $success = $this->config->get('payment_pp_braintree_3ds_unable_to_auth'); - break; - case 'authenticate_error': - $success = $this->config->get('payment_pp_braintree_3ds_error'); - break; - } - } else { - $this->model_extension_payment_pp_braintree->log('Liability shift failed, nonce was not 3D Secured'); - - $success = false; - } - } - } - $this->model_extension_payment_pp_braintree->log("Success:" . (int)$success); - - //Create transaction - if ($success) { - $transaction = $this->model_extension_payment_pp_braintree->addTransaction($this->gateway, $create_sale); - - $order_status_id = 0; - switch ($transaction->transaction->status) { - case 'authorization_expired': - $order_status_id = $this->config->get('payment_pp_braintree_authorization_expired_id'); - break; - case 'authorized': - $order_status_id = $this->config->get('payment_pp_braintree_authorized_id'); - break; - case 'authorizing': - $order_status_id = $this->config->get('payment_pp_braintree_authorizing_id'); - break; - case 'settlement_pending': - $order_status_id = $this->config->get('payment_pp_braintree_settlement_pending_id'); - break; - case 'failed': - $order_status_id = $this->config->get('payment_pp_braintree_failed_id'); - break; - case 'gateway_rejected': - $order_status_id = $this->config->get('payment_pp_braintree_gateway_rejected_id'); - break; - case 'processor_declined': - $order_status_id = $this->config->get('payment_pp_braintree_processor_declined_id'); - break; - case 'settled': - $order_status_id = $this->config->get('payment_pp_braintree_settled_id'); - break; - case 'settling': - $order_status_id = $this->config->get('payment_pp_braintree_settling_id'); - break; - case 'submitted_for_settlement': - $order_status_id = $this->config->get('payment_pp_braintree_submitted_for_settlement_id'); - break; - case 'voided': - $order_status_id = $this->config->get('payment_pp_braintree_voided_id'); - break; - } - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id); - - if ($transaction->success) { - $this->model_extension_payment_pp_braintree->log('Transaction success, details below'); - $this->model_extension_payment_pp_braintree->log($transaction); - - $this->response->redirect($this->url->link('checkout/success', '', true)); - } else { - $this->model_extension_payment_pp_braintree->log('Transaction failed, details below'); - $this->model_extension_payment_pp_braintree->log($transaction); - - $this->session->data['error'] = $this->language->get('error_process_order'); - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - } - - //If this is reached, transaction has failed - $this->model_extension_payment_pp_braintree->log('Transaction reached end of method without being handled, failure'); - - if (isset($this->session->data['order_id'])) { - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_pp_braintree_failed_id')); - } - - $this->response->redirect($this->url->link('checkout/failure', '', true)); - } - - public function nonce() { - $this->initialise(); - - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('extension/payment/pp_braintree'); - - $this->model_extension_payment_pp_braintree->log('Starting vaulted'); - $this->model_extension_payment_pp_braintree->log($this->request->post); - - $json = array(); - - $json['payment_method'] = ''; - - $success = true; - - if (!isset($this->request->post['vaulted_payment_token'])) { - $success = false; - } - - if ($success) { - $payment_method = $this->model_extension_payment_pp_braintree->createPaymentMethodNonce($this->gateway, $this->request->post['vaulted_payment_token']); - - if ($payment_method && $payment_method->success) { - $json['payment_method'] = array( - 'type' => $payment_method->paymentMethodNonce->type, - 'nonce' => $payment_method->paymentMethodNonce->nonce - ); - } else { - $success = false; - } - } - - $json['success'] = $success; - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function remove() { - $this->initialise(); - - $this->load->language('extension/payment/pp_braintree'); - - $this->load->model('extension/payment/pp_braintree'); - - $json = array(); - - $json['success'] = false; - - if (isset($this->request->post['vaulted_payment_method'])) { - $vaulted_payment_method = $this->request->post['vaulted_payment_method']; - } else { - $vaulted_payment_method = ''; - } - - $delete_payment_method = $this->model_extension_payment_pp_braintree->deletePaymentMethod($this->gateway, $vaulted_payment_method); - - if ($delete_payment_method) { - $json['success'] = $this->language->get('text_method_removed'); - } else { - $json['error'] = $this->language->get('text_method_not_removed'); - } - - $vaulted_customer_info = $this->model_extension_payment_pp_braintree->getCustomer($this->gateway, $this->customer_id_prefix . $this->customer->getId()); - - $vaulted_card_count = 0; - $vaulted_paypal_count = 0; - - if ($vaulted_customer_info->creditCards && $this->config->get('payment_pp_braintree_card_vault') == 1) { - $vaulted_card_count = count($vaulted_customer_info->creditCards); - } - - if ($vaulted_customer_info->paypalAccounts && $this->config->get('payment_pp_braintree_paypal_vault') == 1) { - $vaulted_paypal_count = count($vaulted_customer_info->paypalAccounts); - } - - $json['vaulted_payment_count'] = $vaulted_card_count + $vaulted_paypal_count; - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function expressSetup() { - // check checkout can continue due to stock checks or vouchers - if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { - $json = array(); - $json['error'] = true; - $json['url'] = $this->url->link('checkout/cart'); - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - // if user not logged in check that the guest checkout is allowed - if (!$this->customer->isLogged() && (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload() || $this->cart->hasRecurringProducts())) { - $json = array(); - $json['error'] = true; - $json['url'] = $this->url->link('checkout/checkout'); - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } else { - unset($this->session->data['guest']); - } - - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - unset($this->session->data['payment_method']); - unset($this->session->data['payment_methods']); - - if (!$this->customer->isLogged()) { - $this->session->data['paypal_braintree']['guest'] = true; - - $this->session->data['guest']['customer_group_id'] = $this->config->get('config_customer_group_id'); - $this->session->data['guest']['firstname'] = $this->request->post['details']['firstName']; - $this->session->data['guest']['lastname'] = $this->request->post['details']['lastName']; - $this->session->data['guest']['email'] = $this->request->post['details']['email']; - - if (isset($this->request->post['details']['phone'])) { - $this->session->data['guest']['telephone'] = $this->request->post['details']['phone']; - } else { - $this->session->data['guest']['telephone'] = ''; - } - - $this->session->data['guest']['payment']['company'] = ''; - - $this->session->data['guest']['payment']['firstname'] = $this->request->post['details']['firstName']; - $this->session->data['guest']['payment']['lastname'] = $this->request->post['details']['lastName']; - - $this->session->data['guest']['payment']['company_id'] = ''; - $this->session->data['guest']['payment']['tax_id'] = ''; - - if ($this->cart->hasShipping()) { - $shipping_name = explode(' ', $this->request->post['details']['shippingAddress']['recipientName']); - $shipping_first_name = $shipping_name[0]; - unset($shipping_name[0]); - $shipping_last_name = implode(' ', $shipping_name); - - $this->session->data['guest']['payment']['address_1'] = $this->request->post['details']['shippingAddress']['line1']; - if (isset($this->request->post['details']['shippingAddress']['line2'])) { - $this->session->data['guest']['payment']['address_2'] = $this->request->post['details']['shippingAddress']['line2']; - } else { - $this->session->data['guest']['payment']['address_2'] = ''; - } - - $this->session->data['guest']['payment']['postcode'] = $this->request->post['details']['shippingAddress']['postalCode']; - $this->session->data['guest']['payment']['city'] = $this->request->post['details']['shippingAddress']['city']; - - $this->session->data['guest']['shipping']['firstname'] = $shipping_first_name; - $this->session->data['guest']['shipping']['lastname'] = $shipping_last_name; - $this->session->data['guest']['shipping']['company'] = ''; - $this->session->data['guest']['shipping']['address_1'] = $this->request->post['details']['shippingAddress']['line1']; - - if (isset($this->request->post['details']['shippingAddress']['line2'])) { - $this->session->data['guest']['shipping']['address_2'] =$this->request->post['details']['shippingAddress']['line2']; - } else { - $this->session->data['guest']['shipping']['address_2'] = ''; - } - - $this->session->data['guest']['shipping']['postcode'] = $this->request->post['details']['shippingAddress']['postalCode']; - $this->session->data['guest']['shipping']['city'] = $this->request->post['details']['shippingAddress']['city']; - - $this->session->data['shipping_postcode'] = $this->request->post['details']['shippingAddress']['postalCode']; - - $country_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE `iso_code_2` = '" . $this->db->escape($this->request->post['details']['shippingAddress']['countryCode']) . "' AND `status` = '1' LIMIT 1")->row; - - if ($country_info) { - $this->session->data['guest']['shipping']['country_id'] = $country_info['country_id']; - $this->session->data['guest']['shipping']['country'] = $country_info['name']; - $this->session->data['guest']['shipping']['iso_code_2'] = $country_info['iso_code_2']; - $this->session->data['guest']['shipping']['iso_code_3'] = $country_info['iso_code_3']; - $this->session->data['guest']['shipping']['address_format'] = $country_info['address_format']; - $this->session->data['guest']['payment']['country_id'] = $country_info['country_id']; - $this->session->data['guest']['payment']['country'] = $country_info['name']; - $this->session->data['guest']['payment']['iso_code_2'] = $country_info['iso_code_2']; - $this->session->data['guest']['payment']['iso_code_3'] = $country_info['iso_code_3']; - $this->session->data['guest']['payment']['address_format'] = $country_info['address_format']; - $this->session->data['shipping_country_id'] = $country_info['country_id']; - - if (isset($this->request->post['details']['shippingAddress']['state'])) { - $returned_shipping_zone = $this->request->post['details']['shippingAddress']['state']; - } else { - $returned_shipping_zone = ''; - } - - $zone_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE (`name` = '" . $this->db->escape($returned_shipping_zone) . "' OR `code` = '" . $this->db->escape($returned_shipping_zone) . "') AND `status` = '1' AND `country_id` = '" . (int)$country_info['country_id'] . "' LIMIT 1")->row; - } else { - $this->session->data['guest']['shipping']['country_id'] = ''; - $this->session->data['guest']['shipping']['country'] = ''; - $this->session->data['guest']['shipping']['iso_code_2'] = ''; - $this->session->data['guest']['shipping']['iso_code_3'] = ''; - $this->session->data['guest']['shipping']['address_format'] = ''; - $this->session->data['guest']['payment']['country_id'] = ''; - $this->session->data['guest']['payment']['country'] = ''; - $this->session->data['guest']['payment']['iso_code_2'] = ''; - $this->session->data['guest']['payment']['iso_code_3'] = ''; - $this->session->data['guest']['payment']['address_format'] = ''; - $this->session->data['shipping_country_id'] = ''; - - $zone_info = array(); - } - - if ($zone_info) { - $this->session->data['guest']['shipping']['zone'] = $zone_info['name']; - $this->session->data['guest']['shipping']['zone_code'] = $zone_info['code']; - $this->session->data['guest']['shipping']['zone_id'] = $zone_info['zone_id']; - $this->session->data['guest']['payment']['zone'] = $zone_info['name']; - $this->session->data['guest']['payment']['zone_code'] = $zone_info['code']; - $this->session->data['guest']['payment']['zone_id'] = $zone_info['zone_id']; - $this->session->data['shipping_zone_id'] = $zone_info['zone_id']; - } else { - $this->session->data['guest']['shipping']['zone'] = ''; - $this->session->data['guest']['shipping']['zone_code'] = ''; - $this->session->data['guest']['shipping']['zone_id'] = ''; - $this->session->data['guest']['payment']['zone'] = ''; - $this->session->data['guest']['payment']['zone_code'] = ''; - $this->session->data['guest']['payment']['zone_id'] = ''; - $this->session->data['shipping_zone_id'] = ''; - } - - $this->session->data['guest']['shipping_address'] = true; - } else { - $this->session->data['guest']['payment']['address_1'] = ''; - $this->session->data['guest']['payment']['address_2'] = ''; - $this->session->data['guest']['payment']['postcode'] = ''; - $this->session->data['guest']['payment']['city'] = ''; - $this->session->data['guest']['payment']['country_id'] = ''; - $this->session->data['guest']['payment']['country'] = ''; - $this->session->data['guest']['payment']['iso_code_2'] = ''; - $this->session->data['guest']['payment']['iso_code_3'] = ''; - $this->session->data['guest']['payment']['address_format'] = ''; - $this->session->data['guest']['payment']['zone'] = ''; - $this->session->data['guest']['payment']['zone_code'] = ''; - $this->session->data['guest']['payment']['zone_id'] = ''; - $this->session->data['guest']['shipping_address'] = false; - } - - $this->session->data['account'] = 'guest'; - - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - unset($this->session->data['payment_method']); - unset($this->session->data['payment_methods']); - } else { - $this->session->data['paypal_braintree']['guest'] = false; - - unset($this->session->data['guest']); - /** - * if the user is logged in, add the address to the account and set the ID. - */ - - if ($this->cart->hasShipping()) { - $this->load->model('account/address'); - - $addresses = $this->model_account_address->getAddresses(); - - /** - * Compare all of the user addresses and see if there is a match - */ - $match = false; - foreach($addresses as $address) { - if (trim(strtolower($address['address_1'])) == trim(strtolower($this->request->post['details']['shippingAddress']['line1'])) && trim(strtolower($address['postcode'])) == trim(strtolower($this->request->post['details']['shippingAddress']['postalCode']))) { - $match = true; - - $this->session->data['payment_address_id'] = $address['address_id']; - $this->session->data['payment_country_id'] = $address['country_id']; - $this->session->data['payment_zone_id'] = $address['zone_id']; - - $this->session->data['shipping_address_id'] = $address['address_id']; - $this->session->data['shipping_country_id'] = $address['country_id']; - $this->session->data['shipping_zone_id'] = $address['zone_id']; - $this->session->data['shipping_postcode'] = $address['postcode']; - - break; - } - } - - /** - * If there is no address match add the address and set the info. - */ - if ($match == false) { - $shipping_name = explode(' ', trim($this->request->post['details']['shippingAddress']['recipientName'])); - $shipping_first_name = $shipping_name[0]; - unset($shipping_name[0]); - $shipping_last_name = implode(' ', $shipping_name); - - $country_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE `iso_code_2` = '" . $this->db->escape($this->request->post['details']['shippingAddress']['countryCode']) . "' AND `status` = '1' LIMIT 1")->row; - $zone_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE (`name` = '" . $this->db->escape($this->request->post['details']['shippingAddress']['state']) . "' OR `code` = '" . $this->db->escape($this->request->post['details']['shippingAddress']['state']) . "') AND `status` = '1' AND `country_id` = '" . (int)$country_info['country_id'] . "'")->row; - - $address_data = array( - 'firstname' => $shipping_first_name, - 'lastname' => $shipping_last_name, - 'company' => '', - 'company_id' => '', - 'tax_id' => '', - 'address_1' => $this->request->post['details']['shippingAddress']['line1'], - 'address_2' => (isset($this->request->post['details']['shippingAddress']['line2']) ? $this->request->post['details']['shippingAddress']['line2'] : ''), - 'postcode' => $this->request->post['details']['shippingAddress']['postalCode'], - 'city' => $this->request->post['details']['shippingAddress']['city'], - 'zone_id' => (isset($zone_info['zone_id']) ? $zone_info['zone_id'] : 0), - 'country_id' => (isset($country_info['country_id']) ? $country_info['country_id'] : 0) - ); - - $address_id = $this->model_account_address->addAddress($this->customer->getId(), $address_data); - - $this->session->data['payment_address_id'] = $address_id; - $this->session->data['payment_country_id'] = $address_data['country_id']; - $this->session->data['payment_zone_id'] = $address_data['zone_id']; - - $this->session->data['shipping_address_id'] = $address_id; - $this->session->data['shipping_country_id'] = $address_data['country_id']; - $this->session->data['shipping_zone_id'] = $address_data['zone_id']; - $this->session->data['shipping_postcode'] = $address_data['postcode']; - } - } else { - $this->session->data['payment_address_id'] = ''; - $this->session->data['payment_country_id'] = ''; - $this->session->data['payment_zone_id'] = ''; - } - } - - $this->session->data['paypal_braintree'] = $this->request->post; - - $json = array( - 'error' => false, - 'url' => '' - ); - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } - - public function expressConfirm() { - if (!isset($this->session->data['paypal_braintree']) || !isset($this->session->data['paypal_braintree']['nonce'])) { - $this->response->redirect($this->url->link('checkout/cart', '', true)); - } - - $this->load->language('extension/payment/pp_braintree'); - $this->load->language('checkout/cart'); - - $this->load->model('tool/image'); - $this->load->model('extension/payment/pp_braintree'); - - // Coupon - if (isset($this->request->post['coupon']) && $this->validateCoupon()) { - $this->session->data['coupon'] = $this->request->post['coupon']; - - $this->session->data['success'] = $this->language->get('text_coupon'); - - $this->response->redirect($this->url->link('extension/payment/pp_braintree/expressConfirm', '', true)); - } - - // Voucher - if (isset($this->request->post['voucher']) && $this->validateVoucher()) { - $this->session->data['voucher'] = $this->request->post['voucher']; - - $this->session->data['success'] = $this->language->get('text_voucher'); - - $this->response->redirect($this->url->link('extension/payment/pp_braintree/expressConfirm', '', true)); - } - - // Reward - if (isset($this->request->post['reward']) && $this->validateReward()) { - $this->session->data['reward'] = abs($this->request->post['reward']); - - $this->session->data['success'] = $this->language->get('text_reward'); - - $this->response->redirect($this->url->link('extension/payment/pp_braintree/expressConfirm', '', true)); - } - - $this->document->setTitle($this->language->get('text_express_title')); - - $data['heading_title'] = $this->language->get('text_express_title'); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('common/home'), - 'text' => $this->language->get('text_home') - ); - - $data['breadcrumbs'][] = array( - 'text' => $this->language->get('text_cart'), - 'href' => $this->url->link('checkout/cart') - ); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('extension/payment/pp_braintree/expressConfirm'), - 'text' => $this->language->get('text_express_title') - ); - - $points_total = 0; - - foreach ($this->cart->getProducts() as $product) { - if ($product['points']) { - $points_total += $product['points']; - } - } - - $data['column_name'] = $this->language->get('column_name'); - $data['column_model'] = $this->language->get('column_model'); - $data['column_quantity'] = $this->language->get('column_quantity'); - $data['column_price'] = $this->language->get('column_price'); - $data['column_total'] = $this->language->get('column_total'); - - $data['button_shipping'] = $this->language->get('button_express_shipping'); - $data['button_confirm'] = $this->language->get('button_express_confirm'); - - if (isset($this->request->post['next'])) { - $data['next'] = $this->request->post['next']; - } else { - $data['next'] = ''; - } - - $data['action'] = $this->url->link('extension/payment/pp_braintree/expressConfirm', '', true); - - $this->load->model('tool/upload'); - - $products = $this->cart->getProducts(); - - if (empty($products)) { - $this->response->redirect($this->url->link('checkout/cart', '', true)); - } - - foreach ($products as $product) { - $product_total = 0; - - foreach ($products as $product_2) { - if ($product_2['product_id'] == $product['product_id']) { - $product_total += $product_2['quantity']; - } - } - - if ($product['minimum'] > $product_total) { - $data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']); - } - - if ($product['image']) { - $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); - } else { - $image = ''; - } - - $option_data = array(); - - foreach ($product['option'] as $option) { - if ($option['type'] != 'file') { - $value = $option['value']; - } else { - $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); - - if ($upload_info) { - $value = $upload_info['name']; - } else { - $value = ''; - } - } - - $option_data[] = array( - 'name' => $option['name'], - 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ); - } - - // Display prices - if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')); - - $price = $this->currency->format($unit_price, $this->session->data['currency']); - $total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']); - } else { - $price = false; - $total = false; - } - - $data['products'][] = array( - 'cart_id' => $product['cart_id'], - 'thumb' => $image, - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'quantity' => $product['quantity'], - 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), - 'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''), - 'price' => $price, - 'total' => $total, - 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), - 'remove' => $this->url->link('checkout/cart', 'remove=' . $product['cart_id']), - ); - } - - $data['vouchers'] = array(); - - if ($this->cart->hasShipping()) { - $data['has_shipping'] = true; - /** - * Shipping services - */ - if ($this->customer->isLogged()) { - $this->load->model('account/address'); - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - if (!empty($shipping_address)) { - // Shipping Methods - $quote_data = array(); - - $this->load->model('setting/extension'); - - $results = $this->model_setting_extension->getExtensions('shipping'); - - if (!empty($results)) { - foreach ($results as $result) { - if ($this->config->get('shipping_' . $result['code'] . '_status')) { - $this->load->model('extension/shipping/' . $result['code']); - - $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($shipping_address); - - if ($quote) { - $quote_data[$result['code']] = array( - 'title' => $quote['title'], - 'quote' => $quote['quote'], - 'sort_order' => $quote['sort_order'], - 'error' => $quote['error'] - ); - } - } - } - - if (!empty($quote_data)) { - $sort_order = array(); - - foreach ($quote_data as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $quote_data); - - $this->session->data['shipping_methods'] = $quote_data; - $data['shipping_methods'] = $quote_data; - - if (!isset($this->session->data['shipping_method'])) { - //default the shipping to the very first option. - $key1 = key($quote_data); - $key2 = key($quote_data[$key1]['quote']); - $this->session->data['shipping_method'] = $quote_data[$key1]['quote'][$key2]; - } - - $data['code'] = $this->session->data['shipping_method']['code']; - $data['action_shipping'] = $this->url->link('extension/payment/pp_braintree/shipping', '', true); - } else { - unset($this->session->data['shipping_methods']); - unset($this->session->data['shipping_method']); - $data['error_no_shipping'] = $this->language->get('error_no_shipping'); - } - } else { - unset($this->session->data['shipping_methods']); - unset($this->session->data['shipping_method']); - $data['error_no_shipping'] = $this->language->get('error_no_shipping'); - } - } - } else { - $data['has_shipping'] = false; - } - - // Totals - $this->load->model('setting/extension'); - - $totals = array(); - $taxes = $this->cart->getTaxes(); - $total = 0; - - // Because __call can not keep var references so we put them into an array. - $total_data = array( - 'totals' => &$totals, - 'taxes' => &$taxes, - 'total' => &$total - ); - - // Display prices - if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = array(); - - $results = $this->model_setting_extension->getExtensions('total'); - - foreach ($results as $key => $value) { - $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); - } - - array_multisort($sort_order, SORT_ASC, $results); - - foreach ($results as $result) { - if ($this->config->get('total_' . $result['code'] . '_status')) { - $this->load->model('extension/total/' . $result['code']); - - // We have to put the totals in an array so that they pass by reference. - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); - } - } - - $sort_order = array(); - - foreach ($totals as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $totals); - } - - $data['totals'] = array(); - - foreach ($totals as $total) { - $data['totals'][] = array( - 'title' => $total['title'], - 'text' => $this->currency->format($total['value'], $this->session->data['currency']), - ); - } - - /** - * Payment methods - */ - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $this->load->model('account/address'); - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $payment_address = $this->session->data['guest']['payment']; - } - - $method_data = array(); - - $this->load->model('setting/extension'); - - $results = $this->model_setting_extension->getExtensions('payment'); - - $this->model_extension_payment_pp_braintree->log("Payment methods returned based on new data"); - $this->model_extension_payment_pp_braintree->log($results); - - foreach ($results as $result) { - if ($this->config->get('payment_' . $result['code'] . '_status')) { - $this->load->model('extension/payment/' . $result['code']); - - $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($payment_address, $total); - - if ($method) { - $method_data[$result['code']] = $method; - } - } - } - - $sort_order = array(); - - foreach ($method_data as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $method_data); - - $this->model_extension_payment_pp_braintree->log("Payment methods again - sorted"); - $this->model_extension_payment_pp_braintree->log($method_data); - - if (!isset($method_data['pp_braintree'])) { - $this->model_extension_payment_pp_braintree->log("Braintree module was no longer an option. Check configured zones or minimum order amount based on user address info"); - $this->session->data['error_warning'] = $this->language->get('error_unavailable'); - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - - $this->session->data['payment_methods'] = $method_data; - $this->session->data['payment_method'] = $method_data['pp_braintree']; - - $data['action_confirm'] = $this->url->link('extension/payment/pp_braintree/expressComplete', '', true); - - if (isset($this->session->data['error_warning'])) { - $data['error_warning'] = $this->session->data['error_warning']; - unset($this->session->data['error_warning']); - } else { - $data['error_warning'] = ''; - } - - if (isset($this->session->data['success'])) { - $data['success'] = $this->session->data['success']; - unset($this->session->data['success']); - } else { - $data['success'] = ''; - } - - if (isset($this->session->data['attention'])) { - $data['attention'] = $this->session->data['attention']; - unset($this->session->data['attention']); - } else { - $data['attention'] = ''; - } - - $data['coupon'] = $this->load->controller('extension/total/coupon'); - $data['voucher'] = $this->load->controller('extension/total/voucher'); - $data['reward'] = $this->load->controller('extension/total/reward'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['column_right'] = $this->load->controller('common/column_right'); - $data['content_top'] = $this->load->controller('common/content_top'); - $data['content_bottom'] = $this->load->controller('common/content_bottom'); - $data['footer'] = $this->load->controller('common/footer'); - $data['header'] = $this->load->controller('common/header'); - - $this->response->setOutput($this->load->view('extension/payment/pp_braintree_confirm', $data)); - } - - public function expressComplete() { - if (!isset($this->session->data['paypal_braintree']) || !isset($this->session->data['paypal_braintree']['nonce'])) { - $this->response->redirect($this->url->link('checkout/cart', '', true)); - } - - $this->load->language('extension/payment/pp_braintree'); - $redirect = ''; - - if ($this->cart->hasShipping()) { - // Validate if shipping address has been set. - $this->load->model('account/address'); - - if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) { - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - if (empty($shipping_address)) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - - // Validate if shipping method has been set. - if (!isset($this->session->data['shipping_method'])) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - } else { - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - } - - // Validate if payment address has been set. - $this->load->model('account/address'); - - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $payment_address = $this->session->data['guest']['payment']; - } - - // Validate if payment method has been set. - if (!isset($this->session->data['payment_method'])) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - - // Validate cart has products and has stock. - if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { - $redirect = $this->url->link('checkout/cart'); - } - - // Validate minimum quantity requirements. - $products = $this->cart->getProducts(); - - foreach ($products as $product) { - $product_total = 0; - - foreach ($products as $product_2) { - if ($product_2['product_id'] == $product['product_id']) { - $product_total += $product_2['quantity']; - } - } - - if ($product['minimum'] > $product_total) { - $redirect = $this->url->link('checkout/cart'); - - break; - } - } - - if ($redirect == '') { - $totals = array(); - $taxes = $this->cart->getTaxes(); - $total = 0; - - // Because __call can not keep var references so we put them into an array. - $total_data = array( - 'totals' => &$totals, - 'taxes' => &$taxes, - 'total' => &$total - ); - - $this->load->model('setting/extension'); - - $sort_order = array(); - - $results = $this->model_setting_extension->getExtensions('total'); - - foreach ($results as $key => $value) { - $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); - } - - array_multisort($sort_order, SORT_ASC, $results); - - foreach ($results as $result) { - if ($this->config->get('total_' . $result['code'] . '_status')) { - $this->load->model('extension/total/' . $result['code']); - - // We have to put the totals in an array so that they pass by reference. - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); - } - } - - $sort_order = array(); - - foreach ($totals as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $totals); - - $this->load->language('checkout/checkout'); - - $data = array(); - - $data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); - $data['store_id'] = $this->config->get('config_store_id'); - $data['store_name'] = $this->config->get('config_name'); - - if ($data['store_id']) { - $data['store_url'] = $this->config->get('config_url'); - } else { - $data['store_url'] = HTTP_SERVER; - } - - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $data['customer_id'] = $this->customer->getId(); - $data['customer_group_id'] = $this->config->get('config_customer_group_id'); - $data['firstname'] = $this->customer->getFirstName(); - $data['lastname'] = $this->customer->getLastName(); - $data['email'] = $this->customer->getEmail(); - $data['telephone'] = $this->customer->getTelephone(); - - $this->load->model('account/address'); - - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $data['customer_id'] = 0; - $data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; - $data['firstname'] = $this->session->data['guest']['firstname']; - $data['lastname'] = $this->session->data['guest']['lastname']; - $data['email'] = $this->session->data['guest']['email']; - $data['telephone'] = $this->session->data['guest']['telephone']; - - $payment_address = $this->session->data['guest']['payment']; - } - - $data['payment_firstname'] = isset($payment_address['firstname']) ? $payment_address['firstname'] : ''; - $data['payment_lastname'] = isset($payment_address['lastname']) ? $payment_address['lastname'] : ''; - $data['payment_company'] = isset($payment_address['company']) ? $payment_address['company'] : ''; - $data['payment_company_id'] = isset($payment_address['company_id']) ? $payment_address['company_id'] : ''; - $data['payment_tax_id'] = isset($payment_address['tax_id']) ? $payment_address['tax_id'] : ''; - $data['payment_address_1'] = isset($payment_address['address_1']) ? $payment_address['address_1'] : ''; - $data['payment_address_2'] = isset($payment_address['address_2']) ? $payment_address['address_2'] : ''; - $data['payment_city'] = isset($payment_address['city']) ? $payment_address['city'] : ''; - $data['payment_postcode'] = isset($payment_address['postcode']) ? $payment_address['postcode'] : ''; - $data['payment_zone'] = isset($payment_address['zone']) ? $payment_address['zone'] : ''; - $data['payment_zone_id'] = isset($payment_address['zone_id']) ? $payment_address['zone_id'] : ''; - $data['payment_country'] = isset($payment_address['country']) ? $payment_address['country'] : ''; - $data['payment_country_id'] = isset($payment_address['country_id']) ? $payment_address['country_id'] : ''; - $data['payment_address_format'] = isset($payment_address['address_format']) ? $payment_address['address_format'] : ''; - - $data['payment_method'] = ''; - if (isset($this->session->data['payment_method']['title'])) { - $data['payment_method'] = $this->session->data['payment_method']['title']; - } - - $data['payment_code'] = ''; - if (isset($this->session->data['payment_method']['code'])) { - $data['payment_code'] = $this->session->data['payment_method']['code']; - } - - if ($this->cart->hasShipping()) { - if ($this->customer->isLogged()) { - $this->load->model('account/address'); - - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - $data['shipping_firstname'] = $shipping_address['firstname']; - $data['shipping_lastname'] = $shipping_address['lastname']; - $data['shipping_company'] = $shipping_address['company']; - $data['shipping_address_1'] = $shipping_address['address_1']; - $data['shipping_address_2'] = $shipping_address['address_2']; - $data['shipping_city'] = $shipping_address['city']; - $data['shipping_postcode'] = $shipping_address['postcode']; - $data['shipping_zone'] = $shipping_address['zone']; - $data['shipping_zone_id'] = $shipping_address['zone_id']; - $data['shipping_country'] = $shipping_address['country']; - $data['shipping_country_id'] = $shipping_address['country_id']; - $data['shipping_address_format'] = $shipping_address['address_format']; - - $data['shipping_method'] = ''; - if (isset($this->session->data['shipping_method']['title'])) { - $data['shipping_method'] = $this->session->data['shipping_method']['title']; - } - - $data['shipping_code'] = ''; - if (isset($this->session->data['shipping_method']['code'])) { - $data['shipping_code'] = $this->session->data['shipping_method']['code']; - } - } else { - $data['shipping_firstname'] = ''; - $data['shipping_lastname'] = ''; - $data['shipping_company'] = ''; - $data['shipping_address_1'] = ''; - $data['shipping_address_2'] = ''; - $data['shipping_city'] = ''; - $data['shipping_postcode'] = ''; - $data['shipping_zone'] = ''; - $data['shipping_zone_id'] = ''; - $data['shipping_country'] = ''; - $data['shipping_country_id'] = ''; - $data['shipping_address_format'] = ''; - $data['shipping_method'] = ''; - $data['shipping_code'] = ''; - } - - $product_data = array(); - - foreach ($this->cart->getProducts() as $product) { - $option_data = array(); - - foreach ($product['option'] as $option) { - $option_data[] = array( - 'product_option_id' => $option['product_option_id'], - 'product_option_value_id' => $option['product_option_value_id'], - 'option_id' => $option['option_id'], - 'option_value_id' => $option['option_value_id'], - 'name' => $option['name'], - 'value' => $option['value'], - 'type' => $option['type'] - ); - } - - $product_data[] = array( - 'product_id' => $product['product_id'], - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'download' => $product['download'], - 'quantity' => $product['quantity'], - 'subtract' => $product['subtract'], - 'price' => $product['price'], - 'total' => $product['total'], - 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), - 'reward' => $product['reward'] - ); - } - - // Gift Voucher - $voucher_data = array(); - - if (!empty($this->session->data['vouchers'])) { - foreach ($this->session->data['vouchers'] as $voucher) { - $voucher_data[] = array( - 'description' => $voucher['description'], - 'code' => token(10), - 'to_name' => $voucher['to_name'], - 'to_email' => $voucher['to_email'], - 'from_name' => $voucher['from_name'], - 'from_email' => $voucher['from_email'], - 'voucher_theme_id' => $voucher['voucher_theme_id'], - 'message' => $voucher['message'], - 'amount' => $voucher['amount'] - ); - } - } - - $data['products'] = $product_data; - $data['vouchers'] = $voucher_data; - $data['totals'] = $totals; - $data['total'] = $total; - $data['comment'] = ''; - - if (isset($this->request->cookie['tracking'])) { - $data['tracking'] = $this->request->cookie['tracking']; - - $subtotal = $this->cart->getSubTotal(); - - // Affiliate - $this->load->model('affiliate/affiliate'); - - $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']); - - if ($affiliate_info) { - $data['affiliate_id'] = $affiliate_info['affiliate_id']; - $data['commission'] = ($subtotal / 100) * $affiliate_info['commission']; - } else { - $data['affiliate_id'] = 0; - $data['commission'] = 0; - } - - // Marketing - $this->load->model('checkout/marketing'); - - $marketing_info = $this->model_checkout_marketing->getMarketingByCode($this->request->cookie['tracking']); - - if ($marketing_info) { - $data['marketing_id'] = $marketing_info['marketing_id']; - } else { - $data['marketing_id'] = 0; - } - } else { - $data['affiliate_id'] = 0; - $data['commission'] = 0; - $data['marketing_id'] = 0; - $data['tracking'] = ''; - } - - $data['language_id'] = $this->config->get('config_language_id'); - $data['currency_id'] = $this->currency->getId($this->session->data['currency']); - $data['currency_code'] = $this->session->data['currency']; - $data['currency_value'] = $this->currency->getValue($this->session->data['currency']); - $data['ip'] = $this->request->server['REMOTE_ADDR']; - - if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) { - $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR']; - } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) { - $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP']; - } else { - $data['forwarded_ip'] = ''; - } - - if (isset($this->request->server['HTTP_USER_AGENT'])) { - $data['user_agent'] = $this->request->server['HTTP_USER_AGENT']; - } else { - $data['user_agent'] = ''; - } - - if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { - $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE']; - } else { - $data['accept_language'] = ''; - } - - $this->load->model('account/custom_field'); - $this->load->model('checkout/order'); - - $order_id = $this->model_checkout_order->addOrder($data); - $this->session->data['order_id'] = $order_id; - - $this->load->model('extension/payment/pp_braintree'); - - $this->initialise(); - - $create_sale = [ - "amount" => $this->currency->format($data['total'], $data['currency_code'], $data['currency_value'], false), - "paymentMethodNonce" => $this->session->data['paypal_braintree']['nonce'], - "orderId" => $order_id, - 'channel' => 'OpenCart_Cart_vzero', - ]; - - $transaction = $this->model_extension_payment_pp_braintree->addTransaction($this->gateway, $create_sale); - - //handle order status - - $order_status_id = 0; - switch ($transaction->transaction->status) { - case 'authorization_expired': - $order_status_id = $this->config->get('payment_pp_braintree_authorization_expired_id'); - break; - case 'authorized': - $order_status_id = $this->config->get('payment_pp_braintree_authorized_id'); - break; - case 'authorizing': - $order_status_id = $this->config->get('payment_pp_braintree_authorizing_id'); - break; - case 'settlement_pending': - $order_status_id = $this->config->get('payment_pp_braintree_settlement_pending_id'); - break; - case 'failed': - $order_status_id = $this->config->get('payment_pp_braintree_failed_id'); - break; - case 'gateway_rejected': - $order_status_id = $this->config->get('payment_pp_braintree_gateway_rejected_id'); - break; - case 'processor_declined': - $order_status_id = $this->config->get('payment_pp_braintree_processor_declined_id'); - break; - case 'settled': - $order_status_id = $this->config->get('payment_pp_braintree_settled_id'); - break; - case 'settling': - $order_status_id = $this->config->get('payment_pp_braintree_settling_id'); - break; - case 'submitted_for_settlement': - $order_status_id = $this->config->get('payment_pp_braintree_submitted_for_settlement_id'); - break; - case 'voided': - $order_status_id = $this->config->get('payment_pp_braintree_voided_id'); - break; - } - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id); - - if ($transaction->success) { - $this->model_extension_payment_pp_braintree->log('Transaction success, details below'); - $this->model_extension_payment_pp_braintree->log($transaction); - - $this->response->redirect($this->url->link('checkout/success', '', true)); - } else { - $this->model_extension_payment_pp_braintree->log('Transaction failed, details below'); - $this->model_extension_payment_pp_braintree->log($transaction); - - $this->session->data['error'] = $this->language->get('error_process_order'); - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - } else { - $this->response->redirect($redirect); - } - } - - private function initialise() { - $this->load->model('extension/payment/pp_braintree'); - - if ($this->config->get('payment_pp_braintree_access_token') != '') { - $this->gateway = $this->model_extension_payment_pp_braintree->setGateway($this->config->get('payment_pp_braintree_access_token')); - } else { - $this->model_extension_payment_pp_braintree->setCredentials(); - } - } - - public function shipping() { - $this->shippingValidate($this->request->post['shipping_method']); - - $this->response->redirect($this->url->link('extension/payment/pp_braintree/expressConfirm')); - } - - protected function shippingValidate($code) { - $this->load->language('checkout/cart'); - $this->load->language('extension/payment/pp_braintree'); - - if (empty($code)) { - $this->session->data['error_warning'] = $this->language->get('error_shipping'); - return false; - } else { - $shipping = explode('.', $code); - - if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { - $this->session->data['error_warning'] = $this->language->get('error_shipping'); - return false; - } else { - $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; - $this->session->data['success'] = $this->language->get('text_shipping_updated'); - return true; - } - } - } - - protected function validateCoupon() { - $this->load->model('extension/total/coupon'); - - $coupon_info = $this->model_extension_total_coupon->getCoupon($this->request->post['coupon']); - - if ($coupon_info) { - return true; - } else { - $this->session->data['error_warning'] = $this->language->get('error_coupon'); - return false; - } - } - - protected function validateVoucher() { - $this->load->model('extension/total/coupon'); - - $voucher_info = $this->model_extension_total_voucher->getVoucher($this->request->post['voucher']); - - if ($voucher_info) { - return true; - } else { - $this->session->data['error_warning'] = $this->language->get('error_voucher'); - return false; - } - } - - protected function validateReward() { - $points = $this->customer->getRewardPoints(); - - $points_total = 0; - - foreach ($this->cart->getProducts() as $product) { - if ($product['points']) { - $points_total += $product['points']; - } - } - - $error = ''; - - if (empty($this->request->post['reward'])) { - $error = $this->language->get('error_reward'); - } - - if ($this->request->post['reward'] > $points) { - $error = sprintf($this->language->get('error_points'), $this->request->post['reward']); - } - - if ($this->request->post['reward'] > $points_total) { - $error = sprintf($this->language->get('error_maximum'), $points_total); - } - - if (!$error) { - return true; - } else { - $this->session->data['error_warning'] = $error; - return false; - } - } -} diff --git a/upload/catalog/controller/extension/payment/pp_express.php b/upload/catalog/controller/extension/payment/pp_express.php deleted file mode 100644 index e642cde0938..00000000000 --- a/upload/catalog/controller/extension/payment/pp_express.php +++ /dev/null @@ -1,1935 +0,0 @@ -load->language('extension/payment/pp_express'); - - $data['payment_pp_express_incontext_disable'] = $this->config->get('payment_pp_express_incontext_disable'); - - if ($this->config->get('payment_pp_express_test') == 1) { - $data['username'] = $this->config->get('payment_pp_express_sandbox_username'); - } else { - $data['username'] = $this->config->get('payment_pp_express_username'); - } - - $data['continue'] = $this->url->link('extension/payment/pp_express/checkout', '', true); - - unset($this->session->data['paypal']); - - return $this->load->view('extension/payment/pp_express', $data); - } - - public function express() { - $this->load->model('extension/payment/pp_express'); - - if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { - $this->response->redirect($this->url->link('checkout/cart')); - } - - if ($this->customer->isLogged()) { - /** - * If the customer is already logged in - */ - $this->session->data['paypal']['guest'] = false; - - unset($this->session->data['guest']); - } else { - if ($this->config->get('config_checkout_guest') && !$this->config->get('config_customer_price') && !$this->cart->hasDownload() && !$this->cart->hasRecurringProducts()) { - /** - * If the guest checkout is allowed (config ok, no login for price and doesn't have downloads) - */ - $this->session->data['paypal']['guest'] = true; - } else { - /** - * If guest checkout disabled or login is required before price or order has downloads - * - * Send them to the normal checkout flow. - */ - unset($this->session->data['guest']); - - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - } - - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - unset($this->session->data['payment_method']); - unset($this->session->data['payment_methods']); - - $this->load->model('tool/image'); - - if ($this->cart->hasShipping()) { - $shipping = 2; - } else { - $shipping = 1; - } - - $max_amount = $this->cart->getTotal() * 1.5; - $max_amount = $this->currency->format($max_amount, $this->session->data['currency'], '', false); - - $data = array( - 'METHOD' => 'SetExpressCheckout', - 'MAXAMT' => $max_amount, - 'RETURNURL' => $this->url->link('extension/payment/pp_express/expressReturn', '', true), - 'CANCELURL' => $this->url->link('checkout/cart', '', true), - 'REQCONFIRMSHIPPING' => 0, - 'NOSHIPPING' => $shipping, - 'ALLOWNOTE' => $this->config->get('payment_pp_express_allow_note'), - 'LOCALECODE' => 'EN', - 'LANDINGPAGE' => 'Login', - 'HDRIMG' => $this->model_tool_image->resize($this->config->get('payment_pp_express_logo'), 750, 90), - 'PAYFLOWCOLOR' => $this->config->get('payment_pp_express_colour'), - 'CHANNELTYPE' => 'Merchant' - ); - - if (isset($this->session->data['pp_login']['seamless']['access_token']) && (isset($this->session->data['pp_login']['seamless']['customer_id']) && $this->session->data['pp_login']['seamless']['customer_id'] == $this->customer->getId()) && $this->config->get('module_pp_login_seamless')) { - $data['IDENTITYACCESSTOKEN'] = $this->session->data['pp_login']['seamless']['access_token']; - } - - $data = array_merge($data, $this->model_extension_payment_pp_express->paymentRequestInfo()); - - $result = $this->model_extension_payment_pp_express->call($data); - - /** - * If a failed PayPal setup happens, handle it. - */ - if (!isset($result['TOKEN'])) { - $this->session->data['error'] = $result['L_LONGMESSAGE0']; - /** - * Unable to add error message to user as the session errors/success are not - * used on the cart or checkout pages - need to be added? - * If PayPal debug log is off then still log error to normal error log. - */ - - $this->log->write('Unable to create PayPal call: ' . json_encode($result)); - - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - - $this->session->data['paypal']['token'] = $result['TOKEN']; - - if ($this->config->get('payment_pp_express_test') == 1) { - header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN']); - } else { - header('Location: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN']); - } - } - - public function expressReturn() { - /** - * This is the url when PayPal has completed the auth. - * - * It has no output, instead it sets the data and locates to checkout - */ - $this->load->model('extension/payment/pp_express'); - $data = array( - 'METHOD' => 'GetExpressCheckoutDetails', - 'TOKEN' => $this->session->data['paypal']['token'] - ); - - $result = $this->model_extension_payment_pp_express->call($data); - $this->session->data['paypal']['payerid'] = $result['PAYERID']; - $this->session->data['paypal']['result'] = $result; - - $this->session->data['comment'] = ''; - if (isset($result['PAYMENTREQUEST_0_NOTETEXT'])) { - $this->session->data['comment'] = $result['PAYMENTREQUEST_0_NOTETEXT']; - } - - if ($this->session->data['paypal']['guest'] == true) { - - $this->session->data['guest']['customer_group_id'] = $this->config->get('config_customer_group_id'); - $this->session->data['guest']['firstname'] = trim($result['FIRSTNAME']); - $this->session->data['guest']['lastname'] = trim($result['LASTNAME']); - $this->session->data['guest']['email'] = trim($result['EMAIL']); - - if (isset($result['PHONENUM'])) { - $this->session->data['guest']['telephone'] = $result['PHONENUM']; - } else { - $this->session->data['guest']['telephone'] = ''; - } - - $this->session->data['guest']['payment']['firstname'] = trim($result['FIRSTNAME']); - $this->session->data['guest']['payment']['lastname'] = trim($result['LASTNAME']); - - if (isset($result['BUSINESS'])) { - $this->session->data['guest']['payment']['company'] = $result['BUSINESS']; - } else { - $this->session->data['guest']['payment']['company'] = ''; - } - - $this->session->data['guest']['payment']['company_id'] = ''; - $this->session->data['guest']['payment']['tax_id'] = ''; - - if ($this->cart->hasShipping()) { - $shipping_name = explode(' ', trim($result['PAYMENTREQUEST_0_SHIPTONAME'])); - $shipping_first_name = $shipping_name[0]; - unset($shipping_name[0]); - $shipping_last_name = implode(' ', $shipping_name); - - $this->session->data['guest']['payment']['address_1'] = $result['PAYMENTREQUEST_0_SHIPTOSTREET']; - if (isset($result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) { - $this->session->data['guest']['payment']['address_2'] = $result['PAYMENTREQUEST_0_SHIPTOSTREET2']; - } else { - $this->session->data['guest']['payment']['address_2'] = ''; - } - - $this->session->data['guest']['payment']['postcode'] = $result['PAYMENTREQUEST_0_SHIPTOZIP']; - $this->session->data['guest']['payment']['city'] = $result['PAYMENTREQUEST_0_SHIPTOCITY']; - - $this->session->data['guest']['shipping']['firstname'] = $shipping_first_name; - $this->session->data['guest']['shipping']['lastname'] = $shipping_last_name; - $this->session->data['guest']['shipping']['company'] = ''; - $this->session->data['guest']['shipping']['address_1'] = $result['PAYMENTREQUEST_0_SHIPTOSTREET']; - - if (isset($result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) { - $this->session->data['guest']['shipping']['address_2'] = $result['PAYMENTREQUEST_0_SHIPTOSTREET2']; - } else { - $this->session->data['guest']['shipping']['address_2'] = ''; - } - - $this->session->data['guest']['shipping']['postcode'] = $result['PAYMENTREQUEST_0_SHIPTOZIP']; - $this->session->data['guest']['shipping']['city'] = $result['PAYMENTREQUEST_0_SHIPTOCITY']; - - $this->session->data['shipping_postcode'] = $result['PAYMENTREQUEST_0_SHIPTOZIP']; - - $country_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE `iso_code_2` = '" . $this->db->escape($result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']) . "' AND `status` = '1' LIMIT 1")->row; - - if ($country_info) { - $this->session->data['guest']['shipping']['country_id'] = $country_info['country_id']; - $this->session->data['guest']['shipping']['country'] = $country_info['name']; - $this->session->data['guest']['shipping']['iso_code_2'] = $country_info['iso_code_2']; - $this->session->data['guest']['shipping']['iso_code_3'] = $country_info['iso_code_3']; - $this->session->data['guest']['shipping']['address_format'] = $country_info['address_format']; - $this->session->data['guest']['payment']['country_id'] = $country_info['country_id']; - $this->session->data['guest']['payment']['country'] = $country_info['name']; - $this->session->data['guest']['payment']['iso_code_2'] = $country_info['iso_code_2']; - $this->session->data['guest']['payment']['iso_code_3'] = $country_info['iso_code_3']; - $this->session->data['guest']['payment']['address_format'] = $country_info['address_format']; - $this->session->data['shipping_country_id'] = $country_info['country_id']; - } else { - $this->session->data['guest']['shipping']['country_id'] = ''; - $this->session->data['guest']['shipping']['country'] = ''; - $this->session->data['guest']['shipping']['iso_code_2'] = ''; - $this->session->data['guest']['shipping']['iso_code_3'] = ''; - $this->session->data['guest']['shipping']['address_format'] = ''; - $this->session->data['guest']['payment']['country_id'] = ''; - $this->session->data['guest']['payment']['country'] = ''; - $this->session->data['guest']['payment']['iso_code_2'] = ''; - $this->session->data['guest']['payment']['iso_code_3'] = ''; - $this->session->data['guest']['payment']['address_format'] = ''; - $this->session->data['shipping_country_id'] = ''; - } - - if (isset($result['PAYMENTREQUEST_0_SHIPTOSTATE'])) { - $returned_shipping_zone = $result['PAYMENTREQUEST_0_SHIPTOSTATE']; - } else { - $returned_shipping_zone = ''; - } - - $zone_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE (`name` = '" . $this->db->escape($returned_shipping_zone) . "' OR `code` = '" . $this->db->escape($returned_shipping_zone) . "') AND `status` = '1' AND `country_id` = '" . (int)$country_info['country_id'] . "' LIMIT 1")->row; - - if ($zone_info) { - $this->session->data['guest']['shipping']['zone'] = $zone_info['name']; - $this->session->data['guest']['shipping']['zone_code'] = $zone_info['code']; - $this->session->data['guest']['shipping']['zone_id'] = $zone_info['zone_id']; - $this->session->data['guest']['payment']['zone'] = $zone_info['name']; - $this->session->data['guest']['payment']['zone_code'] = $zone_info['code']; - $this->session->data['guest']['payment']['zone_id'] = $zone_info['zone_id']; - $this->session->data['shipping_zone_id'] = $zone_info['zone_id']; - } else { - $this->session->data['guest']['shipping']['zone'] = ''; - $this->session->data['guest']['shipping']['zone_code'] = ''; - $this->session->data['guest']['shipping']['zone_id'] = ''; - $this->session->data['guest']['payment']['zone'] = ''; - $this->session->data['guest']['payment']['zone_code'] = ''; - $this->session->data['guest']['payment']['zone_id'] = ''; - $this->session->data['shipping_zone_id'] = ''; - } - - $this->session->data['guest']['shipping_address'] = true; - } else { - $this->session->data['guest']['payment']['address_1'] = ''; - $this->session->data['guest']['payment']['address_2'] = ''; - $this->session->data['guest']['payment']['postcode'] = ''; - $this->session->data['guest']['payment']['city'] = ''; - $this->session->data['guest']['payment']['country_id'] = ''; - $this->session->data['guest']['payment']['country'] = ''; - $this->session->data['guest']['payment']['iso_code_2'] = ''; - $this->session->data['guest']['payment']['iso_code_3'] = ''; - $this->session->data['guest']['payment']['address_format'] = ''; - $this->session->data['guest']['payment']['zone'] = ''; - $this->session->data['guest']['payment']['zone_code'] = ''; - $this->session->data['guest']['payment']['zone_id'] = ''; - $this->session->data['guest']['shipping_address'] = false; - } - - $this->session->data['account'] = 'guest'; - - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - unset($this->session->data['payment_method']); - unset($this->session->data['payment_methods']); - } else { - unset($this->session->data['guest']); - /** - * if the user is logged in, add the address to the account and set the ID. - */ - - if ($this->cart->hasShipping()) { - $this->load->model('account/address'); - - $addresses = $this->model_account_address->getAddresses(); - - /** - * Compare all of the user addresses and see if there is a match - */ - $match = false; - foreach($addresses as $address) { - if (trim(strtolower($address['address_1'])) == trim(strtolower($result['PAYMENTREQUEST_0_SHIPTOSTREET'])) && trim(strtolower($address['postcode'])) == trim(strtolower($result['PAYMENTREQUEST_0_SHIPTOZIP']))) { - $match = true; - - $this->session->data['payment_address_id'] = $address['address_id']; - $this->session->data['payment_country_id'] = $address['country_id']; - $this->session->data['payment_zone_id'] = $address['zone_id']; - - $this->session->data['shipping_address_id'] = $address['address_id']; - $this->session->data['shipping_country_id'] = $address['country_id']; - $this->session->data['shipping_zone_id'] = $address['zone_id']; - $this->session->data['shipping_postcode'] = $address['postcode']; - - break; - } - } - - /** - * If there is no address match add the address and set the info. - */ - if ($match == false) { - - $shipping_name = explode(' ', trim($result['PAYMENTREQUEST_0_SHIPTONAME'])); - $shipping_first_name = $shipping_name[0]; - unset($shipping_name[0]); - $shipping_last_name = implode(' ', $shipping_name); - - $country_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE `iso_code_2` = '" . $this->db->escape($result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']) . "' AND `status` = '1' LIMIT 1")->row; - $zone_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE (`name` = '" . $this->db->escape($result['PAYMENTREQUEST_0_SHIPTOSTATE']) . "' OR `code` = '" . $this->db->escape($result['PAYMENTREQUEST_0_SHIPTOSTATE']) . "') AND `status` = '1' AND `country_id` = '" . (int)$country_info['country_id'] . "'")->row; - - $address_data = array( - 'firstname' => $shipping_first_name, - 'lastname' => $shipping_last_name, - 'company' => '', - 'company_id' => '', - 'tax_id' => '', - 'address_1' => $result['PAYMENTREQUEST_0_SHIPTOSTREET'], - 'address_2' => (isset($result['PAYMENTREQUEST_0_SHIPTOSTREET2']) ? $result['PAYMENTREQUEST_0_SHIPTOSTREET2'] : ''), - 'postcode' => $result['PAYMENTREQUEST_0_SHIPTOZIP'], - 'city' => $result['PAYMENTREQUEST_0_SHIPTOCITY'], - 'zone_id' => (isset($zone_info['zone_id']) ? $zone_info['zone_id'] : 0), - 'country_id' => (isset($country_info['country_id']) ? $country_info['country_id'] : 0) - ); - - $address_id = $this->model_account_address->addAddress($this->customer->getId(), $address_data); - - $this->session->data['payment_address_id'] = $address_id; - $this->session->data['payment_country_id'] = $address_data['country_id']; - $this->session->data['payment_zone_id'] = $address_data['zone_id']; - - $this->session->data['shipping_address_id'] = $address_id; - $this->session->data['shipping_country_id'] = $address_data['country_id']; - $this->session->data['shipping_zone_id'] = $address_data['zone_id']; - $this->session->data['shipping_postcode'] = $address_data['postcode']; - } - } else { - $this->session->data['payment_address_id'] = ''; - $this->session->data['payment_country_id'] = ''; - $this->session->data['payment_zone_id'] = ''; - } - } - - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm', '', true)); - } - - public function expressConfirm() { - $this->load->language('extension/payment/pp_express'); - $this->load->language('checkout/cart'); - - $this->load->model('tool/image'); - - // Coupon - if (isset($this->request->post['coupon']) && $this->validateCoupon()) { - $this->session->data['coupon'] = $this->request->post['coupon']; - - $this->session->data['success'] = $this->language->get('text_coupon'); - - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm', '', true)); - } - - // Voucher - if (isset($this->request->post['voucher']) && $this->validateVoucher()) { - $this->session->data['voucher'] = $this->request->post['voucher']; - - $this->session->data['success'] = $this->language->get('text_voucher'); - - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm', '', true)); - } - - // Reward - if (isset($this->request->post['reward']) && $this->validateReward()) { - $this->session->data['reward'] = abs($this->request->post['reward']); - - $this->session->data['success'] = $this->language->get('text_reward'); - - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm', '', true)); - } - - $this->document->setTitle($this->language->get('express_text_title')); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('common/home'), - 'text' => $this->language->get('text_home') - ); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('extension/payment/pp_express/express'), - 'text' => $this->language->get('text_title') - ); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('extension/payment/pp_express/expressConfirm'), - 'text' => $this->language->get('express_text_title') - ); - - $points = $this->customer->getRewardPoints(); - - $points_total = 0; - - foreach ($this->cart->getProducts() as $product) { - if ($product['points']) { - $points_total += $product['points']; - } - } - - $data['button_shipping'] = $this->language->get('button_express_shipping'); - $data['button_confirm'] = $this->language->get('button_express_confirm'); - - if (isset($this->request->post['next'])) { - $data['next'] = $this->request->post['next']; - } else { - $data['next'] = ''; - } - - $data['action'] = $this->url->link('extension/payment/pp_express/expressConfirm', '', true); - - $this->load->model('tool/upload'); - - $products = $this->cart->getProducts(); - - foreach ($products as $product) { - $product_total = 0; - - foreach ($products as $product_2) { - if ($product_2['product_id'] == $product['product_id']) { - $product_total += $product_2['quantity']; - } - } - - if ($product['minimum'] > $product_total) { - $data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']); - } - - if ($product['image']) { - $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); - } else { - $image = ''; - } - - $option_data = array(); - - foreach ($product['option'] as $option) { - if ($option['type'] != 'file') { - $value = $option['value']; - } else { - $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); - - if ($upload_info) { - $value = $upload_info['name']; - } else { - $value = ''; - } - } - - $option_data[] = array( - 'name' => $option['name'], - 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ); - } - - // Display prices - if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')); - - $price = $this->currency->format($unit_price, $this->session->data['currency']); - $total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']); - } else { - $price = false; - $total = false; - } - - $recurring_description = ''; - - if ($product['recurring']) { - $frequencies = array( - 'day' => $this->language->get('text_day'), - 'week' => $this->language->get('text_week'), - 'semi_month' => $this->language->get('text_semi_month'), - 'month' => $this->language->get('text_month'), - 'year' => $this->language->get('text_year'), - ); - - if ($product['recurring']['trial']) { - $recurring_price = $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); - $recurring_description = sprintf($this->language->get('text_trial_description'), $recurring_price, $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' '; - } - - $recurring_price = $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); - - if ($product['recurring']['duration']) { - $recurring_description .= sprintf($this->language->get('text_payment_description'), $recurring_price, $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']); - } else { - $recurring_description .= sprintf($this->language->get('text_payment_cancel'), $recurring_price, $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']); - } - } - - $data['products'][] = array( - 'cart_id' => $product['cart_id'], - 'thumb' => $image, - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'quantity' => $product['quantity'], - 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), - 'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''), - 'price' => $price, - 'total' => $total, - 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), - 'remove' => $this->url->link('checkout/cart', 'remove=' . $product['cart_id']), - 'recurring' => $product['recurring'], - 'recurring_name' => (isset($product['recurring']['recurring_name']) ? $product['recurring']['recurring_name'] : ''), - 'recurring_description' => $recurring_description - ); - } - - $data['vouchers'] = array(); - - if ($this->cart->hasShipping()) { - - $data['has_shipping'] = true; - /** - * Shipping services - */ - if ($this->customer->isLogged()) { - $this->load->model('account/address'); - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - if (!empty($shipping_address)) { - // Shipping Methods - $quote_data = array(); - - $this->load->model('setting/extension'); - - $results = $this->model_setting_extension->getExtensions('shipping'); - - if (!empty($results)) { - foreach ($results as $result) { - if ($this->config->get('shipping_' . $result['code'] . '_status')) { - $this->load->model('extension/shipping/' . $result['code']); - - $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($shipping_address); - - if ($quote) { - $quote_data[$result['code']] = array( - 'title' => $quote['title'], - 'quote' => $quote['quote'], - 'sort_order' => $quote['sort_order'], - 'error' => $quote['error'] - ); - } - } - } - - if (!empty($quote_data)) { - $sort_order = array(); - - foreach ($quote_data as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $quote_data); - - $this->session->data['shipping_methods'] = $quote_data; - $data['shipping_methods'] = $quote_data; - - if (!isset($this->session->data['shipping_method'])) { - //default the shipping to the very first option. - $key1 = key($quote_data); - $key2 = key($quote_data[$key1]['quote']); - $this->session->data['shipping_method'] = $quote_data[$key1]['quote'][$key2]; - } - - $data['code'] = $this->session->data['shipping_method']['code']; - $data['action_shipping'] = $this->url->link('extension/payment/pp_express/shipping', '', true); - } else { - unset($this->session->data['shipping_methods']); - unset($this->session->data['shipping_method']); - $data['error_no_shipping'] = $this->language->get('error_no_shipping'); - } - } else { - unset($this->session->data['shipping_methods']); - unset($this->session->data['shipping_method']); - $data['error_no_shipping'] = $this->language->get('error_no_shipping'); - } - } - } else { - $data['has_shipping'] = false; - } - - // Totals - $this->load->model('setting/extension'); - - $totals = array(); - $taxes = $this->cart->getTaxes(); - $total = 0; - - // Because __call can not keep var references so we put them into an array. - $total_data = array( - 'totals' => &$totals, - 'taxes' => &$taxes, - 'total' => &$total - ); - - // Display prices - if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = array(); - - $results = $this->model_setting_extension->getExtensions('total'); - - foreach ($results as $key => $value) { - $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); - } - - array_multisort($sort_order, SORT_ASC, $results); - - foreach ($results as $result) { - if ($this->config->get('total_' . $result['code'] . '_status')) { - $this->load->model('extension/total/' . $result['code']); - - // We have to put the totals in an array so that they pass by reference. - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); - } - } - - $sort_order = array(); - - foreach ($totals as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $totals); - } - - $data['totals'] = array(); - - foreach ($totals as $total) { - $data['totals'][] = array( - 'title' => $total['title'], - 'text' => $this->currency->format($total['value'], $this->session->data['currency']), - ); - } - - /** - * Payment methods - */ - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $this->load->model('account/address'); - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $payment_address = $this->session->data['guest']['payment']; - } - - $method_data = array(); - - $this->load->model('setting/extension'); - - $results = $this->model_setting_extension->getExtensions('payment'); - - foreach ($results as $result) { - if ($this->config->get('payment_' . $result['code'] . '_status')) { - $this->load->model('extension/payment/' . $result['code']); - - $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($payment_address, $total); - - if ($method) { - $method_data[$result['code']] = $method; - } - } - } - - $sort_order = array(); - - foreach ($method_data as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $method_data); - - if (!isset($method_data['pp_express'])) { - $this->session->data['error_warning'] = $this->language->get('error_unavailable'); - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - - $this->session->data['payment_methods'] = $method_data; - $this->session->data['payment_method'] = $method_data['pp_express']; - - $data['action_confirm'] = $this->url->link('extension/payment/pp_express/expressComplete', '', true); - - if (isset($this->session->data['error_warning'])) { - $data['error_warning'] = $this->session->data['error_warning']; - unset($this->session->data['error_warning']); - } else { - $data['error_warning'] = ''; - } - - if (isset($this->session->data['success'])) { - $data['success'] = $this->session->data['success']; - unset($this->session->data['success']); - } else { - $data['success'] = ''; - } - - if (isset($this->session->data['attention'])) { - $data['attention'] = $this->session->data['attention']; - unset($this->session->data['attention']); - } else { - $data['attention'] = ''; - } - - $data['coupon'] = $this->load->controller('extension/total/coupon'); - $data['voucher'] = $this->load->controller('extension/total/voucher'); - $data['reward'] = $this->load->controller('extension/total/reward'); - $data['column_left'] = $this->load->controller('common/column_left'); - $data['column_right'] = $this->load->controller('common/column_right'); - $data['content_top'] = $this->load->controller('common/content_top'); - $data['content_bottom'] = $this->load->controller('common/content_bottom'); - $data['footer'] = $this->load->controller('common/footer'); - $data['header'] = $this->load->controller('common/header'); - - $this->response->setOutput($this->load->view('extension/payment/pp_express_confirm', $data)); - } - - public function expressComplete() { - $this->load->language('extension/payment/pp_express'); - $redirect = ''; - - if ($this->cart->hasShipping()) { - // Validate if shipping address has been set. - $this->load->model('account/address'); - - if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) { - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - if (empty($shipping_address)) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - - // Validate if shipping method has been set. - if (!isset($this->session->data['shipping_method'])) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - } else { - unset($this->session->data['shipping_method']); - unset($this->session->data['shipping_methods']); - } - - // Validate if payment address has been set. - $this->load->model('account/address'); - - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $payment_address = $this->session->data['guest']['payment']; - } - - // Validate if payment method has been set. - if (!isset($this->session->data['payment_method'])) { - $redirect = $this->url->link('checkout/checkout', '', true); - } - - // Validate cart has products and has stock. - if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { - $redirect = $this->url->link('checkout/cart'); - } - - // Validate minimum quantity requirements. - $products = $this->cart->getProducts(); - - foreach ($products as $product) { - $product_total = 0; - - foreach ($products as $product_2) { - if ($product_2['product_id'] == $product['product_id']) { - $product_total += $product_2['quantity']; - } - } - - if ($product['minimum'] > $product_total) { - $redirect = $this->url->link('checkout/cart'); - - break; - } - } - - if ($redirect == '') { - $totals = array(); - $taxes = $this->cart->getTaxes(); - $total = 0; - - // Because __call can not keep var references so we put them into an array. - $total_data = array( - 'totals' => &$totals, - 'taxes' => &$taxes, - 'total' => &$total - ); - - $this->load->model('setting/extension'); - - $sort_order = array(); - - $results = $this->model_setting_extension->getExtensions('total'); - - foreach ($results as $key => $value) { - $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); - } - - array_multisort($sort_order, SORT_ASC, $results); - - foreach ($results as $result) { - if ($this->config->get('total_' . $result['code'] . '_status')) { - $this->load->model('extension/total/' . $result['code']); - - // We have to put the totals in an array so that they pass by reference. - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); - } - } - - $sort_order = array(); - - foreach ($totals as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $totals); - - $this->load->language('checkout/checkout'); - - $data = array(); - - $data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); - $data['store_id'] = $this->config->get('config_store_id'); - $data['store_name'] = $this->config->get('config_name'); - - if ($data['store_id']) { - $data['store_url'] = $this->config->get('config_url'); - } else { - $data['store_url'] = HTTP_SERVER; - } - - if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) { - $data['customer_id'] = $this->customer->getId(); - $data['customer_group_id'] = $this->config->get('config_customer_group_id'); - $data['firstname'] = $this->customer->getFirstName(); - $data['lastname'] = $this->customer->getLastName(); - $data['email'] = $this->customer->getEmail(); - $data['telephone'] = $this->customer->getTelephone(); - - $this->load->model('account/address'); - - $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']); - } elseif (isset($this->session->data['guest'])) { - $data['customer_id'] = 0; - $data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; - $data['firstname'] = $this->session->data['guest']['firstname']; - $data['lastname'] = $this->session->data['guest']['lastname']; - $data['email'] = $this->session->data['guest']['email']; - $data['telephone'] = $this->session->data['guest']['telephone']; - - $payment_address = $this->session->data['guest']['payment']; - } - - $data['payment_firstname'] = isset($payment_address['firstname']) ? $payment_address['firstname'] : ''; - $data['payment_lastname'] = isset($payment_address['lastname']) ? $payment_address['lastname'] : ''; - $data['payment_company'] = isset($payment_address['company']) ? $payment_address['company'] : ''; - $data['payment_company_id'] = isset($payment_address['company_id']) ? $payment_address['company_id'] : ''; - $data['payment_tax_id'] = isset($payment_address['tax_id']) ? $payment_address['tax_id'] : ''; - $data['payment_address_1'] = isset($payment_address['address_1']) ? $payment_address['address_1'] : ''; - $data['payment_address_2'] = isset($payment_address['address_2']) ? $payment_address['address_2'] : ''; - $data['payment_city'] = isset($payment_address['city']) ? $payment_address['city'] : ''; - $data['payment_postcode'] = isset($payment_address['postcode']) ? $payment_address['postcode'] : ''; - $data['payment_zone'] = isset($payment_address['zone']) ? $payment_address['zone'] : ''; - $data['payment_zone_id'] = isset($payment_address['zone_id']) ? $payment_address['zone_id'] : ''; - $data['payment_country'] = isset($payment_address['country']) ? $payment_address['country'] : ''; - $data['payment_country_id'] = isset($payment_address['country_id']) ? $payment_address['country_id'] : ''; - $data['payment_address_format'] = isset($payment_address['address_format']) ? $payment_address['address_format'] : ''; - - $data['payment_method'] = ''; - if (isset($this->session->data['payment_method']['title'])) { - $data['payment_method'] = $this->session->data['payment_method']['title']; - } - - $data['payment_code'] = ''; - if (isset($this->session->data['payment_method']['code'])) { - $data['payment_code'] = $this->session->data['payment_method']['code']; - } - - if ($this->cart->hasShipping()) { - if ($this->customer->isLogged()) { - $this->load->model('account/address'); - - $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); - } elseif (isset($this->session->data['guest'])) { - $shipping_address = $this->session->data['guest']['shipping']; - } - - $data['shipping_firstname'] = $shipping_address['firstname']; - $data['shipping_lastname'] = $shipping_address['lastname']; - $data['shipping_company'] = $shipping_address['company']; - $data['shipping_address_1'] = $shipping_address['address_1']; - $data['shipping_address_2'] = $shipping_address['address_2']; - $data['shipping_city'] = $shipping_address['city']; - $data['shipping_postcode'] = $shipping_address['postcode']; - $data['shipping_zone'] = $shipping_address['zone']; - $data['shipping_zone_id'] = $shipping_address['zone_id']; - $data['shipping_country'] = $shipping_address['country']; - $data['shipping_country_id'] = $shipping_address['country_id']; - $data['shipping_address_format'] = $shipping_address['address_format']; - - $data['shipping_method'] = ''; - if (isset($this->session->data['shipping_method']['title'])) { - $data['shipping_method'] = $this->session->data['shipping_method']['title']; - } - - $data['shipping_code'] = ''; - if (isset($this->session->data['shipping_method']['code'])) { - $data['shipping_code'] = $this->session->data['shipping_method']['code']; - } - } else { - $data['shipping_firstname'] = ''; - $data['shipping_lastname'] = ''; - $data['shipping_company'] = ''; - $data['shipping_address_1'] = ''; - $data['shipping_address_2'] = ''; - $data['shipping_city'] = ''; - $data['shipping_postcode'] = ''; - $data['shipping_zone'] = ''; - $data['shipping_zone_id'] = ''; - $data['shipping_country'] = ''; - $data['shipping_country_id'] = ''; - $data['shipping_address_format'] = ''; - $data['shipping_method'] = ''; - $data['shipping_code'] = ''; - } - - $product_data = array(); - - foreach ($this->cart->getProducts() as $product) { - $option_data = array(); - - foreach ($product['option'] as $option) { - $option_data[] = array( - 'product_option_id' => $option['product_option_id'], - 'product_option_value_id' => $option['product_option_value_id'], - 'option_id' => $option['option_id'], - 'option_value_id' => $option['option_value_id'], - 'name' => $option['name'], - 'value' => $option['value'], - 'type' => $option['type'] - ); - } - - $product_data[] = array( - 'product_id' => $product['product_id'], - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'download' => $product['download'], - 'quantity' => $product['quantity'], - 'subtract' => $product['subtract'], - 'price' => $product['price'], - 'total' => $product['total'], - 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), - 'reward' => $product['reward'] - ); - } - - // Gift Voucher - $voucher_data = array(); - - if (!empty($this->session->data['vouchers'])) { - foreach ($this->session->data['vouchers'] as $voucher) { - $voucher_data[] = array( - 'description' => $voucher['description'], - 'code' => token(10), - 'to_name' => $voucher['to_name'], - 'to_email' => $voucher['to_email'], - 'from_name' => $voucher['from_name'], - 'from_email' => $voucher['from_email'], - 'voucher_theme_id' => $voucher['voucher_theme_id'], - 'message' => $voucher['message'], - 'amount' => $voucher['amount'] - ); - } - } - - $data['products'] = $product_data; - $data['vouchers'] = $voucher_data; - $data['totals'] = $totals; - $data['comment'] = $this->session->data['comment']; - $data['total'] = $total; - - if (isset($this->request->cookie['tracking'])) { - $data['tracking'] = $this->request->cookie['tracking']; - - $subtotal = $this->cart->getSubTotal(); - - // Affiliate - $this->load->model('affiliate/affiliate'); - - $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']); - - if ($affiliate_info) { - $data['affiliate_id'] = $affiliate_info['affiliate_id']; - $data['commission'] = ($subtotal / 100) * $affiliate_info['commission']; - } else { - $data['affiliate_id'] = 0; - $data['commission'] = 0; - } - - // Marketing - $this->load->model('checkout/marketing'); - - $marketing_info = $this->model_checkout_marketing->getMarketingByCode($this->request->cookie['tracking']); - - if ($marketing_info) { - $data['marketing_id'] = $marketing_info['marketing_id']; - } else { - $data['marketing_id'] = 0; - } - } else { - $data['affiliate_id'] = 0; - $data['commission'] = 0; - $data['marketing_id'] = 0; - $data['tracking'] = ''; - } - - $data['language_id'] = $this->config->get('config_language_id'); - $data['currency_id'] = $this->currency->getId($this->session->data['currency']); - $data['currency_code'] = $this->session->data['currency']; - $data['currency_value'] = $this->currency->getValue($this->session->data['currency']); - $data['ip'] = $this->request->server['REMOTE_ADDR']; - - if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) { - $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR']; - } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) { - $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP']; - } else { - $data['forwarded_ip'] = ''; - } - - if (isset($this->request->server['HTTP_USER_AGENT'])) { - $data['user_agent'] = $this->request->server['HTTP_USER_AGENT']; - } else { - $data['user_agent'] = ''; - } - - if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { - $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE']; - } else { - $data['accept_language'] = ''; - } - - $this->load->model('account/custom_field'); - $this->load->model('checkout/order'); - - $order_id = $this->model_checkout_order->addOrder($data); - $this->session->data['order_id'] = $order_id; - - $this->load->model('extension/payment/pp_express'); - - $paypal_data = array( - 'TOKEN' => $this->session->data['paypal']['token'], - 'PAYERID' => $this->session->data['paypal']['payerid'], - 'METHOD' => 'DoExpressCheckoutPayment', - 'PAYMENTREQUEST_0_NOTIFYURL' => $this->url->link('extension/payment/pp_express/ipn', '', true), - 'RETURNFMFDETAILS' => 1 - ); - - $paypal_data = array_merge($paypal_data, $this->model_extension_payment_pp_express->paymentRequestInfo()); - - $result = $this->model_extension_payment_pp_express->call($paypal_data); - - if ($result['ACK'] == 'Success') { - //handle order status - switch($result['PAYMENTINFO_0_PAYMENTSTATUS']) { - case 'Canceled_Reversal': - $order_status_id = $this->config->get('payment_pp_express_canceled_reversal_status_id'); - break; - case 'Completed': - $order_status_id = $this->config->get('payment_pp_express_completed_status_id'); - break; - case 'Denied': - $order_status_id = $this->config->get('payment_pp_express_denied_status_id'); - break; - case 'Expired': - $order_status_id = $this->config->get('payment_pp_express_expired_status_id'); - break; - case 'Failed': - $order_status_id = $this->config->get('payment_pp_express_failed_status_id'); - break; - case 'Pending': - $order_status_id = $this->config->get('payment_pp_express_pending_status_id'); - break; - case 'Processed': - $order_status_id = $this->config->get('payment_pp_express_processed_status_id'); - break; - case 'Refunded': - $order_status_id = $this->config->get('payment_pp_express_refunded_status_id'); - break; - case 'Reversed': - $order_status_id = $this->config->get('payment_pp_express_reversed_status_id'); - break; - case 'Voided': - $order_status_id = $this->config->get('payment_pp_express_voided_status_id'); - break; - } - - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); - - //add order to paypal table - $paypal_order_data = array( - 'order_id' => $order_id, - 'capture_status' => ($this->config->get('payment_pp_express_transaction') == 'Sale' ? 'Complete' : 'NotComplete'), - 'currency_code' => $result['PAYMENTINFO_0_CURRENCYCODE'], - 'authorization_id' => $result['PAYMENTINFO_0_TRANSACTIONID'], - 'total' => $result['PAYMENTINFO_0_AMT'] - ); - - $paypal_order_id = $this->model_extension_payment_pp_express->addOrder($paypal_order_data); - - //add transaction to paypal transaction table - $paypal_transaction_data = array( - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $result['PAYMENTINFO_0_TRANSACTIONID'], - 'parent_id' => '', - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => (isset($result['PAYMENTINFO_0_RECEIPTID']) ? $result['PAYMENTINFO_0_RECEIPTID'] : ''), - 'payment_type' => $result['PAYMENTINFO_0_PAYMENTTYPE'], - 'payment_status' => $result['PAYMENTINFO_0_PAYMENTSTATUS'], - 'pending_reason' => $result['PAYMENTINFO_0_PENDINGREASON'], - 'transaction_entity' => ($this->config->get('payment_pp_express_transaction') == 'Sale' ? 'payment' : 'auth'), - 'amount' => $result['PAYMENTINFO_0_AMT'], - 'debug_data' => json_encode($result) - ); - - $this->model_extension_payment_pp_express->addTransaction($paypal_transaction_data); - - $recurring_products = $this->cart->getRecurringProducts(); - - //loop through any products that are recurring items - if ($recurring_products) { - $this->load->language('extension/payment/pp_express'); - - $this->load->model('checkout/recurring'); - - $billing_period = array( - 'day' => 'Day', - 'week' => 'Week', - 'semi_month' => 'SemiMonth', - 'month' => 'Month', - 'year' => 'Year' - ); - - foreach($recurring_products as $item) { - $data = array( - 'METHOD' => 'CreateRecurringPaymentsProfile', - 'TOKEN' => $this->session->data['paypal']['token'], - 'PROFILESTARTDATE' => gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate("H"), gmdate("i")+5, gmdate("s"), gmdate("m"), gmdate("d"), gmdate("y"))), - 'BILLINGPERIOD' => $billing_period[$item['recurring']['frequency']], - 'BILLINGFREQUENCY' => $item['recurring']['cycle'], - 'TOTALBILLINGCYCLES' => $item['recurring']['duration'], - 'AMT' => $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'], - 'CURRENCYCODE' => $this->session->data['currency'] - ); - - //trial information - if ($item['recurring']['trial']) { - $data_trial = array( - 'TRIALBILLINGPERIOD' => $billing_period[$item['recurring']['trial_frequency']], - 'TRIALBILLINGFREQUENCY' => $item['recurring']['trial_cycle'], - 'TRIALTOTALBILLINGCYCLES' => $item['recurring']['trial_duration'], - 'TRIALAMT' => $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] - ); - - $trial_amt = $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $trial_text = sprintf($this->language->get('text_trial'), $trial_amt, $item['recurring']['trial_cycle'], $item['recurring']['trial_frequency'], $item['recurring']['trial_duration']); - - $data = array_merge($data, $data_trial); - } else { - $trial_text = ''; - } - - $recurring_amt = $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $item['recurring']['cycle'], $item['recurring']['frequency']); - - if ($item['recurring']['duration'] > 0) { - $recurring_description .= sprintf($this->language->get('text_length'), $item['recurring']['duration']); - } - - //create new recurring and set to pending status as no payment has been made yet. - $recurring_id = $this->model_checkout_recurring->addRecurring($order_id, $recurring_description, $item); - - $data['PROFILEREFERENCE'] = $recurring_id; - $data['DESC'] = $recurring_description; - - $result = $this->model_extension_payment_pp_express->call($data); - - if (isset($result['PROFILEID'])) { - $this->model_checkout_recurring->editReference($recurring_id, $result['PROFILEID']); - } else { - // there was an error creating the recurring, need to log and also alert admin / user - - } - } - } - - $this->response->redirect($this->url->link('checkout/success')); - - if (isset($result['REDIRECTREQUIRED']) && $result['REDIRECTREQUIRED'] == true) { - //- handle german redirect here - $this->response->redirect('https://www.paypal.com/cgi-bin/webscr?cmd=_complete-express-checkout&token=' . $this->session->data['paypal']['token']); - } - } else { - if ($result['L_ERRORCODE0'] == '10486') { - if (isset($this->session->data['paypal_redirect_count'])) { - - if ($this->session->data['paypal_redirect_count'] == 2) { - $this->session->data['paypal_redirect_count'] = 0; - $this->session->data['error'] = $this->language->get('error_too_many_failures'); - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } else { - $this->session->data['paypal_redirect_count']++; - } - } else { - $this->session->data['paypal_redirect_count'] = 1; - } - - if ($this->config->get('payment_pp_express_test') == 1) { - $this->response->redirect('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $this->session->data['paypal']['token']); - } else { - $this->response->redirect('https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $this->session->data['paypal']['token']); - } - } - - $this->session->data['error_warning'] = $result['L_LONGMESSAGE0']; - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm', '', true)); - } - } else { - $this->response->redirect($redirect); - } - } - - public function checkout() { - if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { - $this->response->redirect($this->url->link('checkout/cart')); - } - - $this->load->model('extension/payment/pp_express'); - $this->load->model('tool/image'); - $this->load->model('checkout/order'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $max_amount = $this->cart->getTotal() * 1.5; - $max_amount = $this->currency->format($max_amount, $this->session->data['currency'], '', false); - - if ($this->cart->hasShipping()) { - $shipping = 0; - - // PayPal requires some countries to use zone code (not name) to be sent in SHIPTOSTATE - $ship_to_state_codes = array( - '30', // Brazil - '38', // Canada - '105', // Italy - '138', // Mexico - '223', // USA - ); - - if (in_array($order_info['shipping_country_id'], $ship_to_state_codes)) { - $ship_to_state = $order_info['shipping_zone_code']; - } else { - $ship_to_state = $order_info['shipping_zone']; - } - - $data_shipping = array( - 'PAYMENTREQUEST_0_SHIPTONAME' => html_entity_decode($order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname'], ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOSTREET' => html_entity_decode($order_info['shipping_address_1'], ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOSTREET2' => html_entity_decode($order_info['shipping_address_2'], ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOCITY' => html_entity_decode($order_info['shipping_city'], ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOSTATE' => html_entity_decode($ship_to_state, ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOZIP' => html_entity_decode($order_info['shipping_postcode'], ENT_QUOTES, 'UTF-8'), - 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => $order_info['shipping_iso_code_2'], - 'ADDROVERRIDE' => 1, - ); - } else { - $shipping = 1; - $data_shipping = array(); - } - - $data = array( - 'METHOD' => 'SetExpressCheckout', - 'MAXAMT' => $max_amount, - 'RETURNURL' => $this->url->link('extension/payment/pp_express/checkoutReturn', '', true), - 'CANCELURL' => $this->url->link('checkout/checkout', '', true), - 'REQCONFIRMSHIPPING' => 0, - 'NOSHIPPING' => $shipping, - 'LOCALECODE' => 'EN', - 'LANDINGPAGE' => 'Login', - 'HDRIMG' => $this->model_tool_image->resize($this->config->get('payment_pp_express_logo'), 750, 90), - 'PAYFLOWCOLOR' => $this->config->get('payment_pp_express_colour'), - 'CHANNELTYPE' => 'Merchant', - 'ALLOWNOTE' => $this->config->get('payment_pp_express_allow_note') - ); - - $data = array_merge($data, $data_shipping); - - if (isset($this->session->data['pp_login']['seamless']['access_token']) && (isset($this->session->data['pp_login']['seamless']['customer_id']) && $this->session->data['pp_login']['seamless']['customer_id'] == $this->customer->getId()) && $this->config->get('module_pp_login_seamless')) { - $data['IDENTITYACCESSTOKEN'] = $this->session->data['pp_login']['seamless']['access_token']; - } - - $data = array_merge($data, $this->model_extension_payment_pp_express->paymentRequestInfo()); - - $result = $this->model_extension_payment_pp_express->call($data); - - /** - * If a failed PayPal setup happens, handle it. - */ - if (!isset($result['TOKEN'])) { - $this->session->data['error'] = $result['L_LONGMESSAGE0']; - /** - * Unable to add error message to user as the session errors/success are not - * used on the cart or checkout pages - need to be added? - * If PayPal debug log is off then still log error to normal error log. - */ - $this->log->write('Unable to create Paypal session' . json_encode($result)); - - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } - - $this->session->data['paypal']['token'] = $result['TOKEN']; - - if ($this->config->get('payment_pp_express_test') == 1) { - header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN'] . '&useraction=commit'); - } else { - header('Location: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN'] . '&useraction=commit'); - } - } - - public function checkoutReturn() { - $this->load->language('extension/payment/pp_express'); - - $this->load->model('extension/payment/pp_express'); - $this->load->model('checkout/order'); - - $data = array( - 'METHOD' => 'GetExpressCheckoutDetails', - 'TOKEN' => $this->session->data['paypal']['token'] - ); - - $result = $this->model_extension_payment_pp_express->call($data); - - $this->session->data['paypal']['payerid'] = $result['PAYERID']; - $this->session->data['paypal']['result'] = $result; - - $order_id = $this->session->data['order_id']; - - $paypal_data = array( - 'TOKEN' => $this->session->data['paypal']['token'], - 'PAYERID' => $this->session->data['paypal']['payerid'], - 'METHOD' => 'DoExpressCheckoutPayment', - 'PAYMENTREQUEST_0_NOTIFYURL' => $this->url->link('extension/payment/pp_express/ipn', '', true), - 'RETURNFMFDETAILS' => 1 - ); - - $paypal_data = array_merge($paypal_data, $this->model_extension_payment_pp_express->paymentRequestInfo()); - - $result = $this->model_extension_payment_pp_express->call($paypal_data); - - if ($result['ACK'] == 'Success') { - //handle order status - switch($result['PAYMENTINFO_0_PAYMENTSTATUS']) { - case 'Canceled_Reversal': - $order_status_id = $this->config->get('payment_pp_express_canceled_reversal_status_id'); - break; - case 'Completed': - $order_status_id = $this->config->get('payment_pp_express_completed_status_id'); - break; - case 'Denied': - $order_status_id = $this->config->get('payment_pp_express_denied_status_id'); - break; - case 'Expired': - $order_status_id = $this->config->get('payment_pp_express_expired_status_id'); - break; - case 'Failed': - $order_status_id = $this->config->get('payment_pp_express_failed_status_id'); - break; - case 'Pending': - $order_status_id = $this->config->get('payment_pp_express_pending_status_id'); - break; - case 'Processed': - $order_status_id = $this->config->get('payment_pp_express_processed_status_id'); - break; - case 'Refunded': - $order_status_id = $this->config->get('payment_pp_express_refunded_status_id'); - break; - case 'Reversed': - $order_status_id = $this->config->get('payment_pp_express_reversed_status_id'); - break; - case 'Voided': - $order_status_id = $this->config->get('payment_pp_express_voided_status_id'); - break; - } - - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); - - //add order to paypal table - $paypal_order_data = array( - 'order_id' => $order_id, - 'capture_status' => ($this->config->get('payment_pp_express_transaction') == 'Sale' ? 'Complete' : 'NotComplete'), - 'currency_code' => $result['PAYMENTINFO_0_CURRENCYCODE'], - 'authorization_id' => $result['PAYMENTINFO_0_TRANSACTIONID'], - 'total' => $result['PAYMENTINFO_0_AMT'] - ); - - $paypal_order_id = $this->model_extension_payment_pp_express->addOrder($paypal_order_data); - - //add transaction to paypal transaction table - $paypal_transaction_data = array( - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $result['PAYMENTINFO_0_TRANSACTIONID'], - 'parent_id' => '', - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => (isset($result['PAYMENTINFO_0_RECEIPTID']) ? $result['PAYMENTINFO_0_RECEIPTID'] : ''), - 'payment_type' => $result['PAYMENTINFO_0_PAYMENTTYPE'], - 'payment_status' => $result['PAYMENTINFO_0_PAYMENTSTATUS'], - 'pending_reason' => $result['PAYMENTINFO_0_PENDINGREASON'], - 'transaction_entity' => ($this->config->get('payment_pp_express_transaction') == 'Sale' ? 'payment' : 'auth'), - 'amount' => $result['PAYMENTINFO_0_AMT'], - 'debug_data' => json_encode($result) - ); - $this->model_extension_payment_pp_express->addTransaction($paypal_transaction_data); - - $recurring_products = $this->cart->getRecurringProducts(); - - //loop through any products that are recurring items - if ($recurring_products) { - $this->load->model('checkout/recurring'); - - $billing_period = array( - 'day' => 'Day', - 'week' => 'Week', - 'semi_month' => 'SemiMonth', - 'month' => 'Month', - 'year' => 'Year' - ); - - foreach ($recurring_products as $item) { - $data = array( - 'METHOD' => 'CreateRecurringPaymentsProfile', - 'TOKEN' => $this->session->data['paypal']['token'], - 'PROFILESTARTDATE' => gmdate("Y-m-d\TH:i:s\Z", gmmktime(gmdate('H'), gmdate('i') + 5, gmdate('s'), gmdate('m'), gmdate('d'), gmdate('y'))), - 'BILLINGPERIOD' => $billing_period[$item['recurring']['frequency']], - 'BILLINGFREQUENCY' => $item['recurring']['cycle'], - 'TOTALBILLINGCYCLES' => $item['recurring']['duration'], - 'AMT' => $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'], - 'CURRENCYCODE' => $this->session->data['currency'] - ); - - //trial information - if ($item['recurring']['trial'] == 1) { - $data_trial = array( - 'TRIALBILLINGPERIOD' => $billing_period[$item['recurring']['trial_frequency']], - 'TRIALBILLINGFREQUENCY' => $item['recurring']['trial_cycle'], - 'TRIALTOTALBILLINGCYCLES' => $item['recurring']['trial_duration'], - 'TRIALAMT' => $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] - ); - - $trial_amt = $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $trial_text = sprintf($this->language->get('text_trial'), $trial_amt, $item['recurring']['trial_cycle'], $item['recurring']['trial_frequency'], $item['recurring']['trial_duration']); - - $data = array_merge($data, $data_trial); - } else { - $trial_text = ''; - } - - $recurring_amt = $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $item['recurring']['cycle'], $item['recurring']['frequency']); - - if ($item['recurring']['duration'] > 0) { - $recurring_description .= sprintf($this->language->get('text_length'), $item['recurring']['duration']); - } - - //create new recurring and set to pending status as no payment has been made yet. - $recurring_id = $this->model_checkout_recurring->addRecurring($order_id, $recurring_description, $item); - - $data['PROFILEREFERENCE'] = $recurring_id; - $data['DESC'] = $recurring_description; - - $result = $this->model_extension_payment_pp_express->call($data); - - if (isset($result['PROFILEID'])) { - $this->model_checkout_recurring->editReference($recurring_id, $result['PROFILEID']); - } else { - // there was an error creating the recurring, need to log and also alert admin / user - - } - } - } - - if (isset($result['REDIRECTREQUIRED']) && $result['REDIRECTREQUIRED'] == true) { - //- handle german redirect here - $this->response->redirect('https://www.paypal.com/cgi-bin/webscr?cmd=_complete-express-checkout&token=' . $this->session->data['paypal']['token']); - } else { - $this->response->redirect($this->url->link('checkout/success')); - } - } else { - if ($result['L_ERRORCODE0'] == '10486') { - if (isset($this->session->data['paypal_redirect_count'])) { - - if ($this->session->data['paypal_redirect_count'] == 2) { - $this->session->data['paypal_redirect_count'] = 0; - $this->session->data['error'] = $this->language->get('error_too_many_failures'); - - $this->response->redirect($this->url->link('checkout/checkout', '', true)); - } else { - $this->session->data['paypal_redirect_count']++; - } - } else { - $this->session->data['paypal_redirect_count'] = 1; - } - - if ($this->config->get('payment_pp_express_test') == 1) { - $this->response->redirect('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $this->session->data['paypal']['token']); - } else { - $this->response->redirect('https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $this->session->data['paypal']['token']); - } - } - - $this->load->language('extension/payment/pp_express'); - - $data['breadcrumbs'] = array(); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('common/home'), - 'text' => $this->language->get('text_home') - ); - - $data['breadcrumbs'][] = array( - 'href' => $this->url->link('checkout/cart'), - 'text' => $this->language->get('text_cart') - ); - - $data['heading_title'] = $this->language->get('error_heading_title'); - - $data['text_error'] = '
' . $result['L_ERRORCODE0'] . ' : ' . $result['L_LONGMESSAGE0'] . '
'; - - $data['button_continue'] = $this->language->get('button_continue'); - - $data['continue'] = $this->url->link('checkout/cart'); - - unset($this->session->data['success']); - - $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); - - $data['column_left'] = $this->load->controller('common/column_left'); - $data['column_right'] = $this->load->controller('common/column_right'); - $data['content_top'] = $this->load->controller('common/content_top'); - $data['content_bottom'] = $this->load->controller('common/content_bottom'); - $data['footer'] = $this->load->controller('common/footer'); - $data['header'] = $this->load->controller('common/header'); - - $this->response->setOutput($this->load->view('error/not_found', $data)); - } - } - - public function ipn() { - $this->load->model('extension/payment/pp_express'); - $this->load->model('account/recurring'); - - $request = 'cmd=_notify-validate'; - - foreach ($_POST as $key => $value) { - $request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8')); - } - - if ($this->config->get('payment_pp_express_test') == 1) { - $curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); - } else { - $curl = curl_init('https://www.paypal.com/cgi-bin/webscr'); - } - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = trim(curl_exec($curl)); - - if (!$response) { - $this->model_extension_payment_pp_express->log(array('error' => curl_error($curl),'error_no' => curl_errno($curl)), 'Curl failed'); - } - - $this->model_extension_payment_pp_express->log(array('request' => $request,'response' => $response), 'IPN data'); - - if ((string)$response == "VERIFIED") { - if (isset($this->request->post['transaction_entity'])) { - $this->log->write($this->request->post['transaction_entity']); - } - - if (isset($this->request->post['txn_id'])) { - $transaction = $this->model_extension_payment_pp_express->getTransactionRow($this->request->post['txn_id']); - } else { - $transaction = false; - } - - if (isset($this->request->post['parent_txn_id'])) { - $parent_transaction = $this->model_extension_payment_pp_express->getTransactionRow($this->request->post['parent_txn_id']); - } else { - $parent_transaction = false; - } - - if ($transaction) { - //transaction exists, check for cleared payment or updates etc - $this->model_extension_payment_pp_express->log('Transaction exists', 'IPN data'); - - //if the transaction is pending but the new status is completed - if ($transaction['payment_status'] != $this->request->post['payment_status']) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = '" . $this->db->escape($this->request->post['payment_status']) . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1"); - } elseif ($transaction['payment_status'] == 'Pending' && ($transaction['pending_reason'] != $this->request->post['pending_reason'])) { - //payment is still pending but the pending reason has changed, update it. - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `pending_reason` = '" . $this->db->escape($this->request->post['pending_reason']) . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1"); - } - } else { - $this->model_extension_payment_pp_express->log('Transaction does not exist', 'IPN data'); - - if ($parent_transaction) { - //parent transaction exists - $this->model_extension_payment_pp_express->log('Parent transaction exists', 'IPN data'); - - //add new related transaction - $transaction = array( - 'paypal_order_id' => $parent_transaction['paypal_order_id'], - 'transaction_id' => $this->request->post['txn_id'], - 'parent_id' => $this->request->post['parent_txn_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => (isset($this->request->post['receipt_id']) ? $this->request->post['receipt_id'] : ''), - 'payment_type' => (isset($this->request->post['payment_type']) ? $this->request->post['payment_type'] : ''), - 'payment_status' => (isset($this->request->post['payment_status']) ? $this->request->post['payment_status'] : ''), - 'pending_reason' => (isset($this->request->post['pending_reason']) ? $this->request->post['pending_reason'] : ''), - 'amount' => $this->request->post['mc_gross'], - 'debug_data' => json_encode($this->request->post), - 'transaction_entity' => (isset($this->request->post['transaction_entity']) ? $this->request->post['transaction_entity'] : '') - ); - - $this->model_extension_payment_pp_express->addTransaction($transaction); - - /** - * If there has been a refund, log this against the parent transaction. - */ - if (isset($this->request->post['payment_status']) && $this->request->post['payment_status'] == 'Refunded') { - if (($this->request->post['mc_gross'] * -1) == $parent_transaction['amount']) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Refunded' WHERE `transaction_id` = '" . $this->db->escape($parent_transaction['transaction_id']) . "' LIMIT 1"); - } else { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = 'Partially-Refunded' WHERE `transaction_id` = '" . $this->db->escape($parent_transaction['transaction_id']) . "' LIMIT 1"); - } - } - - /** - * If the capture payment is now complete - */ - if (isset($this->request->post['auth_status']) && $this->request->post['auth_status'] == 'Completed' && $parent_transaction['payment_status'] == 'Pending') { - $captured = $this->currency->format($this->model_extension_payment_pp_express->getTotalCaptured($parent_transaction['paypal_order_id']), $this->session->data['currency'], false, false); - $refunded = $this->currency->format($this->model_extension_payment_pp_express->getRefundedTotal($parent_transaction['paypal_order_id']), $this->session->data['currency'], false, false); - $remaining = $this->currency->format($parent_transaction['amount'] - $captured + $refunded, $this->session->data['currency'], false, false); - - $this->model_extension_payment_pp_express->log('Captured: ' . $captured, 'IPN data'); - $this->model_extension_payment_pp_express->log('Refunded: ' . $refunded, 'IPN data'); - $this->model_extension_payment_pp_express->log('Remaining: ' . $remaining, 'IPN data'); - - if ($remaining > 0.00) { - $transaction = array( - 'paypal_order_id' => $parent_transaction['paypal_order_id'], - 'transaction_id' => '', - 'parent_id' => $this->request->post['parent_txn_id'], - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => '', - 'payment_type' => '', - 'payment_status' => 'Void', - 'pending_reason' => '', - 'amount' => '', - 'debug_data' => 'Voided after capture', - 'transaction_entity' => 'auth' - ); - - $this->model_extension_payment_pp_express->addTransaction($transaction); - } - - $this->model_extension_payment_pp_express->updateOrder('Complete', $parent_transaction['order_id']); - } - - } else { - //parent transaction doesn't exists, need to investigate? - $this->model_extension_payment_pp_express->log('Parent transaction not found', 'IPN data'); - } - } - - /* - * Subscription payments - * - * recurring ID should always exist if its a recurring payment transaction. - * - * also the reference will match a recurring payment ID - */ - if (isset($this->request->post['txn_type'])) { - $this->model_extension_payment_pp_express->log($this->request->post['txn_type'], 'IPN data'); - - //payment - if ($this->request->post['txn_type'] == 'recurring_payment') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - $this->model_extension_payment_pp_express->log($recurring, 'IPN data'); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `amount` = '" . (float)$this->request->post['amount'] . "', `type` = '1'"); - - //as there was a payment the recurring is active, ensure it is set to active (may be been suspended before) - if ($recurring['status'] != 1) { - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 2 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "'"); - } - } - } - - //suspend - if ($this->request->post['txn_type'] == 'recurring_payment_suspended') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '6'"); - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 3 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "' LIMIT 1"); - } - } - - //suspend due to max failed - if ($this->request->post['txn_type'] == 'recurring_payment_suspended_due_to_max_failed_payment') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '7'"); - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 3 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "' LIMIT 1"); - } - } - - //payment failed - if ($this->request->post['txn_type'] == 'recurring_payment_failed') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '4'"); - } - } - - //outstanding payment failed - if ($this->request->post['txn_type'] == 'recurring_payment_outstanding_payment_failed') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '8'"); - } - } - - //outstanding payment - if ($this->request->post['txn_type'] == 'recurring_payment_outstanding_payment') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `amount` = '" . (float)$this->request->post['amount'] . "', `type` = '2'"); - - //as there was a payment the recurring is active, ensure it is set to active (may be been suspended before) - if ($recurring['status'] != 1) { - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 2 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "'"); - } - } - } - - //date_added - if ($this->request->post['txn_type'] == 'recurring_payment_profile_date_added') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '0'"); - - if ($recurring['status'] != 1) { - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 2 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "'"); - } - } - } - - //cancelled - if ($this->request->post['txn_type'] == 'recurring_payment_profile_cancel') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false && $recurring['status'] != 3) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '5'"); - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 4 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "' LIMIT 1"); - } - } - - //skipped - if ($this->request->post['txn_type'] == 'recurring_payment_skipped') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '3'"); - } - } - - //expired - if ($this->request->post['txn_type'] == 'recurring_payment_expired') { - $recurring = $this->model_account_recurring->getOrderRecurringByReference($this->request->post['recurring_payment_id']); - - if ($recurring != false) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "', `date_added` = NOW(), `type` = '9'"); - $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 5 WHERE `order_recurring_id` = '" . (int)$recurring['order_recurring_id'] . "' LIMIT 1"); - } - } - } - } elseif ((string)$response == "INVALID") { - $this->model_extension_payment_pp_express->log(array('IPN was invalid'), 'IPN fail'); - } else { - $this->model_extension_payment_pp_express->log('Response string unknown: ' . (string)$response, 'IPN data'); - } - - header("HTTP/1.1 200 Ok"); - } - - public function shipping() { - $this->shippingValidate($this->request->post['shipping_method']); - - $this->response->redirect($this->url->link('extension/payment/pp_express/expressConfirm')); - } - - protected function shippingValidate($code) { - $this->load->language('checkout/cart'); - $this->load->language('extension/payment/pp_express'); - - if (empty($code)) { - $this->session->data['error_warning'] = $this->language->get('error_shipping'); - return false; - } else { - $shipping = explode('.', $code); - - if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { - $this->session->data['error_warning'] = $this->language->get('error_shipping'); - return false; - } else { - $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; - $this->session->data['success'] = $this->language->get('text_shipping_updated'); - return true; - } - } - } - - protected function validateCoupon() { - $this->load->model('extension/total/coupon'); - - $coupon_info = $this->model_extension_total_coupon->getCoupon($this->request->post['coupon']); - - if ($coupon_info) { - return true; - } else { - $this->session->data['error_warning'] = $this->language->get('error_coupon'); - return false; - } - } - - protected function validateVoucher() { - $this->load->model('extension/total/coupon'); - - $voucher_info = $this->model_extension_total_voucher->getVoucher($this->request->post['voucher']); - - if ($voucher_info) { - return true; - } else { - $this->session->data['error_warning'] = $this->language->get('error_voucher'); - return false; - } - } - - protected function validateReward() { - $points = $this->customer->getRewardPoints(); - - $points_total = 0; - - foreach ($this->cart->getProducts() as $product) { - if ($product['points']) { - $points_total += $product['points']; - } - } - - $error = ''; - - if (empty($this->request->post['reward'])) { - $error = $this->language->get('error_reward'); - } - - if ($this->request->post['reward'] > $points) { - $error = sprintf($this->language->get('error_points'), $this->request->post['reward']); - } - - if ($this->request->post['reward'] > $points_total) { - $error = sprintf($this->language->get('error_maximum'), $points_total); - } - - if (!$error) { - return true; - } else { - $this->session->data['error_warning'] = $error; - return false; - } - } -} diff --git a/upload/catalog/controller/extension/payment/pp_payflow.php b/upload/catalog/controller/extension/payment/pp_payflow.php deleted file mode 100644 index ba45b0bc1e5..00000000000 --- a/upload/catalog/controller/extension/payment/pp_payflow.php +++ /dev/null @@ -1,199 +0,0 @@ -load->language('extension/payment/pp_payflow'); - - $data['text_credit_card'] = $this->language->get('text_credit_card'); - $data['text_start_date'] = $this->language->get('text_start_date'); - $data['text_issue'] = $this->language->get('text_issue'); - $data['text_loading'] = $this->language->get('text_loading'); - - $data['entry_cc_owner'] = $this->language->get('entry_cc_owner'); - $data['entry_cc_type'] = $this->language->get('entry_cc_type'); - $data['entry_cc_number'] = $this->language->get('entry_cc_number'); - $data['entry_cc_start_date'] = $this->language->get('entry_cc_start_date'); - $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date'); - $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2'); - $data['entry_cc_issue'] = $this->language->get('entry_cc_issue'); - - $data['button_confirm'] = $this->language->get('button_confirm'); - - $this->load->model('checkout/order'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $data['owner'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']; - - $data['cards'] = array(); - - $data['cards'][] = array( - 'text' => 'Visa', - 'value' => '0' - ); - - $data['cards'][] = array( - 'text' => 'MasterCard', - 'value' => '1' - ); - - $data['cards'][] = array( - 'text' => 'Maestro', - 'value' => '9' - ); - - $data['cards'][] = array( - 'text' => 'Solo', - 'value' => 'S' - ); - - $data['months'] = array(); - - for ($i = 1; $i <= 12; $i++) { - $data['months'][] = array( - 'text' => sprintf('%02d', $i), - 'value' => sprintf('%02d', $i) - ); - } - - $today = getdate(); - - $data['year_valid'] = array(); - - for ($i = $today['year'] - 10; $i < $today['year'] + 1; $i++) { - $data['year_valid'][] = array( - 'text' => sprintf('%02d', $i % 100), - 'value' => sprintf('%04d', $i) - ); - } - - $data['year_expire'] = array(); - - for ($i = $today['year']; $i < $today['year'] + 11; $i++) { - $data['year_expire'][] = array( - 'text' => sprintf('%02d', $i % 100), - 'value' => sprintf('%04d', $i) - ); - } - - return $this->load->view('extension/payment/pp_payflow', $data); - } - - public function send() { - $this->load->language('extension/payment/pp_payflow'); - - $this->load->model('checkout/order'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - if (!$this->config->get('payment_pp_payflow_transaction')) { - $payment_type = 'A'; - } else { - $payment_type = 'S'; - } - - $request = 'USER=' . urlencode($this->config->get('payment_pp_payflow_user')); - $request .= '&VENDOR=' . urlencode($this->config->get('payment_pp_payflow_vendor')); - $request .= '&PARTNER=' . urlencode($this->config->get('payment_pp_payflow_partner')); - $request .= '&PWD=' . urlencode($this->config->get('payment_pp_payflow_password')); - $request .= '&TENDER=C'; - $request .= '&TRXTYPE=' . $payment_type; - $request .= '&AMT=' . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false); - $request .= '&CURRENCY=' . urlencode($order_info['currency_code']); - $request .= '&NAME=' . urlencode($this->request->post['cc_owner']); - $request .= '&STREET=' . urlencode($order_info['payment_address_1']); - $request .= '&CITY=' . urlencode($order_info['payment_city']); - $request .= '&STATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']); - $request .= '&COUNTRY=' . urlencode($order_info['payment_iso_code_2']); - $request .= '&ZIP=' . urlencode(str_replace(' ', '', $order_info['payment_postcode'])); - $request .= '&CLIENTIP=' . urlencode($this->request->server['REMOTE_ADDR']); - $request .= '&EMAIL=' . urlencode($order_info['email']); - $request .= '&ACCT=' . urlencode(str_replace(' ', '', $this->request->post['cc_number'])); - $request .= '&ACCTTYPE=' . urlencode($this->request->post['cc_type']); - $request .= '&CARDSTART=' . urlencode($this->request->post['cc_start_date_month'] . substr($this->request->post['cc_start_date_year'], - 2, 2)); - $request .= '&EXPDATE=' . urlencode($this->request->post['cc_expire_date_month'] . substr($this->request->post['cc_expire_date_year'], - 2, 2)); - $request .= '&CVV2=' . urlencode($this->request->post['cc_cvv2']); - $request .= '&CARDISSUE=' . urlencode($this->request->post['cc_issue']); - $request .= '&BUTTONSOURCE=' . urlencode('OpenCart_2.0_PFP'); - - if (!$this->config->get('payment_pp_payflow_test')) { - $curl = curl_init('https://payflowpro.paypal.com'); - } else { - $curl = curl_init('https://pilot-payflowpro.paypal.com'); - } - - curl_setopt($curl, CURLOPT_PORT, 443); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-VPS-REQUEST-ID: ' . md5($this->session->data['order_id'] . mt_rand()))); - - $response = curl_exec($curl); - - curl_close($curl); - - if (!$response) { - $this->log->write('DoDirectPayment failed: ' . curl_error($curl) . '(' . curl_errno($curl) . ')'); - } - - $response_info = array(); - - parse_str($response, $response_info); - - $json = array(); - - if ($response_info['RESULT'] == '0') { - $message = ''; - - if (isset($response_info['AVSCODE'])) { - $message .= 'AVSCODE: ' . $response_info['AVSCODE'] . "\n"; - } - - if (isset($response_info['CVV2MATCH'])) { - $message .= 'CVV2MATCH: ' . $response_info['CVV2MATCH'] . "\n"; - } - - if (isset($response_info['TRANSACTIONID'])) { - $message .= 'TRANSACTIONID: ' . $response_info['TRANSACTIONID'] . "\n"; - } - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_pp_payflow_order_status_id'), $message, false); - - $json['success'] = $this->url->link('checkout/success'); - } else { - switch ($response_info['RESULT']) { - case '1': - case '26': - $json['error'] = $this->language->get('error_config'); - break; - case '7': - $json['error'] = $this->language->get('error_address'); - break; - case '12': - $json['error'] = $this->language->get('error_declined'); - break; - case '23': - case '24': - $json['error'] = $this->language->get('error_invalid'); - break; - default: - $json['error'] = $this->language->get('error_general'); - break; - } - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } -} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/pp_payflow_iframe.php b/upload/catalog/controller/extension/payment/pp_payflow_iframe.php deleted file mode 100644 index 172be0607f0..00000000000 --- a/upload/catalog/controller/extension/payment/pp_payflow_iframe.php +++ /dev/null @@ -1,158 +0,0 @@ -load->model('checkout/order'); - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->model('localisation/country'); - $this->load->model('localisation/zone'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - if ($this->config->get('payment_pp_payflow_iframe_test')) { - $mode = 'TEST'; - } else { - $mode = 'LIVE'; - } - - $payflow_url = 'https://payflowlink.paypal.com'; - - if ($this->config->get('payment_pp_payflow_iframe_transaction_method') == 'sale') { - $transaction_type = 'S'; - } else { - $transaction_type = 'A'; - } - - $secure_token_id = md5($this->session->data['order_id'] . mt_rand() . microtime()); - - $this->model_extension_payment_pp_payflow_iframe->addOrder($order_info['order_id'], $secure_token_id); - - $shipping_country = $this->model_localisation_country->getCountry($order_info['shipping_country_id']); - $shipping_zone = $this->model_localisation_zone->getZone($order_info['shipping_zone_id']); - - $payment_country = $this->model_localisation_country->getCountry($order_info['payment_country_id']); - $payment_zone = $this->model_localisation_zone->getZone($order_info['payment_zone_id']); - - $url_params = array( - 'TENDER' => 'C', - 'TRXTYPE' => $transaction_type, - 'AMT' => $this->currency->format($order_info['total'], $order_info['currency_code'], false, false), - 'CURRENCY' => $order_info['currency_code'], - 'CREATESECURETOKEN' => 'Y', - 'SECURETOKENID' => $secure_token_id, - 'BILLTOFIRSTNAME' => $order_info['payment_firstname'], - 'BILLTOLASTNAME' => $order_info['payment_lastname'], - 'BILLTOSTREET' => trim($order_info['payment_address_1'] . ' ' . $order_info['payment_address_2']), - 'BILLTOCITY' => $order_info['payment_city'], - 'BILLTOSTATE' => $payment_zone['code'], - 'BILLTOZIP' => $order_info['payment_postcode'], - 'BILLTOCOUNTRY' => $payment_country['iso_code_2'], - ); - - if ($shipping_country) { - $url_params['SHIPTOFIRSTNAME'] = $order_info['shipping_firstname']; - $url_params['SHIPTOLASTNAME'] = $order_info['shipping_lastname']; - $url_params['SHIPTOSTREET'] = trim($order_info['shipping_address_1'] . ' ' . $order_info['shipping_address_2']); - $url_params['SHIPTOCITY'] = $order_info['shipping_city']; - $url_params['SHIPTOSTATE'] = $shipping_zone['code']; - $url_params['SHIPTOZIP'] = $order_info['shipping_postcode']; - $url_params['SHIPTOCOUNTRY'] = $shipping_country['iso_code_2']; - } - - $response_params = $this->model_extension_payment_pp_payflow_iframe->call($url_params); - - if (isset($response_params['SECURETOKEN'])) { - $secure_token = $response_params['SECURETOKEN']; - } else { - $secure_token = ''; - } - - $iframe_params = array( - 'MODE' => $mode, - 'SECURETOKENID' => $secure_token_id, - 'SECURETOKEN' => $secure_token, - ); - - $data['iframe_url'] = $payflow_url . '?' . http_build_query($iframe_params, '', "&"); - $data['checkout_method'] = $this->config->get('payment_pp_payflow_iframe_checkout_method'); - $data['button_confirm'] = $this->language->get('button_confirm'); - $data['create'] = HTTPS_SERVER . 'index.php?route=extension/payment/pp_pro_iframe/create'; - - return $this->load->view('extension/payment/pp_payflow_iframe', $data); - } - - public function paymentReturn() { - $data['url'] = $this->url->link('checkout/success'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow_iframe_return', $data)); - } - - public function paymentCancel() { - $data['url'] = $this->url->link('checkout/checkout'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow_iframe_return', $data)); - } - - public function paymentError() { - $data['url'] = $this->url->link('checkout/checkout'); - - $this->response->setOutput($this->load->view('extension/payment/pp_payflow_iframe_return', $data)); - } - - public function paymentIpn() { - $this->load->model('extension/payment/pp_payflow_iframe'); - $this->load->model('checkout/order'); - - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write('POST: ' . print_r($this->request->post, 1)); - } - - $order_id = $this->model_extension_payment_pp_payflow_iframe->getOrderId($this->request->post['SECURETOKENID']); - - if ($order_id) { - $order_info = $this->model_checkout_order->getOrder($order_id); - - $url_params = array( - 'TENDER' => 'C', - 'TRXTYPE' => 'I', - 'ORIGID' => $this->request->post['PNREF'], - ); - - $response_params = $this->model_extension_payment_pp_payflow_iframe->call($url_params); - - if ($order_info['order_status_id'] == 0 && $response_params['RESULT'] == '0' && $this->request->post['RESULT'] == 0) { - $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('payment_pp_payflow_iframe_order_status_id')); - - if ($this->request->post['TYPE'] == 'S') { - $complete = 1; - } else { - $complete = 0; - } - - $data = array( - 'secure_token_id' => $this->request->post['SECURETOKENID'], - 'transaction_reference' => $this->request->post['PNREF'], - 'transaction_type' => $this->request->post['TYPE'], - 'complete' => $complete, - ); - - $this->model_extension_payment_pp_payflow_iframe->updateOrder($data); - - $data = array( - 'order_id' => $order_id, - 'type' => $this->request->post['TYPE'], - 'transaction_reference' => $this->request->post['PNREF'], - 'amount' => $this->request->post['AMT'], - ); - - $this->model_extension_payment_pp_payflow_iframe->addTransaction($data); - } - } - - $this->response->setOutput('Ok'); - } -} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/pp_pro.php b/upload/catalog/controller/extension/payment/pp_pro.php deleted file mode 100644 index 00a1bce85e5..00000000000 --- a/upload/catalog/controller/extension/payment/pp_pro.php +++ /dev/null @@ -1,186 +0,0 @@ -load->language('extension/payment/pp_pro'); - - $data['cards'] = array(); - - $data['cards'][] = array( - 'text' => 'Visa', - 'value' => 'VISA' - ); - - $data['cards'][] = array( - 'text' => 'MasterCard', - 'value' => 'MASTERCARD' - ); - - $data['cards'][] = array( - 'text' => 'Discover Card', - 'value' => 'DISCOVER' - ); - - $data['cards'][] = array( - 'text' => 'American Express', - 'value' => 'AMEX' - ); - - $data['cards'][] = array( - 'text' => 'Maestro', - 'value' => 'SWITCH' - ); - - $data['cards'][] = array( - 'text' => 'Solo', - 'value' => 'SOLO' - ); - - $data['months'] = array(); - - for ($i = 1; $i <= 12; $i++) { - $data['months'][] = array( - 'text' => sprintf('%02d', $i), - 'value' => sprintf('%02d', $i) - ); - } - - $today = getdate(); - - $data['year_valid'] = array(); - - for ($i = $today['year'] - 10; $i < $today['year'] + 1; $i++) { - $data['year_valid'][] = array( - 'text' => sprintf('%02d', $i % 100), - 'value' => sprintf('%04d', $i) - ); - } - - $data['year_expire'] = array(); - - for ($i = $today['year']; $i < $today['year'] + 11; $i++) { - $data['year_expire'][] = array( - 'text' => sprintf('%02d', $i % 100), - 'value' => sprintf('%04d', $i) - ); - } - - return $this->load->view('extension/payment/pp_pro', $data); - } - - public function send() { - if (!$this->config->get('payment_pp_pro_transaction')) { - $payment_type = 'Authorization'; - } else { - $payment_type = 'Sale'; - } - - $this->load->model('checkout/order'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $request = 'METHOD=DoDirectPayment'; - $request .= '&VERSION=51.0'; - $request .= '&USER=' . urlencode($this->config->get('payment_pp_pro_username')); - $request .= '&PWD=' . urlencode($this->config->get('payment_pp_pro_password')); - $request .= '&SIGNATURE=' . urlencode($this->config->get('payment_pp_pro_signature')); - $request .= '&CUSTREF=' . (int)$order_info['order_id']; - $request .= '&PAYMENTACTION=' . $payment_type; - $request .= '&AMT=' . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false); - $request .= '&CREDITCARDTYPE=' . $this->request->post['cc_type']; - $request .= '&ACCT=' . urlencode(str_replace(' ', '', $this->request->post['cc_number'])); - $request .= '&CARDSTART=' . urlencode($this->request->post['cc_start_date_month'] . $this->request->post['cc_start_date_year']); - $request .= '&EXPDATE=' . urlencode($this->request->post['cc_expire_date_month'] . $this->request->post['cc_expire_date_year']); - $request .= '&CVV2=' . urlencode($this->request->post['cc_cvv2']); - - if ($this->request->post['cc_type'] == 'SWITCH' || $this->request->post['cc_type'] == 'SOLO') { - $request .= '&ISSUENUMBER=' . urlencode($this->request->post['cc_issue']); - } - - $request .= '&FIRSTNAME=' . urlencode($order_info['payment_firstname']); - $request .= '&LASTNAME=' . urlencode($order_info['payment_lastname']); - $request .= '&EMAIL=' . urlencode($order_info['email']); - $request .= '&PHONENUM=' . urlencode($order_info['telephone']); - $request .= '&IPADDRESS=' . urlencode($this->request->server['REMOTE_ADDR']); - $request .= '&STREET=' . urlencode($order_info['payment_address_1']); - $request .= '&CITY=' . urlencode($order_info['payment_city']); - $request .= '&STATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']); - $request .= '&ZIP=' . urlencode($order_info['payment_postcode']); - $request .= '&COUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']); - $request .= '&CURRENCYCODE=' . urlencode($order_info['currency_code']); - $request .= '&BUTTONSOURCE=' . urlencode('OpenCart_2.0_WPP'); - - if ($this->cart->hasShipping()) { - $request .= '&SHIPTONAME=' . urlencode($order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname']); - $request .= '&SHIPTOSTREET=' . urlencode($order_info['shipping_address_1']); - $request .= '&SHIPTOCITY=' . urlencode($order_info['shipping_city']); - $request .= '&SHIPTOSTATE=' . urlencode(($order_info['shipping_iso_code_2'] != 'US') ? $order_info['shipping_zone'] : $order_info['shipping_zone_code']); - $request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['shipping_iso_code_2']); - $request .= '&SHIPTOZIP=' . urlencode($order_info['shipping_postcode']); - } else { - $request .= '&SHIPTONAME=' . urlencode($order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']); - $request .= '&SHIPTOSTREET=' . urlencode($order_info['payment_address_1']); - $request .= '&SHIPTOCITY=' . urlencode($order_info['payment_city']); - $request .= '&SHIPTOSTATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']); - $request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']); - $request .= '&SHIPTOZIP=' . urlencode($order_info['payment_postcode']); - } - - if (!$this->config->get('payment_pp_pro_test')) { - $curl = curl_init('https://api-3t.paypal.com/nvp'); - } else { - $curl = curl_init('https://api-3t.sandbox.paypal.com/nvp'); - } - - curl_setopt($curl, CURLOPT_PORT, 443); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - - $response = curl_exec($curl); - - curl_close($curl); - - if (!$response) { - $this->log->write('DoDirectPayment failed: ' . curl_error($curl) . '(' . curl_errno($curl) . ')'); - } - - $response_info = array(); - - parse_str($response, $response_info); - - $json = array(); - - if (($response_info['ACK'] == 'Success') || ($response_info['ACK'] == 'SuccessWithWarning')) { - $message = ''; - - if (isset($response_info['AVSCODE'])) { - $message .= 'AVSCODE: ' . $response_info['AVSCODE'] . "\n"; - } - - if (isset($response_info['CVV2MATCH'])) { - $message .= 'CVV2MATCH: ' . $response_info['CVV2MATCH'] . "\n"; - } - - if (isset($response_info['TRANSACTIONID'])) { - $message .= 'TRANSACTIONID: ' . $response_info['TRANSACTIONID'] . "\n"; - } - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_pp_pro_order_status_id'), $message, false); - - $json['success'] = $this->url->link('checkout/success'); - } else { - $json['error'] = $response_info['L_LONGMESSAGE0']; - } - - $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($json)); - } -} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/pp_pro_iframe.php b/upload/catalog/controller/extension/payment/pp_pro_iframe.php deleted file mode 100644 index c1d5f5e672e..00000000000 --- a/upload/catalog/controller/extension/payment/pp_pro_iframe.php +++ /dev/null @@ -1,311 +0,0 @@ -load->model('checkout/order'); - $this->load->model('extension/payment/pp_pro_iframe'); - - $this->load->language('extension/payment/pp_pro_iframe'); - - if ($this->config->get('payment_pp_pro_iframe_checkout_method') == 'redirect') { - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $hosted_button_id = $this->constructButtonData($order_info); - - if ($this->config->get('payment_pp_pro_iframe_test')) { - $data['url'] = 'https://securepayments.sandbox.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess'; - } else { - $data['url'] = 'https://securepayments.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess'; - } - - if ($hosted_button_id) { - $data['code'] = $hosted_button_id; - $data['error_connection'] = ''; - } else { - $data['error_connection'] = $this->language->get('error_connection'); - } - } - - $data['create'] = HTTPS_SERVER.'index.php?route=extension/payment/pp_pro_iframe/create'; - - $data['checkout_method'] = $this->config->get('payment_pp_pro_iframe_checkout_method'); - - return $this->load->view('extension/payment/pp_pro_iframe', $data); - } - - public function create() { - $this->load->language('extension/payment/pp_pro_iframe'); - $this->load->model('checkout/order'); - $this->load->model('extension/payment/pp_pro_iframe'); - - $data['text_secure_connection'] = $this->language->get('text_secure_connection'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $hosted_button_id = $this->constructButtonData($order_info); - - if ($hosted_button_id) { - $data['code'] = $hosted_button_id; - - if ($this->config->get('payment_pp_pro_iframe_test')) { - $data['url'] = 'https://securepayments.sandbox.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess'; - } else { - $data['url'] = 'https://securepayments.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess'; - } - - $data['error_connection'] = ''; - } else { - $data['error_connection'] = $this->language->get('error_connection'); - } - - if (file_exists(DIR_APPLICATION . 'view/theme/' . $this->config->get('config_template') . '/stylesheet/stylesheet.css')) { - $data['stylesheet'] = '/catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/stylesheet.css'; - } else { - $data['stylesheet'] = '/catalog/view/theme/default/stylesheet/stylesheet.css'; - } - - $this->response->setOutput($this->load->view('extension/payment/pp_pro_iframe_body', $data)); - } - - public function notify() { - $this->load->model('extension/payment/pp_pro_iframe'); - - if (isset($this->request->post['custom'])) { - $order_id = $this->encryption->decrypt($this->config->get('config_encryption'), $this->request->post['custom']); - } else { - $order_id = 0; - } - - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($order_id); - - if ($order_info) { - $request = 'cmd=_notify-validate'; - - foreach ($this->request->post as $key => $value) { - $request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8')); - } - - if (!$this->config->get('pp_pro_iframe')) { - $curl = curl_init('https://www.paypal.com/cgi-bin/webscr'); - } else { - $curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); - } - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = curl_exec($curl); - - if (curl_errno($curl)) { - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write('pp_pro_iframe :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')'); - } - } else { - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write('pp_pro_iframe :: IPN REQUEST: ' . $request); - $log->write('pp_pro_iframe :: IPN RESPONSE: ' . $response); - } - - if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) { - $order_status_id = $this->config->get('payment_pp_pro_iframe_canceled_reversal_status_id'); - - switch ($this->request->post['payment_status']) { - case 'Canceled_Reversal': - $order_status_id = $this->config->get('payment_pp_pro_iframe_canceled_reversal_status_id'); - break; - case 'Completed': - $order_status_id = $this->config->get('payment_pp_pro_iframe_completed_status_id'); - break; - case 'Denied': - $order_status_id = $this->config->get('payment_pp_pro_iframe_denied_status_id'); - break; - case 'Expired': - $order_status_id = $this->config->get('payment_pp_pro_iframe_expired_status_id'); - break; - case 'Failed': - $order_status_id = $this->config->get('payment_pp_pro_iframe_failed_status_id'); - break; - case 'Pending': - $order_status_id = $this->config->get('payment_pp_pro_iframe_pending_status_id'); - break; - case 'Processed': - $order_status_id = $this->config->get('payment_pp_pro_iframe_processed_status_id'); - break; - case 'Refunded': - $order_status_id = $this->config->get('payment_pp_pro_iframe_processed_status_id'); - break; - case 'Reversed': - $order_status_id = $this->config->get('payment_pp_pro_iframe_reversed_status_id'); - break; - case 'Voided': - $order_status_id = $this->config->get('payment_pp_pro_iframe_voided_status_id'); - break; - } - - if (!$order_info['order_status_id']) { - $paypal_order_data = array( - 'order_id' => $order_id, - 'capture_status' => ($this->config->get('payment_pp_pro_iframe_transaction_method') == 'sale' ? 'Complete' : 'NotComplete'), - 'currency_code' => $this->request->post['mc_currency'], - 'authorization_id' => $this->request->post['txn_id'], - 'total' => $this->request->post['mc_gross'], - ); - - $paypal_iframe_order_id = $this->model_extension_payment_pp_pro_iframe->addOrder($paypal_order_data); - - $paypal_transaction_data = array( - 'paypal_iframe_order_id' => $paypal_iframe_order_id, - 'transaction_id' => $this->request->post['txn_id'], - 'parent_id' => '', - 'note' => '', - 'msgsubid' => '', - 'receipt_id' => $this->request->post['receipt_id'], - 'payment_type' => $this->request->post['payment_type'], - 'payment_status' => $this->request->post['payment_status'], - 'pending_reason' => (isset($this->request->post['pending_reason']) ? $this->request->post['pending_reason'] : ''), - 'transaction_entity' => ($this->config->get('payment_pp_pro_iframe_transaction_method') == 'sale' ? 'payment' : 'auth'), - 'amount' => $this->request->post['mc_gross'], - 'debug_data' => json_encode($this->request->post), - ); - - $this->model_extension_payment_pp_pro_iframe->addTransaction($paypal_transaction_data); - - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); - } else { - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); - } - } else { - $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id')); - } - } - - curl_close($curl); - } - } - - private function constructButtonData($order_info) { - $s_data = array(); - $s_data['METHOD'] = 'BMCreateButton'; - $s_data['VERSION'] = '65.2'; - $s_data['BUTTONCODE'] = 'TOKEN'; - - $s_data['BUTTONLANGUAGE'] = 'en'; - $s_data['BUTTONSOURCE'] = 'OpenCart_2.0_HSS'; - - $s_data['USER'] = $this->config->get('payment_pp_pro_iframe_user'); - $s_data['SIGNATURE'] = $this->config->get('payment_pp_pro_iframe_sig'); - $s_data['PWD'] = $this->config->get('payment_pp_pro_iframe_password'); - - $s_data['BUTTONTYPE'] = 'PAYMENT'; - $s_data['L_BUTTONVAR0'] = 'subtotal=' . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false); - $s_data['L_BUTTONVAR1'] = 'tax=0.00'; - $s_data['L_BUTTONVAR2'] = 'shipping=0.00'; - $s_data['L_BUTTONVAR3'] = 'handling=0.00'; - - if ($this->cart->hasShipping()) { - $s_data['L_BUTTONVAR4'] = 'first_name=' . urlencode($order_info['shipping_firstname']); - $s_data['L_BUTTONVAR5'] = 'last_name=' . urlencode($order_info['shipping_lastname']); - $s_data['L_BUTTONVAR6'] = 'address1=' . urlencode($order_info['shipping_address_1']); - $s_data['L_BUTTONVAR7'] = 'address2=' . urlencode($order_info['shipping_address_2']); - $s_data['L_BUTTONVAR8'] = 'city=' . urlencode($order_info['shipping_city']); - $s_data['L_BUTTONVAR9'] = 'state=' . urlencode($order_info['shipping_zone']); - $s_data['L_BUTTONVAR10'] = 'zip=' . urlencode($order_info['shipping_postcode']); - $s_data['L_BUTTONVAR11'] = 'country=' . urlencode($order_info['shipping_iso_code_2']); - } else { - $s_data['L_BUTTONVAR4'] = 'first_name=' . urlencode($order_info['payment_firstname']); - $s_data['L_BUTTONVAR5'] = 'last_name=' . urlencode($order_info['payment_lastname']); - $s_data['L_BUTTONVAR6'] = 'address1=' . urlencode($order_info['payment_address_1']); - $s_data['L_BUTTONVAR7'] = 'address2=' . urlencode($order_info['payment_address_2']); - $s_data['L_BUTTONVAR8'] = 'city=' . urlencode($order_info['payment_city']); - $s_data['L_BUTTONVAR9'] = 'state=' . urlencode($order_info['payment_zone']); - $s_data['L_BUTTONVAR10'] = 'zip=' . urlencode($order_info['payment_postcode']); - $s_data['L_BUTTONVAR11'] = 'country=' . urlencode($order_info['payment_iso_code_2']); - } - - $s_data['L_BUTTONVAR12'] = 'billing_first_name=' . urlencode($order_info['payment_firstname']); - $s_data['L_BUTTONVAR13'] = 'billing_last_name=' . urlencode($order_info['payment_lastname']); - $s_data['L_BUTTONVAR14'] = 'billing_address1=' . urlencode($order_info['payment_address_1']); - $s_data['L_BUTTONVAR15'] = 'billing_address2=' . urlencode($order_info['payment_address_2']); - $s_data['L_BUTTONVAR16'] = 'billing_city=' . urlencode($order_info['payment_city']); - $s_data['L_BUTTONVAR17'] = 'billing_state=' . urlencode($order_info['payment_zone']); - $s_data['L_BUTTONVAR18'] = 'billing_zip=' . urlencode($order_info['payment_postcode']); - $s_data['L_BUTTONVAR19'] = 'billing_country=' . urlencode($order_info['payment_iso_code_2']); - - $s_data['L_BUTTONVAR20'] = 'notify_url=' . $this->url->link('extension/payment/pp_pro_iframe/notify', '', true); - $s_data['L_BUTTONVAR21'] = 'cancel_return=' . $this->url->link('checkout/checkout', '', true); - $s_data['L_BUTTONVAR22'] = 'paymentaction=' . $this->config->get('payment_pp_pro_iframe_transaction_method'); - $s_data['L_BUTTONVAR23'] = 'currency_code=' . urlencode($order_info['currency_code']); - $s_data['L_BUTTONVAR26'] = 'showBillingAddress=false'; - $s_data['L_BUTTONVAR27'] = 'showShippingAddress=false'; - $s_data['L_BUTTONVAR28'] = 'showBillingEmail=false'; - $s_data['L_BUTTONVAR29'] = 'showBillingPhone=false'; - $s_data['L_BUTTONVAR30'] = 'showCustomerName=true'; - $s_data['L_BUTTONVAR31'] = 'showCardInfo=true'; - $s_data['L_BUTTONVAR32'] = 'showHostedThankyouPage=false'; - $s_data['L_BUTTONVAR33'] = 'bn=GBD'; - $s_data['L_BUTTONVAR35'] = 'address_override=true'; - $s_data['L_BUTTONVAR36'] = 'cpp_header_image=Red'; - $s_data['L_BUTTONVAR44'] = 'bodyBgColor=#AEAEAE'; - $s_data['L_BUTTONVAR47'] = 'PageTitleTextColor=Blue'; - $s_data['L_BUTTONVAR48'] = 'PageCollapseBgColor=#AEAEAE'; - $s_data['L_BUTTONVAR49'] = 'PageCollapseTextColor=#AEAEAE'; - $s_data['L_BUTTONVAR50'] = 'PageButtonBgColor=#AEAEAE'; - $s_data['L_BUTTONVAR51'] = 'orderSummaryBgColor=#AEAEAE'; - $s_data['L_BUTTONVAR55'] = 'template=templateD'; - $s_data['L_BUTTONVAR56'] = 'return=' . $this->url->link('checkout/success', '', true); - $s_data['L_BUTTONVAR57'] = 'custom=' . $this->encryption->encrypt($this->config->get('config_encryption'), $order_info['order_id']); - - if ($this->config->get('payment_pp_pro_iframe_test')) { - $url = 'https://api-3t.sandbox.paypal.com/nvp'; - } else { - $url = 'https://api-3t.paypal.com/nvp'; - } - - $curl = curl_init($url); - - curl_setopt($curl, CURLOPT_PORT, 443); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($s_data, '', "&")); - curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-VPS-REQUEST-ID: ' . md5($order_info['order_id'] . mt_rand()))); - - $response = curl_exec($curl); - - $response_data = array(); - - parse_str($response, $response_data); - - if ($this->config->get('payment_pp_pro_iframe_debug')) { - $log = new Log('pp_pro_iframe.log'); - $log->write(print_r(json_encode($response_data), 1)); - } - - curl_close($curl); - - if (!$response || !isset($response_data['HOSTEDBUTTONID'])) { - return false; - } else { - return $response_data['HOSTEDBUTTONID']; - } - } -} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/pp_standard.php b/upload/catalog/controller/extension/payment/pp_standard.php deleted file mode 100644 index fea3037e650..00000000000 --- a/upload/catalog/controller/extension/payment/pp_standard.php +++ /dev/null @@ -1,240 +0,0 @@ -load->language('extension/payment/pp_standard'); - - $data['text_testmode'] = $this->language->get('text_testmode'); - $data['button_confirm'] = $this->language->get('button_confirm'); - - $data['testmode'] = $this->config->get('payment_pp_standard_test'); - - if (!$this->config->get('payment_pp_standard_test')) { - $data['action'] = 'https://www.paypal.com/cgi-bin/webscr&pal=V4T754QB63XXL'; - } else { - $data['action'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr&pal=V4T754QB63XXL'; - } - - $this->load->model('checkout/order'); - - if(!isset($this->session->data['order_id'])) { - return false; - } - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - if ($order_info) { - $data['business'] = $this->config->get('payment_pp_standard_email'); - $data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); - - $data['products'] = array(); - - foreach ($this->cart->getProducts() as $product) { - $option_data = array(); - - foreach ($product['option'] as $option) { - if ($option['type'] != 'file') { - $value = $option['value']; - } else { - $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); - - if ($upload_info) { - $value = $upload_info['name']; - } else { - $value = ''; - } - } - - $option_data[] = array( - 'name' => (utf8_strlen($option['name']) > 64 ? utf8_substr($option['name'], 0, 62) . '..' : $option['name']), - 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ); - } - - $data['products'][] = array( - 'name' => htmlspecialchars($product['name']), - 'model' => htmlspecialchars($product['model']), - 'price' => $this->currency->format($product['price'], $order_info['currency_code'], false, false), - 'quantity' => $product['quantity'], - 'option' => $option_data, - 'weight' => $product['weight'] - ); - } - - $data['discount_amount_cart'] = 0; - - $total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $order_info['currency_code'], false, false); - - if ($total > 0) { - $data['products'][] = array( - 'name' => $this->language->get('text_total'), - 'model' => '', - 'price' => $total, - 'quantity' => 1, - 'option' => array(), - 'weight' => 0 - ); - } else { - $data['discount_amount_cart'] -= $total; - } - - $ship_to_state_codes = array( - 'BR', // Brazil - 'CA', // Canada - 'IT', // Italy - 'MX', // Mexico - 'US' // USA - ); - - if ($this->cart->hasShipping()) { - $data['no_shipping'] = 2; - $data['address_override'] = 1; - $data['first_name'] = $order_info['shipping_firstname']; - $data['last_name'] = $order_info['shipping_lastname']; - $data['address1'] = $order_info['shipping_address_1']; - $data['address2'] = $order_info['shipping_address_2']; - $data['city'] = $order_info['shipping_city']; - if (in_array($order_info['shipping_iso_code_2'], $ship_to_state_codes)) { - $data['state'] = $order_info['shipping_zone_code']; - } else { - $data['state'] = $order_info['shipping_zone']; - } - $data['zip'] = $order_info['shipping_postcode']; - $data['country'] = $order_info['shipping_iso_code_2']; - } else { - $data['no_shipping'] = 1; - $data['address_override'] = 0; - $data['first_name'] = $order_info['payment_firstname']; - $data['last_name'] = $order_info['payment_lastname']; - $data['address1'] = $order_info['payment_address_1']; - $data['address2'] = $order_info['payment_address_2']; - $data['city'] = $order_info['payment_city']; - if (in_array($order_info['payment_iso_code_2'], $ship_to_state_codes)) { - $data['state'] = $order_info['payment_zone_code']; - } else { - $data['state'] = $order_info['payment_zone']; - } - $data['zip'] = $order_info['payment_postcode']; - $data['country'] = $order_info['payment_iso_code_2']; - } - - $data['currency_code'] = $order_info['currency_code']; - $data['email'] = $order_info['email']; - $data['invoice'] = $this->session->data['order_id'] . ' - ' . $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']; - $data['lc'] = $this->session->data['language']; - $data['return'] = $this->url->link('checkout/success'); - $data['notify_url'] = $this->url->link('extension/payment/pp_standard/callback', '', true); - $data['cancel_return'] = $this->url->link('checkout/checkout', '', true); - - if (!$this->config->get('payment_pp_standard_transaction')) { - $data['paymentaction'] = 'authorization'; - } else { - $data['paymentaction'] = 'sale'; - } - - $data['custom'] = $this->session->data['order_id']; - - return $this->load->view('extension/payment/pp_standard', $data); - } - } - - public function callback() { - if (isset($this->request->post['custom'])) { - $order_id = $this->request->post['custom']; - } else { - $order_id = 0; - } - - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($order_id); - - if ($order_info) { - $request = 'cmd=_notify-validate'; - - foreach ($this->request->post as $key => $value) { - $request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8')); - } - - if (!$this->config->get('payment_pp_standard_test')) { - $curl = curl_init('https://www.paypal.com/cgi-bin/webscr'); - } else { - $curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); - } - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = curl_exec($curl); - - if (!$response) { - $this->log->write('PP_STANDARD :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')'); - } - - if ($this->config->get('payment_pp_standard_debug')) { - $this->log->write('PP_STANDARD :: IPN REQUEST: ' . $request); - $this->log->write('PP_STANDARD :: IPN RESPONSE: ' . $response); - } - - if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) { - $order_status_id = $this->config->get('config_order_status_id'); - - switch($this->request->post['payment_status']) { - case 'Canceled_Reversal': - $order_status_id = $this->config->get('payment_pp_standard_canceled_reversal_status_id'); - break; - case 'Completed': - $receiver_match = (strtolower($this->request->post['receiver_email']) == strtolower($this->config->get('payment_pp_standard_email'))); - - $total_paid_match = ((float)$this->request->post['mc_gross'] == $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)); - - if ($receiver_match && $total_paid_match) { - $order_status_id = $this->config->get('payment_pp_standard_completed_status_id'); - } - - if (!$receiver_match) { - $this->log->write('PP_STANDARD :: RECEIVER EMAIL MISMATCH! ' . strtolower($this->request->post['receiver_email'])); - } - - if (!$total_paid_match) { - $this->log->write('PP_STANDARD :: TOTAL PAID MISMATCH! ' . $this->request->post['mc_gross']); - } - break; - case 'Denied': - $order_status_id = $this->config->get('payment_pp_standard_denied_status_id'); - break; - case 'Expired': - $order_status_id = $this->config->get('payment_pp_standard_expired_status_id'); - break; - case 'Failed': - $order_status_id = $this->config->get('payment_pp_standard_failed_status_id'); - break; - case 'Pending': - $order_status_id = $this->config->get('payment_pp_standard_pending_status_id'); - break; - case 'Processed': - $order_status_id = $this->config->get('payment_pp_standard_processed_status_id'); - break; - case 'Refunded': - $order_status_id = $this->config->get('payment_pp_standard_refunded_status_id'); - break; - case 'Reversed': - $order_status_id = $this->config->get('payment_pp_standard_reversed_status_id'); - break; - case 'Voided': - $order_status_id = $this->config->get('payment_pp_standard_voided_status_id'); - break; - } - - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); - } else { - $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id')); - } - - curl_close($curl); - } - } -} diff --git a/upload/catalog/language/en-gb/extension/payment/klarna_checkout.php b/upload/catalog/language/en-gb/extension/payment/klarna_checkout.php new file mode 100644 index 00000000000..b3a8cc416b8 --- /dev/null +++ b/upload/catalog/language/en-gb/extension/payment/klarna_checkout.php @@ -0,0 +1,14 @@ +contact us.'; -$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; \ No newline at end of file +$_['error_warning'] = 'Please check the form carefully for errors.'; +$_['error_stock'] = 'Products marked with *** are not available in the desired quantity or not in stock!'; +$_['error_minimum'] = 'Minimum order amount for %s is %s!'; +$_['error_required'] = '%s required!'; +$_['error_product'] = 'Warning: There are no products in your cart!'; +$_['error_recurring_required'] = 'Please select a payment recurring!'; +$_['error_unavailable'] = 'Please use the full checkout with this order!'; +$_['error_shipping'] = 'Warning: Shipping method required!'; +$_['error_no_shipping'] = 'Warning: No Shipping options are available.'; +$_['error_firstname'] = 'First Name must be between 1 and 32 characters!'; +$_['error_lastname'] = 'Last Name must be between 1 and 32 characters!'; +$_['error_email'] = 'E-Mail address does not appear to be valid!'; +$_['error_telephone'] = 'Telephone must be between 3 and 32 characters!'; +$_['error_password'] = 'Password must be between 4 and 20 characters!'; +$_['error_confirm'] = 'Password confirmation does not match password!'; +$_['error_address_1'] = 'Address 1 must be between 3 and 128 characters!'; +$_['error_city'] = 'City must be between 2 and 128 characters!'; +$_['error_postcode'] = 'Postcode must be between 2 and 10 characters!'; +$_['error_country'] = 'Please select a country!'; +$_['error_zone'] = 'Please select a region / state!'; +$_['error_agree'] = 'Warning: You must agree to the %s!'; +$_['error_address'] = 'Warning: You must select address!'; +$_['error_custom_field'] = '%s required!'; +$_['error_order_voided'] = 'We could not process your payment. All purchase units in the order are voided. Please contact us.'; +$_['error_order_completed'] = 'We could not process your payment. The payment was authorized or the authorized payment was captured for the order. Please contact us.'; +$_['error_authorization_captured'] = 'We could not process your payment. The authorized payment has one or more captures against it. The sum of these captured payments is greater than the amount of the original authorized payment. Please contact us.'; +$_['error_authorization_denied'] = 'We could not process the transaction with this card. The funds could not be captured. Please try a different funding source.'; +$_['error_authorization_expired'] = 'We could not process your payment. The authorized payment has expired. Please contact us.'; +$_['error_capture_declined'] = 'We could not process the transaction with this card. The funds could not be captured. Please try a different funding source.'; +$_['error_capture_failed'] = 'We could not process your payment. There was an error while capturing payment. Please contact us.'; +$_['error_3ds_failed_authentication'] = 'We could not process the transaction with this card. You may have failed the challenge or the device was not verified.'; +$_['error_3ds_rejected_authentication'] = 'We could not process the transaction with this card. 3D Secure authentication was skipped by you.'; +$_['error_3ds_attempted_authentication'] = 'We could not process the transaction with this card. Card is not enrolled in 3D Secure as card issuing bank is not participating in 3D Secure.'; +$_['error_3ds_unable_authentication'] = 'We could not process the transaction with this card. Issuing bank is not able to complete authentication.'; +$_['error_3ds_challenge_authentication'] = 'We could not process the transaction with this card. Challenge required for authentication.'; +$_['error_3ds_card_ineligible'] = 'We could not process the transaction with this card. Card type and issuing bank are not ready to complete a 3D Secure authentication.'; +$_['error_3ds_system_unavailable'] = 'We could not process the transaction with this card. An error occurred with the 3D Secure authentication system.'; +$_['error_3ds_system_bypassed'] = 'We could not process the transaction with this card. 3D Secure was skipped as authentication system did not require a challenge.'; +$_['error_payment'] = 'Please choose another payment method or contact us.'; +$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; \ No newline at end of file diff --git a/upload/catalog/language/en-gb/extension/payment/pp_braintree.php b/upload/catalog/language/en-gb/extension/payment/pp_braintree.php deleted file mode 100644 index f7c2e85abaa..00000000000 --- a/upload/catalog/language/en-gb/extension/payment/pp_braintree.php +++ /dev/null @@ -1,48 +0,0 @@ -contact us for assistance!'; diff --git a/upload/catalog/language/en-gb/extension/payment/pp_payflow.php b/upload/catalog/language/en-gb/extension/payment/pp_payflow.php deleted file mode 100644 index afa9da4b1df..00000000000 --- a/upload/catalog/language/en-gb/extension/payment/pp_payflow.php +++ /dev/null @@ -1,24 +0,0 @@ -load->language('extension/payment/paypal'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_paypal_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); + $method_data = array(); + + $agree_status = $this->getAgreeStatus(); + + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && $agree_status) { + $this->load->language('extension/payment/paypal'); - if ($this->config->get('payment_paypal_total') > 0 && $this->config->get('payment_paypal_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_paypal_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_paypal_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - $method_data = array(); + if (($this->config->get('payment_paypal_total') > 0) && ($this->config->get('payment_paypal_total') > $total)) { + $status = false; + } elseif (!$this->config->get('payment_paypal_geo_zone_id')) { + $status = true; + } elseif ($query->num_rows) { + $status = true; + } else { + $status = false; + } - if ($status) { - $method_data = array( - 'code' => 'paypal', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + if ($status) { + $method_data = array( + 'code' => 'paypal', + 'title' => $this->language->get('text_paypal_title'), + 'terms' => '', + 'sort_order' => $this->config->get('payment_paypal_sort_order') + ); + } } return $method_data; } + public function hasProductInCart($product_id, $option = array(), $recurring_id = 0) { + $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' AND product_id = '" . (int)$product_id . "' AND recurring_id = '" . (int)$recurring_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'"); + + return $query->row['total']; + } + + public function getCountryByCode($code) { + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE iso_code_2 = '" . $this->db->escape($code) . "' AND status = '1'"); + + return $query->row; + } + + public function getZoneByCode($country_id, $code) { + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND (code = '" . $this->db->escape($code) . "' OR name = '" . $this->db->escape($code) . "') AND status = '1'"); + + return $query->row; + } + + public function getAgreeStatus() { + $agree_status = true; + + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' AND (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); + + if ($query->rows) { + $agree_status = false; + } + + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '220' AND status = '1' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); + + if ($query->rows) { + $agree_status = false; + } + + return $agree_status; + } + public function log($data, $title = null) { - if ($this->config->get('payment_paypal_debug')) { + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + if ($setting['general']['debug']) { $log = new Log('paypal.log'); $log->write('PayPal debug (' . $title . '): ' . json_encode($data)); } diff --git a/upload/catalog/model/extension/payment/paypal_paylater.php b/upload/catalog/model/extension/payment/paypal_paylater.php new file mode 100644 index 00000000000..0b5f27ec943 --- /dev/null +++ b/upload/catalog/model/extension/payment/paypal_paylater.php @@ -0,0 +1,51 @@ +load->model('extension/payment/paypal'); + + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); + + if ($this->config->get('payment_paypal_status') && $this->config->get('payment_paypal_client_id') && $this->config->get('payment_paypal_secret') && $agree_status) { + $this->load->language('extension/payment/paypal'); + + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_paypal_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); + + if (($this->config->get('payment_paypal_total') > 0) && ($this->config->get('payment_paypal_total') > $total)) { + $status = false; + } elseif (!$this->config->get('payment_paypal_geo_zone_id')) { + $status = true; + } elseif ($query->num_rows) { + $status = true; + } else { + $status = false; + } + + if ($status) { + // Setting + $_config = new Config(); + $_config->load('paypal'); + + $config_setting = $_config->get('paypal_setting'); + + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); + + if ($setting['message']['checkout']['status'] && ($this->session->data['currency'] == $setting['general']['currency_code'])) { + $message = $this->load->view('extension/payment/paypal/message'); + } else { + $message = ''; + } + + $method_data = array( + 'code' => 'paypal_paylater', + 'title' => $this->language->get('text_paypal_paylater_title') . $message, + 'terms' => '', + 'sort_order' => $this->config->get('payment_paypal_sort_order') + ); + } + } + + return $method_data; + } +} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/pp_braintree.php b/upload/catalog/model/extension/payment/pp_braintree.php deleted file mode 100644 index f557cfe75d7..00000000000 --- a/upload/catalog/model/extension/payment/pp_braintree.php +++ /dev/null @@ -1,191 +0,0 @@ -clientToken()->generate($data); - } else { - $client_token = Braintree_ClientToken::generate($data); - } - - return $client_token; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function addTransaction($gateway, $data) { - try { - if ($gateway != null) { - $transaction = $gateway->transaction()->sale($data); - } else { - $transaction = Braintree_Transaction::sale($data); - } - - return $transaction; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function getCustomer($gateway, $customer_id, $log = true) { - try { - if ($gateway != null) { - $customer = $gateway->customer()->find($customer_id); - } else { - $customer = Braintree_Customer::find($customer_id); - } - - return $customer; - } catch (Exception $e) { - if ($log) { - $this->log($e->getMessage()); - } - - return false; - } - } - - public function getPaymentMethod($gateway, $token) { - try { - if ($gateway != null) { - $payment_method = $gateway->paymentMethod()->find($token); - } else { - $payment_method = Braintree_PaymentMethod::find($token); - } - - return $payment_method; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function addPaymentMethod($gateway, $data) { - try { - if ($gateway != null) { - $payment_method = $gateway->paymentMethod()->create($data); - } else { - $payment_method = Braintree_PaymentMethod::create($data); - } - - return $payment_method; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function deletePaymentMethod($gateway, $token) { - try { - if ($gateway != null) { - $gateway->paymentMethod()->delete($token); - } else { - Braintree_PaymentMethod::delete($token); - } - - return true; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function getPaymentMethodNonce($gateway, $token) { - try { - if ($gateway != null) { - $response = $gateway->paymentMethodNonce()->find($token); - } else { - $response = Braintree_PaymentMethodNonce::find($token); - } - - return $response; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function createPaymentMethodNonce($gateway, $token) { - try { - if ($gateway != null) { - $response = $gateway->paymentMethodNonce()->create($token); - } else { - $response = Braintree_PaymentMethodNonce::create($token); - } - - return $response; - } catch (Exception $e) { - $this->log($e->getMessage()); - - return false; - } - } - - public function setCredentials() { - Braintree_Configuration::environment($this->config->get('payment_pp_braintree_environment')); - Braintree_Configuration::merchantId($this->config->get('payment_pp_braintree_merchant_id')); - Braintree_Configuration::publicKey($this->config->get('payment_pp_braintree_public_key')); - Braintree_Configuration::privateKey($this->config->get('payment_pp_braintree_private_key')); - } - - public function setGateway($access_token) { - return new Braintree_Gateway(array('accessToken' => $access_token)); - } - - public function getMethod($address, $total) { - $this->load->language('extension/payment/pp_braintree'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_braintree_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_braintree_total') > 0 && $this->config->get('payment_pp_braintree_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_braintree_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_braintree', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_braintree_sort_order') - ); - } - - return $method_data; - } - - public function getSupportedCurrencies() { - $currencies = array(); - - foreach ($this->config->get('payment_pp_braintree_account') as $currency => $account) { - if ($account['status']) { - $currencies[] = $currency; - } - } - - return $currencies; - } - - public function log($data) { - if ($this->config->get('payment_pp_braintree_debug')) { - $log = new Log('braintree.log'); - $log->write(print_r($data, true)); - } - } -} diff --git a/upload/catalog/model/extension/payment/pp_express.php b/upload/catalog/model/extension/payment/pp_express.php deleted file mode 100644 index 8fc0fe71511..00000000000 --- a/upload/catalog/model/extension/payment/pp_express.php +++ /dev/null @@ -1,354 +0,0 @@ -load->language('extension/payment/pp_express'); - - $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE `geo_zone_id` = '" . (int)$this->config->get('payment_pp_express_geo_zone_id') . "' AND `country_id` = '" . (int)$address['country_id'] . "' AND (`zone_id` = '" . (int)$address['zone_id'] . "' OR `zone_id` = '0')"); - - if ($this->config->get('payment_pp_express_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_express_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_express', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_express_sort_order') - ); - } - - return $method_data; - } - - public function addOrder($order_data) { - /** - * 1 to 1 relationship with order table (extends order info) - */ - - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_order` SET - `order_id` = '" . (int)$order_data['order_id'] . "', - `date_added` = NOW(), - `date_modified` = NOW(), - `capture_status` = '" . $this->db->escape($order_data['capture_status']) . "', - `currency_code` = '" . $this->db->escape($order_data['currency_code']) . "', - `total` = '" . (float)$order_data['total'] . "', - `authorization_id` = '" . $this->db->escape($order_data['authorization_id']) . "'"); - - return $this->db->getLastId(); - } - - public function addTransaction($transaction_data) { - /** - * 1 to many relationship with paypal order table, many transactions per 1 order - */ - - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_order_transaction` SET - `paypal_order_id` = '" . (int)$transaction_data['paypal_order_id'] . "', - `transaction_id` = '" . $this->db->escape($transaction_data['transaction_id']) . "', - `parent_id` = '" . $this->db->escape($transaction_data['parent_id']) . "', - `date_added` = NOW(), - `note` = '" . $this->db->escape($transaction_data['note']) . "', - `msgsubid` = '" . $this->db->escape($transaction_data['msgsubid']) . "', - `receipt_id` = '" . $this->db->escape($transaction_data['receipt_id']) . "', - `payment_type` = '" . $this->db->escape($transaction_data['payment_type']) . "', - `payment_status` = '" . $this->db->escape($transaction_data['payment_status']) . "', - `pending_reason` = '" . $this->db->escape($transaction_data['pending_reason']) . "', - `transaction_entity` = '" . $this->db->escape($transaction_data['transaction_entity']) . "', - `amount` = '" . (float)$transaction_data['amount'] . "', - `debug_data` = '" . $this->db->escape($transaction_data['debug_data']) . "'"); - } - - public function paymentRequestInfo() { - - $data['PAYMENTREQUEST_0_SHIPPINGAMT'] = ''; - $data['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->session->data['currency']; - $data['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->config->get('payment_pp_express_transaction'); - - $i = 0; - $item_total = 0; - - foreach ($this->cart->getProducts() as $item) { - $data['L_PAYMENTREQUEST_0_DESC' . $i] = ''; - - $option_count = 0; - foreach ($item['option'] as $option) { - if ($option['type'] != 'file') { - $value = $option['value']; - } else { - $filename = $this->encryption->decrypt($this->config->get('config_encryption'), $option['value']); - $value = utf8_substr($filename, 0, utf8_strrpos($filename, '.')); - } - - $data['L_PAYMENTREQUEST_0_DESC' . $i] .= ($option_count > 0 ? ', ' : '') . $option['name'] . ':' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value); - - $option_count++; - } - - $data['L_PAYMENTREQUEST_0_DESC' . $i] = substr($data['L_PAYMENTREQUEST_0_DESC' . $i], 0, 126); - - $item_price = $this->currency->format($item['price'], $this->session->data['currency'], false, false); - - $data['L_PAYMENTREQUEST_0_NAME' . $i] = $item['name']; - $data['L_PAYMENTREQUEST_0_NUMBER' . $i] = $item['model']; - $data['L_PAYMENTREQUEST_0_AMT' . $i] = $item_price; - - $item_total += number_format($item_price * $item['quantity'], 2, '.', ''); - - $data['L_PAYMENTREQUEST_0_QTY' . $i] = $item['quantity']; - - $data['L_PAYMENTREQUEST_0_ITEMURL' . $i] = $this->url->link('product/product', 'product_id=' . $item['product_id']); - - if ($this->config->get('config_cart_weight')) { - $weight = $this->weight->convert($item['weight'], $item['weight_class_id'], $this->config->get('config_weight_class_id')); - $data['L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE' . $i] = number_format($weight / $item['quantity'], 2, '.', ''); - $data['L_PAYMENTREQUEST_0_ITEMWEIGHTUNIT' . $i] = $this->weight->getUnit($this->config->get('config_weight_class_id')); - } - - if ($item['length'] > 0 || $item['width'] > 0 || $item['height'] > 0) { - $unit = $this->length->getUnit($item['length_class_id']); - $data['L_PAYMENTREQUEST_0_ITEMLENGTHVALUE' . $i] = $item['length']; - $data['L_PAYMENTREQUEST_0_ITEMLENGTHUNIT' . $i] = $unit; - $data['L_PAYMENTREQUEST_0_ITEMWIDTHVALUE' . $i] = $item['width']; - $data['L_PAYMENTREQUEST_0_ITEMWIDTHUNIT' . $i] = $unit; - $data['L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE' . $i] = $item['height']; - $data['L_PAYMENTREQUEST_0_ITEMHEIGHTUNIT' . $i] = $unit; - } - - $i++; - } - - if (!empty($this->session->data['vouchers'])) { - foreach ($this->session->data['vouchers'] as $voucher) { - $item_total += $this->currency->format($voucher['amount'], $this->session->data['currency'], false, false); - - $data['L_PAYMENTREQUEST_0_DESC' . $i] = ''; - $data['L_PAYMENTREQUEST_0_NAME' . $i] = $voucher['description']; - $data['L_PAYMENTREQUEST_0_NUMBER' . $i] = 'VOUCHER'; - $data['L_PAYMENTREQUEST_0_QTY' . $i] = 1; - $data['L_PAYMENTREQUEST_0_AMT' . $i] = $this->currency->format($voucher['amount'], $this->session->data['currency'], false, false); - $i++; - } - } - - // Totals - $this->load->model('setting/extension'); - - $totals = array(); - $taxes = $this->cart->getTaxes(); - $total = 0; - - // Because __call can not keep var references so we put them into an array. - $total_data = array( - 'totals' => &$totals, - 'taxes' => &$taxes, - 'total' => &$total - ); - - // Display prices - if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = array(); - - $results = $this->model_setting_extension->getExtensions('total'); - - foreach ($results as $key => $value) { - $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); - } - - array_multisort($sort_order, SORT_ASC, $results); - - foreach ($results as $result) { - if ($this->config->get('total_' . $result['code'] . '_status')) { - $this->load->model('extension/total/' . $result['code']); - - // We have to put the totals in an array so that they pass by reference. - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); - } - - $sort_order = array(); - - foreach ($totals as $key => $value) { - $sort_order[$key] = $value['sort_order']; - } - - array_multisort($sort_order, SORT_ASC, $totals); - } - } - - foreach ($total_data['totals'] as $total_row) { - if (!in_array($total_row['code'], array('total', 'sub_total'))) { - if ($total_row['value'] != 0) { - $item_price = $this->currency->format($total_row['value'], $this->session->data['currency'], false, false); - - $data['L_PAYMENTREQUEST_0_NUMBER' . $i] = $total_row['code']; - $data['L_PAYMENTREQUEST_0_NAME' . $i] = $total_row['title']; - $data['L_PAYMENTREQUEST_0_AMT' . $i] = $this->currency->format($total_row['value'], $this->session->data['currency'], false, false); - $data['L_PAYMENTREQUEST_0_QTY' . $i] = 1; - - $item_total = $item_total + $item_price; - $i++; - } - } - } - - $data['PAYMENTREQUEST_0_ITEMAMT'] = number_format($item_total, 2, '.', ''); - $data['PAYMENTREQUEST_0_AMT'] = number_format($item_total, 2, '.', ''); - - $z = 0; - - $recurring_products = $this->cart->getRecurringProducts(); - - if ($recurring_products) { - $this->load->language('extension/payment/pp_express'); - - foreach ($recurring_products as $item) { - $data['L_BILLINGTYPE' . $z] = 'RecurringPayments'; - - if ($item['recurring']['trial']) { - $trial_amt = $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $trial_text = sprintf($this->language->get('text_trial'), $trial_amt, $item['recurring']['trial_cycle'], $item['recurring']['trial_frequency'], $item['recurring']['trial_duration']); - } else { - $trial_text = ''; - } - - $recurring_amt = $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $item['quantity'] . ' ' . $this->session->data['currency']; - $recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $item['recurring']['cycle'], $item['recurring']['frequency']); - - if ($item['recurring']['duration'] > 0) { - $recurring_description .= sprintf($this->language->get('text_length'), $item['recurring']['duration']); - } - - $data['L_BILLINGAGREEMENTDESCRIPTION' . $z] = $recurring_description; - $z++; - } - } - - return $data; - } - - public function getTotalCaptured($paypal_order_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' AND `pending_reason` != 'authorization' AND `pending_reason` != 'paymentreview' AND (`payment_status` = 'Partially-Refunded' OR `payment_status` = 'Completed' OR `payment_status` = 'Pending') AND `transaction_entity` = 'payment'"); - - return $qry->row['amount']; - } - - public function getTotalRefunded($paypal_order_id) { - $qry = $this->db->query("SELECT SUM(`amount`) AS `amount` FROM `" . DB_PREFIX . "paypal_order_transaction` WHERE `paypal_order_id` = '" . (int)$paypal_order_id . "' AND `payment_status` = 'Refunded'"); - - return $qry->row['amount']; - } - - public function getTransactionRow($transaction_id) { - $qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_order_transaction` `pt` LEFT JOIN `" . DB_PREFIX . "paypal_order` `po` ON `pt`.`paypal_order_id` = `po`.`paypal_order_id` WHERE `pt`.`transaction_id` = '" . $this->db->escape($transaction_id) . "' LIMIT 1"); - - if ($qry->num_rows > 0) { - return $qry->row; - } else { - return false; - } - } - - public function updateOrder($capture_status, $order_id) { - $this->db->query("UPDATE `" . DB_PREFIX . "paypal_order` SET `date_modified` = now(), `capture_status` = '" . $this->db->escape($capture_status) . "' WHERE `order_id` = '" . (int)$order_id . "'"); - } - - public function call($data) { - if ($this->config->get('payment_pp_express_test')) { - $api_url = 'https://api-3t.sandbox.paypal.com/nvp'; - $api_user = $this->config->get('payment_pp_express_sandbox_username'); - $api_password = $this->config->get('payment_pp_express_sandbox_password'); - $api_signature = $this->config->get('payment_pp_express_sandbox_signature'); - } else { - $api_url = 'https://api-3t.paypal.com/nvp'; - $api_user = $this->config->get('payment_pp_express_username'); - $api_password = $this->config->get('payment_pp_express_password'); - $api_signature = $this->config->get('payment_pp_express_signature'); - } - - $settings = array( - 'USER' => $api_user, - 'PWD' => $api_password, - 'SIGNATURE' => $api_signature, - 'VERSION' => '109.0', - 'BUTTONSOURCE' => 'OpenCart_2.0_EC' - ); - - $this->log($data, 'Call data'); - - $defaults = array( - CURLOPT_POST => 1, - CURLOPT_HEADER => 0, - CURLOPT_URL => $api_url, - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1", - CURLOPT_FRESH_CONNECT => 1, - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_FORBID_REUSE => 1, - CURLOPT_TIMEOUT => 0, - CURLOPT_SSL_VERIFYPEER => 0, - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_POSTFIELDS => http_build_query(array_merge($data, $settings), '', "&"), - ); - - $ch = curl_init(); - - curl_setopt_array($ch, $defaults); - - if (!$result = curl_exec($ch)) { - $this->log(array('error' => curl_error($ch), 'errno' => curl_errno($ch)), 'cURL failed'); - } - - $this->log($result, 'Result'); - - curl_close($ch); - - return $this->cleanReturn($result); - } - - public function recurringPayments() { - /* - * Used by the checkout to state the module - * supports recurring recurrings. - */ - return true; - } - - public function createToken($len = 32) { - $base = 'ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789'; - $max = strlen($base)-1; - $activate_code = ''; - mt_srand((float)microtime()*1000000); - - while (strlen($activate_code)<$len+1) { - $activate_code .= $base[mt_rand(0, $max)]; - } - - return $activate_code; - } - - public function log($data, $title = null) { - if ($this->config->get('payment_pp_express_debug')) { - $this->log->write('PayPal Express debug (' . $title . '): ' . json_encode($data)); - } - } - - public function cleanReturn($data) { - $data = explode('&', $data); - - $arr = array(); - - foreach ($data as $k=>$v) { - $tmp = explode('=', $v); - $arr[$tmp[0]] = isset($tmp[1]) ? urldecode($tmp[1]) : ''; - } - - return $arr; - } -} diff --git a/upload/catalog/model/extension/payment/pp_payflow.php b/upload/catalog/model/extension/payment/pp_payflow.php deleted file mode 100644 index a8cbcefbe3e..00000000000 --- a/upload/catalog/model/extension/payment/pp_payflow.php +++ /dev/null @@ -1,31 +0,0 @@ -load->language('extension/payment/pp_payflow'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_payflow_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_payflow_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_payflow_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_payflow', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_payflow_sort_order') - ); - } - - return $method_data; - } -} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/pp_payflow_iframe.php b/upload/catalog/model/extension/payment/pp_payflow_iframe.php deleted file mode 100644 index c794ead0a62..00000000000 --- a/upload/catalog/model/extension/payment/pp_payflow_iframe.php +++ /dev/null @@ -1,119 +0,0 @@ -load->language('extension/payment/pp_payflow_iframe'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_payflow_iframe_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_payflow_iframe_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_payflow_iframe_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_payflow_iframe', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_payflow_iframe_sort_order') - ); - } - - return $method_data; - } - - public function getOrderId($secure_token_id) { - $result = $this->db->query("SELECT `order_id` FROM `" . DB_PREFIX . "paypal_payflow_iframe_order` WHERE `secure_token_id` = '" . $this->db->escape($secure_token_id) . "'")->row; - - if ($result) { - $order_id = $result['order_id']; - } else { - $order_id = false; - } - - return $order_id; - } - - public function addOrder($order_id, $secure_token_id) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_payflow_iframe_order` SET `order_id` = '" . (int)$order_id . "', `secure_token_id` = '" . $this->db->escape($secure_token_id) . "'"); - } - - public function updateOrder($data) { - $this->db->query(" - UPDATE `" . DB_PREFIX . "paypal_payflow_iframe_order` - SET `transaction_reference` = '" . $this->db->escape($data['transaction_reference']) . "', - `transaction_type` = '" . $this->db->escape($data['transaction_type']) . "', - `complete` = " . (int)$data['complete'] . " - WHERE `secure_token_id` = '" . $this->db->escape($data['secure_token_id']) . "' - "); - } - - public function call($data) { - $default_parameters = array( - 'USER' => $this->config->get('payment_pp_payflow_iframe_user'), - 'VENDOR' => $this->config->get('payment_pp_payflow_iframe_vendor'), - 'PWD' => $this->config->get('payment_pp_payflow_iframe_password'), - 'PARTNER' => $this->config->get('payment_pp_payflow_iframe_partner'), - 'BUTTONSOURCE' => 'OpenCart_Cart_PFP', - ); - - $call_parameters = array_merge($data, $default_parameters); - - if ($this->config->get('payment_pp_payflow_iframe_test')) { - $url = 'https://pilot-payflowpro.paypal.com'; - } else { - $url = 'https://payflowpro.paypal.com'; - } - - $query_params = array(); - - foreach ($call_parameters as $key => $value) { - $query_params[] = $key . '=' . utf8_decode($value); - } - - $this->log('Call data: ' . implode('&', $query_params)); - - $curl = curl_init($url); - - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, implode('&', $query_params)); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_HEADER, false); - curl_setopt($curl, CURLOPT_TIMEOUT, 30); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - - $response = curl_exec($curl); - - $this->log('Response data: ' . $response); - - $response_params = array(); - parse_str($response, $response_params); - - return $response_params; - } - - public function addTransaction($data) { - $this->db->query(" - INSERT INTO " . DB_PREFIX . "paypal_payflow_iframe_order_transaction - SET order_id = " . (int)$data['order_id'] . ", - transaction_reference = '" . $this->db->escape($data['transaction_reference']) . "', - transaction_type = '" . $this->db->escape($data['type']) . "', - `time` = NOW(), - `amount` = '" . $this->db->escape($data['amount']) . "' - "); - } - - public function log($message) { - if ($this->config->get('payment_pp_payflow_iframe_debug')) { - $log = new Log('payflow-iframe.log'); - $log->write($message); - } - } -} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/pp_pro.php b/upload/catalog/model/extension/payment/pp_pro.php deleted file mode 100644 index 68400ba0b01..00000000000 --- a/upload/catalog/model/extension/payment/pp_pro.php +++ /dev/null @@ -1,31 +0,0 @@ -load->language('extension/payment/pp_pro'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_pro_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_pro_total') > 0 && $this->config->get('payment_pp_pro_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_pro_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_pro', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_pro_sort_order') - ); - } - - return $method_data; - } -} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/pp_pro_iframe.php b/upload/catalog/model/extension/payment/pp_pro_iframe.php deleted file mode 100644 index b07720f910d..00000000000 --- a/upload/catalog/model/extension/payment/pp_pro_iframe.php +++ /dev/null @@ -1,41 +0,0 @@ -load->language('extension/payment/pp_pro_iframe'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_pro_iframe_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_pro_iframe_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_pro_iframe_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_pro_iframe', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_pro_iframe_sort_order') - ); - } - - return $method_data; - } - - public function addOrder($order_data) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_iframe_order` SET `order_id` = '" . (int)$order_data['order_id'] . "', `date_added` = NOW(), `date_modified` = NOW(), `capture_status` = '" . $this->db->escape($order_data['capture_status']) . "', `currency_code` = '" . $this->db->escape($order_data['currency_code']) . "', `total` = '" . (float)$order_data['total'] . "', `authorization_id` = '" . $this->db->escape($order_data['authorization_id']) . "'"); - - return $this->db->getLastId(); - } - - public function addTransaction($transaction_data) { - $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_iframe_order_transaction` SET `paypal_iframe_order_id` = '" . (int)$transaction_data['paypal_iframe_order_id'] . "', `transaction_id` = '" . $this->db->escape($transaction_data['transaction_id']) . "', `parent_id` = '" . $this->db->escape($transaction_data['parent_id']) . "', `date_added` = NOW(), `note` = '" . $this->db->escape($transaction_data['note']) . "', `msgsubid` = '" . $this->db->escape($transaction_data['msgsubid']) . "', `receipt_id` = '" . $this->db->escape($transaction_data['receipt_id']) . "', `payment_type` = '" . $this->db->escape($transaction_data['payment_type']) . "', `payment_status` = '" . $this->db->escape($transaction_data['payment_status']) . "', `pending_reason` = '" . $this->db->escape($transaction_data['pending_reason']) . "', `transaction_entity` = '" . $this->db->escape($transaction_data['transaction_entity']) . "', `amount` = '" . (float)$transaction_data['amount'] . "', `debug_data` = '" . $this->db->escape($transaction_data['debug_data']) . "'"); - } -} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/pp_standard.php b/upload/catalog/model/extension/payment/pp_standard.php deleted file mode 100644 index 6eacb1d451a..00000000000 --- a/upload/catalog/model/extension/payment/pp_standard.php +++ /dev/null @@ -1,63 +0,0 @@ -load->language('extension/payment/pp_standard'); - - $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_pp_standard_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); - - if ($this->config->get('payment_pp_standard_total') > $total) { - $status = false; - } elseif (!$this->config->get('payment_pp_standard_geo_zone_id')) { - $status = true; - } elseif ($query->num_rows) { - $status = true; - } else { - $status = false; - } - - $currencies = array( - 'AUD', - 'CAD', - 'EUR', - 'GBP', - 'JPY', - 'USD', - 'NZD', - 'CHF', - 'HKD', - 'SGD', - 'SEK', - 'DKK', - 'PLN', - 'NOK', - 'HUF', - 'CZK', - 'ILS', - 'MXN', - 'MYR', - 'BRL', - 'PHP', - 'TWD', - 'THB', - 'TRY', - 'RUB' - ); - - if (!in_array(strtoupper($this->session->data['currency']), $currencies)) { - $status = false; - } - - $method_data = array(); - - if ($status) { - $method_data = array( - 'code' => 'pp_standard', - 'title' => $this->language->get('text_title'), - 'terms' => '', - 'sort_order' => $this->config->get('payment_pp_standard_sort_order') - ); - } - - return $method_data; - } -} diff --git a/upload/catalog/view/javascript/paypal/paypal.js b/upload/catalog/view/javascript/paypal/paypal.js new file mode 100644 index 00000000000..892ba5771c1 --- /dev/null +++ b/upload/catalog/view/javascript/paypal/paypal.js @@ -0,0 +1,696 @@ +var PayPalAPI = (function () { + var paypal_data = []; + var paypal_script = []; + var paypal_sdk = []; + var paypal_callback; + + var showPayPalAlert = function(data) { + $('#paypal_form .alert').remove(); + + if (data['error'] && data['error']['warning']) { + if ($('#paypal_form').length) { + $('#paypal_form').prepend('
' + data['error']['warning'] + '
'); + } else { + alert(data['error']['warning']); + } + } + }; + + var getQueryParams = function(url) { + const param_arr = url.slice(url.indexOf('?') + 1).split('&'); + const params = {}; + + param_arr.map(param => { + const [key, val] = param.split('='); + params[key] = decodeURIComponent(val); + }) + + return params; + }; + + var updatePayPalData = function() { + var params = []; + var script_file = document.getElementsByTagName('script'); + + for (var i = 0; i < script_file.length; i++) { + if (script_file[i].hasAttribute('src') && (script_file[i].getAttribute('src').indexOf('paypal.js') !== -1)) { + params = getQueryParams(script_file[i].getAttribute('src')); + + break; + } + } + + paypal_data = params; + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/getData', + data: paypal_data, + dataType: 'json', + async: false, + success: function(json) { + paypal_data = json; + + showPayPalAlert(json); + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + }; + + var readyPayPalSDK = function() { + if (typeof PayPalSDK === 'undefined') { + setTimeout(readyPayPalSDK, 100); + } else { + paypal_sdk[paypal_script.length - 1] = PayPalSDK; + + initPayPalSDK(); + } + }; + + var loadPayPalSDK = function() { + var html = ''; + + if (paypal_data['components'].includes('buttons')) { + if (!$('#paypal_button').length) { + if ($(paypal_data['button_insert_tag']).length) { + html = '
'; + + eval("$('" + paypal_data['button_insert_tag'] + "')." + paypal_data['button_insert_type'] + "(html)"); + } + } + } + + if (paypal_data['components'].includes('messages')) { + if (!$('#paypal_message').length) { + if ($(paypal_data['message_insert_tag']).length) { + html = '
'; + + eval("$('" + paypal_data['message_insert_tag'] + "')." + paypal_data['message_insert_type'] + "(html)"); + } + } + } + + var src_data = {}; + + src_data['components'] = paypal_data['components'].join(','); + src_data['client-id'] = paypal_data['client_id']; + src_data['merchant-id'] = paypal_data['merchant_id']; + src_data['currency'] = paypal_data['currency_code']; + src_data['intent'] = paypal_data['transaction_method']; + + if (paypal_data['button_enable_funding'] && paypal_data['button_enable_funding'].length) { + src_data['enable-funding'] = paypal_data['button_enable_funding'].join(','); + } + + if (paypal_data['button_disable_funding'] && paypal_data['button_disable_funding'].length) { + src_data['disable-funding'] = paypal_data['button_disable_funding'].join(','); + } + + var src = 'https://www.paypal.com/sdk/js?' + $.param(src_data); + var script_count = paypal_script.length; + var script_load_status = 0; + + for (var i = 0; i < script_count; i++) { + if (paypal_script[i].src == src) { + script_load_status = 1; + + break; + } + } + + if (!script_load_status) { + if (typeof PayPalSDK !== 'undefined') { + delete PayPalSDK; + } + + paypal_script[script_count] = document.createElement('script'); + paypal_script[script_count].type = 'text/javascript'; + paypal_script[script_count].src = src; + paypal_script[script_count].setAttribute('data-partner-attribution-id', paypal_data['partner_attribution_id']); + paypal_script[script_count].setAttribute('data-client-token', paypal_data['client_token']); + paypal_script[script_count].setAttribute('data-namespace', 'PayPalSDK'); + + paypal_script[script_count].async = false; + paypal_script[script_count].onload = readyPayPalSDK(); + + document.querySelector('body').appendChild(paypal_script[script_count]); + } else if (paypal_sdk[i]) { + PayPalSDK = paypal_sdk[i]; + + initPayPalSDK(); + } + }; + + var initPayPalSDK = function() { + if (paypal_data['components'].includes('buttons') && $('#paypal_button').length && !$('#paypal_button_container').html()) { + $('#paypal_button').css('text-align', paypal_data['button_align']); + + if (paypal_data['button_width']) { + $('#paypal_button_container').css('display', 'inline-block'); + $('#paypal_button_container').css('width', paypal_data['button_width']); + } else { + $('#paypal_button_container').css('display', 'block'); + $('#paypal_button_container').css('width', 'auto'); + } + + try { + var paypal_button_data = { + env: paypal_data['environment'], + locale: paypal_data['locale'], + style: { + layout: ((paypal_data['page_code'] != 'checkout') ? 'horizontal' : 'vertical'), + size: paypal_data['button_size'], + color: paypal_data['button_color'], + shape: paypal_data['button_shape'], + label: paypal_data['button_label'], + tagline: ((paypal_data['page_code'] != 'checkout') ? paypal_data['button_tagline'] : 'false') + }, + // Set up the transaction + createOrder: function(data, actions) { + paypal_order_id = false; + + product_data = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/createOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'button', 'product' : product_data}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + paypal_order_id = json['paypal_order_id']; + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + + return paypal_order_id; + }, + // Finalize the transaction + onApprove: function(data, actions) { + // Call your server to save the transaction + restart = false; + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/approveOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'button', 'paypal_order_id': data.orderID}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + if (json['restart']) { + restart = json['restart']; + } + + if (json['url']) { + location = json['url']; + } + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + + if (restart) { + return actions.restart(); + } + } + }; + + if (paypal_data['button_funding_source']) { + paypal_button_data['fundingSource'] = paypal_data['button_funding_source']; + } + + var paypal_button = PayPalSDK.Buttons(paypal_button_data); + + if (paypal_button.isEligible()) { + paypal_button.render('#paypal_button_container'); + } + } catch (error) { + console.error('PayPal Express failed during startup', error); + } + + $('#paypal_button_container').removeClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('applepay') && $('#applepay_button').length && !$('#applepay_button_container').html()) { + if (window.ApplePaySession && window.ApplePaySession?.supportsVersion(4) && ApplePaySession.canMakePayments()) { + initApplePaySDK().catch(console.log); + } else { + $('#applepay_button').remove(); + + console.log('This device does not support Apple Pay'); + } + } + + if (paypal_data['components'].includes('hosted-fields') && $('#paypal_card').length && !$('#paypal_card_form').find('iframe').length) { + $('#paypal_card').css('text-align', paypal_data['card_align']); + + if (paypal_data['card_width']) { + $('#paypal_card_container').css('display', 'inline-block'); + $('#paypal_card_container').css('width', paypal_data['card_width']); + } else { + $('#paypal_card_container').css('display', 'block'); + $('#paypal_card_container').css('width', 'auto'); + } + + try { + // Check if card fields are eligible to render for the buyer's country. The card fields are not eligible in all countries where buyers are located. + if (PayPalSDK.HostedFields.isEligible() === true) { + var paypal_card_form = document.querySelector('#paypal_card_form'); + var paypal_button_submit = document.querySelector('#paypal_button_submit'); + + PayPalSDK.HostedFields.render({ + styles: { + 'input': { + 'color': '#282c37', + 'transition': 'color 0.1s', + 'line-height': '3' + }, + 'input.invalid': { + 'color': '#E53A40' + }, + ':-ms-input-placeholder': { + 'color': 'rgba(0,0,0,0.6)' + }, + ':-moz-placeholder': { + 'color': 'rgba(0,0,0,0.6)' + } + }, + fields: { + number: { + selector: '#card_number', + placeholder: '#### #### #### ####' + }, + cvv: { + selector: '#cvv', + placeholder: '###' + }, + expirationDate: { + selector: '#expiration_date', + placeholder: 'MM / YYYY' + } + }, + createOrder: function(data, actions) { + paypal_order_id = false; + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/createOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'card'}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + paypal_order_id = json['paypal_order_id']; + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + + return paypal_order_id; + } + }).then(function(hostedFieldsInstance) { + hostedFieldsInstance.on('blur', function (event) { + console.log('CCF Event "blur", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('focus', function (event) { + console.log('CCF Event "focus", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('validityChange', function (event) { + console.log('CCF Event "validityChange", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + // Check if all fields are valid, then show submit button + var formValid = Object.keys(event.fields).every(function (key) { + return event.fields[key].isValid; + }); + + if (formValid) { + $('#paypal_button_submit').addClass('show-button'); + } else { + $('#paypal_button_submit').removeClass('show-button'); + } + }); + + hostedFieldsInstance.on('notEmpty', function (event) { + console.log('CCF Event "notEmpty", state=' + hostedFieldsInstance.getState() + ', event=' + event); + }); + + hostedFieldsInstance.on('empty', function (event) { + console.log('CCF Event "empty", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + $(paypal_card_form).removeClass().addClass('well'); + $('#card_image').removeClass(); + }); + + hostedFieldsInstance.on('cardTypeChange', function (event) { + console.log('CCF Event "cardTypeChange", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + $(paypal_card_form).removeClass().addClass('well'); + $('#card_image').removeClass(); + + // Change card bg depending on card type + if (event.cards.length === 1) { + $(paypal_card_form).addClass(event.cards[0].type); + $('#card_image').addClass(event.cards[0].type); + + // Change the CVV length for AmericanExpress cards + if (event.cards[0].code.size === 4) { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '####' + }); + } else { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '###' + }); + } + } else { + hostedFieldsInstance.setAttribute({ + field: 'cvv', + attribute: 'placeholder', + value: '###' + }); + } + }); + + paypal_button_submit.addEventListener('click', function (event) { + event.preventDefault(); + + if ($('#paypal_button_submit').hasClass('show-button')) { + console.log('CCF Event "click", state=' + hostedFieldsInstance.getState() + ',event=' + event); + + $('#paypal_card_container').addClass('paypal-spinner'); + + hostedFieldsInstance.submit({ + // Need to specify when triggering 3D Secure authentication + contingencies: (paypal_data['card_secure_status'] ? ['3D_SECURE'] : '') + + }).then(function (payload) { + console.log('PayPal CCF submitted:', payload); + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/approveOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'card', 'payload': JSON.stringify(payload)}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + if (json['url']) { + location = json['url']; + } + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + }, + complete: function() { + $('#paypal_card_container').removeClass('paypal-spinner'); + } + }); + }); + } + }, false); + }); + } else { + console.log('Not eligible for CCF'); + } + } catch (error) { + console.error('PayPal Card failed during startup', error); + } + + $('#paypal_card_container').removeClass('paypal-spinner'); + } + + if (paypal_data['components'].includes('messages') && $('#paypal_message').length && !$('#paypal_message_container').html()) { + $('#paypal_message').css('text-align', paypal_data['message_align']); + + if (paypal_data['message_width']) { + $('#paypal_message_container').css('display', 'inline-block'); + $('#paypal_message_container').css('width', paypal_data['message_width']); + } else { + $('#paypal_message_container').css('display', 'block'); + $('#paypal_message_container').css('width', 'auto'); + } + + var paypal_message = document.createElement('div'); + + paypal_message.setAttribute('data-pp-message', ''); + + if (paypal_data['page_code'] == 'product') { + paypal_message.setAttribute('data-pp-placement', 'product'); + } + + if (paypal_data['page_code'] == 'cart') { + paypal_message.setAttribute('data-pp-placement', 'cart'); + } + + if (paypal_data['page_code'] == 'checkout') { + paypal_message.setAttribute('data-pp-placement', 'payment'); + } + + paypal_message.setAttribute('data-pp-amount', paypal_data['message_amount']); + paypal_message.setAttribute('data-pp-style-layout', paypal_data['message_layout']); + + if (paypal_data['message_layout'] == 'text') { + paypal_message.setAttribute('data-pp-style-text-color', paypal_data['message_text_color']); + paypal_message.setAttribute('data-pp-style-text-size', paypal_data['message_text_size']); + } else { + paypal_message.setAttribute('data-pp-style-color', paypal_data['message_flex_color']); + paypal_message.setAttribute('data-pp-style-ratio', paypal_data['message_flex_ratio']); + } + + document.querySelector('#paypal_message_container').appendChild(paypal_message); + + $('#paypal_message_container').removeClass('paypal-spinner'); + } + + if (paypal_callback && typeof paypal_callback == 'function') { + paypal_callback(); + } + }; + + var initApplePaySDK = async function() { + const ApplePaySDK = PayPalSDK.Applepay(); + const { + isEligible, + countryCode, + currencyCode, + merchantCapabilities, + supportedNetworks, + } = await ApplePaySDK.config(); + + if (!isEligible) { + $('#applepay_button').remove(); + + throw 'Apple Pay is not eligible'; + } + + $('#applepay_button').css('text-align', paypal_data['applepay_button_align']); + + var applepay_button_style = []; + + if (paypal_data['applepay_button_width']) { + $('#applepay_button_container').css('display', 'inline-block'); + $('#applepay_button_container').css('width', paypal_data['applepay_button_width']); + } else { + $('#applepay_button_container').css('display', 'block'); + $('#applepay_button_container').css('width', 'auto'); + } + + var applepay_button = document.createElement('apple-pay-button'); + + applepay_button.setAttribute('id', 'apple-pay-button'); + applepay_button.setAttribute('buttonstyle', paypal_data['applepay_button_color']); + applepay_button.setAttribute('type', paypal_data['applepay_button_type']); + applepay_button.setAttribute('locale', paypal_data['locale']); + + var applepay_button_style = []; + + applepay_button_style.push('display: inline-block'); + + if (paypal_data['applepay_button_width']) { + applepay_button_style.push('--apple-pay-button-width: ' + paypal_data['applepay_button_width']); + } else { + applepay_button_style.push('--apple-pay-button-width: 100%'); + } + + applepay_button_style.push('--apple-pay-button-height: calc(var(--apple-pay-button-width) / 7.5)'); + + if (paypal_data['applepay_button_shape'] == 'pill') { + applepay_button_style.push('--apple-pay-button-border-radius: 1000px'); + } else { + applepay_button_style.push('--apple-pay-button-border-radius: 4px'); + } + + applepay_button.setAttribute('style', applepay_button_style.join('; ')); + + document.querySelector('#applepay_button_container').appendChild(applepay_button); + + applepay_button.addEventListener('click', async function (event) { + event.preventDefault(); + + const paymentRequest = { + countryCode, + currencyCode: paypal_data['currency_code'], + merchantCapabilities, + supportedNetworks, + requiredBillingContactFields: ['name', 'phone', 'email', 'postalAddress'], + requiredShippingContactFields: [], + total: { + label: 'Total', + amount: paypal_data['applepay_amount'], + type: 'final', + } + }; + + var session = new ApplePaySession(4, paymentRequest); + + session.onvalidatemerchant = (event) => { + ApplePaySDK.validateMerchant({ + validationUrl: event.validationURL, + }).then((payload) => { + session.completeMerchantValidation(payload.merchantSession); + console.log('Complete Merchant validation Done!', {payload}); + }).catch((error) => { + console.error(error); + session.abort(); + }); + }; + + session.onpaymentmethodselected = (event) => { + console.log('onpaymentmethodselected'); + console.log(event.paymentMethod); // {type: "credit"} + + session.completePaymentMethodSelection({ + newTotal: paymentRequest.total + }); + }; + + session.onshippingcontactselected = async (event) => { + console.log('Your shipping contacts selected is: ' + event.shippingContact); + + const shippingContactUpdate = { + newTotal: paymentRequest.total, + newLineItems: [] + }; + + session.completeShippingContactSelection(shippingContactUpdate); + }; + + session.onshippingmethodselected = (event) => { + console.log('onshippingmethodselected'); + console.log(JSON.stringify(event.shippingMethod, null, 4)); + console.log('Your shipping method selected is: ', event.shippingMethod); + + var shippingMethodUpdate = { + newTotal: paymentRequest.total, + newLineItems: [] + }; + + session.completeShippingMethodSelection(shippingMethodUpdate); + }; + + session.onpaymentauthorized = async (event) => { + try { + console.log('onpaymentauthorized'); + console.log(JSON.stringify(event, null, 4)); + + paypal_order_id = false; + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/createOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'applepay_button'}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + paypal_order_id = json['paypal_order_id']; + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + + await ApplePaySDK.confirmOrder({ + orderId: paypal_order_id, + token: event.payment.token, + billingContact: event.payment.billingContact, + shippingContact: event.payment.shippingContact + }); + + $.ajax({ + method: 'post', + url: 'index.php?route=extension/payment/paypal/approveOrder', + data: {'page_code' : paypal_data['page_code'], 'payment_type' : 'applepay_button', 'paypal_order_id': paypal_order_id}, + dataType: 'json', + async: false, + success: function(json) { + showPayPalAlert(json); + + if (json['url']) { + location = json['url']; + } + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + + session.completePayment({ + status: window.ApplePaySession.STATUS_SUCCESS + }); + } catch (error) { + console.error(error); + + session.completePayment({ + status: window.ApplePaySession.STATUS_FAILURE + }); + } + }; + + session.oncancel = (event) => { + console.log(event); + console.log('Apple Pay Cancelled!'); + } + + session.begin(); + }); + + $('#applepay_button_container').removeClass('paypal-spinner'); + }; + + var init = function(callback = '') { + updatePayPalData(); + + paypal_callback = callback; + + loadPayPalSDK(); + }; + + return { + init: init + }; +}()); + +window.addEventListener('load', function () { + PayPalAPI.init(); +}); + diff --git a/upload/catalog/view/theme/default/stylesheet/paypal/card.css b/upload/catalog/view/theme/default/stylesheet/paypal/card.css new file mode 100644 index 00000000000..2e30a933677 --- /dev/null +++ b/upload/catalog/view/theme/default/stylesheet/paypal/card.css @@ -0,0 +1,130 @@ +#paypal_card_form { + color: #717171; + text-align: center; + transition: all 600ms cubic-bezier(0.2, 1.3, 0.7, 1); + -webkit-animation: cardIntro 500ms cubic-bezier(0.2, 1.3, 0.7, 1); + animation: cardIntro 500ms cubic-bezier(0.2, 1.3, 0.7, 1); + z-index: 1; +} +#paypal_card_form.visa { + color: #fff; + background-color: #0D4AA2; +} +#paypal_card_form.master-card { + color: #fff; + background-color: #363636; + background: linear-gradient(115deg, #d82332, #d82332 50%, #f1ad3d 50%, #f1ad3d); +} +#paypal_card_form.maestro { + color: #fff; + background-color: #363636; + background: linear-gradient(115deg, #009ddd, #009ddd 50%, #ed1c2e 50%, #ed1c2e); +} +#paypal_card_form.american-express { + color: #fff; + background-color: #007CC3; +} +#paypal_card_form.discover { + color: #fff; + background-color: #ff6000; + background: linear-gradient(#d14310, #f7961e); +} +#paypal_card_form.unionpay, #paypal_card_form.jcb, #paypal_card_form.diners-club { + color: #fff; + background-color: #363636; +} +#paypal_card_form .card-info-number, +#paypal_card_form .card-info-date-cvv { + position: relative; + text-align: left; +} +#paypal_card_form .card-info-date { + width: 48%; + float: left; + margin-bottom: 0.5em; +} +#paypal_card_form .card-info-cvv { + width: 48%; + float: right; + margin-bottom: 0.5em; +} +#paypal_card_form .card-info-number, +#paypal_card_form .card-info-date, +#paypal_card_form .card-info-cvv { + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; +} +#paypal_card_form .card-label { + display: block; + margin-bottom: 0.5em; + text-transform: uppercase; +} +#paypal_card_form .card-input-container { + position: relative; + height: 2.75em; + padding: 5px 10px; + margin-bottom: 1em; + background: rgba(255, 255, 255, 0.86); + border: 1px solid #eee; + border-radius: 2px; +} +#paypal_card_form #card_image { + position: absolute; + top: 0px; + right: 2px; + width: 44px; + height: 28px; + background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/346994/card_sprite.png); + background-size: 86px 458px; + border-radius: 4px; + background-position: -100px 0; + background-repeat: no-repeat; +} +#paypal_card_form #card_image.visa { + background-position: 0 -398px; +} +#paypal_card_form #card_image.master-card { + background-position: 0 -281px; +} +#paypal_card_form #card_image.american-express { + background-position: 0 -370px; +} +#paypal_card_form #card_image.discover { + background-position: 0 -163px; +} +#paypal_card_form #card_image.maestro { + background-position: 0 -251px; +} +#paypal_card_form #card_image.jcb { + background-position: 0 -221px; +} +#paypal_card_form #card_image.diners-club { + background-position: 0 -133px; +} +#paypal_card_form #paypal_button_submit { + width: 100%; + padding: 1em 1em; + color: #fff; + background: #282c37; + font-size: 15px; + box-shadow: none; + -moz-box-shadow: none; + -webkit-box-shadow: none; + border: 0; + z-index: 0; + opacity: 0.1; + outline: 0; + -webkit-appearance: none; +} +#paypal_card_form #paypal_button_submit:hover { + background: #535b72; +} +#paypal_card_form #paypal_button_submit:active { + -webkit-animation: cardIntro 200ms cubic-bezier(0.2, 1.3, 0.7, 1); + animation: cardIntro 200ms cubic-bezier(0.2, 1.3, 0.7, 1); +} +#paypal_card_form #paypal_button_submit.show-button { + opacity: 1; + cursor: pointer; +} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/stylesheet/paypal/paypal.css b/upload/catalog/view/theme/default/stylesheet/paypal/paypal.css new file mode 100644 index 00000000000..0abf4320c59 --- /dev/null +++ b/upload/catalog/view/theme/default/stylesheet/paypal/paypal.css @@ -0,0 +1,66 @@ +.paypal-button { + position: relative; +} +@media (max-width: 476px) { + .paypal-button-container { + width: 100% !important; + } +} +.applepay-button { + position: relative; +} +@media (max-width: 476px) { + .applepay-button-container { + width: 100% !important; + } + .applepay-button #apple-pay-button { + width: 100% !important; + } +} +.paypal-card { + position: relative; +} +.paypal-card-container { + position: relative; +} +@media (max-width: 476px) { + .paypal-card-container { + width: 100% !important; + } +} +.paypal-message { + position: relative; +} +.paypal-spinner { + position: relative; + min-height: 20px; +} +.paypal-spinner:before { + content: ''; + position: absolute; + display: block; + width: 20px; + height: 20px; + top: 50%; + left: 50%; + margin-top: -10px; + margin-left: -10px; + border: 2.5px solid #545454; + border-right-color: #545454; + border-right-color: transparent; + border-radius: 50%; + -webkit-animation: paypal-spinner .75s linear infinite; + animation: paypal-spinner .75s linear infinite; + z-index: 1000; +} +.modal { + z-index: 960; +} +.modal-backdrop { + z-index: 940; +} +@keyframes paypal-spinner { + to { + transform: rotate(360deg); + } +} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal.twig deleted file mode 100644 index 595ade9865f..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/paypal.twig +++ /dev/null @@ -1,630 +0,0 @@ - -
- {% if message_status %} -
- {% endif %} - {% if express_status %} -
- {% endif %} - {% if card_status %} - - {% endif %} - -
- diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/confirm.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/confirm.twig new file mode 100644 index 00000000000..7a725469cf6 --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/confirm.twig @@ -0,0 +1,600 @@ +{{ header }} +
+ + {% if attention %} +
{{ attention }} + +
+ {% endif %} + {% if success %} +
{{ success }} + +
+ {% endif %} + {% if error_warning %} +
{{ error_warning }} + +
+ {% endif %} +
{{ column_left }} + {% if column_left and column_right %} + {% set class = 'col-sm-6' %} + {% elseif column_left or column_right %} + {% set class = 'col-sm-9' %} + {% else %} + {% set class = 'col-sm-12' %} + {% endif %} +
{{ content_top }} +

{{ heading_title }}

+
+
+

{{ text_checkout_payment_address }}

+
+
+
+
+
+ {{ text_your_details }} + + {% if guest['firstname'] %}{% endif %} + {% if guest['lastname'] %}{% endif %} + {% if guest['email'] %}{% endif %} + {% if guest['telephone'] %}{% endif %} + {% for custom_field in custom_fields %} + {% if custom_field['location'] == 'account' %} + + {% endif %} + {% endfor %} +
{{ entry_firstname }}{{ guest['firstname'] }}
{{ entry_lastname }}{{ guest['lastname'] }}
{{ entry_email }}{{ guest['email'] }}
{{ entry_telephone }}{{ guest['telephone'] }}
{{ custom_field['name'] }}{{ custom_field['value'] }}
+
+
+
+
+ {{ text_your_address }} + + {% if payment_address['company'] %}{% endif %} + {% if payment_address['address_1'] %}{% endif %} + {% if payment_address['address_2'] %}{% endif %} + {% if payment_address['city'] %}{% endif %} + {% if payment_address['postcode'] %}{% endif %} + {% if payment_address['country'] %}{% endif %} + {% if payment_address['zone'] %}{% endif %} + {% for custom_field in custom_fields %} + {% if custom_field['location'] == 'address' %} + + {% endif %} + {% endfor %} +
{{ entry_company }}{{ payment_address['company'] }}
{{ entry_address_1 }}{{ payment_address['address_1'] }}
{{ entry_address_2 }}{{ payment_address['address_2'] }}
{{ entry_city }}{{ payment_address['city'] }}
{{ entry_postcode }}{{ payment_address['postcode'] }}
{{ entry_country }}{{ payment_address['country'] }}
{{ entry_zone }}{{ payment_address['zone'] }}
{{ custom_field['name'] }}{{ custom_field['value'] }}
+
+
+
+
+
+ {% if has_shipping %} +
+
+

{{ text_checkout_shipping_address }}

+
+
+ + {% if shipping_address['firstname'] %}{% endif %} + {% if shipping_address['lastname'] %}{% endif %} + {% if shipping_address['company'] %}{% endif %} + {% if shipping_address['address_1'] %}{% endif %} + {% if shipping_address['address_2'] %}{% endif %} + {% if shipping_address['city'] %}{% endif %} + {% if shipping_address['postcode'] %}{% endif %} + {% if shipping_address['country'] %}{% endif %} + {% if shipping_address['zone'] %}{% endif %} + {% for custom_field in custom_fields %} + {% if custom_field['location'] == 'address' %} + + {% endif %} + {% endfor %} +
{{ entry_firstname }}{{ shipping_address['firstname'] }}
{{ entry_lastname }}{{ shipping_address['lastname'] }}
{{ entry_company }}{{ shipping_address['company'] }}
{{ entry_address_1 }}{{ shipping_address['address_1'] }}
{{ entry_address_2 }}{{ shipping_address['address_2'] }}
{{ entry_city }}{{ shipping_address['city'] }}
{{ entry_postcode }}{{ shipping_address['postcode'] }}
{{ entry_country }}{{ shipping_address['country'] }}
{{ entry_zone }}{{ shipping_address['zone'] }}
{{ custom_field['name'] }}{{ custom_field['value'] }}
+
+
+ {% endif %} + {% if has_shipping %} + {% if not shipping_methods %} +
{{ error_no_shipping }}
+ {% else %} +
+
+
+

{{ text_checkout_shipping_method }}

+
+
+ {% for shipping_method in shipping_methods %} +

{{ shipping_method['title'] }}

+ {% if not shipping_method['error'] %} + {% for quote in shipping_method['quote'] %} +
+ +
+ {% endfor %} + {% else %} +
{{ shipping_method['error'] }}
+ {% endif %} + {% endfor %} +
+
+
+ {% endif %} + {% endif %} +
+
+

{{ text_checkout_payment_method }}

+
+
+ {% for payment_method in payment_methods %} + {% if payment_method['code'] == 'paypal' %} +
+ +
+ {% endif %} + {% endfor %} +
+
+
+ + + + + + + + + + + + {% for product in products %} + + + + + + + + {% endfor %} + {% for voucher in vouchers %} + + + + + + + + {% endfor %} + +
{{ column_name }}{{ column_model }}{{ column_quantity }}{{ column_price }}{{ column_total }}
+ {{ product['name'] }} + {% for option in product['option'] %}
+ - {{ option['name'] }}: {{ option['value'] }} + {% endfor %} + {% if product['recurring'] %} +
{{ text_recurring_item }} {{ product['recurring_description'] }} + {% endif %} +
{{ product['model'] }}{{ product['quantity'] }}{{ product['price'] }}{{ product['total'] }}
{{ voucher['description'] }}1{{ voucher['amount'] }}{{ voucher['amount'] }}
+
+
+ {% if coupon or voucher or reward %} +
{{ coupon }}{{ voucher }}{{ reward }}

+ {% endif %} +
+
+ + {% for total in totals %} + + + + + {% endfor %} +
{{ total['title'] }}:{{ total['text'] }}
+
+
+ + {{ content_bottom }} +
+ {{ column_right }} +
+
+ +{{ footer }} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/message.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/message.twig new file mode 100644 index 00000000000..78f174729ac --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/message.twig @@ -0,0 +1,8 @@ +
+ \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/payment_address.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/payment_address.twig new file mode 100644 index 00000000000..8909b2063b3 --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/payment_address.twig @@ -0,0 +1,312 @@ + \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal.twig new file mode 100644 index 00000000000..8121c3157c4 --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal.twig @@ -0,0 +1,71 @@ +{% if checkout_mode == 'multi_button' %} +
+ {% if button_status %} +
+
+
+ {% endif %} + {% if applepay_button_status %} +
+
+
+ {% endif %} + {% if card_status %} +
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ {% endif %} +
+ +{% else %} +
+
+ +
+
+ +{% endif %} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_modal.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_modal.twig new file mode 100644 index 00000000000..ec162d73334 --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_modal.twig @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater.twig new file mode 100644 index 00000000000..f0577f1233b --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater.twig @@ -0,0 +1,43 @@ +{% if checkout_mode == 'multi_button' %} +
+ {% if button_status %} +
+
+
+ {% endif %} +
+ +{% else %} +
+
+ +
+
+ +{% endif %} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater_modal.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater_modal.twig new file mode 100644 index 00000000000..a755c8d86bc --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/paypal_paylater_modal.twig @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/paypal/shipping_address.twig b/upload/catalog/view/theme/default/template/extension/payment/paypal/shipping_address.twig new file mode 100644 index 00000000000..a4bcf4d5fe4 --- /dev/null +++ b/upload/catalog/view/theme/default/template/extension/payment/paypal/shipping_address.twig @@ -0,0 +1,195 @@ + \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_braintree.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_braintree.twig deleted file mode 100644 index 388ecf42185..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_braintree.twig +++ /dev/null @@ -1,681 +0,0 @@ - -
{{ text_loading }}
- - - - - - diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_braintree_confirm.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_braintree_confirm.twig deleted file mode 100644 index e0f8bcc63ac..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_braintree_confirm.twig +++ /dev/null @@ -1,146 +0,0 @@ -{{ header }} -
- - {% if attention %} -
{{ attention }} - -
- {% endif %} - - {% if success %} -
{{ success }} - -
- {% endif %} - - {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} - -
{{ column_left }} - {% if column_left and column_right %} - {% set class = 'col-sm-6' %} - {% elseif column_left or column_right %} - {% set class = 'col-sm-9' %} - {% else %} - {% set class = 'col-sm-12' %} - {% endif %} -
{{ content_top }} -

{{ heading_title }}

- - {% if coupon or voucher or reward %} -
{{ coupon }}{{ voucher }}{{ reward }}
- {% endif %} - - {% if has_shipping %} - {% if not shipping_methods %} -
{{ error_no_shipping }}
- {% else %} -
-
- {% for shipping_method in shipping_methods %} -

{{ shipping_method.title }}

- {% if not shipping_method.error %} - {% for quote in shipping_method.quote %} -
- -
- {% endfor %} - {% else %} -
{{ shipping_method.error }}
- {% endif %} - {% endfor %} -
-
- {% endif %} - {% endif %} -
- - - - - - - - - - - - {% for product in products %} - - - - - - - - {% endfor %} - {% for voucher in vouchers %} - - - - - - - - {% endfor %} - -
{{ column_name }}{{ column_model }}{{ column_quantity }}{{ column_price }}{{ column_total }}
- {{ product.name }} - {% for option in product.option %}
- - {{ option.name }}: {{ option.value }} - {% endfor %} - {% if product.recurring %} -
{{ text_recurring_item }} {{ product.recurring_description }} - {% endif %} -
{{ product.model }}{{ product.quantity }}{{ product.price }}{{ product.total }}
{{ voucher.description }}1{{ voucher.amount }}{{ voucher.amount }}
-
-
-
-
- - {% for total in totals %} - - - - - {% endfor %} -
{{ total.title }}:{{ total.text }}
-
-
- - {{ content_bottom }}
- {{ column_right }}
-
-{{ footer }} - diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_express.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_express.twig deleted file mode 100644 index a26040daad4..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_express.twig +++ /dev/null @@ -1,27 +0,0 @@ -{% if payment_pp_express_incontext_disable != 1 %} -
-
- -
-
- - -{% else %} - - -{% endif %} diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_express_confirm.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_express_confirm.twig deleted file mode 100644 index e0842232799..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_express_confirm.twig +++ /dev/null @@ -1,128 +0,0 @@ -{{ header }} -
- - {% if attention %} -
{{ attention }} - -
- {% endif %} - {% if success %} -
{{ success }} - -
- {% endif %} - {% if error_warning %} -
{{ error_warning }} - -
- {% endif %} -
{{ column_left }} - {% if column_left and column_right %} - {% set class = 'col-sm-6' %} - {% elseif column_left or column_right %} - {% set class = 'col-sm-9' %} - {% else %} - {% set class = 'col-sm-12' %} - {% endif %} -
{{ content_top }} -

{{ heading_title }}

- {% if coupon or voucher or reward %} -
{{ coupon }}{{ voucher }}{{ reward }}
- {% endif %} - {% if has_shipping %} - {% if not shipping_methods %} -
{{ error_no_shipping }}
- {% else %} -
-
{% for shipping_method in shipping_methods %} -

{{ shipping_method.title }}

- {% if not shipping_method.error %} - {% for quote in shipping_method.quote %} -
- -
- {% endfor %} - {% else %} -
{{ shipping_method.error }}
- {% endif %} - {% endfor %}
-
- {% endif %} - {% endif %} -
- - - - - - - - - - - - {% for product in products %} - - - - - - - - {% endfor %} - {% for voucher in vouchers %} - - - - - - - - {% endfor %} - -
{{ column_name }}{{ column_model }}{{ column_quantity }}{{ column_price }}{{ column_total }}
{{ product.name }} {% for option in product.option %}
- - {{ option.name }}: {{ option.value }} {% endfor %} - {% if product.recurring %}
- {{ text_recurring_item }} {{ product.recurring_description }} {% endif %}
{{ product.model }}{{ product.quantity }}{{ product.price }}{{ product.total }}
{{ voucher.description }}1{{ voucher.amount }}{{ voucher.amount }}
-
-
-
-
- - {% for total in totals %} - - - - - {% endfor %} -
{{ total.title }}:{{ total.text }}
-
-
- - {{ content_bottom }}
- {{ column_right }}
-
-{{ footer }} - \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_payflow.twig deleted file mode 100644 index dfbaaedfb0c..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow.twig +++ /dev/null @@ -1,123 +0,0 @@ -
-
- {{ text_credit_card }} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
- -
- -
-
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
- -
-
- \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe.twig deleted file mode 100644 index 8ba48bebf8c..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% if checkout_method == 'iframe' %} - -{% else %} - -{% endif %} \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe_return.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe_return.twig deleted file mode 100644 index b2c01b32d5e..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_payflow_iframe_return.twig +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_pro.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_pro.twig deleted file mode 100644 index 8779b81255a..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_pro.twig +++ /dev/null @@ -1,119 +0,0 @@ -
-
- {{ text_credit_card }} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
- -
- -
-
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-
- -
-
- \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe.twig deleted file mode 100644 index ae776c50896..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% if checkout_method == 'iframe' %} - -{% else %} - {% if not error_connection %} -
- - -
- - {% else %} -
{{ error_connection }}
- {% endif %} -{% endif %} diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe_body.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe_body.twig deleted file mode 100644 index a3ca72e6272..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_pro_iframe_body.twig +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -{% if not error_connection %} -
- - -

{{ text_secure_connection }}

- -
- -{% else %} -
{{ error_connection }}
-{% endif %} - - \ No newline at end of file diff --git a/upload/catalog/view/theme/default/template/extension/payment/pp_standard.twig b/upload/catalog/view/theme/default/template/extension/payment/pp_standard.twig deleted file mode 100644 index 742215a7c11..00000000000 --- a/upload/catalog/view/theme/default/template/extension/payment/pp_standard.twig +++ /dev/null @@ -1,54 +0,0 @@ -{% if testmode %} -
{{ text_testmode }}
-{% endif %} -
- - - - {% set i = 1 %} - {% for product in products %} - - - - - - {% set j = 0 %} - {% for option in product.option %} - - - {% set j = j + 1 %} - {% endfor %} - {% set i = i + 1 %} - {% endfor %} - {% if discount_amount_cart %} - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
diff --git a/upload/system/config/paypal.php b/upload/system/config/paypal.php index 7ba9c17f1aa..6747851c202 100644 --- a/upload/system/config/paypal.php +++ b/upload/system/config/paypal.php @@ -1,13 +1,191 @@ '2.0.2', 'partner' => array( 'production' => array( 'partner_id' => 'TY2Q25KP2PX9L', - 'client_id' => 'AbjxI4a9fMnew8UOMoDFVwSh7h1aeOBaXpd2wcccAnuqecijKIylRnNguGRWDrEPrTYraBQApf_-O3_4' + 'client_id' => 'AbjxI4a9fMnew8UOMoDFVwSh7h1aeOBaXpd2wcccAnuqecijKIylRnNguGRWDrEPrTYraBQApf_-O3_4', + 'partner_attribution_id' => 'OPENCARTLIMITED_Cart_OpenCartPCP' ), 'sandbox' => array( 'partner_id' => 'EJNHWRJJNB38L', - 'client_id' => 'AfeIgIr-fIcEucsVXvdq21Ufu0wAALWhgJdVF4ItUK1IZFA9I4JIRdfyJ9vWrd9oi0B6mBGtJYDrlYsG' + 'client_id' => 'AfeIgIr-fIcEucsVXvdq21Ufu0wAALWhgJdVF4ItUK1IZFA9I4JIRdfyJ9vWrd9oi0B6mBGtJYDrlYsG', + 'partner_attribution_id' => 'OPENCARTLIMITED_Cart_OpenCartPCP' + ) + ), + 'general' => array( + 'debug' => false, + 'sale_analytics_range' => 'month', + 'checkout_mode' => 'multi_button', + 'transaction_method' => 'capture', + 'country_code' => 'US', + 'currency_code' => 'USD', + 'currency_value' => '1', + 'card_currency_code' => 'USD', + 'card_currency_value' => '1' + ), + 'button' => array( + 'checkout' => array( + 'page_code' => 'checkout', + 'page_name' => 'text_checkout', + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'funding' => array( + 'paylater' => 1, + 'card' => 0, + 'bancontact' => 0, + 'blik' => 0, + 'eps' => 0, + 'giropay' => 0, + 'ideal' => 0, + 'mercadopago' => 0, + 'mybank' => 0, + 'p24' => 0, + 'sepa' => 0, + 'sofort' => 0, + 'venmo' => 0 + ) + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => true, + 'insert_tag' => '#content #product #button-cart', + 'insert_type' => 'after', + 'align' => 'center', + 'size' => 'responsive', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'tagline' => 'false', + 'funding' => array( + 'paylater' => 0, + 'card' => 0, + 'credit' => 0, + 'bancontact' => 0, + 'blik' => 0, + 'eps' => 0, + 'giropay' => 0, + 'ideal' => 0, + 'mercadopago' => 0, + 'mybank' => 0, + 'p24' => 0, + 'sepa' => 0, + 'sofort' => 0, + 'venmo' => 0 + ) + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => true, + 'insert_tag' => '#content', + 'insert_type' => 'append', + 'align' => 'right', + 'size' => 'large', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'tagline' => 'false', + 'funding' => array( + 'paylater' => 0, + 'card' => 0, + 'bancontact' => 0, + 'blik' => 0, + 'eps' => 0, + 'giropay' => 0, + 'ideal' => 0, + 'mercadopago' => 0, + 'mybank' => 0, + 'p24' => 0, + 'sepa' => 0, + 'sofort' => 0, + 'venmo' => 0 + ), + ) + ), + 'applepay_button' => array( + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy' + ), + 'card' => array( + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'secure_status' => true, + 'secure_scenario' => array( + 'failed_authentication' => 0, + 'rejected_authentication' => 0, + 'attempted_authentication' => 1, + 'unable_authentication' => 0, + 'challenge_authentication' => 0, + 'card_ineligible' => 1, + 'system_unavailable' => 0, + 'system_bypassed' => 1 + ) + ), + 'message' => array( + 'checkout' => array( + 'page_code' => 'checkout', + 'page_name' => 'text_checkout', + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'layout' => 'text', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'home' => array( + 'page_code' => 'home', + 'page_name' => 'text_home', + 'status' => true, + 'insert_tag' => '#common-home', + 'insert_type' => 'prepend', + 'align' => 'center', + 'size' => 'responsive', + 'layout' => 'text', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => true, + 'insert_tag' => '#content #product', + 'insert_type' => 'before', + 'align' => 'center', + 'size' => 'responsive', + 'layout' => 'text', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => true, + 'insert_tag' => '#content', + 'insert_type' => 'append', + 'align' => 'right', + 'size' => 'large', + 'layout' => 'text', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' ) ), 'order_status' => array( @@ -47,40 +225,85 @@ 'id' => 16 ) ), - 'checkout' => array( - 'express' => array( - 'status' => true, - 'button_align' => 'right', - 'button_size' => 'large', - 'button_color' => 'gold', - 'button_shape' => 'rect', - 'button_label' => 'paypal' + 'contact' => array( + 'oid' => '00D300000000LaY', + 'retURL' => 'https://www.opencart.com/', + 'Vendor_Partner_ID_VPID_MAM__c' => '0018000000LjXtY', + 'Campaign_ID__c' => '7012E000001XNG7', + 'lead_source' => 'Partner', + 'recordType' => '0122E000000Qq4v', + 'company' => '', + 'first_name' => '', + 'last_name' => '', + 'email' => '', + 'url' => '', + 'phone' => '', + 'country' => '', + '00N30000000gJEZ' => '', + '00N2E00000II4xQ' => '', + '00N2E00000II4xP' => false, + '00N2E00000II4xO' => '', + '00N80000004IGsC' => '' + ), + 'sale_analytics_range' => array( + 'day' => array( + 'code' => 'day', + 'name' => 'text_day' + ), + 'week' => array( + 'code' => 'week', + 'name' => 'text_week' + ), + 'month' => array( + 'code' => 'month', + 'name' => 'text_month' + ), + 'year' => array( + 'code' => 'year', + 'name' => 'text_year' + ) + ), + 'checkout_mode' => array( + 'multi_button' => array( + 'code' => 'multi_button', + 'name' => 'text_multi_button' + ), + 'one_button' => array( + 'code' => 'one_button', + 'name' => 'text_one_button' + ) + ), + 'transaction_method' => array( + 'authorize' => array( + 'code' => 'authorize', + 'name' => 'text_authorization' + ), + 'capture' => array( + 'code' => 'capture', + 'name' => 'text_sale' + ) + ), + 'paylater_country' => array( + 'US' => array( + 'code' => 'US' ), - 'card' => array( - 'status' => false, - 'form_align' => 'right', - 'form_size' => 'large', - 'secure_status' => true, - 'secure_scenario' => array( - 'undefined' => 1, - 'error' => 0, - 'skipped_by_buyer' => 0, - 'failure' => 0, - 'bypassed' => 0, - 'attempted' => 1, - 'unavailable' => 0, - 'card_ineligible' => 1 - ) + 'GB' => array( + 'code' => 'GB' ), - 'message' => array( - 'status' => true, - 'message_align' => 'right', - 'message_size' => 'large', - 'message_layout' => 'text', - 'message_text_color' => 'black', - 'message_text_size' => '12', - 'message_flex_color' => 'blue', - 'message_flex_ratio' => '8x1' + 'FR' => array( + 'code' => 'FR' + ), + 'DE' => array( + 'code' => 'DE' + ), + 'IT' => array( + 'code' => 'IT' + ), + 'ES' => array( + 'code' => 'ES' + ), + 'AU' => array( + 'code' => 'AU' ) ), 'currency' => array( @@ -88,178 +311,196 @@ 'code' => 'AUD', 'name' => 'text_currency_aud', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'BRL' => array( 'code' => 'BRL', 'name' => 'text_currency_brl', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'CAD' => array( 'code' => 'CAD', 'name' => 'text_currency_cad', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'CZK' => array( 'code' => 'CZK', 'name' => 'text_currency_czk', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'DKK' => array( 'code' => 'DKK', 'name' => 'text_currency_dkk', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'EUR' => array( 'code' => 'EUR', 'name' => 'text_currency_eur', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'HKD' => array( 'code' => 'HKD', 'name' => 'text_currency_hkd', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'HUF' => array( 'code' => 'HUF', 'name' => 'text_currency_huf', 'decimal_place' => 0, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'INR' => array( 'code' => 'INR', 'name' => 'text_currency_inr', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'ILS' => array( 'code' => 'ILS', 'name' => 'text_currency_ils', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'JPY' => array( 'code' => 'JPY', 'name' => 'text_currency_jpy', 'decimal_place' => 0, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'MYR' => array( 'code' => 'MYR', 'name' => 'text_currency_myr', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'MXN' => array( 'code' => 'MXN', 'name' => 'text_currency_mxn', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'TWD' => array( 'code' => 'TWD', 'name' => 'text_currency_twd', 'decimal_place' => 0, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'NZD' => array( 'code' => 'NZD', 'name' => 'text_currency_nzd', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'NOK' => array( 'code' => 'NOK', 'name' => 'text_currency_nok', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'PHP' => array( 'code' => 'PHP', 'name' => 'text_currency_php', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'PLN' => array( 'code' => 'PLN', 'name' => 'text_currency_pln', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'GBP' => array( 'code' => 'GBP', 'name' => 'text_currency_gbp', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'RUB' => array( 'code' => 'RUB', 'name' => 'text_currency_rub', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'SGD' => array( 'code' => 'SGD', 'name' => 'text_currency_sgd', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'SEK' => array( 'code' => 'SEK', 'name' => 'text_currency_sek', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'CHF' => array( 'code' => 'CHF', 'name' => 'text_currency_chf', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ), 'THB' => array( 'code' => 'THB', 'name' => 'text_currency_thb', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => false ), 'USD' => array( 'code' => 'USD', 'name' => 'text_currency_usd', 'decimal_place' => 2, - 'express_status' => true, + 'status' => true, 'card_status' => true ) ), + 'button_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' + ) + ), 'button_align' => array( 'left' => array( 'code' => 'left', @@ -346,13 +587,81 @@ 'name' => 'text_installment' ) ), + 'button_tagline' => array( + 'true' => array( + 'code' => 'true', + 'name' => 'text_yes' + ), + 'false' => array( + 'code' => 'false', + 'name' => 'text_no' + ), + ), 'button_width' => array( 'small' => '200px', 'medium' => '250px', 'large' => '350px', 'responsive' => '' ), - 'form_align' => array( + 'button_funding' => array( + 'paylater' => array( + 'code' => 'paylater', + 'name' => 'text_paylater' + ), + 'card' => array( + 'code' => 'card', + 'name' => 'text_card' + ), + 'bancontact' => array( + 'code' => 'bancontact', + 'name' => 'text_bancontact' + ), + 'bancontact' => array( + 'code' => 'bancontact', + 'name' => 'text_bancontact' + ), + 'blik' => array( + 'code' => 'blik', + 'name' => 'text_blik' + ), + 'eps' => array( + 'code' => 'eps', + 'name' => 'text_eps' + ), + 'giropay' => array( + 'code' => 'giropay', + 'name' => 'text_giropay' + ), + 'ideal' => array( + 'code' => 'ideal', + 'name' => 'text_ideal' + ), + 'mercadopago' => array( + 'code' => 'mercadopago', + 'name' => 'text_mercadopago' + ), + 'mybank' => array( + 'code' => 'mybank', + 'name' => 'text_mybank' + ), + 'p24' => array( + 'code' => 'p24', + 'name' => 'text_p24' + ), + 'sepa' => array( + 'code' => 'sepa', + 'name' => 'text_sepa' + ), + 'sofort' => array( + 'code' => 'sofort', + 'name' => 'text_sofort' + ), + 'venmo' => array( + 'code' => 'venmo', + 'name' => 'text_venmo' + ) + ), + 'applepay_button_align' => array( 'left' => array( 'code' => 'left', 'name' => 'text_align_left' @@ -366,7 +675,11 @@ 'name' => 'text_align_right' ) ), - 'form_size' => array( + 'applepay_button_size' => array( + 'small' => array( + 'code' => 'small', + 'name' => 'text_small' + ), 'medium' => array( 'code' => 'medium', 'name' => 'text_medium' @@ -380,52 +693,116 @@ 'name' => 'text_responsive' ) ), - 'form_width' => array( + 'applepay_button_color' => array( + 'black' => array( + 'code' => 'black', + 'name' => 'text_black' + ), + 'white' => array( + 'code' => 'white', + 'name' => 'text_white' + ), + 'white_outline' => array( + 'code' => 'white-outline', + 'name' => 'text_white_outline' + ) + ), + 'applepay_button_shape' => array( + 'pill' => array( + 'code' => 'pill', + 'name' => 'text_pill' + ), + 'rect' => array( + 'code' => 'rect', + 'name' => 'text_rect' + ) + ), + 'applepay_button_type' => array( + 'buy' => array( + 'code' => 'buy', + 'name' => 'text_buy' + ), + 'donate' => array( + 'code' => 'donate', + 'name' => 'text_donate' + ), + 'plain' => array( + 'code' => 'plain', + 'name' => 'text_plain' + ), + 'check-out' => array( + 'code' => 'check-out', + 'name' => 'text_check_out' + ) + ), + 'applepay_button_width' => array( + 'small' => '200px', 'medium' => '250px', 'large' => '350px', 'responsive' => '' ), - 'secure_scenario' => array( - 'undefined' => array( - 'code' => 'undefined', - 'name' => 'text_3ds_undefined', - 'error' => 'error_3ds_undefined', - 'recommended' => 1 + 'card_align' => array( + 'left' => array( + 'code' => 'left', + 'name' => 'text_align_left' ), - 'error' => array( - 'code' => 'error', - 'name' => 'text_3ds_error', - 'error' => 'error_3ds_undefined', - 'recommended' => 0 + 'center' => array( + 'code' => 'center', + 'name' => 'text_align_center' ), - 'skipped_by_buyer' => array( - 'code' => 'skipped_by_buyer', - 'name' => 'text_3ds_skipped_by_buyer', - 'error' => 'error_3ds_skipped_by_buyer', - 'recommended' => 0 + 'right' => array( + 'code' => 'right', + 'name' => 'text_align_right' + ) + ), + 'card_size' => array( + 'medium' => array( + 'code' => 'medium', + 'name' => 'text_medium' + ), + 'large' => array( + 'code' => 'large', + 'name' => 'text_large' ), - 'failure' => array( - 'code' => 'failure', - 'name' => 'text_3ds_failure', - 'error' => 'error_3ds_failure', + 'responsive' => array( + 'code' => 'responsive', + 'name' => 'text_responsive' + ) + ), + 'card_width' => array( + 'medium' => '250px', + 'large' => '350px', + 'responsive' => '' + ), + 'card_secure_scenario' => array( + 'failed_authentication' => array( + 'code' => 'failed_authentication', + 'name' => 'text_3ds_failed_authentication', + 'error' => 'error_3ds_failed_authentication', 'recommended' => 0 ), - 'bypassed' => array( - 'code' => 'bypassed', - 'name' => 'text_3ds_bypassed', - 'error' => 'error_3ds_bypassed', + 'rejected_authentication' => array( + 'code' => 'rejected_authentication', + 'name' => 'text_3ds_rejected_authentication', + 'error' => 'error_3ds_rejected_authentication', 'recommended' => 0 ), - 'attempted' => array( - 'code' => 'attempted', - 'name' => 'text_3ds_attempted', - 'error' => 'error_3ds_attempted', + 'attempted_authentication' => array( + 'code' => 'attempted_authentication', + 'name' => 'text_3ds_attempted_authentication', + 'error' => 'error_3ds_attempted_authentication', 'recommended' => 1 ), - 'unavailable' => array( - 'code' => 'unavailable', - 'name' => 'text_3ds_unavailable', - 'error' => 'error_3ds_unavailable', + 'unable_authentication' => array( + 'code' => 'unable_authentication', + 'name' => 'text_3ds_unable_authentication', + 'error' => 'error_3ds_unable_authentication', + 'recommended' => 0 + ), + 'challenge_authentication' => array( + 'code' => 'challenge_authentication', + 'name' => 'text_3ds_challenge_authentication', + 'error' => 'error_3ds_challenge_authentication', 'recommended' => 0 ), 'card_ineligible' => array( @@ -433,6 +810,36 @@ 'name' => 'text_3ds_card_ineligible', 'error' => 'error_3ds_card_ineligible', 'recommended' => 1 + ), + 'system_unavailable' => array( + 'code' => 'system_unavailable', + 'name' => 'text_3ds_system_unavailable', + 'error' => 'error_3ds_system_unavailable', + 'recommended' => 0 + ), + 'system_bypassed' => array( + 'code' => 'system_bypassed', + 'name' => 'text_3ds_system_bypassed', + 'error' => 'error_3ds_system_bypassed', + 'recommended' => 1 + ) + ), + 'message_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' ) ), 'message_align' => array( @@ -508,6 +915,49 @@ 'name' => 'text_white' ) ), - 'message_flex_ratio' => array('1x1', '1x4', '8x1', '20x1') + 'message_flex_ratio' => array('1x1', '1x4', '8x1', '20x1'), + 'contact_sales' => array('100k - 250k', '250k - 2m', '2m - 10m', '10m - 20m', '20m - 50m', '50m +'), + 'contact_product' => array( + array( + 'code' => 'BT DCC', + 'name' => 'text_bt_dcc' + ), + array( + 'code' => 'Express Checkout (EC)', + 'name' => 'text_express_checkout' + ), + array( + 'code' => 'Credit - Installments', + 'name' => 'text_credit_installments' + ), + array( + 'code' => 'Point of Sale', + 'name' => 'text_point_of_sale' + ), + array( + 'code' => 'Invoicing API', + 'name' => 'text_invoicing_api' + ), + array( + 'code' => 'PayPal Working Capital', + 'name' => 'text_paypal_working_capital' + ), + array( + 'code' => 'Risk servicing', + 'name' => 'text_risk_servicing' + ), + array( + 'code' => 'PayPal Here', + 'name' => 'text_paypal_here' + ), + array( + 'code' => 'Payouts', + 'name' => 'text_payouts' + ), + array( + 'code' => 'Marketing solutions', + 'name' => 'text_marketing_solutions' + ), + ) ); ?> \ No newline at end of file diff --git a/upload/system/library/config.php b/upload/system/library/config.php index a81c16e0d35..97149210006 100644 --- a/upload/system/library/config.php +++ b/upload/system/library/config.php @@ -28,7 +28,7 @@ public function get($key) { * * * @param string $key - * @param string $value + * @param mixed $value */ public function set($key, $value) { $this->data[$key] = $value; @@ -39,7 +39,7 @@ public function set($key, $value) { * * @param string $key * - * @return mixed + * @return bool */ public function has($key) { return isset($this->data[$key]); diff --git a/upload/system/library/paypal/paypal.php b/upload/system/library/paypal/paypal.php index 82dc10992c0..425e1504d1e 100644 --- a/upload/system/library/paypal/paypal.php +++ b/upload/system/library/paypal/paypal.php @@ -8,27 +8,32 @@ class PayPal { private $partner_id = ''; private $client_id = ''; private $secret = ''; + private $partner_attribution_id = ''; private $access_token = ''; private $errors = array(); private $last_response = array(); //IN: paypal info public function __construct($paypal_info) { - if (isset($paypal_info['partner_id']) && $paypal_info['partner_id']) { + if (!empty($paypal_info['partner_id'])) { $this->partner_id = $paypal_info['partner_id']; } - if (isset($paypal_info['client_id']) && $paypal_info['client_id']) { + if (!empty($paypal_info['client_id'])) { $this->client_id = $paypal_info['client_id']; } - if (isset($paypal_info['secret']) && $paypal_info['secret']) { + if (!empty($paypal_info['secret'])) { $this->secret = $paypal_info['secret']; } - - if (isset($paypal_info['environment']) && (($paypal_info['environment'] == 'production') || ($paypal_info['environment'] == 'sandbox'))) { + + if (!empty($paypal_info['environment']) && (($paypal_info['environment'] == 'production') || ($paypal_info['environment'] == 'sandbox'))) { $this->environment = $paypal_info['environment']; } + + if (!empty($paypal_info['partner_attribution_id'])) { + $this->partner_attribution_id = $paypal_info['partner_attribution_id']; + } } //IN: token info @@ -40,13 +45,11 @@ public function setAccessToken($token_info) { $result = $this->execute('POST', $command, $params); - if (isset($result['access_token']) && $result['access_token']) { + if (!empty($result['access_token'])) { $this->access_token = $result['access_token']; return $this->access_token; } else { - $this->errors[] = $result; - return false; } } @@ -62,11 +65,26 @@ public function getClientToken() { $result = $this->execute('POST', $command); - if (isset($result['client_token']) && $result['client_token']) { + if (!empty($result['client_token'])) { return $result['client_token']; } else { - $this->errors[] = $result; - + return false; + } + } + + //OUT: merchant info, if no return - check errors + public function getUserInfo() { + $command = '/v1/identity/oauth2/userinfo'; + + $params = array( + 'schema' => 'paypalv1.1' + ); + + $result = $this->execute('GET', $command, $params); + + if (!empty($result['user_id'])) { + return $result; + } else { return false; } } @@ -75,18 +93,30 @@ public function getClientToken() { //OUT: merchant info, if no return - check errors public function getSellerCredentials($partner_id) { $command = '/v1/customer/partners/' . $partner_id . '/merchant-integrations/credentials'; - + $result = $this->execute('GET', $command); - if (isset($result['client_id']) && $result['client_id']) { + if (!empty($result['client_id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } + + //IN: partner id, merchant id + //OUT: merchant info, if no return - check errors + public function getSellerStatus($partner_id, $merchant_id) { + $command = '/v1/customer/partners/' . $partner_id . '/merchant-integrations/' . $merchant_id; + + $result = $this->execute('GET', $command); + if (!empty($result['merchant_id'])) { + return $result; + } else { + return false; + } + } + //IN: webhook info public function createWebhook($webhook_info) { $command = '/v1/notifications/webhooks'; @@ -95,11 +125,9 @@ public function createWebhook($webhook_info) { $result = $this->execute('POST', $command, $params, true); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -113,11 +141,9 @@ public function updateWebhook($webhook_id, $webhook_info) { $result = $this->execute('PATCH', $command, $params, true); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -138,11 +164,9 @@ public function getWebhook($webhook_id) { $result = $this->execute('GET', $command); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -153,11 +177,36 @@ public function getWebhooks() { $result = $this->execute('GET', $command); - if (isset($result['webhooks']) && $result['webhooks']) { + if (!empty($result['webhooks'])) { return $result['webhooks']; } else { - $this->errors[] = $result; - + return false; + } + } + + //IN: webhook event id + //OUT: webhook event info, if no return - check errors + public function getWebhookEvent($webhook_event_id) { + $command = '/v1/notifications/webhooks-events/' . $webhook_event_id; + + $result = $this->execute('GET', $command); + + if (!empty($result['id'])) { + return $result; + } else { + return false; + } + } + + //OUT: webhook events info, if no return - check errors + public function getWebhookEvents() { + $command = '/v1/notifications/webhooks-events'; + + $result = $this->execute('GET', $command); + + if (!empty($result['events'])) { + return $result['events']; + } else { return false; } } @@ -170,11 +219,9 @@ public function createOrder($order_info) { $result = $this->execute('POST', $command, $params, true); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -188,13 +235,7 @@ public function updateOrder($order_id, $order_info) { $result = $this->execute('PATCH', $command, $params, true); - if (isset($result['id']) && $result['id']) { - return $result; - } else { - $this->errors[] = $result; - - return false; - } + return true; } //IN: order id @@ -204,11 +245,9 @@ public function getOrder($order_id) { $result = $this->execute('GET', $command); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -219,11 +258,9 @@ public function setOrderAuthorize($order_id) { $result = $this->execute('POST', $command); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -234,11 +271,9 @@ public function setOrderCapture($order_id) { $result = $this->execute('POST', $command); - if (isset($result['id']) && $result['id']) { + if (!empty($result['id'])) { return $result; } else { - $this->errors[] = $result; - return false; } } @@ -277,7 +312,7 @@ private function execute($method, $command, $params = array(), $json = false) { $curl_options[CURLOPT_HTTPHEADER][] = 'Accept-Language: en_US'; $curl_options[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json'; $curl_options[CURLOPT_HTTPHEADER][] = 'PayPal-Request-Id: ' . $this->token(50); - $curl_options[CURLOPT_HTTPHEADER][] = 'PayPal-Partner-Attribution-Id: OPENCARTLIMITED_Cart_OpenCartPCP'; + $curl_options[CURLOPT_HTTPHEADER][] = 'PayPal-Partner-Attribution-Id: ' . $this->partner_attribution_id; if ($this->access_token) { $curl_options[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $this->access_token; @@ -333,11 +368,11 @@ private function execute($method, $command, $params = array(), $json = false) { default: $curl_options[CURLOPT_CUSTOMREQUEST] = strtoupper($method); } - + $ch = curl_init(); curl_setopt_array($ch, $curl_options); $response = curl_exec($ch); - + if (curl_errno($ch)) { $curl_code = curl_errno($ch); @@ -346,25 +381,7 @@ private function execute($method, $command, $params = array(), $json = false) { $this->errors[] = array('name' => $curl_constant[$curl_code], 'message' => curl_strerror($curl_code)); } - - /*$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if (($status_code >= 0) && ($status_code < 200)) { - $this->errors[] = 'Server Not Found (' . $status_code . ')'; - } - - if (($status_code >= 300) && ($status_code < 400)) { - $this->errors[] = 'Page Redirect (' . $status_code . ')'; - } - - if (($status_code >= 400) && ($status_code < 500)) { - $this->errors[] = 'Page not found (' . $status_code . ')'; - } - - if ($status_code >= 500) { - $this->errors[] = 'Server Error (' . $status_code . ')'; - }*/ - + $head = ''; $body = ''; @@ -395,7 +412,11 @@ private function execute($method, $command, $params = array(), $json = false) { $this->last_response = json_decode($body, true); - return $this->last_response; + if (!empty($this->last_response['message'])) { + $this->errors[] = (array)$this->last_response; + } + + return (array)$this->last_response; } } diff --git a/upload/system/storage/vendor/klarna/kco_rest/.coveralls.yml b/upload/system/storage/vendor/klarna/kco_rest/.coveralls.yml new file mode 100644 index 00000000000..09bbb257dc7 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/.coveralls.yml @@ -0,0 +1,3 @@ +src_dir: src +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json diff --git a/upload/system/storage/vendor/klarna/kco_rest/.gitignore b/upload/system/storage/vendor/klarna/kco_rest/.gitignore new file mode 100644 index 00000000000..b5294333576 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +/build/ +/docs/reference diff --git a/upload/system/storage/vendor/klarna/kco_rest/.travis.yml b/upload/system/storage/vendor/klarna/kco_rest/.travis.yml new file mode 100644 index 00000000000..5932d306bd6 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/.travis.yml @@ -0,0 +1,29 @@ +language: php +php: + - 7.0 + - 5.6 + - 5.5 + - 5.4 + - hhvm + +matrix: + allow_failures: + - php: 7.0 + +branches: + only: + - /^v\d\.\d/ +cache: + directories: + - vendor + +before_script: + - composer install --no-interaction + +script: + - composer run test + +after_script: + - php vendor/bin/coveralls -v + +sudo: false diff --git a/upload/system/storage/vendor/klarna/kco_rest/CHANGELOG.md b/upload/system/storage/vendor/klarna/kco_rest/CHANGELOG.md new file mode 100644 index 00000000000..42ca1f21c7e --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/CHANGELOG.md @@ -0,0 +1,17 @@ +## v2.2.0 - 2015-12-7 +- **NEW META-13** Allow for 201 response on refund - *Joakim.L* + +## v2.1.0 - 2015-07-29 +- **NEW MINT-2262** Support Guzzle 5.x versions - *Omer.K, Joakim.L* + +## v2.0.0 - 2015-06-10 +- **NEW MINT-2203** Use order id instead of URL for checkout orders - *Joakim.L* +- **NEW MINT-2214** Add base URLs for North America - *Joakim.L* + +## v1.0.1 - 2015-03-30 +- **FIX MINT-2002** Handle errors with an empty payload - *David.K* +- **NEW MINT-2097** Add apigen and custom styling - *Petros.G* + +## v1.0.0 - 2014-10-16 +- **NEW MINT-1804** Support checkout v3 and ordermanagement v1 APIs - *Joakim.L* + diff --git a/upload/system/storage/vendor/klarna/kco_rest/README.md b/upload/system/storage/vendor/klarna/kco_rest/README.md new file mode 100644 index 00000000000..537f4c98a70 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/README.md @@ -0,0 +1,67 @@ +# Klarna Checkout REST PHP SDK +[![Packagist Version][packagist-image]](https://packagist.org/packages/klarna/kco_rest) +[![Build Status][travis-image]](https://travis-ci.org/klarna/kco_rest_php) +[![Coverage Status][coveralls-image]](https://coveralls.io/r/klarna/kco_rest_php?branch=v2.2) + +Klarna Checkout is a revolutionary new payment solution that is changing the way +people shop online. First, consumers verify their purchase with a minimal +amount of information through intelligent identification, securing your order +immediately, and then complete their payment afterwards – separating buying +from paying and dramatically increasing conversion. Klarna Checkout also allows +merchants to offer all payment methods through one supplier, minimizing +administration, costs and integration time. + + +## Get started + +### Prerequisites +* PHP 5.4 or above +* API credentials + + +### Usage +Example files can be found in the [docs/](docs/) directory. + + +## Documentation +Additional documentation can be found at https://developers.klarna.com. + + +## Questions and feedback +If you have any questions concerning this product or the implementation, +please contact [integration@klarna.com](mailto:integration@klarna.com). + + +## How to contribute +At Klarna, we strive toward achieving the highest possible quality for our +products. Therefore, we require you to follow these guidelines if you wish +to contribute. + +To contribute, the following criteria needs to be fulfilled: + +* Description regarding what has been changed and why +* Pull requests should implement a boxed change +* All code and documentation must follow the [PSR-2 standard](http://www.php-fig.org/psr/psr-2/) +* New features and bug fixes must have accompanying unit tests: + * Positive tests + * Negative tests + * Boundary tests (if possible) + * No less than 90% decision coverage +* All tests should pass + + +## Acknowledgements +* Christer Gustavsson ([@ChristerGustavsson](https://github.com/ChristerGustavsson)) +* David Keijser ([@keis](https://github.com/keis)) +* Joakim Löfgren ([@JoakimLofgren](https://github.com/JoakimLofgren)) +* Majid Garmaroudi ([@dijam](https://github.com/dijam)) +* Omer Karadagli ([@ockcyp](https://github.com/ockcyp)) + + +## License +Klarna Checkout REST PHP SDK is licensed under +[Apache License, Version 2.0](http://www.apache.org/LICENSE-2.0) + +[packagist-image]: https://img.shields.io/packagist/v/klarna/kco_rest.svg?style=flat +[travis-image]: https://img.shields.io/travis/klarna/kco_rest_php/v2.2.svg?style=flat +[coveralls-image]: https://img.shields.io/coveralls/klarna/kco_rest_php/v2.2.svg?style=flat diff --git a/upload/system/storage/vendor/klarna/kco_rest/composer.json b/upload/system/storage/vendor/klarna/kco_rest/composer.json new file mode 100644 index 00000000000..d34e36bfbf6 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/composer.json @@ -0,0 +1,46 @@ +{ + "name": "klarna/kco_rest", + "description": "Klarna Checkout PHP SDK", + "homepage": "http://developers.klarna.com", + "license": "Apache-2.0", + "type": "library", + "authors": [ + { + "name": "Klarna AB", + "email": "integration@klarna.com" + } + ], + "autoload": { + "psr-4": { + "": "src/" + } + }, + "minimum-stability": "stable", + "require": { + "php": ">=5.4.0", + "guzzlehttp/guzzle": ">=4.2,<6.0" + }, + "require-dev": { + "phpunit/phpunit": "4.2.*", + "squizlabs/php_codesniffer": "1.5.*", + "phpmd/phpmd": "2.1.*", + "phploc/phploc": "2.0.*", + "sebastian/phpcpd": "2.0.*", + "satooshi/php-coveralls": "0.6.*", + "apigen/apigen": "4.0.*", + "klarna/apigen-theme": "~1.0" + }, + "scripts": { + "test": "vendor/bin/phpunit --colors", + "reference": "vendor/bin/apigen generate -s src -d docs/reference --template-config='vendor/klarna/apigen-theme/src/config.neon'", + "analyze": [ + "mkdir -p build/logs", + "vendor/bin/phploc --log-csv build/logs/phploc.csv src/ tests/", + "mkdir -p build/pdepend", + "vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --jdepend-chart=build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg src/", + "vendor/bin/phpmd src/,tests/ xml phpmd.xml --reportfile build/logs/pmd.xml || true", + "vendor/bin/phpcs --standard=PSR2 --report=checkstyle --report-file=build/logs/checkstyle.xml --extensions=php src/ tests/", + "vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml src/ tests/ || true" + ] + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/composer.lock b/upload/system/storage/vendor/klarna/kco_rest/composer.lock new file mode 100644 index 00000000000..f6bb9a8b5ae --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/composer.lock @@ -0,0 +1,3569 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "faa4d6f172d4f9991cf2583e57f9b43c", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "5.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "f3c8c22471cb55475105c14769644a49c3262b93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93", + "reference": "f3c8c22471cb55475105c14769644a49c3262b93", + "shasum": "" + }, + "require": { + "guzzlehttp/ringphp": "^1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-05-20 03:47:55" + }, + { + "name": "guzzlehttp/ringphp", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/RingPHP.git", + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "shasum": "" + }, + "require": { + "guzzlehttp/streams": "~3.0", + "php": ">=5.4.0", + "react/promise": "~2.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Ring\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "time": "2015-05-20 03:37:09" + }, + { + "name": "guzzlehttp/streams", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/streams.git", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple abstraction over streams of data", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "stream" + ], + "time": "2014-10-12 19:18:40" + }, + { + "name": "react/promise", + "version": "v2.2.1", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/3b6fca09c7d56321057fa8867c8dbe1abf648627", + "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "React\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "time": "2015-07-03 13:48:55" + } + ], + "packages-dev": [ + { + "name": "andrewsville/php-token-reflection", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/Andrewsville/PHP-Token-Reflection.git", + "reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Andrewsville/PHP-Token-Reflection/zipball/e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee", + "reference": "e6d0ac2baf66cdf154be34c3d2a2aa1bd4b426ee", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "TokenReflection": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3" + ], + "authors": [ + { + "name": "Ondřej Nešpor", + "homepage": "https://github.com/andrewsville" + }, + { + "name": "Jaroslav Hanslík", + "homepage": "https://github.com/kukulich" + } + ], + "description": "Library emulating the PHP internal reflection using just the tokenized source code.", + "homepage": "http://andrewsville.github.com/PHP-Token-Reflection/", + "keywords": [ + "library", + "reflection", + "tokenizer" + ], + "time": "2014-08-06 16:37:08" + }, + { + "name": "apigen/apigen", + "version": "v4.0.1", + "source": { + "type": "git", + "url": "https://github.com/ApiGen/ApiGen.git", + "reference": "b719a6ad49107b5bc0bdf9fc8fae219a9a6dd5f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ApiGen/ApiGen/zipball/b719a6ad49107b5bc0bdf9fc8fae219a9a6dd5f1", + "reference": "b719a6ad49107b5bc0bdf9fc8fae219a9a6dd5f1", + "shasum": "" + }, + "require": { + "andrewsville/php-token-reflection": "~1.4", + "herrera-io/phar-update": "~2.0", + "kdyby/events": "~2.0", + "kukulich/fshl": "~2.1", + "latte/latte": "~2.2", + "michelf/php-markdown": "~1.4", + "nette/application": "~2.2", + "nette/bootstrap": "~2.2", + "nette/di": "~2.2", + "nette/mail": "~2.2", + "nette/neon": "~2.2", + "nette/robot-loader": "~2.2", + "nette/safe-stream": "~2.2", + "php": ">=5.4", + "symfony/console": "~2.6", + "symfony/options-resolver": "~2.6.1", + "tracy/tracy": "~2.2" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "~0.8", + "mockery/mockery": "~0.9", + "phpunit/phpunit": "~4.4", + "zenify/coding-standard": "~3.0" + }, + "bin": [ + "bin/apigen" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.0-dev" + } + }, + "autoload": { + "psr-4": { + "ApiGen\\": "src/ApiGen" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Ondřej Nešpor", + "homepage": "https://github.com/andrewsville" + }, + { + "name": "Jaroslav Hanslík", + "homepage": "https://github.com/kukulich" + }, + { + "name": "Tomáš Votruba", + "email": "tomas.vot@gmail.com" + }, + { + "name": "Olivier Laviale", + "homepage": "https://github.com/olvlvl" + } + ], + "description": "PHP source code API generator", + "homepage": "http://apigen.org/", + "keywords": [ + "api", + "documentation", + "generator", + "phpdoc" + ], + "time": "2015-03-09 11:03:45" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, + { + "name": "herrera-io/json", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/kherge-abandoned/php-json.git", + "reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kherge-abandoned/php-json/zipball/60c696c9370a1e5136816ca557c17f82a6fa83f1", + "reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1", + "shasum": "" + }, + "require": { + "ext-json": "*", + "justinrainbow/json-schema": ">=1.0,<2.0-dev", + "php": ">=5.3.3", + "seld/jsonlint": ">=1.0,<2.0-dev" + }, + "require-dev": { + "herrera-io/phpunit-test-case": "1.*", + "mikey179/vfsstream": "1.1.0", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/lib/json_version.php" + ], + "psr-0": { + "Herrera\\Json": "src/lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io" + } + ], + "description": "A library for simplifying JSON linting and validation.", + "homepage": "http://herrera-io.github.com/php-json", + "keywords": [ + "json", + "lint", + "schema", + "validate" + ], + "time": "2013-10-30 16:51:34" + }, + { + "name": "herrera-io/phar-update", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/kherge-abandoned/php-phar-update.git", + "reference": "15643c90d3d43620a4f45c910e6afb7a0ad4b488" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kherge-abandoned/php-phar-update/zipball/15643c90d3d43620a4f45c910e6afb7a0ad4b488", + "reference": "15643c90d3d43620a4f45c910e6afb7a0ad4b488", + "shasum": "" + }, + "require": { + "herrera-io/json": "1.*", + "herrera-io/version": "1.*", + "php": ">=5.3.3" + }, + "require-dev": { + "herrera-io/phpunit-test-case": "1.*", + "mikey179/vfsstream": "1.1.0", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "files": [ + "src/lib/constants.php" + ], + "psr-0": { + "Herrera\\Phar\\Update": "src/lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io" + } + ], + "description": "A library for self-updating Phars.", + "homepage": "http://herrera-io.github.com/php-phar-update", + "keywords": [ + "phar", + "update" + ], + "time": "2013-11-09 17:13:13" + }, + { + "name": "herrera-io/version", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/kherge-abandoned/php-version.git", + "reference": "d39d9642b92a04d8b8a28b871b797a35a2545e85" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kherge-abandoned/php-version/zipball/d39d9642b92a04d8b8a28b871b797a35a2545e85", + "reference": "d39d9642b92a04d8b8a28b871b797a35a2545e85", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "herrera-io/phpunit-test-case": "1.*", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Herrera\\Version": "src/lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io" + } + ], + "description": "A library for creating, editing, and comparing semantic versioning numbers.", + "homepage": "http://github.com/herrera-io/php-version", + "keywords": [ + "semantic", + "version" + ], + "time": "2014-05-27 05:29:25" + }, + { + "name": "justinrainbow/json-schema", + "version": "1.4.4", + "source": { + "type": "git", + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce", + "reference": "8dc9b9d85ab639ca60ab4608b34c1279d6ae7bce", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "json-schema/json-schema-test-suite": "1.1.0", + "phpdocumentor/phpdocumentor": "~2", + "phpunit/phpunit": "~3.7" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "JsonSchema": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "time": "2015-07-14 16:29:50" + }, + { + "name": "kdyby/events", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/Kdyby/Events.git", + "reference": "8049e0fc7abb48178b4a2a9af230eceebe1a83bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kdyby/Events/zipball/8049e0fc7abb48178b4a2a9af230eceebe1a83bc", + "reference": "8049e0fc7abb48178b4a2a9af230eceebe1a83bc", + "shasum": "" + }, + "require": { + "nette/di": "~2.3@dev", + "nette/utils": "~2.3@dev" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "~0.7", + "latte/latte": "~2.3@dev", + "nette/application": "~2.3@dev", + "nette/bootstrap": "~2.3@dev", + "nette/caching": "~2.3@dev", + "nette/component-model": "~2.2@dev", + "nette/database": "~2.3@dev", + "nette/deprecated": "~2.3@dev", + "nette/di": "~2.3@dev", + "nette/finder": "~2.3@dev", + "nette/forms": "~2.3@dev", + "nette/http": "~2.3@dev", + "nette/mail": "~2.3@dev", + "nette/neon": "~2.3@dev", + "nette/nette": "~2.3@dev", + "nette/php-generator": "~2.3@dev", + "nette/reflection": "~2.3@dev", + "nette/robot-loader": "~2.3@dev", + "nette/safe-stream": "~2.3@dev", + "nette/security": "~2.3@dev", + "nette/tester": "~1.4@rc", + "nette/tokenizer": "~2.2@dev", + "nette/utils": "~2.3@dev", + "symfony/event-dispatcher": "~2.5", + "tracy/tracy": "~2.3@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Kdyby\\Events\\": "src/" + }, + "classmap": [ + "src/Kdyby/Events/exceptions.php" + ], + "files": [ + "src/Doctrine/compatibility.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "Filip Procházka", + "email": "filip@prochazka.su", + "homepage": "http://filip-prochazka.com" + } + ], + "description": "Events for Nette Framework", + "homepage": "http://kdyby.org", + "keywords": [ + "kdyby", + "nette" + ], + "time": "2015-04-04 16:29:31" + }, + { + "name": "klarna/apigen-theme", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/klarna/klarna-apigen-theme.git", + "reference": "1ffcd0e4ea5620d50dbfb74639e4aa4113924911" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/klarna/klarna-apigen-theme/zipball/1ffcd0e4ea5620d50dbfb74639e4aa4113924911", + "reference": "1ffcd0e4ea5620d50dbfb74639e4aa4113924911", + "shasum": "" + }, + "require": { + "latte/latte": "~2.2" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tomáš Votruba", + "email": "tomas.vot@gmail.com" + }, + { + "name": "Olivier Laviale", + "homepage": "https://github.com/olvlvl" + }, + { + "name": "David Keijser", + "email": "david.keijser@klarna.com" + }, + { + "name": "Petros Gkourasas", + "email": "petros.gkourasas@klarna.com" + } + ], + "description": "Klarna theme for ApiGen", + "homepage": "http://klarna.com/", + "time": "2015-03-30 15:27:12" + }, + { + "name": "kukulich/fshl", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/kukulich/fshl.git", + "reference": "974c294ade5d76c0c16b6fe3fd3a584ba999b24f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kukulich/fshl/zipball/974c294ade5d76c0c16b6fe3fd3a584ba999b24f", + "reference": "974c294ade5d76c0c16b6fe3fd3a584ba999b24f", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "psr-0": { + "FSHL": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Jaroslav Hanslík", + "homepage": "https://github.com/kukulich" + } + ], + "description": "FSHL is a free, open source, universal, fast syntax highlighter written in PHP.", + "homepage": "http://fshl.kukulich.cz/", + "keywords": [ + "highlight", + "library", + "syntax" + ], + "time": "2012-09-08 19:00:07" + }, + { + "name": "latte/latte", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nette/latte.git", + "reference": "025883a04b3a5ca48995246e8d82e6ff323d941e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/latte/zipball/025883a04b3a5ca48995246e8d82e6ff323d941e", + "reference": "025883a04b3a5ca48995246e8d82e6ff323d941e", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.1" + }, + "require-dev": { + "nette/tester": "~1.3" + }, + "suggest": { + "ext-fileinfo": "to use filter |datastream", + "ext-mbstring": "to use filters like lower, upper, capitalize, ..." + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Latte: the amazing template engine for PHP", + "homepage": "http://latte.nette.org", + "keywords": [ + "templating", + "twig" + ], + "time": "2015-07-03 13:37:59" + }, + { + "name": "michelf/php-markdown", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/michelf/php-markdown.git", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-lib": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Michelf": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "John Gruber", + "homepage": "http://daringfireball.net/" + }, + { + "name": "Michel Fortin", + "email": "michel.fortin@michelf.ca", + "homepage": "https://michelf.ca/", + "role": "Developer" + } + ], + "description": "PHP Markdown", + "homepage": "https://michelf.ca/projects/php-markdown/", + "keywords": [ + "markdown" + ], + "time": "2015-03-01 12:03:08" + }, + { + "name": "nette/application", + "version": "v2.3.4", + "source": { + "type": "git", + "url": "https://github.com/nette/application.git", + "reference": "785801e441ef83fa4d75cc47c292afedee9b3e4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/application/zipball/785801e441ef83fa4d75cc47c292afedee9b3e4e", + "reference": "785801e441ef83fa4d75cc47c292afedee9b3e4e", + "shasum": "" + }, + "require": { + "nette/component-model": "~2.2", + "nette/http": "~2.2", + "nette/reflection": "~2.2", + "nette/security": "~2.2", + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.3.0", + "nette/di": "~2.3", + "nette/forms": "~2.2", + "nette/robot-loader": "~2.2", + "nette/tester": "~1.3" + }, + "suggest": { + "latte/latte": "Allows using Latte in templates", + "nette/forms": "Allows to use Nette\\Application\\UI\\Form" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Application MVC Component", + "homepage": "http://nette.org", + "time": "2015-07-01 15:54:47" + }, + { + "name": "nette/bootstrap", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nette/bootstrap.git", + "reference": "8e2db45c39a1fa24f88e94c7b2a62ad09e9a306e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/8e2db45c39a1fa24f88e94c7b2a62ad09e9a306e", + "reference": "8e2db45c39a1fa24f88e94c7b2a62ad09e9a306e", + "shasum": "" + }, + "require": { + "nette/di": "~2.3", + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.2", + "nette/application": "~2.3", + "nette/caching": "~2.3", + "nette/database": "~2.3", + "nette/forms": "~2.3", + "nette/http": "~2.3", + "nette/mail": "~2.3", + "nette/robot-loader": "~2.2", + "nette/safe-stream": "~2.2", + "nette/security": "~2.3", + "nette/tester": "~1.3", + "tracy/tracy": "~2.3" + }, + "suggest": { + "nette/robot-loader": "to use Configurator::createRobotLoader()", + "tracy/tracy": "to use Configurator::enableDebugger()" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Bootstrap", + "homepage": "http://nette.org", + "time": "2015-07-11 21:07:11" + }, + { + "name": "nette/caching", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/nette/caching.git", + "reference": "1523a0d2596193dd792045a07e89795eeef435db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/caching/zipball/1523a0d2596193dd792045a07e89795eeef435db", + "reference": "1523a0d2596193dd792045a07e89795eeef435db", + "shasum": "" + }, + "require": { + "nette/finder": "~2.2", + "nette/utils": "~2.2", + "php": ">=5.4.4" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.4", + "nette/di": "~2.3", + "nette/tester": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Caching Component", + "homepage": "http://nette.org", + "time": "2015-06-15 16:32:59" + }, + { + "name": "nette/component-model", + "version": "v2.2.3", + "source": { + "type": "git", + "url": "https://github.com/nette/component-model.git", + "reference": "fe13e630a307ef4585b3573eae0a161dc1c3d428" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/component-model/zipball/fe13e630a307ef4585b3573eae0a161dc1c3d428", + "reference": "fe13e630a307ef4585b3573eae0a161dc1c3d428", + "shasum": "" + }, + "require": { + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Component Model", + "homepage": "http://nette.org", + "time": "2015-07-11 21:11:20" + }, + { + "name": "nette/di", + "version": "v2.3.5", + "source": { + "type": "git", + "url": "https://github.com/nette/di.git", + "reference": "c3e726f8bef49033ba78efe19e999e5fac63f433" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/di/zipball/c3e726f8bef49033ba78efe19e999e5fac63f433", + "reference": "c3e726f8bef49033ba78efe19e999e5fac63f433", + "shasum": "" + }, + "require": { + "nette/neon": "~2.3", + "nette/php-generator": "~2.3", + "nette/utils": "~2.3", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Dependency Injection Component", + "homepage": "http://nette.org", + "time": "2015-07-13 22:28:49" + }, + { + "name": "nette/finder", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/finder.git", + "reference": "38f803a03f4cddf352e28af70294c71f7026e516" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/finder/zipball/38f803a03f4cddf352e28af70294c71f7026e516", + "reference": "38f803a03f4cddf352e28af70294c71f7026e516", + "shasum": "" + }, + "require": { + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Finder: Files Searching", + "homepage": "http://nette.org", + "time": "2015-07-11 21:13:50" + }, + { + "name": "nette/http", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nette/http.git", + "reference": "ff2e4608391bca2444df9af6eaf8666ac853eb02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/http/zipball/ff2e4608391bca2444df9af6eaf8666ac853eb02", + "reference": "ff2e4608391bca2444df9af6eaf8666ac853eb02", + "shasum": "" + }, + "require": { + "nette/utils": "~2.2, >=2.2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/di": "~2.3", + "nette/tester": "~1.4" + }, + "suggest": { + "ext-fileinfo": "to detect type of uploaded files" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette HTTP Component", + "homepage": "http://nette.org", + "time": "2015-07-19 16:17:50" + }, + { + "name": "nette/mail", + "version": "v2.3.2", + "source": { + "type": "git", + "url": "https://github.com/nette/mail.git", + "reference": "2c6c64787edf8131ec5e1b514ecc4a80a6477f80" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/mail/zipball/2c6c64787edf8131ec5e1b514ecc4a80a6477f80", + "reference": "2c6c64787edf8131ec5e1b514ecc4a80a6477f80", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/di": "~2.3", + "nette/tester": "~1.3" + }, + "suggest": { + "ext-fileinfo": "to detect type of attached files" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Mail: Sending E-mails", + "homepage": "http://nette.org", + "time": "2015-07-03 13:31:38" + }, + { + "name": "nette/neon", + "version": "v2.3.2", + "source": { + "type": "git", + "url": "https://github.com/nette/neon.git", + "reference": "48b25e0962d70e9125797e67a144f3e057243d9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/neon/zipball/48b25e0962d70e9125797e67a144f3e057243d9d", + "reference": "48b25e0962d70e9125797e67a144f3e057243d9d", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=5.3.1" + }, + "require-dev": { + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette NEON: parser & generator for Nette Object Notation", + "homepage": "http://ne-on.org", + "time": "2015-07-13 22:29:08" + }, + { + "name": "nette/php-generator", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/php-generator.git", + "reference": "c47ad59b972e8a5f4bb00299951bd8053a8fc074" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/php-generator/zipball/c47ad59b972e8a5f4bb00299951bd8053a8fc074", + "reference": "c47ad59b972e8a5f4bb00299951bd8053a8fc074", + "shasum": "" + }, + "require": { + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette PHP Generator", + "homepage": "http://nette.org", + "time": "2015-07-11 21:19:33" + }, + { + "name": "nette/reflection", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/reflection.git", + "reference": "9c2ed2a29f1f58125a0f19ffc987812d6b17d3e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/reflection/zipball/9c2ed2a29f1f58125a0f19ffc987812d6b17d3e6", + "reference": "9c2ed2a29f1f58125a0f19ffc987812d6b17d3e6", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/caching": "~2.2", + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/di": "~2.3", + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette PHP Reflection Component", + "homepage": "http://nette.org", + "time": "2015-07-11 21:34:53" + }, + { + "name": "nette/robot-loader", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/robot-loader.git", + "reference": "69331d359bbc9e5f911c12b82187cac914d983fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/69331d359bbc9e5f911c12b82187cac914d983fb", + "reference": "69331d359bbc9e5f911c12b82187cac914d983fb", + "shasum": "" + }, + "require": { + "nette/caching": "~2.2", + "nette/finder": "~2.3", + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette RobotLoader: comfortable autoloading", + "homepage": "http://nette.org", + "time": "2015-07-11 21:20:57" + }, + { + "name": "nette/safe-stream", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/safe-stream.git", + "reference": "bf30db367b51a0932c44dcb9a378927644d48b2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/safe-stream/zipball/bf30db367b51a0932c44dcb9a378927644d48b2e", + "reference": "bf30db367b51a0932c44dcb9a378927644d48b2e", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "files": [ + "src/loader.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette SafeStream: Atomic Operations", + "homepage": "http://nette.org", + "time": "2015-07-11 20:59:15" + }, + { + "name": "nette/security", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/nette/security.git", + "reference": "744264a42b506d63009d7e3853ed72b04c99e964" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/security/zipball/744264a42b506d63009d7e3853ed72b04c99e964", + "reference": "744264a42b506d63009d7e3853ed72b04c99e964", + "shasum": "" + }, + "require": { + "nette/utils": "~2.2", + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/di": "~2.3", + "nette/http": "~2.3", + "nette/tester": "~1.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Security: Access Control Component", + "homepage": "http://nette.org", + "time": "2015-07-11 21:22:53" + }, + { + "name": "nette/utils", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "ff80fce39fdc381e7e0db6cc5ffc82162e59f6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/ff80fce39fdc381e7e0db6cc5ffc82162e59f6bb", + "reference": "ff80fce39fdc381e7e0db6cc5ffc82162e59f6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~1.0" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize() and toAscii()", + "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-mbstring": "to use Strings::lower() etc..." + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Nette Utility Classes", + "homepage": "http://nette.org", + "time": "2015-07-13 22:30:00" + }, + { + "name": "pdepend/pdepend", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4", + "reference": "a15ffcbfbcc4570d4a733ca7b76e9cac0a56c3f4", + "shasum": "" + }, + "require": { + "symfony/config": ">=2.4", + "symfony/dependency-injection": ">=2.4", + "symfony/filesystem": ">=2.4" + }, + "require-dev": { + "phpunit/phpunit": "4.*@stable", + "squizlabs/php_codesniffer": "@stable" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "autoload": { + "psr-0": { + "PDepend\\": "src/main/php/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "time": "2015-03-02 08:06:43" + }, + { + "name": "phploc/phploc", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phploc.git", + "reference": "322ad07c112d5c6832abed4269d648cacff5959b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phploc/zipball/322ad07c112d5c6832abed4269d648cacff5959b", + "reference": "322ad07c112d5c6832abed4269d648cacff5959b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/finder-facade": "~1.1", + "sebastian/git": "~1.0", + "sebastian/version": "~1.0", + "symfony/console": "~2.2" + }, + "bin": [ + "phploc" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "A tool for quickly measuring the size of a PHP project.", + "homepage": "https://github.com/sebastianbergmann/phploc", + "time": "2014-06-25 08:11:02" + }, + { + "name": "phpmd/phpmd", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "1a485d9db869137af5e9678bd844568c92998b25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/1a485d9db869137af5e9678bd844568c92998b25", + "reference": "1a485d9db869137af5e9678bd844568c92998b25", + "shasum": "" + }, + "require": { + "pdepend/pdepend": "2.0.*", + "php": ">=5.3.0", + "symfony/config": "2.5.*", + "symfony/dependency-injection": "2.5.*", + "symfony/filesystem": "2.5.*" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of PHPMD handled with Composer.", + "time": "2014-09-25 15:56:22" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.1.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5bd48b86cd282da411bb80baac1398ce3fefac41", + "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-07-26 12:54:47" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-21 08:01:12" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-06-19 03:43:16" + }, + { + "name": "phpunit/phpunit", + "version": "4.2.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c28a790620fe30b049bb693be1ef9cd4e0fe906c", + "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.2", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-09-14 09:31:24" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", + "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-07-10 06:54:24" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, + { + "name": "sebastian/comparator", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-07-26 15:48:44" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", + "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-07-26 06:42:57" + }, + { + "name": "sebastian/exporter", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-06-21 07:55:53" + }, + { + "name": "sebastian/finder-facade", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/finder-facade.git", + "reference": "a520dcc3dd39160eea480daa3426f4fd419a327b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/a520dcc3dd39160eea480daa3426f4fd419a327b", + "reference": "a520dcc3dd39160eea480daa3426f4fd419a327b", + "shasum": "" + }, + "require": { + "symfony/finder": "~2.3", + "theseer/fdomdocument": "~1.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", + "homepage": "https://github.com/sebastianbergmann/finder-facade", + "time": "2015-06-04 08:11:58" + }, + { + "name": "sebastian/git", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/git.git", + "reference": "a99fbc102e982c1404041ef3e4d431562b29bcba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/git/zipball/a99fbc102e982c1404041ef3e4d431562b29bcba", + "reference": "a99fbc102e982c1404041ef3e4d431562b29bcba", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple wrapper for Git", + "homepage": "http://www.github.com/sebastianbergmann/git", + "keywords": [ + "git" + ], + "time": "2013-08-04 09:35:29" + }, + { + "name": "sebastian/phpcpd", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpcpd.git", + "reference": "d3ad100fdf15805495f6ff19f473f4314c99390c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/d3ad100fdf15805495f6ff19f473f4314c99390c", + "reference": "d3ad100fdf15805495f6ff19f473f4314c99390c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-timer": "~1.0", + "sebastian/finder-facade": "~1.1", + "sebastian/version": "~1.0", + "symfony/console": "~2.2", + "theseer/fdomdocument": "~1.4" + }, + "bin": [ + "phpcpd" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Copy/Paste Detector (CPD) for PHP code.", + "homepage": "https://github.com/sebastianbergmann/phpcpd", + "time": "2015-03-26 14:47:38" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-06-21 08:04:50" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21 13:59:46" + }, + { + "name": "seld/jsonlint", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "863ae85c6d3ef60ca49cb12bd051c4a0648c40c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/863ae85c6d3ef60ca49cb12bd051c4a0648c40c4", + "reference": "863ae85c6d3ef60ca49cb12bd051c4a0648c40c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "bin": [ + "bin/jsonlint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], + "time": "2015-01-04 21:18:15" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "1.5.6", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6f3e42d311b882b25b4d409d23a289f4d3b803d5", + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.1.2" + }, + "suggest": { + "phpunit/php-timer": "dev-master" + }, + "bin": [ + "scripts/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-phpcs-fixer": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/CommentParser/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2014-12-04 22:32:15" + }, + { + "name": "symfony/config", + "version": "v2.5.12", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "c7309e33b719433d5cf3845d0b5b9608609d8c8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/c7309e33b719433d5cf3845d0b5b9608609d8c8e", + "reference": "c7309e33b719433d5cf3845d0b5b9608609d8c8e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com", + "time": "2015-01-03 08:01:13" + }, + { + "name": "symfony/console", + "version": "v2.7.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed", + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-07-09 16:07:40" + }, + { + "name": "symfony/dependency-injection", + "version": "v2.5.12", + "target-dir": "Symfony/Component/DependencyInjection", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection.git", + "reference": "c42aee05b466cc9c66b87ddf7d263402befb6962" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/c42aee05b466cc9c66b87ddf7d263402befb6962", + "reference": "c42aee05b466cc9c66b87ddf7d263402befb6962", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4,>=2.4.10", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\DependencyInjection\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "http://symfony.com", + "time": "2015-01-25 04:37:39" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.7.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-06-18 19:21:56" + }, + { + "name": "symfony/filesystem", + "version": "v2.5.12", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "d3c24d7d6e9c342008d8421b2fade460311647ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/d3c24d7d6e9c342008d8421b2fade460311647ea", + "reference": "d3c24d7d6e9c342008d8421b2fade460311647ea", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2015-01-03 21:04:44" + }, + { + "name": "symfony/finder", + "version": "v2.7.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "ae0f363277485094edc04c9f3cbe595b183b78e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/ae0f363277485094edc04c9f3cbe595b183b78e4", + "reference": "ae0f363277485094edc04c9f3cbe595b183b78e4", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2015-07-09 16:07:40" + }, + { + "name": "symfony/options-resolver", + "version": "v2.6.11", + "target-dir": "Symfony/Component/OptionsResolver", + "source": { + "type": "git", + "url": "https://github.com/symfony/OptionsResolver.git", + "reference": "31e56594cee489e9a235b852228b0598b52101c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/OptionsResolver/zipball/31e56594cee489e9a235b852228b0598b52101c1", + "reference": "31e56594cee489e9a235b852228b0598b52101c1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\OptionsResolver\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2015-05-13 11:33:56" + }, + { + "name": "symfony/stopwatch", + "version": "v2.7.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "b07a866719bbac5294c67773340f97b871733310" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310", + "reference": "b07a866719bbac5294c67773340f97b871733310", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-07-01 18:23:16" + }, + { + "name": "symfony/yaml", + "version": "v2.7.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-07-01 11:25:50" + }, + { + "name": "theseer/fdomdocument", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/fDOMDocument.git", + "reference": "d9ad139d6c2e8edf5e313ffbe37ff13344cf0684" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/d9ad139d6c2e8edf5e313ffbe37ff13344cf0684", + "reference": "d9ad139d6c2e8edf5e313ffbe37ff13344cf0684", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "lib-libxml": "*", + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "lead" + } + ], + "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", + "homepage": "https://github.com/theseer/fDOMDocument", + "time": "2015-05-27 22:58:02" + }, + { + "name": "tracy/tracy", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nette/tracy.git", + "reference": "17d15b8dc83cab3bc5022a45d32c681a76cc19e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/tracy/zipball/17d15b8dc83cab3bc5022a45d32c681a76cc19e1", + "reference": "17d15b8dc83cab3bc5022a45d32c681a76cc19e1", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "require-dev": { + "nette/di": "~2.3", + "nette/tester": "~1.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ], + "files": [ + "src/shortcuts.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "http://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "http://nette.org/contributors" + } + ], + "description": "Tracy: useful PHP debugger", + "homepage": "http://tracy.nette.org", + "keywords": [ + "debug", + "debugger", + "nette" + ], + "time": "2015-07-03 12:52:35" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.4.0" + }, + "platform-dev": [] +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/add_shipping_info.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/add_shipping_info.php new file mode 100644 index 00000000000..5bbdc2c6960 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/add_shipping_info.php @@ -0,0 +1,34 @@ +fetchCapture($captureId); +$capture->addShippingInfo([ + "shipping_info" => [ + [ + "shipping_company" => "DHL", + "shipping_method" => "Home", + "tracking_uri" => "http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=1234567890", + "tracking_number" => "1234567890", + "return_tracking_number" => "E-55-KL", + "return_shipping_company" => "DHL", + "return_tracking_uri" => "http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=98389222" + ] + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/trigger_send_out.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/trigger_send_out.php new file mode 100644 index 00000000000..968d187bb88 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/trigger_send_out.php @@ -0,0 +1,22 @@ +fetchCapture($captureId); +$capture->triggerSendout(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/update_customer_details.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/update_customer_details.php new file mode 100644 index 00000000000..6cfe3348baf --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/capture/update_customer_details.php @@ -0,0 +1,27 @@ +fetchCapture($captureId); +$capture->updateCustomerDetails([ + "billing_address" => [ + "email" => "user@example.com", + "phone" => "57-3895734" + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout.php new file mode 100644 index 00000000000..f34b171ca83 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout.php @@ -0,0 +1,60 @@ +create([ + "purchase_country" => "gb", + "purchase_currency" => "gbp", + "locale" => "en-gb", + "order_amount" => 10000, + "order_tax_amount" => 2000, + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 10, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 6000, + "total_tax_amount" => 1200 + ], + [ + "type" => "physical", + "reference" => "543670", + "name" => "Bananas", + "quantity" => 1, + "quantity_unit" => "bag", + "unit_price" => 5000, + "tax_rate" => 2500, + "total_amount" => 4000, + "total_discount_amount" => 1000, + "total_tax_amount" => 800 + ] + ], + "merchant_urls" => [ + "terms" => "http://www.merchant.com/toc", + "checkout" => "http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}", + "confirmation" => "http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}", + "push" => "http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}" + ] +]); + +$checkout->fetch(); + +// Store checkout order id +$orderId = $checkout->getId(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout_attachment.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout_attachment.php new file mode 100644 index 00000000000..02997424058 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/create_checkout_attachment.php @@ -0,0 +1,79 @@ + [ + [ + "unique_account_identifier" => "Test Testperson", + "payment_option" => "card", + "number_paid_purchases" => 1, + "total_amount_paid_purchases" => 10000, + "date_of_last_paid_purchase" => (new DateTime())->format(EMD_FORMAT), + "date_of_first_paid_purchase" => (new DateTime())->format(EMD_FORMAT) + ] + ] +]; + +$checkout = new Klarna\Rest\Checkout\Order($connector); +$checkout->create([ + "purchase_country" => "gb", + "purchase_currency" => "gbp", + "locale" => "en-gb", + "order_amount" => 10000, + "order_tax_amount" => 2000, + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 10, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 6000, + "total_tax_amount" => 1200 + ], + [ + "type" => "physical", + "reference" => "543670", + "name" => "Bananas", + "quantity" => 1, + "quantity_unit" => "bag", + "unit_price" => 5000, + "tax_rate" => 2500, + "total_amount" => 4000, + "total_discount_amount" => 1000, + "total_tax_amount" => 800 + ] + ], + "merchant_urls" => [ + "terms" => "http://www.merchant.com/toc", + "checkout" => "http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}", + "confirmation" => "http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}", + "push" => "http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}" + ], + "attachment" => [ + "content_type" => "application/vnd.klarna.internal.emd-v2+json", + "body" => json_encode($emd) + ] +]); + +$checkout->fetch(); + +// Store checkout order id +$orderId = $checkout->getId(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/fetch_checkout.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/fetch_checkout.php new file mode 100644 index 00000000000..8e1df96cced --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/fetch_checkout.php @@ -0,0 +1,19 @@ +fetch(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/update_checkout.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/update_checkout.php new file mode 100644 index 00000000000..6d42d595d2e --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/checkout/update_checkout.php @@ -0,0 +1,56 @@ +update([ + "order_amount" => 11000, + "order_tax_amount" => 2200, + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 10, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 6000, + "total_tax_amount" => 1200 + ], + [ + "type" => "physical", + "reference" => "543670", + "name" => "Bananas", + "quantity" => 1, + "quantity_unit" => "bag", + "unit_price" => 5000, + "tax_rate" => 2500, + "total_amount" => 4000, + "total_discount_amount" => 1000, + "total_tax_amount" => 800 + ], + [ + "type" => "shipping_fee", + "name" => "Express delivery", + "quantity" => 1, + "unit_price" => 1000, + "tax_rate" => 2500, + "total_amount" => 1000, + "total_tax_amount" => 200 + ] + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/acknowledge_order.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/acknowledge_order.php new file mode 100644 index 00000000000..359f628efce --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/acknowledge_order.php @@ -0,0 +1,22 @@ +acknowledge(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/cancel_order.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/cancel_order.php new file mode 100644 index 00000000000..ebd49eb4c04 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/cancel_order.php @@ -0,0 +1,21 @@ +cancel(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/create_capture.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/create_capture.php new file mode 100644 index 00000000000..88f06f79abb --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/create_capture.php @@ -0,0 +1,49 @@ +createCapture([ + "captured_amount" => 6000, + "description" => "Shipped part of the order", + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 10, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 6000, + "total_tax_amount" => 1200 + ] + ], + "shipping_info" => [ + [ + "shipping_company" => "DHL", + "shipping_method" => "Home", + "tracking_uri" => "http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=1234567890", + "tracking_number" => "1234567890", + "return_tracking_number" => "E-55-KL", + "return_shipping_company" => "DHL", + "return_tracking_uri" => "http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=98389222" + ] + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/extend_authorization_time.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/extend_authorization_time.php new file mode 100644 index 00000000000..745d1beffb3 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/extend_authorization_time.php @@ -0,0 +1,19 @@ +extendAuthorizationTime(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_capture.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_capture.php new file mode 100644 index 00000000000..e0d0053826f --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_capture.php @@ -0,0 +1,21 @@ +fetchCapture($captureId); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_order.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_order.php new file mode 100644 index 00000000000..e333dacdcf1 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/fetch_order.php @@ -0,0 +1,19 @@ +fetch(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/refund_order.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/refund_order.php new file mode 100644 index 00000000000..aafb52f711d --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/refund_order.php @@ -0,0 +1,37 @@ +refund([ + "refunded_amount" => 3000, + "description" => "Refunding half the tomatoes", + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 5, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 3000, + "total_tax_amount" => 600 + ] + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/release_remaining_authorization.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/release_remaining_authorization.php new file mode 100644 index 00000000000..fc51926d715 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/release_remaining_authorization.php @@ -0,0 +1,21 @@ +releaseRemainingAuthorization(); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_customer_details.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_customer_details.php new file mode 100644 index 00000000000..aa29e179501 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_customer_details.php @@ -0,0 +1,30 @@ +updateCustomerDetails([ + "billing_address" => [ + "email" => "user@example.com", + "phone" => "57-3895734" + ], + "shipping_address" => [ + "email" => "user@example.com", + "phone" => "57-3895734" + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_merchant_references.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_merchant_references.php new file mode 100644 index 00000000000..5cd3bc395ef --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_merchant_references.php @@ -0,0 +1,25 @@ +updateMerchantReferences([ + "merchant_reference1" => "15632423", + "merchant_reference2" => "special order" +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_order_lines.php b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_order_lines.php new file mode 100644 index 00000000000..b90ef1154ff --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/docs/examples/order/update_order_lines.php @@ -0,0 +1,37 @@ +updateAuthorization([ + "order_amount" => 6000, + "description" => "Removed bad bananas", + "order_lines" => [ + [ + "type" => "physical", + "reference" => "123050", + "name" => "Tomatoes", + "quantity" => 10, + "quantity_unit" => "kg", + "unit_price" => 600, + "tax_rate" => 2500, + "total_amount" => 6000, + "total_tax_amount" => 1200 + ] + ] +]); diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/README.md b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/README.md new file mode 100644 index 00000000000..cb38f17063c --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/README.md @@ -0,0 +1,14 @@ +install +------- + + git remote add -f hooks ssh://git@stash.internal.machines:7999/mint/git-hooks.git + git merge -s ours --no-commit hooks/master + git read-tree --prefix=git_hooks -u hooks/master + git commit -m "imported git hooks" + + +updating +-------- + + git fetch hooks + git merge -s subtree hooks/master diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/coffeelint b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/coffeelint new file mode 100644 index 00000000000..e3084704324 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/coffeelint @@ -0,0 +1,103 @@ +{ + "arrow_spacing": { + "level": "ignore" + }, + "camel_case_classes": { + "level": "error" + }, + "coffeescript_error": { + "level": "error" + }, + "colon_assignment_spacing": { + "level": "ignore", + "spacing": { + "left": 0, + "right": 0 + } + }, + "cyclomatic_complexity": { + "value": 10, + "level": "ignore" + }, + "duplicate_key": { + "level": "error" + }, + "empty_constructor_needs_parens": { + "level": "ignore" + }, + "indentation": { + "value": 4, + "level": "error" + }, + "line_endings": { + "level": "ignore", + "value": "unix" + }, + "max_line_length": { + "value": 80, + "level": "error", + "limitComments": true + }, + "missing_fat_arrows": { + "level": "ignore" + }, + "newlines_after_classes": { + "value": 3, + "level": "ignore" + }, + "no_backticks": { + "level": "error" + }, + "no_debugger": { + "level": "warn" + }, + "no_empty_functions": { + "level": "ignore" + }, + "no_empty_param_list": { + "level": "ignore" + }, + "no_implicit_braces": { + "level": "ignore", + "strict": true + }, + "no_implicit_parens": { + "strict": true, + "level": "ignore" + }, + "no_interpolation_in_single_quotes": { + "level": "ignore" + }, + "no_plusplus": { + "level": "ignore" + }, + "no_stand_alone_at": { + "level": "ignore" + }, + "no_tabs": { + "level": "error" + }, + "no_throwing_strings": { + "level": "error" + }, + "no_trailing_semicolons": { + "level": "error" + }, + "no_trailing_whitespace": { + "level": "error", + "allowed_in_comments": false, + "allowed_in_empty_lines": true + }, + "no_unnecessary_double_quotes": { + "level": "ignore" + }, + "no_unnecessary_fat_arrows": { + "level": "warn" + }, + "non_empty_constructor_needs_parens": { + "level": "ignore" + }, + "space_operators": { + "level": "ignore" + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/message-format b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/message-format new file mode 100644 index 00000000000..c579f220292 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/message-format @@ -0,0 +1,34 @@ +#!/bin/bash +# http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html + +case "${1}" in + --about ) + echo "make sure commit message is within line width limits" + ;; + * ) + awk ' +/^#/ { + NR-- + next +} + +NR == 1 { + if (length > 50) { + print "title too long" + exit 1 + } +} + +NR == 2 { + if (length != 0) { + print "2nd line should be empty" + exit 2 + } +} + +{ + if (length > 72) { + print "line ", FNR, " is too long"; + } +}' "${1}" +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/ticket-number b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/ticket-number new file mode 100644 index 00000000000..a312756ef14 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/commit-msg/ticket-number @@ -0,0 +1,30 @@ +#!/bin/bash + +function run_test +{ + if ! grep -qvE '^#.*|^$' $1 ; then + exit 0 + fi + + ticket=$(git symbolic-ref HEAD | grep -oP "([A-Z]+)-([0-9]+)") + + if [ -z $ticket ]; then + exit 0 + fi + + if grep -q "^$ticket" $1; then + exit 0 + fi + + echo >> $1 + echo $ticket >> $1 +} + +case "${1}" in + --about ) + echo "Append ticket number to commit message" + ;; + * ) + run_test "$@" + ;; +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/jshint b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/jshint new file mode 100644 index 00000000000..da2bb59cf80 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/jshint @@ -0,0 +1,69 @@ +{ + // ENFORCE + "curly" : true, // Require {} around one-line blocks + "eqeqeq" : true, // Require === + "forin" : true, // Require hasOwnProperty inside forins + "immed" : false, // Require immediate invocations to be wrapped in parenthesis + // eg. (fun(){}()) + "latedef" : true, // Prohibit undefined variables (undef?!) + "newcap" : true, // Require capitalized constructors + "noarg" : true, // Prohibit arguments.callee and .caller + "noempty" : false, // Prohibit empty blocks "{}" + "nonew" : false, // Prohibit new + "plusplus" : false, // Prohibit ++ and -- + "regexp" : false, // Prohibit . in RegExp + "strict" : true, // Require 'use strict' + "trailing" : true, // Prohibit trailing spaces + "undef" : true, // Prohibit undeclared variables + "unused" : "vars",// Prohibit unused variables + + // RELAX + "asi" : false, // Allow missing semicolons due to automatic insertion + "bitwise" : false, // Allow bitwise operators + "boss" : false, // Allow advanced usage of assignments + "debug" : false, // Allow debugger statements + "eqnull" : false, // Allow "== null" + "esnext" : false, // Allow ES.next statements + "evil" : false, // Allow eval + "expr" : false, // Allow expressions instead of assignments/function calls + "funcscope" : false, // Allow vars declared in blocks (ie. if) + "globalstrict" : false, // Allow global 'use strict' + "iterator" : false, // Allow __iterator__ + "lastsemic" : false, // Allow one-line blocks with no semicolon + "laxbreak" : false, // Allow unsafe line breaks + "loopfunc" : false, // Allow function creation inside loops + "multistr" : false, // Allow multiline strings + "nonstandard" : false, // Allow (un)escape + "onecase" : false, // Allow one-case switch statements (=if) + "proto" : false, // Allow __proto__ + "regexdash" : false, // Allow RegExp to finish with a dash + "scripturl" : false, // Allow script-targeted URLs + "shadow" : false, // Allow variable shadowing (redeclaring in new scope) + "sub" : false, // Allow object['name'], not just object.name + "supernew" : false, // Allow "new function(){}" and "new Object" + "validthis" : false, // Allow this even inside a non-constructor + + // LEGACY + "nomen" : false, // Enforce no dangling underscores + "onevar" : true, // Enforce one var per function scope + "passfail" : false, // Stop on first error + "white" : false, // Strict Douglas' whitespace rules + + // MISC + "indent" : 4, // Check that indentation is X spaces + "maxlen" : 100, // Maximum characters/line + + // ENVIRONMENT (GLOBALS) + "browser" : true, // Browser (setTimeout, document,..) + "couch" : false, // CouchDB + "devel" : false, // Development (console, alert,..) + "dojo" : false, + "jquery" : false, + "mootools" : false, + "node" : false, + "mocha" : true, + "prototypejs" : false, + "rhino" : false, + "wsh" : false // Window Scripting Host +} + diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-coffee b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-coffee new file mode 100644 index 00000000000..aa25de50cfd --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-coffee @@ -0,0 +1,59 @@ +#!/bin/bash + +coffeelint_alt="node_modules/.bin/coffeelint coffeelint" + +for c in 'coffeelint.json' "`dirname $0`/../coffeelint"; do + if [ -e "$c" ]; then + config="$c" + fi +done + +function run_coffeelint { + if [ -n "$config" ]; then + $coffeelint -f "${config}" ${@} + else + $coffeelint ${@} + fi +} + +function changed_files { + git diff --cached --name-only --diff-filter=ACM +} + +function write_staged { + while read file; do + name=`echo "$file" | sed 's:/:-:g'` + tmpfile=`mktemp /tmp/XXXXX-${name}` + git show ":$file" > $tmpfile + echo "$tmpfile" + done +} + +case "${1}" in + --about ) + if [ -z "$config" ]; then + config='default config' + fi + echo "Perform static analysis of coffee-script files (${config})" + ;; + * ) + coffeelint=`which $jshint_alt 2>/dev/null | head -n 1` + + # call out to tools + files=`changed_files | grep -e '\.coffee$' | write_staged` + + if [ -z "$files" ]; then + exit 0 + fi + + if test -z "$coffeelint"; then + echo "Please install coffeelint: npm install -g coffeelint" + exit 0 + fi + + run_coffeelint $files + status=$? + rm $files + exit $status + ;; +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-js b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-js new file mode 100644 index 00000000000..3b8ce7ef520 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-js @@ -0,0 +1,59 @@ +#!/bin/bash + +jshint_alt="node_modules/.bin/jshint jshint" + +for c in '.jshintrc' "`dirname $0`/../jshint"; do + if [ -e "$c" ]; then + config="$c" + fi +done + +function run_jshint { + if [ -n "$config" ]; then + $jshint --config "${config}" ${@} + else + $jshint ${@} + fi +} + +function changed_files { + git diff --cached --name-only --diff-filter=ACM +} + +function write_staged { + while read file; do + name=`basename $file` + tmpfile=`mktemp /tmp/XXXXX-${name}` + git show ":$file" > $tmpfile + echo "$tmpfile" + done +} + +case "${1}" in + --about ) + if [ -z "$config" ]; then + config='default config' + fi + echo "Perform static analysis of js source files (${config})" + ;; + * ) + jshint=`which $jshint_alt 2>/dev/null | head -n 1` + + # call out to tools + files=`changed_files | grep -e '\.js$' | write_staged` + + if [ -z "$files" ]; then + exit 0 + fi + + if test -z "$jshint"; then + echo "Please install jshint: npm install -g jshint" + exit 0 + fi + + run_jshint $files + status=$? + rm $files + exit $status + ;; +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-php b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-php new file mode 100644 index 00000000000..8f591edc158 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-php @@ -0,0 +1,65 @@ +#!/bin/bash + +phpcs_alt="vendor/bin/phpcs bin/phpcs ~/.composer/vendor/bin/phpcs phpcs" +phpmd_alt="vendor/bin/phpmd bin/phpmd ~/.composer/vendor/bin/phpmd phpmd" + +phpcs_standard='PSR2' +if [ -e "phpcs.xml" ]; then + phpcs_standard="./phpcs.xml" +fi + +phpmd_output=text +phpmd_rules='phpmd.xml' +if [ ! -e "$phpmd_rules" ]; then + phpmd_rules='codesize,design,naming,unusedcode' +fi + +function run_phpcs { + $phpcs --report-emacs --standard="$phpcs_standard" ${@} +} + +function run_phpmd { + $phpmd "`echo $1 | tr ' ' ','`" "$phpmd_output" "$phpmd_rules" +} + +function changed_files { + git diff --cached --name-only --diff-filter=ACM +} + +function write_staged { + while read file; do + name=`basename $file` + tmpfile=`mktemp /tmp/XXXXX-${name}` + git show ":$file" > $tmpfile + echo "$tmpfile" + done +} + +case "${1}" in + --about ) + echo "Perform static analysis of php source files" + ;; + * ) + phpcs=`which $phpcs_alt 2>/dev/null | head -n 1` + phpmd=`which $phpmd_alt 2>/dev/null | head -n 1` + + # call out to tools + files=`changed_files | grep -e '\.php$' | write_staged` + if [ -z "$files" ]; then + exit 0 + fi + + if test -z "$phpcs" -o -z "$phpmd"; then + echo "Please install phpcs and phpmd: composer global require squizlabs/php_codesniffer phpmd/phpmd" + exit 0 + fi + + run_phpcs $files + phpcs_status=$? + run_phpmd $files + phpmd_status=$? + rm $files + test "$phpcs_status" -eq 0 -a "$phpmd_status" -eq 0 + exit $? + ;; +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-python b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-python new file mode 100644 index 00000000000..aa935679d2c --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/git_hooks/pre-commit/check-python @@ -0,0 +1,48 @@ +#!/bin/bash + +function run_pep8 { + pep8 ${@} +} + +function run_pyflakes { + pyflakes ${@} +} + +function changed_files { + git diff --cached --name-only --diff-filter=ACM +} + +function write_staged { + while read file; do + name=`basename $file` + tmpfile=`mktemp /tmp/XXXXX-${name}` + git show ":$file" > $tmpfile + echo "$tmpfile" + done +} + +case "${1}" in + --about ) + echo "Perform static analysis of python source files" + ;; + * ) + # call out to tools + files=`changed_files | grep -e '\.py$' | write_staged` + if [ -z "$files" ]; then + exit 0 + fi + + if ! which pep8 pyflakes > /dev/null; then + echo "Please install pep8 and pyflakes: pip install pep8 pyflakes" + exit 0 + fi + + run_pep8 $files + pep8_status=$? + run_pyflakes $files + pyflakes_status=$? + rm $files + test "$pep8_status" -eq 0 -a "$pyflakes_status" -eq 0 + exit $? + ;; +esac diff --git a/upload/system/storage/vendor/klarna/kco_rest/phpmd.xml b/upload/system/storage/vendor/klarna/kco_rest/phpmd.xml new file mode 100644 index 00000000000..2348e784325 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/phpmd.xml @@ -0,0 +1,32 @@ + + + Klarna PHPMD ruleset + + + + + + + + + 1 + + + + + + + + + + + + + + + diff --git a/upload/system/storage/vendor/klarna/kco_rest/phpunit.xml.dist b/upload/system/storage/vendor/klarna/kco_rest/phpunit.xml.dist new file mode 100644 index 00000000000..133de98b9af --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/phpunit.xml.dist @@ -0,0 +1,40 @@ + + + + + + + tests/Unit + + + + tests/Component + + + + + + src/ + + + + + + + + + diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Checkout/Order.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Checkout/Order.php new file mode 100644 index 00000000000..798f30967d2 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Checkout/Order.php @@ -0,0 +1,112 @@ +setLocation(self::$path . "/{$orderId}"); + $this[static::ID_FIELD] = $orderId; + } + } + + /** + * Creates the resource. + * + * @param array $data Creation data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the location header is missing + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function create(array $data) + { + $url = $this->post(self::$path, $data) + ->status('201') + ->getLocation(); + + $this->setLocation($url); + + return $this; + } + + /** + * Updates the resource. + * + * @param array $data Update data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException On an unexpected API response + * @throws \RuntimeException If the response content type is not JSON + * @throws \InvalidArgumentException If the JSON cannot be parsed + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function update(array $data) + { + $data = $this->post($this->getLocation(), $data) + ->status('200') + ->contentType('application/json') + ->getJson(); + + $this->exchangeArray($data); + + return $this; + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Capture.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Capture.php new file mode 100644 index 00000000000..6f1a85b618e --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Capture.php @@ -0,0 +1,149 @@ +setLocation($url); + } + + /** + * Creates the resource. + * + * @param array $data Creation data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the location header is missing + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function create(array $data) + { + $url = $this->post($this->getLocation(), $data) + ->status('201') + ->getLocation(); + + $this->setLocation($url); + + return $this; + } + + /** + * Appends shipping information to the capture. + * + * @param array $data Shipping info data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function addShippingInfo(array $data) + { + $this->post($this->getLocation() . '/shipping-info', $data) + ->status('204'); + + return $this; + } + + /** + * Updates the customers details. + * + * @param array $data Customer details data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function updateCustomerDetails(array $data) + { + $this->patch($this->getLocation() . '/customer-details', $data) + ->status('204'); + + return $this; + } + + /** + * Trigger send outs for this capture. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function triggerSendout() + { + $this->post($this->getLocation() . '/trigger-send-out') + ->status('204'); + + return $this; + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Order.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Order.php new file mode 100644 index 00000000000..a13dfcb67d2 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/OrderManagement/Order.php @@ -0,0 +1,317 @@ +setLocation(self::$path . "/{$orderId}"); + $this[static::ID_FIELD] = $orderId; + } + + /** + * Fetches the order. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException On an unexpected API response + * @throws \RuntimeException If the response content type is not JSON + * @throws \InvalidArgumentException If the JSON cannot be parsed + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function fetch() + { + parent::fetch(); + + // Convert captures data to Capture[] + + $captures = []; + foreach ($this['captures'] as $capture) { + $captureId = $capture[Capture::ID_FIELD]; + + $object = new Capture( + $this->connector, + $this->getLocation(), + $captureId + ); + $object->exchangeArray($capture); + + $captures[] = $object; + } + + $this['captures'] = $captures; + + return $this; + } + + /** + * Acknowledges the order. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function acknowledge() + { + $this->post($this->getLocation() . '/acknowledge') + ->status('204'); + + return $this; + } + + /** + * Cancels this order. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function cancel() + { + $this->post($this->getLocation() . '/cancel') + ->status('204'); + + return $this; + } + + /** + * Updates the authorization data. + * + * @param array $data Authorization data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function updateAuthorization(array $data) + { + $this->patch($this->getLocation() . '/authorization', $data) + ->status('204'); + + return $this; + } + + /** + * Extends the authorization time. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function extendAuthorizationTime() + { + $this->post($this->getLocation() . '/extend-authorization-time') + ->status('204'); + + return $this; + } + + /** + * Update the merchant references. + * + * @param array $data Merchant references + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function updateMerchantReferences(array $data) + { + $this->patch($this->getLocation() . '/merchant-references', $data) + ->status('204'); + + return $this; + } + + /** + * Updates the customer details. + * + * @param array $data Customer data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function updateCustomerDetails(array $data) + { + $this->patch($this->getLocation() . '/customer-details', $data) + ->status('204'); + + return $this; + } + + /** + * Refunds an amount of a captured order. + * + * @param array $data Refund data + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function refund(array $data) + { + $this->post($this->getLocation() . '/refunds', $data) + ->status(['201', '204']); + + return $this; + } + + /** + * Release the remaining authorization for an order. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function releaseRemainingAuthorization() + { + $this->post($this->getLocation() . '/release-remaining-authorization') + ->status('204'); + + return $this; + } + + /** + * Capture all or part of an order. + * + * @param array $data Capture data + * + * @see Capture::create() For more information on how to create a capture + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException If the location header is missing + * @throws \RuntimeException If the API replies with an unexpected response + * @throws \LogicException When Guzzle cannot populate the response + * + * @return Capture + */ + public function createCapture(array $data) + { + $capture = new Capture($this->connector, $this->getLocation()); + + $capture->create($data); + + $this['captures'][] = $capture; + + return $capture; + } + + /** + * Fetches the specified capture. + * + * @param string $captureId Capture ID + * + * @see Capture::fetch() For more information on how to fetch a capture + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException On an unexpected API response + * @throws \RuntimeException If the response content type is not JSON + * @throws \InvalidArgumentException If the JSON cannot be parsed + * @throws \LogicException When Guzzle cannot populate the response + * + * @return Capture + */ + public function fetchCapture($captureId) + { + if ($this->offsetExists('captures')) { + foreach ($this['captures'] as $capture) { + if ($capture->getId() !== $captureId) { + continue; + } + + return $capture->fetch(); + } + } + + $capture = new Capture($this->connector, $this->getLocation(), $captureId); + $capture->fetch(); + + $this['captures'][] = $capture; + + return $capture; + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Resource.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Resource.php new file mode 100644 index 00000000000..f1f96cebbae --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Resource.php @@ -0,0 +1,200 @@ +connector = $connector; + } + + /** + * Gets the resource id. + * + * @return string|null + */ + public function getId() + { + return isset($this[static::ID_FIELD]) ? $this[static::ID_FIELD] : null; + } + + /** + * Gets the resource location. + * + * @return string|null + */ + public function getLocation() + { + return $this->url; + } + + /** + * Sets the resource location. + * + * @param string $url Url to the resource + * + * @return self + */ + public function setLocation($url) + { + $this->url = $url; + + return $this; + } + + /** + * Fetches the resource. + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \RuntimeException On an unexpected API response + * @throws \RuntimeException If the response content type is not JSON + * @throws \InvalidArgumentException If the JSON cannot be parsed + * @throws \LogicException When Guzzle cannot populate the response + * + * @return self + */ + public function fetch() + { + $data = $this->get($this->getLocation()) + ->status('200') + ->contentType('application/json') + ->getJson(); + + $this->exchangeArray($data); + + return $this; + } + + /** + * Sends a HTTP request to the specified url. + * + * @param string $method HTTP method, e.g. 'GET' + * @param string $url Request destination + * @param array $options Request options + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \LogicException When Guzzle cannot populate the response + * + * @return ResponseValidator + */ + protected function request($method, $url, array $options = []) + { + $request = $this->connector->createRequest($url, $method, $options); + + return new ResponseValidator($this->connector->send($request)); + } + + /** + * Sends a HTTP GET request to the specified url. + * + * @param string $url Request destination + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \LogicException When Guzzle cannot populate the response + * + * @return ResponseValidator + */ + protected function get($url) + { + return $this->request('GET', $url); + } + + /** + * Sends a HTTP PATCH request to the specified url. + * + * @param string $url Request destination + * @param array $data Data to be JSON encoded + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \LogicException When Guzzle cannot populate the response + * + * @return ResponseValidator + */ + protected function patch($url, array $data) + { + return $this->request('PATCH', $url, ['json' => $data]); + } + + /** + * Sends a HTTP POST request to the specified url. + * + * @param string $url Request destination + * @param array $data Data to be JSON encoded + * + * @throws ConnectorException When the API replies with an error response + * @throws RequestException When an error is encountered + * @throws \LogicException When Guzzle cannot populate the response + * + * @return ResponseValidator + */ + protected function post($url, array $data = null) + { + $options = []; + if ($data !== null) { + $options['json'] = $data; + } + + return $this->request('POST', $url, $options); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/Connector.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/Connector.php new file mode 100644 index 00000000000..8a7ebd442d5 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/Connector.php @@ -0,0 +1,186 @@ + 'https://api.klarna.com']); + * $connector = new \Klarna\Transport\Connector($client, '0', 'sharedSecret'); + * + * + * @param ClientInterface $client HTTP transport client + * @param string $merchantId Merchant ID + * @param string $sharedSecret Shared secret + * @param UserAgentInterface $userAgent HTTP user agent to identify the client + */ + public function __construct( + ClientInterface $client, + $merchantId, + $sharedSecret, + UserAgentInterface $userAgent = null + ) { + $this->client = $client; + $this->merchantId = $merchantId; + $this->sharedSecret = $sharedSecret; + + if ($userAgent === null) { + $userAgent = UserAgent::createDefault(); + } + $this->userAgent = $userAgent; + } + + /** + * Creates a request object. + * + * @param string $url URL + * @param string $method HTTP method + * @param array $options Request options + * + * @return RequestInterface + */ + public function createRequest($url, $method = 'GET', array $options = []) + { + $options['auth'] = [$this->merchantId, $this->sharedSecret]; + $options['headers']['User-Agent'] = strval($this->userAgent); + + return $this->client->createRequest($method, $url, $options); + } + + /** + * Sends the request. + * + * @param RequestInterface $request Request to send + * + * @throws ConnectorException If the API returned an error response + * @throws RequestException When an error is encountered + * @throws \LogicException When the adapter does not populate a response + * + * @return ResponseInterface + */ + public function send(RequestInterface $request) + { + try { + return $this->client->send($request); + } catch (RequestException $e) { + if (!$e->hasResponse()) { + throw $e; + } + + $response = $e->getResponse(); + + if ($response->getHeader('Content-Type') !== 'application/json') { + throw $e; + } + + $data = $response->json(); + + if (!is_array($data) || !array_key_exists('error_code', $data)) { + throw $e; + } + + throw new ConnectorException($data, $e); + } + } + + /** + * Gets the HTTP transport client. + * + * @return ClientInterface + */ + public function getClient() + { + return $this->client; + } + + /** + * Gets the user agent. + * + * @return UserAgentInterface + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Factory method to create a connector instance. + * + * @param string $merchantId Merchant ID + * @param string $sharedSecret Shared secret + * @param string $baseUrl Base URL for HTTP requests + * @param UserAgentInterface $userAgent HTTP user agent to identify the client + * + * @return self + */ + public static function create( + $merchantId, + $sharedSecret, + $baseUrl = self::EU_BASE_URL, + UserAgentInterface $userAgent = null + ) { + $client = new Client(['base_url' => $baseUrl]); + + return new static($client, $merchantId, $sharedSecret, $userAgent); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ConnectorInterface.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ConnectorInterface.php new file mode 100644 index 00000000000..4c625fd685f --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ConnectorInterface.php @@ -0,0 +1,94 @@ +getCode(), $prev); + + $this->errorCode = $data['error_code']; + $this->messages = $data['error_messages']; + $this->correlationId = $data['correlation_id']; + } + + /** + * Gets the API error code for this exception. + * + * @return string + */ + public function getErrorCode() + { + return $this->errorCode; + } + + /** + * Gets the API error messages for this exception. + * + * @return array + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Gets the API correlation ID for this exception. + * + * @return string + */ + public function getCorrelationId() + { + return $this->correlationId; + } + + /** + * Gets the HTTP response for this API error. + * + * @return ResponseInterface + */ + public function getResponse() + { + return $this->getPrevious()->getResponse(); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ResponseValidator.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ResponseValidator.php new file mode 100644 index 00000000000..f318a1a5f56 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/ResponseValidator.php @@ -0,0 +1,137 @@ +response = $response; + } + + /** + * Gets the response object. + * + * @return ResponseInterface + */ + public function getResponse() + { + return $this->response; + } + + /** + * Asserts the HTTP response status code. + * + * @param string|string[] $status Expected status code(s) + * + * @throws \RuntimeException If status code does not match + * + * @return self + */ + public function status($status) + { + $httpStatus = (string) $this->response->getStatusCode(); + if (is_array($status) && !in_array($httpStatus, $status)) { + throw new \RuntimeException( + "Unexpected response status code: {$httpStatus}" + ); + } + + if (is_string($status) && $httpStatus !== $status) { + throw new \RuntimeException( + "Unexpected response status code: {$httpStatus}" + ); + } + + return $this; + } + + /** + * Asserts the Content-Type header. + * + * @param string $mediaType Expected media type + * + * @throws \RuntimeException If Content-Type header is missing + * @throws \RuntimeException If Content-Type header does not match + * + * @return self + */ + public function contentType($mediaType) + { + if (!$this->response->hasHeader('Content-Type')) { + throw new \RuntimeException('Response is missing a Content-Type header'); + } + + $contentType = $this->response->getHeader('Content-Type'); + if ($contentType !== $mediaType) { + throw new \RuntimeException( + "Unexpected Content-Type header received: {$contentType}" + ); + } + + return $this; + } + + /** + * Get the decoded JSON response. + * + * @throws \RuntimeException If the response body is not in JSON format + * @throws \InvalidArgumentException If the JSON cannot be parsed + * + * @return array + */ + public function getJson() + { + return $this->response->json(); + } + + /** + * Gets the Location header. + * + * @throws \RuntimeException If the Location header is missing + * + * @return string + */ + public function getLocation() + { + if (!$this->response->hasHeader('Location')) { + throw new \RuntimeException('Response is missing a Location header'); + } + + return $this->response->getHeader('Location'); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgent.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgent.php new file mode 100644 index 00000000000..2a1d30ee5aa --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgent.php @@ -0,0 +1,130 @@ +fields = []; + } + + /** + * Sets the specified field. + * + * @param string $key Component key, e.g. 'Language' + * @param string $name Component name, e.g. 'PHP' + * @param string $version Version identifier, e.g. '5.4.10' + * @param array $options Additional information + * + * @return self + */ + public function setField($key, $name, $version = '', array $options = []) + { + $field = [ + 'name' => $name + ]; + + if (!empty($version)) { + $field['version'] = $version; + } + + if (!empty($options)) { + $field['options'] = $options; + } + + $this->fields[$key] = $field; + + return $this; + } + + /** + * Serialises the user agent. + * + * @return string + */ + public function __toString() + { + $parts = []; + + foreach ($this->fields as $key => $value) { + $component = "{$key}/{$value['name']}"; + if (!empty($value['version'])) { + $component .= "_{$value['version']}"; + } + + $parts[] = $component; + + if (empty($value['options'])) { + continue; + } + + $opts = implode('; ', $value['options']); + $parts[] = "({$opts})"; + } + + return implode(' ', $parts); + } + + /** + * Creates the default user agent. + * + * @return self + */ + public static function createDefault() + { + $agent = new static(); + + $options = ['Guzzle/' . ClientInterface::VERSION]; + if (extension_loaded('curl')) { + $options[] = 'curl/' . curl_version()['version']; + } + + return $agent + ->setField('Library', static::NAME, static::VERSION, $options) + ->setField('OS', php_uname('s'), php_uname('r')) + ->setField('Language', 'PHP', phpversion()); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgentInterface.php b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgentInterface.php new file mode 100644 index 00000000000..7707d00f698 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/src/Klarna/Rest/Transport/UserAgentInterface.php @@ -0,0 +1,117 @@ +mock->addResponse( + new Response(201, ['Location' => 'http://somewhere/a-path']) + ); + + $order = new Order($this->connector); + $location = $order->create(['data' => 'goes here']) + ->getLocation(); + + $this->assertEquals('http://somewhere/a-path', $location); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals('/checkout/v3/orders', $request->getPath()); + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"goes here"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct and that the updated data + * is accessible. + * + * @return void + */ + public function testUpdate() + { + $json = <<mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0001'); + $order['updated'] = 'not from json'; + + $order->update(['data' => 'sent in']); + + $this->assertEquals('from json', $order['updated']); + $this->assertEquals('0001', $order->getId()); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals('/checkout/v3/orders/0001', $request->getPath()); + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent and retrieved data is correct. + * + * @return void + */ + public function testFetch() + { + $json = <<mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0002'); + $order['updated'] = 'not from json'; + + $order->fetch(); + + $this->assertEquals('from json', $order['updated']); + $this->assertEquals('0002', $order->getId()); + + $request = $this->history->getLastRequest(); + $this->assertEquals('GET', $request->getMethod()); + $this->assertEquals('/checkout/v3/orders/0002', $request->getPath()); + + $this->assertAuthorization($request); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/CaptureTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/CaptureTest.php new file mode 100644 index 00000000000..7b38d836e08 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/CaptureTest.php @@ -0,0 +1,168 @@ +mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $capture = new Capture($this->connector, '/path', '1002'); + $capture['updated'] = 'not from json'; + + $capture->fetch(); + + $this->assertEquals('from json', $capture['updated']); + $this->assertEquals('1002', $capture->getId()); + + $request = $this->history->getLastRequest(); + $this->assertEquals('GET', $request->getMethod()); + $this->assertEquals('/path/captures/1002', $request->getPath()); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct and that the location is updated + * when creating the capture. + * + * @return void + */ + public function testCreate() + { + $this->mock->addResponse( + new Response(201, ['Location' => 'http://somewhere/a-path']) + ); + + $capture = new Capture($this->connector, '/path/to/order'); + $location = $capture->create(['data' => 'goes here']) + ->getLocation(); + + $this->assertEquals('http://somewhere/a-path', $location); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals('/path/to/order/captures', $request->getPath()); + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"goes here"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when appending shipping info. + * + * @return void + */ + public function testAddShippingInfo() + { + $this->mock->addResponse(new Response(204)); + + $capture = new Capture($this->connector, '/order/0002', '1002'); + $capture->addShippingInfo(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/order/0002/captures/1002/shipping-info', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when updating customer details. + * + * @return void + */ + public function testUpdateCustomerDetails() + { + $this->mock->addResponse(new Response(204)); + + $capture = new Capture($this->connector, '/order/0002', '1002'); + $capture->updateCustomerDetails(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('PATCH', $request->getMethod()); + $this->assertEquals( + '/order/0002/captures/1002/customer-details', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when triggering a send-out. + * + * @return void + */ + public function testTriggerSendout() + { + $this->mock->addResponse(new Response(204)); + + $capture = new Capture($this->connector, '/order/0002', '1002'); + $capture->triggerSendout(); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/order/0002/captures/1002/trigger-send-out', + $request->getPath() + ); + + $this->assertAuthorization($request); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/OrderTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/OrderTest.php new file mode 100644 index 00000000000..711d8d897c3 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/OrderManagement/OrderTest.php @@ -0,0 +1,451 @@ +mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0002'); + $order['updated'] = 'not from json'; + + $order->fetch(); + + $this->assertEquals('from json', $order['updated']); + $this->assertEquals('0002', $order->getId()); + + $request = $this->history->getLastRequest(); + $this->assertEquals('GET', $request->getMethod()); + $this->assertEquals('/ordermanagement/v1/orders/0002', $request->getPath()); + + $this->assertAuthorization($request); + + $capture = $order['captures'][0]; + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals($capture->getId(), $capture['capture_id']); + $this->assertEquals('1002', $capture->getId()); + $this->assertEquals('data', $capture['test']); + } + + /** + * Make sure that the request sent is correct when acknowledging an order. + * + * @return void + */ + public function testAcknowledge() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->acknowledge(); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/acknowledge', + $request->getPath() + ); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when cancelling an order. + * + * @return void + */ + public function testCancel() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->cancel(); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/cancel', + $request->getPath() + ); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when extending authorization time. + * + * @return void + */ + public function testExtendAuthorizationTime() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->extendAuthorizationTime(); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/extend-authorization-time', + $request->getPath() + ); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when releasing remaining + * authorization. + * + * @return void + */ + public function testReleaseRemainingAuthorization() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->releaseRemainingAuthorization(); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/release-remaining-authorization', + $request->getPath() + ); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when updating authorization. + * + * @return void + */ + public function testUpdateAuthorization() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->updateAuthorization(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('PATCH', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/authorization', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when updating merchant references. + * + * @return void + */ + public function testUpdateMerchantReferences() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->updateMerchantReferences(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('PATCH', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/merchant-references', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when updating customer details. + * + * @return void + */ + public function testUpdateCustomerDetails() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->updateCustomerDetails(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('PATCH', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/customer-details', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when performing a refund. + * + * @return void + */ + public function testRefund() + { + $this->mock->addResponse(new Response(204)); + + $order = new Order($this->connector, '0002'); + $order->refund(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/refunds', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct when performing a refund. + * + * @return void + */ + public function testRefund201() + { + $this->mock->addResponse(new Response(201)); + + $order = new Order($this->connector, '0002'); + $order->refund(['data' => 'sent in']); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/refunds', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent is correct and that the location is updated + * when creating an order. + * + * @return void + */ + public function testCreateCapture() + { + $this->mock->addResponse( + new Response(201, ['Location' => 'http://somewhere/a-path']) + ); + + $order = new Order($this->connector, '0002'); + $capture = $order->createCapture(['data' => 'goes here']); + + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals('http://somewhere/a-path', $capture->getLocation()); + + $request = $this->history->getLastRequest(); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/captures', + $request->getPath() + ); + + $this->assertEquals('application/json', $request->getHeader('Content-Type')); + $this->assertEquals('{"data":"goes here"}', strval($request->getBody())); + + $this->assertAuthorization($request); + } + + /** + * Make sure that the request sent and retrieved data is correct when fetching + * a capture. + * + * @return void + */ + public function testFetchCapture() + { + $json = <<mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0002'); + + $capture = $order->fetchCapture('1002'); + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/captures/1002', + $capture->getLocation() + ); + + $this->assertEquals('from json', $capture['updated']); + $this->assertEquals('1002', $capture->getId()); + $this->assertEquals($capture->getId(), $capture['capture_id']); + } + + /** + * Make sure that the request sent and retrieved data is correct when fetching + * a capture that exists in the captures list. + * + * @return void + */ + public function testFetchCaptureExisting() + { + $json = <<mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0002'); + + $capture = new Capture($this->connector, $order->getLocation(), '1002'); + $capture['capture_id'] = '1002'; + $capture['updated'] = 'not from json'; + + $order['captures'][] = $capture; + + $capture = $order->fetchCapture('1002'); + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/captures/1002', + $capture->getLocation() + ); + + $this->assertEquals('from json', $capture['updated']); + $this->assertEquals('1002', $capture->getId()); + $this->assertEquals($capture->getId(), $capture['capture_id']); + } + + /** + * Make sure that the request sent and retrieved data is correct when fetching + * a capture that is not already in the captures list. + * + * @return void + */ + public function testFetchCaptureNew() + { + $json = <<mock->addResponse( + new Response( + 200, + ['Content-Type' => 'application/json'], + Stream::factory($json) + ) + ); + + $order = new Order($this->connector, '0002'); + + $capture = new Capture($this->connector, $order->getLocation(), '1002'); + $capture['capture_id'] = '1002'; + $capture['updated'] = 'not from json'; + + $order['captures'][] = $capture; + + $capture = $order->fetchCapture('1003'); + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals( + '/ordermanagement/v1/orders/0002/captures/1003', + $capture->getLocation() + ); + + $this->assertEquals('from json', $capture['updated']); + $this->assertEquals('1003', $capture->getId()); + $this->assertEquals($capture->getId(), $capture['capture_id']); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Component/ResourceTestCase.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/ResourceTestCase.php new file mode 100644 index 00000000000..eb0b1ae711e --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/ResourceTestCase.php @@ -0,0 +1,45 @@ +getHeader('Authorization')); + + $this->assertEquals('Basic', $alg); + + $expected = self::MERCHANT_ID . ':' . self::SHARED_SECRET; + $this->assertEquals($expected, base64_decode($digest)); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Component/TestCase.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/TestCase.php new file mode 100644 index 00000000000..06c5151deb6 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/TestCase.php @@ -0,0 +1,80 @@ +client = new Client(); + $this->mock = new Mock(); + $this->history = new History(); + + // Add the mock subscriber to the client. + $this->client->getEmitter()->attach($this->mock); + $this->client->getEmitter()->attach($this->history); + + $this->connector = new Connector( + $this->client, + self::MERCHANT_ID, + self::SHARED_SECRET + ); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Component/Transport/ConnectorTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/Transport/ConnectorTest.php new file mode 100644 index 00000000000..7dbe72e9167 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Component/Transport/ConnectorTest.php @@ -0,0 +1,144 @@ +connector->createRequest( + 'https://localhost:8888/path-here', + 'POST', + ['query' => ['q' => '1']] + ); + + $this->assertInstanceOf('GuzzleHttp\Message\RequestInterface', $request); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals( + 'https://localhost:8888/path-here?q=1', + $request->getUrl() + ); + + $this->assertEquals(self::MERCHANT_ID, $request->getConfig()['auth'][0]); + $this->assertEquals(self::SHARED_SECRET, $request->getConfig()['auth'][1]); + + $this->assertEquals( + strval($this->connector->getUserAgent()), + $request->getHeader('User-Agent') + ); + } + + /** + * Make sure that the request sent returns an response. + * + * @return void + */ + public function testSend() + { + $response = new Response(200); + $this->mock->addResponse($response); + + $request = $this->connector->createRequest('http://somewhere/path', 'POST'); + $this->assertSame($response, $this->connector->send($request)); + } + + /** + * Make sure that an API error response throws a connector exception. + * + * @return void + */ + public function testSendError() + { + $json = << 'application/json'], + Stream::factory($json) + ); + $this->mock->addResponse($response); + + $this->setExpectedException( + 'Klarna\Rest\Transport\Exception\ConnectorException', + 'ERR_1: msg1, msg2 (#cid_1)' + ); + + $request = $this->connector->createRequest('http://somewhere/path', 'POST'); + $this->connector->send($request); + } + + /** + * Make sure that an error response throws an exception. + * + * @return void + */ + public function testSendGuzzleError() + { + $response = new Response(404); + $this->mock->addResponse($response); + + $this->setExpectedException('GuzzleHttp\Exception\ClientException'); + + $request = $this->connector->createRequest('http://somewhere/path', 'POST'); + $this->connector->send($request); + } + + /** + * Make sure that the factory method creates a connector as expected. + * + * @return void + */ + public function testCreate() + { + $userAgent = $this->getMockBuilder('Klarna\Rest\Transport\UserAgent') + ->getMock(); + + $connector = Connector::create( + self::MERCHANT_ID, + self::SHARED_SECRET, + self::BASE_URL, + $userAgent + ); + + $this->assertSame($userAgent, $connector->getUserAgent()); + $this->assertEquals(self::BASE_URL, $connector->getClient()->getBaseUrl()); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Checkout/OrderTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Checkout/OrderTest.php new file mode 100644 index 00000000000..5e32cbb3957 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Checkout/OrderTest.php @@ -0,0 +1,418 @@ +connector); + $this->assertNull($order->getId()); + + $order = new Order($this->connector, '12345'); + $order['order_id'] = '12345'; + $this->assertEquals('12345', $order->getId()); + $this->assertEquals('/checkout/v3/orders/12345', $order->getLocation()); + } + + /** + * Make sure the correct data is sent and location is updated. + * + * @return void + */ + public function testCreate() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/checkout/v3/orders', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Location') + ->will($this->returnValue('http://somewhere/a-path')); + + $order = new Order($this->connector); + $location = $order->create($data) + ->getLocation(); + + $this->assertEquals('http://somewhere/a-path', $location); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testCreateInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $order->create(['data' => 'goes here']); + } + + /** + * Make sure a missing location header in the response results in an exception. + * + * @return void + */ + public function testCreateNoLocation() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(false)); + + $order = new Order($this->connector); + + $this->setExpectedException( + 'RuntimeException', + 'Response is missing a Location header' + ); + + $order->create(['data' => 'goes here']); + } + + /** + * Make sure the correct data is sent and that the replied data is accessible. + * + * @return void + */ + public function testUpdate() + { + $updateData = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/checkout/v3/orders/12345', + 'POST', + ['json' => $updateData] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'order_id' => '12345' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $order = new Order($this->connector, '12345'); + $order['order_id'] = '12345'; + $order['data'] = 'is overwritten'; + + $order->update($updateData); + + $this->assertEquals('from response json', $order['data']); + $this->assertEquals('12345', $order->getId()); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testUpdateInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $order->update(['data' => 'goes here']); + } + + /** + * Make sure a non-JSON response results in an exception. + * + * @return void + */ + public function testUpdateNotJson() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $order = new Order($this->connector); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected Content-Type header received: text/plain' + ); + + $order->update(['data' => 'goes here']); + } + + /** + * Make sure fetched data is accessible. + * + * @return void + */ + public function testFetch() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/checkout/v3/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'order_id' => '12345' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + + $order->fetch(); + + $this->assertEquals('from response json', $order['data']); + $this->assertEquals('12345', $order->getId()); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testFetchInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/checkout/v3/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $order->fetch(); + } + + /** + * Make sure a non-JSON response results in an exception. + * + * @return void + */ + public function testFetchNotJson() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/checkout/v3/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected Content-Type header received: text/plain' + ); + + $order->fetch(); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/CaptureTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/CaptureTest.php new file mode 100644 index 00000000000..ff665d9eea5 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/CaptureTest.php @@ -0,0 +1,512 @@ +connector, '/orders/1'); + $this->assertEquals('/orders/1/captures', $capture->getLocation()); + } + + /** + * Make sure the location is correct for fetch method. + * + * @return void + */ + public function testConstructorExisting() + { + $capture = new Capture($this->connector, '/orders/1', '2'); + $this->assertEquals('/orders/1/captures/2', $capture->getLocation()); + } + + /** + * Make sure the identifier is retrievable. + * + * @return void + */ + public function testGetId() + { + $capture = new Capture($this->connector, '/orders/12345'); + $this->assertNull($capture->getId()); + + $capture = new Capture($this->connector, '/orders/12345', '2'); + $this->assertEquals('2', $capture->getId()); + } + + /** + * Make sure fetched data is accessible. + * + * @return void + */ + public function testFetch() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'capture_id' => '2' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture['data'] = 'is overwritten'; + + $capture->fetch(); + + $this->assertEquals('from response json', $capture['data']); + $this->assertEquals('2', $capture->getId()); + } + + /** + * Make sure that an unknown status code response results in an exception. + * + * @return void + */ + public function testFetchInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $capture->fetch(); + } + + /** + * Make sure a non-JSON response results in an exception. + * + * @return void + */ + public function testFetchNotJson() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected Content-Type header received: text/plain' + ); + + $capture->fetch(); + } + + /** + * Make sure the correct data is sent and location is updated. + * + * @return void + */ + public function testCreate() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Location') + ->will($this->returnValue('http://somewhere/a-path')); + + $capture = new Capture($this->connector, '/orders/1'); + $location = $capture->create($data) + ->getLocation(); + + $this->assertEquals('http://somewhere/a-path', $location); + } + + /** + * Make sure that an unknown status code response results in an exception. + * + * @return void + */ + public function testCreateInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $capture = new Capture($this->connector, '/orders/1'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $capture->create(['data' => 'goes here']); + } + + /** + * Make sure a missing location header in the response results in an exception. + * + * @return void + */ + public function testCreateNoLocation() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(false)); + + $capture = new Capture($this->connector, '/orders/1'); + + $this->setExpectedException( + 'RuntimeException', + 'Response is missing a Location header' + ); + + $capture->create(['data' => 'goes here']); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testAddShippingInfo() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/shipping-info', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture->addShippingInfo($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testAddShippingInfoInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/shipping-info', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $capture->addShippingInfo($data); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testUpdateCustomerDetails() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/customer-details', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture->updateCustomerDetails($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testUpdateCustomerDetailsInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/customer-details', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $capture->updateCustomerDetails($data); + } + + /** + * Make sure that the correct request is sent. + * + * @return void + */ + public function testTriggerSendout() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/trigger-send-out', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + $capture->triggerSendout(); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testTriggerSendoutInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/orders/1/captures/2/trigger-send-out', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $capture = new Capture($this->connector, '/orders/1', '2'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $capture->triggerSendout(); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/OrderTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/OrderTest.php new file mode 100644 index 00000000000..44de858cce7 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/OrderManagement/OrderTest.php @@ -0,0 +1,921 @@ +connector, '12345'); + $this->assertEquals('12345', $order->getId()); + $this->assertEquals('/ordermanagement/v1/orders/12345', $order->getLocation()); + } + + /** + * Make sure fetched data is accessible. + * + * @return void + */ + public function testFetch() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'order_id' => '12345', + 'captures' => [ + [ + 'capture_id' => '1002', + 'data' => 'also from json' + ], + [ + 'capture_id' => '1003', + 'data' => 'something else' + ] + ] + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + $order['captures'][] = new \ArrayObject(); + + $order->fetch(); + + $this->assertEquals('from response json', $order['data']); + $this->assertEquals('12345', $order->getId()); + + $this->assertCount(2, $order['captures']); + $this->assertContainsOnlyInstancesOf( + 'Klarna\Rest\OrderManagement\Capture', + $order['captures'] + ); + + $this->assertEquals('1002', $order['captures'][0]->getId()); + $this->assertEquals('also from json', $order['captures'][0]['data']); + $this->assertEquals('1003', $order['captures'][1]->getId()); + $this->assertEquals('something else', $order['captures'][1]['data']); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testFetchInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 204' + ); + + $order->fetch(); + } + + /** + * Make sure a non-JSON response results in an exception. + * + * @return void + */ + public function testFetchNotJson() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $order = new Order($this->connector, '12345'); + $order['data'] = 'is overwritten'; + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected Content-Type header received: text/plain' + ); + + $order->fetch(); + } + + /** + * Make sure that the correct request is sent. + * + * @return void + */ + public function testAcknowledge() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/acknowledge', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->acknowledge(); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testAcknowledgeInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/acknowledge', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->acknowledge(); + } + + /** + * Make sure that the correct request is sent. + * + * @return void + */ + public function testCancel() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/cancel', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->cancel(); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testCancelInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/cancel', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->cancel(); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testUpdateAuthorization() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/authorization', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->updateAuthorization($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testUpdateAuthorizationInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/authorization', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->updateAuthorization($data); + } + + /** + * Make sure that the correct request is sent. + * + * @return void + */ + public function testExtendAuthorizationTime() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/extend-authorization-time', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->extendAuthorizationTime(); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testExtendAuthorizationTimeInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/extend-authorization-time', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->extendAuthorizationTime(); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testUpdateMerchantReferences() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/merchant-references', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->updateMerchantReferences($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testUpdateMerchantReferencesInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/merchant-references', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->updateMerchantReferences($data); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testUpdateCustomerDetails() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/customer-details', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->updateCustomerDetails($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testUpdateCustomerDetailsInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/customer-details', + 'PATCH', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->updateCustomerDetails($data); + } + + /** + * Make sure the correct data is sent. + * + * @return void + */ + public function testRefund() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/refunds', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->refund($data); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testRefundInvalidStatusCode() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/refunds', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->refund($data); + } + + /** + * Make sure that the correct request is sent. + * + * @return void + */ + public function testReleaseRemainingAuthorization() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/release-remaining-authorization', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $order = new Order($this->connector, '12345'); + $order->releaseRemainingAuthorization(); + } + + /** + * Make sure an unknown status code response results in an exception. + * + * @return void + */ + public function testReleaseRemainingAuthorizationInvalidStatusCode() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/release-remaining-authorization', + 'POST', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $order = new Order($this->connector, '12345'); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $order->releaseRemainingAuthorization(); + } + + /** + * Make sure that a capture is created properly. + * + * @return void + */ + public function testCreateCapture() + { + $data = ['data' => 'goes here']; + + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/captures', + 'POST', + ['json' => $data] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Location') + ->will($this->returnValue('http://somewhere/a-path')); + + $order = new Order($this->connector, '12345'); + $capture = $order->createCapture($data); + + $this->assertEquals('http://somewhere/a-path', $capture->getLocation()); + } + + /** + * Make sure that a capture is fetched. + * + * @return void + */ + public function testFetchCapture() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/captures/2', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'capture_id' => '2' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $order = new Order($this->connector, '12345'); + $capture = $order->fetchCapture('2'); + + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals('from response json', $capture['data']); + } + + /** + * Make sure that an existing capture is refreshed before returned. + * + * @return void + */ + public function testFetchCaptureExisting() + { + $this->connector->expects($this->never()) + ->method('createRequest'); + + $order = new Order($this->connector, '12345'); + + $order['captures'][] = $this->getMockBuilder('Klarna\Rest\OrderManagement\Capture') + ->disableOriginalConstructor() + ->getMock(); + + $order['captures'][0]->expects($this->once()) + ->method('getId') + ->will($this->returnValue('1')); + + $order['captures'][0]->expects($this->never()) + ->method('fetch'); + + $order['captures'][] = $this->getMockBuilder('Klarna\Rest\OrderManagement\Capture') + ->disableOriginalConstructor() + ->getMock(); + + $order['captures'][1]->expects($this->once()) + ->method('getId') + ->will($this->returnValue('2')); + + $order['captures'][1]->expects($this->once()) + ->method('fetch') + ->will($this->returnValue($order['captures'][1])); + + $this->assertSame($order['captures'][1], $order->fetchCapture('2')); + } + + /** + * Make sure that a new capture is fetched if it is not in the resource. + * + * @return void + */ + public function testFetchCaptureNoCache() + { + $this->connector->expects($this->once()) + ->method('createRequest') + ->with( + '/ordermanagement/v1/orders/12345/captures/2', + 'GET', + [] + ) + ->will($this->returnValue($this->request)); + + $this->connector->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'data' => 'from response json', + 'capture_id' => '2' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $order = new Order($this->connector, '12345'); + $order['captures'][] = $this->getMockBuilder('Klarna\Rest\OrderManagement\Capture') + ->disableOriginalConstructor() + ->getMock(); + + $order['captures'][0]->expects($this->once()) + ->method('getId') + ->will($this->returnValue('1')); + + $capture = $order->fetchCapture('2'); + + $this->assertInstanceOf('Klarna\Rest\OrderManagement\Capture', $capture); + $this->assertEquals('from response json', $capture['data']); + $this->assertEquals('2', $capture->getId()); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/TestCase.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/TestCase.php new file mode 100644 index 00000000000..72fdab1cba5 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/TestCase.php @@ -0,0 +1,57 @@ +request = $this->getMockBuilder('GuzzleHttp\Message\RequestInterface') + ->getMock(); + + $this->response = $this->getMockBuilder('GuzzleHttp\Message\ResponseInterface') + ->getMock(); + + $this->connector = $this->getMockBuilder('Klarna\Rest\Transport\Connector') + ->disableOriginalConstructor() + ->getMock(); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ConnectorTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ConnectorTest.php new file mode 100644 index 00000000000..cdba5d162e1 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ConnectorTest.php @@ -0,0 +1,343 @@ +client = $this->getMockBuilder('GuzzleHttp\ClientInterface') + ->getMock(); + + $this->userAgent = $this->getMockBuilder('Klarna\Rest\Transport\UserAgent') + ->getMock(); + + $this->userAgent->expects($this->any()) + ->method('__toString') + ->will($this->returnValue('a-user-agent')); + + $this->object = new Connector( + $this->client, + self::MERCHANT_ID, + self::SHARED_SECRET, + $this->userAgent + ); + } + + /** + * Make sure that the request is created as intended. + * + * @return void + */ + public function testCreateRequest() + { + $options = [ + 'opt' => 'val', + 'auth' => [self::MERCHANT_ID, self::SHARED_SECRET], + 'headers' => ['User-Agent' => 'a-user-agent'] + ]; + + $this->client->expects($this->any()) + ->method('createRequest') + ->with('uri', 'method', $options) + ->will($this->returnValue($this->request)); + + $request = $this->object->createRequest('method', 'uri', ['opt' => 'val']); + $this->assertSame($this->request, $request); + } + + /** + * Make sure that the request is sent and a response is returned. + * + * @return void + */ + public function testSend() + { + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->returnValue($this->response)); + + $response = $this->object->send($this->request); + + $this->assertSame($this->response, $response); + } + + /** + * Make sure that an exception without a response is re-thrown. + * + * @return void + */ + public function testSendRequestException() + { + $exception = new RequestException( + 'Something went terribly wrong', + $this->request + ); + + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->throwException($exception)); + + $this->setExpectedException( + 'GuzzleHttp\Exception\RequestException', + 'Something went terribly wrong' + ); + + $this->object->send($this->request); + } + + /** + * Make sure that an exception without a JSON response is re-thrown. + * + * @return void + */ + public function testSendConnectorExceptionNoJson() + { + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('')); + + $exception = new RequestException( + 'Something went terribly wrong', + $this->request, + $this->response + ); + + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->throwException($exception)); + + $this->setExpectedException( + 'GuzzleHttp\Exception\RequestException', + 'Something went terribly wrong' + ); + + $this->object->send($this->request); + } + + /** + * Make sure that an exception without data but with json content-type is + * re-thrown. + * + * @return void + */ + public function testSendConnectorExceptionEmptyJson() + { + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $exception = new RequestException( + 'Something went terribly wrong', + $this->request, + $this->response + ); + + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->throwException($exception)); + + $this->setExpectedException( + 'GuzzleHttp\Exception\RequestException', + 'Something went terribly wrong' + ); + + $this->object->send($this->request); + } + + /** + * Make sure that an exception without a proper JSON response is re-thrown. + * + * @return void + */ + public function testSendConnectorExceptionMissingFields() + { + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = []; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $exception = new RequestException( + 'Something went terribly wrong', + $this->request, + $this->response + ); + + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->throwException($exception)); + + $this->setExpectedException( + 'GuzzleHttp\Exception\RequestException', + 'Something went terribly wrong' + ); + + $this->object->send($this->request); + } + + /** + * Make sure that an exception with a error response is wrapped properly. + * + * @return void + */ + public function testSendConnectorException() + { + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('application/json')); + + $data = [ + 'error_code' => 'ERROR_CODE_1', + 'error_messages' => [ + 'Oh dear...', + 'Oh no...' + ], + 'correlation_id' => 'corr_id_1' + ]; + + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue($data)); + + $exception = new RequestException( + 'Something went terribly wrong', + $this->request, + $this->response + ); + + $this->client->expects($this->once()) + ->method('send') + ->with($this->request) + ->will($this->throwException($exception)); + + $this->setExpectedException( + 'Klarna\Rest\Transport\Exception\ConnectorException', + 'ERROR_CODE_1: Oh dear..., Oh no... (#corr_id_1)' + ); + + $this->object->send($this->request); + } + + /** + * Make sure that the factory method creates a connector properly. + * + * @return void + */ + public function testCreate() + { + $connector = Connector::create( + self::MERCHANT_ID, + self::SHARED_SECRET, + self::BASE_URL, + $this->userAgent + ); + + $client = $connector->getClient(); + $this->assertInstanceOf('GuzzleHttp\ClientInterface', $client); + + $this->assertEquals(self::BASE_URL, $client->getBaseUrl()); + + $userAgent = $connector->getUserAgent(); + + $this->assertSame($this->userAgent, $userAgent); + $this->assertEquals('a-user-agent', strval($userAgent)); + } + + /** + * Make sure that the factory method uses the default user agent. + * + * @return void + */ + public function testCreateDefaultUserAgent() + { + $connector = Connector::create( + self::MERCHANT_ID, + self::SHARED_SECRET, + self::BASE_URL + ); + + $userAgent = $connector->getUserAgent(); + $this->assertInstanceOf('Klarna\Rest\Transport\UserAgent', $userAgent); + $this->assertContains('Library/Klarna.kco_rest_php', strval($userAgent)); + } + + /** + * Make sure that the client is retrievable. + * + * @return void + */ + public function testGetClient() + { + $client = $this->object->getClient(); + + $this->assertInstanceOf('GuzzleHttp\ClientInterface', $client); + $this->assertSame($this->client, $client); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/Exception/ConnectorExceptionTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/Exception/ConnectorExceptionTest.php new file mode 100644 index 00000000000..11163fc4f9a --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/Exception/ConnectorExceptionTest.php @@ -0,0 +1,80 @@ + 'ERROR_CODE_1', + 'error_messages' => [ + 'Oh dear...', + 'Oh no...' + ], + 'correlation_id' => 'corr_id_1' + ]; + + $request = $this->getMockBuilder('GuzzleHttp\Message\RequestInterface') + ->getMock(); + $response = $this->getMockBuilder('GuzzleHttp\Message\ResponseInterface') + ->getMock(); + + $response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('500')); + + $previous = new RequestException('Error', $request, $response); + + $exception = new ConnectorException($data, $previous); + + $this->assertEquals(500, $exception->getCode()); + $this->assertSame($response, $exception->getResponse()); + + $this->assertContains( + $data['error_messages'][0], + $exception->getMessages() + ); + $this->assertContains( + $data['error_messages'][1], + $exception->getMessages() + ); + + $this->assertEquals($data['error_code'], $exception->getErrorCode()); + $this->assertEquals($data['correlation_id'], $exception->getCorrelationId()); + + $this->assertSame($previous, $exception->getPrevious()); + $this->assertEquals( + 'ERROR_CODE_1: Oh dear..., Oh no... (#corr_id_1)', + $exception->getMessage() + ); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ResponseValidatorTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ResponseValidatorTest.php new file mode 100644 index 00000000000..09c4e78ddd6 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/ResponseValidatorTest.php @@ -0,0 +1,249 @@ +response = $this->getMockBuilder($interface) + ->getMock(); + + $this->validator = new ResponseValidator($this->response); + } + + /** + * Make sure the response is retrievable. + * + * @return void + */ + public function testGetResponse() + { + $this->assertSame($this->response, $this->validator->getResponse()); + } + + /** + * Make sure that the JSON data is possible to retrieve. + * + * @return void + */ + public function testGetJson() + { + $this->response->expects($this->once()) + ->method('json') + ->will($this->returnValue('json response')); + + $this->assertEquals('json response', $this->validator->getJson()); + } + + /** + * Make sure that the location header can be retrieved. + * + * @return void + */ + public function testGetLocation() + { + $this->response->expects($this->once()) + ->method('hasHeader') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Location') + ->will($this->returnValue('a location')); + + $this->assertEquals('a location', $this->validator->getLocation()); + } + + /** + * Make sure that a missing Location header throws an exception. + * + * @return void + */ + public function testGetLocationException() + { + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Location') + ->will($this->returnValue(false)); + + $this->setExpectedException( + 'RuntimeException', + 'Response is missing a Location header' + ); + + $this->validator->getLocation(); + } + + /** + * Make sure that the content type is asserted properly. + * + * @return void + */ + public function testContentType() + { + $this->response->expects($this->once()) + ->method('hasHeader') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $this->assertSame( + $this->validator, + $this->validator->contentType('text/plain') + ); + } + + /** + * Make sure that a missing Content-Type header throws an exception. + * + * @return void + */ + public function testContentTypeMissingException() + { + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(false)); + + $this->setExpectedException( + 'RuntimeException', + 'Response is missing a Content-Type header' + ); + + $this->validator->contentType('text/plain'); + } + + /** + * Make sure that a different Content-Type header throws an exception. + * + * @return void + */ + public function testContentTypeWrongException() + { + $this->response->expects($this->once()) + ->method('hasHeader') + ->with('Content-Type') + ->will($this->returnValue(true)); + + $this->response->expects($this->once()) + ->method('getHeader') + ->with('Content-Type') + ->will($this->returnValue('text/plain')); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected Content-Type header received: text/plain' + ); + + $this->validator->contentType('application/json'); + } + + /** + * Make sure that the status code is asserted properly. + * + * @return void + */ + public function testStatus() + { + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->assertSame($this->validator, $this->validator->status('200')); + } + + /** + * Make sure that multiple status codes are asserted properly. + * + * @return void + */ + public function testStatuses() + { + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('204')); + + $this->assertSame( + $this->validator, + $this->validator->status(['201', '204']) + ); + } + + /** + * Make sure that a different status code throws an exception. + * + * @return void + */ + public function testStatusException() + { + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('201')); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 201' + ); + + $this->validator->status('200'); + } + + /** + * Make sure that a different status code throws an exception. + * + * @return void + */ + public function testStatusesException() + { + $this->response->expects($this->once()) + ->method('getStatusCode') + ->will($this->returnValue('200')); + + $this->setExpectedException( + 'RuntimeException', + 'Unexpected response status code: 200' + ); + + $this->validator->status(['201', '204']); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/UserAgentTest.php b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/UserAgentTest.php new file mode 100644 index 00000000000..b2e3903c2f1 --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/Unit/Transport/UserAgentTest.php @@ -0,0 +1,125 @@ +agent = new UserAgent(); + } + + /** + * Make sure the default user agent components are present. + * + * @return void + */ + public function testCreateDefault() + { + $agent = UserAgent::createDefault(); + $text = $agent->__toString(); + + $this->assertContains( + 'Language/PHP_' . phpversion(), + $text, + 'No PHP language component present' + ); + + $this->assertContains( + 'OS/' . php_uname('s') . '_' . php_uname('r'), + $text, + 'No OS component present' + ); + + $this->assertContains( + 'Library/' . UserAgent::NAME . '_' . UserAgent::VERSION, + $text, + 'No Library component present', + false + ); + } + + /** + * Make sure the key and component are present in the user agent. + * + * @return void + */ + public function testSetField() + { + $this->agent->setField('key', 'component'); + + $this->assertEquals('key/component', strval($this->agent)); + } + + /** + * Make sure the key, component and version are present. + * + * @return void + */ + public function testSetFieldVersion() + { + $this->agent->setField('key', 'component', '1.0.0'); + + $this->assertEquals('key/component_1.0.0', strval($this->agent)); + } + + /** + * Make sure the key, component, version and options are present. + * + * @return void + */ + public function testSetFieldOptions() + { + $this->agent->setField('key', 'component', '1.0.0', ['attr']); + + $this->assertEquals( + 'key/component_1.0.0 (attr)', + strval($this->agent) + ); + } + + /** + * Make sure the key, component, version and multiple options are present. + * + * @return void + */ + public function testSetFieldTwoOptions() + { + $this->agent->setField('key', 'component', '1.0.0', ['attr1', 'attr2']); + + $this->assertEquals( + 'key/component_1.0.0 (attr1; attr2)', + strval($this->agent) + ); + } +} diff --git a/upload/system/storage/vendor/klarna/kco_rest/tests/bootstrap.php b/upload/system/storage/vendor/klarna/kco_rest/tests/bootstrap.php new file mode 100644 index 00000000000..9065528ce5b --- /dev/null +++ b/upload/system/storage/vendor/klarna/kco_rest/tests/bootstrap.php @@ -0,0 +1,23 @@ +addPsr4('Klarna\\Rest\\Tests\\', __DIR__.'/'); + +date_default_timezone_set('UTC');