Exemple #1
0
    /// <summary>
    /// Refund button clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Refund_Click(object sender, EventArgs e)
    {
        //retrieve order
        ZNode.Libraries.Admin.OrderAdmin orderAdmin = new ZNode.Libraries.Admin.OrderAdmin();
        Order order = orderAdmin.GetOrderByOrderID(OrderID);
        ZNode.Libraries.Framework.Business.ZNodeEncryption enc = new ZNode.Libraries.Framework.Business.ZNodeEncryption();

        //get payment settings
        int paymentSettingID = (int)order.PaymentSettingID;
        PaymentSettingService pss = new PaymentSettingService();
        PaymentSetting ps = pss.GetByPaymentSettingID(paymentSettingID);

        //set gateway info
        GatewayInfo gi = new GatewayInfo();
        gi.GatewayLoginID = enc.DecryptData(ps.GatewayUsername);
        gi.GatewayPassword = enc.DecryptData(ps.GatewayPassword);
        gi.TransactionKey = enc.DecryptData(ps.TransactionKey);
        gi.Vendor = ps.Vendor;
        gi.Partner = ps.Partner;
        //gi.CurrencyCode = CurrencyCode;
        gi.TestMode = ps.TestMode;
        gi.gateway = (GatewayType)ps.GatewayTypeID ;

        string creditCardExp = Convert.ToString(order.CardExp);
        if (creditCardExp == null)
        {
            creditCardExp = "";
        }

        //set credit card
        CreditCard cc = new CreditCard();
        cc.Amount = Decimal.Parse(txtAmount.Text);
        cc.CardNumber = txtCardNumber.Text.Trim();
        cc.CreditCardExp = creditCardExp;
        cc.OrderID = order.OrderID;
        cc.TransactionID = order.CardTransactionID;

        GatewayResponse resp = new GatewayResponse();

        if ((GatewayType)ps.GatewayTypeID == GatewayType.AUTHORIZE)
        {
            GatewayAuthorize auth = new GatewayAuthorize();
            resp = auth.RefundPayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.VERISIGN)
        {
            GatewayPayFlowPro pp = new GatewayPayFlowPro();
            resp = pp.RefundPayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.PAYMENTECH)
        {
            GatewayOrbital pmt = new GatewayOrbital();
            resp = pmt.ReversePayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.IPCOMMERCE)
        {
            GatewayIPCommerce ipc = new GatewayIPCommerce();
            resp = ipc.RefundPayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.NOVA)
        {
            GatewayNova nova = new GatewayNova();
            cc.CreditCardExp = lstMonth.SelectedValue + "/" + lstYear.SelectedValue;
            cc.CardSecurityCode = txtSecurityCode.Text.Trim();
            gi.TransactionType = "CCCredit";
            resp = nova.RefundPayment(gi, cc);
        }
        else
        {
            lblError.Text = "Error: Credit card refunds and not supported for your gateway.";
            return;
        }

        if (resp.IsSuccess)
        {
            //update order status
            order.OrderStateID = 30; //returned status
            order.PaymentStatusID = 3; //refund status

            OrderService os = new OrderService();
            os.Update(order);

            pnlEdit.Visible = false;
            pnlConfirm.Visible = true;
        }
        else
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Could not complete request. The following response was returned by the gateway: ");
            sb.Append(resp.ResponseText);
            lblError.Text = sb.ToString();
        }
    }
Exemple #2
0
    /// <summary>
    /// Decrypts the credit card informations
    /// Set the data to the string builder
    /// </summary>
    /// <param name="sb"></param>
    /// <param name="tag"></param>
    private void DecryptCreditCardInfo(System.Text.StringBuilder sb,string tag)
    {
        ZNode.Libraries.Framework.Business.ZNodeEncryption encryptData = new ZNode.Libraries.Framework.Business.ZNodeEncryption();

        MatchCollection mCollection = Regex.Matches(sb.ToString(), "<" + tag + ">[^>]*>(.*?)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

        //Loop through the matching collection
        foreach (Match m in mCollection)
        {
            string temp = StripXMLtag(m.Value);

            if (temp.Trim().Length > 0)
            {
                sb.Replace(m.Value, "<" + tag + ">" + encryptData.DecryptData(temp) + "</" + tag + ">");
            }
        }
    }
Exemple #3
0
    /// <summary>
    /// Refund button clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Capture_Click(object sender, EventArgs e)
    {
        //retrieve order
        ZNode.Libraries.Admin.OrderAdmin orderAdmin = new ZNode.Libraries.Admin.OrderAdmin();
        Order order = orderAdmin.GetOrderByOrderID(OrderID);
        ZNode.Libraries.Framework.Business.ZNodeEncryption enc = new ZNode.Libraries.Framework.Business.ZNodeEncryption();

        //get payment settings
        int paymentSettingID = (int)order.PaymentSettingID;
        PaymentSettingService pss = new PaymentSettingService();
        PaymentSetting ps = pss.GetByPaymentSettingID(paymentSettingID);

        //set gateway info
        GatewayInfo gi = new GatewayInfo();
        gi.GatewayLoginID = enc.DecryptData(ps.GatewayUsername);
        gi.GatewayPassword = enc.DecryptData(ps.GatewayPassword);
        gi.TransactionKey = enc.DecryptData(ps.TransactionKey);
        gi.Vendor = ps.Vendor;
        gi.Partner = ps.Partner;
        gi.TestMode = ps.TestMode;
        gi.gateway = (GatewayType)ps.GatewayTypeID ;

        string creditCardExp = Convert.ToString(order.CardExp);
        if (creditCardExp == null)
        {
            creditCardExp = "";
        }

        //set credit card
        CreditCard cc = new CreditCard();
        cc.CreditCardExp = creditCardExp;
        cc.OrderID = order.OrderID;
        cc.TransactionID = order.CardTransactionID;

        GatewayResponse resp = new GatewayResponse();

        if ((GatewayType)ps.GatewayTypeID == GatewayType.AUTHORIZE)
        {
            GatewayAuthorize auth = new GatewayAuthorize();
            resp = auth.CapturePayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.VERISIGN)
        {
            GatewayPayFlowPro pp = new GatewayPayFlowPro();
            resp = pp.CapturePayment(gi, cc);
        }
        else if ((GatewayType)ps.GatewayTypeID == GatewayType.PAYMENTECH)
        {
            GatewayOrbital pmt = new GatewayOrbital();
            resp = pmt.CapturePayment(gi, cc);
        }
        else
        {
            lblError.Text = "Error: Credit card payment capture is not supported for your gateway.";

        }

        if (resp.IsSuccess)
        {
            //update order status
            order.PaymentStatusID = 1; //refund status

            OrderService os = new OrderService();
            os.Update(order);

            pnlEdit.Visible = false;
            pnlConfirm.Visible = true;
        }
        else
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Could not complete request. The following response was returned by the gateway: ");
            sb.Append(resp.ResponseText);
            lblError.Text = sb.ToString();
        }
    }