示例#1
0
        /// <summary>
        /// Used to directly charge a mobile subscription with a provided amount.
        /// </summary>
        /// <param name="request">Payment request.</param>
        /// <returns>The payment response.</returns>
        public async Task <PaymentResponse> PayAsync(PaymentRequest request)
        {
            var content         = request.CreateStringContent(_serializerSettings);
            var responseMessage = await _client.PostAsync(RelativeUri.Pay, content).ConfigureAwait(false);

            await CheckIfFailedRequestAsync(responseMessage);

            return(await responseMessage.DeserializeAsAsync <PaymentResponse>());
        }
示例#2
0
        /// <summary>
        /// Used to directly charge a mobile subscription with a provided amount.
        /// </summary>
        /// <param name="request">Payment request.</param>
        /// <exception cref="ArgumentNullException">Thrown if the <see cref="PaymentRequest"/> is null.</exception>
        /// <returns>The payment response.</returns>
        public async Task <PaymentResponse> PayAsync(PaymentRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var content = request.CreateStringContent(_serializerSettings);

            return(await _client.PostAsync(RelativeUri.Pay, content)
                   .ConfigureAwait(false)
                   .ThrowIfErrorResponseAsync()
                   .DeserializeAsync <PaymentResponse>());
        }