Ich versuche, den Transaktions-ID nach dem Kauf zu erhalten, aber es gibt leere auf ThankYou SeitePHP-Streifen den Transaktions-ID nach dem erfolgreichen Kauf erhalten
order.php
<?php
\Stripe\Stripe::setApiKey('<test token>');
$amount = 100;
$card = $_POST['stripeToken'];
// Create a Customer
$customer = \Stripe\Customer::create(array(
"source" => $card,
"email" => $email,
"description" => "Example description")
);
// Charge the Customer instead of the card
$charge = \Stripe\Charge::create(array(
"amount" => 100,
"currency" => "usd",
"customer" => $customer->id)
);
// Save the billing info
set_billing([
'customer_id' => $customer->id,
'address' => $address,
'address2' => $address2,
'city' => $city,
'state' => $state,
'country' => $country,
'postal' => $postal,
'trans_id' => $charge->id // Save the transaction id
]);
function set_billing($fields = array())
{
$bdate = time();
$query = "INSERT INTO billings (
customer_id, address, address2, city,
state, postal, country, billing_date, trans_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $GLOBALS['sqlConnection']->prepare($query);
$stmt->bind_param(
'sssssssis', $fields['customer_id'], $fields['address'], $fields['address2'], $fields['city'], $fields['state'], $fields['postal'], $fields['country'], $bdate, $fields['trans_id']);
$stmt->execute();
}
// If successful, redirect to thank you page
header('Location: /thankyou.php?id=' . $user_id);
exit;
thankyou.php
<?php
$s = $sql->prepare('SELECT trans_id FROM billings WHERE user_id = ?');
$s->bind_param('i', $_GET['id']);
$s->execute();
$s->bind_result($trans_id);
$s->fetch();
?>
<ul>
<li>Transaction id: <?php echo $trans_id ?></li>
</ul>
Gibt es ein Problem mit meinem Code?
eingefügt haben, wie Sie trans_id aus billings Tisch holen werden ... In welcher Datei Sie speichern Transaktionsdetails in billings Tabelle? –
Wenn Sie den Kunden belasten, erhalten Sie ein "Nachrichtenarray", versuchen Sie es zu drucken, und Sie erhalten darin auch 'transaction_id'. Genau wie '$ charge_resp = $ charge ['msg']; $ transactionid = $ charge_resp-> id; ' – Nehal
@keziah, anstatt die Transaktions-ID zu holen, müssen Sie sie zuerst auch speichern. Wo hast du 'transaction id' in deine db eingefügt? – Nehal