1
Check Response
  • What is returned from Secure Pay ?

  • /** This is the SOAP exposes method
    */
    public String validateCreditCard(String encryptedData)
    {

    String returnMessage = "Valid Credit Card"; //if no execption is thrown

    try
    {
    System.out.println("encryptedData is " + encryptedData);
    decryptData(encryptedData);
    verifyCreditCardInfo(false);

    }
    catch(AddressMismatchException amme)
    {
    returnMessage = amme.getMessage();
    //"Address entered does not match with the Credit Card system address";
    }
    catch(InvalidCardNumberException icne)
    {
    returnMessage = icne.getMessage(); //
    "Invalid Credit Number entered, Does not exist in Credit Card system";
    }
    catch(ExpiredCardException ece)
    {
    returnMessage = ece.getMessage(); //
    "Credit Number has expired, Can not Accept";
    }
    catch(NameMismatchException nmme)
    {
    returnMessage = nmme.getMessage(); //"
    Name entered does not match with the Credit Card system name for this card";
    }
    catch(InSufficientBalanceException ibe)
    {
    returnMessage = ibe.getMessage(); //
    "Insufficient funds available for this card number , Can not accept";
    }
    catch(Exception e)
    {
    e.printStackTrace();
    return "System exception occured";
    }

    return returnMessage;
    }

  • // UMSL - web application retrieves this String

  •  String  paymentSuccessful = invokeCreditCardValidationService(session);

    if (paymentSuccessful.equalsIgnoreCase("Valid Credit Card"))
    {
    forwardPath = "success";
    session.setAttribute(LookUpConstants.SUCCESS_MESSAGE,LookUpConstants.PAYMENT_SUCCESSFUL);
    }
    else
    {
    throw new Exception();
    }

  • public String invokeCreditCardValidationService(HttpSession session) throws Exception
    {
    String sHtmlResponse = "";
    String encryptedFile = "C:\\Program Files\\Apache Group\\jakarta-tomcat-4.1.27\\webapps\\cs554project\\WEB-INF\\encryptedpaymentfile.xml";
    String urlString = "http://localhost:7001/cs5890project/servlet/rpcrouter";
    String returnedString = "";


    try
    {
    BufferedReader in = new BufferedReader(new FileReader(encryptedFile));
    String str = null;
    StringBuffer stringBuffer = new StringBuffer();

    while ((str = in.readLine()) != null)
    {
    stringBuffer.append(str+"\n");
    }

    //build a Call object
    Call call = new Call();
    call.setTargetObjectURI("urn:creditCardValidatorService");
    call.setMethodName("validateCreditCard");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    //creating a parameter list
    Vector params = new Vector();
    params.addElement(new Parameter("name", String.class, stringBuffer,null));

    //adding the parameter(s) to the Call object
    call.setParams(params);

    System.out.println("urlString is " + urlString);

    //invoke the soap method
    Response res = call.invoke(new URL(urlString), "");

    //if there is no fault in the method invocation, get the result

    if( res.generatedFault() ==false)
    {
    Parameter retValue = res.getReturnValue();
    Object value = retValue.getValue();
    returnedString = value.toString();
    }
    else
    {
    returnedString = res.getFault().getFaultString();
    System.out.println("The fault is: "+res.getFault().getFaultString());
    }


    System.out.println("returnedString is " + returnedString);

    return returnedString;
    }

    catch(Exception e)
    {
    e.printStackTrace();
    throw e;
    }


    }

  • If success , add a record into UMSL Database for tracking that a credit card payment has been made

  • int success = -1;

    String sql = "insert into student_payment(student_id ,credit_card_no , expiration_date, card_type, payment_amount) values (" + studentId + ",'" + cardNumber + "','" + expiryDate + "','"+ cardType + "'," + courseFee + ")";

    System.out.println("sql is " + sql);

    success = stmt.executeUpdate(sql);

    if (success > 0)
    {
    AddressData addressData = new AddressData();

    addressData.setStreet1(street1);
    if (street2 != null)
    {
    addressData.setStreet2(street2);
    }
    addressData.setCity(city);
    addressData.setState(state);
    addressData.setZipcode(zip);

    userData.setAddressData(addressData);


    CreditCardPaymentData creditCardPaymentData = new CreditCardPaymentData();

    creditCardPaymentData.setAmount(courseFee);
    creditCardPaymentData.setCardNumber(cardNumber);
    creditCardPaymentData.setCardType(cardType);
    creditCardPaymentData.setExpiryDate(expiryDate);
    creditCardPaymentData.setSecurityCode(securityCode);

    session.setAttribute(LookUpConstants.CREDIT_CARD_PAYMENT_DATA,creditCardPaymentData);
    }

 

                                                                       THANK YOU !