mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
fix: fix paypal payment provider and refactor payment code (#2159)
* feat: support paypal payment provider * feat: support paypal flow * feat: use owner replace org for payment * feat: update paypal logic * feat: gofumpt * feat: update payment * fix: fix notify * feat: delete log
This commit is contained in:
@ -24,6 +24,7 @@ class PaymentResultPage extends React.Component {
|
||||
this.state = {
|
||||
classes: props,
|
||||
paymentName: props.match.params.paymentName,
|
||||
organizationName: props.match.params.organizationName,
|
||||
payment: null,
|
||||
timeout: null,
|
||||
};
|
||||
@ -40,18 +41,37 @@ class PaymentResultPage extends React.Component {
|
||||
}
|
||||
|
||||
getPayment() {
|
||||
PaymentBackend.getPayment("admin", this.state.paymentName)
|
||||
PaymentBackend.getPayment(this.state.organizationName, this.state.paymentName)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
payment: res.data,
|
||||
});
|
||||
|
||||
// window.console.log("payment=", res.data);
|
||||
if (res.data.state === "Created") {
|
||||
this.setState({timeout: setTimeout(() => this.getPayment(), 1000)});
|
||||
if (res.data.type === "PayPal") {
|
||||
this.setState({
|
||||
timeout: setTimeout(() => {
|
||||
PaymentBackend.notifyPayment(this.state.organizationName, this.state.paymentName)
|
||||
.then((res) => {
|
||||
this.getPayment();
|
||||
});
|
||||
}, 1000),
|
||||
});
|
||||
} else {
|
||||
this.setState({timeout: setTimeout(() => this.getPayment(), 1000)});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
goToPaymentUrl(payment) {
|
||||
if (payment.returnUrl === undefined || payment.returnUrl === null || payment.returnUrl === "") {
|
||||
Setting.goToLink(`${window.location.origin}/products/${payment.owner}/${payment.productName}/buy`);
|
||||
} else {
|
||||
Setting.goToLink(payment.returnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const payment = this.state.payment;
|
||||
|
||||
@ -71,7 +91,7 @@ class PaymentResultPage extends React.Component {
|
||||
subTitle={i18next.t("payment:Please click the below button to return to the original website")}
|
||||
extra={[
|
||||
<Button type="primary" key="returnUrl" onClick={() => {
|
||||
Setting.goToLink(payment.returnUrl);
|
||||
this.goToPaymentUrl(payment);
|
||||
}}>
|
||||
{i18next.t("payment:Return to Website")}
|
||||
</Button>,
|
||||
@ -107,7 +127,7 @@ class PaymentResultPage extends React.Component {
|
||||
subTitle={i18next.t("payment:Please click the below button to return to the original website")}
|
||||
extra={[
|
||||
<Button type="primary" key="returnUrl" onClick={() => {
|
||||
Setting.goToLink(payment.returnUrl);
|
||||
this.goToPaymentUrl(payment);
|
||||
}}>
|
||||
{i18next.t("payment:Return to Website")}
|
||||
</Button>,
|
||||
|
Reference in New Issue
Block a user