Skip to content

Commit

Permalink
retrieve autorization infos
Browse files Browse the repository at this point in the history
  • Loading branch information
eltorio committed Aug 1, 2023
1 parent 35413e2 commit da9229b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 26 deletions.
22 changes: 22 additions & 0 deletions pretix_paybox/PayboxCheck.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import json
from Crypto.Hash import SHA
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
Expand Down Expand Up @@ -47,3 +48,24 @@ def verify_response(response_message):
h, binary_signature), "Signature Verification Failed"

return True


def get_object_response(response_message):
url_parsed = urlparse(response_message) # object
message = url_parsed.query # string
query = parse_qs(message) # dictionnary
object_response = {
"amount": query["amount"][0],
"paymentId": query["paymentId"][0],
"transactionId": query["transactionId"][0],
"authorizationId": query["authorizationId"][0],
"cardType": query["cardType"][0],
"cardNumber": query["cardNumber"][0],
"cardExpiration": query["cardExpiration"][0],
"error": query["error"][0],
"payboxRef": query["payboxRef"][0],
"date": query["date"][0],
"time": query["time"][0],
"signature": query["signature"][0],
}
return object_response
21 changes: 21 additions & 0 deletions pretix_paybox/locale/django.pot
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,24 @@ msgstr ""

msgid "Payment is pending"
msgstr ""

msgid "Transaction"
msgstr ""

msgid "Authorization"
msgstr ""

msgid "Card type"
msgstr ""

msgid "Card number"
msgstr ""

msgid "Card expiration"
msgstr ""

msgid "Payment date"
msgstr ""

msgid "Reference"
msgstr ""
1 change: 1 addition & 0 deletions pretix_paybox/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def payment_control_render(self, request: HttpRequest, payment: OrderPayment):
ctx = {
"request": request,
"event": self.event,
"payment": payment,
"payment_info": payment.info_data,
"order": payment.order,
}
Expand Down
51 changes: 26 additions & 25 deletions pretix_paybox/templates/pretix_paybox/control.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
{% load i18n %}

{% if payment_info and order.status == "p" %}
<p>{% blocktrans trimmed %}
This order has been paid via Paybox/Up2Pay Payment.
{% if payment.state == "confirmed" and order.status == "p" %}
<p>{% blocktrans trimmed %}
This order has been paid via Paybox/Up2Pay Payment.
{% endblocktrans %}</p>

<dl class="dl-horizontal">
<dt>{% trans "Payer" %}</dt>
<dd>{{ payment_info.payer }}</dd>
<dt>{% trans "Payment date" %}</dt>
<dd>{{ payment_info.date }}</dd>
<dt>{% trans "Reference" %}</dt>
<dd>{{ payment_info.reference }}</dd>
</dl>
<dl class="dl-horizontal">
<dt>{% trans "Transaction" %}</dt>
<dd>{{ payment_info.transactionId }}</dd>
<dt>{% trans "Authorization" %}</dt>
<dd>{{ payment_info.authorizationId }}</dd>
<dt>{% trans "Card type" %}</dt>
<dd>{{ payment_info.cardType }}</dd>
<dt>{% trans "Card number" %}</dt>
<dd>{{ payment_info.cardNumber }}-- ---- ----</dd>
<dt>{% trans "Card expiration" %}</dt>
<dd>{{ payment_info.cardExpiration }}</dd>
<dt>{% trans "Payment date" %}</dt>
<dd>{{ payment_info.date }} {{ payment_info.time }}</dd>
<dt>{% trans "Reference" %}</dt>
<dd>{{ payment_info.payboxRef }}</dd>
</dl>
{% else %}
{% if order.status == "p" %}
<p>{% blocktrans trimmed %}
This order has been marked as paid via Paybox/Up2Pay Payment manually.
{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans trimmed %}
This order has been planned to be paid via Paybox/Up2Pay Payment, but no payment has been received yet.
{% endblocktrans %}</p>
{% endif %}
<dl class="dl-horizontal">
<dt>{% trans "Reference code" %}</dt>
<dd>{{ order.full_code }}</dd>
</dl>
<p>{% blocktrans trimmed %}
This order has been planned to be paid via Paybox/Up2Pay Payment, but no payment has been received yet.
{% endblocktrans %}</p>
<dl class="dl-horizontal">
<dt>{% trans "Reference code" %}</dt>
<dd>{{ order.full_code }}</dd>
</dl>
{% endif %}
3 changes: 2 additions & 1 deletion pretix_paybox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pretix.multidomain.urlreverse import eventreverse
from urllib.parse import parse_qs, urlparse

from .PayboxCheck import verify_response
from .PayboxCheck import get_object_response, verify_response
from .payment import PayboxPayment, check_signed_uuid4, getNonce


Expand Down Expand Up @@ -43,6 +43,7 @@ def effectue(request, *args, **kwargs):
check = verify_response(request.build_absolute_uri())
if check:
if get_response_code(request) == "00000":
payment.info_data = get_object_response(request.build_absolute_uri())
payment.confirm()
return redirect(eventreverse(request.event, 'presale:event.order', kwargs={
'order': payment.order.code,
Expand Down

0 comments on commit da9229b

Please sign in to comment.