Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Store customer id in user private meta
Jakub Draganek94f799cb04a1
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 7f870d8244..c662af98da 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -28,7 +28,7 @@ from ...core.taxes.interface import calculate_checkout_subtotalfrom ...discount import models as voucher_modelfrom ...payment import PaymentErrorfrom ...payment.interface import AddressData-from ...payment.utils import gateway_process_payment+from ...payment.utils import gateway_process_payment, store_id_for_payment_gatewayfrom ...shipping.models import ShippingMethod as ShippingMethodModelfrom ..account.i18n import I18nMixinfrom ..account.types import AddressInput, User@@ -507,13 +507,19 @@ class CheckoutComplete(BaseMutation):try:billing_address = order_data["billing_address"] # type: models.Addressshipping_address = order_data["shipping_address"] # type: models.Address- gateway_process_payment(+ trs = gateway_process_payment(payment=payment,payment_token=payment.token,billing_address=AddressData(**billing_address.as_data()),shipping_address=AddressData(**shipping_address.as_data()),store_source=store_source,)+ if trs.is_success and trs.customer_id:+ user = info.context.user+ if user:+ gateway = payment.gateway+ store_id_for_payment_gateway(user, gateway, trs.customer_id)+except PaymentError as e:abort_order_data(order_data)raise ValidationError(str(e))diff --git a/saleor/payment/utils.py b/saleor/payment/utils.pyindex 4fe320724a..f47ddf1160 100644--- a/saleor/payment/utils.py+++ b/saleor/payment/utils.py@@ -232,6 +232,7 @@ def create_transaction(amount=gateway_response.amount,currency=gateway_response.currency,error=gateway_response.error,+ customer_id=gateway_response.customer_id,gateway_response=gateway_response.raw_response or {},)return txn