Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1.         need_profile = False
  2.         if not self.payment_profile_id:
  3.             need_profile = True
  4.         if old_profile.billing_address is not None and old_profile.billing_address != self.billing_address:
  5.             need_profile = True
  6.         if old_profile.credit_card is not None and old_profile.credit_card != self.credit_card:
  7.             need_profile = True
  8.         if cc_num is None:
  9.             need_profile = False
  10.         if need_profile:
  11.             settings = get_cim_setting()
  12.             gateway = PaymentProcessor(settings=settings)
  13.             purchaseargs = self.billing_address.get_purchase_dict('bill')
  14.             purchase = Purchase(**purchaseargs)
  15.             cim_purchase = CIMPurchase(purchase=purchase, customer_profile_id=self.customer_profile_id)
  16.             response = gateway.create_payment_profile(cim_purchase, self.credit_card, cc_num)
  17.             if response.success:
  18.                 self.payment_profile_id = response.message
  19.             else:
  20.                 raise AuthNetException('', 'CIM Payment Profile Creation Failed')
  21.         super(UserProfile, self).save()
  22.         transaction.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement