public override IElectronicPayment ProcessHttpResponse(System.Web.HttpRequest postBackData, PaymentRequestTypes paymentType) { IElectronicPayment payment = new ElectronicPayment(); try { if (postBackData["RESULT"] == CC_TRANSACTION_APPROVED && postBackData["USER10"].ToUpper() != "UPDATE_DATEBASE_DELAYED_CAPTURE") { payment.TransactionStatus = PaymentStatus.Approved; } else { payment.TransactionStatus = PaymentStatus.Declined; } payment.TransactionReference = postBackData["PNREF"]; payment.UserInfo = new Cuyahoga.Modules.ECommerce.Util.WebStoreUser(); string[] name = postBackData["Name"].Split(" ".ToCharArray()); payment.UserInfo.UserDetails.FirstName = name[0]; payment.UserInfo.UserDetails.LastName = name[1]; payment.UserInfo.UserDetails.EmailAddress = postBackData["Email"]; payment.UserInfo.UserAddress.Postcode = postBackData["Zip"]; payment.UserInfo.UserAddress.AddressLine1 = postBackData["Address"]; payment.UserInfo.UserAddress.AddressLine2 = postBackData["USER4"]; payment.UserInfo.UserAddress.City = postBackData["USER5"]; payment.UserInfo.UserAddress.Region = postBackData["USER6"]; payment.UserInfo.UserDetails.TelephoneNumber = postBackData["USER7"]; payment.UserInfo.UserDetails.FaxNumber = postBackData["USER8"]; } catch (Exception e) { LogManager.GetLogger(GetType()).Error(e); } return null; }
public IElectronicPayment CreatePayment(IBasket order, ITextTranslator translator) { IElectronicPayment payment = new ElectronicPayment(); PopulatePayment(payment, order, translator); return payment; }
public override IElectronicPayment ProcessHttpResponse(HttpRequest postBackData, PaymentRequestTypes paymentType) { IElectronicPayment payment = new ElectronicPayment(); switch (paymentType) { case PaymentRequestTypes.ImmediatePayment: case PaymentRequestTypes.ReservePayment: try { Currency currency = GetPaymentCurrency(postBackData); payment.LocalRequestReference = postBackData["cartId"]; Money amount = new Money(currency, Decimal.Parse(postBackData["authAmount"])); payment.PaymentAmount = amount; SetPaymentDate(postBackData, payment); //Make sure this request came from the right address if (IsAllowedRemoteAddress(postBackData) && IsCallbackAuthenticated(postBackData)) { string status = postBackData["transStatus"]; switch (status.ToUpper()) { case STATUS_SUCCESS: payment.TransactionStatus = PaymentStatus.Approved; payment.TransactionReference = postBackData["transId"]; break; case STATUS_DECLINED: payment.TransactionStatus = PaymentStatus.Declined; break; default: payment.TransactionStatus = PaymentStatus.Other; break; } } else { payment.TransactionStatus = PaymentStatus.Fraud; } LogResponse(payment, "WorldPay Status [" + postBackData["transStatus"] + "], Raw Auth Code [" + postBackData["rawAuthCode"] + "], Raw Auth Message [" + postBackData["rawAuthMessage"] + "], " + GetResponseHttpLogInfo(postBackData)); } catch (Exception e) { Logger.Error(e); } try { //payment.UserInfo.UserName = postBackData["name"]; payment.UserInfo.UserAddress.Postcode = postBackData["postcode"]; payment.UserInfo.UserDetails.EmailAddress = postBackData["email"]; payment.UserInfo.UserAddress.AddressLine1 = postBackData["address"]; payment.UserInfo.UserAddress.CountryCode = postBackData["countryString"]; payment.UserInfo.UserDetails.TelephoneNumber = postBackData["tel"]; payment.UserInfo.UserDetails.FaxNumber = postBackData["fax"]; } catch (Exception f) { Logger.Error(f); } return payment; default: throw new InvalidOperationException("Payment request type not supported [" + paymentType + "]"); } }
public override IElectronicPayment ProcessHttpResponse(HttpRequest postBackData, PaymentRequestTypes paymentType) { IElectronicPayment payment = new ElectronicPayment(); if (DefaultCurrency == null) { DefaultCurrency = new Currency(DEFAULT_CULTURE); } try { payment.TransactionReference = postBackData["oid"]; Money amount = new Money(DefaultCurrency, Decimal.Parse(postBackData["total"])); payment.PaymentAmount = amount; payment.PaymentDate = DateTime.Parse(postBackData["datetime"]); //EPDQ don't seem to have a reference. They will create a new one //if you don't supply a local reference payment.LocalRequestReference = payment.TransactionReference; //Make sure this request came from the right address if (IsAllowedRemoteAddress(postBackData)) { string status = postBackData["transactionstatus"]; switch (status.ToLower()) { case STATUS_SUCCESS: payment.TransactionStatus = PaymentStatus.Approved; break; case STATUS_DECLINED: payment.TransactionStatus = PaymentStatus.Declined; break; case STATUS_FRAUD: payment.TransactionStatus = PaymentStatus.Fraud; break; default: payment.TransactionStatus = PaymentStatus.Other; break; } } else { payment.TransactionStatus = PaymentStatus.Fraud; } LogResponse(payment, "ePDQ Status [" + postBackData["transactionstatus"] + "], " + GetResponseHttpLogInfo(postBackData)); } catch (Exception e) { Logger.Error(e); } return payment; }
public override IElectronicPayment ProcessHttpResponse(HttpRequest postBackData, PaymentRequestTypes paymentType) { /* https://www.mymerchant.com/Success.jsp ?orderKey=MYADMINCODE^MYMERCHANT^T0211010 &paymentStatus=AUTHORISED &paymentAmount=1400 &paymentCurrency=GBP &mac=25eefe952a6bbd09fe1c2c09bca4fa09 */ if (!IsCallbackAuthenticated(postBackData)) { throw new InvalidOperationException("Invalid details supplied - MAC check failed"); } IElectronicPayment payment = new ElectronicPayment(); payment.PaymentDate = DateTime.Now; payment.TransactionStatus = (postBackData[REQUEST_FIELD_PAYMENT_STATUS] == "AUTHORISED") ? PaymentStatus.Approved : PaymentStatus.Declined; string orderKey = postBackData[REQUEST_FIELD_ORDER_KEY]; string[] orderInfo = new string[] {}; if (orderKey != null && orderKey.Length > 0) { orderInfo = orderKey.Split(ORDER_KEY_DELIMITER.ToCharArray()); } if (orderInfo.Length == ORDER_KEY_LENGTH) { string mac = postBackData[REQUEST_FIELD_MAC]; string orderRef = orderInfo[2]; //Maybe check other parameters as well /* * Not documented, but it appears that when you use a mac secret, the order reference becomes the * original local reference number, NOT the transaction reference */ if (mac != null && mac.Length > 0) { payment.LocalRequestReference = orderRef; } else { payment.TransactionReference = orderRef; } payment.PaymentAmount = GetPaymentAmount(postBackData); } else { //Something wrong with the values payment.TransactionStatus = PaymentStatus.Other; } //Record the details LogResponse(payment); return payment; }