Bill & Pay Web API Call Example

What is Bill & Pay?

Businesses of any size can affordably send electronic invoices and receive ACH and credit card payments online from their customers.
Bill & Pay is the most comprehensive product of its kind on the market today. It is loaded with features and options, while remaining affordable and easy-to-use.
Checkout out Bill & Pay for QuickBooks users or Bill & Pay Easy Invoice for non-QuickBooks users.

Benefits of Bill & Pay

 Here is sample java code for authentication.


String xmlRequestData = "<?xml version=\"1.0\"?><request><response><type>xml</type></response><biller><authenticate><id>1111</id><password>password</password></authenticate></biller></request>";


public String xmlPost(String xmlRequestData) {
        String result = "";
        OutputStream os = null;

        try {
            URL url = new URL("https://www.billandpay.com/webservices/service.php");
            URLConnection con = url.openConnection();

            // specify that we will send output and accept input
            con.setDoInput(true);
            con.setDoOutput(true);

            con.setConnectTimeout(20000);  // long timeout, but not infinite
            con.setReadTimeout(20000);

            con.setUseCaches(false);
            con.setDefaultUseCaches(false);

            // tell the web server what we are sending
            con.setRequestProperty("Method", "POST");
            con.setRequestProperty("Content-Type", "text/xml");
            os = con.getOutputStream();
            OutputStreamWriter writer = new OutputStreamWriter(os);

            writer.write(xmlRequestData);
            writer.flush();
            writer.close();

            // reading the response
            InputStreamReader reader = new InputStreamReader(con.getInputStream());

            StringBuilder buf = new StringBuilder();
            char[] cbuf = new char[2048];
            int num;

            while (-1 != (num = reader.read(cbuf))) {
                buf.append(cbuf, 0, num);
            }

            result = buf.toString();

            System.err.println("\nResponse from server after POST:\n" + result);
        } catch (Throwable t) {
            t.printStackTrace(System.out);
        }
        return result;
    }

Comments

Popular posts from this blog

Simple Invoice Creation With Jasper Report

Dynamic Image in Jasper Report

Auto Increment Oracle Table Id Mapping With JPA Entity