Пример #1
0
        public async Task <bool> CaptureAuthorizedCharge(string stripeAuthChargeId, int amount)
        {
            var opts = new ChargeCaptureOptions()
            {
                Amount = amount
            };
            var    chargeService = new ChargeService();
            Charge charge        = await chargeService.CaptureAsync(stripeAuthChargeId, opts);

            return(charge != null);
        }
Пример #2
0
        public async Task <Charge> CreateCaptureAsync(string chargeId, decimal amount, decimal applicationFeeAmount)
        {
            var options = new ChargeCaptureOptions
            {
                Amount = (long)(amount * 100),
                ApplicationFeeAmount = (long)(applicationFeeAmount * 100)
            };

            var service = new ChargeService();

            return(await service.CaptureAsync(chargeId, options));
        }
Пример #3
0
        public async Task <IEnumerable <TransactionDTO> > Execute(PaymentModel payment)
        {
            var customer = await _paymentRepository.GetLastTransaction(payment.OrderId);

            var service = new ChargeService();

            var orderInfo = new PaymentModel {
                UserId = customer.UserId, VendorId = customer.VendorId, OrderId = customer.OrderId, Amount = customer.Amount
            };

            if (!customer.TransactionType.ToUpper().Equals(PaymentServiceConstants.PaymentType.Auth.ToString().ToUpper()))
            {
                throw new Exception("Server can not find auth transaction");//TODO: треба ще ексепшин хендлінг
            }
            var transaction = await _retryHelper.RetryIfThrown(async() =>
            {
                var result = await service.CaptureAsync(customer.ExternalId, null);
                return(_mappingProvider.GetMappingOperation(PaymentServiceConstants.PaymentMappingType.Stripe_Succeeded)
                       .Map(PaymentServiceConstants.PaymentType.Capture, orderInfo, result, result.Created));
            }, PaymentServiceConstants.PaymentType.Capture, orderInfo, PaymentServiceConstants.isSucceeded.Succeeded);

            return(await _paymentRepository.CreateTransactions(transaction));
        }
Пример #4
0
 public async Task <Charge> CaptureAsync(string chargeId, ChargeCaptureOptions chargeCaptureOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
 {
     return(await chargeService.CaptureAsync(chargeId, chargeCaptureOptions, requestOptions, cancellationToken));
 }