Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Getting Started >

Create a feed similar to the Stripe direct feed from my SaaS

Started by Flon Mackenzie -   in Getting Started

I am a developer of a SaaS.

The Stripe direct feed is not good enough for my purposes as it only splits in 2 transactions in Xero for total charge and stripe fees from the Stripe charge.

I have application fees in Stripe which include GST and these are combined with the Stripe fees in the Stripe feed so it makes it impossible to reconcile.

What I want to do is make a direct feed from my SaaS to the customers Xero account the same as the Stripe feed works.

I will basically just get the data from Stripe and split a Stripe charge into 3 Xero transactions so it can be reconciled.

I will need to use the API, I just want to check that this is possible?

So the Xero account holder will need to authorize the link to my SaaS platform and then it will set up a Xero bank account with a feed the same setting up Stripe direct feed does.
Hi Fion

We don't generally provide access to the bank feeds API unless you are a bank or similar financial institution. This would prevent you from replicating the functionality of the Stripe feed.

For the scenario you've described we suggest an alternative workflow so that reconciliation can be streamlined. This is described here: https://developer.xero.com/documentation/guides/how-to-guides/handling-payment-processor-receipts-in-xero/

A variation of this would be to use a dummy bank account in place of the clearing account.
 

Robin B (Community Manager)  

I can't really make much sense of the example in that link.
How does that work with a Stripe feed?

So there is no way for me to import a the equivalent of a bank transaction csv using the API?

I can currently replicate what I want to do at the moment by doing the following:

1) Delete the unreconciled stripe fees from the Stripe NZD 0000000 Bank Account.
2) Go to "Import Bank Transactions" and import a csv that my SaaS has created. This is just the Stripe fees split into multiple transactions for Xero. This replaces the deleted fees with the correct ones split into application fee and stripe fee.
3) Reconcile.

I need to automate this.
 

Flon Mackenzie  

I have only just started to use Xero so maybe I need to understand some of the concepts such as invoices in the article you linked. I will do some more reading.

I am still curious if I can automate it though.
 

Flon Mackenzie  

After reading a bit more about Xero and reconciliation it looks as if I could be approaching this from the other side.

Rather than trying to correct the Stripe statement lines I could be importing Invoices (Xero Transactions) that map to the Stripe fees. e.g. in my case 2 invoices to match the 1 stripe fee statement line. The Xero user could then reconcile against these invoices.

@Robin This may have bee what you were suggesting with that link but it went over my head.
 

Flon Mackenzie  

If we start from the beginning, the goal is to be able to reconcile the amounts coming in on the bank statement. The problem is that the amounts on the bank statement don't match the transactions in Xero.

In a simple example you might make a sale for $100, however once the Stripe has deducted their fee, you see $98 arrive in your bank account. As the amounts don't match, reconciliation becomes difficult.

The action of importing a CSV bank statement can't be replicated through the API. However a similar outcome can be achieved.

The workflow below is based on that in the link from my original response, but adapted to use a dummy bank account.

The first step would be to create a dummy bank account which would represent the funds being held by Stripe.

On the completion of a sale you would record a number transactions:
1. An invoice to record the sale. $100 in my example, this could contain different lines with different tax treatment as required
2. A payment of $100 applied to the invoice, the bank account chosen would be your dummy Stripe bank account. This would be marked as reconciled.
3. A Spend Money transaction (BankTransaction) on the dummy Stripe bank account representing the Stripe fee. $2 in my example. This would be marked as reconciled.
Finally,
4. A Bank transfer of $98 representing the transfer of funds from Stripe to the real bank account.

On your dummy Stripe bank account you'll now see three transactions. These will total 0 and cancel each other out.

On your real bank statement you'll see the $98 coming from Stripe and match it to the bank transfer that has already been created.

I would suggest trying this using the demo company to see it in action.
 

Robin B (Community Manager)  

Thanks Robin. I will have a go at implementing something like this next week.

How would I go about raising a change request for the Stripe direct feed?

There must be a lot of people this is affecting.

I have been in discussion with the Stripe developers in their discord group and they have confirmed that it is Xero that has developed the integration for this to convert from the Stripe API to the Xero API.

Stripe Developer:
"ok checked and yeah the integration should be owned/built by Xero and they would need to improve this, so I'm sorry to have to route you again but yeah Stripe doesn't have any code/integration here to update/change"
 

Flon Mackenzie  

Hi Robin,

I have tried the method you suggested above.
You can see the result here

Not sure if I have done this correctly as it is still marked as unreconciled.
I have given Xero support access to my account if you want to take a look.

So how would I replicate this with my real stripe feed.
I'm expecting 4000+ stripe fees coming into each of my customers Xero accounts so I assume that I would need to import the invoices as a csv file that I generate for each of my customers to manually import into their xero accounts?

Do you offer phone support at all as I feel that it may be a much quicker option to get my head around it.

Cheers,
Flon
 

Flon Mackenzie  

What I ended up doing was:
1) Creating a dummy Stripe bank account
2) Automatically creating a csv from Stripe with the Stripe Transaction split into 3 Xero transactions (charge, Stripe fee, Application fee).
3) Customer manually imports this csv into their Xero account.
4) Reconcile using pre set up bank rules.

This will be a replacement for the Stripe direct feed which does not work with Stripe application fees.

I will look at a way to fully integrate with Xero using the API and automate this next year.
 

Flon Mackenzie  

Hey Flon, we have the exact same issue. Can you elaborate on how you're automatically creating a csv from Stripe with the Stripe Transaction split into 3 Xero transactions?
 

Ab Hoss  

@abhoss Sure.
I use these this API to get the balance transactions:
https://stripe.com/docs/api/balance_transactions/list?lang=node

Then for each balance transaction I need to call the below API to get additional data:
https://stripe.com/docs/api/charges/retrieve

I'm happy to share my code if you like. It is in nodejs. It is not production ready but works.
 

Flon Mackenzie  

Hey Flon, thanks a lot for the explanation! If you can share your code that would be great :)
 

Ab Hoss  

No worries.
Its a bit messy and may need to be tweaked to handle all cases but it does work.
Hopefully that should get you started.

Unfortunately my users still have to manually import it into Xero dummy bank account to reconcile. I hope to figure out a way to automate this in the future.

This code is provided by the developer community - Xero does not warrant it in any way
 

Flon Mackenzie