-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Payment Gateways like Esewa, Khalti #1
Comments
To add Khalti or eSewa Nepali payment gateways during checkout alongside Stripe, you'll need to integrate their APIs into your application. Here's a high-level plan: Steps to Implement Khalti or eSewa Payment Gateways
Example Code for Khalti IntegrationFrontend Button (React/JavaScript) const onKhaltiPayment = () => {
const config = {
publicKey: "YOUR_KHALTI_PUBLIC_KEY",
productIdentity: "1234567890",
productName: "Your Product Name",
productUrl: "http://yourwebsite.com",
eventHandler: {
onSuccess(payload) {
console.log("Payment successful", payload);
// Send payload to backend for verification
},
onError(error) {
console.error("Payment failed", error);
},
},
};
const checkout = new KhaltiCheckout(config);
checkout.show({ amount: 1000 }); // Amount in paisa
}; Backend Verification (Node.js Example) const axios = require('axios');
app.post('/verify-payment', async (req, res) => {
const { token, amount } = req.body;
try {
const response = await axios.post(
'https://khalti.com/api/v2/payment/verify/',
{
token: token,
amount: amount,
},
{
headers: {
Authorization: `Key YOUR_KHALTI_SECRET_KEY`,
},
}
);
res.json({ success: true, data: response.data });
} catch (error) {
res.status(400).json({ success: false, error: error.response.data });
}
}); Once integrated, you'll offer users more localized and convenient payment options, improving their checkout experience. |
@Mustkeem324 feel free to contribute! 😊 |
Currently, only stripe is supported.
Add more options during the checkout by implementing khalti or esewa nepali payment gateways.
The text was updated successfully, but these errors were encountered: