Project

General

Profile

New Function #79

Updated by Deca Park about 1 year ago

<p>1.<strong>[Scheduler] VBank Payment Expire Scheduler</strong></p> 

 <p style="margin-left: 40px;">1.reference<br /> 
 &nbsp; -&nbsp;non-violent #9874-note#18<br /> 
 2.crontab<br /> 
 &nbsp; - execute per 1 hour<br /> 
 3.logic<br /> 
 &nbsp; 1) SELECT st_order_payment with payment_status = &#39;PS20&#39; (wait deposit)<br /> 
 &nbsp; &nbsp; a) get va_due_date<br /> 
 &nbsp; &nbsp; b) if current datetime &gt; va_due_date<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp;b-1) UPDATE st_order_payment<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- payment_status = &#39;PS22&#39; (deposit expire)<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- mod_date / mod_user_no = NULL<br /> 
 &nbsp; &nbsp;* define fee_payment_status value as constant</p> 

 <p>2<strong>.[API] VBank deposit complete process (가상계좌 웹훅)</strong></p> 

 <p style="margin-left: 40px;">1.document<br /> 
 &nbsp; https://docs.tosspayments.com/guides/learn/virtual-account-webhook<br /> 
 <br /> 
 2.make <strong>Webhook&nbsp;endpoint</strong> to receive event payload from PG<br /> 
 &nbsp; 1) URL:&nbsp;<strong>POST {domain}/hook</strong><br /> 
 &nbsp; &nbsp; - permitAll (don&#39;t check authentication)<br /> 
 <br /> 
 3.DEPOSIT_CALLBACK Webhook event data (JSON) from PG<br /> 
 &nbsp; &nbsp; [example]<br /> 
 &nbsp; &nbsp; {<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;createdAt: &#39;2023-05-23T14:42:26.000000&#39;,<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;secret: &#39;ps_Z1aOwX7K8mYpalqAGRwj8yQxzvNP&#39;,<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;orderId: &#39;3f9c765d-60ed-4735-8af5-ab9d1142a3e8&#39;,<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;status: &#39;DONE&#39;,<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;transactionKey: &#39;83B3CD71DF004878066FEDCB7C21E775&#39;<br /> 
 &nbsp;&nbsp; &nbsp;}<br /> 
 <br /> 
 4.process Logic<br /> 
 &nbsp; 1) SELECT DB (st_order_payment)<br /> 
 &nbsp; &nbsp; &nbsp; condition: order_no = {orderId param}<br /> 
 &nbsp; 2) <strong>if No data OR {pg_secret} != {secret param}, SKIP<br /> 
 &nbsp; &nbsp; &nbsp; - response status(200) ok</strong><br /> 
 &nbsp; 3) if {pg_secret} = {secret param}<br /> 
 &nbsp; &nbsp; &nbsp;a) if {status param} =<strong> &#39;DONE&#39;</strong><br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; UPDATE DB (st_order_payment)<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; - payment_status = <strong>&#39;PS21&#39;</strong>, va_proc_date = {current date}<br /> 
 &nbsp; &nbsp; &nbsp;b) if {status param} =<strong> &#39;WAITING_FOR_DEPOSIT&#39;</strong><br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; UPDATE DB (st_order_payment)<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; - payment_status =<strong> &#39;PS23&#39;</strong>, va_proc_date = {current date}<br /> 
 &nbsp; 4)<strong> response status(200) ok</strong></p> 

 <p>3.<strong>[Common] PG payment cancellation (결제취소)&nbsp;&nbsp;function</strong></p> 

 <ul> 
	 <li><strong>it&#39;s called on API and ADMIN both</strong></li> 
 </ul> 

 <p style="margin-left: 40px;">1.parameters<br /> 
 &nbsp; 1) order no<br /> 
 &nbsp; 2) user_seq<br /> 
 &nbsp; 3) cancel reason<br /> 
 <br /> 
 2.Process<br /> 
 &nbsp; 0) SELECT DB (st_order_payment) (with order_no = {order no param})<br /> 
 &nbsp; &nbsp; a)<strong> if No data OR payment_key value is NUL(empty), SKIP</strong><br /> 
 &nbsp; &nbsp; b) if not, continue<br /> 
 &nbsp; 1) call <strong>PG payment cancel API</strong><br /> 
 &nbsp; &nbsp; a) document<br /> 
 &nbsp; &nbsp; &nbsp; - https://docs.tosspayments.com/reference#%EA%B2%B0%EC%A0%9C-%EC%B7%A8%EC%86%8C<br /> 
 &nbsp; &nbsp; b) URL: POST /v1/payment/{paymentKey}/cancel<br /> 
 &nbsp; &nbsp; &nbsp; - {paymentKey} : st_order_payment.payment_key<br st_order_payment.payment_key (with order_no param)<br /> 
 &nbsp; &nbsp; c) header<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp;- Authorization: {same with pg confirm API}<br /> 
 &nbsp; &nbsp; d) RequestBody<br /> 
 &nbsp; &nbsp; &nbsp; d-1) cancelReason : {cancel reason param}<br /> 
 &nbsp; &nbsp; &nbsp; d-2) cancelAmount : don&#39;t set because cancel amount is total amount<br /> 
 &nbsp; &nbsp; &nbsp; d-3) refundReceiveAccount object<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; - <strong>if {st_order_payment.payment_method} = &#39;PV02&#39; (VBank), set (it not, don&#39;t set)</strong><br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; d-3-1) bank : {st_order_payment.refund_bank_code}<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; d-3-2) accountNumber : {refund_account_number}<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; d-3-3) holderName : {refund_holder_name}<br /> 
 <br /> 
 &nbsp; &nbsp; &nbsp;[example]<br /> 
 &nbsp; &nbsp; &nbsp;curl --request POST \<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;--url https://api.tosspayments.com/v1/payments/5zJ4xY7m0kODnyRpQWGrN2xqGlNvLrKwv1M9ENjbeoPaZdL6/cancel \<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;--header &#39;Authorization: Basic dGVzdF9za196WExrS0V5cE5BcldtbzUwblgzbG1lYXhZRzVSOg==&#39; \<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;--header &#39;Content-Type: application/json&#39; \<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;--header &#39;Idempotency-Key: e9b779ed-3541-4b6e-aa95-88f710689a68&#39; \<br /> 
 &nbsp;&nbsp; &nbsp; &nbsp;--data &#39;{&quot;cancelReason&quot;:&quot;고객 변심&quot;}&#39;<br /> 
 <br /> 
 &nbsp; 2) if cancel API is success<br /> 
 &nbsp; &nbsp; a) UPDATE st_order_payment<br /> 
 &nbsp; &nbsp; &nbsp; condition:&nbsp;order_no = {order_no param}<br /> 
 &nbsp; &nbsp; &nbsp; set :<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; payment_status = &#39;PS11&#39;<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; cancel_amount = {payment_amount}, cancel_reason = {decided by process type}<br /> 
 &nbsp; &nbsp; &nbsp; &nbsp; cancel_proc_date = {current date}, cancel_user_seq = {decided by process type}<br /> 
 <br /> 
 &nbsp; 3) if cancel API is fail<br /> 
 &nbsp; &nbsp; a) return PG error_code / error_msg without DB UPDATE</p> 

 <p>4.<strong>[API] 스마트오더 주문 취소 (store order cancel) - Change</strong></p> 

 <p style="margin-left: 40px;">1.URL: POST /api/store_order_cancel<br /> 
 2.process logic<br /> 
 &nbsp; 1) UPDATE DB (st_order)<br /> 
 &nbsp; &nbsp; - same with previous definition<br /> 
 &nbsp; 2) <strong>call Common PG payment cancellation (결제취소) function&nbsp;</strong><br /> 
 &nbsp; &nbsp; a) parameter<br /> 
 &nbsp; &nbsp; &nbsp; - order no : {order_no param}<br /> 
 &nbsp; &nbsp; &nbsp; - user_seq : {user_seq of id param}<br /> 
 &nbsp; &nbsp; &nbsp; - cancel reason : {code name of cancel_reason_type param - grp_code: SD}<br /> 
 3.<strong>Response (Add)</strong><br /> 
 &nbsp; 1) order_no : {order_no}<br /> 
 &nbsp; 2) pg_error_code / pg_error_msg : if PG cancel API is fail, set it</p> <p>&nbsp;</p> 

Back