#GamingForeverYT
1 messages · Page 1 of 1 (latest)
hi
hmm, not sure what you mean. What is the value of your $product_price variable exactly?
that's not how our PaymentLinks work, you don't build them yourself by combining strings with variables, the whole link is static and something you get from the Stripe Dashboard or API
its the id of the price
so its a variable that has the id
hmm yeah but that makes no sense?
does https://buy.stripe.com/price_xxx actually do anything if you visit such a link?
Yes
`use Stripe\Product;
include('config.php');
require_once('./assets/libs/stripe-php-10.1.0/init.php');
$stripe = new \Stripe\StripeClient(
'keyy'
);
$product = $stripe->products->create(
[
'name' => 'Basic Dashboard',
'default_price_data' => [
'unit_amount' => 1,
'currency' => 'eur',
],
'expand' => ['default_price'],
]
);
$product_id = $product->getLastResponse()->headers["Request-Id"];
$product_price = $product -> default_price -> id;
$product_link = $stripe->paymentLinks->create([
'line_items' => [
[
'price' => $product_price,
'quantity' => 1,
],
],
]);
header('Location: https://buy.stripe.com/<$product_price>');`
that is my code
but i dont know how to set a varible in a link so the id will be automatic there
I want that the variable will become example https://buy.stripe.com/test_4gwaGVcB94yL2KAcMQ
it's just header('Location: ' + $product_link->url);
https://stripe.com/docs/api/payment_links/payment_links/object?lang=php#payment_link_object-url
thanks
Fatal error: Uncaught TypeError: Unsupported operand types: string + string in C:\xampp\htdocs\index.php:42 Stack trace: #0 {main} thrown in C:\xampp\htdocs\index.php on line 42
ah yeah, it's PHP
header('Location: ' . $product_link->url); I think to concat strings in PHP (uses a .) you're the PHP dev so probably know more
i am a newbie in php so xD
It works 😄
i have a other question qlso
sure, what's up?
How can i set the payment methode? only on 1
example bancontact
`$product_link = $stripe->paymentLinks->create([
'line_items' => [
[
'price' => $product_price,
'quantity' => 1,
],
],
]);`
you don't have to change the code, if you activate Bancontact on https://dashboard.stripe.com/settings/payment_methods in your settings it will be shown on the PaymentLink page if possible.
Yeah
but i want
that
if they press on bancontact on the site
they can only pay with bancontact
if they press on ideal they can only pay with ideal
so i want to set in the code
that you can pay with that
then you can use https://stripe.com/docs/api/payment_links/payment_links/create?lang=php#create_payment_link-payment_method_types and set explicitly the types you want instead.
what have you tried?
that's why we have docs and a test mode really, so you can try it
anyway
to save you time, it's 'payment_method_types'=> ["bancontact"],
Thanks
but do try it yourself before just asking, it's straightforward and you'll learn more about coding and Stripe by trying!
hi
$stripe->prices->update( $product_price, ['metadata' => ['default_price' => '10']] );
this is good right?
becouse it give me for this no error
) The Checkout Session's total amount due must add up to at least €0.50 eur
i get that error
Hi! I'm taking over this thread.
The Checkout Session's total amount due must add up to at least €0.50 eur
The total for a Checkout Session must be at least 0.50€, otherwise it won't work. So it looks like your total is too low.
Can you share the request ID (req_xxx) where you see that error? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_eAfJHS22dshWyM
This is the request where you created the payment link: https://dashboard.stripe.com/test/logs/req_Xhxkfw8FBc0qOm
The price you used is for 0.01€, which is less than 0.50€, that's why it fails.
yes but how can i change the price in code?
automatically