public async Task <bool> ProcessPayment(string url)
        {
            if ((url.IndexOf(_forwardUrl, StringComparison.CurrentCulture) != -1) || (url.IndexOf(_forwardVerifyUrl, StringComparison.CurrentCulture) != -1))
            {
                string query = url;
                Dictionary <string, string> dict = Parameters.dictionaryWithQueryString(query.Substring(query.IndexOf('?') + 1));
                int      errorCode = Parameters.ConvertToInt(Parameters.stringFromParsedDictionary(dict, "error"));
                B2PError error     = (errorCode != 0) ? new B2PError(errorCode, "") : null;

                IB2PResponse response = _purchaseRequest.ResponseForRequest();
                response.fillFromDictionary(dict);

                if (error != null && error.Code == 127)
                {
                    return(false);
                }

                var operationResponse = (B2POperationResponse)response;
                var operationId       = operationResponse.ID;
                var orderId           = operationResponse.order_id;

                if (operationResponse.state == "APPROVED")
                {
                    return(true);
                }
                else
                {
                    return(await Operation(operationId, orderId));
                }
            }

            return(false);
        }
        private async void PostRequest(IB2PRequest request, Action <IB2PResponse, B2PError> completion)
        {
            B2PError     error          = null;
            IB2PResponse response       = null;
            string       responseString = "";

            var data = request.RequestData(_sector, _password, _forwardUrl);

            string url = this.UrlForRequest() + request.Path();

            try
            {
                responseString = await Parameters.POST(url, data);
            }
            catch (Exception ex)
            {
                error = new B2PError(-1, ex.Message);
            }

            if (error == null)
            {
                if (responseString == "ok")
                {
                    B2POperationResponse changeRecResponse = (B2POperationResponse)request.ResponseForRequest();
                    changeRecResponse.message = responseString;
                    response = changeRecResponse;
                }
                else
                {
                    string rootName = "";
                    try
                    {
                        rootName = Parameters.getRootName(responseString);
                    }
                    catch (Exception e)
                    {
                        error = new B2PError(-1, e.Message);
                    }

                    if (error == null)
                    {
                        Dictionary <string, string> responseDictionary = Parameters.dictionaryForXMLString(responseString);
                        if (rootName == "error")
                        {
                            int code = Parameters.ConvertToInt(Parameters.stringFromParsedDictionary(responseDictionary, "code"));
                            error = new B2PError(code, Parameters.stringFromParsedDictionary(responseDictionary, "description"));
                        }

                        if (error == null)
                        {
                            bool isSignatureOK = true;

                            if (Parameters.stringFromParsedDictionary(responseDictionary, "signature") != "")
                            {
                                string signature = Parameters.stringFromParsedDictionary(responseDictionary, "signature");
                                isSignatureOK = Parameters.checkSignature(signature, responseString, _password);
                            }
                            if (isSignatureOK)
                            {
                                response = request.ResponseForRequest();
                                response.fillFromDictionary(responseDictionary);

                                if (response.GetType() == typeof(B2POrderResponse))
                                {
                                    B2POrderResponse orderResponse    = (B2POrderResponse)response;
                                    List <string>    operationsString = Parameters.cutOperationsInArrayFromResponseString(responseString);
                                    foreach (string operationString in operationsString)
                                    {
                                        Dictionary <string, string> operationDictionary = Parameters.dictionaryForXMLString(operationString);
                                        B2POperationResponse        operationResponse   = new B2POperationResponse();
                                        operationResponse.fillFromDictionary(operationDictionary);
                                        orderResponse.operations.Add(operationResponse);
                                    }
                                }
                            }
                            else
                            {
                                error = new B2PError(109, "Invalid signature");
                            }
                        }
                    }
                }
            }

            completion(response, error);
        }