Example #1
0
File: api.py Project: eerock/reddit
    def process_response(self, res):
        from r2.models import Account

        fullname = res.merchantcustomerid.contents[0]
        name = res.description.contents[0]
        customer_id = int(res.customerprofileid.contents[0])
        acct = Account._by_name(name)

        # make sure we are updating the correct account!
        if acct.name == name:
            CustomerID.set(acct, customer_id)
        else:
            raise AuthorizeNetException, "account name doesn't match authorize.net account"

        # parse the ship-to list, and make sure the Account is up todate
        ship_to = []
        for profile in res.findAll("shiptolist"):
            a = Address.fromXML(profile)
            ShippingAddress.add(acct, a.customerAddressId)
            ship_to.append(a)

        # parse the payment profiles, and ditto
        profiles = []
        for profile in res.findAll("paymentprofiles"):
            a = Address.fromXML(profile)
            cc = CreditCard.fromXML(profile.payment)
            payprof = PaymentProfile(a, cc, int(a.customerPaymentProfileId))
            PayID.add(acct, a.customerPaymentProfileId)
            profiles.append(payprof)

        return acct, Profile(acct, profiles, ship_to)
Example #2
0
File: api.py Project: eerock/reddit
 def process_error(self, res):
     if self.is_error_code(res, Errors.RECORD_NOT_FOUND):
         ShippingAddress.delete(self._user, self.customerAddressId)
     GetCustomerShippingAddressRequest.process_error(self, res)
Example #3
0
File: api.py Project: eerock/reddit
 def process_response(self, res):
     ShippingAddress.delete(self._user, self.customerAddressId)
     return True
Example #4
0
File: api.py Project: eerock/reddit
 def process_response(self, res):
     # add the id to the user object in case something has gone wrong
     ShippingAddress.add(self._user, self.customerAddressId)
     return Address.fromXML(res.address)
Example #5
0
File: api.py Project: eerock/reddit
 def process_response(self, res):
     pay_id = int(res.customeraddressid.contents[0])
     ShippingAddress.add(self._user, pay_id)
     return pay_id
Example #6
0
 def process_response(self, res):
     # add the id to the user object in case something has gone wrong
     ShippingAddress.add(self._user, self.customerAddressId)
     return Address.fromXML(res.address)
Example #7
0
 def process_response(self, res):
     pay_id = int(res.customeraddressid.contents[0])
     ShippingAddress.add(self._user, pay_id)
     return pay_id
Example #8
0
 def process_error(self, res):
     if self.is_error_code(res, Errors.RECORD_NOT_FOUND):
         ShippingAddress.delete(self._user, self.customerAddressId)
     GetCustomerShippingAddressRequest.process_error(self, res)
Example #9
0
 def process_response(self, res):
     ShippingAddress.delete(self._user, self.customerAddressId)
     return True