def build_submission self kwargs Return dict of data that contains eve

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def build_submission(self, **kwargs):
"""
Return a dict of data that contains everything required for an order
submission. This includes payment details (if any).
This can be the right place to perform tax lookups and apply them to
the basket.
"""
basket = kwargs.get('basket', self.request.basket)
shipping_address = self.get_shipping_address(basket)
shipping_method = self.get_shipping_method(
basket, shipping_address)
if not shipping_method:
total = None
else:
total = self.get_order_totals(
basket, shipping_method=shipping_method)
submission = {
'user': self.request.user,
'basket': basket,
'shipping_address': shipping_address,
'shipping_method': shipping_method,
'order_total': total,
'order_kwargs': {},
'payment_kwargs': {}}
# Allow overrides to be passed in
submission.update(kwargs)
# Set guest email after overrides as we need to update the order_kwargs
# entry.
if (not submission['user'].is_authenticated() and
'guest_email' not in submission['order_kwargs']):
email = self.checkout_session.get_guest_email()
submission['order_kwargs']['guest_email'] = email
return submission