public async Task <ConfirmationResultModel> ConfirmInPublicAsync(string privateAddress)
        {
            #region Validation

            if (string.IsNullOrEmpty(privateAddress))
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.InvalidPrivateAddress));
            }

            var linkRequest = await _requestsRepository.GetByPrivateAddressAsync(privateAddress);

            if (linkRequest == null)
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestDoesNotExist));
            }

            if (linkRequest.IsPendingApproval())
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestHasNotBeenApproved));
            }

            if (linkRequest.IsConfirmedInPublic)
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestAlreadyConfirmed));
            }

            #endregion

            await _requestsRepository.SetPubliclyConfirmedAsync(linkRequest.CustomerId);

            _log.Info("Link request has been confirmed in public blockchain", new { linkRequest.CustomerId });

            if (linkRequest.IsConfirmedInPrivate)
            {
                await _finalizedPublisher.PublishAsync(new WalletLinkingStatusChangeFinalizedEvent
                {
                    PrivateAddress = linkRequest.PrivateAddress,
                    PublicAddress  = linkRequest.PublicAddress
                });

                _log.Info("The wallet linking has been finalized", new { linkRequest.CustomerId });
            }
            else
            {
                _log.Error(
                    message: "The wallet linking transaction has been confirmed in public blockchain but not confirmed in private blockchain yet",
                    context: new { linkRequest.CustomerId, linkRequest.PrivateAddress, linkRequest.PublicAddress });
            }

            return(ConfirmationResultModel.Succeeded());
        }
        public async Task <ConfirmationResultModel> ConfirmInPrivateAsync(string privateAddress)
        {
            #region Validation

            if (string.IsNullOrEmpty(privateAddress))
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.InvalidPrivateAddress));
            }

            var linkRequest = await _requestsRepository.GetByPrivateAddressAsync(privateAddress);

            if (linkRequest == null)
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestDoesNotExist));
            }

            if (linkRequest.IsPendingApproval())
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestHasNotBeenApproved));
            }

            if (linkRequest.IsConfirmedInPrivate)
            {
                return(ConfirmationResultModel.Failed(ConfirmationError.LinkRequestAlreadyConfirmed));
            }

            #endregion

            await _requestsRepository.SetPrivatelyConfirmedAsync(linkRequest.CustomerId);

            _log.Info("Link request has been confirmed in private blockchain", new { linkRequest.CustomerId });

            await _completedPublisher.PublishAsync(new WalletLinkingStatusChangeCompletedEvent
            {
                CustomerId     = linkRequest.CustomerId,
                PublicAddress  = linkRequest.PublicAddress,
                PrivateAddress = linkRequest.PrivateAddress,
                EventId        = Guid.NewGuid().ToString(),
                Fee            = linkRequest.Fee ?? 0
            });

            return(ConfirmationResultModel.Succeeded());
        }
Ejemplo n.º 3
0
        public ActionResult ConfirmationService(string orderRef, string orderAmount, string chargeAmount)
        {
            var model = new ConfirmationResultModel();
            ConfirmationRequest request = new ConfirmationRequest();

            request.MERCHANT       = "OPU_TEST";
            request.ORDER_REF      = orderRef;
            request.ORDER_AMOUNT   = orderAmount;
            request.ORDER_CURRENCY = "TRY";
            request.IDN_DATE       = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
            request.CHARGE_AMOUNT  = chargeAmount;
            Options options = new Options();

            options.Url       = "https://secure.payu.com.tr/order/idn.php";
            options.SecretKey = "SECRET_KEY";
            var response = ConfirmationRequest.Execute(request, options); //konfirmasyon servisi servis çağrısı başlatıldığı kısım.

            model.Response = response;
            return(View(model));
        }