Skip to content

Instantly share code, notes, and snippets.

@jwdomb
Last active April 5, 2018 01:27
Show Gist options
  • Save jwdomb/019a397c49a8195303aaf1c6d4cc3975 to your computer and use it in GitHub Desktop.
Save jwdomb/019a397c49a8195303aaf1c6d4cc3975 to your computer and use it in GitHub Desktop.
Pricing calculations
# Functions to help calculate aspects of prices,
# particularly when using a service like Stripe
# ------------------------------------------------------------------------------
# (MIT) LICENSE
# Copyright 2018 Joseph W. Dombroski <http://jwdomb.com/for/github-gist>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ------------------------------------------------------------------------------
# Calculate revenue for batched 99¢ transactions
def batch_price(purchases_in_period):
revenue = purchases_in_period * 0.99
processing_fee = revenue * 0.029
stripe_fee = 0.30
net_revenue = revenue - processing_fee - stripe_fee
return net_revenue
for games in range(1,10):
print str(batch_price(games)) + " " +str(batch_price(games) / (games * 0.99))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment