Пример #1
0
        internal static PaymentServicePlatformPortTypeClient GetService(string siteUrl)
        {
            var basicHttpSecurityMode = BasicHttpSecurityMode.None;

            if (siteUrl.StartsWith("https"))
            {
                basicHttpSecurityMode = BasicHttpSecurityMode.Transport;
            }

            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;

            Uri serviceUri = new Uri(siteUrl);

            AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("SOAPAction", "https://implementacion.nps.com.ar/ws.php/Authorize_3p", 1);

            AddressHeader[] addressHeaders1 = new AddressHeader[1] {
                addressHeader1
            };

            EndpointAddress endpointAddress = new EndpointAddress(serviceUri, addressHeaders1);

            //Create the binding here
            Binding binding = new CustomBinding(BindingFactory.CreateInstance(basicHttpSecurityMode));

            PaymentServicePlatformPortTypeClient client = new PaymentServicePlatformPortTypeClient(binding, endpointAddress);

            client.Endpoint.Behaviors.Add(new FaultFormatingBehavior());

            return(client);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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;
            }
        }