Esempio n. 1
0
        public Task <ApiResult <ApiRefundResponse> > CreateRefundAsync(long paymentId,
                                                                       ApiRefundRequest refundRequest,
                                                                       CancellationToken cancellationToken)
        {
            paymentId.ThrowIfNotCondition(id => id > 0, nameof(paymentId));
            refundRequest.ThrowIfNull(nameof(refundRequest));
            cancellationToken.ThrowIfNull(nameof(cancellationToken));
            refundRequest.Refund.ThrowIfNull(nameof(refundRequest.Refund));

            var validationResult = _refundRequestValidator.Validate(refundRequest.Refund);

            if (!validationResult.IsValid)
            {
                return(validationResult.ToValidationException().ToApiResult <ApiRefundResponse>().ToAwaitable());
            }

            var uri     = GetRefundsUri(paymentId);
            var request = refundRequest.ToHttpRequest(HttpMethod.Post, uri);

            return(HttpClient.InvokeAsync <ApiRefundResponse>(request, cancellationToken));
        }
Esempio n. 2
0
 public Task <ApiResult <ApiRefundResponse> > CreateRefundAsync(long paymentId,
                                                                ApiRefundRequest refundRequest,
                                                                string idempotencyToken)
 {
     return(CreateRefundAsync(paymentId, refundRequest, idempotencyToken, CancellationToken.None));
 }