#elazhari-laravel
1 messages · Page 1 of 1 (latest)
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
I'm sorry you gave me nothing to go on for now
What is the problem? What is your code?
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
Did we talk about this before? I feel like some asked that question with that code multiple times before
yes
That is the PaymentIntent creation yes
that still leads to no payment attempt, so there's nothing to Transfer
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',
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
right
but
i need to do it dynamic
because it-s better too retrieve it from stripe
not using a fixed one
👋 stepping in
hello
hello
Yes it can be retrieved from Stripe, by using the Retrieve PaymentIntent API
https://stripe.com/docs/api/payment_intents/retrieve, call this with your Payment Intent Id pi_3LAIt1JiicWbnm4L1JdDfOQ3, then takes the response's charges and take the Charge Id from there
\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
They are 2 separated functions? For 2 different requests?
there are one for the payment intent
and thereis another one for the transfer
in another modul
Controller*
Let's take a step back and let me ask some question
Where did you take the value of pi_3LAIt1JiicWbnm4L1JdDfOQ3?
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
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
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
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:
- What input data do you have? (in example: you have $request->payment_intent from POST parameters)
- What logic will you do? (in example: you want to create a Transfer)
- What is the output? (in example the created Transfer Id)
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
after the payment intent success
i want to send a percentage to the store owner
Is this from a different function?
Ok I got it. The issue here is that when you create Transfer, you don't have the PaymentIntent Id
Let me ask another question, how is this transfer function called? Is it triggered by some HTTP request to your server?
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
No I am not asking that
but i don't know how to apply the source code
I am asking about your business logic
yes
By which scenario, you image your Transfer function is called?
in example, when your customer does something on your site?
Right? So you don't need a separated function, you need to write the Transfer logic right after you have the PaymentIntent succeeded
okay right but then i need the restaurant id to retreive the
account id
stripe
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
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
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
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
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
You can do that, but it's not recommended since you don't know what PI related to
i wqnt just to make this work till i will find
a solution my customer is waiting me for a month
I recommend talking to your frontend developer first. It's really depends on them to send you the PaymentIntent Id
ok
but every payment
i ll see
can i know just how to get the transfer from the balance
just don't specify the source_transaction
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
so you have a charge id this time
i added that is it good like this?
It's incorrect since you shouldn't create another Charge. Your customer is already billed from the previous Payment Intent
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
ok buthow the charge functions go widout the card infos or the other things ?
how the charge functions go widout the card infos or the other things ?
You were creating it using source =tok_visaso 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
i understand now
okay
i have an idea
i ll make a charge with test card with a huuuge number
hhhhhhhhhhhhhhhhh
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!