In this article, we will learn how to Refund Payment using Square in ASP.NET Web application.
Let’s begin.
Please read this article first of all here.
You can refund the entire payment amount or a portion of it
Open the HomeController.cshtml and add the below code in it.
public ActionResult Index() { return View(); } public async System.Threading.Tasks.Task<ActionResult> RefundProcessAsync() { try { client = new SquareClient.Builder() .Environment(Square.Environment.Sandbox) .AccessToken("Your Access Token") .Build(); string idempotencyKey = NewIdempotencyKey(); var amountMoney = new Money.Builder() .Amount(100L) .Currency("USD") .Build(); var body = new RefundPaymentRequest.Builder( idempotencyKey: idempotencyKey, amountMoney: amountMoney, paymentId: "Your Payment Id") .Build(); var result = await client.RefundsApi.RefundPaymentAsync(body: body); return Json(new { IsSuccess = true, Message = "Refund Successfully." }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { IsSuccess = false, Message = ex.Message }, JsonRequestBehavior.AllowGet); } } private static string NewIdempotencyKey() { return Guid.NewGuid().ToString(); }
if you have any questions or issues about this article, please let me know. For More Information Here.
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular