Get Umbraco Certified in October

5 courses in 4 different countries across 2 continents leaves no excuse.

Attend courses in the Netherlands, UK, USA and at Umbraco HQ in Denmark.

See the schedule and read more about our training here.

Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

These support forums are now closed for new topics and comments.
Please head on over to for support.

  • Simon Dingley 849 posts 1722 karma points
    Sep 26, 2011 @ 17:32
    Simon Dingley

    ISO 3166-1 numeric codes

    Finishing up the first stages of the HSBC Payment Provider and I need to pass through the numeric country code to the service which is currently not available through the API or as far as I can tell the .Net Framework, only the alpha codes. 

    Looking for advice on the best way to implement this since I am sure they will not be the only payment provider using this method of country identification?

    Thanks, Simon

  • Søren Spelling Lund2691 karma points
    Sep 26, 2011 @ 18:04
    Søren Spelling Lund

    I had a similar challenge when I did our license store. I ended up doing an extension method for country, which maps country codes from a lookup structure. 

  • Simon Dingley1722 karma points
    Sep 26, 2011 @ 18:22
    Simon Dingley

    Something you're willing to share? Is this something that may be included OOTB in the future?

    Thanks, Simon

  • Søren Spelling Lund2691 karma points
    Sep 26, 2011 @ 19:37
    Søren Spelling Lund

    In my case my requirement was slightly different: I needed to figure out whether any given ISO code belongs to the EU, but the idea is the same.

    Here the extension I did:

    public static string GetCountryCode(this Country country)
        IDictionary<string, string> countryCodesInEu = new Dictionary<string, string>
                {"Denmark", "DK"},
                {"Austria", "AT"},
                {"Belgium", "BG"},
                {"Cyprus", "CY"},
                {"Switzerland", "CZ"},
                {"Germany", "DE"},
                {"Estonia", "EE"},
                {"Spain", "ES"},
                {"Finland", "FI"},
                {"France", "FR"},
                {"United Kingdom", "GB"},
                {"Greece", "GR"},
                {"Hungary", "HU"},
                {"Ireland", "IE"},
                {"Italy", "IT"},
                {"Luxembourg", "LU"},
                {"Latvia", "LV"},
                {"Malta", "MT"},
                {"Netherlands", "NL"},
                {"Poland", "PL"},
                {"Portugal", "PT"},
                {"Romania", "RO"},
                {"Sweden", "SE"},
                {"Solvenia", "SI"},
                {"Solvakia", "SK"},
        if (countryCodesInEu.Keys.Contains(country.Name))
            return countryCodesInEu[country.Name];
        return null;
Please Sign in or register to post replies

Write your reply to:

Draft is the community mothership for Umbraco, the open source cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.3.0