Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- need_profile = False
- if not self.payment_profile_id:
- need_profile = True
- if old_profile.billing_address is not None and old_profile.billing_address != self.billing_address:
- need_profile = True
- if old_profile.credit_card is not None and old_profile.credit_card != self.credit_card:
- need_profile = True
- if cc_num is None:
- need_profile = False
- if need_profile:
- settings = get_cim_setting()
- gateway = PaymentProcessor(settings=settings)
- purchaseargs = self.billing_address.get_purchase_dict('bill')
- purchase = Purchase(**purchaseargs)
- cim_purchase = CIMPurchase(purchase=purchase, customer_profile_id=self.customer_profile_id)
- response = gateway.create_payment_profile(cim_purchase, self.credit_card, cc_num)
- if response.success:
- self.payment_profile_id = response.message
- else:
- raise AuthNetException('', 'CIM Payment Profile Creation Failed')
- super(UserProfile, self).save()
- transaction.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement