This is for general discussions around integrating Paynow into your Python applications
General Discussion - Python Integration
Hi @admaku. Can you please share the link to the plugin’s repository so we can collaborate on it?
@paynow, is it possible that you can alert us of new changes in the API, I recently encountered a nasty bug which broke everything,
“status.paid” is now “status” type “str” not boolean ), if this is the new standard then please update documentation…And also a suggestion can you please create a repo we can fork.
I am getting this error. ImportError: cannot import name 'Paynow'
. I installed paynow==1.0.4 and i am getting this error when i try importing it. Like:
from paynow import Paynow
Can anyone help?
Here is what i did in my intergration utility ```from paynow import Paynow
from django.conf import settings
from .models import Payment
import json
class PaymentService:
def init(self):
self.paynow = Paynow(
settings.PAYNOW_INTEGRATION_ID,
settings.PAYNOW_INTEGRATION_KEY,
settings.PAYNOW_RETURN_URL,
settings.PAYNOW_RESULT_URL
)
def initiate_payment(self, amount, reference, email, farmer, phone=None, method=None):
if phone.startswith(‘0’):
phone = ‘+263’ + phone[1:]
payment = Payment.objects.create(amount=amount, reference=reference, farmer=farmer)
payment_response = self.paynow.create_payment(reference, email)
payment_response.add('Payment for services', amount)
try:
if method in ['ecocash', 'onemoney', 'innbucks', 'paygo']:
response = self.paynow.send_mobile(payment_response, phone, method)
elif method in ['vmc', 'zimswitch']:
response = self.paynow.send(payment_response)
else:
return {'success': False, 'message': 'Invalid payment method selected.'}
if response.success:
payment.status = 'Pending'
payment.save()
return {
'success': True,
'payment_url': response.redirect_url,
'poll_url': response.poll_url
}
else:
print(f"Error received from Paynow API: {response.error} (type: {type(response.error)})")
error_message = str(response.error) if isinstance(response.error, str) else repr(response.error)
return {'success': False, 'message': error_message}
except Exception as e:
print(f"Error initiating payment: {e}")
return {'success': False, 'message': f"Internal error: {str(e)}"}``` but i am having error and it not showing the exact errror ```{"success": false, "message": "<class 'str'>"}``` how best can i resolve this?