AttributeError at /callback/ module 'zeep.client' has no attribute 'service'

Question:

when I want to use the zeep package in django for the payment gateway, I face an error.
error image,
code image

callback function in views.py in shop app:

# Callback function
def callback(request):
    if request.GET.get('Status') == 'NOK':
        authority = request.GET.get('authority')
        invoice = get_object_or_404(models.Invoice, authority=authority)
        amount = 0
        order = invoice.order
        order_items = models.OrderItem.objects.filter(order=order)
        for item in order_items:
            amount += item.product_cost
        result = client.service.PaymentVerification(MERCHANT, authority, amount)
        if result.Status == 100:
            return render(request, 'callback.html', {'invoice': invoice})
        else:
            return HttpResponse('error ' + str(result.Status))
    else:
        return HttpResponse('error ')
Asked By: Hamed 3dart

||

Answers:

The zeep documentation shows that the object client must be initialized as shown in the example listed on the site:

from zeep import Client, Settings

settings = Settings(strict=False, xml_huge_tree=True)
client = Client('http://my-wsdl/wsdl', settings=settings)

I suspect you either made a typo in defining it or just never did.

Answered By: Blye
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.