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
예제 #2
0
    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_numAccountUpdates(self, mock__get_file_str_from_sftp):
        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'

        mock__get_file_str_from_sftp.return_value = """<cnpResponse version='12.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'>
                        <batchResponse cnpBatchId='12344' merchantId='56789' numAccountUpdates='3' xmlns='http://www.vantivcnp.com/schema'>
                            <saleResponse>
                                <cnpTxnId>123</cnpTxnId>
                                <accountUpdater>
                                    <accountUpdateSource>N</accountUpdateSource>
                                </accountUpdater>
                                </saleResponse>
                            </batchResponse>
                       </cnpResponse>
                       """

        response = batch.retrieve('retrieve_file', conf)
        self.assertEquals(
            response['batchResponse']['saleResponse']['cnpTxnId'], '123')
        self.assertEquals(response['batchResponse']['@numAccountUpdates'], '3')
    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)
예제 #5
0
    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'])
예제 #6
0
    def test_request_args_invalid_conf(self):
        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
        conf_wrong = 1
        self.assertRaises(utils.VantivException, online.request, transaction, conf_wrong)
    def test_submit(self, mock__put_file_to_sftp):
        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

        txns = batch.Transactions()
        txns.add(transaction)

        # first arg is not instance of batch.Transactions
        self.assertRaises(utils.VantivException, batch.submit, transaction,
                          conf)

        # first arg is an new instance of utils.Configuration
        self.assertRaises(utils.VantivException, batch.submit,
                          batch.Transactions(), conf)

        # second arg is not instance of utils.Configuration
        self.assertRaises(utils.VantivException, batch.submit, txns, 1)

        # Third arg is not sring
        self.assertRaises(utils.VantivException, batch.submit, txns, conf,
                          txns)

        # Fourth arg is not positive int
        self.assertRaises(utils.VantivException, batch.submit, txns, conf,
                          'aaa', -1)

        mock__put_file_to_sftp.return_value = 'filename'

        self.assertEquals('filename', batch.submit(txns, conf))
예제 #8
0
    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'])