PayPal
Use PayPal as payment provider
Medusa Paypal Payment
What is it?
Medusa Paypal Payment is a basic integration of payment provider for Paypal.
Installation
- Install plugin by adding to your Copy to clipboard
package.json:
Warning
123..."@rsc-labs/medusa-paypal-payment": "0.0.1" // or other available version...
and execute install, e.g. Copy to clipboardyarn install.
- Add plugin to your Copy to clipboard
medusa-config.js(Note - please notice that you need to add it to payment plugin):
1234567891011121314151617181920...plugins: [{resolve: "@rsc-labs/medusa-paypal-payment",options: {oAuthClientId: <oauth-client-id>,oAuthClientSecret: <oauth-client-secret>,environment: <env-definition>,},}],modules: [{resolve: "@medusajs/medusa/payment",options: {providers: [{resolve: "@rsc-labs/medusa-paypal-payment/providers/paypal-payment",id: "paypal-payment",options: {
Overview
The Paypal Provider gives ability to:
- make a payment using Paypal
- cancel payment
- refund payment
- track payments in Paypal
Configuration
Plugin uses 3 required parameters:
- Copy to clipboard
oAuthClientId- required parameter which you can find in your Paypal Developer Dashboard - Copy to clipboard
oAuthClientSecret- required parameter which you can find in your Paypal Developer Dashboard - Copy to clipboard
environment- set to Copy to clipboardsandboxor Copy to clipboardproduction. You can use it to test with your Copy to clipboardsandboxenvironment.
After above configuration, you can then add the payment provider to your reqion.
Storefront
We recommend using Copy to clipboard@paypal/react-paypal-js package on your storefront as it simplifies the implementation a lot. Here is the example of using Paypal as payment:
1234567891011121314151617181920import { OnApproveActions, OnApproveData } from "@paypal/paypal-js"import { PayPalButtons, usePayPalScriptReducer } from "@paypal/react-paypal-js"...const PayPalPaymentButton = ({cart,notReady,"data-testid": dataTestId,}: {cart: HttpTypes.StoreCartnotReady: boolean"data-testid"?: string}) => {const [submitting, setSubmitting] = useState(false)const [errorMessage, setErrorMessage] = useState<string | null>(null)const onPaymentCompleted = async () => {await placeOrder().catch((err) => {setErrorMessage(err.message)})
Copy to clipboardclient-id - you can retrieve it from your Paypal Developer Dashboard.
Notes
- Intent has been chosen to Copy to clipboard
authorizein Copy to clipboardPayPalScriptProvider- it means that firstly payment is authorized, then it can be capture via Admin UI. Plugin (not yet) support automatic capturing. - Copy to clipboard
usePayPalScriptReducerrequires Copy to clipboardPayPalScriptProviderto be a parent. It is not problem when making a payment, but when you would like to redirect the user you need be careful. The best option is to put Copy to clipboardPayPalScriptProvideras high as possible in components' tree. - Copy to clipboard
session?.data.paypalOrderId- Copy to clipboardpaypalOrderIdis created by the plugin and put it in the Copy to clipboarddata. However, there are more information put in Copy to clipboarddataby the plugin, so you can log them into console and see how you can use it in your storefront.
License
MIT
© 2025 RSC https://rsoftcon.com/


