AttributeError: 'module' object has no attribute 'postDirectOrder'
Question: I'm trying to use this python package <https://pypi.python.org/pypi/pesapal>
in one of my projects.

But I noticed that for some weird reason the author stuffed all the logic in
the [`__init__.py` file](https://github.com/kelonye/python-
pesapal/blob/master/lib/__init__.py) which doesn't make sense to me, but hey..

So when I try to use the package I get the following error:

    
    
    'module' object has no attribute 'postDirectOrder
    

I'm on Python 2.7.7, I've tried `from pesapal import *` but no luck. I tried:

    
    
    >>> from pesapal import PesaPal
    >>> url = PesaPal.postDirectOrder(post_params, request_data)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unbound method postDirectOrder() must be called with PesaPal instance as first argument (got dict inst
    ance instead)
    


Answer: The 0.3 release differs significantly from later code; it contains a _class_
`PesaPal()` which takes `consumer_key` and `consumer_secret` arguments:

    
    
    pp = PesaPal(key, secret)
    url = pp.postDirectOrder(post_params, request_data)
    

The project never correctly tagged the 0.3 release, but there is a [0.3
release commit](https://github.com/kelonye/python-
pesapal/commit/1a7848fc84d7277e7faa9c697bd1455761ed996c#diff-d41d8cd98f00b204e9800998ecf8427e);
you can [browse the source tree at that
commit](https://github.com/kelonye/python-
pesapal/tree/1a7848fc84d7277e7faa9c697bd1455761ed996c) to get an idea of what
is expected.

The project README there includes an example:

>
>     import pesapal, urllib2
>  
>     consumer_key ='consumer_key'
>     consumer_secret = 'consumer_secret'
>     testing = False
>  
>     ### make client
>     client = pesapal.PesaPal(consumer_key, consumer_secret, testing)
>  
>     ### post a direct order
>  
>     request_data = {
>       'Amount': '',
>       'Description': '',
>       'Type': '',
>       'Reference': '',
>       'PhoneNumber': ''
>     }
>     post_params = {
>       'oauth_callback': 'www.example.com/post_payment_page'
>     }
>     request = client.postDirectOrder(post_params, request_data)
>     # get url to display as an iframe
>     print request.to_url()
>  

