get_quote
Calculate shipping costs and USDC payment amount for hats purchased with cryptocurrency, then receive the wallet address to complete your transaction.
Instructions
Get a shipping quote and USDC payment amount for a product. Returns the wallet address to send payment to.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variant_id | Yes | Shopify variant ID | |
| shipping_name | Yes | Recipient full name | |
| shipping_address1 | Yes | Street address | |
| shipping_city | Yes | City | |
| shipping_state | Yes | State (2-letter code) | |
| shipping_zip | Yes | ZIP code | |
| shipping_country | No | Country code (default: US) |
Implementation Reference
- main.py:307-350 (handler)The `get_quote` handler calculates the product price and shipping, generates a unique quote ID, stores the quote details, and returns the payment instructions in USDC on the Base network.
async def get_quote(request: Request): body = await request.json() variant_id = body.get("variant_id") quantity = body.get("quantity", 1) address = body.get("shipping_address", {}) # Get variant price from Shopify data = await shopify_get(f"variants/{variant_id}.json") variant = data["variant"] unit_price = float(variant["price"]) subtotal = unit_price * quantity # Standard shipping estimate (US $5, international $15) country = address.get("country_code", "US") shipping = 5.0 if country == "US" else 15.0 total_usdc = round(subtotal + shipping, 2) quote_id = make_quote_id(variant_id, quantity) _quotes[quote_id] = { "variant_id": variant_id, "quantity": quantity, "total_usdc": total_usdc, "shipping_address": address, "expires_at": time.time() + 600, # 10 min "product_title": variant.get("title", ""), } return { "quote_id": quote_id, "product": variant.get("title", ""), "quantity": quantity, "subtotal_usdc": subtotal, "shipping_usdc": shipping, "total_usdc": total_usdc, "payment_wallet": PAYMENT_WALLET, "network": "base", "token": "USDC", "token_contract": USDC_CONTRACT, "instructions": ( f"Send exactly {total_usdc} USDC on Base network to {PAYMENT_WALLET}, " f"then call place_order with the transaction hash and this quote_id." ), "expires_in": "10 minutes", }