def ecommerce_order_summary(orderid): logger.debug("ecommerce_order_summary()") active_order = None user_info = get_userinfo() okta_auth = OktaAuth(session[SESSION_INSTANCE_SETTINGS_KEY]) storefront_system_token = okta_auth.get_oauth_system_token( session[SESSION_INSTANCE_SETTINGS_KEY]['settings'] ['storefront_system_client_id'], session[SESSION_INSTANCE_SETTINGS_KEY] ['settings']['storefront_system_client_secret'], session[SESSION_INSTANCE_SETTINGS_KEY]['settings'] ['storefront_system_client_scopes']) storefront = StorefrontFactory.getStorefrontProvider( session[SESSION_INSTANCE_SETTINGS_KEY]['settings'], user_info, TokenUtil.get_access_token(request.cookies), storefront_system_token['access_token']) if orderid is None: active_order = session["just_submitted_order_id"] del session["just_submitted_order_id"] else: active_order = orderid order = storefront.getOrder(active_order) return render_template("ecommerce/ordersummary.html", order=order, config=session[SESSION_INSTANCE_SETTINGS_KEY], _scheme="https")
def ecommerce_order_post(): user_info = get_userinfo() okta_admin = OktaAdmin(session[SESSION_INSTANCE_SETTINGS_KEY]) okta_auth = OktaAuth(session[SESSION_INSTANCE_SETTINGS_KEY]) storefront_system_token = okta_auth.get_oauth_system_token( session[SESSION_INSTANCE_SETTINGS_KEY]['settings'] ['storefront_system_client_id'], session[SESSION_INSTANCE_SETTINGS_KEY] ['settings']['storefront_system_client_secret'], session[SESSION_INSTANCE_SETTINGS_KEY]['settings'] ['storefront_system_client_scopes']) storefront = StorefrontFactory.getStorefrontProvider( session[SESSION_INSTANCE_SETTINGS_KEY]['settings'], user_info, TokenUtil.get_access_token(request.cookies), storefront_system_token['access_token']) cartId = None userId = None logger.debug("ecommerce_order_post()") logger.debug(request.form) if not user_info: cartId = session['guest_cart_id'] userId = request.form.get("email") else: cartId = session['customer_cart_id'] userId = user_info['email'] orderAddress = OrderShipAddress(request.form.get("firstName"), request.form.get("lastName"), request.form.get("address"), request.form.get("city"), request.form.get("state"), request.form.get("country"), request.form.get("zip")) orderBilling = OrderBillingInfo(request.form.get("cc-name"), request.form.get("cc-number"), 'visa', request.form.get("cc-expiration-month"), request.form.get("cc-expiration-year"), '1234') order = Order(None, None, orderAddress, orderBilling, None, None, None) #Post the order orderResponse = storefront.order(cartId, userId, order) session["just_submitted_order_id"] = orderResponse["orderId"] if "customer_cart_id" in session: del session['customer_cart_id'] if "guest_cart_id" in session: del session['guest_cart_id'] return redirect( url_for("ecommerce_views_bp.ecommerce_order_summary", _external="True", _scheme=session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"], message="Order Complete", orderid=orderResponse["orderId"]))