Exemple #1
0
    def test_accept_challenged_charge_request(self):
        '''
        Verify that we can accept challenged charge requests.
        '''
        # 1: get a token
        # on live, this step --MUST-- be performed by the web
        # application through the javascript library.
        token = self.get_token(random.choice(fixtures.CC_CHALLENGED_FDS),
                               SANDBOX_CLIENT_KEY)

        # 2: Create a sandbox gateway
        gateway = veritrans.VTDirect(SANDBOX_SERVER_KEY, sandbox_mode=True)

        # 3: Create a charge request
        cc_payment = payment_types.CreditCard(
            bank=self.expected['credit_card']['bank'], token_id=token)

        charge_req = request.ChargeRequest(
            charge_type=cc_payment,
            transaction_details=self.trans_details,
            customer_details=self.cust_details,
            item_details=self.item_details)

        # 4: Submit charge request
        #     - verify we get a status_code of CHALLENGE back
        #     - verify that we are returned a CreditCardChargeResponse
        resp = gateway.submit_charge_request(charge_req)

        self.assertIsInstance(resp, response.CreditCardChargeResponse)
        self.assertEqual(status.CHALLENGE, resp.status_code)

        # 5: Lookup the status of the transaction using the response
        #     - verify can use CreditCareChargeResponse can as a StatusRequest
        #     - verify we get a StatusResponse back
        #     - verify the status_code is still CHALLENGE
        status_resp = gateway.submit_status_request(resp)
        self.assertIsInstance(status_resp, response.StatusResponse)
        self.assertEqual(status_resp.status_code, status.CHALLENGE)

        # 6: Approve the transaction!
        #     - verify can build an ApprovalRequest
        #     - verify we get an ApprovalResponse back
        #     - verify the status_code is now SUCCESS
        approval_req = request.ApprovalRequest(status_resp.order_id)
        approval_resp = gateway.submit_approval_request(approval_req)

        self.assertIsInstance(approval_resp, response.ApproveResponse)
        self.assertEqual(approval_resp.status_code, status.SUCCESS)
Exemple #2
0
 def invalid_orderid_raises_validation_exception(self):
     order_id = ''.join([fake.random_letter() for _ in range(51)])
     req = request.ApprovalRequest(order_id)
     self.assertRaises(validators.ValidationError,
                       lambda: req.validate_all())
Exemple #3
0
 def test_init_args_persisted_as_attribues(self):
     order_id = ''.join([fake.random_letter() for _ in range(20)])
     req = request.ApprovalRequest(order_id)
     self.assertEqual(req.order_id, order_id)