How to charge fee on stripe api using c# - stripe-payments

I am using Stripe Api to create a customer and then charge it.
What i wanted is to charge my customer whenever it create a sell or charge.
I want 7% of total amount to be credited in my stripe account.
I have tried the Application fee when creating charge with customer Id , but it requires destination to be passed, which requires merchant ID, which always throws error that "No Merchant Found with provided ID".

How the documentation say, there are two way to create a charge: Charging directly and Charging through the platform.
Which of these are you using? (Can I suppose the second since you were talking about the "destination"? ).
They both require connected accounts to do charge, ect.
In the case of Charging through the platform, you need that the account is connected to the platform to be visible from the "destination" (Connecting_Account_Documentation).
If it is not so, explains better the situation in which you find.
application_fee:
A fee in cents that will be applied to the charge and transferred to the application owner's Stripe account. To use an application fee, the request must be made on behalf of another account, using the Stripe-Account header, an OAuth key, or the destination parameter. For more information, see the application fees documentation.
destination:
An account to make the charge on behalf of. If specified, the charge will be attributed to the destination account for tax reporting, and the funds from the charge will be transferred to the destination account. The ID of the resulting transfer will be returned in the transfer field of the response. See the documentation for details.

Related

Taking fee and payment reservation Stripe

Pretty new to Stripe, we're building an online marketplace. Each user can buy assets from any other user. We also take fees for each payment.
We go with connected accounts. Seller goes through the onboarding flow (create connected account, create account link etc), while buyer is registered as a customer of our platform on Stripe.
Now, whenever buyer makes a payment we create a payment intent to pay to us (amount + 20% fee via):
stripe.paymentIntents.create(params)
Then we create new payout to seller (amount) using source transaction from payment intent above:
await stripe.transfers.create({
amount: payment.amount * 100,
currency: payment.currency,
destination: seller.stripeAccountId,
source_transaction: sourceTransaction,
});
Is this the preferred and best way of handling this? In terms of time, we need first to wait for payment to settle to our bank account to be able to payout seller?
Is there any better way of doing this instead of manual payouts?
Is there a way to make direct transfer to connected account when user does payment?
I tried with payment intent, specifying connected account id in request, but API is complaining that customer id is on our platform but account id is specified, so it's not possible obviously.
Also, manual payouts would come handy to simulate payment escrow/deposit. When user create a request for some asset, we would immediately transfer certain amount to our account, like reserving that amount. And if the seller accepts the offer, we would do a payout. If seller rejects the offer, we would do payout to the buyer, giving him back his money.
Does this make sense?
Thanks in advance
You don't need Payout (yet) in your use case. You are doing Separate Charges and Transfers, and fund simply moves from your Account's balance to Connected Account's balance. It hasn't been out of your Connected Account's balance to your Connected Account's bank account yet, which is called "Payout".
In another word, Payout is separated process than Charges and Transfers. Charges and Transfers can happen immediately, and Payouts normally happen later on a daily basis or manually.
Find more explanation on Connect Balance.
There is also Destination Charge which is simpler than Separate Charges and Transfers. I recommend Destination Charge unless you have specific reason to use Separate Charges and Transfers, ie. you need to transfer to multiple Connected Accounts on one payment.

How to generate invoices for the application fees with Stripe direct charges?

I'm launching a marketplace where some professionals offer their services and customers can book and pay them online. I take percentage fees in the process and I use stripe direct charges for that. So when a customer proceed to a stripe payment though my website the professional (the connected account) gets paid and automatically pays me (the platform account) the application fees percentage that I set.
I've searched on stripe website and couldn't find an answer: Is it possible to generate automatically some invoices from my platform account to the connected account that would be related to the application fees ?
For example if the professional's price is 10$ and the application fees that I set is 10% how could I generate the 1$ invoice to the professional ?
I only found how to build or generate invoices for connected account to their customers but not invoices involving the platform account and the connected account.
It seems like what you are looking for is an application_fee[1] . As the diagram[2] displays, the professional (Connected account) charges the customer directly but your application fee is collected and deposited in your account during the funds flow of the Connected account.
This does not provide any invoice to the professional since the application_fee is sent to your account at the same time as the remaining funds are transferred to the Connected account. This process allows you to have a set percentage based application fee you charge the professionals on your marketplace.
The application_fee approach is the recommended way of collection a fee as part of a direct charge. This will not generate an invoice to your Connected accounts automatically but you could always generate one of your own (outside of Stripe) as a record of the fee for those accounts.
https://stripe.com/docs/connect/direct-charges#collecting-fees
https://stripe.com/docs/connect/direct-charges#flow-of-funds-with-fees

Stripe connect. Transferring payment to a connected account charges fees on the main account

I have account B connected to account A (both are standard accounts).
What I'm trying to do: accept a payment through A and send the full amount to B, which then gets charged the corresponding Stripe fees.
What I did: Created a webhook that fires on charge.succeeded and does a transfer to the connected account (B), using the charge id in source_transaction (As per https://stripe.com/docs/connect/charges-transfers)
What happens: The connected account (B) seems to get the full payment, without fees, the fees seem to be charged to account A
Could it be that it's because in test mode? The idea is to use account A to send/split a payment between other accounts (1 or more), as in a marketplace.
You'd usually simply use a Direct Charge — https://stripe.com/docs/connect/direct-charges. That's exactly how you platform A makes an API call on connected account B to facilitate a payment, and the fees are paid by B.
The link you posted is for a more advanced integration where the platform processes the payment(and therefore pays the Stripe processing fees) and then transfers money to a connected account(like a company like Lyft charging a rider, then transferring some of the money to the driver).
The idea is to use account A to send/split a payment between other accounts (1 or more), as in a marketplace
You can't use Direct Charges to split a single payment between multiple connected accounts such that they all pay the fees separately. The most you could do is make multiple separate charges — like take the card from the customer, clone it to each individual account involved, and do N separate charges (https://stripe.com/docs/connect/cloning-customers-across-accounts) on each of them. I wouldn't really recommend that since it likely leads to more declines and disputes(it's weird to have a shopping cart with 5 items from 5 sellers and get charged by the actual 5 sellers, I would expect to be charged once by the company that runs the marketplace).
If you really need to do this type of business model where you take a single payment and then split between multiple sellers then you do need to take the approach you linked to, and have the platform pay the fees, that's the only way, it's specifically discussed at https://stripe.com/docs/connect/charges#types in detail.

Stripe payment and bank account

Is it possible with Stripe to perform a test transaction to ensure that an account is funded?
I would like to :
take the Credit Card ID at the moment of the booking (but no payment at that moment)
make the customer pay AFTER the service has been done
What you likely want is to place a hold on the card for the given amount, and then capture the funds later after the service has completed. When placing a hold the given amount is authorized and guaranteed by the cardholder's bank. You'll often see these types of transactions show up on your online bank statement when renting a car or when checking-in to a hotel room. When processing your payment with Stripe you would set the capture_method on the PaymentIntent to manual which tells Stripe to only authorize the given amount. Then, once the service is rendered you would capture the funds. The following guide covers the approach in detail:
https://stripe.com/docs/payments/capture-later

Stripe - How to get purchaser's information for a charge with Connect (Express)?

I've set up a test charge using stripe.Charge.create() and it is working, i.e. I can see the dollar amounts processed in the Connect test dashboard. It appears to be money going from the tok_visa to a dummy Stripe account I set up.
charge = stripe.Charge.create(
amount=1000,
currency="usd",
source="tok_visa",
application_fee_amount=123,
transfer_data={
"destination": "{{CONNECTED_STRIPE_ACCOUNT_ID}}",
}
)
For a marketplace type platform, I need to be able to send funds from the purchasing user to the selling user, however.
Would I need to get the purchaser's account (or some other object?) to use as the "source" in the charge?
How do I get that to put it into the "source" field?
I feel a little lost in Stripe's docs, so I could be missing something. Thank you for any tips.
I need to be able to send funds from the purchasing user to the
selling user, however
If by 'purchasing user' you mean a cardholder customer of your marketplace, this is exactly what you have. tok_visa here represents a credit card, that you accept through a payment page.
If instead you mean, the purchasing user is another connected account in the marketplace, you can either :
use an account debit to debit one account, and then transfer to
another.
collect a card from users when they sign up and create a
Customer object for them. You can then charge that customer as needed
like in your example code. You need to maintain a link in your system that
'customer cus_xxx is also my marketplace user acct_xxx'

Resources