Ejemplo n.º 1
0
    def test_address(self):
        from r2.lib.authorize.api import Address
        address = Address(firstName="Bob",
                          lastName="Smith",
                          company="Reddit Inc.",
                          address="123 Main St.",
                          city="San Francisco",
                          state="California",
                          zip="12345",
                          country="USA",
                          phoneNumber="415-555-1234",
                          faxNumber="415-555-4321",
                          customerPaymentProfileId="1234567890",
                          customerAddressId="2233",
                          )
        expected = ("<firstName>Bob</firstName>" +
                   "<lastName>Smith</lastName>" +
                   "<company>Reddit Inc.</company>" +
                   "<address>123 Main St.</address>" +
                   "<city>San Francisco</city>" +
                   "<state>California</state>" +
                   "<zip>12345</zip>" +
                   "<country>USA</country>" +
                   "<phoneNumber>415-555-1234</phoneNumber>" +
                   "<faxNumber>415-555-4321</faxNumber>" +
                   "<customerPaymentProfileId>1234567890</customerPaymentProfileId>" +
                   "<customerAddressId>2233</customerAddressId>")

        self.assertEqual(address.toXML(), expected)
Ejemplo n.º 2
0
    def test_address(self):
        from r2.lib.authorize.api import Address
        address = Address(
            firstName="Bob",
            lastName="Smith",
            company="Reddit Inc.",
            address="123 Main St.",
            city="San Francisco",
            state="California",
            zip="12345",
            country="USA",
            phoneNumber="415-555-1234",
            faxNumber="415-555-4321",
            customerPaymentProfileId="1234567890",
            customerAddressId="2233",
        )
        expected = (
            "<firstName>Bob</firstName>" + "<lastName>Smith</lastName>" +
            "<company>Reddit Inc.</company>" +
            "<address>123 Main St.</address>" + "<city>San Francisco</city>" +
            "<state>California</state>" + "<zip>12345</zip>" +
            "<country>USA</country>" +
            "<phoneNumber>415-555-1234</phoneNumber>" +
            "<faxNumber>415-555-4321</faxNumber>" +
            "<customerPaymentProfileId>1234567890</customerPaymentProfileId>" +
            "<customerAddressId>2233</customerAddressId>")

        self.assertEqual(address.toXML(), expected)
Ejemplo n.º 3
0
# useful test data:
test_card = dict(AMEX       = ("370000000000002"  , 1234),
                 DISCOVER   = ("6011000000000012" , 123),
                 MASTERCARD = ("5424000000000015" , 123),
                 VISA       = ("4007000000027"    , 123),
                 # visa card which generates error codes based on the amount
                 ERRORCARD  = ("4222222222222"    , 123))

test_card = Storage((k, CreditCard(cardNumber=x,
                                   expirationDate="2011-11",
                                   cardCode=y)) for k, (x, y) in
                    test_card.iteritems())

test_address = Address(firstName="John",
                       lastName="Doe",
                       address="123 Fake St.",
                       city="Anytown",
                       state="MN",
                       zip="12346")


@export
def get_account_info(user, recursed=False): 
    # if we don't have an ID for the user, try to make one
    if not CustomerID.get_id(user):
        cust_id = CreateCustomerProfileRequest(user).make_request()

    # if we do have a customerid, we should be able to fetch it from authorize
    try:
        u, data = GetCustomerProfileRequest(user).make_request()
    except AuthorizeNetException:
        u = None