#MMunir-payments

1 messages · Page 1 of 1 (latest)

lofty pawn
#

MMunir-payments

#

MMunir-payments

#

hey! you could yes, but I'm not sure why you ever would! Generally, you load the page when a customer wants to pay, create a PaymentIntent, and that's what you use for the payment to pay with. Can you expand a little on what you're trying to do?

cobalt hare
#

like I have different products with different requirements like in meta if some information is not there it doesn't proceed to checkout

lofty pawn
#

hmm, ok! Then sure, you can build things like that if you wish. Or you could create the PaymentIntent in an XHR/Ajax request instead when the user has picked what they want and you POST to your backend, whatever works for you(you don't have to create the PaymentIntent when the page loads if you don't want to)

cobalt hare
#

$session = \Stripe\Checkout\Session::create([
'success_url' => 'http://localhost:4242/?success=true',
'cancel_url' => 'http://localhost:4242/?cancel=true',
'mode' => 'payment',
'payment_method_types' => ['card'],
'payment_intent_data' => [
'metadata' => [
'date' => $params->datepicker,
'no of adults' => $params->adults,
'no of children' => $params->children,
'package' => $params->occupancy,
'atv' => $params->atv,
]
],
'metadata' => [
'date' => $params->datepicker,
'no of adults' => $params->adults,
'no of children' => $params->children,
'package' => $params->occupancy,
'atv' => $params->atv,
],
'submit_type' => 'donate',
'line_items' => [[
'price_data' => [
'currency' => 'aed',
'product' => $products[$params->occupancy],
'unit_amount' => $params->amount,
],
'quantity' => 1,
]]
]);

#

like this is my session in other products i wont be having atv so i thought if another payment intent is there it can be better but i think copying this and pasting twice dosent cahnge any thing

#

or maybe the way its structur i am missing something to add two payment in tent in one file

lofty pawn
#

I don't understand you, sorry.

#

anyway there is one PaymentIntent per each CheckoutSession, you can't have multiple. You can create multiple CheckoutSessions though if you want to for some reason.

cobalt hare
#

\

#

like i have created two different session but it dosent work when i proceed with it

lofty pawn
#

well yes of course it doesn't, you defined the variable $session twice so that doesn't work in PHP, the programming language you use.

#

you also only return the ID of one of the Sessions so even if it did work, you're creating one session and not doing anything with it.

#

I really don't understand what you're trying to do.

cobalt hare
#

https://bigdunestours.com/index.html like this is my prototype but the thing is variable like atv won't be available in other sessions I don't want to create separate index.php for each product because I have 25 products and creating each one is a lot so I wanted to have it all in one

lofty pawn
#

then you can do that, it's just some code you'd have to write

#

like have some if-statements and business logic to create the correct Session metadata for what your customer is doing. Not sure I can really help you there, it's not really directly related to Stripe, it's how you write your code.

cobalt hare
#

see that if things work well and i am receiving all the requests that my customer choose, the point is this is one product but in other products, we will be having more details like time slot for products and if I create a payment intent i add meta for time slot it dosent proceed with my morning safari product as payment intent request time slot for it and if i want payment intent different in same file how can i

lofty pawn
#

I'm sorry but I can not understand that sentence at all.

cobalt hare
#

well just one thing to just make sure like i can have multiple payment intent right rest i will look for the code

#

in single index.php

indigo stone
#

Hey taking over from @lofty pawn – let me know if there's any specific questions I can answer