#sxe-success-url
1 messages · Page 1 of 1 (latest)
Hu
Hi
When my payment is confirmed and the url is being redirected to the one which i've set it on js, url_param
If I
echo $_GET['secret_code'] ```
Works fine. It shows the secret code.
But, if I check in my DB the secret code, it does not find it, even if, previously, i've inserted it inside the db.
Sorry I don't really understand... you are seeing the data you want in your success Url, then you are inserting it into your database, then you query your database but that data doesn't show up in the database?
webhook php
if ($event->type == 'payment_intent.succeeded')
{
$stmt = $con->prepare("INSERT INTO x (x) VALUES (x)");
.....
On webhook.php i'm inserting into database the payment id, the secret_Code as can we say it.
on success url, I'm doing this;
$stmt = $con->prepare("SELECT ID FROM table
WHERE secretcode = ?");
$stmt->bind_param("s", $_GET['payment_intent']);
$stmt->execute();
$results = $stmt->get_result();
while($row = $results->fetch_assoc()) {
$ID = $row['ID'];
}
echo $_GET['payment_intent'];
echo $ID ;
$ID is null
while $_Get['payment_intent'] is not null.
Okay so then it seems you aren't retrieving from your database correctly or you aren't inserting correctly. So I'd first log our $results here
Value exists in DB.
If I enter on the DB and check it with the query, I can find it.
Okay so then log out $row and what do you see?
Yeah or $error_log($row)
I'm not the most familiar with PHP but I think one of those two options should return something
NULL
echo var_dump($row);
pi_3L07adLKPu9R0yzS1X72iO6O
NULL
echo $_GET['payment_intent'];
echo "<br>";
echo var_dump($row);
Okay so I would assume that is the issue then
What is $results->fetch_assoc()
What is the definition of that method?
We're fetching the results get by the query.
$stmt = $con->prepare("SELECT Factura FROM PlatiEfectuate
WHERE Identificare = ?");
$stmt->bind_param("s", $_GET['payment_intent']);
$stmt->execute();
$results = $stmt->get_result();
while($row = $results->fetch_assoc()) {
$Factura = $row['Factura'];
}
$results = $stmt->get_result();
This gets the results from the query itself.
while($row = $results->fetch_assoc()) {
This grabs them, fetch them as non-array values
I think that, my succes page loads before the insert query gets run.
Oh fetch_assoc() is built in mysql method
Got it
So yeah, then the issue seems to be with the insert timing
If you are able to retrieve the PI ID from the URL but your query for that specific PI in your database isn't returning it, then you need to debug the insert
Is there any method to call the success url after a while?
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
return_url: 'url',
},
});
``` this
No you would need to use setTimeout or something
Can you give me an example?
You still would need to trigger that method somehow though
Mostly you can just reload your webpage, no?
and that will trigger the clientside action?
Well, that's the funny thing,
If I make a php code to reload the page once,
Actually let me try.
I refreshed the page.
with header
And still did not work.
I will try to header in 10 seconds, then.
Works fine, ty1
What works? Refreshing the page to trigger the client action?
Or you are getting the data now?
Refreshing the page after 5 seconds. But, I'm trying to trigger the client action somehow.
How you doing @mild walrus ?
I think I found why my page needs to be reloaded after 5 seconds.
I need to work on my queries, because I have 10 php queries right now
and let's say, each 0.5 second
0.5 x 10 = 5 sec
Yep that makes sense
That said... why do you need to be able to retrieve the PI from your database immediately after it is inserted?
As you noted, you have it from the success URL
So you can handle your database stuff asynch and not worry about that immediately
Exactly lol
why should I run queries inside the webhook.php
whenI can run them inside the success page