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> /// Begins the payment. /// </summary> /// <param name="paymentSystem">The payment System.</param> /// <param name="paymentArgs">The payment arguments.</param> public override void Invoke([NotNull] PaymentSystem paymentSystem, [NotNull] PaymentArgs paymentArgs) { Assert.IsNotNull(paymentSystem, "Payment method is null"); Assert.ArgumentNotNull(paymentArgs, "paymentArgs"); Assert.IsNotNull(paymentArgs.ShoppingCart, "Shopping cart is null"); PaymentSettingsReader configuration = new PaymentSettingsReader(paymentSystem); string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string amount = paymentArgs.ShoppingCart.Totals.TotalPriceIncVat.ToCents(); string currencyCode = this.Currency(paymentArgs.ShoppingCart.Currency.Code); string orderNumber = paymentArgs.ShoppingCart.OrderNumber; string redirectUrl = paymentArgs.PaymentUrls.ReturnPageUrl; string paymentSystemCode = paymentSystem.Code; string webServicePlatform = configuration.GetSetting("webServicePlatform"); string language = configuration.GetSetting("language"); RegisterRequest request = new RegisterRequest { Order = new Order { Amount = amount, OrderNumber = orderNumber, CurrencyCode = currencyCode }, Terminal = new Terminal { Language = language, RedirectUrl = redirectUrl }, Environment = new Services.Environment { WebServicePlatform = webServicePlatform } }; Netaxept client = new Netaxept(); try { RegisterResponse response = client.Register(merchantId, token, request); NameValueCollection data = new NameValueCollection { { "MerchantID", merchantId }, { "TransactionID", response.TransactionId } }; ITransactionData transactionDataProvider = Context.Entity.Resolve <ITransactionData>(); transactionDataProvider.SaveStartValues(orderNumber, amount, currencyCode, paymentSystemCode); this.PostData(paymentSystem.PaymentUrl, data); } catch (Exception exception) { Log.Error(exception.Message, this); HttpContext.Current.Session["paymentErrorMessage"] = exception.Message; HttpContext.Current.Response.Redirect(paymentArgs.PaymentUrls.FailurePageUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } }
/// <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()); } }
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> /// Begins the payment. /// </summary> /// <param name="paymentSystem">The payment System.</param> /// <param name="paymentArgs">The payment arguments.</param> public override void Invoke([NotNull] PaymentSystem paymentSystem, [NotNull] PaymentArgs paymentArgs) { Assert.IsNotNull(paymentSystem, "Payment method is null"); Assert.ArgumentNotNull(paymentArgs, "paymentArgs"); Assert.IsNotNull(paymentArgs.ShoppingCart, "Shopping cart is null"); PaymentSettingsReader configuration = new PaymentSettingsReader(paymentSystem); string merchantId = paymentSystem.Username; string token = paymentSystem.Password; string amount = paymentArgs.ShoppingCart.Totals.TotalPriceIncVat.ToCents(); string currencyCode = this.Currency(paymentArgs.ShoppingCart.Currency.Code); string orderNumber = paymentArgs.ShoppingCart.OrderNumber; string redirectUrl = paymentArgs.PaymentUrls.ReturnPageUrl; string paymentSystemCode = paymentSystem.Code; string webServicePlatform = configuration.GetSetting("webServicePlatform"); string language = configuration.GetSetting("language"); RegisterRequest request = new RegisterRequest { Order = new Order { Amount = amount, OrderNumber = orderNumber, CurrencyCode = currencyCode }, Terminal = new Terminal { Language = language, RedirectUrl = redirectUrl }, Environment = new Services.Environment { WebServicePlatform = webServicePlatform } }; Netaxept client = new Netaxept(); try { RegisterResponse response = client.Register(merchantId, token, request); NameValueCollection data = new NameValueCollection { { "MerchantID", merchantId }, { "TransactionID", response.TransactionId } }; ITransactionData transactionDataProvider = Context.Entity.Resolve<ITransactionData>(); transactionDataProvider.SaveStartValues(orderNumber, amount, currencyCode, paymentSystemCode); this.PostData(paymentSystem.PaymentUrl, data); } catch (Exception exception) { Log.Error(exception.Message, this); HttpContext.Current.Session["paymentErrorMessage"] = exception.Message; HttpContext.Current.Response.Redirect(paymentArgs.PaymentUrls.FailurePageUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } }