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

mstdmstd's avatar

Which stripe API must be used when customer recieves money from owner of stripe account ?

Hello, In laravel 5.8 app with stripe/stripe-php: ^7.50 when customer pays for provided services it has code:

            \Stripe\Stripe::setApiKey( config('app.STRIPE_TEST_KEY') );
            $user = User::where('id', $request->user_id)->first();
            $customer_id = $user->stripe_customer_id;

                    $charge = \Stripe\Charge::create([
                        'amount' => $request->amount * 100, // Say $request->amount= 50
                        'currency' => $request->currency,   // USD
                        'customer' => $customer_id
                    ]);
                    TransactionsTable::create([
                        'user_id' => $user->id,
                        'type' => $request->card['brand'],
                        'amount' => $request->amount,
                        'currency' => $request->currency,
                        'transaction_id' => $charge->id,
                        'status' => $charge->status
                    ]);

And USD 50 is subtracted from customer card and is added to the owner of stripe account (in dev app.STRIPE_TEST_KEY)

But if in case when customer recieves money from owner of stripe account (customer earned some maney on the site) which API can I to use? The same API/code( \Stripe\Charge::create) with negative sum or other api must be used ? I do not know can I call this operation as refund or other operation?

Thanks!

0 likes
0 replies

Please or to participate in this conversation.