|
| 1 | +# 🚀 Hyperswitch Medusa Plugin |
| 2 | +> Transform your Medusa store with seamless payment processing using Hyperswitch! |
| 3 | +
|
| 4 | +[](https://medusajs.com) |
| 5 | +[](https://hyperswitch.io) |
| 6 | + |
| 7 | +## 📑 Table of Contents |
| 8 | +- [Installation](#installation) |
| 9 | + - [Medusa Backend Setup](#medusa-backend-setup) |
| 10 | + - [Hyperswitch Plugin Setup](#hyperswitch-plugin-setup) |
| 11 | +- [Video Installation Guide](#video-installation-guide) |
| 12 | +- [Usage](#usage) |
| 13 | + |
| 14 | +## 🛠 Installation |
| 15 | + |
| 16 | +### Medusa Backend Setup |
| 17 | + |
| 18 | +#### Prerequisites |
| 19 | +- Node.js (version 16 or higher) |
| 20 | +- PostgreSQL |
| 21 | +- Git |
| 22 | + |
| 23 | +#### Step-by-Step Guide |
| 24 | + |
| 25 | +1. **Clone the starter repository** |
| 26 | + ```bash |
| 27 | + git clone https://github.com/medusajs/medusa-starter-default.git |
| 28 | + cd medusa-starter-default |
| 29 | + ``` |
| 30 | + |
| 31 | +2. **Switch to v1 branch** |
| 32 | + ```bash |
| 33 | + git checkout v1 |
| 34 | + ``` |
| 35 | + |
| 36 | +3. **Install dependencies** |
| 37 | + ```bash |
| 38 | + npm install |
| 39 | + ``` |
| 40 | + |
| 41 | +4. **Set up environment variables** |
| 42 | + ```bash |
| 43 | + cp .env.template .env |
| 44 | + ``` |
| 45 | + |
| 46 | +5. **Create PostgreSQL database** |
| 47 | + ```sql |
| 48 | + CREATE DATABASE "your_database_name"; |
| 49 | + ``` |
| 50 | + |
| 51 | +6. **Configure database connection** |
| 52 | + Add to your `.env` file: |
| 53 | + ```bash |
| 54 | + DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<your_database_name> |
| 55 | + ``` |
| 56 | + |
| 57 | +7. **Run migrations** |
| 58 | + ```bash |
| 59 | + npx medusa migrations run |
| 60 | + ``` |
| 61 | + |
| 62 | +8. **Seed the database** |
| 63 | + ```bash |
| 64 | + yarn seed |
| 65 | + ``` |
| 66 | + |
| 67 | +9. **Start the development server** |
| 68 | + ```bash |
| 69 | + npm run dev |
| 70 | + ``` |
| 71 | + |
| 72 | +> 💡 **Default Admin Credentials** |
| 73 | + |
| 74 | +> Password: `supersecret` |
| 75 | +
|
| 76 | +To create a new admin user: |
| 77 | +```bash |
| 78 | +npx medusa user -e [email protected] -p your-password |
| 79 | +``` |
| 80 | + |
| 81 | +### Hyperswitch Plugin Setup |
| 82 | + |
| 83 | +1. **Install the plugin** |
| 84 | + ```bash |
| 85 | + npm install medusa-payment-hyperswitch |
| 86 | + ``` |
| 87 | + |
| 88 | +2. **Update medusa-config.js** |
| 89 | + ```javascript |
| 90 | + { |
| 91 | + resolve: "medusa-payment-hyperswitch", |
| 92 | + options: { |
| 93 | + enableUI: true, |
| 94 | + } |
| 95 | + } |
| 96 | + ``` |
| 97 | + |
| 98 | +3. **Add encryption key** |
| 99 | + Add to your `.env` file: |
| 100 | + ```bash |
| 101 | + HYPERSWITCH_SECRET_KEY=GvcUS5KMlC/3ND1eCXx4n4VEosUwblX5kcJ4gKkumiw= |
| 102 | + ``` |
| 103 | + > ⚠️ Make sure to use a secure 256-bit key for encryption in production! |
| 104 | +
|
| 105 | +4. **Build the project** |
| 106 | + ```bash |
| 107 | + npm run build |
| 108 | + ``` |
| 109 | + |
| 110 | +## 🎥 Video Installation Guides |
| 111 | + |
| 112 | +### Backend Installation Tutorial |
| 113 | +Watch our detailed guide for setting up the Medusa backend: |
| 114 | + |
| 115 | +[](https://youtu.be/Qf1svoZguy0) |
| 116 | + |
| 117 | +Key topics covered: |
| 118 | +- Repository cloning & setup |
| 119 | +- Environment configuration |
| 120 | +- Database initialization |
| 121 | +- Running migrations and seeding data |
| 122 | + |
| 123 | +### Plugin Installation Tutorial |
| 124 | +Learn how to integrate the Hyperswitch plugin: |
| 125 | + |
| 126 | +[](https://youtu.be/tu_ekb1g_c0) |
| 127 | + |
| 128 | +Key topics covered: |
| 129 | +- Plugin installation steps |
| 130 | +- Configuration in medusa-config.js |
| 131 | +- Setting up encryption keys |
| 132 | +- Testing the integration |
| 133 | + |
| 134 | +## 🎮 Usage |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +Once installed, you can access the Hyperswitch payment options in your Medusa admin panel: |
| 140 | +1. Navigate to Settings → Regions |
| 141 | +2. Configure Edit Region Details |
| 142 | +3. Select Payment Processors as Hyperswitch |
| 143 | +4. Navigate to Settings → Payments |
| 144 | +5. Configure your Hyperswitch credentials |
| 145 | + |
| 146 | +## 🛒🛍️ Hyperswitch integrated Storefront |
| 147 | +1. **Clone the storefront repository** |
| 148 | + ```bash |
| 149 | + git clone https://github.com/Ayyanaruto/hyperswitch-medusa-storefront.git |
| 150 | + cd hyperswitch-medusa-storefront |
| 151 | + ``` |
| 152 | +2. **Install dependencies** |
| 153 | + ```bash |
| 154 | + npm install |
| 155 | + ``` |
| 156 | +3. **Configure your `.env` file** |
| 157 | + Add to your `.env` file: |
| 158 | + ``` |
| 159 | + #Your Medusa backend, should be updated to where you are hosting your server. Remember to update CORS settings for your server |
| 160 | + NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000 |
| 161 | + |
| 162 | + #Your store URL, should be updated to where you are hosting your storefront. |
| 163 | + NEXT_PUBLIC_BASE_URL=http://localhost:8000 |
| 164 | + |
| 165 | + #Your preferred default region. When middleware cannot determine the user region from the "x-vercel-country" header, the default region will be used. ISO-2 lowercase format. |
| 166 | + NEXT_PUBLIC_DEFAULT_REGION=us |
| 167 | + |
| 168 | + #Your hyperswitch Public Key |
| 169 | + NEXT_PUBLIC_HYPERSWITCH_KEY= pk_****** |
| 170 | + |
| 171 | + # Your Next.js revalidation secret. See – https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#on-demand-revalidation |
| 172 | + REVALIDATE_SECRET=supersecret |
| 173 | + ``` |
| 174 | + 4. **Start the development server** |
| 175 | + ```bash |
| 176 | + npm run start |
| 177 | + ``` |
| 178 | +
|
| 179 | +<p align="center"> |
| 180 | + Made with ❤️ by Ayyan Shaikh |
| 181 | +</p> |
0 commit comments