예제 #1
0
        public Batch_Sale_Release_Result Sale_Release(Batch_Sale_Release_Details details)
        {
            #region Error Condition Checking
            if (BankAccountEnabled && CreditCardEnabled)
            {
                throw new Exception("Mixed batching not allowed by gateway");
            }

            if (!BankAccountEnabled && !CreditCardEnabled)
            {
                throw new Exception("Gateway not set up for any service");
            }

            if (String.IsNullOrEmpty(details.TransactionIdentifier))
            {
                throw new Exception("Batch has to be submitted before release");
            }
            #endregion

            string result = "";

            XElement dorelease = new XElement("dorelease");
            dorelease.Add(new XElement("merchantno", MerchantNumber));
            dorelease.Add(new XElement("referenceno", details.TransactionIdentifier));

            if (BankAccountEnabled)
            {
                var client = getDebitOrderClient();
                result = client.releaseDebitFile(dorelease.ToString());
            }
            else if (CreditCardEnabled)
            {
                var client = getCollectionsClient();
                result = client.releaseDebitFile(dorelease.ToString());
            }

            XmlDocument rdoc = new XmlDocument();
            rdoc.LoadXml(result);

            XmlNodeList doReleaseNodes = rdoc.GetElementsByTagName("dorelease_result");

            if (doReleaseNodes.Count == 0)
            {
                throw new Exception("Invalid response from gateway");
            }

            var releaseResNode  = doReleaseNodes[0].SelectNodes("result").Item(0);
            var releaseDescNode = doReleaseNodes[0].SelectNodes("description").Item(0);

            bool approved = releaseResNode.InnerText == "1";

            return(new Batch_Sale_Release_Result {
                isReleaseSuccess = approved, RequestXml = dorelease.ToString(), ResponseXml = result, ErrorCode = releaseResNode.InnerText, ErrorMessage = releaseDescNode.InnerText
            });
        }
예제 #2
0
 public Batch_Sale_Release_Result Sale_Release(Batch_Sale_Release_Details details)
 {
     throw new NotImplementedException();
 }