#elazhari-transfer-connect
1 messages ยท Page 1 of 1 (latest)
hi dear
soooorry wrong thread
no problem
So what's the issue with making a Transfer? Our API documentation is here: https://stripe.com/docs/api/transfers/create and that's how you make it (we have examples in all languages, even PHP)
I'd recommend debugging your code
You need to add logs, read the PHP error log on your server, etc.
you also need to catch errors cleanly in your code, see https://stripe.com/docs/error-handling
If you do you will see the exact error as our API will tell you exactly waht the problem is
Right now you are not catching any exceptions in your code
so you literally crash
you need to fix that, and read your PHP error log which would have the exact error
okay
you can also look at your logs in your Stripe Dashboard https://dashboard.stripe.com/test/logs and see the failed request explicitly
that's what i want to tell
you
when i'm using transfer_data parameter
it's working fine
and it's show's on the stripe logs
but when i'm using a normal transfer on the stripe it's say for brazil need source_transaction parameter
when i'm adding this parameter i don't see any transaction fail in the stripe logs
I can tell you none of that is possible
like the first call in your picture doesn't confirm the PaymentIntent
so there's never a payment attempt in the first place
the payment goes well it's just the first part of the code
I mean I can tell you for sure it can't work
It only works likely because it's Test mode and you have a lot of funds in your balance
are you sure?
You haven't confirmed the PaymentIntent, it hasn't charged anyone yet, at least with the code you shared
it's just a little part
of the code
not all the code
the payment intent is going to charge without problems
the problem just in the transfer
the second part of the image if you didn't get any solution just say that o problem
My advice is to start by reading: https://stripe.com/docs/connect/charges-transfers#transfer-availability which covers in details how the flow of funds
Now to answer your real question: some countries have different rules. In some countries you can't just "transfer funds from wherever to them"
you have to associate the transfer of funds with an existing payment origin. This is done via source_transaction
and for that Transfer creation to work, the ch_123 from the Charge has to be passed, which only happens after the PaymentIntent confirmation
yes that part of the code is correct
but if you print that value right now you'll see it's empty/doesn't work
because, just to reiterate, you never confirmed the PaymentIntent, so you have nothing in charges
that's just pictures of pictures ๐
If you take the time to call var_dump($intent) before the Transfer creation and look at the output you'll see charges is empty
lol I know but it's a picture of your screen
we're all devs, just share real code here ๐
it's having more than 1000 line
not really though
Like you only need to share a handful of line, like your first picture
public function acceptStripePayment(Request $request)
{
$user = auth()->user();
if (in_array('ideal', $request->payment_method_types)) {
//some logic later to be added
}
if ($user) {
\Stripe\Stripe::setApiKey(config('setting.stripeSecretKey'));
$intent = \Stripe\PaymentIntent::create([
'amount' => $request->amount,
'payment_method' => $request->id,
'payment_method_types' => $request->payment_method_types,
'currency' => $request->currency,
// 'transfer_data' => [
// 'amount' => 100,
// 'destination' => 'acct_1L1dqjGOusD4vd2A',
// ],
]);
$transfer = \Stripe\Transfer::create([
"amount" => 100,
"currency" => $request->currency,
"source_transaction" => $intent->charges->data[0]->id,
"destination" => "acct_1L1dqjGOusD4vd2A",
]);
return response()->json($intent);
} else {
return response()->json(['success' => false], 401);
}
}
Ultimately, sorry, I already explained the exact issue, let's look at that first
I'm worried you don't really understand your code overall
i'm understand it
i'm just need who know more stripe
i'm not using
it
at all in my projects
'amount' => $request->amount,
'payment_method' => $request->id,
'payment_method_types' => $request->payment_method_types,
'currency' => $request->currency,
]);```
this is the PaymentIntent creation
yes
This creates a PaymentIntent, nothing else. No charge attempt happens
At that point, after that call, you do not have anything inside charges
okay tell me what i can do
i got it
continue
but still your code immediately goes and do this $transfer = \Stripe\Transfer::create([ "amount" => 100, "currency" => $request->currency, "source_transaction" => $intent->charges->data[0]->id, "destination" => "acct_1L1dqjGOusD4vd2A", ]);
This: $intent->charges->data[0]->id is wrong. Because there's nothing in data. It's en empty array
I'm sorry, you're kind of just asking for the fix instead of understanding so it's hard to help you here ๐ฆ
Why did you comment out transfer_data on PaymentIntent creation?
just i have tested alot of stripe parameters
to try parameter what it did
because i don't like just reading i'm testing also
okay so before Brazil, what happened? Because the code you wrote would never have worked. Did you just not have source_transaction and you always float the money for everyone all the time?
the payment intent is wrking well$
without problems
and the function is working
cuz i'm using it as an api in my backend to call it
anytime if i need it
then it's working
i want now any solution for it if you have anything to help
me
i ll be thankful
Unfortunately you're really just looking for a solution and not understanding of it. I understand why, but it won't really help you
okay
it's made me ve a headache
hahaha
stripe is organized but have a big doc
you can explain more i want to understand
Let me explain the normal flow of funds
1/ You create a PaymentIntent saying "I want to charge $10 USD"
2/ Client-side, you collect card details from your customer and you confirm the PaymentIntent. This creates a Charge ch_123 representing the money moving into your account. The funds will not be available immediately, it takes 2 days in the US for example
3/ Later, you decide you want to send funds to your connected account. Unless you already have money in your account balance and want to float the money, you almost always want to pass source_transaction as documented in the doc I linked earlier (https://stripe.com/docs/connect/charges-transfers#transfer-availability). This should look like source_transaction: 'ch_123'. So it has to happen after step #2
you and your pictures ๐น
you're a developer, you own the code, you can look at the exact error message if any, the state of each API request and explain what you see instead
I try to help but that picture has nothing
there's a red thing saying a request filed
the error message below is truncated entirely
I'm asking you to take a few extra seconds to look into the error and explain what you see instead of a screenshot of your screen
I'm sorry I know you're frustrated, but I'm a developer helping you, another developer, debug your code, not write it for you. I've explained a few things and your response is immediately a picture of something and no explanation.
okay i ll see the problem and i ll back to you
after app debuging it's not showing the exact error
sure, because it's the same problem as yourfirst question when you open the thread
you have a PHP crash, you don't handle errors properly, so it just crashes and returns 500
if you handle errors based on the docs I shared https://stripe.com/docs/error-handling you will see a real error
oh well sorry I couldn't help more unfortunately
no problem that's it
You can always contact our support team for help, that might be better, they can look at your logs