Added elements for mobile payments. BOD-90

This commit is contained in:
Patrick Fic
2020-07-24 16:30:21 -07:00
parent 1e00b376ea
commit 8750894c56
8 changed files with 278 additions and 140 deletions

View File

@@ -44,3 +44,38 @@ exports.payment = async (req, res) => {
res.status(400).send(error);
}
};
exports.mobile_payment = async (req, res) => {
const { amount, stripe_acct_id } = req.body;
console.log("exports.payment -> amount", amount);
console.log("exports.payment -> stripe_acct_id", stripe_acct_id);
try {
await stripe.paymentIntents
.create(
{
//Pull the amounts from the payment request.
payment_method_types: ["card"],
amount: amount,
currency: "cad",
application_fee_amount: 50,
},
{
stripeAccount: stripe_acct_id,
}
)
.then(function (paymentIntent) {
try {
return res.send({
clientSecret: paymentIntent.client_secret,
});
} catch (err) {
return res.status(500).send({
error: err.message,
});
}
});
} catch (error) {
console.log("error", error);
res.status(400).send(error);
}
};