Skip to content

Commit 7fbdf70

Browse files
committed
Success API 호출시 티켓 생성
1 parent b1df9c8 commit 7fbdf70

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

payment/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,24 @@ def post(self, request):
6464

6565
payment_key = request.data["merchant_uid"]
6666

67+
target_payment = Payment.objects.get(payment_key=payment_key)
68+
6769
payment_history = PaymentHistory(
6870
payment_key=payment_key,
6971
status=enum.PaymentStatus.PAYMENT_SUCCESS.value,
7072
is_webhook=False
7173
)
7274
payment_history.save()
7375

76+
if not Ticket.objects.filter(payment=target_payment).exists():
77+
ticket = Ticket.objects.create(
78+
ticket_type=target_payment.ticket_type,
79+
bought_at=datetime.datetime.now(),
80+
user=target_payment.user,
81+
)
82+
ticket.save()
83+
84+
7485
dto = {
7586
"msg": "ok",
7687
"merchant_uid": request.data["merchant_uid"]

0 commit comments

Comments
 (0)