Error on testing


#1

Hello, I am using python3.9 and django 3.2. I added paynow library via pip. when I try to test with 0771111111 and auth email used to create the paynow account I am getting error called Error: <paynow.model.InitResponse object at 0x7f77fbe866a0>. Kindly help:

paynow = Paynow(
‘ID’,
‘KEY’,
https://example.co.zw’,
https://example.co.zw
)

# Create new payment and pass in the reference and payer's email address
payment = paynow.create_payment('Order', 'auth_email')

# Passing in the name of the item and the price of the item
payment.add('Order', amount_to_pay)

# Save the response from paynow in a variable
response = paynow.send_mobile(payment, eco_num, 'ecocash')
print(response.status)
print(eco_num)

if response.success:
    poll_url = response.poll_url

    print("Poll Url: ", poll_url)

    status = paynow.check_transaction_status(poll_url)
    print("Payment Status: ", status.status)

return HttpResponse(200)

#2

Hi kindly print response.data to get the error from Paynow


#3

response.data is not recognised but response.status is recognised


#4

Your IDE will complain but just print it will show the error.


#5

So it is saying 'InitResponse' object has no attribute 'data' Screenshot%20from%202024-10-25%2008-53-13


#6

Good day.

what version of Paynow SDK are you using

kindly run pip install paynow --upgrade to update to latest version and try to print again