diff --git a/frontend/views.py b/frontend/views.py index 6eac16b8..6a0c3a44 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -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() diff --git a/payment/manager.py b/payment/manager.py index 17b90a1d..64389779 100644 --- a/payment/manager.py +++ b/payment/manager.py @@ -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, diff --git a/payment/models.py b/payment/models.py index 182d0e5c..9ff8c72a 100644 --- a/payment/models.py +++ b/payment/models.py @@ -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):