示例#1
0
        public async Task <PaymentUrlData> GetUrlDataAsync(
            string paymentSystem,
            string transactionId,
            string clientId,
            double fullAmount,
            string assetId,
            string walletId,
            string countryIso3Code,
            string info)
        {
            var cashInPaymentSystem = CashInPaymentSystem.CreditVoucher;
            var serviceUrl          = SelectCreditVouchersService();

            var ownerType = await _ownerTypeService.GetOwnerTypeAsync(walletId);

            if (ownerType == OwnerType.Mt)
            {
                var legalEntity = await _legalEntityService.GetLegalEntityAsync(walletId);

                cashInPaymentSystem = CashInPaymentSystem.Fxpaygate;
                serviceUrl          = SelectFxpaygateService(OwnerType.Mt, legalEntity);
            }
            else if (IsFxpaygateAndSpot(paymentSystem, assetId, countryIso3Code))
            {
                cashInPaymentSystem = CashInPaymentSystem.Fxpaygate;
                serviceUrl          = SelectFxpaygateService(OwnerType.Spot);
            }

            if (!IsPaymentSystemSupported(cashInPaymentSystem, assetId))
            {
                throw new ArgumentException($"Asset {assetId} is not supported by {cashInPaymentSystem} payment system.");
            }

            GetUrlDataResult urlData;

            using (var paymentGatewayService = new PaymentGatewayServiceClient(serviceUrl))
            {
                urlData = await paymentGatewayService.GetUrlData(transactionId, clientId, fullAmount, assetId, info);
            }

            var result = new PaymentUrlData
            {
                PaymentUrl    = urlData.PaymentUrl,
                OkUrl         = urlData.OkUrl,
                FailUrl       = urlData.FailUrl,
                CancelUrl     = JsonConvert.DeserializeObject <OtherPaymentInfo>(info).CancelUrl,
                ReloadRegexp  = urlData.ReloadRegexp,
                UrlsRegexp    = urlData.UrlsRegexp,
                ErrorMessage  = urlData.ErrorMessage,
                PaymentSystem = cashInPaymentSystem,
            };

            return(result);
        }