Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
It seems we can only specify the 2 char country code? The payment gateway we are working with requires the 3 char code.
I can do a lookup as we're only targeting UK at the moment and then possibly USA soon after. But I can see it being a problem for global sites.
I think in this case I would suggest you do the conversion in the payment provider as allowing the stored code to be changeable could have adverse effects on code that expects it in the 2 letter format (ie, I think consistency is more beneficial than flexibility here).
With that being the case you have 2 options really. Store a hard coded lookup table of 2 to 3 letter ISO3166 codes. Or potentially look at using CultureInfo to do it dynamically
public string ConvertTwoLetterNameToThreeLetterName(string name)
if (name.Length != 2)
throw new ArgumentException("name must be two letters.");
name = name.ToUpper();
var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (var culture in cultures)
var region = new RegionInfo(culture.LCID);
if (region.TwoLetterISORegionName.ToUpper() == name)
This is modified from a stack overflow post which has some good other alternatives too https://stackoverflow.com/questions/4884692/converting-country-codes-in-net
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted