#Linq2-connect
1 messages · Page 1 of 1 (latest)
@dire blade could you share an example of a ch_xxx/py_xxx/pi_xxxx payment ID so I can see exactly the API requests you're making?
Send £11.00 main Stripe Account, take £0.52 Fee, send £10.00 to the connected account and leave the remaining £0.48 in the main account??
That should really just be for example, create a PaymentIntent with amount:1100 (11 pounds) and a transfer_data[amount]:1000 (10 pounds) I would think.
also yes (1100 * 91 / 100); is 1001 which is why you see £10.01 I guess! and 90% is £9.90 yes. Not sure I follow the issue? You're using a percentage so don't you expect that to happen? I don't understand why you use a percentage but then want the amount to be something static. If you want to, you could round the result to some concept of a "closest round number" with some extra code!
$amount = 990;
// bring to closest 100 multiple
echo ceil(100 / $amount) * 100;
$amount = 1001;
// bring to closest 100 multiple
echo ceil(100 / $amount) * 100;
$amount = 1000;
// bring to closest 100 multiple
echo ceil(100 / $amount) * 100;
for example in PHP you can use ceil that way, all those examples print 1000 so 10 pounds (based on https://stackoverflow.com/questions/11022488/javascript-using-round-to-the-nearest-10/11022517)
Hi Sorry new to this, just trying to wrap my head around it all, we had a developer who wrote it, I'm still trying to figure out what is doing what and where, where would i find ch_xxx/py_xxx/pi_xxxx?
it's the ID of object that's created when calling the API(you might find them on your Stripe dashboard for example https://dashboard.stripe.com/test/payments )
pi_3JhB1YBSmYxaSWkP1BR4I5Ba
I'll look in a bit but did you read the rest of my replies?
it should answer you I think
yep so you can see on https://dashboard.stripe.com/test/logs/req_o1IPg2F1cwZa4v that you pass amount:1100 (11 pounds) and a transfer_data[amount]:1001 (10.01 pounds) so that's what your code is currently doing. As I described above, that is 91% yes(which is what the code you shared is supposed to do). Not sure what your overall goal is but if you want to add some extra logic to try to round things to a more whole number you definitely can.
yes, I'm trying to figure it out also work out what the other developer has done...
What I can find in the code is, on the booking page there is a bit of JavaScript
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button" style="float:right;"
data-key="{{ config('app.STRIPE_PUBLISHABLE_KEY') }}" data-email="{{ auth()->user()->email }}"
data-name="{{ auth()->user()->name }}"
data-amount="{{ $total_payable_amount * 100}}"
data-currency="{{config('app.GC_CURRENCY')}}"
data-locale="auto"></script>
That code must be something else
it's not related to creating PaymentIntents like the example you shared
maybe look for \Stripe\PaymentIntent in your codebase
or strings like transfer_data
What I'm trying to do is the following:
The Partners Product is £10.00, we add a 10% fee which equates to £11.00 Total
When it goes to Stripe the FULL £10.00 should be transferred to the connected account and the Main account should be £1.00 Fee minus the transaction fees
public function stripePayment(\Illuminate\Http\Request $request)
{ $token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
// $partneruser = User::where('stripe_account_id', '!=', null)->where('role_type', 1)->first();
$partneruser = Partner::find($request->input('partner_id'))->with('user')->first();
if ($partneruser) {
if (($partneruser->user->stripe_account_id == '') || ($partneruser->user->stripe_account_id == null)) {
return;
}
}
(float) $totalamount = $request->input('total_payable_amount');
$partneramount = ($totalamount * 90 / 100);
$adminamount = $totalamount - $partneramount;
\Stripe\Stripe::setApiKey(config('app.STRIPE_SECRET_KEY'));
$customer = \Stripe\Customer::create([
'name' => Auth::user()->name,
'email' => $email,
'source' => $token,
'description' => 'User id: ' . Auth::user()->id,
]);
$payment_intent = \Stripe\PaymentIntent::create([
'payment_method_types' => ['card'],
'confirm' => true,
'amount' => $totalamount,
'currency' => config('app.GC_CURRENCY'),
'on_behalf_of' => $partneruser->user->stripe_account_id,
'transfer_data' => [
'destination' => $partneruser->user->stripe_account_id,
'amount' => $partneramount
],
'payment_method_types' => ['card'],
'customer' => $customer->id,
'setup_future_usage' => 'on_session',
'metadata' => [
'order_id' => rand(10000, 1000000),
],
// 'return_url' => config('app.url') . '/payment-success/',
// 'cancel_url' => config('app.url') . '/payment-failure/',
]);
@dire blade to be clear I can't write your code for you.
When it goes to Stripe the FULL £10.00 should be transferred to the connected account and the Main account should be £1.00 Fee minus the transaction fees
I answered that above :
That should really just be for example, create a PaymentIntent with amount:1100 (11 pounds) and a transfer_data[amount]:1000 (10 pounds) I would think.
$partneramount = ($totalamount * 90 / 100); that is getting 90% of "total_payable_amount".
and it's what is used for transfer_data[amount] in that code. So if the "total_payable amount" is 1000 (10 pounds) then it's 9000, if the if the "total_payable amount" is 1100 (11 pounds) it's 990 (9.90 pounds).
you control all the logic and code here so there's limited input I can give you.
hang on I've found another bit of code what they have written, which I think I can redo to make it calculate correctly.
I think you calculate 90% of the final price(the 11) when you should be calculating it on the price before you added the 10% fee(the 10)
I've sorted it, just re-wrote the booking form and split it there out rather than trying to take off the 10% off the full amount at this stage $partneramount = ($totalamount * 90 / 100);