Пример #1
0
        public async Task <LicensePayment> GetPayment(int licenseId, ApplicationUser user)
        {
            var license = await _licensesRepository.GetLicense(licenseId);

            var licenseType = await _licenseTypesRepository.Get(license.LicenseTypeId);

            var amount  = (int)(license.Price * 100);
            var payment = new LicensePayment
            {
                Currency    = license.Currency,
                Address     = "-",
                Amount      = amount,
                City        = "-",
                Client      = $"{user.FirstName} {user.Surname}",
                Description = LicenseTypeNameResolver.ResolveLicenseTypeName(licenseType),
                Email       = user.Email,
                Language    = "pl",
                Country     = "PL",
                MerchantId  = _paymentsConfiguration.MerchantId,
                PosId       = _paymentsConfiguration.PosId,
                UrlReturn   = _paymentsConfiguration.UrlReturn,
                UrlStatus   = _paymentsConfiguration.UrlStatus,
                SessionId   = license.Id,
                Sign        = _paymentSigner.SignPayment(license.Id, _paymentsConfiguration.MerchantId, amount, license.Currency, _paymentsConfiguration.CRC),
                ZipCode     = "31-001",
                PaymentsUrl = _paymentsConfiguration.PaymentsUrl
            };

            return(payment);
        }
Пример #2
0
        public async Task <LicenseResponseModel> CreateLicense(int licenseTypeId, string userId, int institutionId)
        {
            var type = await _licenseTypesRepository.Get(licenseTypeId);

            switch (type.Kind)
            {
            case LicenseKinds.Coach:
                return(await CreateCoachLicense(licenseTypeId, userId));

            case LicenseKinds.Judge:
                return(await CreateJudgeLicense(licenseTypeId, userId));

            case LicenseKinds.Fighter:
                return(await CreateFighterLicense(licenseTypeId, userId));

            case LicenseKinds.Gym:
                return(await CreateGymLicense(licenseTypeId, institutionId, userId));

            default:
                throw new NotSupportedException();
            }
        }