Capture the payment for a basket and create an order

    request.data should contain:

    'address': Dict with the following fields:
        shipping_name
        shipping_address_line1
        shipping_address_city
        shipping_address_zip
        shipping_address_country
        billing_name
        billing_address_line1
        billing_address_city
        billing_address_zip
        billing_address_country

    'email': Email address of the customer
    'shipping': The shipping rate (in the sites' currency)

def capture_payment(request):
    """
    Capture the payment for a basket and create an order

    request.data should contain:

    'address': Dict with the following fields:
        shipping_name
        shipping_address_line1
        shipping_address_city
        shipping_address_zip
        shipping_address_country
        billing_name
        billing_address_line1
        billing_address_city
        billing_address_zip
        billing_address_country

    'email': Email address of the customer
    'shipping': The shipping rate (in the sites' currency)
    """
    # get request data
    address = request.data['address']
    email = request.data.get('email', None)
    shipping_option = request.data.get('shipping_option', None)

    # Capture the payment
    order = create_order(
        email,
        request,
        addresses=address,
        shipping_option=shipping_option,
        capture_payment=True
    )
    response = Response(data={"order_id": order.id},
                        status=status.HTTP_201_CREATED)

    return response