#elazhari-transfer-connect

1 messages ยท Page 1 of 1 (latest)

native lantern
#

hello

warped viper
#

hi dear

native lantern
#

soooorry wrong thread

warped viper
#

no problem

native lantern
warped viper
#

i did everything but i got error 500

#

can you found wher is the problem

#

e*

native lantern
#

I'd recommend debugging your code

#

You need to add logs, read the PHP error log on your server, etc.

#

If you do you will see the exact error as our API will tell you exactly waht the problem is

warped viper
#

i did it but no results

#

it's just showing 500()

native lantern
#

no you didn't

#

500 means simply a PHP error

warped viper
#

yyes i know

#

wait

native lantern
#

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

warped viper
#

okay

native lantern
warped viper
#

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

native lantern
#

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

warped viper
#

i'm not lieng bro it's the truth

#

why i want help if i'am lieng

warped viper
native lantern
#

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

warped viper
#

the transfer_data parameter

#

get the funds from

#

the same payment transaction

native lantern
#

no

#

there's no transaction

warped viper
#

are you sure?

native lantern
#

You haven't confirmed the PaymentIntent, it hasn't charged anyone yet, at least with the code you shared

warped viper
#

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

native lantern
#

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

warped viper
#

okay

#

is the calling for charge id

#

is correct or no?

native lantern
#

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

warped viper
native lantern
#

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

warped viper
#

it's not picture

#

it's a rdp

#

๐Ÿ˜‚ ๐Ÿคจ

native lantern
#

lol I know but it's a picture of your screen

#

we're all devs, just share real code here ๐Ÿ™‚

warped viper
#

it's having more than 1000 line

native lantern
#

not really though

#

Like you only need to share a handful of line, like your first picture

warped viper
#

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);
    }
}
native lantern
#

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

warped viper
#

i'm understand it

#

i'm just need who know more stripe

#

i'm not using

#

it

#

at all in my projects

native lantern
#
  'amount' => $request->amount,
  'payment_method' => $request->id,
  'payment_method_types' => $request->payment_method_types,
  'currency' => $request->currency,
]);```
this is the PaymentIntent creation
warped viper
#

yes

native lantern
#

This creates a PaymentIntent, nothing else. No charge attempt happens

#

At that point, after that call, you do not have anything inside charges

warped viper
#

okay tell me what i can do

native lantern
#

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

warped viper
#

any suggested changes ?

#

right

native lantern
#

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?

warped viper
#

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

native lantern
#

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?

warped viper
#

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

native lantern
#

Unfortunately you're really just looking for a solution and not understanding of it. I understand why, but it won't really help you

warped viper
#

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

native lantern
#

Let me explain the normal flow of funds

warped viper
#

btw as i see the charges parameter is null

#

goahead

native lantern
#

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

warped viper
native lantern
#

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

warped viper
#

yes

#

i'm going to do my best to get a solution

#

thank you for nothing

native lantern
#

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

warped viper
#

wait

#

i'm going to check the server logs

native lantern
#

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.

warped viper
#

okay i ll see the problem and i ll back to you

#

after app debuging it's not showing the exact error

native lantern
#

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

warped viper
#

i will not using transfer

#

i'm tired

#

hhahah

#

thank you

native lantern
#

oh well sorry I couldn't help more unfortunately

warped viper
#

no problem that's it

native lantern
#

You can always contact our support team for help, that might be better, they can look at your logs