#elazhari-laravel

1 messages · Page 1 of 1 (latest)

finite isle
#

hello @modern island what do you need help with?

modern island
#

hii

#

please i need to do a transfer i was searching for this for months without any solution @finite isle

#

the problem on the source_transaction parameter

#

i can-t get this parameter value

#

because i have two seperated functions

#

@finite isle

finite isle
#

I'm sorry you gave me nothing to go on for now

#

What is the problem? What is your code?

modern island
#

wait

#

$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,
              
            ]);

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

this is the payment intebt

#

n

finite isle
#

Did we talk about this before? I feel like some asked that question with that code multiple times before

modern island
#

yes

finite isle
#

That is the PaymentIntent creation yes

modern island
#

i don't know

#

but

finite isle
#

that still leads to no payment attempt, so there's nothing to Transfer

modern island
#

i have talked with alooot here

#

i have changed the code

#

i added anothr function

#

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" => 'pi_3LAIt1JiicWbnm4L1JdDfOQ3',
                        "destination" => $restaurant->stripeId,
                    ]);
                }
            
            }
#

it s on oanother model

#

but

#

now i need to retrieve the source transaction from the old function

#

the payment intent

#

or i want to transfer the percentage from the balance without source_transaction

#

i have problem just in the source transaction

#

"source_transaction" => 'pi_3LAIt1JiicWbnm4L1JdDfOQ3',

finite isle
#

sure but source_transaction can not take a pi_123 id, I've explained this many times last time and I'm sure everyone else on my team did

#

we need a Charge id ch_123

#

After the PaymentIntent is confirmed, which happens client-side, at that point you get a payment_intent.succeeded event for example and it will have a Charge id ch_123

#

that's what you need to pass

modern island
#

right

#

but

#

i need to do it dynamic

#

because it-s better too retrieve it from stripe

#

not using a fixed one

hollow quail
#

👋 stepping in

modern island
#

hello

hollow quail
#

hello

#

Yes it can be retrieved from Stripe, by using the Retrieve PaymentIntent API

modern island
#

\Stripe\Stripe::setApiKey(config('setting.stripeSecretKey'));
$intent = \Stripe\PaymentIntent::retrieve($request->payment_intent);

#

i did it already haha but i need it

#

payment intent because i don't hav

#

ee

#

any payment intent values in the api request

#

the transfer functiion is seperated

#

btw

hollow quail
#

They are 2 separated functions? For 2 different requests?

modern island
#

there are one for the payment intent

#

and thereis another one for the transfer

#

in another modul

#

Controller*

hollow quail
#

Let's take a step back and let me ask some question

#

Where did you take the value of pi_3LAIt1JiicWbnm4L1JdDfOQ3?

modern island
#

it's not important because it will change to the charge id but the question is how i can retrieve it i'm going to give you the parameters in every function okay

#

{id: "pi_3LB6pZJiicWbnm4L1iJ5UUA0", object: "payment_intent", amount: 135350, amount_capturable: 0,…}
amount: 135350
amount_capturable: 0
amount_details: {tip: []}
tip: []
amount_received: 0
application: null
application_fee_amount: null
automatic_payment_methods: null
canceled_at: null
cancellation_reason: null
capture_method: "automatic"
charges: {object: "list", data: [], has_more: false, total_count: 0,…}
data: []
has_more: false
object: "list"
total_count: 0
url: "/v1/charges?payment_intent=pi_3LB6pZJiicWbnm4L1iJ5UUA0"
client_secret: "pi_3LB6pZJiicWbnm4L1iJ5UUA0_secret_mUIC74xDYHRuCKMnhVoKXX6cs"
confirmation_method: "automatic"
created: 1655340305
currency: "brl"
customer: null
description: null
id: "pi_3LB6pZJiicWbnm4L1iJ5UUA0"
invoice: null
last_payment_error: null
livemode: false
metadata: []
next_action: null
object: "payment_intent"
on_behalf_of: null
payment_method: "pm_1LB6pXJiicWbnm4LKOC5yu6T"
payment_method_options: {,…}
card: {installments: null, mandate_options: null, network: null, request_three_d_secure: "automatic"}
installments: null
mandate_options: null
network: null
request_three_d_secure: "automatic"
payment_method_types: ["card"]
0: "card"
processing: null
receipt_email: null
review: null
setup_future_usage: null
shipping: null
source: null
statement_descriptor: null
statement_descriptor_suffix: null
status: "requires_confirmation"
transfer_data: null
transfer_group: null

#

this is the payment intent request

hollow quail
#

Thanks for pasting the data. But I am afraid you are off-track already. Let's take a step back and organize your data flow

modern island
#

and this is the function of transfer it's not just a transfer function it's also for another payments gatways and i did an if condition for the transfer to the store owner

#

cash_change_amount: ""
coupon: null
delivery_type: 1
dis: 1.4
location: {lat: "-23.65230870711039", lng: "-47.580027510478416",…}
method: "STRIPE"
order: [{id: 14, restaurant_id: "4", item_category_id: "13", name: "Colágeno FlexGold", price: "89.90",…}]
order_comment: ". "
partial_wallet: false
payment_token: ""
pending_payment: false
schedule_date: null
schedule_slot: null
tipAmount: null
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2JiaXAuY29tLmJyL3B1YmxpYy9hcGkvbG9naW4iLCJpYXQiOjE2NTUxNzI1MjQsIm5iZiI6MTY1NTE3MjUyNCwianRpIjoiNkc1eWVwSWcyejM2ZG1LUCIsInN1YiI6MSwicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlMGIwNDc1NDZhYSJ9.zvrxH0OzqakXj_RjW1JAs6znYiQAexDuQrqvMnPpOvw"

#

total: {productQuantity: 1, totalPrice: 1348.5}
productQuantity: 1
totalPrice: 1348.5
user: {success: true, data: {id: 1,…}, running_order: null, delivery_details: null}
data: {id: 1,…}
auth_token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2JiaXAuY29tLmJyL3B1YmxpYy9hcGkvbG9naW4iLCJpYXQiOjE2NTUxNzI1MjQsIm5iZiI6MTY1NTE3MjUyNCwianRpIjoiNkc1eWVwSWcyejM2ZG1LUCIsInN1YiI6MSwicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlMGIwNDc1NDZhYSJ9.zvrxH0OzqakXj_RjW1JAs6znYiQAexDuQrqvMnPpOvw"
avatar: null
default_address: {,…}
default_address_id: "37"
email: "agameos@gmail.com"
id: 1
name: "Delivery"
phone: "14499"
tax_number: null
wallet_balance: 482.4
delivery_details: null
running_order: null
success: true

#

sorry for that but

hollow quail
#

No worries. My advice is to take a step back and think about your data flow. Please answer these questions:

When you design the your transfer function:

  1. What input data do you have? (in example: you have $request->payment_intent from POST parameters)
  2. What logic will you do? (in example: you want to create a Transfer)
  3. What is the output? (in example the created Transfer Id)
modern island
#

firstly i don't have the payment_intent from the post parameters for Transfer

#

after the payment intent success

#

i want to send a percentage to the store owner

#

i can't use it in the transfer_data because i don't have the parameter of the restaurant id to retrive the stripe account id from database

#

the output for transfer is need a source transaction

#

for complete the function

#

there is anyway to do it with th whole balance

#

transfer from the balance

hollow quail
#

after the payment intent success
i want to send a percentage to the store owner
Is this from a different function?

modern island
#

yes

#

payment intent is from another function in another controller

hollow quail
#

Ok I got it. The issue here is that when you create Transfer, you don't have the PaymentIntent Id

modern island
#

yees i can't retreive it from another function

#

i need a way for it

hollow quail
#

Let me ask another question, how is this transfer function called? Is it triggered by some HTTP request to your server?

modern island
#

the stripe-js is working in a splitted react js in this project

#

and i m using laravel like a backend

#

and the problem the chunks is minified and can't editing this files

#

but i have the source code

hollow quail
#

No I am not asking that

modern island
#

but i don't know how to apply the source code

hollow quail
#

I am asking about your business logic

modern island
#

ok

#

yes

hollow quail
#

By which scenario, you image your Transfer function is called?

#

in example, when your customer does something on your site?

modern island
#

no

#

just after

#

the payment intent

hollow quail
#

Right? So you don't need a separated function, you need to write the Transfer logic right after you have the PaymentIntent succeeded

modern island
#

okay right but then i need the restaurant id to retreive the

#

account id

#

stripe

hollow quail
#

Yes, the problem is that you need both the restaurant's Account Id and the Payment Intent Id to make a Transfer

#

When frontend fire this place-order to backend, it will need to pass in both Account Id, and the confirmed Payment Intent Id

#

Frontend will need to somehow save the PaymentIntent Id from the confirm response they have got, as I see in your screenshot

modern island
#

yes but the confirm function

#

is in the stripe-js

#

minifid

#

section

hollow quail
#

So you need your frontend guy to do it for you

#

Tell them to include it the Payment Intent Id alongside with the restaurant Id

modern island
#

i hqve the source code

#

but i need

#

to know how i can remove the minified

#

and apply the real source code

#

do you have any ideaq about that

hollow quail
#

That's a different thing. You could try it but eventually you will need your frontend guy to do it for you

#

I would recommend don't do it yourself. The minified version doesn't have meaningful variable name and it's just too hard to grasp the logic

modern island
#

yes right

#

bbtw i have a head ache because of that hhh

#

@hollow quail

#

i wqant now just to use the transfer datat

#

i mean if i want to transfer money

#

from the balance

#

not the

#

from a paymeny intent can i do that?

#

@hollow quail

hollow quail
#

You can do that, but it's not recommended since you don't know what PI related to

modern island
#

i wqnt just to make this work till i will find

#

a solution my customer is waiting me for a month

hollow quail
#

I recommend talking to your frontend developer first. It's really depends on them to send you the PaymentIntent Id

modern island
#

ok

#

but every payment

#

i ll see

#

can i know just how to get the transfer from the balance

hollow quail
#

just don't specify the source_transaction

modern island
#

they said

#

for

#

brazil

#

need this parameter

#

it's obligatory for my case

#

$charge = \Stripe\Charge::create(array(
"amount" => round($orderTotal ),
"currency" => "brl",
"source" => "tok_visa",
"transfer_group" => "{ORDER10}",
));

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

please

#

i did a charge request

#

there are any zay to do so;ething like this

#

MM

#

@hollow quail

hollow quail
#

so you have a charge id this time

modern island
#

i added that is it good like this?

hollow quail
#

It's incorrect since you shouldn't create another Charge. Your customer is already billed from the previous Payment Intent

modern island
#

is the payment intent

#

like the charge

#

qnd thqt's not showing any errors at all

hollow quail
#

Payment Intent, or Charge, is to charge your customer. They are similar

#

You are charging them twice, once in PaymentIntent and one in the Charge

modern island
#

ok buthow the charge functions go widout the card infos or the other things ?

modern island
#

btw i need to make transfer

#

from the balance i the brazil

hollow quail
#

how the charge functions go widout the card infos or the other things ?
You were creating it using source = tok_visa so it used a test card. It's not a real world usecase

#

You are going off-track already. Don't create another Charge like this. Instead get your frontend dev to send you the previous/already confirmed PaymentIntent Id

modern island
#

i understand now

#

okay

#

i have an idea

#

i ll make a charge with test card with a huuuge number

#

hhhhhhhhhhhhhhhhh

hollow quail
#

I need to step out. If you have your frontend dev sending the parameter for you and have other questions, feel free to ask in the channel!