https://gist.github.com/andrewnelder/e637db3b9ec65b8877e966432b104ba5
If you go through and print the values of the three variables (`stripe_fee`, `platform_total`, and `connected_total`) at the end of each block, you should get the results you're trying to find! The long and the short of it is: "It depends on the way you're charging your customers." If you're charging your customers using the `destination`-parameter, you'll utilize the method and results described in the top-half of this script. Whereas, if you're charging customers directly, using the `Stripe-Account`-header, you'll utilize the method and results described in the bottom-half of this script.
Hope that helps! Let me know if I can clarify anything here for you. Normally I don't like to just throw code-samples around, but in this case, it seemed like the better way to communicate exactly what you needed to do. That being said, I'm happy to go into more depth.
Kind Regards,
Andrew