#Ludderz

1 messages ยท Page 1 of 1 (latest)

iron plazaBOT
warm estuary
#

Hello!

#

How can I help?

tiny onyx
#

sooooo i need to run an ecom website for a business i work for, they buy sell phones, so stock changes every hour and i wanna add stripe to a custom website ive coded, BUT heres the problem, it says this on the setup

" // Provide the exact Price ID (for example, pr_1234) of the product you want to sell
price: '{{PRICE_ID}}',
quantity: 1,
},
],"

any way round that as people i work for wont be able to do this when they get new stock

#

like kinda just a simple buy button that pulls all the stuff from basket if that makes sense not price id and stuff kinda like how paypal has done it

warm estuary
#

Yeah that's totally possible. You can use price_data instead of price if you want to create the price inline instead of ahead of the Checkout Session

#

So you would basically send the cart info to your server endpoint and translate that cart info into the necessary line_items for Checkout and then create the Checkout Session and redirect

tiny onyx
#

i was legit about to ask for that lol

#

okay awesome ill have a look ๐Ÿ˜„

warm estuary
#

Yep take a look and let me know if you have any follow up questions!

tiny onyx
#

little confused on where this goes server.js?

#

sorry im completely new to this

warm estuary
#
{price_data: {
  unit_amount: 100,
  currency: 'usd',
  product: 'prod_123'
}
}]```
#

That's an example

#

In this case you would pull the product ID from one that you had already created

#

You could also create it inline just like the above using product_data

tiny onyx
#

i dont want to have 'line_items' => [
[
'price' => 'price_H5ggYwtDq4fbrJ',
'quantity' => 2,
],
],

because people i work for wont understand it, I have it all in a database with phpmyadmin can i just pull it from there instead of typing every product

warm estuary
#

Yep that would be the idea

tiny onyx
#

like there will be alot of products in and out

warm estuary
#

I'm just telling you how our API works

#

So yeah, you would want to match up your database with the information that our API needs

#

Then you query your database based on the cart info that is passed from the client and then submit the corresponding information to our API

tiny onyx
#

would this work?

warm estuary
#

Sorry I can't audit your code line by line. It looks fine based on a glance, but really the best thing to do is to test it out and then work from there!

tiny onyx
#

okay can we keep this open for like half hour just while i see if this works?

warm estuary
#

Sure

tiny onyx
#

hi are ya there? ๐Ÿ˜„

warm estuary
#

๐Ÿ‘‹

tiny onyx
#

So i think i have it working, how can i see if one of the test cards went though?

warm estuary
tiny onyx
#

it works but i get these errors

warm estuary
#

Can you post that request ID?

#

The req_xxx

maiden eagle
#

Hello! I'm taking over and catching up...

#

Looks like you tried to create a Charge with the amount set to zero, which is not allowed.

tiny onyx
#

okay 1 second

tiny onyx
maiden eagle
#

Yep.

#

Well, I don't know if it's correct in your DB or not, all I can see is that you passed 0 for the amount from your PHP code.

#

I can't say where the 0 came from beyond that.

tiny onyx
#

AHHH

#

its not even connected...

#

hang on lol

#

would it be worth making a new db with these :

#

saves me some headaches then if so

maiden eagle
#

That's up to you. ๐Ÿ™‚

tiny onyx
#

okay give me 10 mins and ill get back to you ๐Ÿ˜„

#

it still no work ๐Ÿ˜ญ can i come back to this tomorrow? its to late for my brain ill send u all errors i got right now

maiden eagle
#

Yeah, you can come back tomorrow and get help in #dev-help again. ๐Ÿ™‚

tiny onyx
#

is it possible to keep this one open or is it automatic close?

maiden eagle
#

Looks like you're still sending us an amount of 0 though.

#

This thread will be closed, but you can still view it.

#

You can bookmark the link or search for it.

tiny onyx
#

if i was to youtube it. what would i search because all the videos i get is the one where i have to manually enter the product i wanna avoid that

maiden eagle
#

I'm not sure what you're trying to do or what exactly is blocking you.

tiny onyx
#

are we allowed to talk in dm? if i give u a dm tomorrow about it and i can explain what i need

maiden eagle
#

No, please do not DM people for help with Stripe. I won't be around tomorrow, but someone else should be. You can ask more questions in #dev-help tomorrow, or I can help you more here now.

tiny onyx
#

okay no problem give me a min to type what im looking for

#

so, im making an ecom website for a buy and sell company (mobile phones) so stock changes everyday.

I want a payment gateway like paypal where it just gets whats in ur cart and pay that

everyone i work with isnt all computer smart lol so i dont want to have manual input, i just want it to get the total price of the cart and items in the cart

maiden eagle
#

Okay. Is there a reason you're trying to create a Charge directly? That's a legacy approach we do not recommend.

tiny onyx
#

tbh its there to help people i work with aswell to keep it simple, i just dont want to have to manually input the products and prices because there is alot of products and they wont know what to do

maiden eagle
#

When you say you don't want to manually input the products and prices are you talking about your customers (the people paying) or people on your staff? Or someone else?

tiny onyx
#

this bit, i want that to get it from my phpmyadmin database

maiden eagle
#

Okay, so that's for Stripe Checkout, which is completely different from the request we were talking about earlier.

#

The request you made earlier was to create a Charge directly (not recommended).

#

Do you want to use Stripe Checkout or are you trying to build a custom payment form on your site?

tiny onyx
#

stripe checkout

#

no wait

#

custom

maiden eagle
#

Are you sure?

tiny onyx
#

I'm never sure anymore lol, ok sure lets do stripe checkout

maiden eagle
#

Well, you should make sure you know what you want before we continue. A custom payment form gives you more control, but is more difficult to build and maintain. Stripe Checkout is easier to use and maintain, but you have less control over the payment experience. Which of those sounds like the right fit for what you want to do?

tiny onyx
#

lets do stripe checkout, looks more like what im looking for, is this where i input all my products to the server.js?

maiden eagle
#

Stripe Checkout is designed to work with Products and Prices you define in Stripe, but you don't have to use it that way. You can set Product and Price data on the fly when you create a Checkout Session without setting it up ahead of time.

tiny onyx
#

so would "price_data" pull it from my cart

maiden eagle
#

You can put whatever you want in there from wherever you want, yeah.

#

Can you provide more details about what exactly you mean when you say "pull it from my cart"?

tiny onyx
#

1 sec ill explain it

#

so i want it to take this price and automatically have that on stripe without doing

"const paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
payment_method_types: ['card'],
});"

so it just pops up with the name of product and the price that they pay

maiden eagle
#

Okay, it's important to understand that if you're using Stripe Checkout you will not be creating Payment Intents or Charges. The only thing you're going to create are Checkout Sessions.

#

Stripe Checkout will create a Payment Intent for you, and the Payment Intent will create the Charge.

#

So you need to create a Checkout Session and specify the information above inside price_data (as linked above).

#

Then once the Checkout Session is created it will have a url property. You send your customer to that URL and they see Stripe Checkout and pay you.

#

For example:

$checkoutSession = $stripe->checkout->sessions->create([
    'success_url' => 'https://example.com/?success&session_id={CHECKOUT_SESSION_ID}',
    'mode' => 'payment',
    'line_items' => [
        [
            'price_data' => [
                'currency' => 'usd',
                'product_data' => [
                    'name' => 'Example Product',
                ],
                'unit_amount' => 4200,
            ],
            'quantity' => 1,
        ],
    ],
]);
#

You can add in other details as documented at the link I shared above, but that's a minimal example.

#

You do that, you get a Checkout Session back, you send your customer to the Checkout Session's url.