#KarlMeyer
1 messages · Page 1 of 1 (latest)
Hello. Unfortunately we can only support users in English in here
Ok cool. What can I help you with?
I am trying to call this variable {{summe}}, nbut it gives me an error in symfony:
this is the code:
$session = Session::create([
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => 'T-shirt',
],
//'unit_amount' => 2000,
'unit_amount' => '{{summe}}',
],
'quantity' => 1,
]],
'mode' => 'payment',
Ah ok. Can you share the request id? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center 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.
There's also a possibility the error occurred before the request reached our servers, so there may not be a request id. What was the error message?
I believe ist this one: req_5rIp8E3nnMxpHe
invalid integer: {{summe}}
thats the error message
Ah yeah you're just passing a string with braces around the word summe
If summe is set to an integer, just pass the variable without quotes or braces around it
when I don't use the quotes i get: syntax error, unexpected token "{"
Yeah remove the braces too. I'm not a PHP programmer, but I think it should be: 'unit_amount' => summe
in the html I have:
{% set summe = summe + bestellung.preis %}
{{summe}}
Ok but you create the checkout session on the backend
without the braces I get: Undefined constant "App\Controller\summe"
So what you have in html isn't relevant here
Or at least you should be creating the checkout session on the backend. Is that what you're doing?
I created an html page, where I call diferent values from the server. the added values are returned in the variable {{summe}} in the same html. I just wanted to pass this variable to the payment form
Yes I understand, but unless the summe variable exists in that scope on the server (not in your html) you can't reference it
and you'd need to reference it like 'unit_amount' => summe
Because it's server side code, nothing is being templatized or filled in like your html is
Somewhere in that function you'd set $summe = summe + bestellung.preis or whatever the proper syntax for that in PHP is. then reference it in the session creation with 'unit_amount' => summe
Or if you have summe set in your javascript code on the front-end, you can pass that to your backend to create the checkout session
But 'unit_amount' => '{{summe}}', is not how you reference a variable in the backend
I understand. Thank you for your help. I will try and reference that variable in a session🙏