mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-22 21:33:36 +08:00
Add payerName to provider.
This commit is contained in:
@ -170,6 +170,7 @@ func BuyProduct(id string, providerName string, user *User, host string) (string
|
|||||||
|
|
||||||
owner := product.Owner
|
owner := product.Owner
|
||||||
productName := product.Name
|
productName := product.Name
|
||||||
|
payerName := fmt.Sprintf("%s | %s", user.Name, user.DisplayName)
|
||||||
paymentName := util.GenerateTimeId()
|
paymentName := util.GenerateTimeId()
|
||||||
productDisplayName := product.DisplayName
|
productDisplayName := product.DisplayName
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ func BuyProduct(id string, providerName string, user *User, host string) (string
|
|||||||
returnUrl := fmt.Sprintf("%s/payments/%s/result", originFrontend, paymentName)
|
returnUrl := fmt.Sprintf("%s/payments/%s/result", originFrontend, paymentName)
|
||||||
notifyUrl := fmt.Sprintf("%s/api/notify-payment/%s/%s/%s/%s", originBackend, owner, providerName, productName, paymentName)
|
notifyUrl := fmt.Sprintf("%s/api/notify-payment/%s/%s/%s/%s", originBackend, owner, providerName, productName, paymentName)
|
||||||
|
|
||||||
payUrl, err := pProvider.Pay(providerName, productName, paymentName, productDisplayName, product.Price, returnUrl, notifyUrl)
|
payUrl, err := pProvider.Pay(providerName, productName, payerName, paymentName, productDisplayName, product.Price, returnUrl, notifyUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func NewAlipayPaymentProvider(appId string, appPublicKey string, appPrivateKey s
|
|||||||
return pp
|
return pp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pp *AlipayPaymentProvider) Pay(providerName string, productName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error) {
|
func (pp *AlipayPaymentProvider) Pay(providerName string, productName string, payerName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error) {
|
||||||
//pp.Client.DebugSwitch = gopay.DebugOn
|
//pp.Client.DebugSwitch = gopay.DebugOn
|
||||||
|
|
||||||
bm := gopay.BodyMap{}
|
bm := gopay.BodyMap{}
|
||||||
|
24
pp/gc.go
24
pp/gc.go
@ -38,11 +38,14 @@ type GcPayReqInfo struct {
|
|||||||
OrderDate string `json:"orderdate"`
|
OrderDate string `json:"orderdate"`
|
||||||
OrderNo string `json:"orderno"`
|
OrderNo string `json:"orderno"`
|
||||||
Amount string `json:"amount"`
|
Amount string `json:"amount"`
|
||||||
PayerId string `json:"payerid"`
|
|
||||||
PayerName string `json:"payername"`
|
|
||||||
Xmpch string `json:"xmpch"`
|
Xmpch string `json:"xmpch"`
|
||||||
|
Body string `json:"body"`
|
||||||
ReturnUrl string `json:"return_url"`
|
ReturnUrl string `json:"return_url"`
|
||||||
NotifyUrl string `json:"notify_url"`
|
NotifyUrl string `json:"notify_url"`
|
||||||
|
PayerId string `json:"payerid"`
|
||||||
|
PayerName string `json:"payername"`
|
||||||
|
Remark1 string `json:"remark1"`
|
||||||
|
Remark2 string `json:"remark2"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GcPayRespInfo struct {
|
type GcPayRespInfo struct {
|
||||||
@ -151,16 +154,17 @@ func (pp *GcPaymentProvider) doPost(postBytes []byte) ([]byte, error) {
|
|||||||
return respBytes, nil
|
return respBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pp *GcPaymentProvider) Pay(providerName string, productName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error) {
|
func (pp *GcPaymentProvider) Pay(providerName string, productName string, payerName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error) {
|
||||||
payReqInfo := GcPayReqInfo{
|
payReqInfo := GcPayReqInfo{
|
||||||
OrderDate: util.GenerateSimpleTimeId(),
|
OrderDate: util.GenerateSimpleTimeId(),
|
||||||
OrderNo: util.GenerateTimeId(),
|
OrderNo: paymentName,
|
||||||
Amount: getPriceString(price),
|
Amount: getPriceString(price),
|
||||||
PayerId: "",
|
|
||||||
PayerName: "",
|
|
||||||
Xmpch: pp.Xmpch,
|
Xmpch: pp.Xmpch,
|
||||||
|
Body: productDisplayName,
|
||||||
ReturnUrl: returnUrl,
|
ReturnUrl: returnUrl,
|
||||||
NotifyUrl: notifyUrl,
|
NotifyUrl: notifyUrl,
|
||||||
|
Remark1: payerName,
|
||||||
|
Remark2: productName,
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(payReqInfo)
|
b, err := json.Marshal(payReqInfo)
|
||||||
@ -316,5 +320,13 @@ func (pp *GcPaymentProvider) GetInvoice(paymentName string, personName string, p
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if invoiceRespInfo.State == "0" {
|
||||||
|
return "", fmt.Errorf("申请成功,开票中")
|
||||||
|
}
|
||||||
|
|
||||||
|
if invoiceRespInfo.Url == "" {
|
||||||
|
return "", fmt.Errorf("invoice URL is empty")
|
||||||
|
}
|
||||||
|
|
||||||
return invoiceRespInfo.Url, nil
|
return invoiceRespInfo.Url, nil
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ package pp
|
|||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
type PaymentProvider interface {
|
type PaymentProvider interface {
|
||||||
Pay(providerName string, productName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error)
|
Pay(providerName string, productName string, payerName string, paymentName string, productDisplayName string, price float64, returnUrl string, notifyUrl string) (string, error)
|
||||||
Notify(request *http.Request, body []byte, authorityPublicKey string) (string, string, float64, string, string, error)
|
Notify(request *http.Request, body []byte, authorityPublicKey string) (string, string, float64, string, string, error)
|
||||||
GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
|
GetInvoice(paymentName string, personName string, personIdCard string, personEmail string, personPhone string, invoiceType string, invoiceTitle string, invoiceTaxId string) (string, error)
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ class PaymentEditPage extends React.Component {
|
|||||||
paymentName: props.match.params.paymentName,
|
paymentName: props.match.params.paymentName,
|
||||||
payment: null,
|
payment: null,
|
||||||
isModalVisible: false,
|
isModalVisible: false,
|
||||||
|
isInvoiceLoading: false,
|
||||||
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -69,20 +70,25 @@ class PaymentEditPage extends React.Component {
|
|||||||
issueInvoice() {
|
issueInvoice() {
|
||||||
this.setState({
|
this.setState({
|
||||||
isModalVisible: false,
|
isModalVisible: false,
|
||||||
|
isInvoiceLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
PaymentBackend.invoicePayment(this.state.payment.owner, this.state.paymentName)
|
PaymentBackend.invoicePayment(this.state.payment.owner, this.state.paymentName)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
this.setState({
|
||||||
|
isInvoiceLoading: false,
|
||||||
|
});
|
||||||
if (res.msg === "") {
|
if (res.msg === "") {
|
||||||
Setting.showMessage("success", `Successfully invoiced`);
|
Setting.showMessage("success", `Successfully invoiced`);
|
||||||
this.setState({
|
window.location.reload();
|
||||||
paymentName: this.state.payment.name,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", res.msg);
|
Setting.showMessage(res.msg.includes("成功") ? "info" : "error", res.msg);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
this.setState({
|
||||||
|
isInvoiceLoading: false,
|
||||||
|
});
|
||||||
Setting.showMessage("error", `Failed to connect to server: ${error}`);
|
Setting.showMessage("error", `Failed to connect to server: ${error}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -337,6 +337,8 @@ export function showMessage(type, text) {
|
|||||||
message.success(text);
|
message.success(text);
|
||||||
} else if (type === "error") {
|
} else if (type === "error") {
|
||||||
message.error(text);
|
message.error(text);
|
||||||
|
} else if (type === "info") {
|
||||||
|
message.info(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user