Skip to content

Commit

Permalink
for #385: move sandbox_charge to payments.tests
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder authored and jdungan committed Aug 12, 2016
1 parent d1a49b9 commit 7c36a1d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 21 deletions.
5 changes: 5 additions & 0 deletions auctions/models.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down
Empty file added payments/management/__init__.py
Empty file.
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions 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
3 changes: 0 additions & 3 deletions payments/tests/utils_test.py
Expand Up @@ -42,6 +42,3 @@ def test_calculate_amounts(self):
- offer_values['application_fee']
)
)

def test_sandbox_charge(TestCase):
utils.sandbox_charge(10)
18 changes: 0 additions & 18 deletions payments/utils.py
Expand Up @@ -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

0 comments on commit 7c36a1d

Please sign in to comment.