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 @@ -92,6 +92,32 @@ def post(self, request):
92
92
return Response (dto )
93
93
94
94
95
+ class PaymentFailedApi (APIView ):
96
+ def post (self , request ):
97
+ if not request .is_authenticated :
98
+ return Response ({"msg" : "not logged in user" }, status = 400 )
99
+
100
+ payment_key = request .data ["merchant_uid" ]
101
+
102
+ payment = Payment .objects .get (payment_key = payment_key )
103
+ payment .status = enum .PaymentStatus .PAYMENT_FAILED .value
104
+ payment .save ()
105
+
106
+ payment_history = PaymentHistory (
107
+ payment_key = payment_key ,
108
+ status = enum .PaymentStatus .PAYMENT_FAILED .value ,
109
+ is_webhook = False
110
+ )
111
+ payment_history .save ()
112
+
113
+ dto = {
114
+ "msg" : "ok" ,
115
+ "merchant_uid" : request .data ["merchant_uid" ]
116
+ }
117
+
118
+ return Response (dto )
119
+
120
+
95
121
@api_view (["POST" ])
96
122
def post__generate_payment_key (request ):
97
123
You can’t perform that action at this time.
0 commit comments