예제 #1
0
def http_delete_request(url_suffix,config=conf):
    request_url = config.url + url_suffix

    try:
        http_response = requests.delete(request_url, headers=PAYFAC_API_HEADERS,auth=HTTPBasicAuth(config.username, config.password))

    except requests.RequestException:
        raise utils.PayfacError(HTTP_ERROR_MESSAGE)

    print_to_console("\nDELETE request to:", request_url, config)
    validate_response(http_response)
    print_to_console("\nResponse :", http_response.text, config)
    return utils.generate_response(http_response)
예제 #2
0
def http_put_request(url_suffix, request_xml, config=conf):
    request_url = config.url.encode('utf-8') + url_suffix;
    try:
        http_response = requests.put(request_url, headers=PAYFAC_API_HEADERS,
                                     auth=HTTPBasicAuth(config.username, config.password),
                                     data=request_xml)
    except requests.RequestException:
        raise utils.PayfacError(HTTP_ERROR_MESSAGE)

    print_to_console("\nPUT request to:", request_url, config)
    print_to_console("\nRequest :", request_xml, config)
    validate_response(http_response)
    print_to_console("\nResponse :", http_response.text, config)
    return utils.generate_response(http_response)
예제 #3
0
def http_get_retrieval_request(url_suffix, config=conf):
    url = getattr(config, 'url')
    # print("url -> "+url+"\n")
    request_url = url + url_suffix
    # request_url = "https://www.testvantivcnp.com/sandbox/payfac" + url_suffix

    try:
        http_response = requests.get(request_url, headers=PAYFAC_API_HEADERS,
                                     auth=HTTPBasicAuth(config.username, config.password))

    except requests.RequestException:
        traceback.print_exc()
        raise utils.PayfacError(HTTP_ERROR_MESSAGE)

    print_to_console("\nGET request to:", request_url, config)
    validate_response(http_response)
    print_to_console("\nResponse :", http_response.text, config)
    return utils.generate_response(http_response)