コード例 #1
0
        static void Main(string[] args)
        {
            const string username                = "******";
            const string apikey                  = "54a533717fcb1be4577e96ea7a02c1ca9c6e802a56a670379085582ca3c118a7";
            const string productName             = "coolproduct";
            decimal      amount                  = 150M;
            string       currencyCode            = "KES";
            Dictionary <string, string> metadata = new Dictionary <string, string> {
                { "what this is", "cool stuff" }
            };

            var gw = new AfricasTalkingGateway(username, apikey);

            try
            {
                Console.WriteLine("Hello World!");
                StashResponse res = gw.TopupStash(productName, currencyCode, amount, metadata);
                Console.WriteLine(res.ToString());
            }
            catch (AfricasTalkingGatewayException e)
            {
                Console.WriteLine("We had an errror: " + e);
            }

            Console.ReadLine();
        }
コード例 #2
0
        private void FindBobo(StashResponse stashResponse)
        {
            var allAccounts = stashResponse.stashes.Where(s => s.accountName != null).Select(s => s.accountName).ToList();
            var boboExists  = allAccounts.Any(s => s.Equals("ldbob"));

            if (boboExists)
            {
                Console.WriteLine("Found bobo!");
            }
        }
コード例 #3
0
        private void FindHeadhunter(StashResponse stashResponse)
        {
            var a =
                stashResponse.stashes
                .Where(s => s.items.Where(i => i.name.Equals("Headhunter")).Any())
                .ToList();

            foreach (var stash in a)
            {
                Console.WriteLine("Headhunter sold by " + stash.lastCharacterName);
            }
        }
コード例 #4
0
        public void DoTopupStash()
        {
            const string productName             = "coolproduct";
            decimal      amount                  = 150M;
            string       currencyCode            = "KES";
            Dictionary <string, string> metadata = new Dictionary <string, string> {
                { "what this is", "cool stuff" }
            };
            StashResponse stashResponse = _atGWInstance.TopupStash(productName, currencyCode, amount, metadata);
            var           success       = stashResponse.Status == "Success";

            Assert.IsTrue(success, "Should successfully topup product stash");
        }
コード例 #5
0
        public void DoWalletTransfer()
        {
            const int    productCode             = 1234;
            const string productName             = "coolproduct";
            decimal      amount                  = 150M;
            string       currencyCode            = "KES";
            Dictionary <string, string> metadata = new Dictionary <string, string>
            {
                { "mode", "transfer" }
            };

            StashResponse stashResponse = _atGWInstance.WalletTransfer(productName, productCode, currencyCode, amount, metadata);
            var           success       = stashResponse.Status == "Success";

            Assert.IsTrue(success, "Should transfer amounts between wallets");
        }
コード例 #6
0
 public void DelegateMethod(StashResponse stashResponse)
 {
     Console.WriteLine("Fetched " + stashResponse.stashes.Count + " stashes.");
     FindBobo(stashResponse);
     FindHeadhunter(stashResponse);
 }