Giter VIP home page Giter VIP logo

africastalking.net's People

Contributors

aksalj avatar allanwenzs avatar georgeouma avatar jcardif avatar njuru007 avatar patrick-kings avatar thebeachmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

africastalking.net's Issues

Patch

Add Features:

  • Wallet transfer
  • Topup stash
  • Query Transaction ID,Wallet Balance, Product transactions, Wallet balance

Improvements:
Docs -> USSD Application
Docs -> Voice Application

Patch:
Add test cases

Wallet Balance

When fetching wallet balance for a user account, as indicated on the ReadMe doesn't work anymore;

**string fetchBalanceResponse = _atGWInstance.FetchWalletBalance();
JObject fetchBalanceResponseJson = JObject.Parse(fetchBalanceResponse);**

Instead, parse dynamic JSON
dynamic res = gw.GetUserData(); Console.WriteLine(res.UserData.balance);
This will give for example Ksh. 600.56

The message is either empty or phone number is not valid - with valid phone number

Sometimes I'm getting the following error message from your library: "The message is either empty or phone number is not valid", but the number is valid and exists, for example for number "+254111604133".

Is there something wrong with your logic which validates the phone number?

I'm using the AfricasTalking.NET in version 1.1.720.

Framework for handling ussd

Hi Team

how about building a framework to support the menu navigation and data handling

its more on the way we build websites these days ie MVC

in that way the user or other devs will use the ussd to focus on problem-solving rather than handling the routing and menu options etc

Priority:Low

Library Depreciated

Why don't you update library to fully support .net core/asp.net core 3.0, 3.1 ?

image

image

More robust phone number validation

private static bool IsPhoneNumber(string[] number)
        {
            bool valid = true;
            foreach (string num in number)
            {
               var status = Regex.Match(num, @"^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d{5,}$").Success;
                valid = valid & status;
            }
            return valid;
        }

Have looked at this method of validating numbers.
I would suggest use libphonenumber-csharp to enable Parsing/formatting/validating phone numbers for all countries.
It has nice goodies backed right in.
Test it here

Getting error Unexpected character encountered while parsing value: T. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue()

I am using .net core web api as my callback

My initiating logic test app is

const string Username = "myusername";
            const string Apikey = "myapikey";
            var gateway = new AfricasTalkingGateway(Username, Apikey);
            string tokenId = "tkn";
            const string PhoneNumber = "+..";  my kenya number
            const string Menu = "CON You're about to love C#\n1.Accept my fate\n2.No Never\n";

            // Let's create a checkout token  first
            try
            {
                var tkn = gateway.CreateCheckoutToken(PhoneNumber);
                if (tkn["description"] == "Success")
                {
                    tokenId = tkn["token"];
                }

                // Then send user menu...
                var prompt = gateway.InitiateUssdPushRequest(PhoneNumber, Menu, tokenId);
                if (prompt["errorMessage"] == "None")
                {
                    Console.WriteLine("Awesome");
                }
            }
            catch (AfricasTalkingGatewayException ex)
            {
                Console.WriteLine("Woopsies : " + ex.Message);
            }

My controller logic is as following

[Route("[controller]/[action]")]
[Produces("text/plain")]
public class USSDServiceController : Controller
{
public static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
[HttpPost]
public IActionResult Process([FromForm] [FromBody] UssdResponse ussdResponse)
{

        IActionResult responseMessage;
        string response;
        Logger.Debug("Revieved Rrquest Process");

        if (ussdResponse != null)
        {
            Logger.DebugFormat("Request content {0},{1},{2},{3}", ussdResponse.phoneNumber, ussdResponse.serviceCode, ussdResponse.sessionId, ussdResponse.text);

            if (ussdResponse.text == null)
            {
                ussdResponse.text = "";
            }

            if (ussdResponse.text.Equals("", StringComparison.Ordinal))
            {
                response = "CON USSD Demo in Action\n";
                response += "1. Do something\n";
                response += "2. Do some other thing\n";
                response += "3. Get my Number\n";
            }
            else if (ussdResponse.text.Equals("1", StringComparison.Ordinal))
            {
                response = "END I am doing something \n";
            }
            else if (ussdResponse.text.Equals("2", StringComparison.Ordinal))
            {
                response = "END Some other thing has been done \n";
            }
            else if (ussdResponse.text.Equals("3", StringComparison.Ordinal))
            {
                response = $"END Here is your phone number : {ussdResponse.phoneNumber} \n";
            }
            else
            {
                response = "END Invalid option \n";
            }
        }
        else
        {
            Logger.Debug("Empty response");
            response = "END Invalid request \n";
        }
       responseMessage = StatusCode((int)HttpStatusCode.Created, response);
        return responseMessage;
    }
}


public class UssdResponse
{
    public string text { get; set; }
    public string phoneNumber { get; set; }
    public string sessionId { get; set; }
    public string serviceCode { get; set; }

}			

C2B Transactions

Issue :

Developers passing Athena as an argument for sandbox C2B transactions.

Fix:

When a sandbox product is created,it should be manually assigned a channel by clicking Add Channel on the product Action Menus: the ... next to the product name
chnladd

AfricasTalkingCS.AfricasTalkingGatewayException Message : The message is either empty or phone number is not valid

at AfricasTalkingCS.AfricasTalkingGateway.SendMessage(String to, String message, String from, Int32 bulkSmsMode, Hashtable options)

This Exception is thrown only with multiple recipients in the list
Code attached..

using AfricasTalkingCS;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Smsing
{
    class Program
    {
        static void Main(string[] args)
        {
            // Specify your login credentials
            string username = ConfigurationManager.AppSettings["username"];
            string apiKey = ConfigurationManager.AppSettings["apiKey"];
            const string env = "sandbox"; // For sandbox users

            // Specify the numbers that you want to send to in a comma-separated list
            // Please ensure you include the country code (+254 for Kenya in this case)
            string recipients = "+254708440184,+254715359478";
            //string recipients = "+254715359478";
            // And of course we want our recipients to know what we really do
            string message = "Trying multiple send sms";

            // Create a new instance of our awesome gateway class
            var gateway = new AfricasTalkingGateway(username, apiKey, env);

            string from = null; //$from = "shortCode or senderId";

            int bulkSMSMode = 1; // This should always be 1 for bulk messages

            Hashtable options = new Hashtable();
            options["enqueue"] = 1;

            // Any gateway errors will be captured by our custom Exception class below,
            // so wrap the call in a try-catch block   
            try
            {
                var sms = gateway.SendMessage(recipients, message, from, bulkSMSMode, options);
                foreach (var res in sms["SMSMessageData"]["Recipients"])
                {
                    Console.WriteLine((string)res["number"] + ": ");
                    Console.WriteLine((string)res["status"] + ": ");
                    Console.WriteLine((string)res["messageId"] + ": ");
                    Console.WriteLine((string)res["cost"] + ": ");
                }

                Console.ReadLine();
            }
            catch (AfricasTalkingGatewayException exception)
            {
                Console.WriteLine(exception);
            }
            Console.ReadLine();
        }
    }
}

.Net Core Support

Kindly consider updating the library to be supported by .Net Core

Possible NullReference Exception

if (phoneNumber.Length == 0 || shortCode.Length == 0 || keyWord.Length == 0 || !IsPhoneNumber(numbers))

Hi, this check will fail when a string in null since you can't call .Length on a null string object.

I would suggest using String.IsNullOrWhiteSpace(String) to do the check.

You can create a test case wherein you pass null for phoneNumber/shortCode/keyWord and see that a NullObjectReferenceException is thrown instead of the anticipated AfricasTalkingGatewayException

feat : return JSON

Return all API responses as JSON objects.
{ APIResponse : { "stuff: : "stuff_value", "some" : "more_stuff" } }

B2C - MobileB2CRecepient providerChannel Missing

providerChannel String Optional: The channel the payment will be made from e.g a paybill number. The payment channel must be mapped to your Africa’s Talking payment product. If not specified, a default provider channel will be used.

that is missing from the MobileB2CRecepient object.

ASP.NET Core API Not working with Africa's Talking USSD Service

I created a dotnet core API to provide the callback URL for the USSD Service. But the API does not work the USSD Services gives the error below:
image

My controller is designed as follows:

 [Route("api/[controller]")]
    [ApiController]
    public class ServicesController : ControllerBase
    {
        [Route("ussd")]
        [HttpPost]
        public IActionResult USSDService([FromBody] USSDResponse serviceResponse)
        {

        }
    }

However the USSD service works when the method is changed as follows:

        public IActionResult USSDService(string serviceResponse)
        {

        }

But the issue is that no object is passed from the USSD Service to this method

Configure callback url on dashboard

Hello, I implemented initiateussdpushrequest on my codebase and tried debugging but i was getting a failed response to configure callback url on my dashboard. I have created a channel and registered a callback url on the test sandbox. What could be the issue? Kindly help resolve

docs : document responses

1 Add sample JSON responses from API.
2. Fold sample code using <summary> tag on Markdown

Some Summary like code

{apiSays : { "stuff" : "sent_from_api", "more" : "stuff" } }

var sampleCode = this.Display(sample);  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.