拉卡拉增加不限制支付方式
This commit is contained in:
@@ -169,7 +169,7 @@ func (c *Client) CreatePayment(ctx context.Context, req CreatePaymentRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
payWay := firstNonEmpty(req.PayWay, c.cfg.PayWay, "ZFBZF")
|
||||
payMode := firstNonEmpty(c.cfg.PayMode, payModeFromPayWay(payWay), "ALIPAY")
|
||||
payMode := normalizeCounterPayMode(c.cfg.PayMode)
|
||||
expireMinutes := c.cfg.OrderExpireMinutes
|
||||
if expireMinutes <= 0 {
|
||||
expireMinutes = 15
|
||||
@@ -183,9 +183,11 @@ func (c *Client) CreatePayment(ctx context.Context, req CreatePaymentRequest) (*
|
||||
"support_refund": 1,
|
||||
"support_repeat_pay": 1,
|
||||
"support_cancel": 0,
|
||||
"counter_param": fmt.Sprintf(`{"pay_mode":"%s"}`, payMode),
|
||||
"order_info": sanitizeText(req.Body, 128),
|
||||
}
|
||||
if payMode != "" {
|
||||
reqData["counter_param"] = fmt.Sprintf(`{"pay_mode":"%s"}`, payMode)
|
||||
}
|
||||
if c.cfg.TermNo != "" {
|
||||
reqData["term_no"] = c.cfg.TermNo
|
||||
}
|
||||
@@ -710,6 +712,15 @@ func payModeFromPayWay(payWay string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeCounterPayMode(value string) string {
|
||||
switch strings.ToUpper(strings.TrimSpace(value)) {
|
||||
case "", "AUTO", "ALL", "NONE", "UNLIMITED":
|
||||
return ""
|
||||
default:
|
||||
return strings.ToUpper(strings.TrimSpace(value))
|
||||
}
|
||||
}
|
||||
|
||||
func sanitizeText(value string, maxRunes int) string {
|
||||
value = strings.TrimSpace(value)
|
||||
if value == "" || maxRunes <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user