[#37053797] reverting stripelib.py -- Sn tests run but django command test_stripe_charge fails: done so Eric can fix circular import issue:
>>> >>> >>> (regluitdj14)raymond-yees-computer:regluit raymondyee$ django-admin.py test_stripe_charge Traceback (most recent call last): File "/Users/raymondyee/.virtualenvs/regluitdj14/bin/django-admin.py", line 5, in <module> management.execute_from_command_line() File "/Users/raymondyee/.virtualenvs/regluitdj14/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/Users/raymondyee/.virtualenvs/regluitdj14/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/raymondyee/.virtualenvs/regluitdj14/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/Users/raymondyee/.virtualenvs/regluitdj14/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/Users/raymondyee/.virtualenvs/regluitdj14/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Users/raymondyee/C/src/Gluejar/regluit/payment/management/commands/test_stripe_charge.py", line 2, in <module> from regluit.payment import stripelib File "/Users/raymondyee/C/src/Gluejar/regluit/payment/stripelib.py", line 10, in <module> from regluit.payment.models import Account File "/Users/raymondyee/C/src/Gluejar/regluit/payment/models.py", line 4, in <module> from regluit.core.models import Campaign, Wishlist, Premium, PledgeExtra File "/Users/raymondyee/C/src/Gluejar/regluit/core/models.py", line 998, in <module> from regluit.payment.manager import PaymentManager File "/Users/raymondyee/C/src/Gluejar/regluit/payment/manager.py", line 2, in <module> from regluit.payment.models import Transaction, Receiver, PaymentResponse ImportError: cannot import name Transactionpull/1/head
parent
72a440383d
commit
89b3b5c599
|
@ -7,15 +7,16 @@ from pytz import utc
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from regluit.payment.models import Account
|
||||||
from regluit.payment.parameters import PAYMENT_HOST_STRIPE
|
from regluit.payment.parameters import PAYMENT_HOST_STRIPE
|
||||||
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE, TRANSACTION_STATUS_COMPLETE, PAYMENT_TYPE_AUTHORIZATION, TRANSACTION_STATUS_CANCELED
|
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE, TRANSACTION_STATUS_COMPLETE, PAYMENT_TYPE_AUTHORIZATION, TRANSACTION_STATUS_CANCELED
|
||||||
|
from regluit.payment import baseprocessor
|
||||||
from regluit.utils.localdatetime import now, zuluformat
|
from regluit.utils.localdatetime import now, zuluformat
|
||||||
|
|
||||||
import stripe
|
import stripe
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class StripeError(Exception):
|
class StripeError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -38,11 +39,15 @@ try:
|
||||||
from regluit.core.models import Key
|
from regluit.core.models import Key
|
||||||
STRIPE_PK = Key.objects.get(name="STRIPE_PK").value
|
STRIPE_PK = Key.objects.get(name="STRIPE_PK").value
|
||||||
STRIPE_SK = Key.objects.get(name="STRIPE_SK").value
|
STRIPE_SK = Key.objects.get(name="STRIPE_SK").value
|
||||||
|
STRIPE_PARTNER_PK = Key.objects.get(name="STRIPE_PARTNER_PK").value
|
||||||
|
STRIPE_PARTNER_SK = Key.objects.get(name="STRIPE_PARTNER_SK").value
|
||||||
logger.info('Successful loading of STRIPE_*_KEYs')
|
logger.info('Successful loading of STRIPE_*_KEYs')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# currently test keys for Gluejar and for raymond.yee@gmail.com as standin for non-profit
|
# currently test keys for Gluejar and for raymond.yee@gmail.com as standin for non-profit
|
||||||
STRIPE_PK = 'pk_0EajXPn195ZdF7Gt7pCxsqRhNN5BF'
|
STRIPE_PK = 'pk_0EajXPn195ZdF7Gt7pCxsqRhNN5BF'
|
||||||
STRIPE_SK = 'sk_0EajIO4Dnh646KPIgLWGcO10f9qnH'
|
STRIPE_SK = 'sk_0EajIO4Dnh646KPIgLWGcO10f9qnH'
|
||||||
|
STRIPE_PARTNER_PK ='pk_0AnIkNu4WRiJYzxMKgruiUwxzXP2T'
|
||||||
|
STRIPE_PARTNER_SK = 'sk_0AnIvBrnrJoFpfD3YmQBVZuTUAbjs'
|
||||||
|
|
||||||
# set default stripe api_key to that of unglue.it
|
# set default stripe api_key to that of unglue.it
|
||||||
|
|
||||||
|
@ -260,56 +265,9 @@ class PledgeScenarioTest(TestCase):
|
||||||
print "list of events", cls._sc.event.all()
|
print "list of events", cls._sc.event.all()
|
||||||
print [(i, e.id, e.type, e.created, e.pending_webhooks, e.data) for (i,e) in enumerate(cls._sc.event.all()['data'])]
|
print [(i, e.id, e.type, e.created, e.pending_webhooks, e.data) for (i,e) in enumerate(cls._sc.event.all()['data'])]
|
||||||
|
|
||||||
class StripePaymentRequest(object):
|
class StripePaymentRequest(baseprocessor.BasePaymentRequest):
|
||||||
'''
|
"""so far there is no need to have a separate class here"""
|
||||||
Handles common information incident to payment processing
|
pass
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
# Global values for the class
|
|
||||||
response = None
|
|
||||||
raw_response = None
|
|
||||||
errorMessage = None
|
|
||||||
status = None
|
|
||||||
url = None
|
|
||||||
|
|
||||||
def ack( self ):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def success(self):
|
|
||||||
|
|
||||||
if self.errorMessage:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def error(self):
|
|
||||||
if self.errorMessage:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def error_data(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def error_id(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def error_string(self):
|
|
||||||
return self.errorMessage
|
|
||||||
|
|
||||||
def envelope(self):
|
|
||||||
# The envelope is used to store info about this request
|
|
||||||
if self.response:
|
|
||||||
return str(self.response)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def correlation_id(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def timestamp(self):
|
|
||||||
return str(datetime.datetime.now())
|
|
||||||
|
|
||||||
def requires_explicit_preapprovals():
|
def requires_explicit_preapprovals():
|
||||||
"""a function that returns for the given payment processor"""
|
"""a function that returns for the given payment processor"""
|
||||||
|
@ -323,10 +281,7 @@ def make_account(user, token):
|
||||||
# create customer and charge id and then charge the customer
|
# create customer and charge id and then charge the customer
|
||||||
customer = sc.create_customer(card=token, description=user.username,
|
customer = sc.create_customer(card=token, description=user.username,
|
||||||
email=user.email)
|
email=user.email)
|
||||||
|
|
||||||
|
|
||||||
from regluit.payment.models import Account
|
|
||||||
|
|
||||||
account = Account(host = PAYMENT_HOST_STRIPE,
|
account = Account(host = PAYMENT_HOST_STRIPE,
|
||||||
account_id = customer.id,
|
account_id = customer.id,
|
||||||
card_last4 = customer.active_card.last4,
|
card_last4 = customer.active_card.last4,
|
||||||
|
@ -342,31 +297,10 @@ def make_account(user, token):
|
||||||
|
|
||||||
return account
|
return account
|
||||||
|
|
||||||
class Pay(StripePaymentRequest):
|
class Pay(StripePaymentRequest, baseprocessor.Pay):
|
||||||
|
pass
|
||||||
'''
|
|
||||||
The pay function generates a redirect URL to approve the transaction
|
|
||||||
'''
|
|
||||||
|
|
||||||
def __init__( self, transaction, return_url=None, amount=None, paymentReason=""):
|
class Preapproval(StripePaymentRequest, baseprocessor.Preapproval):
|
||||||
self.transaction=transaction
|
|
||||||
|
|
||||||
def api(self):
|
|
||||||
return "null api"
|
|
||||||
|
|
||||||
def exec_status( self ):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def amount( self ):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def key( self ):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def next_url( self ):
|
|
||||||
return self.url
|
|
||||||
|
|
||||||
class Preapproval(StripePaymentRequest):
|
|
||||||
|
|
||||||
def __init__( self, transaction, amount, expiry=None, return_url=None, paymentReason=""):
|
def __init__( self, transaction, amount, expiry=None, return_url=None, paymentReason=""):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue