#Convert this code into appwrite cloud function

5 messages · Page 1 of 1 (latest)

shut veldt
#

const Insta = require('instamojo-nodejs')

const bodyParser = require('body-parser')

const API_KEY="02d2514bbb73fb7cc9f66959dad905d"

const AUTH_KEY="385c76863481a25d0eb298508f8647d"
Insta.setKeys(API_KEY,AUTH_KEY)


const app=express()

app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())

const PORT = process.env.PORT || 5001

app.get('/',(req,res) =>{
    res.sendFile(__dirname+"/Frontend/index.html")
})

app.post('/pay',(req,res) =>{

let name= req.body.name;
let email=req.body.email;
let amount = req.body.amount;
console.log(name);
console.log(email);
console.log(amount);

let data = new Insta.PaymentData();

const REDIRECT_URL = "http://localhost:5001/success";
 
data.setRedirectUrl(REDIRECT_URL);
data.send_email="True";
data.purpose = "printfc";
data.amount=amount;
data.name=name;
data.email=email;

Insta.createPayment(data, function(error, response){
    if(error){
        
    }else{
console.log(response)
        res.send("please check email")
    }
})
})
app.get('/success',(req,res) =>{
    res.send("successful")
})

app.listen(PORT,() =>{
    console.log(`App is listening on ${PORT}`)
})```
fathom river
#

Hi @shut veldt
You can learn how to write Appwrite Functions by looking at the syntax of our functions here in our documentation: https://appwrite.io/docs/functions#writingYourOwnFunction

I will additionally mention that while we have created the documentation for our services, at the end of the day, it is important that you must create the solutions for problems you're solving on your own.

You can look at the functions syntax for Node.js in our documentation, and in case you come across Appwrite-related issues in the process, we're here to help. However, the rest is your responsibility.

shut veldt
#

Ok

shut veldt
#

There is no documentation that a beginner can understand