#Rian ROnald
1 messages · Page 1 of 1 (latest)
yes
"custom_fields": [
{
"dropdown": null,
"key": "discordid",
"label": {
"custom": "Discord ID",
"type": "custom"
},
"numeric": null,
"optional": false,
"text": {
"maximum_length": null,
"minimum_length": null,
"value": "962801895188090960"
},
"type": "text"
}
],
So when you create a checkout session with this in your code and you attempt to access custom_fields[0], what do you get?
Nothing
No index error?
nope
And when you attempt custom_fields[1] you see the field object?
Nothing
So then we have to ask if the custom_fields property is something the object exposes after you pass it.
What is behind your question? What are you trying to do?
$stripe = new \Stripe\StripeClient('SECERE EY');
$checkoutSessions = $stripe->checkout->sessions->all(['limit' => 3]);
$found = false;
foreach ($checkoutSessions as $checkoutSession) {
$discordID = $checkoutSession->custom_fields[0]->text->value;
if ($discordID === $discord_id) {
$found = true;
include('includes/config.php');
$user_query = "UPDATE users SET paid = 1 WHERE discordID = :discordID";
$stmt = $pdo->prepare($user_query);
$stmt->bindParam(':discordID', $discordID, PDO::PARAM_INT);
$stmt->execute();
$url = "WEBTHIng";
$hookObject = json_encode([
"embeds" => [
[
"title" => "Purchase has been made!",
"type" => "rich",
"color" => hexdec( "3cb2f7" ),
"fields" => [
[
"name" => "Discord Tag",
"value" => "<@" . $discord_id . ">",
"inline" => true
],
[
"name" => "Discord ID",
"value" => "$discord_id",
"inline" => true
],
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt_array( $ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
]
]);
$response = curl_exec( $ch );
curl_close( $ch );
break;
}
What im trying to do is when a user does a purchase it redirects them to the link that has this code and it searches for their id they put in the field with the session id then updates the db and sends a webhook