Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public RequestOutput GenerateRequest(RequestInput input)
        {
            RequestOutput result = new RequestOutput(SubmitXml(GenerateRequestXml(input)));

            return(result);
        }
Example #2
0
        public override string RedirectForPayment(OrderData orderData)
        {
            orderData.OrderStatus = "020";
            orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "");
            orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture();
            orderData.SavePurchaseData();
            try
            {
                var settings = ProviderUtils.GetProviderSettings("NBrightPxPaypayment");

                string PxPayUserId = settings.GetXmlProperty("genxml/textbox/pxpayuserid");
                string PxPayKey    = settings.GetXmlProperty("genxml/textbox/pxpaykey");

                PxPay WS = new PxPay(PxPayUserId, PxPayKey);

                RequestInput input = new RequestInput();

                var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal");
                var alreadypaid  = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid");

                var orderTotal = (appliedtotal - alreadypaid).ToString("0.00");

                var param = new string[3];
                param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString("");
                param[1] = "status=1";
                var returnUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param);
                param[1] = "status=0";
                var returnCancelUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param);

                input.AmountInput       = orderTotal;
                input.CurrencyInput     = settings.GetXmlProperty("genxml/textbox/currencycode");
                input.MerchantReference = settings.GetXmlProperty("genxml/textbox/merchantref");
                input.TxnType           = "Purchase";
                input.UrlFail           = returnUrl;
                input.UrlSuccess        = returnCancelUrl;

                input.TxnId = Guid.NewGuid().ToString().Substring(0, 16);
                orderData.PurchaseInfo.SetXmlProperty("genxml/txnid", input.TxnId);
                orderData.Save();

                RequestOutput output = WS.GenerateRequest(input);

                if (output.valid == "1" && output.URI != null)
                {
                    // Redirect user to payment page
                    return(output.Url);
                }
                else
                {
                    // rollback transaction
                    orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>PAYMENT RETURN ERROR: </div><div>" + output + "</div>");
                    orderData.PaymentFail();
                    return(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param));
                }
            }
            catch (Exception ex)
            {
                // rollback transaction
                orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>PAYMENT EXCEPTION: </div><div>" + ex + "</div>");
                orderData.PaymentFail();

                var param = new string[3];
                param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString("");
                param[1] = "status=0";
                return(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param));
            }
        }