Beispiel #1
0
        /// <summary>
        /// Creates a refund for payment.
        /// </summary>
        /// <param name="paymentId">The payment ID.</param>
        /// <param name="amount">The amount to refund.</param>
        /// <param name="requestOptions"><see cref="RequestOptions"/></param>
        /// <returns>The refund.</returns>
        /// <exception cref="MercadoPagoException">If a unexpected exception occurs.</exception>
        /// <exception cref="MercadoPagoApiException">If the API returns a error.</exception>
        public PaymentRefund Refund(
            long paymentId,
            decimal?amount,
            RequestOptions requestOptions = null)
        {
            var request = new PaymentRefundCreateRequest
            {
                Amount = amount,
            };

            return(Send(
                       $"/v1/payments/{paymentId}/refunds",
                       HttpMethod.POST,
                       request,
                       requestOptions));
        }
Beispiel #2
0
        /// <summary>
        /// Creates async a refund for payment.
        /// </summary>
        /// <param name="paymentId">The payment ID.</param>
        /// <param name="amount">The amount to refund.</param>
        /// <param name="requestOptions"><see cref="RequestOptions"/></param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>A task whose the result is the refund.</returns>
        /// <exception cref="MercadoPagoException">If a unexpected exception occurs.</exception>
        /// <exception cref="MercadoPagoApiException">If the API returns a error.</exception>
        public Task <PaymentRefund> RefundAsync(
            long paymentId,
            decimal?amount,
            RequestOptions requestOptions       = null,
            CancellationToken cancellationToken = default)
        {
            var request = new PaymentRefundCreateRequest
            {
                Amount = amount,
            };

            return(SendAsync(
                       $"/v1/payments/{paymentId}/refunds",
                       HttpMethod.POST,
                       request,
                       requestOptions,
                       cancellationToken));
        }