#surajpatidar

1 messages · Page 1 of 1 (latest)

carmine forgeBOT
dull meteor
#

Do you mean you would like to check the Stripe fee of a payment?

faint ice
#

yes

#

i have one problem

#

pi_3NVocoECJUF37lWX18V3liHH

dull meteor
faint ice
#

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

dull meteor
#

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

faint ice
#

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

dull meteor
#

Yup! So the steps will be:

  1. Create checkout session of $100 without transfer_data
  2. 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
faint ice
dull meteor
#

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

faint ice
#

can we add any paramter in checkout and it return net amount

dull meteor
#

I'm afraid this is not possible. You'd need to compute yourself

faint ice
#

please dont close chat i will implement now

#

in checkout success it return this

#

so which id use for retrive stripe fees

dull meteor
faint ice
#

'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"
}]

dull meteor
#

Yup! pi_3NVp9XECJUF37lWX0q37UlYr should be used to retrieve the payment intent

faint ice
#

"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

dull meteor
#

is there any issue with the net amount? it looks fine to me

faint ice
#

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

dull meteor
faint ice
#

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

dull meteor
faint ice
#

means i need save id's of payment intent and transfer

dull meteor
#

yup!

faint ice
#

okay thank you sir ji