Discussions

Ask a Question
Back to All

TypeError: paymongo.paymentMethods.create is not a function

i got this code from paymongo-node sdks github repo.

https://github.com/paymongo/paymongo-node

const paymongo = require('paymongo-node')(process.env.NODE_ENV_PAYMONGO_SECRET);

const createPayIntent = async (amount) => {
const result = await paymongo.paymentIntents.create({
amount: amount,is not a function
payment_method_allowed: ['paymaya', 'gcash'],
payment_method_options: {card: {request_three_d_secure: 'any'}},
currency: 'PHP',
capture_type: 'automatic',
description: 'gcash and paymaya only'
})
return result;
}

this line of code actually works

but when i try this. paymongo.paymentMethods.create it does not work.

//the code:

const createPayMethod = async (name, email, phone, method) => {
const result = await paymongo.paymentMethods.create({
billing: {name: name, email: email, phone: phone},
type: method
});
return result;
}

same with paymongo.paymentIntents.attach

//the code:

const attachPayIntent = async (payIntId, payMetId) => {
const result = paymongo.paymentIntents.attach({
payment_method: payMetId,
return_url: 'https://www.paymongo.com/academy/the-paymongo-dashboard'
},{id: payIntId})
return result;
}

it both producess the same error.

is not a function

please help.