diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py
index 70b6d8728364ccf8a03e13862aea56a73f249958..8804ca6f3e64473fd65341ce6bba25b89e393925 100644
--- a/addons/sale/controllers/portal.py
+++ b/addons/sale/controllers/portal.py
@@ -343,7 +343,7 @@ class PaymentPortal(payment_portal.PaymentPortal):
             # Check the access token against the order values. Done after fetching the order as we
             # need the order fields to check the access token.
             if not payment_utils.check_access_token(
-                access_token, order_sudo.partner_id.id, amount, order_sudo.currency_id.id
+                access_token, order_sudo.partner_invoice_id.id, amount, order_sudo.currency_id.id
             ):
                 raise ValidationError(_("The provided parameters are invalid."))
 
diff --git a/addons/sale/tests/test_payment_flow.py b/addons/sale/tests/test_payment_flow.py
index 770b3f9493b8a7f537fe5c5d5edf92b349c0c203..8d8f3f884b8d974b1e54c8b4ac2d0015c025e9ea 100644
--- a/addons/sale/tests/test_payment_flow.py
+++ b/addons/sale/tests/test_payment_flow.py
@@ -19,7 +19,7 @@ class TestSalePayment(AccountPaymentCommon, SaleCommon, PaymentHttpCommon):
 
         # Replace PaymentCommon defaults by SaleCommon ones
         cls.currency = cls.sale_order.currency_id
-        cls.partner = cls.sale_order.partner_id
+        cls.partner = cls.sale_order.partner_invoice_id
 
     def test_11_so_payment_link(self):
         # test customized /payment/pay route with sale_order_id param
@@ -70,6 +70,17 @@ class TestSalePayment(AccountPaymentCommon, SaleCommon, PaymentHttpCommon):
         self.assertTrue(tx_sudo.payment_id)
         self.assertEqual(tx_sudo.payment_id.state, 'posted')
 
+    def test_so_payment_link_with_different_partner_invoice(self):
+        # test customized /payment/pay route with sale_order_id param
+        # partner_id and partner_invoice_id different on the so
+        self.sale_order.partner_invoice_id = self.portal_partner
+        self.partner = self.sale_order.partner_invoice_id
+        route_values = self._prepare_pay_values()
+        route_values['sale_order_id'] = self.sale_order.id
+
+        tx_context = self._get_tx_checkout_context(**route_values)
+        self.assertEqual(tx_context['partner_id'], self.sale_order.partner_invoice_id.id)
+
     def test_12_so_partial_payment_link(self):
         # test customized /payment/pay route with sale_order_id param
         # partial amount specified