Exemplo n.º 1
0
        public async void MakeBillPayment()
        {
            var req = new BillPaymentRequest
            {
                Paycode        = "lAApm6OBmRmp3cQ",
                Reference      = "0000000001",
                Amount         = "100",
                OrderReference = "abcd"
            };

            var res = await _gladepayService.PutAsync <BillPaymentRequest>(req);


            Assert.True(res.StatusCode == HttpStatusCode.OK);
            Debug.WriteLine(res.Data);
        }
Exemplo n.º 2
0
        public async Task <BillPaymentResponse> PostBillPaymentRequest(BillPaymentRequest billPaymentRequest)
        {
            string responseString = string.Empty;
            BillPaymentResponse billPaymentResponse = new BillPaymentResponse();
            Guid fiId = Guid.Parse(fiIdString);

            switch (billPaymentRequest.BillerID.ToLower())
            {
            case "869cd85f-c155-429e-8ded-b92f41b61ec1":
                responseString = await OzoneBillPaymentProxy.PayBill(new Helpers.OzoneBillPaymentRequest()
                {
                    MobileNumber = billPaymentRequest.BillerAccountNumber,
                    Amount       = billPaymentRequest.Amount
                });

                responseString = Regex.Unescape(responseString);
                responseString = responseString.Substring(1, responseString.LastIndexOf("\"") - 1);

                byte[]       encodedString = Encoding.UTF8.GetBytes(responseString);
                MemoryStream ms            = new MemoryStream(encodedString);
                ms.Flush();
                ms.Position = 0;
                XmlDocument doc = new XmlDocument();
                doc.Load(ms);
                ms.Close();

                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
                namespaceManager.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
                namespaceManager.AddNamespace("ns1", "http://api.csr.mind.com");
                namespaceManager.AddNamespace("ns9", "http://api.csr.mind.com/addPayment");

                XmlNodeList paymentNodes = doc.SelectNodes("/soapenv:Envelope/soapenv:Body/ns1:addPaymentReturn/ns9:response/ns9:payment", namespaceManager);

                if (paymentNodes.Count > 0)
                {
                    billPaymentResponse.Successful    = true;
                    billPaymentResponse.Message       = "Payment to mobile number " + billPaymentRequest.BillerAccountNumber + " successful.";
                    billPaymentResponse.TransactionID = paymentNodes[0].Attributes["id"].Value;
                }
                else
                {
                    billPaymentResponse.Successful = false;
                    billPaymentResponse.Message    = "There was an error. Please ensure the mobile number is correct.";
                }

                var sourceAccount = db.AssociatedAccounts.Where(p => p.AssociatedAccountID == billPaymentRequest.AssociatedAccountID).First();
                db.Transfers.Add(new Transfer
                {
                    SourceInstitutionID = fiId,
                    SourceAccountID     = billPaymentRequest.AssociatedAccountID,
                    SourceAccountNumber = sourceAccount.AccountNumber,
                    SourceTransactionID = "",
                    BillerID            = Guid.Parse(fiIdString),
                    BillerAccountNumber = billPaymentRequest.BillerAccountNumber,
                    BillerTransactionID = billPaymentResponse.TransactionID,
                    TransferAmount      = (decimal)billPaymentRequest.Amount,
                    TransferDescription = "Ozone Bill Payment",
                    Status            = paymentNodes.Count > 0 ? "Successful" : "Error",
                    StatusDescription = billPaymentResponse.Message,
                    Created           = DateTime.Now
                });
                db.SaveChanges();
                break;
            }

            return(billPaymentResponse);
        }