Esempio n. 1
0
        public bool Reverse(ReverseRequest request_, out int responseCode_)
        {
            LOG.Debug("ENTER");

            bool retVal = false;

            responseCode_ = -1;

            try
            {
                POSInterfaceServiceClient svc = new POSInterfaceServiceClient();
                svc.ChannelFactory.Endpoint.ListenUri = new Uri("http://geoitddev.geocom.com.uy:8554/v2/itdservice");

                var reverseResponse = svc.processFinancialReverse(request_);
                responseCode_ = reverseResponse.ResponseCode;
                retVal        = responseCode_ == 0;
            }
            catch (Exception ex)
            {
                LOG.Fatal(ex, "{Message}", "Exception caught.");
            }
            finally
            {
                LOG.Debug("EXIT");
            }

            return(retVal);
        }
Esempio n. 2
0
        /// <summary>
        ///     支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。
        ///     注意:7天以内的交易单可调用撤销,其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】,没有明确的支付结果再调用【撤销订单API】。
        ///     调用支付接口后请勿立即调用撤销订单API,建议支付后至少15s后再调用撤销订单接口。
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ReverseResult Reverse(ReverseRequest model)
        {
            var url = "https://api.mch.weixin.qq.com/secapi/pay/reverse";

            ReverseResult result = null;

            try
            {
                var wechatConfig = WeChatConfig;
                model.Appid     = wechatConfig.AppId;
                model.Mch_id    = PayConfig.MchId;
                model.Nonce_str = PayUtil.GetNoncestr();
                //本地或者服务器的证书位置(证书在微信支付申请成功发来的通知邮件中)
                var cert = PayConfig.PayCertPath;
                //私钥(在安装证书时设置)
                var password = PayConfig.CertPassword;

                //调用证书
                var cer = new X509Certificate2(cert, password,
                                               X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

                var dictionary = PayUtil.GetAuthors(model);
                model.Sign = PayUtil.CreateMd5Sign(dictionary, PayConfig.TenPayKey); //生成Sign
                result     = PostXML <ReverseResult>(url, model, cer);
            }
            catch (Exception ex)
            {
                WeChatHelper.LoggerAction?.Invoke(nameof(TenPayV3), ex.ToString());
            }
            return(result);
        }
Esempio n. 3
0
        private ReverseResponse Reverse(ReverseRequest request)
        {
            InitializeServiceClient();

            ReverseResponse response;

            try
            {
                var responseReverseTask = _cmtPaymentServiceClient.PostAsync(request);
                responseReverseTask.Wait();
                response = responseReverseTask.Result;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);

                var aggregateException = ex as AggregateException;
                if (aggregateException == null)
                {
                    throw ex;
                }

                var webServiceException = aggregateException.InnerException as WebServiceException;
                if (webServiceException == null)
                {
                    throw ex;
                }

                response = JsonConvert.DeserializeObject <ReverseResponse>(webServiceException.ResponseBody);
            }

            _logger.LogMessage("CMT reverse response : " + response.ResponseMessage);

            return(response);
        }
Esempio n. 4
0
        public string ReversePayment(MetaDataViewDto metaData, PaymentViewDto payment)
        {
            ReverseRequestFactory reverseRequestFactory = new ReverseRequestFactory();
            RestClientTool <ReverseRequest, ReverseResponse> restClient = new RestClientTool <ReverseRequest, ReverseResponse>();

            ReverseRequest reverseRequest = reverseRequestFactory
                                            .AddOriginalPaymentReferenceNumber(payment.PaymentReferenceNumber).AddMsisdn(metaData.Msisdn)
                                            .AddClientIPAddress(metaData.ClientIPAddress).Build();

            ReverseResponse reverseResponse = restClient.RestClientRequest(Constants.REVERSE_URL, reverseRequest);

            if (reverseResponse.ResponseHeader.ResponseCode != null && reverseResponse.ResponseHeader.ResponseCode == "0")
            {
                return(reverseResponse.ApprovalCode);
            }
            else if (reverseResponse.ResponseHeader != null)
            {
                string errorMessage = "Reverse payment was not successful: [%s], %s" + reverseResponse.ResponseHeader.ResponseCode + reverseResponse.ResponseHeader.ResponseDescription;
                throw new Exception(errorMessage);
            }
            else
            {
                string errorMessage = "Reverse payment was not successful, response status info is empty.";
                throw new Exception(errorMessage);
            }
        }
Esempio n. 5
0
 public ReverseResponse Reverse(ReverseRequest request)
 {
     return(new ReverseResponse
     {
         Text = string.Join("Welcome ", request.Text.Reverse().ToArray())
     });
 }
Esempio n. 6
0
        public async Task <ReverseResponse> Reverse(ReverseRequest data)
        {
            var response = await _client.TryExecute <BlankResponse>(HttpMethod.Post, "/v1/Reverse", data);

            switch (response.responseStatusCode)
            {
            case 200:
                return(new ReverseResponse());

            case 472:
                await _client.Execute <BlankResponse>(HttpMethod.Post, "/v1/Cancel", data);

                return(new ReverseResponse());

            case 477:
                throw new InvalidIdentityException(response.responseStatusCode);

            case 572:
            case 471:
                throw new PaymentTransactionNotFoundException(response.responseStatusCode);

            case 474:
            case 476:
                throw new InvalidTransactionStateException(response.responseStatusCode);

            case 473:
            case 475:
                throw new DuplicateReverseException(response.responseStatusCode);

            default:
                throw response.exception;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Reverse geo code.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task <ReverseReply> ReverseGeoCode(ReverseRequest request, ServerCallContext context)
        {
            var data = await _locationRepository.GetLocationInByLatitudeAndLongitudeAsync(request.Latitude,
                                                                                          request.Longitude);

            return(data == null ? null : _mapper.Map <ReverseReply>(data));
        }
Esempio n. 8
0
        public ReverseResponse Reverse(ReverseRequest request)
        {
            var response = new ReverseResponse();

            response.Success();

            return(response);
        }
Esempio n. 9
0
        // Unary call
        public override Task <ReverseReply> ReverseString(ReverseRequest request, ServerCallContext context)
        {
            var reverseReply = new ReverseReply
            {
                Reversed = new string(request.Data.Reverse().ToArray())
            };

            return(Task.FromResult(reverseReply));
        }
Esempio n. 10
0
        static void UnaryCall(ReverseService.ReverseServiceClient client)
        {
            string textToReverse = "Bangladesh";
            var    requestData   = new ReverseRequest()
            {
                Data = textToReverse
            };

            var reply = client.ReverseString(requestData);

            Console.WriteLine("Reverse of " + textToReverse + " --->>> " + reply.Reversed);
        }
        /// <summary>
        /// Для запроса отмены оплаты заказа используется запрос reverse.do. Функция отмены доступна в течение ограниченного времени
        /// после оплаты, точные сроки необходимо уточнять в Банке.
        /// Операция отмены оплаты может быть совершена только один раз. Если она закончится ошибкой, то повторная операция отмены
        /// платежа не пройдет. Данная функция доступна магазинам по согласованию с Банком. Для выполнения операции отмены пользователь должен обладать
        /// соответствующими правами.
        /// </summary>
        public ReverseResponse Reverse(ReverseParams reverseParams)
        {
            var url     = _settings.BaseUrl + "/reverse.do";
            var request = new ReverseRequest(reverseParams)
            {
                userName = _settings.Username,
                password = _settings.Password
            };

            var result = _networkClient.PostObjectViaUrlParams <ReverseResponse>(url, request);

            return(result);
        }
Esempio n. 12
0
        static async Task ServerStreamingCall(ReverseService.ReverseServiceClient client)
        {
            string textToReverse = "I Like Programming";
            var    requestData   = new ReverseRequest()
            {
                Data = textToReverse
            };

            Console.WriteLine("Main text: " + textToReverse);
            using (var call = client.ReverseStringWithCaseSupport(requestData))
            {
                var responseStream = call.ResponseStream;
                while (await responseStream.MoveNext())
                {
                    Console.WriteLine(responseStream.Current.Reversed);
                }
            }
        }
Esempio n. 13
0
        private void Void(string fleetToken, string deviceId, long transactionId, int driverId, int tripId, ref string message)
        {
            var reverseRequest = new ReverseRequest
            {
                FleetToken    = fleetToken,
                DeviceId      = deviceId,
                TransactionId = transactionId,
                DriverId      = driverId,
                TripId        = tripId
            };

            var reverseResponse = Reverse(reverseRequest);

            if (reverseResponse.ResponseCode != 1)
            {
                throw new Exception("Cannot cancel cmt transaction");
            }

            message = message + " The transaction has been cancelled.";
        }
Esempio n. 14
0
        // Server side streaming call
        public override async Task ReverseStringWithCaseSupport(ReverseRequest request, IServerStreamWriter <ReverseReply> responseStream,
                                                                ServerCallContext context)
        {
            List <ReverseReply> reverseReplies = new List <ReverseReply>
            {
                new ReverseReply {
                    Reversed = new string(request.Data.Reverse().ToArray())
                },
                new ReverseReply {
                    Reversed = new string(request.Data.ToLower().Reverse().ToArray())
                },
                new ReverseReply {
                    Reversed = new string(request.Data.ToUpper().Reverse().ToArray())
                }
            };

            foreach (var reply in reverseReplies)
            {
                Thread.Sleep(10 * 1000);
                await responseStream.WriteAsync(new ReverseReply(reply));
            }
        }
Esempio n. 15
0
        public Task <ReverseResponse> Reverse(ulong payGateTranId)
        {
            var request = new ReverseRequest(_config.MerchantConfigurationId, payGateTranId);

            return(Reverse(request));
        }