#elazahari-question
1 messages · Page 1 of 1 (latest)
hello please just ask your question and we can help
@golden bridge anything I can help with?
we mostly just need the question to help you 🙂
I'm heading out but my colleagues can help once you ask your question
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);
}
hi there! alright, is there any reason why you're not using destination charges instead? https://stripe.com/docs/connect/destination-charges
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
destination charges will make things easier for you - it will automatically create the Transfer once the PaymentIntent is successful
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',
],
]);
why can't you retrieve that information beforehand?
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
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.
yes i hqve the destinition is worked perfectly
but i need to retrieve stripe account id hahha
i4; too confused btz
w
have you created any test connected accounts?
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
i feel like we're talking about entirely different things here
or if there is any other way without the charge id to get money directly from the balance
source_transaction
i know what you mean brother but the problem is
To clarify, your original code is actually Separate Charges and Transfers (SCT). [0] Now, if you want to use this flow, that's fine too, it's just going to involve more effort.
yes right
to retrieve the charge id, you would retrieve the PaymentIntent. If the PaymentIntent is successful, you can then get the charge id in the first object of the array : https://stripe.com/docs/api/payment_intents/object#payment_intent_object-charges-data
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
the minified code has nothing to do with your question. What's the problem you're facing here? I see that you have a PaymentIntent but it still requires confirmation. If you want a successful PaymentIntent to perform testing that you will need to confirm that PaymentIntent - either https://stripe.com/docs/api/payment_intents/confirm, or you can pass in confirm=true when creating the PaymentIntent https://stripe.com/docs/api/payment_intents/create#create_payment_intent-confirm
what transaction id?
can you share a link to the exact parameter from the docs : https://stripe.com/docs/api/payment_intents/object
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
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
can you share the PaymentIntent id here?
$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);
}
}
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
if you retrieve this PaymentIntent, and look at charges.data[0].id
the charge id is there
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
what do you mean by another place?
have you tried retrieving the PaymentIntent in your other function then? https://stripe.com/docs/api/payment_intents/retrieve