public async Task <ActionResult> AddOrUpdateCartPayment(PaymentUpdateModel payment) { EnsureThatCartExist(); //Need lock to prevent concurrent access to same cart using (var lockObject = await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart.Id)).LockAsync()) { await _cartBuilder.AddOrUpdatePaymentAsync(payment); await _cartBuilder.SaveAsync(); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public async Task <ActionResult> AddOrUpdatePaymentJson(string paymentId, Address billingAddress, string paymentMethodCode, string outerId) { EnsureThatCartExist(); //Need lock to prevent concurrent access to same cart using (var lockObject = await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart.Id)).LockAsync()) { await _cartBuilder.AddOrUpdatePaymentAsync(paymentId, billingAddress, paymentMethodCode, outerId); await _cartBuilder.SaveAsync(); } return(Json(null, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> AddOrUpdateCartPayment(Payment payment) { await EnsureCartExistsAsync(); if (payment.Amount.Amount == decimal.Zero) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Valid payment amount is required")); } //Need lock to prevent concurrent access to same cart using (await AsyncLock.GetLockByKey(GetAsyncLockCartKey(WorkContext.CurrentCart)).LockAsync()) { await _cartBuilder.AddOrUpdatePaymentAsync(payment); await _cartBuilder.SaveAsync(); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }