Принимайте платежи через Square
Medusa Square Payment is a basic integration of payment provider for Square Payment.
Warning
1...2"@rsc-labs/medusa-square-payment": "0.0.1" // or other available version3...
and execute install, e.g. .
1...2 plugins: [3 {4 resolve: "@rsc-labs/medusa-square-payment",5 options: {6 token: <app-token>,7 environment: <env-definition>,8 },9 }10 ],11 modules: [12 {13 resolve: "@medusajs/medusa/payment",14 options: {15 providers: [16 {17 resolve: "@rsc-labs/medusa-square-payment/providers/square-payment",18 id: "square-payment",19 options: {20 token: <app-token>,21 environment: <env-definition>,22 },23 }24 ]25 },26 },27...
The basic implementation of Square payment provider gives the possibility to make a payment in your storefront.
Plugin uses 1 required parameter and 1 optional:
After above configuration, you can then add the payment provider to your reqion.
We recommend using package on your storefront as it simplifies the implementation a lot. Here is the example of using credit card as payment:
1import { PaymentForm, CreditCard as SquareCreditCard } from 'react-square-web-payments-sdk';2...34const handleSquareSubmit = async (token: string) => {5 setIsLoading(true)6 try {7 if (!activeSession) {8 await initiatePaymentSession(cart,9 {10 provider_id: selectedPaymentMethod,11 data: {12 cartId: cart?.id,13 token: token14 }15 })16 }1718 return router.push(19 pathname + "?" + createQueryString("step", "review"),20 {21 scroll: false,22 }23 )24 } catch (err: any) {25 setError(err.message)26 } finally {27 setIsLoading(false)28 }29 }30{isSquare(selectedPaymentMethod) &&31 <div>32 <PaymentForm33 applicationId="<application-id>"34 cardTokenizeResponseReceived={(token, verifiedBuyer) => {35 handleSquareSubmit(token.token!);36 }}37 locationId='XXXXXXXXXX'38 >39 <SquareCreditCard/>40 </PaymentForm>41 </div>42}
- you can retrieve it from your Square Developer Dashboard.
Plugin does not support refunds and cancels. It has been tested using only credit card - when authorized, it captures money automatically.
MIT
© 2025 RSC https://rsoftcon.com/