from __future__ import print_function
import time
import authorizenet_rest

from authorizenet_rest.rest import ApiException
from authorizenet_rest.apis.captures_api import CapturesApi
from pprint import pprint
import warnings
import os
import sys
# QA modification
import csv
# QA modification
# import imp
# constants = imp.load_source('modulename', 'constants.py')
# warnings.filterwarnings("ignore",category=DeprecationWarning)
import base64
import urllib3

ExternalConfig = imp.load_source('modulename', '.\ExternalConfiguration.py')


def create_a_capture(paymentid):
    ExternalConfig.setConfig();
    apiclient = ExternalConfig.configureApiClient();
    authorization = ExternalConfig.getAuthorization()
    api_instance = authorizenet_rest.apis.captures_api.CapturesApi(apiclient)
    body = authorizenet_rest.CaptureRequest("150.00")
    try:
        print("Check Response")
        api_response = api_instance.create_a_capture( paymentid, body, authorization= authorization)
        pprint(api_response)

    except ApiException as e:
        print("Connection exception:")
        print("Exception when calling paymentsAPI->CreateACapture: %s\n" % e)

if (os.path.basename(__file__) == os.path.basename(sys.argv[0])):
    create_a_capture("60033788906")