#radiant1106
1 messages · Page 1 of 1 (latest)
Yes that's because you are seinding credit card numbers directly in the API. That's shouldn't happen in Live mode
You want to review the API you are calling
Can you please help me with it?
Okie can you find the request that errored?
req_xxx
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
my code:
const settings = require("../settings.json");
const fs = require('fs');
const indexjs = require("../index.js");
const fetch = require('node-fetch');
var validators = require('credit-card-validate');
const stripe = require('stripe')(settings.stripe.key);
module.exports.load = async function(app, db) {
app.get("/buycoins", async(req, res) => {
if(!req.session.pterodactyl) return res.redirect("/?error="+encodeURIComponent((new Buffer("You are not logged in.")).toString('base64')));
const token = await stripe.tokens.create({
card: {
number: `${req.query.number}`,
exp_month: +req.query.month,
exp_year: +req.query.year,
cvc: req.query.vrf,
},
});
const charge = await stripe.charges.create({
amount: req.query.amt * settings.stripe.amount,
currency: 'gbp',
source: token,
description: 'Transaction: ' + settings.stripe.coins * req.query.amt,
});
if(charge.status != "succeeded") return res.redirect("/buy?error="+encodeURIComponent((new Buffer("Invalid card information.")).toString('base64')));
let ccoins = await db.get(`coins-${req.session.userinfo.id}`)
ccoins += settings.stripe.coins * req.query.amt;
await db.set(`coins-${req.session.userinfo.id}`, ccoins)
});
};
let me proovide you, please wait
Yes that stripe.tokens.create
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
it is passing number directly
how I am supposed to do that?
This Token and Charge is an old and legacy approach. You should use the newer Checkout or PaymentElement flow. See https://stripe.com/docs/payments/accept-a-payment
yes, it used to work months before
I am not experienced with new changes, can you help me editing the code please?
Hey @glossy mortar , I am waiting for your response.
Yes but this is still passing Card Number. You can't do this on Live mode or you will be exposed to PCI Compliance
More here https://stripe.com/docs/security/guide
Please follow the guide I shared earlier to switch over to Checkout or PaymentElement
can you edit the code for me?
No we can't. Please follow the guide I mentioned here
I am afraid no
I just have to edit this part?
const token = await stripe.tokens.create({
card: {
number: ${req.query.number},
exp_month: +req.query.month,
exp_year: +req.query.year,
cvc: req.query.vrf,
},
});
👋 Taking over this thread
The entire integration should be migrated to the new Payment Intent with Payment Element, or Checkout Session as orakaro shared earlier: https://stripe.com/docs/payments/accept-a-payment, not only this specific code
I got this interface for my old site
so I just have to ask them for the amount then redirect it to stripe page to complete the transaction?
enter card details there
Yes if you use Checkout Session (Stripe hosted payment page)
but for the amount I should let that column there?
then pass the amount to the new api?
Yup, that sounds right to me
I will have to update the stripe version in my nodejs application?
currently: "stripe": "^9.4.0",
It's recommended to upgrade to the latest version to get the latest feature. The latest version is v14.14.0: https://github.com/stripe/stripe-node
Hey, I got it and now I just want to set the unit_amount
like this
And setting that
unit_amount
I don't see any issue with your code. Is there any problem you're facing?
yes, in the unit amount its saying invalid integer
if I am doing like 100
its proceding me to the checkout page
Can you share the request ID (req_xxx) with the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
theree
In https://dashboard.stripe.com/logs/req_XPyxGB4VCSDShB, you're passing "NaN" in the request, instead of an integer
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
you didn't got my problem
What is the problem? We didn't receive the right value in the unit_amount, so the error was returned
can I add more items there?
Yes! line_items is an array. You can add more items to it
what to do on the submit form side then?
Your client (form) should pass the item information to your server, which then set them into Checkout Session creation
now everything worked for the unit_amount, now I want to add to the database if the payment gets success please tell me if there guide on it.