#radiant1106

1 messages · Page 1 of 1 (latest)

deep notchBOT
glossy mortar
#

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

glossy mortar
#

Okie can you find the request that errored?

#

req_xxx

icy adder
#

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)
  });
};
icy adder
glossy mortar
#

Yes that stripe.tokens.create

icy adder
glossy mortar
#

it is passing number directly

icy adder
glossy mortar
icy adder
#

yes, it used to work months before

icy adder
#

Hey @glossy mortar , I am waiting for your response.

glossy mortar
#

Yes but this is still passing Card Number. You can't do this on Live mode or you will be exposed to PCI Compliance

#

Please follow the guide I shared earlier to switch over to Checkout or PaymentElement

deep notchBOT
glossy mortar
icy adder
#

I tried it but still errors and errors

#

can't we just proceed with the old api?

glossy mortar
#

I am afraid no

icy adder
#

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,
},
});

primal owl
#

👋 Taking over this thread

icy adder
#

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

primal owl
#

Yes if you use Checkout Session (Stripe hosted payment page)

icy adder
#

ye

#

ok

icy adder
#

then pass the amount to the new api?

primal owl
#

Yup, that sounds right to me

icy adder
#

currently: "stripe": "^9.4.0",

primal owl
icy adder
#

like this

#

And setting that

#

unit_amount

primal owl
#

I don't see any issue with your code. Is there any problem you're facing?

icy adder
#

if I am doing like 100

#

its proceding me to the checkout page

primal owl
primal owl
icy adder
#

you didn't got my problem

primal owl
#

What is the problem? We didn't receive the right value in the unit_amount, so the error was returned

primal owl
#

Yes! line_items is an array. You can add more items to it

icy adder
primal owl
#

Your client (form) should pass the item information to your server, which then set them into Checkout Session creation

icy adder