private ReqMessage ProcessGeoITDPruchaseVoid(ReqMessage reqMsg_) { LOG.Trace("ENTER"); ReqMessage retVal = new ReqMessage(null); try { string jsonBody = ByteStream.PByteToPrimitive(reqMsg_.Body, 0, typeof(string)).ToString(); GeoITDPurchaseRequest purchaseRequest = GeoITDPurchaseRequest.DeserializeJson(jsonBody); GeoITDClient geoITDClient = new GeoITDClient(); //(ConfigMgr.Instance.MercadoPagoAPIURL, ConfigMgr.Instance.MercadoLibreAPIURL, ConfigMgr.Instance.MercadoLibreAPIAccessTOKEN); string strAux = ""; PurchaseVoidResponse response; LOG.Info("{Message}", $"Before calling PurchaseVoid(), REQUEST:\r\n{jsonBody}"); if (geoITDClient.PurchaseVoid(GeoITDPurchaseRequest.ToPurchaseVoidRequest(purchaseRequest), out response)) { strAux = $"response_code={response.ResponseCode}|" + $"transaction_id={response.TransactionId}"; } else { strAux = $"response_code={(response == null? -1 : response.ResponseCode)}"; } //retVal.MessageType = reqMsg_.MessageType; retVal.Body = ByteStream.ToPByte(strAux); //retVal.BodySize = retVal.Body.Length; //retVal.Checksum = retVal.GenerateChecksum(); LOG.Info("{Message}", $"After calling Purchase(), RESPONSE:\r\n{strAux}"); } catch (Exception ex) { //retVal.MessageType = reqMsg_.MessageType; retVal.Body = ByteStream.ToPByte(ex.Message); //retVal.BodySize = retVal.Body.Length; //retVal.Checksum = retVal.GenerateChecksum(); LOG.Fatal(ex, "{Message}", "Exception caught."); } finally { LOG.Trace("EXIT"); } retVal.MessageType = reqMsg_.MessageType; retVal.BodySize = retVal.Body.Length; retVal.Checksum = retVal.GenerateChecksum(); return(retVal); }
private ReqMessage ProcessGeoITDQueryStatus(ReqMessage reqMsg_, bool waitForStatus = true) { LOG.Trace("ENTER"); ReqMessage retVal = new ReqMessage(null); try { string jsonBody = ByteStream.PByteToPrimitive(reqMsg_.Body, 0, typeof(string)).ToString(); GeoITDPurchaseQueryRequest queryRequest = GeoITDPurchaseQueryRequest.DeserializeJson(jsonBody); GeoITDClient geoITDClient = new GeoITDClient(); string strAux = ""; PurchaseQueryResponse queryResponse; LOG.Info("{Message}", $"Before calling ProcessGeoITDQueryStatus(), REQUEST:\r\n{jsonBody}"); if (geoITDClient.QueryTransactionStatus(GeoITDPurchaseQueryRequest.ToPurchaseQueryRequest(queryRequest), out queryResponse, waitForStatus)) { strAux = $"response_code={queryResponse.ResponseCode}|" + $"pos_response_code={queryResponse.PosResponseCode}|" + $"pos_response_code_ext={queryResponse.PosResponseCodeExtension}|" + $"ticket={queryResponse.Ticket}|" + $"authorization_code={queryResponse.AuthorizationCode}|" + $"issuer={queryResponse.Issuer}|" + $"card_number={queryResponse.CardNumber}|" + $"expiration_date={queryResponse.ExpirationDate}|" + $"transaction_date={DateTime.ParseExact($"{queryResponse.TransactionDate}", "yyMMdd", CultureInfo.InvariantCulture):dd/MM/yyyy}|" + $"transaction_time={DateTime.ParseExact($"{queryResponse.TransactionHour}", "HHmmss", CultureInfo.InvariantCulture):HH:mm}|" + $"EMV_application_id={queryResponse.EmvApplicationId}|" + $"EMV_application_name={queryResponse.EmvApplicationName}|" + $"transaction_type={queryResponse.TransactionType}|" + $"origin_card_type={queryResponse.OriginCardType}|" + $"batch={queryResponse.Batch}|" + $"acquirer={queryResponse.Acquirer}|" + $"merchant={queryResponse.Merchant}|" + $"input_mode={queryResponse.InputMode}|" + $"card_owner_name={queryResponse.CardOwnerName}|" + $"tax_amount={queryResponse.TaxAmount}"; } else { strAux = $"response_code={queryResponse.ResponseCode}"; } retVal.MessageType = reqMsg_.MessageType; retVal.Body = ByteStream.ToPByte(strAux); retVal.BodySize = retVal.Body.Length; retVal.Checksum = retVal.GenerateChecksum(); LOG.Info("{Message}", $"After calling ProcessGeoITDQueryStatus(), RESPONSE:\r\n{strAux}"); } catch (Exception ex) { LOG.Fatal(ex, "{Message}", "Exception caught."); } finally { LOG.Trace("EXIT"); } return(retVal); }
//private ReqMessage ProcessGeoITDPruchaseVoid(ReqMessage reqMsg_) //{ // LOG.Trace("ENTER"); // ReqMessage retVal = new ReqMessage(null); // try // { // string jsonBody = ByteStream.PByteToPrimitive(reqMsg_.Body, 0, typeof(string)).ToString(); // GeoITDPurchaseRequest purchaseRequest = GeoITDPurchaseRequest.DeserializeJson(jsonBody); // GeoITDClient geoITDClient = new GeoITDClient(); // //(ConfigMgr.Instance.MercadoPagoAPIURL, ConfigMgr.Instance.MercadoLibreAPIURL, ConfigMgr.Instance.MercadoLibreAPIAccessTOKEN); // string strAux = ""; // long transactionId = 0; // PurchaseQueryResponse queryResponse; // LOG.Info("{Message}", $"Before calling Purchase(), REQUEST:\r\n{jsonBody}"); // if (geoITDClient.PurchaseVoid(GeoITDPurchaseRequest.ToPurchaseVoidRequest(purchaseRequest), out queryResponse)) // { // strAux = $"response_code={queryResponse.ResponseCode}|" + // $"pos_response_code={queryResponse.PosResponseCode}|" + // $"pos_response_code_ext={queryResponse.PosResponseCodeExtension}|" + // $"transaction_id={transactionId}|" + // $"ticket={queryResponse.Ticket}|" + // $"authorization_code={queryResponse.AuthorizationCode}|" + // $"issuer={queryResponse.Issuer}|" + // $"card_number={queryResponse.CardNumber}|" + // $"expiration_date={queryResponse.ExpirationDate}|" + // $"transaction_datetime={queryResponse.TransactionDate} {queryResponse.TransactionHour}"; // } // else // { // strAux = $"response_code={queryResponse.ResponseCode}"; // } // retVal.MessageType = reqMsg_.MessageType; // retVal.Body = ByteStream.ToPByte(strAux); // retVal.BodySize = retVal.Body.Length; // retVal.Checksum = retVal.GenerateChecksum(); // LOG.Info("{Message}", $"After calling Purchase(), RESPONSE:\r\n{strAux}"); // } // catch (Exception ex) // { // LOG.Fatal(ex, "{Message}", "Exception caught."); // } // finally // { // LOG.Trace("EXIT"); // } // return retVal; //} private ReqMessage ProcessGeoITDPruchaseRefund(ReqMessage reqMsg_) { LOG.Trace("ENTER"); ReqMessage retVal = new ReqMessage(null); try { string jsonBody = ByteStream.PByteToPrimitive(reqMsg_.Body, 0, typeof(string)).ToString(); GeoITDPurchaseRequest purchaseRequest = GeoITDPurchaseRequest.DeserializeJson(jsonBody); GeoITDClient geoITDClient = new GeoITDClient(); //(ConfigMgr.Instance.MercadoPagoAPIURL, ConfigMgr.Instance.MercadoLibreAPIURL, ConfigMgr.Instance.MercadoLibreAPIAccessTOKEN); string strAux = ""; //long transactionId = 0; PurchaseRefundResponse queryResponse; LOG.Info("{Message}", $"Before calling Purchase(), REQUEST:\r\n{jsonBody}"); if (geoITDClient.PurchaseRefund(GeoITDPurchaseRequest.ToPurchaseRefundRequest(purchaseRequest), out queryResponse)) { strAux = $"response_code={queryResponse.ResponseCode}|" + $"transaction_id={queryResponse.TransactionId}"; } else { strAux = $"response_code={(queryResponse == null ? -1 : queryResponse.ResponseCode)}"; } //if (geoITDClient.PurchaseRefund(GeoITDPurchaseRequest.ToPurchaseRefundRequest(purchaseRequest), out queryResponse)) //{ // strAux = $"response_code={queryResponse.ResponseCode}|" + // $"pos_response_code={queryResponse.PosResponseCode}|" + // $"pos_response_code_ext={queryResponse.PosResponseCodeExtension}|" + // $"transaction_id={transactionId}|" + // $"ticket={queryResponse.Ticket}|" + // $"authorization_code={queryResponse.AuthorizationCode}|" + // $"issuer={queryResponse.Issuer}|" + // $"card_number={queryResponse.CardNumber}|" + // $"expiration_date={queryResponse.ExpirationDate}|" + // $"transaction_datetime={queryResponse.TransactionDate} {queryResponse.TransactionHour}"; //} //else //{ // strAux = $"response_code={queryResponse.ResponseCode}"; //} //retVal.MessageType = reqMsg_.MessageType; retVal.Body = ByteStream.ToPByte(strAux); //retVal.BodySize = retVal.Body.Length; //retVal.Checksum = retVal.GenerateChecksum(); LOG.Info("{Message}", $"After calling Purchase(), RESPONSE:\r\n{strAux}"); } catch (Exception ex) { retVal.Body = ByteStream.ToPByte(ex.Message); LOG.Fatal(ex, "{Message}", "Exception caught."); } finally { LOG.Trace("EXIT"); } retVal.MessageType = reqMsg_.MessageType; retVal.BodySize = retVal.Body.Length; retVal.Checksum = retVal.GenerateChecksum(); return(retVal); }