コード例 #1
0
  public GetTransactionResponseMessage getTransaction(
      String api,
      String safekey,
      additionalInfo additionalInformation,
      List<HeaderProperty> headers,
      String username,
      String password) {
    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.implicitTypes = true;
    soapEnvelope.dotNet = true;
    soapEnvelope.setAddAdornments(true);
    SoapObject soapReq = new SoapObject("", "n1:getTransaction");

    // getTransaction namespace, NB for PAYU
    AttributeInfo attributeInfo = new AttributeInfo();
    attributeInfo.setValue("http://soap.api.controller.web.payjar.com/");
    attributeInfo.setName("xmlns:n1");
    soapReq.addAttribute(attributeInfo);

    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/",
        "AdditionalInformation",
        new additionalInfo().getClass());
    soapReq.addProperty("Api", api);
    soapReq.addProperty("Safekey", safekey);
    additionalInformation.isGetTransaction = true;
    soapReq.addProperty("AdditionalInformation", additionalInformation);
    soapEnvelope.setOutputSoapObject(soapReq);

    // set security header for PAYU
    Element header[] = new Element[1];
    header[0] =
        new Element()
            .createElement(
                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
                "Security");
    header[0].setAttribute(null, "v:mustUnderstand", "1");

    Element to =
        new Element()
            .createElement(
                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
                "UsernameToken");

    Element action1 = new Element().createElement(null, "n0:Username");
    action1.setAttribute(
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
        "Id",
        "UsernameToken-9");
    action1.addChild(Node.TEXT, username);
    to.addChild(Node.ELEMENT, action1);

    Element action2 = new Element().createElement(null, "n0:Password");
    action2.setAttribute(
        null,
        "Type",
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
    action2.addChild(Node.TEXT, password);
    to.addChild(Node.ELEMENT, action2);

    header[0].addChild(Node.ELEMENT, to);

    soapEnvelope.headerOut = header;

    HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);
    httpTransport.debug = true;
    try {
      httpTransport.getServiceConnection().setRequestProperty("Connection", "close");
      System.setProperty("http.keepAlive", "false");
      httpTransport.getServiceConnection().setRequestProperty("Accept-Encoding", "gzip");
      if (headers != null) {
        httpTransport.call(
            "http://soap.api.controller.web.payjar.com/getTransaction", soapEnvelope, headers);
      } else {
        sendgetTransaction(
            "http://soap.api.controller.web.payjar.com/getTransaction", soapEnvelope, 0);
      }
      Object retObj = soapEnvelope.bodyIn;
      if (retObj instanceof SoapFault) {
        SoapFault fault = (SoapFault) retObj;
        Exception ex = new Exception(fault.faultstring);
        if (eventHandler != null) eventHandler.Wsdl2CodeFinishedWithException(ex);
      } else {
        SoapObject result = (SoapObject) retObj;
        if (result.getPropertyCount() > 0) {
          Object obj = result.getProperty(0);
          SoapObject j = (SoapObject) obj;
          GetTransactionResponseMessage resultVariable = new GetTransactionResponseMessage(j);
          return resultVariable;
        }
      }
    } catch (Exception e) {
      if (eventHandler != null) eventHandler.Wsdl2CodeFinishedWithException(e);
      e.printStackTrace();
    }
    return null;
  }
コード例 #2
0
  public SetTransactionResponseMessage setTransaction2(
      String api,
      String safekey,
      transactionType transactionType,
      boolean transactionTypeSpecified,
      boolean stage,
      boolean stageSpecified,
      additionalInfo additionalInformation,
      customer customer,
      basket basket,
      fraud fraud,
      VectorcreditCard creditcard,
      Vectoreft eft,
      VectorloyaltyCard loyalty,
      VectorbankTransfer bankTransfer,
      ebucks ebucks,
      autoPay autopay,
      soulstace soulstace,
      globalpay globalpay,
      VectorcustomField customfield,
      transactionRecord transactionRecord,
      List<HeaderProperty> headers,
      String username,
      String password) {
    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.implicitTypes = false;
    soapEnvelope.dotNet = true;
    soapEnvelope.setAddAdornments(true);
    SoapObject soapReq = new SoapObject("", "n1:setTransaction");

    // settranaction namespace, NB for PAYU
    AttributeInfo attributeInfo = new AttributeInfo();
    attributeInfo.setValue("http://soap.api.controller.web.payjar.com/");
    attributeInfo.setName("xmlns:n1");
    soapReq.addAttribute(attributeInfo);

    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/",
        "AdditionalInformation",
        new additionalInfo().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Customer", new customer().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Basket", new basket().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Fraud", new fraud().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Ebucks", new ebucks().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Autopay", new autoPay().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Soulstace", new soulstace().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/", "Globalpay", new globalpay().getClass());
    soapEnvelope.addMapping(
        "http://soap.api.controller.web.payjar.com/",
        "TransactionRecord",
        new transactionRecord().getClass());

    soapReq.addProperty("Customer", customer);
    soapReq.addProperty("Api", api);
    soapReq.addProperty("Safekey", safekey);
    if (transactionTypeSpecified)
      soapReq.addProperty("TransactionType", transactionType.toString());
    if (stageSpecified) soapReq.addProperty("Stage", stage);
    soapReq.addProperty("AdditionalInformation", additionalInformation);
    soapReq.addProperty("Basket", basket);
    //        soapReq.addProperty("Fraud", fraud);
    //        soapReq.addProperty("Creditcard", creditcard);
    //        soapReq.addProperty("Loyalty", loyalty);
    //        soapReq.addProperty("BankTransfer", bankTransfer);
    //        soapReq.addProperty("Ebucks", ebucks);
    //        soapReq.addProperty("Autopay", autopay);
    //        soapReq.addProperty("Soulstace", soulstace);
    //        soapReq.addProperty("Globalpay", globalpay);
    // soapReq.addProperty("Customfield", customfield);
    soapReq.addProperty("TransactionRecord", transactionRecord);
    soapEnvelope.setOutputSoapObject(soapReq);

    // set security header for PAYU
    Element header[] = new Element[1];
    header[0] =
        new Element()
            .createElement(
                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
                "Security");
    header[0].setAttribute(null, "v:mustUnderstand", "1");

    Element to =
        new Element()
            .createElement(
                "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
                "UsernameToken");

    Element action1 = new Element().createElement(null, "n0:Username");
    action1.setAttribute(
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
        "Id",
        "UsernameToken-9");
    action1.addChild(Node.TEXT, username);
    to.addChild(Node.ELEMENT, action1);

    Element action2 = new Element().createElement(null, "n0:Password");
    action2.setAttribute(
        null,
        "Type",
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
    action2.addChild(Node.TEXT, password);
    to.addChild(Node.ELEMENT, action2);

    header[0].addChild(Node.ELEMENT, to);

    soapEnvelope.headerOut = header;

    HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);
    httpTransport.debug = true;
    try {
      if (headers != null) {
        httpTransport.call(
            "http://soap.api.controller.web.payjar.com/setTransaction", soapEnvelope, headers);
      } else {
        httpTransport.call(
            "http://soap.api.controller.web.payjar.com/setTransaction", soapEnvelope);
      }
      Object retObj = soapEnvelope.bodyIn;
      String a = soapEnvelope.toString();
      if (retObj instanceof SoapFault) {
        SoapFault fault = (SoapFault) retObj;
        Exception ex = new Exception(fault.faultstring);
        if (eventHandler != null) eventHandler.Wsdl2CodeFinishedWithException(ex);
      } else {
        SoapObject result = (SoapObject) retObj;
        if (result.getPropertyCount() > 0) {
          Object obj = result.getProperty(0);
          SoapObject j = (SoapObject) obj;
          SetTransactionResponseMessage resultVariable = new SetTransactionResponseMessage(j);
          return resultVariable;
        }
      }
    } catch (Exception e) {
      if (eventHandler != null) eventHandler.Wsdl2CodeFinishedWithException(e);
      e.printStackTrace();
    }
    return null;
  }