#surajpatidar
1 messages · Page 1 of 1 (latest)
Do you mean you would like to check the Stripe fee of a payment?
You may refer to the guide here for checking the Stripe fee of a payment: https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
any api to retrive in code
i have use this stripe checkout for
expires_at=int(time.time()) + settings.STRIPE_CHECKOUT_SESSION_EXPIRE,
payment_method_types=["card"],
customer=stripe_customer.id,
line_items=[
{
"price_data": {
"currency": "usd",
"unit_amount": int(total * 100),
"product_data": {
"name": product.title,
"description": product.description,
},
},
"quantity": 1,
}
],
invoice_creation={
"enabled": True,
},
metadata={"order_id": order.id, "type": "order"},
payment_intent_data={
"transfer_data": {
"amount": int(producer_transfer * 100),
"destination": order.provider.stripe_account.id,
},
},
mode="payment",
success_url=f"{prefix}{settings.HOST_NAME}/order/checkout/success",
cancel_url=f"{prefix}{settings.HOST_NAME}/order/checkout/cancel/",
)
Session.sync_from_stripe_data(session)```
i want to cut stripe fees then get amount before checkout and transfer amount in connect account and user pay in checkout page
I see! In this case, instead of using destination charge, i.e. with transfer_data, you may use Separate Charges and Transfer instead. This means that you will charge with Checkout Session without transfer_data, then transfer manually with Transfer API later after successful payment, and getting the Stripe fee to compute the final transfer amount.
You may refer to the guide here: https://stripe.com/docs/connect/separate-charges-and-transfers
i want to like that
total 100$
stripe fees cut 3.20
get_new amount = 96.80
platform_fees = 96.80*10/100
transfer = 87.12 in connected account
Yup! So the steps will be:
- Create checkout session of $100 without
transfer_data - After customer makes payment successfully, calculate the final transfer amount $87.12. Then use Transfer API to transfer $87.12 to the connected account: https://stripe.com/docs/api/transfers
For example,
curl https://api.stripe.com/v1/transfers \
-u "sk_xxx:" \
-d amount=8712 \
-d currency=usd \
-d destination={{OTHER_CONNECTED_STRIPE_ACCOUNT_ID}} \
-d transfer_group=ORDER10
okay but how to check how much net amount in successs payment
You can use this guide to get the Stripe fee, then compute the net amount: https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
New amount = Charge amount ($100) - Stripe fee ($3.20 - get the number with the guide above)
Platform fee = New amount ($96.80) * 10%
Transfer amount = Charge amount ($100) - Stripe fee ($3.20) - Platform fee ($9.68) = $87.12
can we add any paramter in checkout and it return net amount
I'm afraid this is not possible. You'd need to compute yourself
please dont close chat i will implement now
in checkout success it return this
so which id use for retrive stripe fees
You can use retrieve the payment_intent from about checkout.session.completed event and follow this guide to get stripe fee: https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
'payment_intent': 'pi_3NVp9XECJUF37lWX0q37UlYr', use this id for retrive payment intent ?
fees details [<StripeObject at 0x7f2cec0dd220> JSON: {
"amount": 2350,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}]
Yup! pi_3NVp9XECJUF37lWX0q37UlYr should be used to retrieve the payment intent
"balance_transaction": {
"amount": 80000,
"available_on": 1690416000,
"created": 1689830522,
"currency": "usd",
"description": null,
"exchange_rate": null,
"fee": 2350,
"fee_details": [
{
"amount": 2350,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}
],
"id": "txn_3NVpJ6ECJUF37lWX0Zz1ItGJ",
"net": 77650,
"object": "balance_transaction",
"reporting_category": "charge",
"source": "ch_3NVpJ6ECJUF37lWX02F0GvXv",
"status": "pending",
"type": "charge"
},
it give this net amount
is there any issue with the net amount? it looks fine to me
yes fine
one more question
can in future if i need refund of this amount on user account how to do this
it possible if i use this way for transfer
You may use transfer reversal: https://stripe.com/docs/api/transfer_reversals
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i have use you suggest flow and it work fine
now i want to if customer cancel order in this case i want refund amount so how to refund because we trnasfer amount on connect acount
You can do a transfer reversal from the connected account to platform first, then refund from the platform. The steps will be:
- Transfer reversal from the original transfer: https://stripe.com/docs/api/transfer_reversals
- Refund from the original payment intent: https://stripe.com/docs/api/refunds/create
Issuing refund guide: https://stripe.com/docs/connect/separate-charges-and-transfers#issuing-refunds
means i need save id's of payment intent and transfer
yup!
okay thank you sir ji