Improve InvoicePayment() error handling.

This commit is contained in:
Gucheng Wang
2022-04-27 00:24:48 +08:00
parent e5c1f560c5
commit ea005aaf4d
11 changed files with 50 additions and 14 deletions

View File

@ -65,7 +65,24 @@ class PaymentEditPage extends React.Component {
}
issueInvoice() {
alert("111")
this.setState({
isModalVisible: false,
});
PaymentBackend.invoicePayment(this.state.payment.owner, this.state.paymentName)
.then((res) => {
if (res.msg === "") {
Setting.showMessage("success", `Successfully invoiced`);
this.setState({
paymentName: this.state.payment.name,
});
} else {
Setting.showMessage("error", res.msg);
}
})
.catch(error => {
Setting.showMessage("error", `Failed to connect to server: ${error}`);
});
}
downloadInvoice() {
@ -361,6 +378,10 @@ class PaymentEditPage extends React.Component {
}
checkError() {
if (this.state.payment.state !== "Paid") {
return i18next.t("payment:Please pay the order first!");
}
if (!Setting.isValidPersonName(this.state.payment.personName)) {
return i18next.t("signup:Please input your real name!");
}

View File

@ -54,3 +54,10 @@ export function deletePayment(payment) {
body: JSON.stringify(newPayment),
}).then(res => res.json());
}
export function invoicePayment(owner, name) {
return fetch(`${Setting.ServerUrl}/api/invoice-payment?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST",
credentials: "include"
}).then(res => res.json());
}

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "Person phone - Tooltip",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.",
"Please click the below button to return to the original website": "Please click the below button to return to the original website",
"Please pay the order first!": "Please pay the order first!",
"Price": "Price",
"Price - Tooltip": "Price - Tooltip",
"Processing...": "Processing...",

View File

@ -291,6 +291,7 @@
"Person phone - Tooltip": "缴费人本人的手机号",
"Please carefully check your invoice information. Once the invoice is issued, it cannot be withdrawn or modified.": "请仔细检查下列发票信息,发票一经开具,无法退换。",
"Please click the below button to return to the original website": "请点击下方按钮返回原网站",
"Please pay the order first!": "请先完成支付后再进行操作!",
"Price": "价格",
"Price - Tooltip": "商品价格",
"Processing...": "正在处理...",