public ProcessPaymentResult CaptureIPay(string transactionId, string amount, ProcessPaymentResult result, string creditCardType) { string CompanyKey = this._iPaySettings.CompanyKey; if (creditCardType.Equals("Amex")) { CompanyKey = this._iPaySettings.CompanyKeyAMEX; } Processor processor = new Processor("prd.txngw.com", 86, CompanyKey, 30000); processor.EncryptionMode = EncryptionModeType.TripleDES; processor.AddEncryptionKey("0502114302159200"); processor.AddEncryptionKey("0029512034112050"); processor.AddEncryptionKey("0215920005021143"); processor.SetValue("TERMINAL_ID", this._iPaySettings.TerminalId.ToString()); processor.SetValue("SERVICE_FORMAT", "1010"); processor.SetValue("CURRENCY_CODE", Convert.ToInt32(this._iPaySettings.CurrencyCode).ToString()); processor.SetValue("CURRENCY_INDICATOR", "1"); processor.SetValue("TRANSACTION_ID", transactionId); processor.SetValue("SERVICE", "CC"); processor.SetValue("SERVICE_TYPE", "DEBIT"); processor.SetValue("SERVICE_SUBTYPE", "CAPTURE"); processor.SetValue("AMOUNT", amount); processor.Build(); processor.ProcessRequest(); string xmlValue1 = this.GetXMLValue(processor.ResponseXml, "RESPONSE_TEXT"); string xmlValue2 = this.GetXMLValue(processor.ResponseXml, "MRC"); string xmlValue3 = this.GetXMLValue(processor.ResponseXml, "ARC"); if (xmlValue3 == "00" && xmlValue2 == "00") { if (xmlValue1 == "TRAN CAPTURED") { result.CaptureTransactionId = this.GetXMLValue(processor.ResponseXml, "APPROVAL_CODE"); result.CaptureTransactionResult = xmlValue1; result.NewPaymentStatus = PaymentStatus.Paid; } else { result.AddError(string.Format("Error: TRAN CAPTURED : {0}:ARC{1}:MRC{2}", (object)xmlValue1, (object)xmlValue3, (object)xmlValue2)); } } else { result.AddError(string.Format("Error: CaptureIPay : {0}:ARC{1}:MRC{2}", (object)xmlValue1, (object)xmlValue3, (object)xmlValue2)); } processor.ResetObjects(); return(result); }
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest) { CapturePaymentResult capturePaymentResult = new CapturePaymentResult(); Processor processor = new Processor("prd.txngw.com", 86, this._iPaySettings.CompanyKey, 30000); processor.EncryptionMode = EncryptionModeType.TripleDES; processor.AddEncryptionKey("0502114302159200"); processor.AddEncryptionKey("0029512034112050"); processor.AddEncryptionKey("0215920005021143"); processor.SetValue("TERMINAL_ID", this._iPaySettings.TerminalId.ToString()); processor.SetValue("SERVICE_FORMAT", "1010"); processor.SetValue("CURRENCY_CODE", Convert.ToInt32(this._iPaySettings.CurrencyCode).ToString()); processor.SetValue("CURRENCY_INDICATOR", "1"); processor.SetValue("TRANSACTION_ID", capturePaymentRequest.Order.AuthorizationTransactionId); processor.SetValue("SERVICE", "CC"); processor.SetValue("SERVICE_TYPE", "DEBIT"); processor.SetValue("SERVICE_SUBTYPE", "CAPTURE"); processor.SetValue("AMOUNT", capturePaymentRequest.Order.OrderTotal.ToString("0.00", (IFormatProvider)CultureInfo.InvariantCulture)); processor.Build(); processor.ProcessRequest(); string xmlValue1 = this.GetXMLValue(processor.ResponseXml, "RESPONSE_TEXT"); string xmlValue2 = this.GetXMLValue(processor.ResponseXml, "MRC"); string xmlValue3 = this.GetXMLValue(processor.ResponseXml, "ARC"); if (xmlValue3 == "00" && xmlValue2 == "00") { if (xmlValue1 == "TRAN CAPTURED") { capturePaymentResult.CaptureTransactionId = this.GetXMLValue(processor.ResponseXml, "APPROVAL_CODE"); capturePaymentResult.CaptureTransactionResult = xmlValue1; capturePaymentResult.NewPaymentStatus = PaymentStatus.Paid; } else { capturePaymentResult.AddError(string.Format("Error: {0}:ARC{1}:MRC{2}", xmlValue1, xmlValue3, xmlValue2)); } } else { capturePaymentResult.AddError(string.Format("Error: {0}:ARC{1}:MRC{2}", xmlValue1, xmlValue3, xmlValue2)); } processor.ResetObjects(); return(capturePaymentResult); }
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest) { ProcessPaymentResult result = new ProcessPaymentResult(); string CompanyKey = this._iPaySettings.CompanyKey; if (processPaymentRequest.CreditCardType.Equals("Amex")) { CompanyKey = this._iPaySettings.CompanyKeyAMEX; } Processor processor1 = new Processor("prd.txngw.com", 86, CompanyKey, 30000); processor1.EncryptionMode = EncryptionModeType.TripleDES; processor1.AddEncryptionKey("0502114302159200"); processor1.AddEncryptionKey("0029512034112050"); processor1.AddEncryptionKey("0215920005021143"); processor1.SetValue("TRANSACTION_INDICATOR", "7"); processor1.SetValue("SERVICE", "CC"); processor1.SetValue("SERVICE_TYPE", "DEBIT"); processor1.SetValue("SERVICE_SUBTYPE", "AUTH"); processor1.SetValue("SERVICE_FORMAT", "1010"); Customer customerById = this._customerService.GetCustomerById(processPaymentRequest.CustomerId); processor1.SetValue("ACCOUNT_NUMBER", processPaymentRequest.CreditCardNumber); processor1.SetValue("FIRST_NAME", customerById.BillingAddress.FirstName); processor1.SetValue("LAST_NAME", customerById.BillingAddress.LastName); processor1.SetValue("ADDRESS", customerById.BillingAddress.Address1); processor1.SetValue("CITY", customerById.BillingAddress.City); processor1.SetValue("POSTAL_CODE", customerById.BillingAddress.ZipPostalCode); processor1.SetValue("CURRENCY_CODE", Convert.ToInt32(this._iPaySettings.CurrencyCode).ToString()); processor1.SetValue("CURRENCY_INDICATOR", "1"); processor1.SetValue("CVV", processPaymentRequest.CreditCardCvv2); processor1.SetValue("COUNTRY", customerById.BillingAddress.Country.ThreeLetterIsoCode); Processor processor2 = processor1; string KeyName = "EXPIRATION"; int num1 = processPaymentRequest.CreditCardExpireMonth; string str1 = num1.ToString("D2"); num1 = processPaymentRequest.CreditCardExpireYear; string str2 = num1.ToString().Substring(2, 2); string KeyValue = str1 + str2; processor2.SetValue(KeyName, KeyValue); processor1.SetValue("TERMINAL_ID", this._iPaySettings.TerminalId.ToString()); Decimal num2 = Math.Round(processPaymentRequest.OrderTotal, 2); processor1.SetValue("AMOUNT", num2.ToString("0.00", (IFormatProvider)CultureInfo.InvariantCulture)); processor1.Build(); processor1.ProcessRequest(); string xmlValue1 = this.GetXMLValue(processor1.ResponseXml, "RESPONSE_TEXT"); string xmlValue2 = this.GetXMLValue(processor1.ResponseXml, "MRC"); string xmlValue3 = this.GetXMLValue(processor1.ResponseXml, "ARC"); if (xmlValue3 == "00" && xmlValue2 == "00") { if (xmlValue1 == "APPROVAL" || xmlValue1 == "Approved") { result.AuthorizationTransactionCode = this.GetXMLValue(processor1.ResponseXml, "APPROVAL_CODE"); result.AuthorizationTransactionId = this.GetXMLValue(processor1.ResponseXml, "TRANSACTION_ID"); result.AuthorizationTransactionResult = xmlValue1; result.NewPaymentStatus = PaymentStatus.Authorized; if (this.GetTransactionMode() == "CAPTURE") { processor1.ResetObjects(); // to prevent error : TRAN NOT FOUND // delay 5 seconds System.Threading.Thread.Sleep(5000); result = this.CaptureIPay(result.AuthorizationTransactionId, num2.ToString("0.00", (IFormatProvider)CultureInfo.InvariantCulture), result, processPaymentRequest.CreditCardType); } } else { result.AddError(string.Format("Error: APPROVAL : {0}:ARC{1}:MRC{2}", (object)xmlValue1, (object)xmlValue3, (object)xmlValue2)); } } else { processor1.ResetObjects(); result.AddError(string.Format("Error: ProcessPayment : {0}:ARC{1}:MRC{2}", (object)xmlValue1, (object)xmlValue3, (object)xmlValue2)); } return(result); }