Neurotech-HQ / pypesa

Python wrapper on Mpesa public API for mobile Payment Integration
https://kalebu.github.io/python-pesa/
MIT License
32 stars 10 forks source link

Improve package structure #7

Closed SentinelWarren closed 2 years ago

SentinelWarren commented 2 years ago

Structural and formatting improvements.

Kalebu commented 2 years ago

Hello @SentinelWarren, Thank you looks great but I also begin thinking this update is going to break most of the code that people have already written using the existing structure, what do you think?

and how can we update it in such a way we can cause less trouble

Best regards Kalebu

SentinelWarren commented 2 years ago

I also begin thinking this update is going to break most of the code that people have already written using the existing structure, what do you think?

@Kalebu, I definitely agree with this point, in fact the breaking point is on how Mpesa class is being called, the old way was direct pypesa() and in this refactor is pypesa.Mpesa().

and how can we update it in such a way we can cause less trouble

Well, since i personally think this change is kind of a necessary evil, here are a few suggestions;

  1. Change __init__.py to reflect the old way of calling Mpesa class, i.e pypesa(), the code will then be something like;
    
    import sys
    from pypesa.mpesa import Mpesa

sys.modules[name] = Mpesa


Note: this will break other ways of importing the class, i.e `from pypesa import Mpesa` and the likes will result to `ImportError`.

2. Find a way to make both ways to coexist harmoniously (currently i don't know how to do it).

3. Stick with the new way and force changes from the user's side.

Personally, i would go with both options 1 & 2, the first as a short term solution, and the latter as a long term solution since the first as some bottle necks along the way.

What do you think?
Kalebu commented 2 years ago

@SentinelWarren can you contribute the fixes for payment reversal and DRY violation as separate pull request while we looking for architecture to resolve this ?

SentinelWarren commented 2 years ago

@SentinelWarren can you contribute the fixes for payment reversal and DRY violation as separate pull request while we looking for architecture to resolve this ?

@Kalebu apologies for the late response. Well that i can do, I'll send a pull request as soon as I'm done with the changes.

Kalebu commented 2 years ago

Hello @SentinelWarren, No worries

Looking forward seeing your pull request

best regards Kalebu