Esempio n. 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();
        }
    }
Esempio n. 2
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();
        }
    }