From 7c36a1de9fdfb03db86527418d0871883650735d Mon Sep 17 00:00:00 2001 From: groovecoder Date: Fri, 12 Aug 2016 13:58:41 -0500 Subject: [PATCH] for #385: move sandbox_charge to payments.tests --- auctions/models.py | 5 ++++ payments/management/__init__.py | 0 payments/management/commands/__init__.py | 0 payments/management/commands/__init__0.py | 0 payments/management/commands/charge.py | 31 +++++++++++++++++++++++ payments/tests/utils_test.py | 3 --- payments/utils.py | 18 ------------- 7 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 payments/management/__init__.py create mode 100644 payments/management/commands/__init__.py create mode 100644 payments/management/commands/__init__0.py create mode 100644 payments/management/commands/charge.py diff --git a/auctions/models.py b/auctions/models.py index a87585d0..c78182f0 100644 --- a/auctions/models.py +++ b/auctions/models.py @@ -218,6 +218,8 @@ def payout(self): bid__issue=self.issue, charge_id__isnull=False, refund_id=u'', + ).exclude( + user=self.user ) # # capture payment to this users account for offer in valid_offers: @@ -450,6 +452,9 @@ def save(self, *args, **kwargs): if is_new: self.add_fees() + def add_fees(): + raise NotImplementedError + class Offer(Payment): bid = models.ForeignKey(Bid, related_name='payments') diff --git a/payments/management/__init__.py b/payments/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/payments/management/commands/__init__.py b/payments/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/payments/management/commands/__init__0.py b/payments/management/commands/__init__0.py new file mode 100644 index 00000000..e69de29b diff --git a/payments/management/commands/charge.py b/payments/management/commands/charge.py new file mode 100644 index 00000000..b47c309f --- /dev/null +++ b/payments/management/commands/charge.py @@ -0,0 +1,31 @@ +from django.core.management.base import BaseCommand +from django.conf import settings + +import stripe +stripe.api_key = settings.STRIPE_SECRET_KEY + +from payments import utils + + +class Command(BaseCommand): + + def add_arguments(self, parser): + parser.add_argument('amount', nargs='+', type=int) + + def handle(self, *args, **options): + amount = options['amount'][0] + details = utils.transaction_amounts(amount) + charge_amount = details['charge_amount'] + fee = details['application_fee'] + + print details + + charge = stripe.Charge.create( + customer='cus_8xssHec3HDIwUs', + destination='acct_18fylUFyyzYSCsjR', + amount=int(charge_amount * 100), + currency="usd", + application_fee=int(fee * 100) + ) + + print charge.id diff --git a/payments/tests/utils_test.py b/payments/tests/utils_test.py index 18b87c3a..fdf868c3 100644 --- a/payments/tests/utils_test.py +++ b/payments/tests/utils_test.py @@ -42,6 +42,3 @@ def test_calculate_amounts(self): - offer_values['application_fee'] ) ) - - def test_sandbox_charge(TestCase): - utils.sandbox_charge(10) diff --git a/payments/utils.py b/payments/utils.py index 3d80be4b..6cbe4208 100644 --- a/payments/utils.py +++ b/payments/utils.py @@ -137,21 +137,3 @@ def charge(offer, payout): print 'charge error: %s' % e.message offer.error_message = e.message offer.save() - - -def sandbox_charge(offer_amount): - details = transaction_amounts(offer_amount) - amount = details['charge_amount'] - fee = details['application_fee'] - - print details - - charge = stripe.Charge.create( - customer='cus_8xssHec3HDIwUs', - destination='acct_18fylUFyyzYSCsjR', - amount=int(amount * 100), - currency="usd", - application_fee=int(fee * 100) - ) - - print charge.id