Session::get(...) is just one of the way to save the $charge_id
- Is it a temporary token or transaction ID?
- If it is a transaction ID, yes you should save it for future refunds.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello guys , i integrate stripe successfully ,one question , when i create payment it generate token, which is $charge_id.
my question is should i save $charge_id in my database ?
b/c when i request refund it askes $charge_id, where can i get it ? the documentation $charge_id = Session::get('charge_id');
session part is not clear for me
any help, thanks
@aronaman You should not be creating a token using input data like that. If you’re using a customer’s card number, expiry data and CVV in a PHP file, then that data is touching your server, and you then need to worry about PCI compliance—which defeats the point of using a payment processor like Stripe.
Instead, follow Stripe’s documentation and example and instead use their JavaScript SDK to capture card details. The card details will only ever touch Stripe’s servers then (meaning you no longer need to worry about PCI compliance) and Stripe will issue you a token which you can then use to create charges. After creating a charge, if you need to save the charge ID to perform refunds in the future, then do so.
Please or to participate in this conversation.