ShippingRate
The ShippingRate resource lets you create and manage Stripe Shipping Rates for calculating shipping costs in checkout sessions and invoices.
Minimal Example
Section titled “Minimal Example”Create a standard shipping rate:
import { ShippingRate } from "alchemy/stripe";
const standardShipping = await ShippingRate("standard-shipping", { displayName: "Standard Shipping", type: "fixed_amount", fixedAmount: { amount: 500, currency: "usd", }, deliveryEstimate: { minimum: { unit: "business_day", value: 5 }, maximum: { unit: "business_day", value: 7 }, },});
Express Shipping Rate
Section titled “Express Shipping Rate”Create an express shipping option:
import { ShippingRate } from "alchemy/stripe";
const expressShipping = await ShippingRate("express-shipping", { displayName: "Express Shipping", type: "fixed_amount", fixedAmount: { amount: 1500, currency: "usd", }, deliveryEstimate: { minimum: { unit: "business_day", value: 1 }, maximum: { unit: "business_day", value: 2 }, }, taxBehavior: "exclusive", metadata: { priority: "high", service_level: "express", },});
Free Shipping Rate
Section titled “Free Shipping Rate”Create a free shipping option:
import { ShippingRate } from "alchemy/stripe";
const freeShipping = await ShippingRate("free-shipping", { displayName: "Free Shipping", type: "fixed_amount", fixedAmount: { amount: 0, currency: "usd", }, deliveryEstimate: { minimum: { unit: "business_day", value: 7 }, maximum: { unit: "business_day", value: 10 }, }, metadata: { promotion: "free_shipping_over_50", },});