public string GetXml(HostedPayment payment) { var xmlOutput = new Utf8StringWriter(Encoding.UTF8); var order = payment.GetCreateOrderBuilder(); var rows = payment.GetRowBuilder(); var xmlSettings = new XmlWriterSettings { Encoding = Encoding.UTF8 }; using (var xmlw = XmlWriter.Create(xmlOutput, xmlSettings)) { Action <string, string> doWriteSimple = (name, value) => WriteSimpleElement(name, value, xmlw); xmlw.WriteStartDocument(); xmlw.WriteComment("Message generated by Integration package C#"); xmlw.WriteStartElement("payment"); payment.WritePaymentSpecificXml(xmlw); doWriteSimple("customerrefno", order.GetClientOrderNumber()); //This is not an error. Do not confuse with order.GetCustomerReference(). doWriteSimple("currency", order.GetCurrency()); doWriteSimple("amount", payment.GetAmount().ToString(CultureInfo.InvariantCulture)); doWriteSimple("vat", payment.GetVat().ToString(CultureInfo.InvariantCulture)); doWriteSimple("lang", payment.GetPayPageLanguageCode().ToLower()); doWriteSimple("returnurl", payment.GetReturnUrl()); doWriteSimple("cancelurl", payment.GetCancelUrl()); doWriteSimple("callbackurl", payment.GetCallbackUrl()); doWriteSimple("iscompany", order.GetIsCompanyIdentity().ToString().ToLower()); doWriteSimple("ipaddress", payment.GetIpAddress()); if (payment.GetType() == typeof(PaymentMethodPayment)) { var pm = payment as PaymentMethodPayment; if (pm.GetPaymentMethod() == PaymentMethod.SVEACARDPAY_PF) { SerializeUnknownCustomer(order, xmlw); } } else { SerializeCustomer(order, xmlw); } SerializeRows(rows, xmlw); SerializeExcludedPaymentMethods(payment.GetExcludedPaymentMethod(), xmlw); doWriteSimple("addinvoicefee", "false"); xmlw.WriteEndDocument(); } return(xmlOutput.ToString()); }
static void Main(string[] args) { //Create voguepay merchant instance Merchant merchantinfo = new Merchant(); merchantinfo.MerchantID = "6359-0000000"; merchantinfo.Username = "******"; merchantinfo.Email = "*****@*****.**"; //Create voguepay instance (Parameters "live" or "demo", default is demo) Voguepay voguepay = new Voguepay("live"); voguepay.Init(merchantinfo); //Create customer instance Customerinfo customer = new Customerinfo(); customer.Name = "Sam Great"; customer.Phone = "20339922"; customer.Email = "*****@*****.**"; customer.City = "Allen"; customer.Country = "NGA"; customer.State = "Ikeja"; customer.ZipCode = "23401"; customer.Address = "3 Drive view estate"; //Create a hosted payment transaction HostedPayment hostedPayment = new HostedPayment(); hostedPayment.Amount = 250.3333; hostedPayment.Reference = "MyRef123"; hostedPayment.Memo = "Sample payment"; hostedPayment.Currency = "NGN"; hostedPayment.StoreID = "293330002"; //optional hostedPayment.SuccessURL = "https://sample.com/success"; hostedPayment.FailureURL = "https://sample.com/fail"; hostedPayment.NotificationURL = "https://sample.com/notify"; string jsonResult = voguepay.Pay(hostedPayment, customer); Console.WriteLine(jsonResult); Console.ReadKey(); }