Exemple #1
0
        /// <summary>
        /// Makes a swish payment via the e-commerce flow
        /// </summary>
        /// <param name="payment">The payment details</param>
        /// <returns>Payment response containing payment status location</returns>
        public async Task <ECommercePaymentResponse> MakeECommercePaymentAsync(ECommercePaymentModel payment)
        {
            payment.PayeeAlias = MerchantId;
            payment.PayerAlias = FixPayerAlias(payment.PayerAlias);
            var response = await Post(payment, _paymentRequestsPath).ConfigureAwait(false);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                return(ExtractSwishResponse(response) as ECommercePaymentResponse);
            }
            return(GetErrorResponse <ECommercePaymentResponse>(responseContent, response.StatusCode));
        }
        /// <summary>
        /// Makes a swish payment via the e-commerce flow
        /// </summary>
        /// <param name="payment">The payment details</param>
        /// <returns>Payment response containing payment status location</returns>
        public async Task <ECommercePaymentResponse> MakeECommercePaymentAsync(ECommercePaymentModel payment)
        {
            payment.PayeeAlias = MerchantId;

            var response = await Post(payment, _paymentRequestsPath).ConfigureAwait(false);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (response.StatusCode == (HttpStatusCode)422)
            {
                throw new HttpRequestException(responseContent);
            }
            response.EnsureSuccessStatusCode();

            return(ExtractSwishResponse(response) as ECommercePaymentResponse);
        }