from __future__ import print_function
import time
import authorizenet_rest

from authorizenet_rest.rest import ApiException
from authorizenet_rest.apis.forced_captures_api import ForcedCapturesApi
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_foced_capture():
    ExternalConfig.setConfig();
    apiclient = ExternalConfig.configureApiClient();
    authorization = ExternalConfig.getAuthorization()
    futdate = ExternalConfig.futuredate()
    api_instance = authorizenet_rest.apis.forced_captures_api.ForcedCapturesApi(apiclient)
    creditcard = authorizenet_rest.CreditCard("4111111111111111", futdate, "VISA", "123")
    bankaccount = authorizenet_rest.BankAccount("savings", "8456464", "Demo", "WEB", "BankName", "")
    payment_instrument = authorizenet_rest.PaymentInstrument()
    payment_instrument.credit_card = creditcard
    payment_instrument.bank_account = ""
    payment_instrument.fluid_data = ""
    payment_instrument.customer = ""
    payment_instrument.validate = "true"
    forced_capture_request = authorizenet_rest.ForcedCaptureRequest("250", "1234", payment_instrument)
    try:
        api_response = api_instance.create_a_forced_capture(forced_capture_request, authorization= authorization)
        pprint(api_response)

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

if (os.path.basename(__file__) == os.path.basename(sys.argv[0])):
    create_a_foced_capture()