def test_request_relturn_format(self, mock__http_post): transaction = fields.authorization() transaction.reportGroup = 'Planets' transaction.orderId = '12344' transaction.amount = 106 transaction.orderSource = 'ecommerce' transaction.id = 'thisisid' card = fields.cardType() card.number = '4100000000000000' card.expDate = '1210' card.type = 'VI' transaction.card = card mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='1' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> </cnpOnlineResponse> """ self.assertRaises(utils.VantivException, online.request, transaction, conf, 'dict') mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> <authorizationResponse id='thisisid' reportGroup='Planets' customerId=''> <cnpTxnId>4544691351798650001</cnpTxnId> <orderId>12344</orderId> <response>000</response> <responseTime>2017-03-13T12:14:00</responseTime> <message>Approved</message> <authCode>07585</authCode> <accountUpdater> <originalCardInfo> <type>VI</type> <number>4100100000000000</number> <expDate>1110</expDate> </originalCardInfo> <newCardInfo> <type>VI</type> <number>4532694461984309</number> <expDate>1114</expDate> </newCardInfo> </accountUpdater> <networkTransactionId>63225578415568556365452427825</networkTransactionId> </authorizationResponse> </cnpOnlineResponse> """ # return dict response = online.request(transaction, conf) self.assertEquals('0', response['@response']) self.assertEquals('4544691351798650001', response['authorizationResponse']['cnpTxnId']) self.assertIsInstance(response, dict) # return xml string response = online.request(transaction, conf, 'xml') self.assertIsInstance(response, str) # return fields object. response = online.request(transaction, conf, 'object') self.assertEquals('0', response.response)
def doCycle(self, threadId): authorization = fields.authorization() authorization.reportGroup = '123456' authorization.orderId = str(threadId - (int(round(time.time() * 1000)))) authorization.amount = '106' authorization.orderSource = 'ecommerce' authorization.id = 'id' + str(threadId) card = fields.cardType() card.number = '4100000000000000' card.expDate = '1210' card.type = 'VI' authorization.card = card startTime = (int(round(time.time() * 1000))) response = online.request(authorization, self.config) # print(response) responseTime = (int(round(time.time() * 1000))) - startTime self.assertEquals("123456", response['authorizationResponse']['@reportGroup']) if (response['authorizationResponse']['response'] == '000'): self.successCount += 1 else: self.failedCount += 1 return responseTime
def test_sale_with_nonrealtime_accountUpdater(self, mock__http_post): transaction = fields.sale() transaction.id = '12345' transaction.amount = 106 transaction.cnpTxnId = 123456 transaction.orderId = '12344' transaction.orderSource = 'ecommerce' card = fields.cardType() card.type = 'VI' card.number = '4100000000000000' card.expDate = '1210' transaction.card = card mock__http_post.return_value = """<cnpOnlineResponse version='12.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> <saleResponse> <cnpTxnId>123</cnpTxnId> <accountUpdater> <accountUpdateSource>N</accountUpdateSource> </accountUpdater> </saleResponse> </cnpOnlineResponse> """ response = online.request(transaction, conf) self.assertEquals('123', response['saleResponse']['cnpTxnId']) self.assertEquals( "N", response['saleResponse']['accountUpdater']['accountUpdateSource'])
def test_credit_with_mcc(self, mock__http_post): transaction = fields.credit() transaction.reportGroup = 'Planets' transaction.orderId = '56789' transaction.amount = 100 transaction.orderSource = 'ecommerce' transaction.merchantCategoryCode = '7890' transaction.id = 'thisisid' card = fields.cardType() card.type = 'VI' card.number = '4100000000000100' card.expDate = '1210' transaction.card = card mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='1' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> </cnpOnlineResponse> """ self.assertRaises(utils.VantivException, online.request, transaction, conf, 'dict') mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> <authorizationResponse id='thisisid' reportGroup='Planets' customerId=''> <cnpTxnId>4544691351798650001</cnpTxnId> <orderId>56789</orderId> <response>000</response> <responseTime>2017-03-13T12:14:00</responseTime> <message>Approved</message> <authCode>07585</authCode> <accountUpdater> <originalCardInfo> <type>VI</type> <number>4100000000000100</number> <expDate>1210</expDate> </originalCardInfo> <newCardInfo> <type>VI</type> <number>4532694461984309</number> <expDate>1114</expDate> </newCardInfo> </accountUpdater> <networkTransactionId>63225578415568556365452427825</networkTransactionId> </authorizationResponse> <merchantCategoryCode>7890</merchantCategoryCode> </cnpOnlineResponse> """ response = online.request(transaction, conf) self.assertEquals("000", response['authorizationResponse']['response']) self.assertEquals("7890", response['merchantCategoryCode'])
def test_echeck__Sale_with_mcc(self, mock__http_post): transaction = fields.echeckRedeposit() transaction.reportGroup = 'Planets' transaction.orderId = '12344' transaction.amount = 106 transaction.orderSource = 'ecommerce' transaction.id = 'ThisIsID' echeck = fields.echeckType() echeck.accNum = '12345657890' echeck.routingNum = '123456789' echeck.checkNum = '123455' transaction.merchantCategoryCode = '78901' echeck.accType = 'Checking' transaction.echeck = echeck billtoaddress = fields.contact() billtoaddress.firstName = 'Peter' billtoaddress.lastName = 'Green' billtoaddress.companyName = 'Green Co' billtoaddress.phone = '999-999-9999' transaction.billToAddress = billtoaddress card = fields.cardType() card.type = 'VI' card.number = '4100000000000100' card.expDate = '1210' transaction.card = card mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='1' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> </cnpOnlineResponse> """ self.assertRaises(utils.VantivException, online.request, transaction, conf, 'dict') mock__http_post.return_value = """<cnpOnlineResponse version='11.0' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'> <authorizationResponse id='thisisid' reportGroup='Planets' customerId=''> <cnpTxnId>4544691351798650001</cnpTxnId> <orderId>56789</orderId> <response>000</response> <responseTime>2017-03-13T12:14:00</responseTime> <message>Approved</message> <authCode>07585</authCode> <accountUpdater> <originalCardInfo> <type>VI</type> <number>4100000000000100</number> <expDate>1210</expDate> </originalCardInfo> <newCardInfo> <type>VI</type> <number>4532694461984309</number> <expDate>1114</expDate> </newCardInfo> </accountUpdater> <networkTransactionId>63225578415568556365452427825</networkTransactionId> </authorizationResponse> <merchantCategoryCode>7890</merchantCategoryCode> </cnpOnlineResponse> """ response = online.request(transaction, conf) self.assertEquals("000", response['authorizationResponse']['response']) self.assertEquals("7890", response['merchantCategoryCode'])