public string BuyAirtimeLive(string phoneNumber, int amount) { AfricasTalkingGatewayFile gatewayFile = new AfricasTalkingGatewayFile(config.liveUsername, config.liveApiKey, "production"); ArrayList reciepientList = new ArrayList(); Hashtable rec1 = new Hashtable(); rec1["phoneNumber"] = phoneNumber; rec1["amount"] = "NGN " + amount.ToString(); reciepientList.Add(rec1); try { dynamic response = gatewayFile.sendAirtime(reciepientList); messageFromAPI = "Airtime Sent"; return(messageFromAPI); } catch (AfricasTalkingGatewayException ex) { messageFromAPI = "Airtime failed because: " + ex.Message; return(messageFromAPI); } }
public string SingleSMS(string recipient, string messageToSend) { AfricasTalkingGatewayFile gatewayFile = new AfricasTalkingGatewayFile(config.sandboxUsername, config.sandboxApiKey, config.environment); try { dynamic results = gatewayFile.sendMessage(recipient, messageToSend, config.senderID); messageFromAPI = "Message Successfully Sent to " + recipient + "from " + config.senderID; return(messageFromAPI); } catch (AfricasTalkingGatewayException e) { messageFromAPI = "Encountered an error: " + e.Message; return(messageFromAPI); } }