Hare is the erros message in console. "Cannot determine payment method".
{errors: {…}, params: {…}, message: 'Cannot determine payment method.', success: false} errors: {validationErrors: {…}, errorCollections: {…}} message: "Cannot determine payment method." params: {transaction: {…}} success: false [[Prototype]]: Object
Let me tell one thing I have made token properly. Hare I attached few segment of my code.
const buy = () => { setData({ loading: true });
let nonce;
let getNonce = data.instance
.requestPaymentMethod()
.then(data => {
nonce = data.nonce;
const paymentData = {
paymentMethodNonce: nonce,
amount: getTotal(products)
};
processPayment(userId, token, paymentData)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
})
.catch(error => {
setData({ ...data, error: error.message });
});
};
Hare is the process payment Controller
exports.processPayment = (req, res) => {
const nonceFromTheClient = req.body.payment_method_nonce;
const amountFromTheClient = req.body.amount;
// charge
const newTransaction = gateway.transaction.sale(
{
amount: amountFromTheClient,
paymentMethodNonce: nonceFromTheClient,
options: {
submitForSettlement: true
}
},
(err, result) => {
if (err) {
res.status(500).json(err);
} else {
res.json(result);
}
}
);
};