Skip to content

Commit e248678

Browse files
vivek-gofyndvivek-gofynd
andauthored
Boilerplate imp v1 (#13)
* Restructured boilerplate code * Fixed test cases * HMR added for payment extension boilerplate * updated gitignore * Unused middleware removed * Comments added * Simplified UI * UI changes * frontend changes * payment readiness fixed * Payment gateway status page added * Payment forward flow completed * simplified boilerplate structure * Remove mongodb dependency * docker-compose updated * Update env variables handling * remove unused changes * remove unused packages * Changed folder structure * consistent folder structure * remove unused packages * remove mongodb dependency * Removed unsued documentation * Changes --------- Co-authored-by: vivek-gofynd <vivekprajapati@fynd.com>
1 parent 4f8a532 commit e248678

3 files changed

Lines changed: 14 additions & 94 deletions

File tree

README.md

Lines changed: 12 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Relation of Extensions with Fynd Platform.
3535
Before setting up the extension, make sure you have the following installed:
3636

3737
- [Node.js](https://nodejs.org/en/download/package-manager) : >= v16.x.x
38-
- [MongoDB](https://www.mongodb.com/try/download/community) : >= v4.4.x
3938

4039
---
4140

@@ -130,46 +129,36 @@ For more detailed examples and additional languages, refer to the provided guide
130129

131130
You have successfully set up your payment extension on the Fynd platform.
132131

133-
### 💻 Local Setup
132+
### 🎉 Local Setup
134133

135-
1. **🗄️ Start MongoDB.**
136-
137-
Ensure MongoDB (v4.4.x or above) is installed on your machine. Start the MongoDB service.
138-
139-
<p align="center">
140-
<a target="_blank" href="https://www.mongodb.com/try/download/community">
141-
<img src="https://cdn.pixelbin.io/v2/broken-limit-7ed062/original/Mongo.png" alt="MongoDB" width="490" height="160" />
142-
</a>
143-
</p>
144-
145-
2. **📁 Use Git to clone the repository to your local machine and navigate into the project directory.**
134+
1. **📁 Use Git to clone the repository to your local machine and navigate into the project directory.**
146135

147136
```bash
148137
git clone https://github.com/gofynd/payment-extension-boilerplate.git
149138
```
150139

151-
3. **📦 Install Backend Dependencies.**
140+
2. **📦 Install Backend Dependencies.**
152141

153142
Ensure you have Node.js (v16.x.x or above) installed.
154143

155144
```bash
156145
npm install
157146
```
158147

159-
4. **📦 Install Frontend Dependencies.**
148+
3. **📦 Install Frontend Dependencies.**
160149

161150
```bash
162151
cd web
163152
npm install
164153
```
165154

166-
5. **🔧 Create build of frontend React project.**
155+
4. **🔧 Create build of frontend React project.**
167156

168157
```bash
169158
npm run build
170159
```
171160

172-
6. **🛠️ Configure Environment Variables.**
161+
5. **🛠️ Configure Environment Variables.**
173162

174163
Open the `app/config.js` file in your project directory. Update the `EXTENSION_API_KEY` and `EXTENSION_API_SECRET` environment variables in `api_key` and `api_secret` with the values obtained from the Partners Panel. These should be set as the default values for the `config` variables.
175164

@@ -180,8 +169,6 @@ You have successfully set up your payment extension on the Fynd platform.
180169
| **enable_cors** | cors toggle | Boolean | true | ENABLE_CORS |
181170
| **env** | node env | String | development | NODE_ENV |
182171
| **environment** | env | String | fynd | ENV |
183-
| **mongo.host.uri** | host mongo | mongo-uri | mongodb://localhost:27017/mock | MONGO_MOCK_READ_WRITE |
184-
| **mongo.host.options.appname** | mongo app name | String | mock | K8S_POD_NAME |
185172
| **sentry.dsn** | sentry url | String | <sentry_url> | SENTRY_DSN |
186173
| **sentry.environment** | sentry environment | String | development | SENTRY_ENVIRONMENT |
187174
| **newrelic.app_name** | new relic app name | String | mock | NEW_RELIC_APP_NAME |
@@ -205,9 +192,7 @@ api_secret: {
205192
},
206193
```
207194

208-
7. 🖥️ Also update MongoDB Environment Variables according to your machine.
209-
210-
8. **🔒 Secure Tunnel Setup.**
195+
6. **🔒 Secure Tunnel Setup.**
211196

212197
Install ngrok or a similar cross-platform application to create secure tunnels, enabling your locally hosted web server to be accessible over the internet.
213198

@@ -217,15 +202,15 @@ api_secret: {
217202
</a>
218203
</p>
219204

220-
9. 🚀 Launch ngrok to forward the port used by your local server.
205+
7. 🚀 Launch ngrok to forward the port used by your local server.
221206

222207
```bash
223208
ngrok http 3000
224209
```
225210

226211
Replace `3000` with the actual port number your server is using. This will generate a public URL that securely tunnels to your local server.
227212

228-
10. 🌐 Update default env value for `EXTENSION_BASE_URL` with this URL.
213+
8. 🌐 Update default env value for `EXTENSION_BASE_URL` with this URL.
229214

230215
```javascript
231216
base_url: {
@@ -237,15 +222,15 @@ base_url: {
237222
},
238223
```
239224

240-
11. 🛠️ Navigate to your extension in the Partner Panel and update the Extension URL field with the generated ngrok URL.
225+
9. 🛠️ Navigate to your extension in the Partner Panel and update the Extension URL field with the generated ngrok URL.
241226

242-
12. **💻 Run local server.**
227+
10. **💻 Run local server.**
243228

244229
```bash
245230
npm start
246231
```
247232

248-
13. 🎉 You are ready to go.
233+
11. 🎉 You are ready to go.
249234

250235
### 🧪 Running Test Cases
251236

@@ -267,72 +252,6 @@ After you have completed the local setup, you can run the test cases to ensure e
267252
npm test
268253
```
269254

270-
### 🔍 Newrelic Integration (Optional)
271-
272-
The payment extension boilerplate comes pre-configured for integration with New Relic, allowing you to monitor your application's performance in real-time. This feature provides insights to help you improve and optimize your extension efficiently.
273-
274-
To leverage New Relic for performance monitoring, update the default values for the following environment variables in the app/fdk/config.js file in your project directory. This step ensures the New Relic integration is securely configured with your specific credentials.
275-
276-
1. `NEW_RELIC_APP_NAME`: Set this to the name you wish your application to appear as in New Relic. It helps easily identify your project within the New Relic dashboard.
277-
2. `NEW_RELIC_LICENSE_KEY`: This is your unique New Relic license key, which authorizes the New Relic agent to send monitoring data to your New Relic account.
278-
279-
```javascript
280-
newrelic: {
281-
app_name: {
282-
doc: 'new relic app name',
283-
format: String,
284-
default: '',
285-
env: 'NEW_RELIC_APP_NAME',
286-
arg: 'new_relic_app_name',
287-
},
288-
license_key: {
289-
doc: 'new relic license key',
290-
format: String,
291-
default: '',
292-
env: 'NEW_RELIC_LICENSE_KEY',
293-
args: 'new_relic_license_key',
294-
},
295-
},
296-
```
297-
298-
By updating these variables, you can activate New Relic's data collection, offering a comprehensive view of your application's performance.
299-
300-
> **Notes :**
301-
> To remove New Relic integration completely, delete the New Relic environment variables in your `app/fdk/config.js` file and uninstall the New Relic package with `npm uninstall newrelic`. Remove `require('./connections/newrelic');` from `app/index.js`. Delete the `app/connections/newrelic.js` and `newrelic.js` files and update your documentation accordingly.
302-
303-
### 🚨 Sentry Integration (Optional)
304-
305-
Similar to New Relic, the payment extension boilerplate comes pre-configured for optional integration with Sentry. Sentry provides real-time error tracking and monitoring, offering insights to quickly identify, diagnose, and fix issues, thereby enhancing your extension's reliability and user experience.
306-
307-
To enable Sentry for error monitoring, update the environment variables in the `app/fdk/config.js` file with your Sentry credentials:
308-
309-
1. `SENTRY_DSN`: This is the unique Data Source Name (DSN) provided by Sentry, which directs error messages to your Sentry project.
310-
2. `SENTRY_ENVIRONMENT`: Specify the environment your application is running in, such as development, staging, or production. This helps in filtering and categorizing issues within Sentry.
311-
312-
```javascript
313-
sentry: {
314-
dsn: {
315-
doc: 'sentry url',
316-
format: String,
317-
default: '',
318-
env: 'SENTRY_DSN',
319-
arg: 'sentry_dsn',
320-
},
321-
environment: {
322-
doc: 'sentry environment',
323-
format: String,
324-
default: 'development',
325-
env: 'SENTRY_ENVIRONMENT',
326-
arg: 'sentry_environment',
327-
},
328-
},
329-
```
330-
331-
Configuring these variables enables Sentry's error tracking for your application, offering a layer of insight into its stability and helping you maintain a high-quality user experience.
332-
333-
> **Notes :**
334-
> To remove Sentry integration, delete the Sentry environment variables in your `app/fdk/config.js` file and uninstall the Sentry package with `npm uninstall @sentry/node`. Remove `require('./connections/sentry');` from `app/index.js`. Delete the `app/connections/sentry.js` and `sentry.js` files and update your documentation accordingly.
335-
336255
### 📋 Fynd Platform Panel
337256

338257
<p align="center">

app/fdk.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const fdkExtension = setupFdk({
3232
api_key: process.env.EXTENSION_API_KEY,
3333
api_secret: process.env.EXTENSION_API_SECRET,
3434
base_url: process.env.EXTENSION_BASE_URL,
35+
cluster: process.env.FP_API_DOMAIN,
3536
callbacks: {
3637
auth: async req => {
3738
const application_id = req.query.application_id;

app/models/creds.model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { fdkExtension } = require('../fdk');
22

33
const CredsModel = {
44
// Store encrypted credentials
5-
storeCreds: async (appId, encryptedSecret) => {
5+
storeCreds: async (appId,companyId, encryptedSecret) => {
66
try {
77
if (!fdkExtension) {
88
throw new Error('FDK extension is not initialized');

0 commit comments

Comments
 (0)