protected ProcessResponse Process([NotNull] PaymentSystem paymentSystem, [NotNull] ReservationTicket reservationTicket, decimal amount, [NotNull] string operation) { Assert.ArgumentNotNull(paymentSystem, "paymentSystem"); Assert.ArgumentNotNull(reservationTicket, "reservationTicket"); Assert.ArgumentNotNull(operation, "operation"); string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string transactionId = reservationTicket.TransactionNumber; string transactionAmount = amount.ToCents(); Netaxept client = new Netaxept(); ProcessRequest processRequest = new ProcessRequest { Operation = operation, TransactionId = transactionId, TransactionAmount = transactionAmount }; return(client.Process(merchantId, token, processRequest)); }
protected ProcessResponse Process([NotNull] PaymentSystem paymentSystem, [NotNull] ReservationTicket reservationTicket, decimal amount, [NotNull] string operation) { Assert.ArgumentNotNull(paymentSystem, "paymentSystem"); Assert.ArgumentNotNull(reservationTicket, "reservationTicket"); Assert.ArgumentNotNull(operation, "operation"); string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string transactionId = reservationTicket.TransactionNumber; string transactionAmount = amount.ToCents(); Netaxept client = new Netaxept(); ProcessRequest processRequest = new ProcessRequest { Operation = operation, TransactionId = transactionId, TransactionAmount = transactionAmount }; return client.Process(merchantId, token, processRequest); }
/// <summary> /// Processes the callback in terms of the HttpRequest and extracts either hidden form fields, or querystring parameters /// that is returned from the payment provider. /// Determines the payment status and saves that indication for later, could be in session, in db, or other storage. /// This information is important and used in the GetPaymentStatus(). /// </summary> /// <param name="paymentSystem">The payment system.</param> /// <param name="paymentArgs">The payment args.</param> public override void ProcessCallback([NotNull] PaymentSystem paymentSystem, [NotNull] PaymentArgs paymentArgs) { Assert.ArgumentNotNull(paymentSystem, "paymentSystem"); Assert.ArgumentNotNull(paymentArgs, "paymentArgs"); Assert.IsNotNull(paymentArgs.ShoppingCart, "Shopping cart is null"); this.PaymentStatus = PaymentStatus.Failure; HttpRequest request = HttpContext.Current.Request; PaymentSettingsReader configuration = new PaymentSettingsReader(paymentSystem); ITransactionData transactionDataProvider = Context.Entity.Resolve <ITransactionData>(); string operation = configuration.GetSetting("operation"); string transactionId = request.QueryString["transactionId"]; string responseCode = request.QueryString["responseCode"]; if (string.Compare(responseCode, "OK", StringComparison.OrdinalIgnoreCase) == 0) { string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string orderNumber = paymentArgs.ShoppingCart.OrderNumber; decimal amount = paymentArgs.ShoppingCart.Totals.TotalPriceIncVat; string currency = this.Currency(paymentArgs.ShoppingCart.Currency.Code); Netaxept client = new Netaxept(); ProcessRequest processRequest = new ProcessRequest { Operation = operation, TransactionId = transactionId }; try { ProcessResponse processResponse = client.Process(merchantId, token, processRequest); if (string.Compare(processResponse.ResponseCode, "OK", StringComparison.OrdinalIgnoreCase) == 0) { this.PaymentStatus = PaymentStatus.Succeeded; transactionDataProvider.SaveCallBackValues(paymentArgs.ShoppingCart.OrderNumber, this.PaymentStatus.ToString(), transactionId, amount.ToString(), currency, string.Empty, string.Empty, string.Empty, string.Empty); if (string.Compare(operation, this.ReservableTransactionType, StringComparison.OrdinalIgnoreCase) == 0) { ReservationTicket reservationTicket = new ReservationTicket { Amount = amount, AuthorizationCode = processResponse.AuthorizationId, InvoiceNumber = orderNumber, TransactionNumber = transactionId }; transactionDataProvider.SavePersistentValue(reservationTicket.InvoiceNumber, PaymentConstants.ReservationTicket, reservationTicket); } } } catch (Exception exception) { Log.Error(exception.Message, exception, this); } } else if (string.Compare(responseCode, "CANCEL", StringComparison.OrdinalIgnoreCase) == 0) { this.PaymentStatus = PaymentStatus.Canceled; } if (this.PaymentStatus != PaymentStatus.Succeeded) { transactionDataProvider.SavePersistentValue(paymentArgs.ShoppingCart.OrderNumber, TransactionConstants.PaymentStatus, this.PaymentStatus.ToString()); } }
/// <summary> /// Processes the callback in terms of the HttpRequest and extracts either hidden form fields, or querystring parameters /// that is returned from the payment provider. /// Determines the payment status and saves that indication for later, could be in session, in db, or other storage. /// This information is important and used in the GetPaymentStatus(). /// </summary> /// <param name="paymentSystem">The payment system.</param> /// <param name="paymentArgs">The payment args.</param> public override void ProcessCallback([NotNull] PaymentSystem paymentSystem, [NotNull] PaymentArgs paymentArgs) { Assert.ArgumentNotNull(paymentSystem, "paymentSystem"); Assert.ArgumentNotNull(paymentArgs, "paymentArgs"); Assert.IsNotNull(paymentArgs.ShoppingCart, "Shopping cart is null"); this.PaymentStatus = PaymentStatus.Failure; HttpRequest request = HttpContext.Current.Request; PaymentSettingsReader configuration = new PaymentSettingsReader(paymentSystem); ITransactionData transactionDataProvider = Context.Entity.Resolve<ITransactionData>(); string operation = configuration.GetSetting("operation"); string transactionId = request.QueryString["transactionId"]; string responseCode = request.QueryString["responseCode"]; if (string.Compare(responseCode, "OK", StringComparison.OrdinalIgnoreCase) == 0) { string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string orderNumber = paymentArgs.ShoppingCart.OrderNumber; decimal amount = paymentArgs.ShoppingCart.Totals.TotalPriceIncVat; string currency = this.Currency(paymentArgs.ShoppingCart.Currency.Code); Netaxept client = new Netaxept(); ProcessRequest processRequest = new ProcessRequest { Operation = operation, TransactionId = transactionId }; try { ProcessResponse processResponse = client.Process(merchantId, token, processRequest); if (string.Compare(processResponse.ResponseCode, "OK", StringComparison.OrdinalIgnoreCase) == 0) { this.PaymentStatus = PaymentStatus.Succeeded; transactionDataProvider.SaveCallBackValues(paymentArgs.ShoppingCart.OrderNumber, this.PaymentStatus.ToString(), transactionId, amount.ToString(), currency, string.Empty, string.Empty, string.Empty, string.Empty); if (string.Compare(operation, this.ReservableTransactionType, StringComparison.OrdinalIgnoreCase) == 0) { ReservationTicket reservationTicket = new ReservationTicket { Amount = amount, AuthorizationCode = processResponse.AuthorizationId, InvoiceNumber = orderNumber, TransactionNumber = transactionId }; transactionDataProvider.SavePersistentValue(reservationTicket.InvoiceNumber, PaymentConstants.ReservationTicket, reservationTicket); } } } catch (Exception exception) { Log.Error(exception.Message, exception, this); } } else if (string.Compare(responseCode, "CANCEL", StringComparison.OrdinalIgnoreCase) == 0) { this.PaymentStatus = PaymentStatus.Canceled; } if (this.PaymentStatus != PaymentStatus.Succeeded) { transactionDataProvider.SavePersistentValue(paymentArgs.ShoppingCart.OrderNumber, TransactionConstants.PaymentStatus, this.PaymentStatus.ToString()); } }