public NpsUpdateResponse Update(NpsModel model) { var updateResponse = new NpsUpdateResponse(); try { using (var ctx = new DataClassesDataContext()) { var nps = ctx.Engagement_NetPromoterScores.FirstOrDefault(r => r.NPSEngagementId == model.NpsEngagementId && r.MasterCustomerId == model.MasterCustomerId); if (nps != null) { nps.NPSResultDate = DateTime.Now; nps.NPSScore = Convert.ToInt32(model.Score); nps.NPSComments = model.Comments; ctx.SubmitChanges(); } updateResponse.Success = true; return(updateResponse); } } catch (Exception e) { logger.Log(LogLevel.Error, e, "Error in Controller"); updateResponse.Success = false; updateResponse.ErrorMessage = e.Message; return(updateResponse); } }
public static RequerimientoStruct_SimpleQueryTx GetRequestSimpleQueryTx(NpsModel model) { RequerimientoStruct_SimpleQueryTx req = new RequerimientoStruct_SimpleQueryTx(); req.psp_Version = "2.2"; req.psp_MerchantId = "arsa_smartcar"; req.psp_QueryCriteria = model.psp_QueryCriteria; req.psp_QueryCriteriaId = model.psp_QueryCriteriaId; req.psp_PosDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); NpsEncryptFields operations = new NpsEncryptFields(); req.psp_SecureHash = operations.EncriptarCampos(GetCatParamsSimpleQueryTx(req)); return(req); }
public tbPayment ConsultarEstadoDelPago(string psp_TransactionId, string psp_MerchTxRef, tbPaymentDetail paymentDetail) { try { _paymentDetail = paymentDetail; NpsModel model = new NpsModel(); model.psp_QueryCriteria = "T"; model.psp_QueryCriteriaId = psp_TransactionId; return(this.RequestSimpleQueryTx(model)); } catch (Exception ex) { throw ex; } }
public string CrearFormulario(string merchantTransactionReference, string amount, string product, string numPayments, tbPaymentDetail paymentDetail) { try { _paymentDetail = paymentDetail; NpsModel model = new NpsModel(); model.psp_MerchTxRef = merchantTransactionReference; model.psp_Amount = amount; model.psp_Product = product; model.psp_NumPayments = numPayments; return(this.ArmarRequest(model)); } catch (Exception ex) { throw ex; } }
public static RequerimientoStruct_PayOnLine_3p GetRequestPayOnline3p(NpsModel model) { RequerimientoStruct_PayOnLine_3p req = new RequerimientoStruct_PayOnLine_3p(); req.psp_Version = "2.2"; req.psp_MerchantId = "arsa_smartcar"; //<-- this will be parametrisable req.psp_TxSource = "WEB"; req.psp_MerchTxRef = model.psp_MerchTxRef; //This will be guide numer req.psp_MerchOrderId = "003"; req.psp_ReturnURL = ConfigurationManager.AppSettings["ServerName"] + "/api/ServicePaymentFormListener"; req.psp_FrmLanguage = "es_AR"; //<-- this will be parameter (ex. cookies) //req.psp_FrmBackButtonURL = "https://returnurl/back.html"; req.psp_Amount = model.psp_Amount; req.psp_NumPayments = model.psp_NumPayments; req.psp_Currency = "032"; //<-- this will be parametrisable req.psp_Country = "ARG"; //<-- this will be parametrisable req.psp_Product = model.psp_Product; //14 is Visa, see nps documentation. req.psp_CustomerMail = "*****@*****.**"; req.psp_MerchantMail = "*****@*****.**"; req.psp_PurchaseDescription = "ENVIO DE CARTA"; req.psp_PosDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // "2016-06-26 15:00:00"; if (!string.IsNullOrEmpty(model.psp_CustomerId)) { req.psp_VaultReference = new VaultReference3pStruct() { CustomerId = model.psp_CustomerId } } ; NpsEncryptFields operations = new NpsEncryptFields(); req.psp_SecureHash = operations.EncriptarCampos(GetCatParamsPayOnline3p(req)); return(req); }
private string ArmarRequest(NpsModel model) { try { //var proxy = new NpsService.PaymentServicePlatformPortTypeClient("PaymentServicePlatformPort"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; PaymentServicePlatformPortTypeClient client = new PaymentServicePlatformPortTypeClient("PaymentServicePlatformPort"); RespuestaStruct_PayOnLine_3p result = new RespuestaStruct_PayOnLine_3p(); RequerimientoStruct_PayOnLine_3p query = new RequerimientoStruct_PayOnLine_3p(); query = GetRequestPayOnline3p(model); this.AuditRequestResponse(JsonConvert.SerializeObject(query)); result = client.PayOnLine_3p(query); this.AuditRequestResponse(JsonConvert.SerializeObject(result)); //Estoy actualizando por referencia los valores de los campos dentro del registro tbPaymentDetails _paymentDetail.pde_vendor_response_id = result.psp_TransactionId; _paymentDetail.pde_vendor_response_status = result.psp_ResponseCod; if (!string.IsNullOrEmpty(result.psp_FrontPSP_URL)) { return(result.psp_FrontPSP_URL); } else { return(result.psp_ResponseExtended); } } catch (Exception ex) { throw ex; } }
public RetornoModel <List <NpsModel> > ObterAgendamentosPorStatus(enumStatusNPS Status) { RetornoModel <List <NpsModel> > retorno = new RetornoModel <List <NpsModel> >(); retorno.Mensagem = "OK"; retorno.Sucesso = true; retorno.Retorno = new List <NpsModel>(); try { using (var bo = new NetPromoterServiceBO()) { var registros = bo.ObterAgendamentosPorStatus(Status.ValueAsString()).ToList(); registros.ForEach(a => { NpsModel nps = new NpsModel(); nps.ID = a.ID; nps.Name = a.Name; nps.Email = a.Email; nps.Delay = a.Delay; nps.Status = a.Status; nps.Canal = a.Canal; nps.DataInclusao = a.DataInclusao; nps.DataEnvio = a.DataEnvio; retorno.Retorno.Add(nps); }); } } catch (Exception ex) { retorno.Mensagem = ex.Message; retorno.Sucesso = false; } return(retorno); }
private tbPayment RequestSimpleQueryTx(NpsModel model) { try { tbPayment paymentResult = new tbPayment(); //var proxy = new NpsService.PaymentServicePlatformPortTypeClient("PaymentServicePlatformPort"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; PaymentServicePlatformPortTypeClient client = new PaymentServicePlatformPortTypeClient("PaymentServicePlatformPort"); RespuestaStruct_SimpleQueryTx result = new RespuestaStruct_SimpleQueryTx(); RequerimientoStruct_SimpleQueryTx query = new RequerimientoStruct_SimpleQueryTx(); query = GetRequestSimpleQueryTx(model); this.AuditRequestResponse(JsonConvert.SerializeObject(query)); result = client.SimpleQueryTx(query); this.AuditRequestResponse(JsonConvert.SerializeObject(result)); //Estoy actualizando por referencia los valores de los campos dentro del registro tbPaymentDetails _paymentDetail.pde_vendor_response_status = result.psp_ResponseCod; //Valido si el codigo de respuesta del simple query es OK = 2 if (Int32.Parse(result.psp_ResponseCod).Equals(2)) { if (result.psp_Transaction != null) { int responseCode = Int32.Parse(result.psp_Transaction.psp_ResponseCod); //y el codigo de la transaccion=0 "Compra online aprobada" //result.psp_Transaction.psp_ResponseCod = 0 (Pago aceptado) //result.psp_Transaction.psp_ResponseCod = 9 (Pago rechazado) //result.psp_Transaction.psp_ResponseCod = 25 (Formulario en curso) //result.psp_Transaction.psp_ResponseCod = 3 (fondos insuficientes) //result.psp_Transaction.psp_ResponseCod = 9 (form vencido) switch (responseCode) { case 0: { paymentResult.pst_id = (int)EnumPaymentStatus.PAGADO; paymentResult.pay_informacion_adicional = result.psp_Transaction.psp_ResponseMsg; break; } default: { paymentResult.pst_id = (int)EnumPaymentStatus.ERROR; paymentResult.pay_informacion_adicional = result.psp_Transaction.psp_ResponseMsg + " | " + result.psp_Transaction.psp_ResponseExtended; break; } } //Estoy actualizando por referencia los valores de los campos dentro del registro tbPaymentDetails _paymentDetail.pde_vendor_response_id = result.psp_Transaction.psp_TransactionId; } } return(paymentResult); } catch (Exception ex) { throw ex; } }