- 22 Apr, 2026 1 commit
-
-
IanShaw027 authored
-
- 21 Apr, 2026 3 commits
-
-
IanShaw027 authored
-
IanShaw027 authored
-
IanShaw027 authored
-
- 20 Apr, 2026 3 commits
-
-
IanShaw027 authored
-
IanShaw027 authored
-
erio authored
Motivation: platform-certificate mode is being phased out by WeChat (2024-10+, newly-provisioned merchants already cannot download platform certificates at all), and wxpay config errors currently surface only when an order is being created — admins have no feedback at save time. Also, errors were returned as natural-language strings, leaving the frontend no way to localize them. Changes: - backend/internal/payment/provider/wxpay.go - Replace fmt.Errorf with structured infraerrors.BadRequest errors: - WXPAY_CONFIG_MISSING_KEY (metadata: key) - WXPAY_CONFIG_INVALID_KEY_LENGTH (metadata: key, expected, actual) - WXPAY_CONFIG_INVALID_KEY (metadata: key) for malformed PEMs - Parse privateKey and publicKey PEMs in NewWxpay so malformed keys fail at save time instead of at order creation. - Keep the pubkey verifier (NewSHA256WithRSAPubkeyVerifier) as the single supported verifier; no more loadKeyPair helper. - backend/internal/service/payment_order.go invokeProvider - If CreateProvider or CreatePayment returns a structured ApplicationError, pass it through (optionally enriching metadata with provider/instance_id) instead of wrapping it as generic PAYMENT_GATEWAY_ERROR — so clients see the actual reason code (e.g. WXPAY_CONFIG_MISSING_KEY) and can localize. - Simplify a few messages (TOO_MANY_PENDING, DAILY_LIMIT_EXCEEDED, PAYMENT_GATEWAY_ERROR, NO_AVAILABLE_INSTANCE) to keyword form with metadata for template variables. - backend/internal/service/payment_config_providers.go - New helper validateProviderConfig calls provider.CreateProvider at save time. Enabled instances are validated on both Create and Update so admins see config errors immediately in the dialog, not later at order creation. - Disabled instances are not validated (half-filled drafts are allowed). - backend/internal/payment/provider/wxpay_test.go - Add generateTestKeyPair helper that produces valid RSA-2048 PKCS8/PKIX PEMs per test, used by the valid-config baseline (prior fake strings no longer pass the eager PEM check). - Cover each structured-error branch (missing/invalid-length/malformed PEM).
-
- 14 Apr, 2026 2 commits
-
-
erio authored
Backend fixes: - #1: doSub subscription idempotency via audit log check - #2: markFailed only when status=RECHARGING (prevents overwriting COMPLETED) - #3: ExpireTimedOutOrders checks upstream payment before expiring - #4: Public verify endpoint for payment result page (no auth required) - #5: EasyPay QueryOrder returns amount, confirmPayment handles zero amount - #6: WxPay notifyUrl priority: request-first, config-fallback - #7: EasyPay remove double URL decode in VerifyNotification - #8: checkPaid/cancelUpstreamPayment use order's provider instance - #9: Amount NaN/Inf/negative validation in order creation and refund - #10: Refund amount comparison uses tolerance instead of float64 == - #11: Skip balance deduction on retry when previous rollback failed - #12: checkPaid logs fulfillment errors instead of silently ignoring - #13: WxPay certSerial added to required config fields Frontend fixes: - Payment result page no longer requires authentication - Public verify API fallback for expired sessions
-
erio authored
Tests (1033 new lines, 100% coverage on modified functions): - amount.go: YuanToFen/FenToYuan with precision edge cases - wxpay: mapWxState, wxSV, formatPEM, NewWxpay validation - alipay: isTradeNotExist, NewAlipay validation - webhook: writeSuccessResponse (wxpay JSON, stripe empty, others text) - config: validateProviderRequest, isSensitiveConfigField, joinTypes - fulfillment: resolveRedeemAction idempotency logic Business logic changes: - Allow empty supported_types on provider instances - Block removing payment types when instance has pending orders - Extract resolveRedeemAction as testable pure function
-
- 11 Apr, 2026 1 commit
-
-
erio authored
Add a full payment and subscription system supporting EasyPay (Alipay/WeChat), Stripe, and direct Alipay/WeChat Pay providers with multi-instance load balancing.
-