Forums

HTTPError: 403 Client Error-- access to pexternal payment provider raise errors

In my current project i use a payment provider that use WebGate service and recently error described bellow happens:

raise HTTPError(http_error_msg, response=self)
2021-04-27 18:58:51,097: Error running WSGI application
2021-04-27 18:58:51,100: requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.zarinpal.com/pg/services/WebGate/wsdl
2021-04-27 18:58:51,100:   File "/usr/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
2021-04-27 18:58:51,100:     response = self.get_response(request)

i use zeep for connect to payment provider, and site and api (https://www.zarinpal.com/pg/services/WebGate/wsdl) already registered in whitelist in this and this post. as seen in stack trace this code: client = Client('https://www.zarinpal.com/pg/services/WebGate/wsdl') where the error occured. Is this a error from payment provider or from host side? any help please

What is the Client? Does it need to be configured to use proxy?

@ fjl, thanks for reply. Client is a part of zeep package and it described here as

A fast and modern Python SOAP client

Check if you need to set up it to use a proxy. You will find proxy detail in 403 Forbidden error | PythonAnywhere help

As i said in first post, address used in client object already added to whitelist and code worked fine with no errors so far. Now what causes this error as I mailed to payment provider about this error and they assured no change happened to service address and it is accessible yet

Inspect the content of the response the you're getting to determine what the cause of the 403 may be.

.

HTTPError(http_error_msg, response=self)
2021-04-27 18:58:51,097: Error running WSGI application
2021-04-27 18:58:51,100: requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.zarinpal.com/pg/services/WebGate/wsdl
2021-04-27 18:58:51,100:   File "/usr/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
2021-04-27 18:58:51,100:     response = self.get_respo

[edit by admin: formatting]

That's just the stack trace -- what is in the content of the HTTPError object? You can find it (assuming that the exception is in a variable called exc) as exc.response.content.

My guess is that the authorization credentials that you are using are being rejected by zarinpal, so the details should be visible there.

@giles, thanks for reply. still that error remained. paymet(zarinpal) support team asked me to run some shell commands in root of my site to check connection between pythonanywhere host and their CDN server, but as my current account is free, i can't run some commands such ping, curl and Traceroute . So is it possible to run that shell command file (linux-zp.sh) in my root directory, so i can send output to support team. if you don't have access to that file, is as bellow:

#!/bin/bash
echo "######################################################"
echo "Ping Result :  "
ping -c 5 www.zarinpal.com |  tee -a "zarinpal-output.txt"
echo "###################################################### "

ping -c 5 185.143.233.5 |  tee -a "zarinpal-output.txt"
echo "###################################################### "

ping -c 5 185.143.234.5   tee -a "zarinpal-output.txt"
echo "###################################################### "

traceroute 185.143.233.5  tee -a "zarinpal-output.txt"
echo "###################################################### "
traceroute 185.143.234.5  tee -a "zarinpal-output.txt"
echo "###################################################### "
echo "DNS  Result :  "
dig www.zarinpal.com    |  tee -a "zarinpal-output.txt"
echo "############################################################################# "
echo "Curl Result"
curl -I "https://www.zarinpal.com" -vv  |  tee -a "zarinpal-output.txt"
echo "########################################################################## "
echo "My Public ip"
dig +short myip.opendns.com @resolver1.opendns.com |  tee -a "zarinpal-output.txt"
echo "##########################################################################"
echo "Please Send Zarinpal-OutPut to Zarinpal's Support Team"

Thanks in advance.

Hi again, they also want me to run these commands and send them result:

curl -I https://www.zarinpal.com -vvv
curl -L www.zarinpal.com - vvv

thanks and, help please

@giles @fjl Is this request is unexpectable or must start a new topic? It's just for debbuging my app and testing purpose. I'm still waiting for your help.

You can run traceroute, dig and curl.

ping is not installed at the moment.

@fjl Thanks alot

what you suggest instead of ping command.

I've run those ping commands for you -- the output is below:

# ping -c 5 www.zarinpal.com
PING www.zarinpal.com (185.215.234.5) 56(84) bytes of data.
64 bytes from 185.215.234.5 (185.215.234.5): icmp_seq=1 ttl=34 time=24.8 ms
64 bytes from 185.215.234.5 (185.215.234.5): icmp_seq=2 ttl=34 time=25.0 ms
64 bytes from 185.215.234.5 (185.215.234.5): icmp_seq=3 ttl=34 time=24.8 ms
64 bytes from 185.215.234.5 (185.215.234.5): icmp_seq=4 ttl=34 time=24.9 ms
64 bytes from 185.215.234.5 (185.215.234.5): icmp_seq=5 ttl=34 time=24.8 ms
--- www.zarinpal.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 24.804/24.870/24.964/0.070 ms
# ping -c 5 185.143.233.5
PING 185.143.233.5 (185.143.233.5) 56(84) bytes of data.
64 bytes from 185.143.233.5: icmp_seq=1 ttl=33 time=76.5 ms
64 bytes from 185.143.233.5: icmp_seq=2 ttl=33 time=76.9 ms
64 bytes from 185.143.233.5: icmp_seq=3 ttl=33 time=54.9 ms
64 bytes from 185.143.233.5: icmp_seq=4 ttl=33 time=47.1 ms
64 bytes from 185.143.233.5: icmp_seq=5 ttl=33 time=43.2 ms
--- 185.143.233.5 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 43.220/59.721/76.912/14.357 ms
# ping -c 5 185.143.234.5
PING 185.143.234.5 (185.143.234.5) 56(84) bytes of data.
64 bytes from 185.143.234.5: icmp_seq=1 ttl=34 time=26.5 ms
64 bytes from 185.143.234.5: icmp_seq=2 ttl=34 time=46.0 ms
64 bytes from 185.143.234.5: icmp_seq=3 ttl=34 time=27.3 ms
64 bytes from 185.143.234.5: icmp_seq=4 ttl=34 time=24.8 ms
64 bytes from 185.143.234.5: icmp_seq=5 ttl=34 time=25.0 ms
--- 185.143.234.5 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 24.816/29.928/45.973/8.076 ms

@ giles, Thanks so oso so much. The problem was blocking ip in CDN payment provider, and with information yoe provide for me they easily solve the problim. thanks again man.

Excellent, glad we were able to help!