Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' into email_interface_as_plugin
Maciej Korycinskib5efc1343e14
diff --cc poetry.lockindex 07b68b95d3,f831c44d93..22242249f5--- a/poetry.lock+++ b/poetry.lock@@@ -165,20 -165,20 +165,20 @@@ d = ["aiohttp (>=3.3.2)", "aiohttp-cors[[package]]name = "boto3"- version = "1.17.34"-version = "1.17.33"++version = "1.17.36"description = "The AWS SDK for Python"category = "main"optional = falsepython-versions = ">= 2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"[package.dependencies]- botocore = ">=1.20.34,<1.21.0"-botocore = ">=1.20.33,<1.21.0"++botocore = ">=1.20.36,<1.21.0"jmespath = ">=0.7.1,<1.0.0"s3transfer = ">=0.3.0,<0.4.0"[[package]]name = "botocore"- version = "1.20.34"-version = "1.20.33"++version = "1.20.36"description = "Low-level, data-driven core of boto 3."category = "main"optional = false@@@ -849,7 -849,7 +849,7 @@@ gitdb = ">=4.0.1,<5[[package]]name = "google-api-core"--version = "1.26.1"++version = "1.26.2"description = "Google API client core library"category = "main"optional = false@@@ -1184,7 -1176,7 +1184,7 @@@ test = ["Cython (==0.29.14)"[[package]]name = "identify"- version = "2.2.0"-version = "2.1.3"++version = "2.2.1"description = "File identification library for Python"category = "dev"optional = false@@@ -1711,7 -1692,7 +1711,7 @@@ snowballstemmer = "*[[package]]name = "pyflakes"--version = "2.3.0"++version = "2.3.1"description = "passive checker of Python programs"category = "dev"optional = false@@@ -2640,12 -2585,12 +2640,12 @@@ black ={file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"},]boto3 = [- {file = "boto3-1.17.34-py2.py3-none-any.whl", hash = "sha256:1ddd597e3d8b7553432f84b32b9519cc90aad91c4dc3873725375163c9f98353"},- {file = "boto3-1.17.34.tar.gz", hash = "sha256:8f33cb3d2fc42b0547a5560a6d7397aa93336f50899386762b2450682c0e992b"},- {file = "boto3-1.17.33-py2.py3-none-any.whl", hash = "sha256:3306dad87f993703b102a0a70ca19c549b7f41e7f70fa7b4c579735c9f79351d"},- {file = "boto3-1.17.33.tar.gz", hash = "sha256:0cac2fffc1ba915f7bb5ecee539318532db51f218c928a228fafe3e501e9472e"},++ {file = "boto3-1.17.36-py2.py3-none-any.whl", hash = "sha256:16ca7a34eb88138e0d1ae2532e17975eef578aa1754e2d209ad41a8dfce059ce"},++ {file = "boto3-1.17.36.tar.gz", hash = "sha256:75f59fb3d764a381bb0108cb5036b398d0c8a1cf719e6b5aadbc5a53a1fd735e"},]botocore = [- {file = "botocore-1.20.34-py2.py3-none-any.whl", hash = "sha256:c4fe4fea1d6a3934dd8c670ee83b128f935a64078786fe8afb8a662446304926"},- {file = "botocore-1.20.34.tar.gz", hash = "sha256:749bdb151e340329f1b25600bfe9d223e930f8ba26bd74b71478ca5781f2feaf"},- {file = "botocore-1.20.33-py2.py3-none-any.whl", hash = "sha256:a33e862685259fe22d9790d9c9f3567feda8b824d44d3c62a3617af1133543a4"},- {file = "botocore-1.20.33.tar.gz", hash = "sha256:e355305309699d3aca1e0050fc21d48595b40db046cb0d2491cd57ff5b26920b"},++ {file = "botocore-1.20.36-py2.py3-none-any.whl", hash = "sha256:9ce33bd4175d58c5fdeb8e35052aa370aff74b347227e65ddc3f4fa01ef0686f"},++ {file = "botocore-1.20.36.tar.gz", hash = "sha256:148f5d7d48c54ed450831e5dd4d13284b2418955b6d99db23a3d9c4c6cb515c8"},]braintree = [{file = "braintree-4.6.0-py2.py3-none-any.whl", hash = "sha256:d3aa0e29eb3923574a58e8ee3219566c918ff161c98f2de715ba29cb715169c7"},@@@ -2940,12 -2885,12 +2940,12 @@@ gitpython ={file = "GitPython-3.1.14.tar.gz", hash = "sha256:be27633e7509e58391f10207cd32b2a6cf5b908f92d9cd30da2e514e1137af61"},]google-api-core = [-- {file = "google-api-core-1.26.1.tar.gz", hash = "sha256:23b0df512c4cc8729793f8992edb350e3211f5fd0ec007afb1599864b421beef"},-- {file = "google_api_core-1.26.1-py2.py3-none-any.whl", hash = "sha256:c383206f0f87545d3e658c4f8dc3b18a8457610fdbd791a15757c5b42d1e0e7f"},++ {file = "google-api-core-1.26.2.tar.gz", hash = "sha256:418a131cd349e8bda036741d93e7fb9caefa691daa7296851193edc60b3c946c"},++ {file = "google_api_core-1.26.2-py2.py3-none-any.whl", hash = "sha256:79811ec36d182c9be1398609d651c30803b01fe02d4758c886acc0524ff9b53e"},]google-auth = [- {file = "google-auth-1.27.1.tar.gz", hash = "sha256:d8958af6968e4ecd599f82357ebcfeb126f826ed0656126ad68416f810f7531e"},- {file = "google_auth-1.27.1-py2.py3-none-any.whl", hash = "sha256:63a5636d7eacfe6ef5b7e36e112b3149fa1c5b5ad77dd6df54910459bcd6b89f"},+ {file = "google-auth-1.28.0.tar.gz", hash = "sha256:9bd436d19ab047001a1340720d2b629eb96dd503258c524921ec2af3ee88a80e"},+ {file = "google_auth-1.28.0-py2.py3-none-any.whl", hash = "sha256:dcaba3aa9d4e0e96fd945bf25a86b6f878fcb05770b67adbeb50a63ca4d28a5e"},]google-cloud-core = [{file = "google-cloud-core-1.6.0.tar.gz", hash = "sha256:c6abb18527545379fc82efc4de75ce9a3772ccad2fc645adace593ba097cbb02"},@@@ -3110,8 -3051,8 +3110,8 @@@ httptools ={file = "httptools-0.1.1.tar.gz", hash = "sha256:41b573cf33f64a8f8f3400d0a7faf48e1888582b6f6e02b82b9bd4f0bf7497ce"},]identify = [- {file = "identify-2.2.0-py2.py3-none-any.whl", hash = "sha256:39c0b110c9d0cd2391b6c38cd0ff679ee4b4e98f8db8b06c5d9d9e502711a1e1"},- {file = "identify-2.2.0.tar.gz", hash = "sha256:efbf090a619255bc31c4fbba709e2805f7d30913fd4854ad84ace52bd276e2f6"},- {file = "identify-2.1.3-py2.py3-none-any.whl", hash = "sha256:46d1816c6a4fc2d1e8758f293a5dcc1ae6404ab344179d7c1e73637bf283beb1"},- {file = "identify-2.1.3.tar.gz", hash = "sha256:ed4a05fb80e3cbd12e83c959f9ff7f729ba6b66ab8d6178850fd5cb4c1cf6c5d"},++ {file = "identify-2.2.1-py2.py3-none-any.whl", hash = "sha256:9cc5f58996cd359b7b72f0a5917d8639de5323917e6952a3bfbf36301b576f40"},++ {file = "identify-2.2.1.tar.gz", hash = "sha256:1cfb05b578de996677836d5a2dde14b3dffde313cf7d2b3e793a0787a36e26dd"},]idna = [{file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"},@@@ -3524,8 -3482,8 +3524,8 @@@ pydocstyle ={file = "pydocstyle-6.0.0.tar.gz", hash = "sha256:164befb520d851dbcf0e029681b91f4f599c62c5cd8933fd54b1bfbd50e89e1f"},]pyflakes = [-- {file = "pyflakes-2.3.0-py2.py3-none-any.whl", hash = "sha256:910208209dcea632721cb58363d0f72913d9e8cf64dc6f8ae2e02a3609aba40d"},-- {file = "pyflakes-2.3.0.tar.gz", hash = "sha256:e59fd8e750e588358f1b8885e5a4751203a0516e0ee6d34811089ac294c8806f"},++ {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"},++ {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"},]pyjwt = [{file = "PyJWT-2.0.1-py3-none-any.whl", hash = "sha256:b70b15f89dc69b993d8a8d32c299032d5355c82f9b5b7e851d1a6d706dffe847"},diff --cc requirements.txtindex df27ec03cd,363880c3b7..30d83dc597--- a/requirements.txt+++ b/requirements.txt@@@ -6,8 -6,8 +6,8 @@@ authorizenet==1.1.babel==2.9.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")beautifulsoup4==4.7.1billiard==3.6.3.0; python_version >= "3.6"- boto3==1.17.34; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")- botocore==1.20.34; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"-boto3==1.17.33; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")-botocore==1.20.33; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"++boto3==1.17.36; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")++botocore==1.20.36; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"braintree==4.6.0cachetools==4.2.1; python_version >= "3.5" and python_version < "4.0" and (python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.6.0")cairocffi==1.2.0; python_version >= "3.6"@@@ -47,8 -47,8 +47,8 @@@ enmerkar==0.7.et-xmlfile==1.0.1; python_version >= "3.6"faker==6.6.2; python_version >= "3.6"freezegun==0.3.15; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")--google-api-core==1.26.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"-google-auth==1.27.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0"++google-api-core==1.26.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"+google-auth==1.28.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0"google-cloud-core==1.6.0; python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.6.0"google-cloud-pubsub==2.4.0; python_version >= "3.6"google-cloud-storage==1.36.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")diff --cc requirements_dev.txtindex a20e1a0a97,6d0ae3a883..f125b2eecd--- a/requirements_dev.txt+++ b/requirements_dev.txt@@@ -13,8 -13,8 +13,8 @@@ beautifulsoup4==4.7.beautifultable==0.7.0billiard==3.6.3.0; python_version >= "3.6"black==20.8b1; python_version >= "3.6"- boto3==1.17.34; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")- botocore==1.20.34; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"-boto3==1.17.33; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")-botocore==1.20.33; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"++boto3==1.17.36; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")++botocore==1.20.36; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"braintree==4.6.0cachetools==4.2.1; python_version >= "3.5" and python_version < "4.0" and (python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.6.0")cairocffi==1.2.0; python_version >= "3.6"@@@ -68,8 -68,8 +68,8 @@@ flake8==3.9.0; (python_version >= "2.7freezegun==0.3.15; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")gitdb==4.0.5; python_version >= "3.4" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version < "3.10" and python_version >= "3.4"gitpython==3.1.14; python_version >= "3.4" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version < "3.10" and python_version >= "3.4"--google-api-core==1.26.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"-google-auth==1.27.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0"++google-api-core==1.26.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"+google-auth==1.28.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0"google-cloud-core==1.6.0; python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.6.0"google-cloud-pubsub==2.4.0; python_version >= "3.6"google-cloud-storage==1.36.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")@@@ -88,10 -88,9 +88,10 @@@ grpcio==1.36.1; python_version >= "3.6gunicorn==20.0.4; python_version >= "3.4"h11==0.12.0; python_version >= "3.6"html-to-draftjs==1.0.1+html2text==2020.1.16; python_version >= "3.5"html5lib==1.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"httptools==0.1.1; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy"- identify==2.2.0; python_full_version >= "3.6.1"-identify==2.1.3; python_full_version >= "3.6.1"++identify==2.2.1; python_full_version >= "3.6.1"idna==2.10; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"iniconfig==1.1.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"isort==5.8.0; python_version >= "3.6" and python_version < "4.0"@@@ -138,7 -136,7 +138,7 @@@ pybars3==0.9.pycodestyle==2.7.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"pydocstyle==6.0.0; python_version >= "3.6"--pyflakes==2.3.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"++pyflakes==2.3.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"pyjwt==2.0.1; python_version >= "3.6"pylint-celery==0.3pylint-django==2.4.2diff --cc saleor/checkout/complete_checkout.pyindex 1929d48463,6217f54b00..9c0b93b1c8--- a/saleor/checkout/complete_checkout.py+++ b/saleor/checkout/complete_checkout.py@@@ -408,7 -411,10 +411,7 @@@ def _create_order# Send the order confirmation emailtransaction.on_commit(- lambda: send_order_confirmation(order, checkout.redirect_url, plugin_manager)- lambda: send_order_confirmation.delay(order.pk, checkout.redirect_url, user.pk)- )- transaction.on_commit(- lambda: send_staff_order_confirmation.delay(order.pk, checkout.redirect_url)++ lambda: send_order_confirmation(order, checkout.redirect_url, manager))return orderdiff --cc saleor/graphql/order/tests/test_order.pyindex 263f6301c1,1c60071932..5e77cae996--- a/saleor/graphql/order/tests/test_order.py+++ b/saleor/graphql/order/tests/test_order.py@@@ -819,17 -817,7 +819,18 @@@ def test_order_confirmtype=order_events.OrderEvents.PAYMENT_CAPTURED,parameters__amount=payment_txn_preauth.get_total().amount,).exists()- capture_mock.assert_called_once_with(payment_txn_preauth)+++ capture_mock.assert_called_once_with(payment_txn_preauth, ANY)+ expected_payload = {+ "order": get_default_order_payload(order_unconfirmed, ""),+ "recipient_email": order_unconfirmed.user.email,+ "requester_user_id": staff_api_client.user.id,+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_CONFIRMED, expected_payload+ )def test_order_confirm_unfulfilled(staff_api_client, order, permission_manage_orders):@@@ -3239,16 -3235,13 +3242,18 @@@ def test_order_cancel_as_appassert not data["orderErrors"]mock_clean_order_cancel.assert_called_once_with(order)- mock_cancel_order.assert_called_once_with(order=order, user=AnonymousUser())+ mock_cancel_order.assert_called_once_with(+ order=order, user=AnonymousUser(), manager=ANY+ )[email protected]("saleor.plugins.manager.PluginsManager.notify")def test_order_capture(- staff_api_client, permission_manage_orders, payment_txn_preauth, staff_user+ mocked_notify,+ staff_api_client,+ permission_manage_orders,+ payment_txn_preauth,+ staff_user,):order = payment_txn_preauth.orderquery = """diff --cc saleor/graphql/order/types.pyindex b6da6b84fc,60b09aff19..667249cc44--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@@ -17,8 -17,7 +17,7 @@@ from ...graphql.utils import get_user_ofrom ...order import OrderStatus, modelsfrom ...order.models import FulfillmentStatusfrom ...order.utils import get_order_country, get_valid_shipping_methods_for_order- from ...plugins.manager import get_plugins_manager-from ...product.templatetags.product_images import get_product_image_thumbnail+from ...product.product_images import get_product_image_thumbnailfrom ...warehouse import models as warehouse_modelsfrom ..account.types import Userfrom ..account.utils import requestor_has_accessdiff --cc saleor/order/actions.pyindex b9fa8204cc,7ab44e69cf..f011b6a34e--- a/saleor/order/actions.py+++ b/saleor/order/actions.py@@@ -94,20 -107,24 +106,20 @@@ def order_confirmedTrigger event, plugin hooks and optionally confirmation email."""events.order_confirmed_event(order=order, user=user)- manager = get_plugins_manager()manager.order_confirmed(order)if send_confirmation_email:- send_order_confirmed.delay(order.pk, user.pk)+ send_order_confirmed(order, user, manager)- def handle_fully_paid_order(order: "Order", user: Optional["User"] = None):+ def handle_fully_paid_order(+ manager: "PluginsManager", order: "Order", user: Optional["User"] = None+ ):events.order_fully_paid_event(order=order, user=user)- manager = get_plugins_manager()-if order.get_customer_email():- events.email_sent_event(- order=order, user=user, email_type=events.OrderEventsEmails.PAYMENT- )- send_payment_confirmation.delay(order.pk)+ send_payment_confirmation(order, manager)if utils.order_needs_automatic_fulfillment(order):-- automatically_fulfill_digital_lines(order)++ automatically_fulfill_digital_lines(order, manager)try:analytics.report_order(order.tracking_client_id, order)except Exception:@@@ -147,16 -163,16 +158,16 @@@ def order_refundedevents.payment_refunded_event(order=order, user=user, amount=amount, payment=payment)- if not manager:- manager = get_plugins_manager()manager.order_updated(order)- send_order_refunded_confirmation(order, user, amount, payment.currency)+ send_order_refunded_confirmation(order, user, amount, payment.currency, manager)- def order_voided(order: "Order", user: "User", payment: "Payment"):+ def order_voided(+ order: "Order", user: "User", payment: "Payment", manager: "PluginsManager"+ ):events.payment_voided_event(order=order, user=user, payment=payment)- get_plugins_manager().order_updated(order)+ manager.order_updated(order)def order_returned(@@@ -193,12 -209,12 +204,12 @@@ def order_fulfilledif notify_customer:for fulfillment in fulfillments:- send_fulfillment_confirmation_to_customer(order, fulfillment, user)+ send_fulfillment_confirmation_to_customer(order, fulfillment, user, manager)- def order_shipping_updated(order: "Order"):+ def order_shipping_updated(order: "Order", manager: "PluginsManager"):recalculate_order(order)- get_plugins_manager().order_updated(order)+ manager.order_updated(order)def order_authorized(@@@ -323,7 -355,7 +350,7 @@@ def fulfill_order_lines(order_lines_inf@transaction.atomic--def automatically_fulfill_digital_lines(order: "Order"):++def automatically_fulfill_digital_lines(order: "Order", manager: "PluginsManager"):"""Fulfill all digital lines which have enabled automatic fulfillment setting.Send confirmation email afterward.@@@ -363,9 -395,8 +390,8 @@@FulfillmentLine.objects.bulk_create(fulfillments)fulfill_order_lines(lines_info)- manager = get_plugins_manager()- emails.send_fulfillment_confirmation_to_customer(- order, fulfillment, user=order.user+ send_fulfillment_confirmation_to_customer(+ order, fulfillment, user=order.user, manager=manager)update_order_status(order)diff --cc saleor/order/tests/test_fulfullments_actions.pyindex 312889bd0b,431d8f34f7..96ce51b372--- a/saleor/order/tests/test_fulfullments_actions.py+++ b/saleor/order/tests/test_fulfullments_actions.py@@@ -26,9 -25,9 +25,9 @@@ def test_create_fulfillments{"order_line": order_line2, "quantity": 2},]}--++ manager = get_plugins_manager()[fulfillment] = create_fulfillments(- staff_user, order, fulfillment_lines_for_warehouses, True- staff_user, order, fulfillment_lines_for_warehouses, get_plugins_manager(), True++ staff_user, order, fulfillment_lines_for_warehouses, manager, True)flush_post_commit_hooks()@@@ -56,7 -55,7 +55,7 @@@)mock_email_fulfillment.assert_called_once_with(- order, order.fulfillments.get(), staff_user, mock_get_plugins_manager()- order, order.fulfillments.get(), staff_user++ order, order.fulfillments.get(), staff_user, manager)@@@ -184,8 -189,8 +189,9 @@@ def test_create_fulfillments_with_one_l]}++ manager = get_plugins_manager()[fulfillment] = create_fulfillments(- staff_user, order, fulfillment_lines_for_warehouses, True- staff_user, order, fulfillment_lines_for_warehouses, get_plugins_manager(), True++ staff_user, order, fulfillment_lines_for_warehouses, manager, True)flush_post_commit_hooks()@@@ -211,7 -216,7 +217,7 @@@)mock_email_fulfillment.assert_called_once_with(- order, order.fulfillments.get(), staff_user, mock_get_plugins_manager()- order, order.fulfillments.get(), staff_user++ order, order.fulfillments.get(), staff_user, manager)@@@ -232,8 -235,8 +236,9 @@@ def test_create_fulfillments_with_variastr(warehouse.pk): [{"order_line": order_line, "quantity": 2}]}++ manager = get_plugins_manager()[fulfillment] = create_fulfillments(- staff_user, order, fulfillment_lines_for_warehouses, True- staff_user, order, fulfillment_lines_for_warehouses, get_plugins_manager(), True++ staff_user, order, fulfillment_lines_for_warehouses, manager, True)flush_post_commit_hooks()@@@ -254,7 -257,7 +259,7 @@@assert stock_quantity_before == stock.quantitymock_email_fulfillment.assert_called_once_with(- order, order.fulfillments.get(), staff_user, mock_get_plugins_manager()- order, order.fulfillments.get(), staff_user++ order, order.fulfillments.get(), staff_user, manager)@@@ -278,8 -278,8 +281,9 @@@ def test_create_fulfillments_without_al]}++ manager = get_plugins_manager()[fulfillment] = create_fulfillments(- staff_user, order, fulfillment_lines_for_warehouses, True- staff_user, order, fulfillment_lines_for_warehouses, get_plugins_manager(), True++ staff_user, order, fulfillment_lines_for_warehouses, manager, True)flush_post_commit_hooks()@@@ -307,7 -307,7 +311,7 @@@)mock_email_fulfillment.assert_called_once_with(- order, order.fulfillments.get(), staff_user, mock_get_plugins_manager()- order, order.fulfillments.get(), staff_user++ order, order.fulfillments.get(), staff_user, manager)diff --cc saleor/order/tests/test_notifications.pyindex 3df4fbd6e0,0000000000..d6e4cb832amode 100644,000000..100644--- a/saleor/order/tests/test_notifications.py+++ b/saleor/order/tests/test_notifications.py@@@ -1,421 -1,0 +1,421 @@@+from decimal import Decimal+from functools import partial+from unittest import mock++from measurement.measures import Weight+from prices import Money, fixed_discount++from ...core.notify_events import NotifyEventType+from ...discount import DiscountValueType+from ...order import notifications+from ...plugins.manager import get_plugins_manager+from ...product.models import DigitalContentUrl+from ..notifications import (+ get_address_payload,+ get_default_fulfillment_line_payload,+ get_default_fulfillment_payload,+ get_default_order_payload,+ get_order_line_payload,+)+from ..utils import add_variant_to_draft_order+++def test_get_order_line_payload(order_line):+ order_line.variant.product.weight = Weight(kg=5)+ order_line.variant.product.save()++ payload = get_order_line_payload(order_line)++ attributes = order_line.variant.product.attributes.all()+ expected_attributes_payload = []+ for attr in attributes:+ expected_attributes_payload.append(+ {+ "assignment": {+ "attribute": {+ "slug": attr.assignment.attribute.slug,+ "name": attr.assignment.attribute.name,+ }+ },+ "values": [+ {+ "name": value.name,+ "value": value.value,+ "slug": value.slug,+ "file_url": value.file_url,+ }+ for value in attr.values.all()+ ],+ }+ )+ unit_tax_amount = (+ order_line.unit_price_gross_amount - order_line.unit_price_net_amount+ )+ total_gross = order_line.unit_price_gross * order_line.quantity+ total_net = order_line.unit_price_net * order_line.quantity+ total_tax = total_gross - total_net+ assert payload == {+ "variant": {+ "id": order_line.variant_id,+ "first_image": None,+ "images": None,+ "weight": "",+ },+ "product": {+ "attributes": expected_attributes_payload,+ "first_image": None,+ "images": None,+ "weight": "5.0 kg",+ "id": order_line.variant.product.id,+ },+ "translated_product_name": order_line.translated_product_name+ or order_line.product_name,+ "translated_variant_name": order_line.translated_variant_name+ or order_line.variant_name,+ "id": order_line.id,+ "product_name": order_line.product_name,+ "variant_name": order_line.variant_name,+ "product_sku": order_line.product_sku,+ "is_shipping_required": order_line.is_shipping_required,+ "quantity": order_line.quantity,+ "quantity_fulfilled": order_line.quantity_fulfilled,+ "currency": order_line.currency,+ "unit_price_net_amount": order_line.unit_price_net_amount,+ "unit_price_gross_amount": order_line.unit_price_gross_amount,+ "unit_tax_amount": unit_tax_amount,+ "total_gross_amount": total_gross.amount,+ "total_net_amount": total_net.amount,+ "total_tax_amount": total_tax.amount,+ "tax_rate": order_line.tax_rate,+ "is_digital": order_line.is_digital,+ "digital_url": "",+ "unit_discount_amount": order_line.unit_discount_amount,+ "unit_discount_reason": order_line.unit_discount_reason,+ "unit_discount_type": order_line.unit_discount_type,+ "unit_discount_value": order_line.unit_discount_value,+ }+++def test_get_address_payload(address):+ payload = get_address_payload(address)+ assert payload == {+ "first_name": address.first_name,+ "last_name": address.last_name,+ "company_name": address.company_name,+ "street_address_1": address.street_address_1,+ "street_address_2": address.street_address_2,+ "city": address.city,+ "city_area": address.city_area,+ "postal_code": address.postal_code,+ "country": str(address.country),+ "country_area": address.country_area,+ "phone": str(address.phone),+ }+++def test_get_default_order_payload(order_line):+ order_line.refresh_from_db()+ order = order_line.order+ order_line_payload = get_order_line_payload(order_line)+ redirect_url = "http://redirect.com/path"+ subtotal = order.get_subtotal()+ order.total = subtotal + order.shipping_price+ tax = order.total_gross_amount - order.total_net_amount++ value = Decimal("20")+ discount = partial(fixed_discount, discount=Money(value, order.currency))+ order.undiscounted_total = order.total+ order.total = discount(order.total)+ order.discounts.create(+ value_type=DiscountValueType.FIXED,+ value=value,+ reason="Discount reason",+ amount=(order.undiscounted_total - order.total).gross,+ # type: ignore+ )+ order.save()++ payload = get_default_order_payload(order, redirect_url)++ assert payload == {+ "discounts": [+ {+ "amount_value": Decimal("20.000"),+ "name": None,+ "reason": "Discount reason",+ "translated_name": None,+ "type": "manual",+ "value": Decimal("20.000"),+ "value_type": "fixed",+ }+ ],+ "channel_slug": order.channel.slug,+ "id": order.id,+ "token": order.token,+ "created": str(order.created),+ "display_gross_prices": order.display_gross_prices,+ "currency": order.currency,+ "total_gross_amount": order.total_gross_amount,+ "total_net_amount": order.total_net_amount,+ "shipping_method_name": order.shipping_method_name,+ "status": order.status,+ "metadata": order.metadata,+ "private_metadata": order.private_metadata,+ "shipping_price_net_amount": order.shipping_price_net_amount,+ "shipping_price_gross_amount": order.shipping_price_gross_amount,+ "order_details_url": f"{redirect_url}?token={order.token}",+ "email": order.get_customer_email(),+ "subtotal_gross_amount": subtotal.gross.amount,+ "subtotal_net_amount": subtotal.net.amount,+ "tax_amount": tax,+ "lines": [order_line_payload],+ "billing_address": get_address_payload(order.billing_address),+ "shipping_address": get_address_payload(order.shipping_address),+ "language_code": order.language_code,+ "discount_amount": Decimal("20.000"),+ "undiscounted_total_gross_amount": order.undiscounted_total.gross.amount,+ "undiscounted_total_net_amount": order.undiscounted_total.net.amount,+ "voucher_discount": None,+ }+++def test_get_default_fulfillment_payload(+ fulfillment,+ digital_content,+):+ order = fulfillment.order+ fulfillment.tracking_number = "http://tracking.url.com/123"+ fulfillment.save(update_fields=["tracking_number"])+ line = order.lines.first()+ line.variant = digital_content.product_variant+ line.save(update_fields=["variant"])+ DigitalContentUrl.objects.create(content=digital_content, line=line)++ order_payload = get_default_order_payload(order)+ payload = get_default_fulfillment_payload(order, fulfillment)++ # make sure that test will not fail because of the list order+ payload["order"]["lines"] = sorted(payload["order"]["lines"], key=lambda l: l["id"])+ payload["physical_lines"] = sorted(payload["physical_lines"], key=lambda l: l["id"])+ order_payload["lines"] = sorted(order_payload["lines"], key=lambda l: l["id"])++ digital_line = fulfillment.lines.get(order_line=line.id)+ physical_line = fulfillment.lines.exclude(id=digital_line.id).first()+ assert payload == {+ "order": order_payload,+ "fulfillment": {+ "tracking_number": fulfillment.tracking_number,+ "is_tracking_number_url": fulfillment.is_tracking_number_url,+ },+ "physical_lines": [get_default_fulfillment_line_payload(physical_line)],+ "digital_lines": [get_default_fulfillment_line_payload(digital_line)],+ "recipient_email": order.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_email_payment_confirmation(mocked_notify, site_settings, payment_dummy):+ manager = get_plugins_manager()+ order = payment_dummy.order+ expected_payload = {+ "order": get_default_order_payload(order),+ "recipient_email": order.get_customer_email(),+ "payment": {+ "created": payment_dummy.created,+ "modified": payment_dummy.modified,+ "charge_status": payment_dummy.charge_status,+ "total": payment_dummy.total,+ "captured_amount": payment_dummy.captured_amount,+ "currency": payment_dummy.currency,+ },+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }+ notifications.send_payment_confirmation(order, manager)+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_PAYMENT_CONFIRMATION, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_email_order_confirmation(mocked_notify, order, site_settings):+ manager = get_plugins_manager()+ redirect_url = "https://www.example.com"++ notifications.send_order_confirmation(order, redirect_url, manager)++ expected_payload = {+ "order": get_default_order_payload(order, redirect_url),+ "recipient_email": order.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_CONFIRMATION, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_confirmation_emails_without_addresses_for_payment(+ mocked_notify,+ site_settings,+ digital_content,+ payment_dummy,+):+ order = payment_dummy.order++ manager = get_plugins_manager()++ line = add_variant_to_draft_order(- order, digital_content.product_variant, quantity=1++ order, digital_content.product_variant, quantity=1, manager=manager+ )+ DigitalContentUrl.objects.create(content=digital_content, line=line)++ order.shipping_address = None+ order.shipping_method = None+ order.billing_address = None+ order.save(update_fields=["shipping_address", "shipping_method", "billing_address"])+- manager = get_plugins_manager()+ notifications.send_payment_confirmation(order, manager)++ expected_payload = {+ "order": get_default_order_payload(order),+ "recipient_email": order.get_customer_email(),+ "payment": {+ "created": payment_dummy.created,+ "modified": payment_dummy.modified,+ "charge_status": payment_dummy.charge_status,+ "total": payment_dummy.total,+ "captured_amount": payment_dummy.captured_amount,+ "currency": payment_dummy.currency,+ },+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_PAYMENT_CONFIRMATION, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_confirmation_emails_without_addresses_for_order(+ mocked_notify, order, site_settings, digital_content+):++ assert not order.lines.count()++ manager = get_plugins_manager()++ line = add_variant_to_draft_order(- order, digital_content.product_variant, quantity=1++ order, digital_content.product_variant, quantity=1, manager=manager+ )+ DigitalContentUrl.objects.create(content=digital_content, line=line)++ order.shipping_address = None+ order.shipping_method = None+ order.billing_address = None+ order.save(update_fields=["shipping_address", "shipping_method", "billing_address"])++ redirect_url = "https://www.example.com"- manager = get_plugins_manager()++ notifications.send_order_confirmation(order, redirect_url, manager)++ expected_payload = {+ "order": get_default_order_payload(order, redirect_url),+ "recipient_email": order.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }++ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_CONFIRMATION, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_fulfillment_confirmation(+ mocked_notify, fulfilled_order, site_settings, staff_user+):+ fulfillment = fulfilled_order.fulfillments.first()+ fulfillment.tracking_number = "https://www.example.com"+ fulfillment.save()+ manager = get_plugins_manager()++ notifications.send_fulfillment_confirmation_to_customer(+ order=fulfilled_order,+ fulfillment=fulfillment,+ user=staff_user,+ manager=manager,+ )++ expected_payload = get_default_fulfillment_payload(fulfilled_order, fulfillment)+ expected_payload["requester_user_id"] = staff_user.id+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_FULFILLMENT_CONFIRMATION, payload=expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_fulfillment_update(mocked_notify, fulfilled_order, site_settings):+ fulfillment = fulfilled_order.fulfillments.first()+ fulfillment.tracking_number = "https://www.example.com"+ fulfillment.save()+ manager = get_plugins_manager()++ notifications.send_fulfillment_update(+ order=fulfilled_order, fulfillment=fulfillment, manager=manager+ )++ expected_payload = get_default_fulfillment_payload(fulfilled_order, fulfillment)++ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_FULFILLMENT_UPDATE, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_email_order_canceled(mocked_notify, order, site_settings, staff_user):+ # given+ manager = get_plugins_manager()++ # when+ notifications.send_order_canceled_confirmation(order, staff_user, manager)++ # then+ expected_payload = {+ "order": get_default_order_payload(order),+ "recipient_email": order.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ "requester_user_id": staff_user.id,+ }+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_CANCELED, expected_payload+ )++[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_email_order_refunded(mocked_notify, order, site_settings, staff_user):+ # given+ manager = get_plugins_manager()+ amount = order.total.gross.amount++ # when+ notifications.send_order_refunded_confirmation(+ order, staff_user, amount, order.currency, manager+ )++ # then+ expected_payload = {+ "requester_user_id": staff_user.id,+ "order": get_default_order_payload(order),+ "amount": amount,+ "currency": order.currency,+ "recipient_email": order.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }++ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_REFUND_CONFIRMATION, expected_payload+ )diff --cc saleor/order/tests/test_order_actions.pyindex f7da81dd08,b9a68eaa92..ec289c8167--- a/saleor/order/tests/test_order_actions.py+++ b/saleor/order/tests/test_order_actions.py@@@ -67,59 -63,67 +67,55 @@@ def order_with_digital_line(order, digireturn order- @patch("saleor.order.actions.get_plugins_manager")-@patch("saleor.order.emails.send_fulfillment_confirmation.delay")-@patch("saleor.order.emails.send_payment_confirmation.delay")+@patch(+ "saleor.order.actions.send_fulfillment_confirmation_to_customer",+ wraps=send_fulfillment_confirmation_to_customer,+)+@patch(+ "saleor.order.actions.send_payment_confirmation", wraps=send_payment_confirmation+)def test_handle_fully_paid_order_digital_lines(mock_send_payment_confirmation,- mock_send_fulfillment_confirmation,+ send_fulfillment_confirmation_to_customer,- mocked_get_plugins_manager,order_with_digital_line,):- manager = mocked_get_plugins_manager()+ order = order_with_digital_line+ order.payments.add(Payment.objects.create())redirect_url = "http://localhost.pl"order = order_with_digital_lineorder.redirect_url = redirect_urlorder.save()- handle_fully_paid_order(order)+ manager = get_plugins_manager()+ handle_fully_paid_order(manager, order)fulfillment = order.fulfillments.first()+ event_order_paid = order.events.get()- (- event_order_paid,- event_email_sent,- event_order_fulfilled,- event_digital_links,- ) = order.events.all()assert event_order_paid.type == OrderEvents.ORDER_FULLY_PAID- assert event_email_sent.type == OrderEvents.EMAIL_SENT- assert event_order_fulfilled.type == OrderEvents.EMAIL_SENT- assert event_digital_links.type == OrderEvents.EMAIL_SENT-- assert (- event_order_fulfilled.parameters["email_type"] == OrderEventsEmails.FULFILLMENT- )- assert (- event_digital_links.parameters["email_type"] == OrderEventsEmails.DIGITAL_LINKS- )-- mock_send_payment_confirmation.assert_called_once_with(order.pk)- mock_send_fulfillment_confirmation.assert_called_once_with(- order.pk, fulfillment.pk, redirect_url+ mock_send_payment_confirmation.assert_called_once_with(order, manager)+ send_fulfillment_confirmation_to_customer.assert_called_once_with(+ order, fulfillment, user=order.user, manager=manager)order.refresh_from_db()assert order.status == OrderStatus.FULFILLED- @patch("saleor.order.actions.get_plugins_manager")-@patch("saleor.order.emails.send_payment_confirmation.delay")+@patch("saleor.order.actions.send_payment_confirmation")- def test_handle_fully_paid_order(- mock_send_payment_confirmation, mocked_get_plugins_manager, order- ):+ def test_handle_fully_paid_order(mock_send_payment_confirmation, order):+ manager = get_plugins_manager()+++ order.payments.add(Payment.objects.create())- handle_fully_paid_order(order)+ handle_fully_paid_order(manager, order)- event_order_paid, event_email_sent = order.events.all()- assert event_order_paid.type == OrderEvents.ORDER_FULLY_PAID+ event_order_paid = order.events.get()+- assert event_email_sent.type == OrderEvents.EMAIL_SENT- assert event_email_sent.parameters == {- "email": order.get_customer_email(),- "email_type": OrderEventsEmails.PAYMENT,- }+ assert event_order_paid.type == OrderEvents.ORDER_FULLY_PAID- mock_send_payment_confirmation.assert_called_once_with(- order, mocked_get_plugins_manager()- )- mock_send_payment_confirmation.assert_called_once_with(order.pk)++ mock_send_payment_confirmation.assert_called_once_with(order, manager)-@patch("saleor.order.emails.send_payment_confirmation.delay")+@patch("saleor.order.notifications.send_payment_confirmation")def test_handle_fully_paid_order_no_email(mock_send_payment_confirmation, order):order.user = Noneorder.user_email = ""@@@ -228,12 -237,9 +229,9 @@@ def test_cancel_orderorder_line__order=order, quantity_allocated__gt=0).exists()- send_order_canceled_confirmation_mock.assert_called_once_with(- order, None, mocked_get_plugins_manager()- )- send_order_canceled_confirmation_mock.assert_called_once_with(order, None)++ send_order_canceled_confirmation_mock.assert_called_once_with(order, None, manager)- @patch("saleor.order.actions.get_plugins_manager")@patch("saleor.order.actions.send_order_refunded_confirmation")def test_order_refunded(send_order_refunded_confirmation_mock,@@@ -386,7 -390,7 +383,10 @@@ def test_fulfill_digital_linesline.save()order_with_lines.refresh_from_db()-- automatically_fulfill_digital_lines(order_with_lines)++ manager = get_plugins_manager()++++ automatically_fulfill_digital_lines(order_with_lines, manager)++line.refresh_from_db()fulfillment = Fulfillment.objects.get(order=order_with_lines)fulfillment_lines = fulfillment.lines.all()diff --cc saleor/product/utils/availability.pyindex 9291bb2912,84fbbd1564..027cc81621--- a/saleor/product/utils/availability.py+++ b/saleor/product/utils/availability.py@@@ -147,14 -145,11 +146,12 @@@ def get_product_availabilitycollections: Iterable[Collection],discounts: Iterable[DiscountInfo],channel: Channel,+ manager: "PluginsManager",country: Optional[Country] = None,local_currency: Optional[str] = None,- plugins: Optional["PluginsManager"] = None,) -> ProductAvailability:+ country = country or Country(settings.DEFAULT_COUNTRY)with opentracing.global_tracer().start_active_span("get_product_availability"):- if not plugins:- plugins = get_plugins_manager()discounted = Nonediscounted_net_range = get_product_price_range(product=product,@@@ -225,14 -220,11 +222,12 @@@ def get_variant_availabilitycollections: Iterable[Collection],discounts: Iterable[DiscountInfo],channel: Channel,+ plugins: "PluginsManager",country: Optional[Country] = None,local_currency: Optional[str] = None,- plugins: Optional["PluginsManager"] = None,) -> VariantAvailability:+ country = country or Country(settings.DEFAULT_COUNTRY)with opentracing.global_tracer().start_active_span("get_variant_availability"):- if not plugins:- plugins = get_plugins_manager()discounted = plugins.apply_taxes_to_product(product,get_variant_price(