diff --git a/apps/pg/urls.py b/apps/pg/urls.py index 6fa5c3f..5eb12ad 100644 --- a/apps/pg/urls.py +++ b/apps/pg/urls.py @@ -6,7 +6,7 @@ app_name = "pg" urlpatterns = [ path('page/charge//', PaymentRequestView.as_view(), name='payment-request-view'), - path('page/pna_callback//', PaymentConfirmView.as_view(), name='payment-confirm-view'), + path('page/confirm//', PaymentConfirmView.as_view(), name='payment-confirm-view'), path('api/charge_create/', PaymentRequestCreateApiView.as_view(), name='charge-request-create-api-view'), path('api/application/charge_create/', ApplicationPaymentRequestCreateApiView.as_view(), name='application-user-charge-request-create-api-view'), path('api/calculate_commission/', CalculateCommissionView.as_view(), name='calculate-commission-view'), diff --git a/apps/pg/views.py b/apps/pg/views.py index 5022bc1..1451db6 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -119,7 +119,7 @@ class PaymentRequestView(UpdateView): @method_decorator(csrf_exempt, name='dispatch') class PaymentConfirmView(UpdateView): - template_name = 'pg/payment_failure.html' + template_name = 'pg/payment_confirm.html' # template_name = 'pg/payment_success.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' @@ -131,13 +131,19 @@ class PaymentConfirmView(UpdateView): # return Charge.objects.filter(state__in=[StateChoices.CREATED.value, StateChoices.SUCCESS.value]) def get(self, request, *args, **kwargs): - print('get') print(args) print(kwargs) self.object = self.get_object() tool = self.object.get_gateway_tools() - tool.confirm_request(request) + # state, message = tool.confirm_request(request) + # if state: + # self.template_name = 'pg/payment_success.html' + # + # + # # TODO: + # context = self.get_context_data(object=self.object) + # context['message'] = message context = self.get_context_data() return self.render_to_response(context) @@ -161,30 +167,3 @@ class PaymentConfirmView(UpdateView): context = self.get_context_data(object=self.object) context['message'] = message return self.render_to_response(context) - - - # def form_valid(self, form): - # self.object = form.save() - # charge_request: ChargeRequest = self.get_object() - # try: - # - # # transaction = Transaction.objects.create( - # # uuid=charge.uuid, - # # payee_id=charge.user.pk, - # # payee_type=1, - # # payer_id=payer_pk, - # # payer_type=2, - # # amount=amount, - # # details={'description': 'شارژ مجازی کیف پول'} - # # ) - # # transaction.submit() - # # transaction.verify() - # # charge.change_state(from_state=StateChoices.PENDING.value, to_state=StateChoices.SUCCESS.value) - # - # except Exception as e: - # print(e) - # messages.error(self.request, 'خطایی رخ داده است') - # charge_request.change_state(from_state=StateChoices.PENDING.value, to_state=StateChoices.EXPECTED_FAILURE.value) - # - # return HttpResponseRedirect(self.get_success_url()) - diff --git a/templates/pg/payment-confirm.html b/templates/pg/payment-confirm.html deleted file mode 100644 index 3e87bfc..0000000 --- a/templates/pg/payment-confirm.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "base.html" %} -{% load static %} -{% load crispy_forms_tags %} -{% load jalali_tags %} - -{% block title %}بازگشت{% endblock %} -{% block page_title %}بازگشت{% endblock %} - - -{% block content %} - مبلغ {{ object.amount }} ریال با وضعیت {{ object.get_state_display }}
-
- {% csrf_token %} -
-
- {#
#} - {#
#} - {{ form|crispy }} - {#
#} - {#
#} -
-
بازگشت به برنامه
-
-
- -
-
-
-
- -{% endblock %} \ No newline at end of file diff --git a/templates/pg/payment_failure.html b/templates/pg/payment_confirm.html similarity index 94% rename from templates/pg/payment_failure.html rename to templates/pg/payment_confirm.html index bd19088..926cfab 100644 --- a/templates/pg/payment_failure.html +++ b/templates/pg/payment_confirm.html @@ -1,179 +1,179 @@ -{% load static %} -{% load crispy_forms_tags %} -{% load jalali_tags %} - - - - - - - - Payment Unsuccessful - - - - - - - - - -
-
- -
-
!
- {% if message %} -

{{ message }}

- {% else %} -

پرداخت شما ناموفق بود

- {% endif %} -
-
-

کد پیگیری تراکنش شما: {{ object.reference_number }}

-

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

-
- addwin -
- -
-
- {% csrf_token %} - {{ form|crispy }} - -
-
-
-
- - +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + + + + + + + + Payment Unsuccessful + + + + + + + + + +
+
+ +
+
!
+ {% if message %} +

{{ message }}

+ {% else %} +

پرداخت شما ناموفق بود

+ {% endif %} +
+
+

کد پیگیری تراکنش شما: {{ object.reference_number }}

+

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

+
+ وینسو +
+ +
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
+
+ + \ No newline at end of file diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index 81cac7d..fa011f1 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -155,9 +155,9 @@
مقدار پرداخت شده: - {{ object.amount }} تومان + {{ object.amount }} ریال
- addwin + وینسو
@@ -167,7 +167,6 @@
-