fix(v2): P4 终审波——歧义渠道错误留 processing(ErrRefundRejected 哨兵)/ 拒绝fixture签名 / 错误映射测试 / GetRefund 日志
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
@@ -7,6 +7,7 @@ package stripe
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -65,6 +66,14 @@ func (p *Provider) Refund(_ context.Context, providerRef, refundID string, amoun
|
||||
params.SetIdempotencyKey(refundID)
|
||||
rf, err := p.sc.Refunds.New(params)
|
||||
if err != nil {
|
||||
// *stripe.Error + HTTPStatusCode 4xx = 渠道对这次请求的确定性拒绝(参数/状态
|
||||
// 类错误,如金额超出可退余额、PaymentIntent 已全额退过);5xx/网络错误(err 不是
|
||||
// *stripe.Error,或是但状态码 5xx)结果不确定,不 wrap ErrRefundRejected ——
|
||||
// 与 alipay 同一判定原则(见 provider.ErrRefundRejected 注释 / item 1)。
|
||||
var serr *gostripe.Error
|
||||
if errors.As(err, &serr) && serr.HTTPStatusCode >= 400 && serr.HTTPStatusCode < 500 {
|
||||
return "", provider.PaidFailed, fmt.Errorf("stripe: 退款被拒: %w", errors.Join(provider.ErrRefundRejected, err))
|
||||
}
|
||||
return "", provider.PaidFailed, fmt.Errorf("stripe: 退款请求失败: %w", err)
|
||||
}
|
||||
return rf.ID, mapRefundStatus(rf.Status), nil
|
||||
|
||||
Reference in New Issue
Block a user