✨ process pay result
This commit is contained in:
parent
c2e03aedb9
commit
b288cad771
@ -9,16 +9,16 @@ import {useDownloadReceiptPDF} from "@/service/generate-pdf.ts";
|
||||
import {useEffect} from "react";
|
||||
import {useSetState} from "ahooks";
|
||||
import {FailIcon} from "@/assets/images/pay/fail.tsx";
|
||||
import {updateBillPaymentSuccess} from "@/service/api/bill.ts";
|
||||
|
||||
type PayResult = 'fail' | 'success' | 'cancel' | 'error' | string;
|
||||
function updateBillSuccess(billId){
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
billId
|
||||
}
|
||||
}
|
||||
|
||||
function updateBillSuccess(billId: number, type: string, ref: string) {
|
||||
updateBillPaymentSuccess(billId, ref, type).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
|
||||
const PayIndex = () => {
|
||||
const {t} = useTranslation()
|
||||
const {downloadPDF} = useDownloadReceiptPDF()
|
||||
@ -37,13 +37,14 @@ const PayIndex = () => {
|
||||
status = search.get('status')
|
||||
if (from) {
|
||||
setState({from})
|
||||
if(from == 'asia_spay') {
|
||||
const refId = search.get('Ref')
|
||||
const bill = search.get('bill')
|
||||
// 参数无效
|
||||
if(!refId){
|
||||
if (!bill) {
|
||||
setState({result: 'fail'})
|
||||
return;
|
||||
}
|
||||
if (result == 'success') {
|
||||
updateBillSuccess(Number(bill), from, (from == 'asia_pay' ? search.get('Ref')! : search.get('callback_id')!));
|
||||
}
|
||||
}
|
||||
setState({result, status})
|
||||
@ -60,15 +61,15 @@ const PayIndex = () => {
|
||||
{t('pay.text_success')}
|
||||
</h2>
|
||||
</div>
|
||||
<div className={styles.payConfirm}>
|
||||
<div className="student-email">{t('bill.bill_number')}: PM-202405211114</div>
|
||||
{state.bill && <div className={styles.payConfirm}>
|
||||
<div className="student-email">{t('bill.bill_number')}: {state.bill.student_number || state.bill.application_number}</div>
|
||||
<div className="pay-submit">
|
||||
<Button
|
||||
theme={'solid'}
|
||||
onClick={() => downloadPDF({id: Date.now()})}
|
||||
onClick={() => downloadPDF(state.bill!)}
|
||||
style={{width: 250, marginTop: 20}}>{t('bill.download_receipt')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>}
|
||||
</> : <div className={styles.paySuccess}>
|
||||
<div className={styles.successIcon} style={{color: '#f05672'}}>
|
||||
<FailIcon/>
|
||||
|
@ -50,3 +50,6 @@ export function confirmBills(bill_ids: number[]) {
|
||||
return post(`/api/bills/apply`, {bill_ids})
|
||||
}
|
||||
|
||||
export function updateBillPaymentSuccess(billId: number, merchant_ref: string,peyment_channel:string) {
|
||||
return post(`api/bills/${billId}/finish`, {merchant_ref,peyment_channel})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user