File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 7
7
path ("portone/webhook/" , PortoneWebhookApi .as_view (), name = "portone-webhook" ),
8
8
path ("key/" , post__generate_payment_key , name = "get-payment-key" ),
9
9
path ("success/" , PaymentSuccessApi .as_view (), name = "payment-success" ),
10
+ path ("failed/" , PaymentSuccessApi .as_view (), name = "payment-success" ),
10
11
path ("cancel/" , post__cancel_payment , name = "cancel-payment" ),
11
12
]
Original file line number Diff line number Diff line change @@ -79,6 +79,32 @@ def post(self, request):
79
79
return Response (dto )
80
80
81
81
82
+ class PaymentFailedApi (APIView ):
83
+ def post (self , request ):
84
+ if not request .is_authenticated :
85
+ return Response ({"msg" : "not logged in user" }, status = 400 )
86
+
87
+ payment_key = request .data ["merchant_uid" ]
88
+
89
+ payment = Payment .objects .get (payment_key = payment_key )
90
+ payment .status = enum .PaymentStatus .PAYMENT_FAILED .value
91
+ payment .save ()
92
+
93
+ payment_history = PaymentHistory (
94
+ payment_key = payment_key ,
95
+ status = enum .PaymentStatus .PAYMENT_FAILED .value ,
96
+ is_webhook = False
97
+ )
98
+ payment_history .save ()
99
+
100
+ dto = {
101
+ "msg" : "ok" ,
102
+ "merchant_uid" : request .data ["merchant_uid" ]
103
+ }
104
+
105
+ return Response (dto )
106
+
107
+
82
108
@api_view (["POST" ])
83
109
def post__generate_payment_key (request ):
84
110
You can’t perform that action at this time.
0 commit comments