سلام
وقت بخیر
من هنگام ارسال درخواست پست ارور 404 میگیرم راههای مختلفی هم امتحان کردم ولی به نتیجه ای نرسیدم
داخل تنضیمات هم SANDBOX = True قرار دادم و قسمت urls.py , form.py درست ست شده
zarinpal.py
from django.conf import settings
from suds.client import Client
def zpla_request_handler(merchant_id, amount, detail, user_email, user_phone_number, callback):
sandbox = 'sandbox' if settings.SANDBOX else 'www'
client = Client(f"https://{sandbox}.zarinpal.com/pg/services/WebGate/wsdl")
result = client.service.PaymentRequest(
merchant_id, amount, detail,
user_email, user_phone_number, callback
)
if result.Status == 100:
return f"https://{sandbox}.zarinpal.com/pg/StartPay/" + result.Authority, result.Authority
else:
return None,None
view.py
from django.shortcuts import render, redirect
from django.views import View
from finance.forms import ChargeWalletForm
from finance.utils.zarinpal import zpla_request_handler
class ChargeWalletView(View):
template_name = 'finance/charge_wallet.html'
form_class = ChargeWalletForm
def get(self, request, *args, **kwargs):
return render(request, self.template_name, {'form': self.form_class})
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)
if form.is_valid():
amount = form.cleaned_data['amount']
payment_link, authority = zpla_request_handler(
merchant_id="00000000-0000-0000-0000-000000000000",
amount=amount,
detail="charge",
user_email="asdf.j@da.com",
user_phone_number="912341",
callback="http://127.0.0.1:8000/finance/verify/"
)
if payment_link is not None:
return redirect(payment_link)
return render(request, self.template_name, {'form': form})