Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Aronaman's avatar

stripe fund

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

0 likes
6 replies
laracoft's avatar

@aronaman

Session::get(...) is just one of the way to save the $charge_id

  1. Is it a temporary token or transaction ID?
  2. If it is a transaction ID, yes you should save it for future refunds.
Aronaman's avatar

@laracoft it is transaction id

            $token = $stripe->tokens()->create([
                'card' => [
                    'number'    => $strip['card_no'],
                    'exp_month' => $strip['exp_month'],
                    'exp_year'  => $strip['exp_year'],
                    'cvc'       => $strip['cvv'],
                ],
            ]);

my issue is what about security ?? and did you use Cartalyst\Stripe before ??

laracoft's avatar

@aronaman

  1. As long as you don't save the credit card #, it is ok.
  2. A transaction ID is just a reference number.
  3. No, I have not used Cartalyst\Stripe
Aronaman's avatar

@laracoft which means i dont need to fill a form(number,exp_month...) for refund ?

call saved token and run ??

martinbean's avatar
Level 80

@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.