Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add redirect url to order confirmation
IKarbowiakf19002ff0205
diff --git a/saleor/account/emails.py b/saleor/account/emails.pyindex 13748cbeb6..549a76b90a 100644--- a/saleor/account/emails.py+++ b/saleor/account/emails.py@@ -1,11 +1,11 @@-from urllib.parse import urlencode, urlsplit+from urllib.parse import urlencodefrom django.contrib.auth.tokens import default_token_generatorfrom templated_email import send_templated_mailfrom ..account import events as account_eventsfrom ..celeryconf import app-from ..core.emails import get_email_context+from ..core.emails import get_email_context, prepare_urldef send_user_password_reset_email_with_url(redirect_url, user):@@ -17,9 +17,8 @@ def send_user_password_reset_email_with_url(redirect_url, user):@app.taskdef _send_password_reset_email_with_url(recipient_email, redirect_url, user_id, token):params = urlencode({"email": recipient_email, "token": token})- reset_url = urlsplit(redirect_url)- reset_url = reset_url._replace(query=params)- _send_password_reset_email(recipient_email, reset_url.geturl(), user_id)+ reset_url = prepare_url(params, redirect_url)+ _send_password_reset_email(recipient_email, reset_url, user_id)def _send_password_reset_email(recipient_email, reset_url, user_id):@@ -80,9 +79,8 @@ def _send_set_user_password_email_with_url(recipient_email, redirect_url, token, template_name):params = urlencode({"email": recipient_email, "token": token})- password_set_url = urlsplit(redirect_url)- password_set_url = password_set_url._replace(query=params)- _send_set_password_email(recipient_email, password_set_url.geturl(), template_name)+ password_set_url = prepare_url(params, redirect_url)+ _send_set_password_email(recipient_email, password_set_url, template_name)def _send_set_password_email(recipient_email, password_set_url, template_name):diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex e139b7db2d..141a053cbe 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -1163,7 +1163,9 @@ def abort_order_data(order_data: dict):@transaction.atomic-def create_order(*, checkout: Checkout, order_data: dict, user: User) -> Order:+def create_order(+ *, checkout: Checkout, order_data: dict, user: User, redirect_url: str+) -> Order:"""Create an order from the checkout.Each order will get a private copy of both the billing and the shipping@@ -1204,7 +1206,7 @@ def create_order(*, checkout: Checkout, order_data: dict, user: User) -> Order:order_created(order=order, user=user)# Send the order confirmation email- send_order_confirmation.delay(order.pk, user.pk)+ send_order_confirmation.delay(order.pk, redirect_url, user.pk)return orderdiff --git a/saleor/core/emails.py b/saleor/core/emails.pyindex 8fe253e6e8..17c87f0ade 100644--- a/saleor/core/emails.py+++ b/saleor/core/emails.py@@ -1,3 +1,5 @@+from urllib.parse import urlsplit+from django.contrib.sites.models import Sitefrom django.templatetags.static import static@@ -14,3 +16,9 @@ def get_email_context():"site_name": site.name,}return send_email_kwargs, email_template_context+++def prepare_url(params: str, redirect_url: str) -> str:+ split_url = urlsplit(redirect_url)+ split_url = split_url._replace(query=params)+ return split_url.geturl()diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 23488b0246..d8328dffa7 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -7,6 +7,7 @@ from django.db import transactionfrom django.db.models import Prefetchfrom django.utils import timezone+from ...account.error_codes import AccountErrorCodefrom ...checkout import modelsfrom ...checkout.error_codes import CheckoutErrorCodefrom ...checkout.utils import (@@ -29,6 +30,7 @@ from ...checkout.utils import (from ...core import analyticsfrom ...core.exceptions import InsufficientStockfrom ...core.taxes import TaxError+from ...core.utils.url import validate_storefront_urlfrom ...discount import models as voucher_modelfrom ...payment import PaymentError, gateway, models as payment_modelsfrom ...payment.interface import AddressData@@ -632,6 +634,13 @@ class CheckoutComplete(BaseMutation):"Determines whether to store the payment source for future usage."),)+ redirect_url = graphene.String(+ required=False,+ description=(+ "URL of a view where users should be redirected to "+ "see the order details. URL in RFC 1808 format."+ ),+ )class Meta:description = (@@ -643,7 +652,7 @@ class CheckoutComplete(BaseMutation):error_type_field = "checkout_errors"@classmethod- def perform_mutation(cls, _root, info, checkout_id, store_source):+ def perform_mutation(cls, _root, info, checkout_id, store_source, **data):checkout = cls.get_node_or_error(info,checkout_id,@@ -712,8 +721,22 @@ class CheckoutComplete(BaseMutation):if txn.customer_id and user.is_authenticated:store_customer_id(user, payment.gateway, txn.customer_id)+ redirect_url = data.get("redirect_url", "")+ if redirect_url:+ try:+ validate_storefront_url(redirect_url)+ except ValidationError as error:+ raise ValidationError(+ {"redirect_url": error}, code=AccountErrorCode.INVALID+ )+# create the order into the database- order = create_order(checkout=checkout, order_data=order_data, user=user)+ order = create_order(+ checkout=checkout,+ order_data=order_data,+ user=user,+ redirect_url=redirect_url,+ )# remove checkout after order is successfully paidcheckout.delete()diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex dc939255a0..fdfd8a6c1f 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -2204,7 +2204,7 @@ type Mutation {tokenVerify(token: String!): VerifyTokencheckoutAddPromoCode(checkoutId: ID!, promoCode: String!): CheckoutAddPromoCodecheckoutBillingAddressUpdate(billingAddress: AddressInput!, checkoutId: ID!): CheckoutBillingAddressUpdate- checkoutComplete(checkoutId: ID!, storeSource: Boolean = false): CheckoutComplete+ checkoutComplete(checkoutId: ID!, redirectUrl: String, storeSource: Boolean = false): CheckoutCompletecheckoutCreate(input: CheckoutCreateInput!): CheckoutCreatecheckoutCustomerAttach(checkoutId: ID!, customerId: ID!): CheckoutCustomerAttachcheckoutCustomerDetach(checkoutId: ID!): CheckoutCustomerDetachdiff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex cce1e0b050..ac97d69a5f 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -1,8 +1,9 @@+from urllib.parse import urlencode+from templated_email import send_templated_mailfrom ..celeryconf import app-from ..core.emails import get_email_context-from ..core.utils import build_absolute_uri+from ..core.emails import get_email_context, prepare_urlfrom ..seo.schema.email import get_order_confirmation_markupfrom . import eventsfrom .models import Fulfillment, Order@@ -13,19 +14,17 @@ UPDATE_FULFILLMENT_TEMPLATE = "order/update_fulfillment"CONFIRM_PAYMENT_TEMPLATE = "order/payment/confirm_payment"-def collect_data_for_email(order_pk, template):- """Collect the required data for sending emails.-- Args:- order_pk (int): order primary key- template (str): email template path-- """+def collect_data_for_email(+ order_pk: int, template: str, redirect_url: str = ""+) -> dict:+ """Collect the required data for sending emails."""order = Order.objects.get(pk=order_pk)recipient_email = order.get_customer_email()send_kwargs, email_context = get_email_context()- # TODO: in #5022- email_context["order_details_url"] = build_absolute_uri(order.get_absolute_url())++ email_context["order_details_url"] = (+ prepare_order_details_url(order, redirect_url) if redirect_url else ""+ )email_context["order"] = order# Order confirmation template requires additional information@@ -41,6 +40,11 @@ def collect_data_for_email(order_pk, template):}+def prepare_order_details_url(order: Order, redirect_url: str) -> str:+ params = urlencode({"token": order.token})+ return prepare_url(params, redirect_url)++def collect_data_for_fullfillment_email(order_pk, template, fulfillment_pk):fulfillment = Fulfillment.objects.get(pk=fulfillment_pk)email_data = collect_data_for_email(order_pk, template)@@ -59,9 +63,9 @@ def collect_data_for_fullfillment_email(order_pk, template, fulfillment_pk):@app.task-def send_order_confirmation(order_pk, user_pk=None):+def send_order_confirmation(order_pk, redirect_url, user_pk=None):"""Send order confirmation email."""- email_data = collect_data_for_email(order_pk, CONFIRM_ORDER_TEMPLATE)+ email_data = collect_data_for_email(order_pk, CONFIRM_ORDER_TEMPLATE, redirect_url)send_templated_mail(**email_data)events.email_sent_event(order=email_data["context"]["order"],diff --git a/templates/templated_email/order/payment/confirm_payment.email b/templates/templated_email/order/payment/confirm_payment.emailindex 22075bef9c..eec15e87fb 100644--- a/templates/templated_email/order/payment/confirm_payment.email+++ b/templates/templated_email/order/payment/confirm_payment.email@@ -7,8 +7,8 @@{% block plain %}{% include 'templated_email/shared/_header.email' %}{% blocktrans context "Payment confirmation email text" %}-Thank you for your payment. To see your payment details please visit:-{{ order_details_url }}+Thank you for your payment.+Your payment was successful charged.{% endblocktrans %}{% include 'templated_email/shared/_footer.email' %}{% endblock %}diff --git a/tests/api/benchmark/test_checkout.py b/tests/api/benchmark/test_checkout.pyindex c03ac87e91..1ef2dfc5d8 100644--- a/tests/api/benchmark/test_checkout.py+++ b/tests/api/benchmark/test_checkout.py@@ -492,8 +492,8 @@ def test_checkout_payment_charge(@pytest.mark.count_queries(autouse=False)def test_complete_checkout(api_client, checkout_with_charged_payment, count_queries):query = """- mutation completeCheckout($checkoutId: ID!) {- checkoutComplete(checkoutId: $checkoutId) {+ mutation completeCheckout($checkoutId: ID!, $redirectUrl: String) {+ checkoutComplete(checkoutId: $checkoutId, redirectUrl: $redirectUrl) {errors {fieldmessage@@ -507,7 +507,8 @@ def test_complete_checkout(api_client, checkout_with_charged_payment, count_quer"""variables = {- "checkoutId": Node.to_global_id("Checkout", checkout_with_charged_payment.pk)+ "checkoutId": Node.to_global_id("Checkout", checkout_with_charged_payment.pk),+ "redirectUrl": "https://www.example.com",}get_graphql_content(api_client.post_graphql(query, variables))diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex 84da3c0654..9b6bb60e05 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -1131,8 +1131,8 @@ def test_checkout_email_update_validation(user_api_client, checkout_with_item):MUTATION_CHECKOUT_COMPLETE = """- mutation checkoutComplete($checkoutId: ID!) {- checkoutComplete(checkoutId: $checkoutId) {+ mutation checkoutComplete($checkoutId: ID!, $redirectUrl: String) {+ checkoutComplete(checkoutId: $checkoutId, redirectUrl: $redirectUrl) {order {id,token@@ -1181,7 +1181,7 @@ def test_checkout_complete(orders_count = Order.objects.count()checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)content = get_graphql_content(response)@@ -1285,7 +1285,7 @@ def test_checkout_complete_does_not_delete_checkout_after_unsuccessful_payment(orders_count = Order.objects.count()checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)get_graphql_content(response)@@ -1307,7 +1307,7 @@ def test_checkout_complete_does_not_delete_checkout_after_unsuccessful_payment(def test_checkout_complete_invalid_checkout_id(user_api_client):checkout_id = "invalidId"- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}orders_count = Order.objects.count()response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)content = get_graphql_content(response)@@ -1326,7 +1326,7 @@ def test_checkout_complete_no_payment(checkout.billing_address = addresscheckout.save()checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}orders_count = Order.objects.count()response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)content = get_graphql_content(response)@@ -1358,7 +1358,7 @@ def test_checkout_complete_insufficient_stock(payment.checkout = checkoutpayment.save()checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}orders_count = Order.objects.count()response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)content = get_graphql_content(response)@@ -1367,6 +1367,72 @@ def test_checkout_complete_insufficient_stock(assert orders_count == Order.objects.count()+def test_checkout_complete_without_redirect_url(+ user_api_client,+ checkout_with_gift_card,+ gift_card,+ payment_dummy,+ address,+ shipping_method,+):++ assert not gift_card.last_used_on++ checkout = checkout_with_gift_card+ checkout.shipping_address = address+ checkout.shipping_method = shipping_method+ checkout.billing_address = address+ checkout.save()++ checkout_line = checkout.lines.first()+ checkout_line_quantity = checkout_line.quantity+ checkout_line_variant = checkout_line.variant++ gift_current_balance = checkout.get_total_gift_cards_balance()+ total = calculations.checkout_total(checkout)+ payment = payment_dummy+ payment.is_active = True+ payment.order = None+ payment.total = total.gross.amount+ payment.currency = total.gross.currency+ payment.checkout = checkout+ payment.save()+ assert not payment.transactions.exists()++ orders_count = Order.objects.count()+ checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)+ variables = {"checkoutId": checkout_id}+ response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)++ content = get_graphql_content(response)+ data = content["data"]["checkoutComplete"]+ assert not data["errors"]++ order_token = data["order"]["token"]+ assert Order.objects.count() == orders_count + 1+ order = Order.objects.first()+ assert order.token == order_token+ assert order.total.gross == total.gross - gift_current_balance++ order_line = order.lines.first()+ assert checkout_line_quantity == order_line.quantity+ assert checkout_line_variant == order_line.variant+ assert order.shipping_address == address+ assert order.shipping_method == checkout.shipping_method+ assert order.payments.exists()+ order_payment = order.payments.first()+ assert order_payment == payment+ assert payment.transactions.count() == 1++ gift_card.refresh_from_db()+ assert gift_card.current_balance == zero_money()+ assert gift_card.last_used_on++ assert not Checkout.objects.filter(+ pk=checkout.pk+ ).exists(), "Checkout should have been deleted"++def test_fetch_checkout_by_token(user_api_client, checkout_with_item):query = """query getCheckout($token: UUID!) {diff --git a/tests/api/test_checkout_digital.py b/tests/api/test_checkout_digital.pyindex b13e2aba7f..79f52663af 100644--- a/tests/api/test_checkout_digital.py+++ b/tests/api/test_checkout_digital.py@@ -169,7 +169,7 @@ def test_checkout_complete(order_count = Order.objects.count()checkout = checkout_with_digital_itemcheckout_id = Node.to_global_id("Checkout", checkout.pk)- variables = {"checkoutId": checkout_id}+ variables = {"checkoutId": checkout_id, "redirectUrl": "https://www.example.com"}# Set a billing addresscheckout.billing_address = addressdiff --git a/tests/test_asynchronous_tasks.py b/tests/test_asynchronous_tasks.pyindex 0e3c876b12..69b50225ea 100644--- a/tests/test_asynchronous_tasks.py+++ b/tests/test_asynchronous_tasks.py@@ -7,7 +7,8 @@ from saleor.order.emails import send_order_confirmation, send_payment_confirmatidef test_email_sending_asynchronously(transactional_db, celery_app, celery_worker, order_with_lines):- order = send_order_confirmation.delay(order_with_lines.pk)+ redirect_url = "https://www.example.com"+ order = send_order_confirmation.delay(order_with_lines.pk, redirect_url)payment = send_payment_confirmation.delay(order_with_lines.pk)order.get()payment.get()diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex cdae427ee5..0d58e219e0 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -103,6 +103,7 @@ def test_create_order_creates_expected_events(checkout=checkout, tracking_code="tracking_code", discounts=None),user=customer_user if not is_anonymous_user else AnonymousUser(),+ redirect_url="https://www.example.com",)# Ensure only two events were created, and retrieve them@@ -167,10 +168,20 @@ def test_create_order_doesnt_duplicate_order(order_data = prepare_order_data(checkout=checkout, tracking_code="", discounts=None)- order_1 = create_order(checkout=checkout, order_data=order_data, user=customer_user)+ order_1 = create_order(+ checkout=checkout,+ order_data=order_data,+ user=customer_user,+ redirect_url="https://www.example.com",+ )assert order_1.checkout_token == checkout.token- order_2 = create_order(checkout=checkout, order_data=order_data, user=customer_user)+ order_2 = create_order(+ checkout=checkout,+ order_data=order_data,+ user=customer_user,+ redirect_url="https://www.example.com",+ )assert order_1.pk == order_2.pk@@ -199,6 +210,7 @@ def test_create_order_with_gift_card(checkout=checkout, tracking_code="tracking_code", discounts=None),user=customer_user if not is_anonymous_user else AnonymousUser(),+ redirect_url="https://www.example.com",)assert order.gift_cards.count() == 1@@ -228,6 +240,7 @@ def test_create_order_with_gift_card_partial_use(checkout=checkout, tracking_code="tracking_code", discounts=None),user=customer_user,+ redirect_url="https://www.example.com",)gift_card_used.refresh_from_db()@@ -271,6 +284,7 @@ def test_create_order_with_many_gift_cards(checkout=checkout, tracking_code="tracking_code", discounts=None),user=customer_user,+ redirect_url="https://www.example.com",)gift_card_created_by_staff.refresh_from_db()@@ -296,6 +310,7 @@ def test_note_in_created_order(request_checkout_with_item, address, customer_usediscounts=None,),user=customer_user,+ redirect_url="https://www.example.com",)assert order.customer_note == request_checkout_with_item.notediff --git a/tests/test_emails.py b/tests/test_emails.pyindex a5464c9ba4..38f69cc0fa 100644--- a/tests/test_emails.py+++ b/tests/test_emails.py@@ -1,4 +1,5 @@from unittest import mock+from urllib.parse import urlencodeimport pytestfrom django.core import mail@@ -8,7 +9,7 @@ from templated_email import get_connectionimport saleor.account.emails as account_emailsimport saleor.order.emails as emails-from saleor.core.emails import get_email_context+from saleor.core.emails import get_email_context, prepare_urlfrom saleor.core.utils import build_absolute_urifrom saleor.order.utils import add_variant_to_order@@ -60,18 +61,10 @@ def test_collect_data_for_email(order):assert "schema_markup" not in email_context- "send_email,template",- [- (emails.send_payment_confirmation, emails.CONFIRM_PAYMENT_TEMPLATE),- (emails.send_order_confirmation, emails.CONFIRM_ORDER_TEMPLATE),- ],-)@mock.patch("saleor.order.emails.send_templated_mail")-def test_send_emails(- mocked_templated_email, order, template, send_email, site_settings-):- send_email(order.pk)+def test_send_email_payment_confirmation(mocked_templated_email, order, site_settings):+ template = emails.CONFIRM_PAYMENT_TEMPLATE+ emails.send_payment_confirmation(order.pk)email_data = emails.collect_data_for_email(order.pk, template)recipients = [order.get_customer_email()]@@ -91,27 +84,45 @@ def test_send_emails(email_connection.get_email_message(to=recipients, **expected_call_kwargs)- "send_email,template",- [- (emails.send_payment_confirmation, emails.CONFIRM_PAYMENT_TEMPLATE),- (emails.send_order_confirmation, emails.CONFIRM_ORDER_TEMPLATE),- ],-)@mock.patch("saleor.order.emails.send_templated_mail")-def test_send_confirmation_emails_without_addresses(- mocked_templated_email, order, template, send_email, site_settings, digital_content+def test_send_email_order_confirmation(mocked_templated_email, order, site_settings):+ template = emails.CONFIRM_ORDER_TEMPLATE+ redirect_url = "https://www.example.com"+ emails.send_order_confirmation(order.pk, redirect_url)+ email_data = emails.collect_data_for_email(order.pk, template, redirect_url)++ recipients = [order.get_customer_email()]++ expected_call_kwargs = {+ "context": email_data["context"],+ "from_email": site_settings.default_from_email,+ "template_name": template,+ }++ mocked_templated_email.assert_called_once_with(+ recipient_list=recipients, **expected_call_kwargs+ )++ # Render the email to ensure there is no error+ email_connection = get_connection()+ email_connection.get_email_message(to=recipients, **expected_call_kwargs)++[email protected]("saleor.order.emails.send_templated_mail")+def test_send_confirmation_emails_without_addresses_for_payment(+ mocked_templated_email, order, site_settings, digital_content):assert not order.lines.count()+ template = emails.CONFIRM_PAYMENT_TEMPLATEadd_variant_to_order(order, digital_content.product_variant, quantity=1)order.shipping_address = Noneorder.shipping_method = Noneorder.billing_address = Noneorder.save(update_fields=["shipping_address", "shipping_method", "billing_address"])- send_email(order.pk)+ emails.send_payment_confirmation(order.pk)email_data = emails.collect_data_for_email(order.pk, template)recipients = [order.get_customer_email()]@@ -131,6 +142,41 @@ def test_send_confirmation_emails_without_addresses(email_connection.get_email_message(to=recipients, **expected_call_kwargs)[email protected]("saleor.order.emails.send_templated_mail")+def test_send_confirmation_emails_without_addresses_for_order(+ mocked_templated_email, order, site_settings, digital_content+):++ assert not order.lines.count()++ template = emails.CONFIRM_ORDER_TEMPLATE+ add_variant_to_order(order, digital_content.product_variant, quantity=1)+ 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"+ emails.send_order_confirmation(order.pk, redirect_url)+ email_data = emails.collect_data_for_email(order.pk, template, redirect_url)++ recipients = [order.get_customer_email()]++ expected_call_kwargs = {+ "context": email_data["context"],+ "from_email": site_settings.default_from_email,+ "template_name": template,+ }++ mocked_templated_email.assert_called_once_with(+ recipient_list=recipients, **expected_call_kwargs+ )++ # Render the email to ensure there is no error+ email_connection = get_connection()+ email_connection.get_email_message(to=recipients, **expected_call_kwargs)++@pytest.mark.parametrize("send_email,template",[@@ -204,3 +250,10 @@ def test_send_set_password_email(staff_user, site_settings):assert len(mail.outbox) == 1sended_message = mail.outbox[0].bodyassert password_set_url in sended_message+++def test_prepare_url():+ redirect_url = "https://www.example.com"+ params = urlencode({"param1": "abc", "param2": "xyz"})+ result = prepare_url(params, redirect_url)+ assert result == "https://www.example.com?param1=abc¶m2=xyz"