Connect "Stripe Connect" with the Telegram Payment API - stripe-payments

How can I use Stripe Connect, let's say to create a "Direct Charge", while sending an Invoice on the Telegram Payment API?
The Telegram API seems to only allow for a "provider_token", I see no further details for the Stripe API, like the required "stripe_account" property for direct charges.
I guess Telegram itself uses Stripe Connect to charge on the users behalf... But that doesn't seem to have stopped this guy from doing something very similar:
https://www.reddit.com/r/TelegramBots/comments/6f6b4z/telepay_a_bot_that_enables_instant_and_secure/
He uses express accounts, but the fundamental problem of not being able to speak to stripe directly seems to be the same.
Thanks :)

You're correct about the Telegram API: there is no way to create a direct charge to a connected Stripe account when receiving payments through Telegram. But there are workarounds. I'm the author of the bot you linked; here's how I managed to move funds from my account to a connected Stripe account via Telegram.
Firstly, you need to accept the payment as usual (e.g. follow the normal sendInvoice flow). For my purposes, I made the payload parameter the ID of the user that is being sent the money (it's later matched with the Stripe account ID in the database, but you can do this however you want). The rest is out of scope of the question, so I won't describe this process in detail; Telegram has a very nice guide on it.
Once you receive the successful_payment event from the Telegram API, you can then transfer the money from your own Stripe account to the linked Stripe account using the Stripe Connect transfers endpoint, but be careful: it doesn't give you the amount that was given to your own Stripe balance (taking fees into account), so you will need to calculate that yourself. Depending on your account, it would look something like this for JavaScript: payment.total_amount - Math.round(payment.total_amount * 0.029 + 30).
After you've transfered the money to their account, you can perform a payout as usual with the payouts Stripe Connect endpoint.
But note that this is just one example; you can use all of the Stripe Connect APIs with this. In fact, you probably have even more flexibility with this, since the funds hit your Stripe account before they reach the connected account's, so you can do whatever you want with them :)
So, TL;DR: Once you've received the successful_payment from Telegram, transfer the money to the connected Stripe account, then perform a payout on it.

Related

Stripe send payment to customers' bank account in Nodejs

I'm working on a POS app where users can buy things from owners. How can I send the money directly from the user to the owner in nodejs?
Thanks
You need to use Stripe Connect in order to send funds to another account with Stripe.
Stripe Connect is a huge topic and needs lots of research into account types and fund flows: https://stripe.com/docs/connect.

Stripe Payment Intents API: How to confirm the payment on the server side?

Before migrating to the Payment Intents API the user's credit card payment was confirmed and charged on the server side using the token (received from stripe.createToken) after the purchase has been completed. This gave us the possibility not to confirm the payment in case any errors happens.
Now, with the Payment Intents API the payment confirmation happens already on the client side (stripe.confirmCardPayment) which is a problem in case an error happens on the server side while completing the purchase as the credit card has already been charged. A refund is not valid solution your Stripe fees won't be refunded.
How can we implement card payments with the Payment Intents API but confirm the payment at the final end of the purchase (as in the legacy workflow)? Or how can we prevent the credit card from being charged in case an error occurs during the checkout workflow?
Unfortunately, we couldn't find a solution to this problem in the documentation.
Help appreciated!
Here are the docs: https://stripe.com/docs/payments/payment-intents/migration
What you are looking for is modeled via "manual confirmation" of a PaymentIntent: https://stripe.com/docs/payments/accept-a-payment-synchronously.
It isn't Stripe's recommended integration. The recommended approach is to confirm client-side and listen to webhooks for payment confirmation.
This is because with manual confirmation, there is a higher chance of customer "drop off" where they authenticate your PaymentIntent on your webpage but close it out, meaning you lose your client->server roundtrip, leaving your payment unconfirmed (eventhough the customer thinks they authenticated hence paid).
Additionally, manual confirmation only works for card type payments, it is not supported for other payment methods based in other regions like iDEAL or SEPA Debit etc.
In our case, we wanted to authenticate the card payment at the end directly after making the charge. The Stripe support was able to help us with the following answer:
As I understand you would like to authenticate the payment at the end directly after making the charge. There is a solution to this, with the capture_method being set to Manual - https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method. What this would mean is, that the charge will be made and the user / client would be able to confirm the payment afterwards in the Dashboard directly.
This method is called Auth and Capture. Place a hold on a card to reserve funds now but only capture them after your business completes the service. When a payment is authorized, the bank guarantees the amount and holds it on the customer’s card for up to seven days, or two days for in-person payments using Terminal. You can find more information along with the API's under this Link: https://stripe.com/docs/payments/capture-later#authorize-only

When receiving a `payout.created` Stripe webhook, what is the easiest way to determine which Stripe Connect Custom account it is for?

(Stripe api version: 2020-08-27)
I am working on setting up Stripe to create payouts automatically each week to our Stripe Connect accounts with earnings.
I want my own api to listen for the payout.created Stripe webhook, so I can record and track the event data in my local database. However, I don't see any easy way to tell which Stripe Connect account the newly created payout is for, by looking at the object's properties (API reference).
I was going to try and make the determination by looking at the $payout->destination property, which would give me the bank account the payout was for. I could then retrieve that bank account and see which user it relates to. However, in order to retrieve a bank account, I have to already know the customer id, and I don't have that info. I'm not even dealing with a customer here, I'm dealing with a service provider that has earnings that we need to pay. The bank account is not the same thing as the stripe connect account.
How do I deal with this? Seems weird that it would be so difficult to figure out who the payout is for.

Stripe transfer receipt

I am developing app where transfer money from platform to connect when completing some task.
And then my app customers can get money in their stripe account.
I think they need to get receipt for getting earning when using my app but I can't see how to send receipts to customer's email for transferring.
I know it can by specifying receipts_email when charing and refund but no such stuff in transfer object.
How can my app send receipt to customer for transferring ?
if it's impossible what is providing instead in stripe?
Really I need to get help.
Thank you.
The email receipt feature is only available for Charges which happen when you charge a Customer's card. This is documented here: https://stripe.com/docs/receipts
Stripe does not send email receipts when you transfer funds to a connected account or when funds are sent to their own bank accounts. This is something that you would need to build on your side instead based on the funds you're sending to them.

User to user payment on stripe

My requirement is, from my application I want my user to transfer the amount to another user of my application. Assume that both user have stripe account. I have gone through stripe docs, and I understood that in order to do transfer from one user account to another I need to use stripe connect. I could able to do authentication and I'm getting access token successfully for the sender. How can I make a transfer to a recipient ? I have only recipient's email id with me. Should I need to create a recipient through code and do the transfer using that recipient id returns from stripe ?
Im using php. Please help me.
Stripe Connect doesn't work like that. Instead, Connect allows an application to make card charges on behalf of a user and take a portion of the amount. The rest is automatically and immediately put into the user's Stripe account, where it's subject to the normal bank account transfer rules (2-7 day rolling transfers or API-driven manual transfers).
Another way to do this is using Stripe Recipients and Transfers. For example, your application charges a customer $10. You create a Recipient for your user using their bank account information (account number and routing number). Then, you can create a Transfer from your Stripe account to their bank account. Note that this only works for US bank accounts as of today.
If you really want to do user to user transfers, unfortunately Stripe isn't the platform for you. You could use PayPal or you could possibly use Balanced Payments, although again you can only transfer money to and from US bank accounts.

Resources