def test_charge_ampersand_in_invoice_number(self):
        self.charge_service._config = TestServicesConfig.valid_services_config

        details = HpsTransactionDetails()
        details.invoice_number = '&something'

        try:
            response = self.charge_service.charge(
                '5', 'usd', TestCreditCard.valid_visa,
                None, False, None, False, details)
            self.assertIsNotNone(response)
            self.assertEqual('00', response.response_code)
        except HpsGatewayException, e:
            self.fail('Gateway threw an error')
    def test_charge_ampersand_in_invoice_number(self):
        self.charge_service._config = TestServicesConfig.valid_services_config

        details = HpsTransactionDetails()
        details.invoice_number = '&something'

        try:
            response = self.charge_service.charge('5', 'usd',
                                                  TestCreditCard.valid_visa,
                                                  None, False, None, False,
                                                  details)
            self.assertIsNotNone(response)
            self.assertEqual('00', response.response_code)
        except HpsGatewayException, e:
            self.fail('Gateway threw an error')
    def test_visa_with_details(self):
        details = HpsTransactionDetails()
        details.memo = 'memo'
        details.invoice_number = '1234'
        details.customer_id = 'customerID'

        charge = self.charge_service.charge(50, 'usd',
                                            TestCreditCard.valid_visa,
                                            TestCardHolder.valid_card_holder,
                                            False, 'descriptor', False,
                                            details)

        self.assertIsNotNone(charge)

        transaction = self.charge_service.get(charge.transaction_id)
        self.assertIsNotNone(transaction)
        self.assertEqual(transaction.memo, 'memo')
        self.assertEqual(transaction.invoice_number, '1234')
        self.assertEqual(transaction.customer_id, 'customerID')
    def test_visa_with_details(self):
        details = HpsTransactionDetails()
        details.memo = 'memo'
        details.invoice_number = '1234'
        details.customer_id = 'customerID'

        charge = self.charge_service.charge(
            50, 'usd',
            TestCreditCard.valid_mastercard,
            TestCardHolder.valid_card_holder,
            False, 'descriptor', False,
            details)

        self.assertIsNotNone(charge)

        transaction = self.charge_service.get(charge.transaction_id)
        self.assertIsNotNone(transaction)
        self.assertEquals(transaction.memo, 'memo')
        self.assertEquals(transaction.invoice_number, '1234')
        self.assertEquals(transaction.customer_id, 'customerID')