internal static PosResponse DoTransaction(IHpsServicesConfig config, PosRequestVer10Transaction transaction, long?clientTransactionId = null) { var req = new PosRequest { Ver10 = new PosRequestVer10 { Header = new PosRequestVer10Header { SecretAPIKey = config.SecretApiKey, LicenseId = config.LicenseId, SiteId = config.SiteId, DeviceId = config.DeviceId, VersionNbr = config.VersionNumber, UserName = config.UserName, Password = config.Password, DeveloperID = config.DeveloperId, SiteTrace = config.SiteTrace }, Transaction = transaction } }; if (clientTransactionId.HasValue) { req.Ver10.Header.ClientTxnId = clientTransactionId.Value; req.Ver10.Header.ClientTxnIdSpecified = true; } using (var client = new PosGatewayService { Url = HpsConfiguration.SoapServiceUri }) { return(client.DoTransaction(req)); } }
/// <summary> /// /// </summary> /// <param name="posRequest"></param> /// <param name="refundable">for void & refund</param> /// <param name="type">sales, void, refund</param> /// <returns></returns> private GVPSRequest CreateSalesInstance(PosRequest posRequest, bool refundable = false, string type = "sales") { string SecurityData = GetSHA1(_password + String.Format("000{0}", _terminalId)) .ToUpper(); //_terminalId'nin 9 haneye tamamlanması gerekiyor. string _HashData = !refundable? GetSHA1(posRequest.OrderId + _terminalId + posRequest.CardNumber + posRequest.Amount + SecurityData).ToUpper() : GetSHA1(posRequest.OrderId + _terminalId + posRequest.Amount + SecurityData).ToUpper(); var gvpRequest = new GVPSRequest(); gvpRequest.Mode = _workingMode; gvpRequest.Version = GVPVERSION; gvpRequest.Terminal = new Terminal() { ID = _terminalId, UserID = posRequest.UserId, MerchantID = _merchantId, ProvUserID = !refundable ? _provisionUser : "******", HashData = _HashData }; gvpRequest.Customer = new Customer() { EmailAddress = posRequest.UserEmail, IPAddress = posRequest.UserIp }; gvpRequest.Card = !refundable ? new Card() { Number = posRequest.CardNumber, CVV2 = posRequest.Cvc2, ExpireDate = String.Format("{0}{1}", posRequest.Month, posRequest.Year) //MMYY } : new Card(); gvpRequest.Order = new Order() { OrderID = posRequest.OrderId, GroupID = string.Empty }; gvpRequest.Transaction = new Transaction() { Type = "sales", CurrencyCode = posRequest.CurrencyCode, MotoInd = !refundable ? "N" : "H", InstallmentCnt = posRequest.InstallmentCount == 0 ? String.Empty : posRequest.InstallmentCount.ToString(), // 10,05 -> 1005 Amount = posRequest.Amount, CardholderPresentCode = "0" }; return(gvpRequest); }
internal override PosResponse Void(PosRequest posRequest) { var response = new PosResponse(); var gvpRequest = CreateSalesInstance(posRequest,refundable:true, type:"void"); 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; }
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); }
static void Main(string[] args) { VPosContext context = new VPosContext(new GarantiVPos("123123", "PAUHT", "P@ssW0rd", "008871", "htttp://garantisanalpos.com")); var request = new PosRequest(); request.Amount = "1000"; request.CardNumber = "2039023902909309"; request.CardOnName = "Oğuzhan YILMAZ"; request.CurrencyCode = "989"; request.Cvc2 = "000"; request.InstallmentCount = 3; request.Month = "12"; request.Year = "14"; request.UserIp = "192.168.2.1"; request.UserEmail = "*****@*****.**"; request.UserId = Guid.NewGuid().ToString("N"); Console.Read(); }
internal PosResponse DoTransaction(PosRequestVer10Transaction transaction, long?clientTransactionId = null) { // Check for a valid config. if (IsConfigInvalid()) { throw new HpsAuthenticationException(HpsExceptionCodes.InvalidConfiguration, Resource.Exception_Message_InvalidConfig); } var req = new PosRequest { Ver10 = new PosRequestVer10 { Header = new PosRequestVer10Header { SecretAPIKey = ServicesConfig.SecretApiKey, LicenseId = ServicesConfig.LicenseId, SiteId = ServicesConfig.SiteId, DeviceId = ServicesConfig.DeviceId, VersionNbr = ServicesConfig.VersionNumber, UserName = ServicesConfig.UserName, Password = ServicesConfig.Password, DeveloperID = ServicesConfig.DeveloperId, SiteTrace = ServicesConfig.SiteTrace }, Transaction = transaction } }; if (clientTransactionId.HasValue) { req.Ver10.Header.ClientTxnId = clientTransactionId.Value; req.Ver10.Header.ClientTxnIdSpecified = true; } using (var client = new PosGatewayService { Url = ServicesConfig.ServiceUrl }) { return(client.DoTransaction(req)); } }
///<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); }
/// <summary> /// /// </summary> /// <param name="posRequest"></param> /// <param name="refundable">for void & refund</param> /// <param name="type">sales, void, refund</param> /// <returns></returns> private GVPSRequest CreateSalesInstance(PosRequest posRequest, bool refundable = false, string type = "sales") { string SecurityData = GetSHA1(_password + String.Format("000{0}", _terminalId)) .ToUpper(); //_terminalId'nin 9 haneye tamamlanması gerekiyor. string _HashData = !refundable ? GetSHA1(posRequest.OrderId + _terminalId + posRequest.CardNumber + posRequest.Amount + SecurityData).ToUpper() : GetSHA1(posRequest.OrderId + _terminalId + posRequest.Amount + SecurityData).ToUpper(); var gvpRequest = new GVPSRequest(); gvpRequest.Mode = _workingMode; gvpRequest.Version = GVPVERSION; gvpRequest.Terminal = new Terminal() { ID = _terminalId, UserID = posRequest.UserId, MerchantID = _merchantId, ProvUserID = !refundable ? _provisionUser : "******", HashData = _HashData }; gvpRequest.Customer = new Customer() { EmailAddress = posRequest.UserEmail, IPAddress = posRequest.UserIp }; gvpRequest.Card = !refundable ? new Card() { Number = posRequest.CardNumber, CVV2 = posRequest.Cvc2, ExpireDate = String.Format("{0}{1}", posRequest.Month, posRequest.Year) //MMYY } : new Card(); gvpRequest.Order = new Order() { OrderID = posRequest.OrderId, GroupID = string.Empty }; gvpRequest.Transaction = new Transaction() { Type = "sales", CurrencyCode = posRequest.CurrencyCode, MotoInd = !refundable ? "N" : "H", InstallmentCnt = posRequest.InstallmentCount == 0 ? String.Empty : posRequest.InstallmentCount.ToString(), // 10,05 -> 1005 Amount = posRequest.Amount, CardholderPresentCode = "0" }; return gvpRequest; }
///<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); }
public PosResponse Void(PosRequest posRequest) { return _vpos.Void(posRequest); }
public PosResponse Sales(PosRequest posRequest) { return _vpos.Sales(posRequest); }
public PosResponse Void(PosRequest posRequest) { return(_vpos.Void(posRequest)); }
internal override PosResponse ReFund(PosRequest posRequest) { throw new NotImplementedException(); }
internal override PosResponse Void(PosRequest posRequest) { throw new NotImplementedException(); }
public PosResponse ReFund(PosRequest posRequest) { return(_vpos.ReFund(posRequest)); }
public PosResponse ReFund(PosRequest posRequest) { return _vpos.ReFund(posRequest); }
public PosResponse Sales(PosRequest posRequest) { return(_vpos.Sales(posRequest)); }