public async Task Should_Retrieve_Checkout_Form_Result() { IReadOnlyList <BasketItem> basketItems = new ReadOnlyCollection <BasketItem>(new List <BasketItem>() { BasketItemBuilder.Create().Price("0.3").Build() }); CreateCheckoutFormInitializeRequest request = CreateCheckoutFormInitializeRequestBuilder.Create() .Price("0.3") .PaymentGroup(PaymentGroup.LISTING.ToString()) .PaidPrice("0.4") .CallbackUrl("https://www.merchant.com/callback") .BasketItems(basketItems) .Build(); CheckoutFormInitialize checkoutFormInitialize = await CheckoutFormInitialize.CreateAsync(request, Options); RetrieveCheckoutFormRequest retrieveCheckoutFormRequest = RetrieveCheckoutFormRequestBuilder.Create() .Token(checkoutFormInitialize.Token) .Build(); CheckoutForm checkoutForm = await CheckoutForm.RetrieveAsync(retrieveCheckoutFormRequest, Options); PrintResponse(checkoutForm); Assert.NotNull(checkoutForm.ErrorMessage); Assert.AreEqual(Status.FAILURE.ToString(), checkoutForm.Status); Assert.NotNull(checkoutForm.SystemTime); }
public ActionResult ResultBank() { Response.Write(Session["token"] + " token"); Options op = new Options(); op.ApiKey = "sandbox-4qe5Bt7swzzJZ3rJaaGvj2CmUvNVMGpU"; op.SecretKey = "sandbox-fm5wbKx0Dx3t09pGa75kwRrUjgXuJkQT"; op.BaseUrl = "https://sandbox-api.iyzipay.com"; RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.ConversationId = "123456789"; request.Token = Session["token"].ToString(); CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, op); Response.Write("payment statüs : " + checkoutForm.PaymentStatus + "<br>"); Response.Write(" Status : " + checkoutForm.Status + "<br>"); Response.Write(" Status : " + checkoutForm.Installment.Value + "<br>"); Response.Write("payment Price : " + checkoutForm.Price + "<br>"); Response.Write("payment PaidPrice : " + checkoutForm.PaidPrice + "<br>"); Response.Write("payment IyziCommissionFee : " + checkoutForm.IyziCommissionFee + "<br>"); Response.Write("payment IyziCommissionRateAmount : " + checkoutForm.IyziCommissionRateAmount + "<br>"); Response.Write("payment MerchantCommissionRate : " + checkoutForm.MerchantCommissionRate + "<br>"); Response.Write("payment MerchantCommissionRateAmount : " + checkoutForm.MerchantCommissionRateAmount + "<br>"); Response.Write("payment Token : " + checkoutForm.Token + "<br>"); return(View()); }
public ActionResult PayOut(RetrieveCheckoutFormRequest model) { int siparisID = 0; string data = ""; Options options = new Options(); options.ApiKey = ConfigurationManager.AppSettings["iyzico_apikey"]; options.SecretKey = ConfigurationManager.AppSettings["iyzico_secretkey"]; options.BaseUrl = ConfigurationManager.AppSettings["iyzico_baseurl"]; data = model.Token; RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.Token = data; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, options); Int32.TryParse(checkoutForm.BasketId, out siparisID); Siparis siparis = new Siparis(); siparis.Load(siparisID); if (checkoutForm.PaymentStatus == "SUCCESS") { siparis.DurumGuncelle((int)siparisDurum.hazirlaniyor, 0); } else { siparis.DurumGuncelle((int)siparisDurum.odemeBasarisiz, 0); } return(RedirectToAction("Pay", new { id = siparisID })); }
public Purchase Charge(CheckoutForm form, Beer beer) { var charge = new StripeChargeCreateOptions() { Amount = Convert.ToInt32(beer.Price * 100), ApplicationFee = Convert.ToInt32((beer.Price * 0.05M) * 100), Currency = "AUD", Source = new StripeSourceOptions() { TokenId = form.StripeToken } }; var service = new StripeChargeService(beer.User.StripeAccessToken); var result = service.Create(charge); if (!result.Paid) { throw new Exception(result.FailureMessage); } var purchase = new Purchase() { Email = form.StripeEmail, StripePaymentId = result.Id, CreatedDate = DateTime.Now }; _brewsyContext.Purchases.Add(purchase); _brewsyContext.SaveChanges(); return(purchase); }
public IActionResult Onay([FromForm] string token) { var options = new Options { ApiKey = "sandbox-7xSIEv7d8wZc2BiX2nGEQnhhdDg6wm30", SecretKey = "sandbox-XKXfOIBvPLCwqo5xgn1zmDJUWvjVjB1v", BaseUrl = "https://sandbox-api.iyzipay.com" }; RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest { ConversationId = "123", Token = token }; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, options); ViewData["Greeting"] = checkoutForm.PaymentStatus; if (checkoutForm.PaymentStatus == "SUCCESS") { return(View("Success")); } else if (checkoutForm.PaymentStatus == "FAILURE") { return(View("Fail")); } return(View()); }
public IActionResult Index(CheckoutForm model) { var beer = _context.Beers.Include(x => x.User).FirstOrDefault(x => x.Id == model.BeerId); var purchase = _chargeService.Charge(model, beer); return(RedirectToAction("Thankyou", "Home")); }
public CheckoutForm ContolPayment(string token, string conversationid) { RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.ConversationId = conversationid; request.Token = token; return(CheckoutForm.Retrieve(request, this._option)); }
public object CallbackForm(string token) { RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.ConversationId = "123456789"; request.Token = token; var checkoutForm = CheckoutForm.Retrieve(request, options); return(checkoutForm); }
public void Should_Retrieve_Checkout_Form_Result() { RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.ConversationId = "123456789"; request.Token = "token"; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, options); PrintResponse <CheckoutForm>(checkoutForm); Assert.AreEqual(Status.SUCCESS.ToString(), checkoutForm.Status); Assert.AreEqual(Locale.TR.ToString(), checkoutForm.Locale); Assert.AreEqual("123456789", checkoutForm.ConversationId); Assert.IsNotNull(checkoutForm.SystemTime); Assert.IsNull(checkoutForm.ErrorCode); Assert.IsNull(checkoutForm.ErrorMessage); Assert.IsNull(checkoutForm.ErrorGroup); }
public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } Book = _context.Book.Find(id); if (Book == null) { return(NotFound()); } CheckoutForm = new CheckoutForm(); CheckoutForm.BookId = Book.Id; CheckoutForm.BookName = Book.Name; return(Page()); }
public async Task Should_Retrieve_Checkout_Form_Result() { RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest { ConversationId = "123456789", Token = "token" }; CheckoutForm checkoutForm = await CheckoutForm.RetrieveAsync(request, Options); PrintResponse(checkoutForm); Assert.AreEqual(Status.SUCCESS.ToString(), checkoutForm.Status); Assert.AreEqual(Locale.TR.ToString(), checkoutForm.Locale); Assert.AreEqual("123456789", checkoutForm.ConversationId); Assert.IsNotNull(checkoutForm.SystemTime); Assert.IsNull(checkoutForm.ErrorCode); Assert.IsNull(checkoutForm.ErrorMessage); Assert.IsNull(checkoutForm.ErrorGroup); }
public async Task <IActionResult> OnGet( [FromServices] GetCart getCart, [FromServices] IWebHostEnvironment env) { var userId = User.GetUserId(); var cart = await getCart.Get(userId); if (cart.Products.Count <= 0) { return(RedirectToPage("/Index")); } Form = new CheckoutForm(); if (env.IsDevelopment()) { Form.Name = "test"; Form.Email = "*****@*****.**"; Form.Phone = "7845556789"; Form.Address1 = "Test"; Form.Address2 = ""; Form.City = "City"; Form.Country = "Country"; Form.PostCode = "QQ1 2RR"; Form.State = ""; } else if (cart.DeliveryInformationComplete) { Form.Name = cart.Name; Form.Email = cart.Email; Form.Phone = cart.Phone; Form.Address1 = cart.Address1; Form.Address2 = cart.Address2; Form.City = cart.City; Form.Country = cart.Country; Form.PostCode = cart.PostCode; Form.State = cart.State; } return(Page()); }
public ActionResult ResultPay(RetrieveCheckoutFormRequest model) { string data = ""; Options options = new Options(); options.ApiKey = "sandbox-......"; //Iyzico Tarafından Sağlanan Api Key options.SecretKey = "sandbox-...."; //Iyzico Tarafından Sağlanan Secret Key options.BaseUrl = "https://sandbox-api.iyzipay.com"; data = model.Token; RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.Token = data; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, options); if (checkoutForm.PaymentStatus == "SUCCESS") { return(RedirectToAction("Confirmation")); } return(View()); }
public ActionResult Sonuc(RetrieveCheckoutFormRequest model) { string data = ""; Options options = new Options(); options.ApiKey = "sandbox-Z92PD5nIy1dHFVLlk3vPhnjzYmC8f2MS"; options.SecretKey = "sandbox-qrEHpoSgczPPnNJ7F0tcGGG7PcO9MEKU"; options.BaseUrl = "https://sandbox-api.iyzipay.com" data = model.Token; RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest(); request.Token = data; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, options); if (checkoutForm.PaymentStatus == "SUCCESS") { return(RedirectToAction("Onay")); } return(View()); }
public IActionResult Onay([FromForm] string token) { RetrieveCheckoutFormRequest request = new RetrieveCheckoutFormRequest { ConversationId = "123", Token = token }; CheckoutForm checkoutForm = CheckoutForm.Retrieve(request, option); ViewData["Approval"] = checkoutForm.PaymentStatus; if (checkoutForm.PaymentStatus == "SUCCESS") { return(View("Success")); } else if (checkoutForm.PaymentStatus == "FAILURE") { return(View("Fail")); } return(View()); }
private void btn_CheckOut_Click(object sender, EventArgs e) { if (Main.loggedInUser.userid != "" && Main.loggedInUser.userid != null && currentItem != null) { CheckoutForm checkoutForm = new CheckoutForm(); checkoutForm.ShowDialog(); currentItem.Initial = Main.loggedInUser.initial; if (Main.studentNo != null && Main.studentNo != "") { currentItem.StudentNo = Main.studentNo; currentItem.MakeTransaction(!currentItem.Status); resetDisplay(); MessageBox.Show("Transaction Complete!"); } else { MessageBox.Show("Check the student Number!"); } tb_barcode.Focus(); } }
public IActionResult Checkout(CheckoutForm checkoutForm) { using (var context = new BookContext()) { var copy = context.Copy.Single(s => s.CopyId == checkoutForm.CopyId); copy.MemberId = checkoutForm.MemberId; copy.IssueDate = DateTime.Now; copy.DueDate = DateTime.Now.AddDays(7); context.SaveChanges(); var member = context.Members.Single(s => s.MemberId == checkoutForm.MemberId); var displayCopies = new ListOfCopies { CopyList = member.Copies.ToList() }; displayCopies.ToList().Add(copy); member.CopyId = checkoutForm.CopyId; context.SaveChanges(); } return(RedirectToAction("CheckedOutBooks")); }
public JsonResult HandleCheckout([FromBody] EmployeeForm eform) { var success = false; var reason = "unknown"; Console.WriteLine(eform.Data); CheckoutForm form = JsonSerializer.Deserialize <CheckoutForm>(eform.Data); Console.WriteLine(form.BookId); Console.WriteLine(form.Username); try { var handler = new ConnectionHandler(); using (MySqlConnection connection = handler.Connection) { MySqlTransaction trans = connection.BeginTransaction(); string sql = "SELECT userId FROM Users WHERE username=@USERNAME"; MySqlCommand cmd = new MySqlCommand(sql, connection); cmd.Transaction = trans; cmd.Parameters.AddWithValue("@USERNAME", form.Username); MySqlDataReader rdr = cmd.ExecuteReader(); // if the username exists if (rdr.Read()) { int userId = (int)rdr[0]; rdr.Close(); cmd.CommandText = "SELECT * FROM BookHistory WHERE userId=@USERID AND dateReturned IS NULL"; cmd.Parameters.AddWithValue("@USERID", userId); rdr = cmd.ExecuteReader(); // User does not have a book already checkedout if (!rdr.Read()) { rdr.Close(); cmd.CommandText = "SELECT availability FROM BookDetails WHERE bookId=@BOOKID"; cmd.Parameters.AddWithValue("@BOOKID", form.BookId); rdr = cmd.ExecuteReader(); if (rdr.Read()) { if (rdr[0].ToString() == "available") { rdr.Close(); cmd.CommandText = "INSERT INTO BookHistory(userId, bookId, dateCheckout) VALUES (@USERID, @BOOKID, CURDATE())"; cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE BookDetails SET availability='checkedout' WHERE bookId=@BOOKID"; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } else if (rdr[0].ToString() == "reserved") { rdr.Close(); cmd.CommandText = "SELECT userId FROM Reservations WHERE bookId=@BOOKID"; rdr = cmd.ExecuteReader(); if (rdr.Read()) { if ((int)rdr[0] == userId) { rdr.Close(); cmd.CommandText = "INSERT INTO BookHistory(userId, bookId, dateCheckout) VALUES (@USERID, @BOOKID, CURDATE())"; cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE BookDetails SET availability='checkedout' WHERE bookId=@BOOKID"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM Reservations WHERE bookId=@BOOKID"; cmd.ExecuteNonQuery(); trans.Commit(); success = true; } else { rdr.Close(); reason = "reserved"; } } else { // INTERNAL PROBLEM - Book is reserved but there is no row in Reservations reason = "unknown"; } } else { rdr.Close(); reason = "unavailable"; } } else { rdr.Close(); reason = "badBookId"; } } else { rdr.Close(); reason = "multipleCheckout"; } } else { rdr.Close(); reason = "badUsername"; } } } catch (Exception ex) { success = false; Console.WriteLine(ex); } if (success) { reason = "none"; } return(new JsonResult($"{{\"success\":\"{success}\"," + $"\"reason\":\"{reason}\"}}", new System.Text.Json.JsonSerializerOptions())); }