示例#1
0
        public virtual async Task <IPaymentRequestResult> RequestAsync(Invoice invoice, CancellationToken cancellationToken = default)
        {
            if (invoice == null)
            {
                throw new ArgumentNullException(nameof(invoice));
            }

            var data = MelliHelper.CreateRequestData(invoice, _options.Value);

            var result = await PostJsonAsync <MelliApiRequestResult>(MelliHelper.ServiceRequestUrl, data, cancellationToken).ConfigureAwaitFalse();

            return(MelliHelper.CreateRequestResult(result, _httpContextAccessor, _messageOptions.Value));
        }
示例#2
0
        public virtual async Task <IPaymentVerifyResult> VerifyAsync(Payment payment, CancellationToken cancellationToken = default)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            var data = MelliHelper.CreateCallbackResult(
                payment,
                _httpContextAccessor.HttpContext.Request,
                _options.Value,
                _messageOptions.Value);

            if (!data.IsSucceed)
            {
                return(data.Result);
            }

            var result = await PostJsonAsync <MelliApiVerifyResult>(MelliHelper.ServiceVerifyUrl, data.JsonDataToVerify, cancellationToken).ConfigureAwaitFalse();

            return(MelliHelper.CreateVerifyResult(data.Token, result, _messageOptions.Value));
        }