-
-
Save andrewnelder/e637db3b9ec65b8877e966432b104ba5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an Account | |
acc = stripe.Account.create(email="platformcharge@test.test", managed=True) | |
# Destination Charge | |
ch = stripe.Charge.create(destination=acc.id, description="platform charge", amount=2000, application_fee=1000, currency="usd", source=gentok()) | |
ref = stripe.Refund.create(charge=ch.id, amount=1500, refund_application_fee=True, reverse_transfer=True) | |
ch = stripe.Charge.retrieve(ch.id, expand=["balance_transaction", "application_fee", "transfer"]) | |
ref = stripe.Refund.retrieve(ref.id, expand=["balance_transaction"]) | |
stripe_fee = -1 * ref.balance_transaction.fee # on the platform account | |
platform_total = ch.application_fee.amount_refunded - stripe_fee | |
connected_total = ch.transfer.amount_reversed - ch.application_fee.amount_refunded | |
print " Stripe Fee: ", stripe_fee | |
print " Platform Total: ", platform_total | |
print "Connected Account Total: ", connected_total | |
# Direct Charge | |
ch = stripe.Charge.create(description="connected account charge", amount=2000, application_fee=1000, currency="usd", source=gentok(), stripe_account=acc.id) | |
ref = stripe.Refund.create(charge=ch.id, amount=1500, refund_application_fee=True, stripe_account=acc.id) | |
ch = stripe.Charge.retrieve(ch.id, expand=["balance_transaction", "application_fee", "transfer"], stripe_account=acc.id) | |
ref = stripe.Refund.retrieve(ref.id, expand=["balance_transaction"], stripe_account=acc.id) | |
stripe_fee = -1 * ref.balance_transaction.fee # on the connected account | |
platform_total = ch.application_fee.amount_refunded | |
connected_total = ch.amount_refunded - ch.application_fee.amount_refunded - stripe_fee | |
print " Stripe Fee: ", stripe_fee | |
print " Platform Total: ", platform_total | |
print "Connected Account Total: ", connected_total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment