32 lines
		
	
	
		
			960 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			960 B
		
	
	
	
		
			JavaScript
		
	
	
	
| import dayjs from "dayjs";
 | |
| 
 | |
| const handleParams = (obj) => Object.entries(obj).reduce((total,curr) => {
 | |
|     if(!total){
 | |
|         total += `${curr[0]}=${curr[1]}`
 | |
|     }else{
 | |
|         total += `|${curr[0]}=${curr[1]}`
 | |
|     }
 | |
|     return total
 | |
| },'')
 | |
| 
 | |
| 
 | |
| export default function usePay(){
 | |
|     const payFunc = (args) => {
 | |
|         const {order_no,notify_url,TranAmt} = args;
 | |
|         const Plain = {
 | |
|             MercUrl:notify_url,
 | |
|             TranAmt:Number(TranAmt).toFixed(2),
 | |
|             TermSsn:order_no,
 | |
|             BackLink:encodeURIComponent(`${window.location.origin}/#/pages/ycnc/orderDetail?order_no=${order_no}`),
 | |
|             psbcmcc:'LSXD',
 | |
|             TxnDt:dayjs(Date.now()).format('YYYY-MM-DD'),
 | |
|             MercCode:import.meta.env.VITE_YCNC_MERCH_CODE
 | |
|         }
 | |
|         const params = {
 | |
|             Plain:handleParams(Plain),
 | |
|         }
 | |
|         console.log('handCodePay-params',Plain);
 | |
|         Fw.device.api.handCodePay(params);
 | |
|     }
 | |
|     return {payFunc}
 | |
| } |