#elazahari-question

1 messages · Page 1 of 1 (latest)

reef wren
#

hello please just ask your question and we can help

#

@golden bridge anything I can help with?

golden bridge
#

hiii

#

sorry

#

for late

#

i was working to fix the problem

#

@reef wren

reef wren
#

we mostly just need the question to help you 🙂

golden bridge
#

thank you

#

for your patient

reef wren
#

I'm heading out but my colleagues can help once you ask your question

golden bridge
#

oww

#

okay brother

#

btw

#

//successfuly received payment
if ($request['method'] == 'STRIPE') {

                $restaurant = Restaurant::where('id', $newOrder->restaurant_id)->first();

                if ( $restaurant->stripeId != null) {

                    \Stripe\Stripe::setApiKey(config('setting.stripeSecretKey'));

                    $percentage = 95;
    
                    $transfer = \Stripe\Transfer::create([
                        "amount" => round(($percentage / 100) * $orderTotal),
                        "currency" => 'brl',
                        "source_transaction" => null,
                        "destination" => $restaurant->stripeId,
                    ]);
                }
            
            }
#

i want to make transfer after a successfull payment intent

#

as you see here

#

if ($user) {

            \Stripe\Stripe::setApiKey(config('setting.stripeSecretKey'));

            $percentage = 95;
            $intent = \Stripe\PaymentIntent::create([
                'amount' => $request->amount,
                'payment_method' => $request->id,
                'payment_method_types' => $request->payment_method_types,
                'currency' => $request->currency,
              
            ]);

            return response()->json($intent);
            
        } else {
            return response()->json(['success' => false], 401);
        }
ebon berry
golden bridge
#

because i'm using two seperated functions]

#

i want to know how i can use the charge id

#

or better how to retreive

#

it

#

from a specific order

ebon berry
#

destination charges will make things easier for you - it will automatically create the Transfer once the PaymentIntent is successful

golden bridge
#

yes right i did that but i have problems

#

wait let me check again

#

@ebon berry

#

i can-t do the destinations charges

#

because i don-t have the restaurant id on the api request to call it and retrieve the specific stripe account

#

id

#

$intent = \Stripe\PaymentIntent::create([
'amount' => $request->amount,
'payment_method' => $request->id,
'payment_method_types' => $request->payment_method_types,
'currency' => $request->currency,
'transfer_data' => [
'amount' => round(($percentage / 100) * $request->amount),
'destination' => $restaurant->restaurant['stripeId'],
'destination' => 'acct_1L1dqjGOusD4vd2A',
],
]);

ebon berry
#

why can't you retrieve that information beforehand?

golden bridge
#

i'm using minifies react js

#

the code is can't be edited

#

and i can't change the request

#

do you have some experience on react js too ?

#

because i'm really in trouble bro

ebon berry
#

i'm a bit confused, if you need a basic sample to get started, you can refer to this guide (which also has an example in React) : https://stripe.com/docs/payments/quickstart

You would edit the PaymentIntent parameters in that sample to create a destination charge.

golden bridge
#

yes i hqve the destinition is worked perfectly

#

but i need to retrieve stripe account id hahha

#

i4; too confused btz

#

w

ebon berry
#

have you created any test connected accounts?

golden bridge
#

yes

#

the problem

#

is in my code

#

i'sure

#

i missed something

#

i want to retrieve the charge id for the payment intent

#

to add it in the source_transaction

ebon berry
#

i feel like we're talking about entirely different things here

golden bridge
#

or if there is any other way without the charge id to get money directly from the balance

golden bridge
ebon berry
golden bridge
#

yes right

ebon berry
golden bridge
#

picture nu;ber 3 is the picture where the request of plqiing ordere

#

as you see it's seperated

#

accept-stripe... is the payment intent function

#

the confirm is going with stripe-js

#

but the code is minified but i have the full source code and i don't know how i can apply it

ebon berry
golden bridge
#

@ebon berry i have the transaction id

#

parametre

ebon berry
#

what transaction id?

golden bridge
#

i think it will not work

#

there are any other way to take payment

#

from the balance

#

without the charge id i can-t get it here

ebon berry
#

why can't you get it here?

#

what error are you seeing?

golden bridge
#

the source_transaction is obligatory for brasil users

#

then now i don-t see the charge id or any of intent parameters on the other function

#

th problemm is retreiving the payment intent

#

parameters

ebon berry
#

i see you've retrieved the PaymentIntent before

#

have you confirmed it?

golden bridge
#

it's confirmed

#

and after i want to retreive it on the next function

ebon berry
#

can you share the PaymentIntent id here?

golden bridge
#

$restaurant = Restaurant::where('id', $request->restaurant_id)->first();
if ($user) {

            \Stripe\Stripe::setApiKey(config('setting.stripeSecretKey'));

            $percentage = 95;
            $intent = \Stripe\PaymentIntent::create([
                'amount' => $request->amount,
                'payment_method' => $request->id,
                'payment_method_types' => $request->payment_method_types,
                'currency' => $request->currency,
                // 'transfer_data' => [
                //     'amount' => round(($percentage / 100) * $request->amount),
                //     //'destination' => $restaurant->restaurant['stripeId'],
                //     'destination' => 'acct_1L1dqjGOusD4vd2A', 
                // ],
            ]);

            return response()->json($intent);
            
        } else {
            return response()->json(['success' => false], 401);
        }
}
ebon berry
#

the PaymentIntent id looks like pi_xxx

#

you have it here in the screenshot, can you paste that id here for me to take a look

golden bridge
#

okay

#

pi_3LAIt1JiicWbnm4L1JdDfOQ3

ebon berry
#

if you retrieve this PaymentIntent, and look at charges.data[0].id

#

the charge id is there

golden bridge
#

i'm going to try it again and i ll reply to you

#

yes it"'s there but how i can retreive in another

#

place

ebon berry
#

what do you mean by another place?

golden bridge
#

another

#

modul

#

but the same page

#

'another function'

#

it's really complicated

ebon berry