Ejemplo n.º 1
0
 ///<summary>For terminal services.</summary>
 public PayConnectResponse(PosResponse response)
 {
     if (response != null)
     {
         AuthCode    = response.AuthCode;
         RefNumber   = response.ReferenceNumber.ToString();
         Description = response.ResponseDescription;
         StatusCode  = response.ResponseCode;
         CardType    = response.CardBrand;
     }
 }
Ejemplo n.º 2
0
        ///<summary>Turns a PosResponse into an OpenDentBusiness.PayConnectResponse.</summary>
        public static PayConnectResponse ToPayConnectResponse(PosResponse response)
        {
            PayConnectResponse pcResponse = new PayConnectResponse();

            if (response != null)
            {
                pcResponse.AuthCode    = response.AuthCode;
                pcResponse.RefNumber   = response.ReferenceNumber.ToString();
                pcResponse.Description = response.ResponseDescription;
                pcResponse.StatusCode  = response.ResponseCode;
                pcResponse.CardType    = response.CardBrand;
            }
            return(pcResponse);
        }
Ejemplo n.º 3
0
        internal override PosResponse ReFund(PosRequest posRequest)
        {
            var response = new PosResponse();

            var gvpRequest = CreateSalesInstance(posRequest, refundable: true, type: "refund");

            response.RequestTextData  = this.SerializeObjectToXmlString <GVPSRequest>(gvpRequest);
            response.ResponseTextData = SendHttpRequest(_hostUrl, "Post", response.RequestTextData);

            var responseObject = this.DeSerializeObject <GVPSResponse>(response.ResponseTextData);

            response.OrderId    = responseObject.Order.OrderID;
            response.StatusCode = responseObject.Transaction.Response.Code;
            response.Status     = responseObject.Transaction.Response.Message.Equals("Approved") ? true : false;
            response.ErrorMsg   = responseObject.Transaction.Response.ErrorMsg;

            return(response);
        }
Ejemplo n.º 4
0
        internal override PosResponse Sales(PosRequest posRequest)
        {
            var response = new PosResponse();

            var gvpRequest = CreateSalesInstance(posRequest);

            response.RequestTextData = this.SerializeObjectToXmlString<GVPSRequest>(gvpRequest);
            response.ResponseTextData = SendHttpRequest(_hostUrl, "Post", response.RequestTextData);

            var responseObject = this.DeSerializeObject<GVPSResponse>(response.ResponseTextData);

            response.OrderId = responseObject.Order.OrderID;
            response.StatusCode = responseObject.Transaction.Response.Code;
            response.Status = responseObject.Transaction.Response.Message.Equals("Approved") ? true : false;
            response.ErrorMsg = responseObject.Transaction.Response.ErrorMsg;

            return response;
        }
Ejemplo n.º 5
0
        ///<summary>Processes a PayConnect payment via a credit card terminal.</summary>
        private bool ProcessPaymentTerminal()
        {
            PosRequest posRequest = null;

            try {
                if (radioSale.Checked)
                {
                    posRequest = PosRequest.CreateSale(PIn.Decimal(textAmount.Text));
                }
                else if (radioAuthorization.Checked)
                {
                    posRequest = PosRequest.CreateAuth(PIn.Decimal(textAmount.Text));
                }
                else if (radioVoid.Checked)
                {
                    posRequest = PosRequest.CreateVoidByReference(textRefNumber.Text);
                }
                else if (radioReturn.Checked)
                {
                    if (textRefNumber.Text == "")
                    {
                        posRequest = PosRequest.CreateRefund(PIn.Decimal(textAmount.Text));
                    }
                    else
                    {
                        posRequest = PosRequest.CreateRefund(PIn.Decimal(textAmount.Text), textRefNumber.Text);
                    }
                }
                else                  //Shouldn't happen
                {
                    MsgBox.Show(this, "Please select a transaction type");
                    return(false);
                }
                posRequest.ForceDuplicate = checkForceDuplicate.Checked;
            }
            catch (Exception ex) {
                MessageBox.Show(Lan.g(this, "Error creating request:") + " " + ex.Message);
                return(false);
            }
            bool result = true;

            ODProgress.ShowAction(() => {
                _posResponse = DpsPos.ProcessCreditCard(posRequest);
            },
                                  startingMessage: Lan.g(this, "Processing payment on terminal"),
                                  actionException: ex => {
                this.Invoke(() => {
                    MessageBox.Show(Lan.g(this, "Error processing card:") + " " + ex.Message);
                    result = false;
                });
            });
            if (!result)
            {
                return(false);
            }
            if (_posResponse == null)
            {
                MessageBox.Show(Lan.g(this, "Error processing card"));
                return(false);
            }
            if (_posResponse.ResponseCode != "0")           //"0" indicates success. May need to check the AuthCode field too to determine if this was a success.
            {
                MessageBox.Show(Lan.g(this, "Error message from Pay Connect:") + "\r\n" + _posResponse.ResponseDescription);
                return(false);
            }
            PayConnectService.signatureResponse sigResponse = null;
            try {
                Cursor      = Cursors.WaitCursor;
                sigResponse = SendSignature(_posResponse.ReferenceNumber.ToString());
                Cursor      = Cursors.Default;
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(Lan.g(this, "Card successfully charged. Error processing signature:") + " " + ex.Message);
            }
            textCardNumber.Text = _posResponse.CardNumber;
            textAmount.Text     = _posResponse.Amount.ToString("f");
            _receiptStr         = PayConnectTerminal.BuildReceiptString(posRequest, _posResponse, sigResponse, _clinicNum);
            PrintReceipt(_receiptStr);
            return(true);
        }
Ejemplo n.º 6
0
        ///<summary>Builds a receipt string for a terminal transaction.</summary>
        public static string BuildReceiptString(PosRequest posRequest, PosResponse posResponse, PayConnectService.signatureResponse sigResponse,
                                                long clinicNum)
        {
            string result = "";
            int    xleft  = 0;
            int    xright = 15;
            int    xmax   = 37;

            result += Environment.NewLine;
            result += CreditCardUtils.AddClinicToReceipt(clinicNum);
            //Print body
            result += "Date".PadRight(xright - xleft, '.') + DateTime.Now.ToString() + Environment.NewLine;
            result += Environment.NewLine;
            result += AddReceiptField("Trans Type", posResponse.TransactionType.ToString());
            result += Environment.NewLine;
            result += AddReceiptField("Transaction #", posResponse.ReferenceNumber.ToString());
            result += AddReceiptField("Account", posResponse.CardNumber);
            result += AddReceiptField("Card Type", posResponse.CardBrand);
            result += AddReceiptField("Entry", posResponse.EntryMode);
            result += AddReceiptField("Auth Code", posResponse.AuthCode);
            result += AddReceiptField("Result", posResponse.ResponseDescription);
            result += AddReceiptField("MerchantId", posResponse.MerchantId);
            result += AddReceiptField("TerminalId", posResponse.TerminalId);
            result += AddReceiptField("Mode", posResponse.Mode);
            result += AddReceiptField("CardVerifyMthd", posResponse.CardVerificationMethod);
            if (posResponse.EMV != null && !string.IsNullOrEmpty(posResponse.EMV.AppId))
            {
                result += AddReceiptField("EMV AppId", posResponse.EMV.AppId);
            }
            if (posResponse.EMV != null && !string.IsNullOrEmpty(posResponse.EMV.TermVerifResults))
            {
                result += AddReceiptField("EMV TermResult", posResponse.EMV.TermVerifResults);
            }
            if (posResponse.EMV != null && !string.IsNullOrEmpty(posResponse.EMV.IssuerAppData))
            {
                result += AddReceiptField("EMV IssuerData", posResponse.EMV.IssuerAppData);
            }
            if (posResponse.EMV != null && !string.IsNullOrEmpty(posResponse.EMV.TransStatusInfo))
            {
                result += AddReceiptField("EMV TransInfo", posResponse.EMV.TransStatusInfo);
            }
            if (posResponse.EMV != null && !string.IsNullOrEmpty(posResponse.EMV.AuthResponseCode))
            {
                result += AddReceiptField("EMV AuthResp", posResponse.EMV.AuthResponseCode);
            }
            result += Environment.NewLine + Environment.NewLine + Environment.NewLine;
            if (posResponse.TransactionType.In(TransactionType.Refund, TransactionType.Void))
            {
                result += "Total Amt".PadRight(xright - xleft, '.') + (posResponse.Amount * -1) + Environment.NewLine;
            }
            else
            {
                result += "Total Amt".PadRight(xright - xleft, '.') + posResponse.Amount + Environment.NewLine;
            }
            result += Environment.NewLine + Environment.NewLine + Environment.NewLine;
            result += "I agree to pay the above total amount according to my card issuer/bank agreement." + Environment.NewLine;
            result += Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine;
            if (sigResponse == null || sigResponse.Status == null || sigResponse.Status.code != 0)
            {
                result += "Signature X".PadRight(xmax - xleft, '_');
            }
            else
            {
                result += "Electronically signed";
            }
            return(result);
        }