bestmos
V2EX  ›  Java

微信支付 Java sdk 这个设计是不是有点奇怪

  •  
  •   bestmos · Apr 30, 2025 · 2756 views
    This topic created in 381 days ago, the information mentioned may be changed or developed.

    坐标

    <groupId>com.github.wechatpay-apiv3</groupId>
    <artifactId>wechatpay-java</artifactId>
    

    他在 app/jsapi/native 等支付中,每个交易类型一个单独的包,里面放对象 每个包一个 Transaction 类,支付回调时又拿不到是哪个类型的交易,应该用哪个包下的 Transaction 接回调的结果

    伪代码

    import com.wechat.pay.java.service.partnerpayments.nativepay.model.Transaction ;
    class{
        Transaction transaction;
        try {
            RequestParam requestParam = WeChatUtil.handleNodifyRequestParam(request);
            transaction = notificationParser.parse(requestParam, Transaction.class);
            log.info("支付回调信息: {}", transaction);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    

    如果交易类型不是 nativepay 又得换别的包下的 Transaction ,这不太对吧 有没有佬踩过这个坑

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2935 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 06:08 · PVG 14:08 · LAX 23:08 · JFK 02:08
    ♥ Do have faith in what you're doing.