Skip to content

Commit 99275b4

Browse files
committed
added paid extension boilerplate backend
1 parent 6e0cdd5 commit 99275b4

File tree

6 files changed

+666
-9
lines changed

6 files changed

+666
-9
lines changed

billing.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { setupBilling, OrmType } = require("fdk-billing-javascript");
2+
const mongoose = require('mongoose');
3+
4+
// Connect to MongoDB (using local MongoDB or MongoDB Atlas)
5+
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/fynd-extension-billing';
6+
7+
// Connect to MongoDB (removed deprecated options)
8+
mongoose.connect(MONGODB_URI)
9+
.then(() => {
10+
console.log('Connected to MongoDB for billing');
11+
})
12+
.catch((error) => {
13+
console.error('MongoDB connection error:', error);
14+
});
15+
16+
// Initialize billing instance
17+
const fdkBillingInstance = setupBilling({
18+
extension_id: process.env.EXTENSION_API_KEY,
19+
db_connection: mongoose.connection,
20+
collection_name: {
21+
plan: "plans",
22+
subscription: "seller_subscriptions"
23+
},
24+
orm_type: OrmType.MONGOOSE
25+
});
26+
27+
module.exports = { fdkBillingInstance };

package-lock.json

Lines changed: 248 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"dotenv": "^16.4.5",
2323
"express": "^4.19.2",
2424
"serve-static": "^1.15.0",
25-
"sqlite3": "^5.1.7"
25+
"sqlite3": "^5.1.7",
26+
"fdk-billing-javascript": "github:gofynd/fdk-extension-utils-javascript",
27+
"mongoose": "^8.0.0"
2628
},
2729
"devDependencies": {
2830
"axios-mock-adapter": "^1.21.2",

0 commit comments

Comments
 (0)