Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Authorizenet backend cleanup

  • Loading branch information...
commit f3161b5df9d872861f432ecfca64af1aca304013 1 parent 2b2538f
@paluh paluh authored
View
15 satchless/contrib/payment/authorizenet_provider/__init__.py
@@ -66,17 +66,16 @@ def get_billing_data(self, order):
return result
def confirm(self, order, typ=None):
- v = order.paymentvariant.get_subtype_instance()
trans_type = self.capture and 'AUTH_CAPTURE' or 'AUTH_ONLY'
data = {
- 'card_num': v.cc_number,
- 'exp_date': v.cc_expiration,
+ 'card_num': order.payment.cc_number,
+ 'exp_date': order.payment.cc_expiration,
'amount': order.get_total().gross,
'invoice_num': order.pk,
'type': trans_type,
}
- if v.cc_cvv2:
- data['card_code'] = v.cc_cvv2
+ if order.payment.cc_cvv2:
+ data['card_code'] = order.payment.cc_cvv2
data.update(self.get_billing_data(order))
data.update(self.get_shipping_data(order))
data = dict((k, unidecode(v) if isinstance(v, unicode) else v)
@@ -85,9 +84,9 @@ def confirm(self, order, typ=None):
response = process_payment(data, {})
except urllib2.URLError:
raise PaymentFailure(ugettext("Could not connect to the gateway."))
- v.cc_cvv2 = '' # Forget the CVV2 number immediately after the transaction
- v.response = response
- v.save()
+ order.payment.cc_cvv2 = '' # Forget the CVV2 number immediately after the transaction
+ order.payment.response = response
+ order.payment.save()
if not response.is_approved:
raise PaymentFailure(response.response_reason_text)
View
5 satchless/contrib/payment/authorizenet_provider/models.py
@@ -2,13 +2,16 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
-class AuthorizeNetPayment(models.Model):
+from ...util.models import DeferredOneToOneField
+
+class AuthorizeNetPaymentBase(models.Model):
cc_name = models.CharField(_('Name on Credit Card'), max_length=128)
cc_number = models.CharField(_('Card Number'), max_length=32)
cc_expiration = models.DateField(_('Exp. date'), null=True)
cc_cvv2 = models.CharField(_('CVV2 Security Number'), max_length=4)
response = models.ForeignKey(authorizenet.models.Response, null=True,
blank=True, editable=False)
+ order = DeferredOneToOneField('order', related_name='payment', editable=False)
class Meta:
abstract = True
View
5 satchless/util/models.py
@@ -94,6 +94,11 @@ class DeferredForeignKey(DeferredField):
klass = models.ForeignKey
+class DeferredOneToOneField(DeferredField):
+
+ klass = models.OneToOneField
+
+
class DeferredManyToManyField(DeferredField):
klass = models.ManyToManyField
Please sign in to comment.
Something went wrong with that request. Please try again.