{"id":2837,"date":"2022-07-13T21:33:15","date_gmt":"2022-07-13T21:33:15","guid":{"rendered":"https:\/\/www.reloadly.com\/blog\/?p=2837"},"modified":"2022-07-13T21:33:16","modified_gmt":"2022-07-13T21:33:16","slug":"airtime-c-quickstart","status":"publish","type":"post","link":"https:\/\/blog.reloadly.com\/blog\/airtime-c-quickstart\/","title":{"rendered":"Airtime C# Quickstart"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_46 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"ez-toc-toggle-icon-1\"><label for=\"item-69d2b69257d16\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #000000;color:#000000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #000000;color:#000000\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-69d2b69257d16\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-visibility-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-c-quickstart\/#Get_an_access_token\" title=\"Get an access token\">Get an access token<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.reloadly.com\/blog\/airtime-c-quickstart\/#Make_an_airtime_or_data_top-up\" title=\"Make an airtime or data top-up\">Make an airtime or data top-up<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>This quick start will guide you through integrating Reloadly\u2019s Airtime API into your C# application. Prerequisites needed for this guide are:<\/p>\n\n\n\n<ul><li>The reader should have a decent understanding of C#.<\/li><li>A Reloadly account &#8211; if you don\u2019t have one, you can sign up <a href=\"https:\/\/www.reloadly.com\/registration\">here<\/a><\/li><li>Next, you need to have funds in your test wallet. When you sign up, a certain amount of funds are automatically added to your test wallet. You can fund your live wallet by following the steps in the <a href=\"https:\/\/developers.reloadly.com\/wallet\">Wallet<\/a> section<\/li><li>Sign in to retrieve your <strong>client_id<\/strong> and <strong>client_secret<\/strong> keys for test mode. You can get both keys by toggling from live to test mode on the sidebar and navigating to <strong>Developers &gt; API<\/strong> settings<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Get_an_access_token\"><\/span>Get an access token<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Reloadly issues access tokens (also called bearer tokens) that are used to authorize API requests. Using your test <strong>client_id<\/strong> and <strong>client_secret<\/strong>, make a request to Reloadly\u2019s authorization URL to obtain the appropriate access token. You can get a test access token by making a request in your C# application like this<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\r\nusing System.Net.Http;\r\nusing System.Threading.Tasks;\r\nusing System.Text;\r\nusing Newtonsoft.Json.Linq;\r\n \r\npublic class Program\r\n{\r\n  public static async Task Main(string&#091;] args)\r\n  {\r\n    using (var client = new HttpClient())\r\n    {\r\n      JObject json = JObject.Parse(@\"{\r\n        client_id: 'qwcLzXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',\r\n        client_secret: '7kscVxQZ32-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',\r\n        grant_type: 'client_credentials',\r\n        audience: 'https:\/\/topups-sandbox.reloadly.com'\r\n      }\");\r\n      var postData = new StringContent(json.ToString(), Encoding.UTF8, \"application\/json\");\r\n      var request = await client.PostAsync(\"https:\/\/auth.reloadly.com\/oauth\/token\", postData);\r\n      var response = await request.Content.ReadAsStringAsync();\r\n \r\n      Console.WriteLine(response);\r\n    }\r\n  }\r\n}\r<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Production access tokens are valid for 60 days, test access tokens are only valid for 24 hours.<\/p>\n\n\n\n<p>If your request is successful, you should get the following response.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>{\r\n    \"access_token\": \"eyJraWQiOiI1N2JjZjNhNy01YmYwLTQ1M2QtODQ0Mi03ODhlMTA4OWI3MDIiLCJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2NzkzIiwiaXNzIjoiaHR0cHM6Ly9yZWxvYWRseS1zYW5kYm94LmF1dGgwLmNvbS8iLCJodHRwczovL3JlbG9hZGx5LmNvbS9zYW5kYm94Ijp0cnVlLCJodHRwczovL3JlbG9hZGx5LmNvbS9wcmVwYWlkVXNlcklkIjoiNjc5MyIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyIsImF1ZCI6Imh0dHBzOi8vdG9wdXBzLWhzMjU2LXNhbmRib3gucmVsb2FkbHkuY29tIiwibmJmIjoxNjU0MDgzNjY3LCJhenAiOiI2NzkzIiwic2NvcGUiOiJzZW5kLXRvcHVwcyByZWFkLW9wZXJhdG9ycyByZWFkLXByb21vdGlvbnMgcmVhZC10b3B1cHMtaGlzdG9yeSByZWFkLXByZXBhaWQtYmFsYW5jZSByZWFkLXByZXBhaWQtY29tbWlzc2lvbnMiLCJleHAiOjE2NTQxNzAwNjcsImh0dHBzOi8vcmVsb2FkbHkuY29tL2p0aSI6IjYwMTY4ODNiLWYxYTgtNGJhMy1hNmM3LWIwNjBkNDRmN2EyMCIsImlhdCI6MTY1NDA4MzY2NywianRpIjoiZGUwNzRlM2QtM2JkYi00N2ExLTkzNDktZTk1YmZiNjZlNGVmIn0.ZXUzCYbCCTzpDMr5hP7YvgWYqniy9kBY0Y5vWS8wRrA\",\r\n    \"scope\": \"developer\",\r\n    \"expires_in\": 86400,\r\n    \"token_type\": \"Bearer\"\r\n}\r<\/code><\/pre>\n\n\n\n<div style=\"height:41px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Make_an_airtime_or_data_top-up\"><\/span><strong>Make an airtime or data top-up<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now that you have an access token, you can make an airtime or data top-up with the Airtime API. You can find details for the operator of your choice on your Reloadly dashboard by navigating on the sidebar to the <strong>Pricing &gt; Airtime<\/strong> section.<\/p>\n\n\n\n<p>In the examples below, we are using a mobile number and an operator registered in the United Arab Emirates to show how making an airtime top-up works in a C# application.<\/p>\n\n\n\n<div style=\"height:38px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\r\nusing System.Net.Http;\r\nusing System.Threading.Tasks;\r\nusing System.Text;\r\nusing Newtonsoft.Json.Linq;\r\n \r\npublic class Program\r\n{\r\n  public static async Task Main(string&#091;] args)\r\n  {\r\n    using (var client = new HttpClient())\r\n    {\r\n      client.DefaultRequestHeaders.Add(\"Authorization\", \"Bearer &lt;YOUR_TOKEN_HERE&gt;\");\r\n      JObject json = JObject.Parse(@\"{\r\n        operatorId: 1100,\r\n        amount: 832,\r\n        useLocalAmount: false,\r\n        customIdentifier: 'airtime-top-up',\r\n        recipientEmail: 'jeanb@reloadly.com',\r\n        recipientPhone: {\r\n          countryCode: 'AE',\r\n          number: '0503971821'\r\n        },\r\n        senderPhone: {\r\n          countryCode: 'CA',\r\n          number: '11231231231'\r\n        }\r\n      }\");\r\n      var postData = new StringContent(json.ToString(), Encoding.UTF8, \"application\/json\");\r\n      var request = await client.PostAsync(\"https:\/\/topups-sandbox.reloadly.com\/topups\", postData);\r\n      var response = await request.Content.ReadAsStringAsync();\r\n \r\n      Console.WriteLine(response);\r\n    }\r\n  }\r\n}\r<\/code><\/pre>\n\n\n\n<div style=\"height:44px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If your request is successful, you should receive a response from Reloadly<\/p>\n\n\n\n<div style=\"height:39px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>{\r\n    \"transactionId\": 33469,\r\n    \"status\": \"SUCCESSFUL\",\r\n    \"operatorTransactionId\": null,\r\n    \"customIdentifier\": \"airtime-top-up\",\r\n    \"recipientPhone\": \"971503971821\",\r\n    \"recipientEmail\": null,\r\n    \"senderPhone\": \"11231231231\",\r\n    \"countryCode\": \"AE\",\r\n    \"operatorId\": 1100,\r\n    \"operatorName\": \"Etisalat United Arab Emirates\",\r\n    \"discount\": 41.6,\r\n    \"discountCurrencyCode\": \"NGN\",\r\n    \"requestedAmount\": 832,\r\n    \"requestedAmountCurrencyCode\": \"NGN\",\r\n    \"deliveredAmount\": 5.6,\r\n    \"deliveredAmountCurrencyCode\": \"AED\",\r\n    \"transactionDate\": \"2022-06-06 10:57:48\",\r\n    \"pinDetail\": null,\r\n    \"balanceInfo\": {\r\n        \"oldBalance\": 809811.69103,\r\n        \"newBalance\": 809021.29103,\r\n        \"cost\": 790.4,\r\n        \"currencyCode\": \"NGN\",\r\n        \"currencyName\": \"Nigerian Naira\",\r\n        \"updatedAt\": \"2022-06-06 14:57:48\"\r\n    }\r\n}\r<\/code><\/pre>\n\n\n\n<div style=\"height:37px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If you made it to this point, you have successfully made your first top-up in a C# application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This quick start will guide you through integrating Reloadly\u2019s Airtime API into your C# application. Prerequisites needed for this guide are: The reader should have a decent understanding of C#. A Reloadly account &#8211; if you don\u2019t have one, you can sign up here Next, you need to have funds in your test wallet. When<\/p>\n","protected":false},"author":17,"featured_media":2689,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[274],"tags":[11,277,414,282],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Airtime C# Quickstart - Reloadly<\/title>\n<meta name=\"description\" content=\"Reloadly Resources. Insights, Info and Analysis For The Mobile Airtime API Community\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Airtime C# Quickstart - Reloadly\" \/>\n<meta property=\"og:description\" content=\"Reloadly Resources. Insights, Info and Analysis For The Mobile Airtime API Community\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\" \/>\n<meta property=\"og:site_name\" content=\"Reloadly\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-13T21:33:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-13T21:33:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2022\/05\/api-benefits-for-business.png\" \/>\n\t<meta property=\"og:image:width\" content=\"641\" \/>\n\t<meta property=\"og:image:height\" content=\"334\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\",\"name\":\"Reloadly\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2020\/11\/logo-1.svg\",\"width\":100,\"height\":100,\"caption\":\"Reloadly\"},\"image\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#website\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"name\":\"Reloadly\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.reloadly.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.reloadly.com\/blog\/wp-content\/uploads\/2022\/05\/api-benefits-for-business.png\",\"width\":641,\"height\":334},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#webpage\",\"url\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\",\"name\":\"Airtime C# Quickstart - Reloadly\",\"isPartOf\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#primaryimage\"},\"datePublished\":\"2022-07-13T21:33:15+00:00\",\"dateModified\":\"2022-07-13T21:33:16+00:00\",\"description\":\"Reloadly Resources. Insights, Info and Analysis For The Mobile Airtime API Community\",\"breadcrumb\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/\",\"url\":\"https:\/\/www.reloadly.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\",\"url\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/\",\"name\":\"Airtime C# Quickstart\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#\/schema\/person\/2400042054e3b3009489e487224a6984\"},\"headline\":\"Airtime C# Quickstart\",\"datePublished\":\"2022-07-13T21:33:15+00:00\",\"dateModified\":\"2022-07-13T21:33:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#primaryimage\"},\"keywords\":\"airtime,api,C-sharp,developer\",\"articleSection\":\"Developer Blog\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.reloadly.com\/blog\/airtime-c-quickstart\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#\/schema\/person\/2400042054e3b3009489e487224a6984\",\"name\":\"Raphael Ugwu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.reloadly.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/656844c0101d37e5695eee915ed3a49d?s=96&d=mm&r=g\",\"caption\":\"Raphael Ugwu\"},\"url\":\"https:\/\/blog.reloadly.com\/blog\/author\/fullstackmafia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","authors":[{"term_id":359,"user_id":17,"is_guest":0,"slug":"fullstackmafia","display_name":"Raphael Ugwu"}],"_links":{"self":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2837"}],"collection":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/comments?post=2837"}],"version-history":[{"count":1,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2837\/revisions"}],"predecessor-version":[{"id":2838,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/posts\/2837\/revisions\/2838"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/media\/2689"}],"wp:attachment":[{"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/media?parent=2837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/categories?post=2837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.reloadly.com\/blog\/wp-json\/wp\/v2\/tags?post=2837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}