Skip to content

Commit

Permalink
Merge pull request #170 from vtex-apps/save-card-fix
Browse files Browse the repository at this point in the history
Allow null country code
  • Loading branch information
btalma authored Apr 12, 2024
2 parents 050b417 + 47197fd commit bcc3542
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Allow null country code

## [1.21.1] - 2024-03-18

### Fixed
Expand Down
13 changes: 11 additions & 2 deletions dotnet/Services/CybersourcePaymentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,13 @@ public string RemoveDiacritics(string text)

public string GetCountryCode(string country)
{
return CybersourceConstants.CountryCodesMapping[country];
string retval = string.Empty;
if (!string.IsNullOrEmpty(country))
{
retval = CybersourceConstants.CountryCodesMapping[country];
}

return retval;
}

private string GetCardType(string cardTypeText)
Expand Down Expand Up @@ -2905,7 +2911,10 @@ public async Task<SearchResponse> SearchTransaction(string referenceNumber, Merc
}

SearchResponse searchResponse = await this.SearchTransaction($"{referenceNumber}{orderSuffix}", merchantSettings);
if (searchResponse != null)
if (searchResponse != null &&
searchResponse.Embedded != null &&
searchResponse.Embedded.TransactionSummaries != null &&
searchResponse.Embedded.TransactionSummaries.Count > 0)
{
_context.Vtex.Logger.Warn("GetPaymentStatus", null, "Loaded Transactions from Cybersource", new[] { ("searchResponse", JsonConvert.SerializeObject(searchResponse)) });
// First transaction should be the most recent
Expand Down

0 comments on commit bcc3542

Please sign in to comment.