Now recording pledge as such -- and not charging immediately.

running into exception at https://github.com/Gluejar/regluit/blob/relaunch_ry/payment/manager.py#L554-- have to start implementing a baseclass for stripelib to handle pledge modification
pull/1/head
Raymond Yee 2012-09-17 16:56:07 -07:00
parent f88017c607
commit 6a650affc8
3 changed files with 18 additions and 10 deletions

View File

@ -793,20 +793,27 @@ class FundPledgeView(FormView):
else:
customer = None
charge = sc.create_charge(preapproval_amount, card=stripe_token, description="${0} for test / cc not retained".format(preapproval_amount))
# change to PAYMENT_TYPE_AUTHORIZATION when we are doing a real preapproval
self.transaction.type = PAYMENT_TYPE_INSTANT
# set True for now -- wondering whether we should actually wait for a webhook -- don't think so.
## settings to apply to transaction for TRANSACTION_STATUS_COMPLETE
#self.transaction.type = PAYMENT_TYPE_INSTANT
#self.transaction.approved = True
#self.transaction.status = TRANSACTION_STATUS_COMPLETE
#self.transaction.pay_key = charge.id
# settings to apply to transaction for TRANSACTION_STATUS_ACTIVE
# should approved be set to False and wait for a webhook?
self.transaction.type = PAYMENT_TYPE_AUTHORIZATION
self.transaction.approved = True
self.transaction.pay_key = charge.id
self.transaction.status = TRANSACTION_STATUS_ACTIVE
self.transaction.preapproval_key = charge.id
self.transaction.currency = 'USD'
self.transaction.amount = preapproval_amount
self.transaction.date_payment = now()
self.transaction.status = TRANSACTION_STATUS_COMPLETE
self.transaction.save()

View File

@ -766,7 +766,7 @@ class PaymentManager( object ):
t = Transaction.create(amount=amount,
max_amount=amount,
host=transaction.host,
currency=currency,
currency=transaction.currency,
status=TRANSACTION_STATUS_CREATED,
campaign=transaction.campaign,
user=transaction.user,

View File

@ -143,10 +143,11 @@ class Transaction(models.Model):
ack_dedication=self.ack_dedication)
@classmethod
def create(cls,amount=0.00, max_amount=0.00, currency='USD',
def create(cls,amount=0.00, host=PAYMENT_HOST_NONE, max_amount=0.00, currency='USD',
status=TRANSACTION_STATUS_NONE,campaign=None, user=None, pledge_extra=None):
if pledge_extra:
return cls.objects.create(amount=amount,
return cls.objects.create(amount=amount,
host=host,
max_amount=max_amount,
currency=currency,
status=status,
@ -158,7 +159,7 @@ class Transaction(models.Model):
ack_dedication=pledge_extra.ack_dedication
)
else:
return cls.objects.create(amount=amount, max_amount=max_amount, currency=currency,status=status,
return cls.objects.create(amount=amount, host=host, max_amount=max_amount, currency=currency,status=status,
campaign=campaign, user=user)
class PaymentResponse(models.Model):