public async Task <DonateViaAffiliateProgramViewModel> Handle(DonateViaAffiliateProgramCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            await ValidateCommand(command);

            var orderId          = command.RequestedUserAccount.Id;
            var userPaymentForId = command.UserMultiAccountId;

            var paymentResponse = await _bitBayPayFacade.CreatePayment(orderId, command.Amount);

            ValidateResponse(paymentResponse);

            var paymentHistory = new PaymentHistory(
                id: Guid.NewGuid(),
                paymentId: paymentResponse.Data.PaymentId,
                orderId: orderId,
                userPaymentForId: userPaymentForId,
                amountToPay: command.Amount,
                paymentFor: PaymentForHelper.ProjectDonationViaAffiliateProgram
                );
            await _paymentHistoryRepository.CreateAsync(paymentHistory);

            return(new DonateViaAffiliateProgramViewModel
            {
                PaymentUrl = paymentResponse.Data.Url
            });
        }
Example #2
0
        public async Task<DonateViewModel> Handle(DonateCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            await ValidateCommand(command);

			var orderId = command.RequestedUserAccount.Id;

			// If donation is for foundation (command.UserMultiAccountId is null) then we set orderId (id of the user who makes payment) to the requested user ID
			var isDonationForFoundation = command.UserMultiAccountId.HasValue == false;
			var userPaymentForId = isDonationForFoundation ? _rootId : command.UserMultiAccountId.Value;

			var paymentResponse = await _bitBayPayFacade.CreatePayment(orderId, command.Amount);

            ValidateResponse(paymentResponse);

            var paymentHistory = new PaymentHistory(
                id: Guid.NewGuid(),
                paymentId: paymentResponse.Data.PaymentId,
                orderId: orderId,
				userPaymentForId: userPaymentForId,
				amountToPay: command.Amount,
                paymentFor: isDonationForFoundation ? PaymentForHelper.DonationForFoundation : PaymentForHelper.ProjectDonation
            );
            await _paymentHistoryRepository.CreateAsync(paymentHistory);

            return new DonateViewModel
            {
                PaymentUrl = paymentResponse.Data.Url
            };
        }
Example #3
0
        public async Task <string> Handle(PayMembershipsFeeCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            await ValidateCommand(command);

            var orderId         = command.UserAccountDataId;
            var paymentResponse = await _bitBayPayFacade.CreatePayment(orderId, command.Amount);

            ValidateResponse(paymentResponse);

            var paymentHistory = new PaymentHistory(
                id: Guid.NewGuid(),
                paymentId: paymentResponse.Data.PaymentId,
                orderId: orderId,
                userPaymentForId: _rootId,
                amountToPay: command.Amount,
                paymentFor: PaymentForHelper.MembershipsFee
                );
            await _paymentHistoryRepository.CreateAsync(paymentHistory);

            return(paymentResponse.Data.Url);
        }