#linq2-connect
1 messages · Page 1 of 1 (latest)
thanks, it's not my code, someone I asked to do a simple booking system has done the code from line 111 for last 6 weeks they have been at it.
so the code is a bit confusing since it's using both the legacy approach (posting a Token to your server and using Stripe\Charge::create ) and the current approach(using Stripe\PaymentIntent )
the code also creates an Express account and then uses it for a Direct Charge, which is not recommended either(you generally use Destination Charges for Express)
in any case, the code for creating the PaymentIntent doesn't actually do a payment. It just creates the PaymentIntent. To actually process the payment you have to "confirm" the PaymentIntent by calling https://stripe.com/docs/js/payment_intents/confirm_card_payment on the frontend for example, or the backend confirm endpoint https://stripe.com/docs/api/payment_intents/confirm
I would just start over using a guide like https://stripe.com/docs/connect/collect-then-transfer-guide or https://stripe.com/docs/connect/enable-payment-acceptance-guide depending on what your goals are
I did the code up to line 111 for express onboarding, I know this works to create the partner, I take it that bit is still correct?
that seems fine I think
I didn't realise you're able to create a Person object for Express but I guess it's possible if the code work when you run it!
thanks the end goal is, to have partners use the onboarding, then for members to book fishing pegs, the payment goes to the partner, minus admin fees
which goes to the main account
yeah then you want https://stripe.com/docs/connect/collect-then-transfer-guide I would say and the part for creating the payment is https://stripe.com/docs/connect/collect-then-transfer-guide?platform=web#accept-payment
which is that you should either use Checkout(the PHP code creates a CheckoutSession and redirects the browser to it), or PaymentIntents(the PHP code creates a PaymentIntent and then passes it to frontend Javascript to display a card input and process the payment)
the 'old way' that code uses of accepting a token from a POST request should not be used anymore, the links above are the correct way to use Stripe to process payments
<form action="/create-checkout-session" method="POST">
so does that relate to $session = \Stripe\Checkout\Session::create([
yes
so when you click submit, it then runs that code and pushes the data to the connect account?
sorry for been a bit thick, i usually learn visually as slightly dyslexic
Hi! I'm taking over karllekko.
I'm guessing you are talking about this page: https://stripe.com/docs/connect/collect-then-transfer-guide?platform=web#accept-payment
When clicking on the submit button, the customer is redirected to a stripe hosted page called Checkout Session, where they have to enter their payment details.
And once they submit the Checkout Session, then the payment is made to both the platform account and the connected account.
ok so in the code I submitted, if I get rid of everything from line 111
and the data from https://stripe.com/docs/connect/collect-then-transfer-guide
then just Add
then on my checkout form, do I have to pass any hidden fields?
like you used to?
then on my checkout form, do I have to pass any hidden fields?
What do you mean by "hidden fields"? To create a Checkout Session you can reuse the code on the link I shared earlier: https://stripe.com/docs/connect/collect-then-transfer-guide?platform=web#accept-payment
And then you redirect your customers to the Checkout Session URL, it's a stripe hosted page to collect the payment information.
sorry, hidden fields in the form, they used to pass params via hidden fields in the form...
Who is "they"? And what information would you like to pass to the form?
such as this
<input type="hidden" name="main_amount" value="<?php echo number_format((float)$main_amount, 2, '.', ''); ?>" />
pass from the html form to the stripe session
To clarify: when using Checkout Session, you no longer need to create a payment form, Stripe will do that for you!
To set the amount on the Checkout page, we recommend using a price object. So first you create a price object (either in the dashboard or with the API), and then you pass the price ID when creating the Checkout Session: price: "price_xxx".
the price, will be coming from our database, not stripe..
just so i don't get confused again! the documents links sent are as follows:
docs/connect/collect-then-transfer-guide - this transfers all the money to the connected account, then takes 'application_fee_amount' and places that in the main stripe account.
You can directly set the price when creating the Checkout Session with line_items.price_data https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
docs/connect/enable-payment-acceptance-guide - this take payment to the main account and then passes the remainder to the connect account?
docs/connect/collect-then-transfer-guide - this transfers all the money to the connected account, then takes 'application_fee_amount' and places that in the main stripe account.
All money is sent to the platform account, and then a transfer is made to the connected account. In the end the platform only keeps the application fee, and the rest is for the connected account. This image is a good summary:
right got it... so we need to follow this guide docs/connect/collect-then-transfer-guide
which charges the whole monies to the Platform account, then transfers all the monies to the connected account, the transfers the Application fees (which will cover all stripe fees including withdrawal payments)?
Yes, you need to create a Checkout Session like this, and then once the customer fills the payment form, Stripe will automatically take care of sending the funds to your platform and connected account.
with the following, as we don't store items on stripe,
'line_items' => [
[
'price' => 10.00,
'quantity' => 2,
],
Could we add a description of the item
if so what would that param be?
or some id so we could Identify what it is?
with the following, as we don't store items on stripe,
This code won't work. You need something like this (note that I haven't tested this code)
'line_items' => [
'price_data' => [
'currency': 'XXX',
'unit_amount': 1000,
'product_data' => [
'name': "YYY"
]
],
'quantity' => 2,
]
All parameters are listed here: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
Could we add a description of the item
Yes inproduct_datathere isnameanddescription
one last question
we have 2 fees, one for the user and one for the connected account
example a peg booking is £10.00
user we add 2% booking fee
total £10.20 to the user
we charge charge the partner 2% plus 0.25% + 10p (this covers all stripe transaction fees)
how do I take the payment to of £10.20 but only send £10.00 to the connected account and then retrieve the application fees from the connected account?
When creating the checkout sessions you have to set two things:
- The price the customer pays:
price_data.unit_amount - And the application fee the platform receive
application_fee
It's up to you how you set these two amounts.
the booking fee we don't want the partner to see that, that is why I ask
Here "partner" is the connected account?
When using destination charges, the connected account would see the full amount paid by the customer yes.
I want the booking fee to remain in the main account and then the £10.00 to go to the connected account, is that possible in anyway?
That's possible by doing Separate Charges & Transfer. You can learn more about this here: https://stripe.com/docs/connect/charges-transfers
also is it possible to pay several connected accounts in one payment?
also is it possible to pay several connected accounts in one payment?
Yes, with Separate Charges & Transfer you can.