public static Uri GetUrlWithQueryString(this Uri uri, PaymentOrderExpand paymentExpand) { string paymentExpandQueryString = GetExpandQueryString <PaymentOrderExpand>(paymentExpand); var url = !string.IsNullOrWhiteSpace(paymentExpandQueryString) ? new Uri(uri.OriginalString + paymentExpandQueryString, UriKind.RelativeOrAbsolute) : uri; return(url); }
/// <summary> /// Create a payment order /// </summary> /// <param name="paymentOrderRequest"></param> /// <param name="paymentOrderExpand"></param> /// <returns></returns> public async Task <IPaymentOrderResponse> Create(PaymentOrderRequest paymentOrderRequest, PaymentOrderExpand paymentOrderExpand = PaymentOrderExpand.None) { var url = new Uri("/psp/paymentorders", UriKind.Relative).GetUrlWithQueryString(paymentOrderExpand); var requestDto = new PaymentOrderRequestDto(paymentOrderRequest); var paymentOrderResponseContainer = await HttpClient.PostAsJsonAsync <PaymentOrderResponseDto>(url, requestDto); return(new PaymentOrderResponse(paymentOrderResponseContainer, HttpClient)); }
public PaymentOrder GetPaymentOrder(IOrderGroup orderGroup, PaymentOrderExpand paymentOrderExpand = PaymentOrderExpand.None) { var swedbankPayCheckoutOrderId = orderGroup.Properties[Constants.SwedbankPayOrderIdField]?.ToString(); if (!string.IsNullOrWhiteSpace(swedbankPayCheckoutOrderId)) { var market = _marketService.GetMarket(orderGroup.MarketId); var uri = new Uri(swedbankPayCheckoutOrderId, UriKind.Relative); return(GetPaymentOrder(uri, market, orderGroup.Properties[Constants.Culture]?.ToString(), paymentOrderExpand)); } return(null); }
/// <summary> /// Get payment order by id /// </summary> /// <param name="id"></param> /// <param name="paymentOrderExpand"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="HttpRequestException"></exception> /// <exception cref="HttpResponseException"></exception> public async Task <IPaymentOrderResponse> Get(Uri id, PaymentOrderExpand paymentOrderExpand = PaymentOrderExpand.None) { if (id == null) { throw new ArgumentNullException(nameof(id), $"{id} cannot be null"); } Uri url = id.GetUrlWithQueryString(paymentOrderExpand); var paymentOrderResponseContainer = await HttpClient.GetAsJsonAsync <PaymentOrderResponseDto>(url); return(new PaymentOrderResponse(paymentOrderResponseContainer, HttpClient)); }
public virtual PaymentOrder GetPaymentOrder(Uri id, IMarket market, string languageId, PaymentOrderExpand paymentOrderExpand = PaymentOrderExpand.None) { var config = LoadCheckoutConfiguration(market, languageId); var swedbankPayClient = _swedbankPayClientFactory.Create(config); try { return(AsyncHelper.RunSync(() => swedbankPayClient.PaymentOrders.Get(id, paymentOrderExpand))); } catch (Exception ex) { _logger.Error(ex.Message, ex); throw; } }