public virtual async Task <PaymentRequestData> UpdatePaymentRequest(string storeId, string paymentRequestId, UpdatePaymentRequestRequest request, CancellationToken token = default) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-requests/{paymentRequestId}", bodyPayload : request, method : HttpMethod.Put), token); return(await HandleResponse <PaymentRequestData>(response)); }
public async Task <IActionResult> UpdatePaymentRequest(string storeId, string paymentRequestId, [FromBody] UpdatePaymentRequestRequest request) { var validationResult = Validate(request); if (validationResult != null) { return(validationResult); } var pr = await _paymentRequestRepository.FindPaymentRequests( new PaymentRequestQuery() { StoreId = storeId, Ids = new[] { paymentRequestId } }); if (pr.Total == 0) { return(NotFound()); } var updatedPr = pr.Items.First(); updatedPr.SetBlob(request); return(Ok(FromModel(await _paymentRequestRepository.CreateOrUpdatePaymentRequest(updatedPr)))); }
public async Task <IActionResult> UpdatePaymentRequest(string storeId, string paymentRequestId, [FromBody] UpdatePaymentRequestRequest request) { var validationResult = Validate(request); if (validationResult != null) { return(validationResult); } request.Currency ??= StoreData.GetStoreBlob().DefaultCurrency; var pr = await _paymentRequestRepository.FindPaymentRequests( new PaymentRequestQuery() { StoreId = storeId, Ids = new[] { paymentRequestId } }); if (pr.Length == 0) { return(PaymentRequestNotFound()); } var updatedPr = pr.First(); updatedPr.SetBlob(request); return(Ok(FromModel(await _paymentRequestRepository.CreateOrUpdatePaymentRequest(updatedPr)))); }