public ActionResult Destroy(string id) { var orderId = new Guid(id); var order = MvcApplication.FindOrder(orderId); if (order == null) { return(Redirect("/")); } //this is a return, or a Void //just need the transaction ID var gate = OpenGateway(); //void it var request = new VoidRequest(order.TransactionID); var response = gate.Send(request); if (response.Approved) { order.AuthCode = response.AuthorizationCode; order.OrderMessage = "Your order was refunded - we've put a fresh pot on"; //reset it Session["order"] = order; } else { //error... oops. Reload the page order.OrderMessage = response.Message; } //record the order, send to the receipt page return(View()); }
public async void Run_SimpleVoidTest() { ShowTestOnTerminal("SimpleVoid"); AuthorizationRequest setupRequest = new AuthorizationRequest { Pan = "4111111111111111", ExpMonth = "12", ExpYear = "2025", Amount = "25.55", Test = true, TransactionRef = Guid.NewGuid().ToString("N"), }; output.WriteLine("Setup request: {0}", setupRequest); AuthorizationResponse setupResponse = await blockchyp.ChargeAsync(setupRequest); output.WriteLine("Setup Response: {0}", setupResponse); VoidRequest request = new VoidRequest { TransactionId = setupResponse.TransactionId, Test = true, }; output.WriteLine("Request: {0}", request); VoidResponse response = await blockchyp.VoidAsync(request); output.WriteLine("Response: {0}", response); Assert.True(response.Success, "response.Success"); Assert.True(response.Approved, "response.Approved"); }
protected void btnReturn_Click(object sender, EventArgs e) { var order = (CoffeeShopWebApp.Model.CoffeeOrder)Session["order"]; if (order == null) { Response.Redirect("/"); } //this is a return, or a Void //just need the transaction ID var gate = OpenGateway(); //void it var request = new VoidRequest(order.TransactionID); var response = gate.Send(request); if (response.Approved) { order.AuthCode = response.AuthorizationCode; order.OrderMessage = "Your order was refunded - we've put a fresh pot on"; //reset it Session["order"] = order; lblOrder.Text = order.OrderMessage; } else { //error... oops. Reload the page order.OrderMessage = response.Message; } }
public Task <VoidResponse> VoidTransactionAsync(VoidRequest voidRequest) { var request = new RestRequest(Urls.TransactionsApiV1Void, Method.POST); request.AddJsonBody(voidRequest); return(MakeRestRequest <VoidResponse>(request)); }
// Void public async Task <VoidResponse> Void(VoidRequest req) { string jsonRequest = CommonService.JsonSerializer <VoidRequest>(req); string jsonResponse = await PostRequest(jsonRequest, "authorize", req.TransactionID); return(CommonService.JsonDeSerializer <VoidResponse>(jsonResponse)); }
public override VoidProcessPaymentResult VoidProcessPayment(VoidProcessPaymentEvaluationContext context) { var retVal = new VoidProcessPaymentResult(); if (context.Payment.PaymentStatus == PaymentStatus.Cancelled) { var request = new VoidRequest(context.Payment.OuterId); var gate = new Gateway(ApiLogin, TxnKey, true); var response = gate.Send(request); if (response.Approved) { context.Payment.IsCancelled = true; retVal.IsSuccess = true; retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Voided; context.Payment.VoidedDate = context.Payment.CancelledDate = DateTime.UtcNow; } else { retVal.ErrorMessage = response.Message; } } else { throw new NullReferenceException("Only authorized payments can be voided"); } return(retVal); }
public RepositoryInfo[] getAllRepositories([System.Xml.Serialization.XmlElementAttribute("GetAllRepositories", Namespace = "http://www.informatica.com/wsh", IsNullable = true)] VoidRequest GetAllRepositories1) { object[] results = this.Invoke("getAllRepositories", new object[] { GetAllRepositories1 }); return((RepositoryInfo[])(results[0])); }
public VoidResponse logout([System.Xml.Serialization.XmlElementAttribute("Logout", Namespace = "http://www.informatica.com/wsh")] VoidRequest Logout1) { object[] results = this.Invoke("logout", new object[] { Logout1 }); return((VoidResponse)(results[0])); }
public Task <VoidResponse> VoidPayment(string paymentId, VoidRequest voidRequest, CancellationToken cancellationToken = default) { CheckoutUtils.ValidateParams("paymentId", paymentId, "voidRequest", voidRequest); return(ApiClient.Post <VoidResponse>( BuildPath(GetBaseUrl(), OrdersPath, paymentId, VoidsPath), SdkAuthorization(), voidRequest, cancellationToken)); }
/// <remarks/> public void getAllRepositoriesAsync(VoidRequest GetAllRepositories1, object userState) { if ((this.getAllRepositoriesOperationCompleted == null)) { this.getAllRepositoriesOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetAllRepositoriesOperationCompleted); } this.InvokeAsync("getAllRepositories", new object[] { GetAllRepositories1 }, this.getAllRepositoriesOperationCompleted, userState); }
private static async Task <VoidResponse> VoidSaleAsync(string paymentId, IPagadorClient client) { var request = new VoidRequest { Amount = 100000, PaymentId = paymentId }; return(await client.VoidAsync(request)); }
/// <remarks/> public void logoutAsync(VoidRequest Logout1, object userState) { if ((this.logoutOperationCompleted == null)) { this.logoutOperationCompleted = new System.Threading.SendOrPostCallback(this.OnlogoutOperationCompleted); } this.InvokeAsync("logout", new object[] { Logout1 }, this.logoutOperationCompleted, userState); }
public async Task <VoidResponse> VoidAsync(VoidRequest request, MerchantCredentials credentials = null) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (_credentials == null && credentials == null) { throw new InvalidOperationException("Credentials are null"); } var currentCredentials = credentials ?? _credentials; if (string.IsNullOrWhiteSpace(currentCredentials.MerchantId)) { throw new InvalidOperationException("Invalid credentials: MerchantId is null"); } if (string.IsNullOrWhiteSpace(currentCredentials.MerchantKey)) { throw new InvalidOperationException("Invalid credentials: MerchantKey is null"); } var httpRequest = new RestRequest(@"v2/sales/{paymentId}/void", Method.PUT) { RequestFormat = DataFormat.Json }; httpRequest.AddHeader("Content-Type", "application/json"); httpRequest.AddHeader("MerchantId", currentCredentials.MerchantId); httpRequest.AddHeader("MerchantKey", currentCredentials.MerchantKey); httpRequest.AddHeader("RequestId", Guid.NewGuid().ToString()); httpRequest.AddUrlSegment("paymentId", request.PaymentId); httpRequest.AddQueryParameter("amount", request.Amount.ToString(CultureInfo.InvariantCulture)); var cancellationTokenSource = new CancellationTokenSource(); var httpResponse = await RestClientApi.ExecuteTaskAsync(httpRequest, cancellationTokenSource.Token); if (httpResponse.StatusCode != HttpStatusCode.OK) { return(new VoidResponse { HttpStatus = httpResponse.StatusCode, ErrorDataCollection = JsonDeserializer.Deserialize <List <ErrorData> >(httpResponse) }); } var jsonResponse = JsonDeserializer.Deserialize <VoidResponse>(httpResponse); jsonResponse.HttpStatus = httpResponse.StatusCode; return(jsonResponse); }
public async Task VoidCompletes_Test() { var authorization = new AuthorizeRequest { Amount = new Amount { BaseAmount = 1000 }, Card = new Card { CardPresent = false, Cvv = "123", ExpirationMonth = "12", ExpirationYear = "21", Pan = "5105105105105100" }, Mid = _merchantId, Terminal = new Terminal { EntryType = EntryType.Keypad, TerminalId = _terminalId, TerminalType = TerminalType.ECommerce }, Payer = new Payer { BillingAddress = new Address { PostalCode = "76132" } } }; var response = await _client.AuthorizeAmountAsync(authorization); Assert.IsNotNull(response.TransactionId); Assert.IsNotNull(response.AuthCode); var voidRequest = new VoidRequest { Mid = _merchantId, Terminal = new Terminal { EntryType = EntryType.Keypad, TerminalId = _terminalId, TerminalType = TerminalType.ECommerce }, TransactionId = response.TransactionId }; var voidResponse = await _client.VoidTransactionAsync(voidRequest); Assert.IsNotNull(voidResponse.TransactionId); }
public Task <VoidResponse> VoidPayment( string paymentId, VoidRequest voidRequest = null, string idempotencyKey = null, CancellationToken cancellationToken = default) { CheckoutUtils.ValidateParams("paymentId", paymentId); return(ApiClient.Post <VoidResponse>(BuildPath(PaymentsPath, paymentId, "voids"), SdkAuthorization(), voidRequest, cancellationToken, idempotencyKey)); }
private TransactionResponse Void(string reference) { var voidRequest = new VoidRequest(_userName, _password, reference); var response = voidRequest.Execute(); return(new TransactionResponse { Approved = response.ResponseStatus == ResponseStatus.Approved, AuthCode = response.AuthCode, Message = response.ResponseText, TransactionId = response.TransactionId }); }
private TransactionResponse VoidRequest(string reference) { var req = new VoidRequest(reference); var response = Gateway.Send(req); return(new TransactionResponse { Approved = response.Approved, AuthCode = response.AuthorizationCode, Message = response.Message, TransactionId = response.TransactionID }); }
public async Task <IActionResult> Void(VoidRequest request) { TransactionOutput serviceResponse = await _service.VoidTransaction(request.AuthorizationId); StatusResponse response = new StatusResponse { AmountAvailable = serviceResponse.AmountAvailable, Currency = serviceResponse.Currency, Error = serviceResponse.Error, Success = serviceResponse.Success }; return(Ok(response)); }
private async Task ShouldVoidCardPayment() { var paymentResponse = await MakeCardPayment(); var voidRequest = new VoidRequest { Reference = Guid.NewGuid().ToString() }; var response = await PreviousApi.PaymentsClient().VoidPayment(paymentResponse.Id, voidRequest); response.ShouldNotBeNull(); response.ActionId.ShouldNotBeNullOrEmpty(); response.Reference.ShouldNotBeNullOrEmpty(); response.GetLink("payment").ShouldNotBeNull(); }
private async Task ShouldVoidPayment_Request() { var voidRequest = new VoidRequest(); var voidResponse = new VoidResponse(); _apiClient.Setup(apiClient => apiClient.Post <VoidResponse>(PaymentsPath + "/payment_id/voids", _authorization, voidRequest, CancellationToken.None, "test")) .ReturnsAsync(() => voidResponse); IPaymentsClient paymentsClient = new PaymentsClient(_apiClient.Object, _configuration.Object); var response = await paymentsClient.VoidPayment("payment_id", voidRequest, "test"); response.ShouldNotBeNull(); }
public async Task CanVoidPayment() { var paymentRequest = TestHelper.CreateCardPaymentRequest(); var paymentResponse = await _api.Payments.RequestAsync(paymentRequest); paymentResponse.Payment.CanVoid().ShouldBe(true); var voidRequest = new VoidRequest { Reference = Guid.NewGuid().ToString() }; var voidResponse = await _api.Payments.VoidAsync(paymentResponse.Payment.Id, voidRequest); voidResponse.ActionId.ShouldNotBeNullOrEmpty(); voidResponse.Reference.ShouldBe(voidRequest.Reference); }
private async Task ShouldVoidPayment() { var voidRequest = new VoidRequest(); var voidResponse = new VoidResponse(); _apiClient.Setup(apiClient => apiClient.Post <VoidResponse>("klarna-external/orders/id/voids", _authorization, voidRequest, CancellationToken.None, null)) .ReturnsAsync(() => voidResponse); var klarnaClient = new KlarnaClient(_apiClient.Object, _configuration.Object); var response = await klarnaClient.VoidPayment("id", voidRequest, CancellationToken.None); response.ShouldNotBeNull(); }
public override async Task GetTodos(VoidRequest request, IServerStreamWriter <TodoReturn> responseStream, ServerCallContext context) { List <TodoReturn> listTodo = new List <TodoReturn>(); var result = await _toporepository.GetAllTodos(); foreach (var item in result) { listTodo.Add(new TodoReturn { Category = item.Category, Content = item.Content, Title = item.Title }); } foreach (var item in listTodo) { await responseStream.WriteAsync(item); } }
private async Task ShouldVoidCardPaymentIdempotently() { var paymentResponse = await MakeCardPayment(); var voidRequest = new VoidRequest { Reference = Guid.NewGuid().ToString() }; var response = await Retriable(async() => await PreviousApi.PaymentsClient() .VoidPayment(paymentResponse.Id, voidRequest, IdempotencyKey)); response.ShouldNotBeNull(); var response2 = await Retriable(async() => await PreviousApi.PaymentsClient() .VoidPayment(paymentResponse.Id, voidRequest, IdempotencyKey)); response2.ShouldNotBeNull(); response.ActionId.ShouldBe(response2.ActionId); }
/// <summary> /// Successful response returned from a Void Transaction request. /// https://apidocs.securenet.com/docs/voids.html?lang=csharp /// </summary> public void Voids_Void_Transaction_Request_Returns_Successfully(int transactionId) { // Arrange var request = new VoidRequest { TransactionId = transactionId, DeveloperApplication = new DeveloperApplication { DeveloperId = 12345678, Version = "1.2" } }; var apiContext = new APIContext(); var controller = new PaymentsController(); // Act var response = controller.ProcessRequest <VoidResponse>(apiContext, request); // Assert Assert.IsNotNull(response); Assert.IsTrue(response.Success); }
public override Task <CustomerListBookResponse> GetAllBooks(VoidRequest request, ServerCallContext context) { logger.LogInformation("Begin grpc call from method {Method} for all books", context.Method); //using ( var dbcontext = new dbBooksContext(dbContextOptions)) //{ CustomerListBookResponse response = new CustomerListBookResponse(); var datas = bookContext.Books; foreach (var item in datas) { response.Books.Add(new CustomerBookDataReponse { Id = item.Id, Name = item.Name, Price = item.Price, Category = item.Category, Author = item.Author, }); } return(Task.FromResult(response)); //} }
//////////////// Void methods ///////////// private void VoidButton_Click(object sender, EventArgs e) { VoidRequest request = new VoidRequest(); if (OrderPaymentsView.SelectedItems.Count == 1) { POSPayment payment = ((POSPayment)OrderPaymentsView.SelectedItems[0].Tag); request.PaymentId = payment.PaymentID; request.EmployeeId = payment.EmployeeID; request.OrderId = payment.OrderID; request.VoidReason = "USER_CANCEL"; cloverConnector.VoidTransaction(request); } }
public VoidResponse Void(Guid paymentId, MerchantAuthentication merchantAuthentication, VoidRequest voidRequest) { var restRequest = new RestRequest(@"sales/{paymentId}/void", Method.PUT) { RequestFormat = DataFormat.Json }; AddHeaders(restRequest, merchantAuthentication); restRequest.AddUrlSegment("paymentId", paymentId.ToString()); if (voidRequest.Amount != null) { restRequest.AddQueryParameter("amount", voidRequest.Amount.ToString()); } var response = RestClient.Execute <VoidResponse>(restRequest); VoidResponse voidResponse = null; if (response.StatusCode == HttpStatusCode.OK) { voidResponse = JsonConvert.DeserializeObject <VoidResponse>(response.Content); } else if (response.StatusCode == HttpStatusCode.BadRequest) { voidResponse = new VoidResponse { ErrorDataCollection = JsonDeserializer.Deserialize <List <Error> >(response) } } ; else { voidResponse = new VoidResponse(); } voidResponse.HttpStatus = response.StatusCode; return(voidResponse); }
public override bool ProcessPayment(Payment payment, ref string message) { var info = payment as CreditCardPayment; if (ReferenceEquals(info, null)) { payment.Status = PaymentStatus.Failed.ToString(); message = "AuthorizeNet gateway supports only CreditCardPayment"; return(false); } string[] validateSettings = { "MerchantLogin", "MerchantPassword" }; foreach (var validateSetting in validateSettings) { if (!Settings.ContainsKey(validateSetting) || string.IsNullOrWhiteSpace(Settings[validateSetting])) { payment.Status = PaymentStatus.Failed.ToString(); message = string.Format("{0} not configured", validateSetting); return(false); } } var transactionType = (TransactionType)Enum.Parse(typeof(TransactionType), info.TransactionType); payment.Status = PaymentStatus.Processing.ToString(); var gateway = new Gateway(Settings["MerchantLogin"], Settings["MerchantPassword"]); bool isTestMode; if (Settings.ContainsKey("TestMode") && bool.TryParse(Settings["TestMode"], out isTestMode)) { gateway.TestMode = isTestMode; } var description = string.Format("{0} transaction for order id {1}", transactionType, info.OrderForm.OrderGroupId); IGatewayRequest request = null; switch (transactionType) { case TransactionType.Authorization: case TransactionType.Sale: request = new AuthorizationRequest(info.CreditCardNumber, string.Format("{0}{1}", info.CreditCardExpirationMonth, info.CreditCardExpirationYear), info.Amount, description, transactionType == TransactionType.Sale); break; case TransactionType.Capture: request = new PriorAuthCaptureRequest(info.Amount, info.ValidationCode); break; case TransactionType.Credit: request = new CreditRequest(info.ValidationCode, info.Amount, info.CreditCardNumber); break; case TransactionType.Void: request = new VoidRequest(info.ValidationCode); break; } if (request == null) { payment.Status = PaymentStatus.Failed.ToString(); message = string.Format("Unsupported transation type {0}", transactionType); return(false); } request.AddCardCode(info.CreditCardSecurityCode); var invoice = info.OrderForm.OrderGroupId; var order = info.OrderForm.OrderGroup as Order; if (order != null) { invoice = order.TrackingNumber; } request.AddInvoice(invoice); request.AddTax(info.OrderForm.TaxTotal); // Find the address var address = info.OrderForm.OrderGroup.OrderAddresses .FirstOrDefault(a => String.Compare(a.OrderAddressId, info.BillingAddressId, StringComparison.OrdinalIgnoreCase) == 0); if (address != null) { request.AddCustomer(address.Email, address.FirstName, address.LastName, address.Line1 + " " + address.Line2, address.StateProvince, address.PostalCode); } //foreach (var lineItem in info.OrderForm.LineItems) //{ // request.AddLineItem(lineItem.LineItemId, lineItem.DisplayName, lineItem.Description, // (int)lineItem.Quantity, lineItem.PlacedPrice, false); //} try { var response = gateway.Send(request, description); if (!response.Approved) { payment.Status = PaymentStatus.Denied.ToString(); message = "Transaction Declined: " + response.Message; return(false); } info.StatusCode = response.ResponseCode; info.StatusDesc = response.Message; info.ValidationCode = response.TransactionID; info.AuthorizationCode = response.AuthorizationCode; // transaction is marked as completed every time the payment operation succeeds even if it is void transaction type payment.Status = PaymentStatus.Completed.ToString(); } catch (Exception ex) { payment.Status = PaymentStatus.Failed.ToString(); throw new ApplicationException(ex.Message); } return(true); }
public virtual void StubServiceMethodWithNoResponse(VoidRequest request) { }
public ActionResult StartNewSeason(VoidRequest request) { var seasonName = _seasonLogic.StartNewSeason(); return Ok(seasonName); }
public ActionResult GetSeasons(VoidRequest request) { List<Season> seasons = _seasonLogic.GetSeasons(); return Ok(seasons); }