Swiftpack.co - kevinzhow/wechatpay-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by kevinzhow.
kevinzhow/wechatpay-swift v0.0.13
微信支付 V3 API 的 Swift 服务端 SDK
⭐️ 41
🕓 3 weeks ago
iOS macOS
.package(url: "https://github.com/kevinzhow/wechatpay-swift.git", from: "v0.0.13")


微信支付 V3 API 的 Swift SDK,自动化了加密 & 解密过程

目前支持了 H5API


  1. 初始化 WechatPay
let wechatPay = WechatPay(
    apiV3Secret: "",
    certificatePath: "",
    wxCertificatePath: "",
    mchid: "",
    serialNo: "")
  1. 调用 H5API 进行下单
let request = WechatPay.H5API.PrepayRequest(
    mchid: "",
    description: "Test Product",
    outTradeNo: "",
    notifyURL: "",
    amount:  WechatPay.H5API.PrepayRequest.Amount(total: 6800),
    appid: "",
    sceneInfo: WechatPay.H5API.PrepayRequest.SceneInfo(
                payerClientIp: "",
                h5Info: WechatPay.H5API.PrepayRequest.SceneInfo.H5Info(type: "Wap")))

let client = WechatPay.H5API(wechatPay: wechatPay)

let h5Response = try await client.prepayWithRequestPayment(request: request)


  • 下载微信平台证书 downloadCertificates
  • 解密证书内容 decodeCert


  • 预下单 prepayWithRequestPayment
  • 查询订单 queryTransactionWithTradeNo
  • 解析微信支付通知 decodeNotification


Stars: 41
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics