Skip to content

Commit

Permalink
Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
IliyanIlievPH committed May 14, 2020
1 parent 5e92661 commit d0191dc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public interface IPartnerIntegrationPropertiesService
List<IntegrationProperty> GetIntegrationProperties();

Task<PayrexxIntegrationProperties> FetchPropertiesAsync(Guid partnerId);

PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(string paymentIntegrationProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="MAVN.Service.CustomerProfile.Client" Version="1.2.0" />
<PackageReference Include="MAVN.Service.CustomerProfile.Client" Version="1.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MAVN.Service.PayrexxIntegration.Domain\MAVN.Service.PayrexxIntegration.Domain.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,34 @@ public async Task<PayrexxIntegrationProperties> FetchPropertiesAsync(Guid partne
if (partnerIntegrationProperties.ErrorCode != PaymentProviderDetailsErrorCodes.None)
return new PayrexxIntegrationProperties { ErrorCode = IntegrationPropertiesErrorCode.PartnerConfigurationNotFound };

var jobj = (JObject)JsonConvert.DeserializeObject(partnerIntegrationProperties.PaymentProviderDetails.PaymentIntegrationProperties);
return DeserializePayrexxIntegrationProperties(partnerIntegrationProperties.PaymentProviderDetails.PaymentIntegrationProperties);
}

public PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(string paymentIntegrationProperties)
{
JObject jobj;
try
{
jobj = (JObject)JsonConvert.DeserializeObject(paymentIntegrationProperties);
}
catch
{
return new PayrexxIntegrationProperties
{
ErrorCode = IntegrationPropertiesErrorCode.Fail
};
}

var instance = jobj[Constants.InstanceJsonProperty]?.ToString();

if (string.IsNullOrWhiteSpace(instance))
return new PayrexxIntegrationProperties { ErrorCode = IntegrationPropertiesErrorCode.PartnerConfigurationPropertyIsMissing };
{
return new PayrexxIntegrationProperties
{
ErrorCode = IntegrationPropertiesErrorCode.PartnerConfigurationPropertyIsMissing
};
}

var apiKey = jobj[Constants.ApiKeyJsonProperty]?.ToString();

return new PayrexxIntegrationProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ public Task<List<string>> GetPaymentIntegrationSupportedCurrenciesAsync()
[ProducesResponseType(typeof(CheckIntegrationErrorCode), (int)HttpStatusCode.OK)]
public async Task<CheckIntegrationErrorCode> CheckPaymentIntegrationAsync([FromBody] CheckPaymentIntegrationRequest request)
{
var integrationProperties = await _partnerIntegrationPropertiesFetcherService.FetchPropertiesAsync(request.PartnerId);
var integrationProperties = string.IsNullOrEmpty(request.PaymentIntegrationProperties)
? await _partnerIntegrationPropertiesFetcherService.FetchPropertiesAsync(request.PartnerId)
: _partnerIntegrationPropertiesFetcherService.DeserializePayrexxIntegrationProperties(
request.PaymentIntegrationProperties);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="LykkeBiz.Sdk" Version="1.0.0" />
<PackageReference Include="MAVN.Service.PaymentIntegrationPlugin.Client" Version="1.11.0" />
<PackageReference Include="MAVN.Service.PaymentIntegrationPlugin.Client" Version="1.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.14.0" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit d0191dc

Please sign in to comment.