Trying to Integrate Stripe Payment Gateway in Donation Webpage. Have least knowledge in integrating payment gateways
After following a simple tutorial, am able to complete payment but cant add other payment options as well as transfer User data in frontend as well Backend.
sepa_debit and wallets are not visible.
Not able to display the amount the user enters in the form in the payment of stripe
Home.ejs
<!DOCTYPE html>
<html>
<title>Stripe Payment Demo</title>
<body>
<h3>Welcome to Payment Gateway</h3>
<form action="payment" method="POST" >
<input type="number" id="amount">
<input type="submit">
<script
src="//checkout.stripe.com/v2/checkout.js"
class="stripe-button"
data-key="<%= key %>"
data-amount=document.getElementById(amount)
data-currency="inr"
data-name="Sparks Foundation NGO"
data-description="Donate Now to Better Somesone's Life"
data-locale="auto" >
</script>
</form>
</body>
</html>
index.js
const express = require('express')
const bodyparser = require('body-parser')
const path = require('path')
const app = express()
var Publishable_Key = 'pk_test_51MY8LgSIjyhEAXRbDHDLZUfwFVuxKzUWesWXwQLfnb6vOoAyvelN0KVUGSwXdlez6FhoLgWD6Ngn4DKa6eZnG2c400Dn74v3r2'
var Secret_Key = 'sk_test_51MY8LgSIjyhEAXRbqRP5AWJWYbdXJ0Tj9P1FoYM83U6j0ckHItUTCw8PfAeBKPpP4PJHQ5kzqexK1q6xgsFhxVTB00H7MQtYig'
const stripe = require('stripe')(Secret_Key)
const port = process.env.PORT || 3000
app.use(bodyparser.urlencoded({extended:false}))
app.use(bodyparser.json())
// View Engine Setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
app.get('/', function(req, res){
res.render('Home', {
key: Publishable_Key
})
})
app.post('/payment', function(req, res){
// Moreover you can take more details from user
// like Address, Name, etc from form
stripe.customers.create({
email: req.body.stripeEmail,
source: req.body.stripeToken,
name: 'Gourav Hammad',
address: {
line1: 'TC 9/4 Old MES colony',
postal_code: '452331',
city: 'Indore',
state: 'Madhya Pradesh',
country: 'India',
}
})
.then((customer) => {
return charge = async()=>{
await stripe.PaymentIntent.create({
payment_method_types: ["card","sepa_debit","wallets"],
amount: 1099,
currency: 'usd',
});
}
})
.then((charge) => {
res.send("Success") // If no error occurs
})
.catch((err) => {
res.send(err)
console.log(err); // If some error occurs
});
})
app.listen(port, function(error){
if(error) throw error
console.log("Server created Successfully")
})
Reference Image
Please help. Thanks in Advance