示例#1
0
        public async Task <CheckIntegrationErrorCode> CheckPaymentIntegrationAsync([FromBody] CheckPaymentIntegrationRequest request)
        {
            var integrationProperties = await _partnerIntegrationPropertiesFetcherService.FetchPropertiesAsync(request.PartnerId);

            if (integrationProperties.ErrorCode != IntegrationPropertiesErrorCode.None)
            {
                return(_mapper.Map <CheckIntegrationErrorCode>(integrationProperties.ErrorCode));
            }

            var client = new PayrexxIntegrationClient(
                integrationProperties.ApiBaseUrl,
                integrationProperties.InstanceName,
                integrationProperties.ApiKey);

            try
            {
                var res = await client.Api.CheckSignatureAsync();

                return(res.Status == "success"
                    ? CheckIntegrationErrorCode.None
                    : CheckIntegrationErrorCode.Fail);
            }
            catch (Exception e)
            {
                _log.Warning(null, exception: e);
                return(CheckIntegrationErrorCode.Fail);
            }
        }
        public async Task <CheckPaymentIntegrationResponse> CheckPaymentIntegrationAsync([FromBody] CheckPaymentIntegrationRequest request)
        {
            var checkResult = await _paymentManagementClient.Api.CheckPaymentIntegrationAsync(new PaymentIntegrationCheckRequest
            {
                PartnerId = request.PartnerId,
                PaymentIntegrationProvider   = request.PaymentIntegrationProvider,
                PaymentIntegrationProperties = request.PaymentIntegrationProperties,
            });

            switch (checkResult)
            {
            case CheckPaymentIntegrationErrorCode.None:
                return(new CheckPaymentIntegrationResponse {
                    IsConfiguredCorrectly = true
                });

            case CheckPaymentIntegrationErrorCode.Fail:
            case CheckPaymentIntegrationErrorCode.PartnerConfigurationNotFound:
            case CheckPaymentIntegrationErrorCode.PartnerConfigurationPropertyIsMissing:
            case CheckPaymentIntegrationErrorCode.PaymentIntegrationProviderIsMissing:
                return(new CheckPaymentIntegrationResponse {
                    IsConfiguredCorrectly = false, Error = checkResult.ToString()
                });

            default:
                throw new ArgumentOutOfRangeException();
            }
        }