Sunday, February 21, 2016

Cashless transaction with local Transport - part 3


package JavaSMSProject;


import java.net.*;

public class CopyOfSMSclass {
public void sendSMS(Integer amount, Integer bal, String recipient) {
        try {
                //String recipient = "918888899999"; // Receipietnt mobile number
                String message = "Your account has been deducted with" + amount + "your current balance is" + bal;
                String username = "xxx";  //Username that you have registered with OzekiNG
                String password = "xxx"; // Password that you have registered with OzekiNG
                String originator = "918888866666"; // Sender mobile number

                String requestUrl  = "http://127.0.0.1:9501/api?action=sendmessage&" +
    "username=" + URLEncoder.encode(username, "UTF-8") +
    "&password=" + URLEncoder.encode(password, "UTF-8") +
    "&recipient=" + URLEncoder.encode(recipient, "UTF-8") +
    "&messagetype=SMS:TEXT" +
    "&messagedata=" + URLEncoder.encode(message, "UTF-8") +
    "&originator=" + URLEncoder.encode(originator, "UTF-8") +
    "&serviceprovider=HTTPServer0" +
    "&responseformat=html";
             
                //GSMModem1



                URL url = new URL(requestUrl);
                HttpURLConnection uc = (HttpURLConnection)url.openConnection();

                System.out.println(uc.getResponseMessage());

                uc.disconnect();

        } catch(Exception ex) {
                System.out.println(ex.getMessage());

        }
}


}


This class triggers SMS gateway and sends the information to the customer.

A basic application to work with SMS along with cashless transaction with local transport and it has few enhancements to work on.






No comments:

Post a Comment