Medusa Square Services Plugin.
A full-featured Square integration plugin for Medusa v2. Handles payment processing, OAuth account linking, bidirectional catalog/customer/inventory sync, and Apple Pay domain registration — all configurable from the admin dashboard at runtime.
yarn add @weareseeed/medusa-square-plugin# ornpm install @weareseeed/medusa-square-plugin
import { defineConfig } from "@medusajs/framework/utils"export default defineConfig({modules: [// Register Square as a payment provider{resolve: "@medusajs/medusa/payment",options: {providers: [{resolve: "@weareseeed/medusa-square-plugin/providers/square-payment",id: "square",},],},},],plugins: [{resolve: "@weareseeed/medusa-square-plugin",options: {},},],})
No options are required. All configuration is managed through the Admin UI.
npx medusa db:migrate
This creates the table used by the plugin.
| Variable | Description | Default | Required |
|---|---|---|---|
| Public URL of your Medusa backend, used as the OAuth redirect base | Yes (production) |
# .env (development)MEDUSA_BACKEND_URL=http://localhost:9000# .env (production)MEDUSA_BACKEND_URL=https://api.yourdomain.com
The OAuth callback will be registered at .
After installing, a Square section appears under your Medusa Admin settings. It has three tabs:
Use — the official React wrapper around the Square Web Payments SDK, built by the same team — to collect payment details on your storefront.
yarn add react-square-web-payments-sdk# ornpm install react-square-web-payments-sdk
Before rendering the payment form, fetch the public Square config from the store endpoint to get the and :
Response:
{"location_id": "XXXXXXXXX","application_id": "xxxxx-xxxxxx-xxxxxxxxx","currency": "XXX","capabilities": ["CREDIT_CARD_PROCESSING","AUTOMATIC_TRANSFERS"]}
Wrap your checkout with and drop in the component. The SDK handles input rendering and tokenization.
import { PaymentForm, CreditCard } from "react-square-web-payments-sdk"import { CartDTO } from "@medusajs/types";const PAYMENT_PROVIDER_SQUARE = "pp_square_square";interface SquareConfig {application_id: stringlocation_id: stringcurrency: string}export function SquareCheckout({ config , cart }: { config: SquareConfig , cart: CartDTO }) {return (<PaymentFormapplicationId={config.application_id}locationId={config.location_id}cardTokenizeResponseReceived={async (token, buyer) => {// Pass it to your Medusa payment sessionawait initiatePaymentSession(cart, {provider_id: PAYMENT_PROVIDER_SQUARE,data: { token, buyer, cart_id: cart?.id },});}}createPaymentRequest={() => {// Payment request configurationreturn {requestShippingAddress: false,requestBillingInfo: true,currencyCode: config.currency,countryCode:"US", // Store Country Codetotal: {label: "My Store",amount: cart.total.toString(),},};}}><CreditCard /></PaymentForm>)}
The plugin supports bidirectional sync between Medusa and Square.
Event subscribers listen for Medusa events and push updates to Square:
| Medusa Event | Syncs To Square |
|---|---|
| / | Catalog item |
| / | Catalog item variation |
| / | Catalog category |
| / | Customer |
These run only when / are enabled in the config.
Trigger from the Admin UI or programmatically:
Medusa → Square ()
Square → Medusa ()
import {syncMedusaSquareWorkflow,syncSquareMedusaWorkflow,} from "@weareseeed/medusa-square-plugin/workflows"// Inside a Medusa workflow or API route:await syncMedusaSquareWorkflow(container).run()await syncSquareMedusaWorkflow(container).run()
All routes are prefixed with your Medusa backend URL.
Require admin authentication.
| Method | Path | Description |
|---|---|---|
| Get active Square configuration | ||
| Update metadata/settings | ||
| List available Square locations | ||
| Set active location | ||
| Start OAuth flow (redirect to Square) | ||
| OAuth callback handler | ||
| Disconnect Square account | ||
| Register Apple Pay domain |
Public endpoints for storefront use.
| Method | Path | Description |
|---|---|---|
| Get public Square config (application ID, location, currency, capabilities) | ||
| Check plugin availability |
The plugin exports Medusa v2 workflows that can be composed into your own workflows:
import { getSquareConfigWorkflow } from "@weareseeed/medusa-square-plugin/workflows"// Retrieve the active Square configurationconst { result } = await getSquareConfigWorkflow(container).run()
| Export | Description |
|---|---|
| Returns the active record | |
| Full Medusa → Square data sync | |
| Full Square → Medusa data sync |
Make sure is set to your publicly accessible backend URL before starting the OAuth flow, otherwise the redirect will fail.
After connecting:
In the Settings tab:
| Square Status | Medusa Status |
|---|---|