JSSDK

调用JSSDK方法之前,请先参考入门

  1. // 下单,获取到微信返回的prepay_id
  2. response, err := PaymentService.Order.JSAPITransaction(ctx, &request2.RequestJSAPIPrepay{
  3. Amount: &request2.JSAPIAmount{
  4. Total: 1,
  5. Currency: "CNY",
  6. },
  7. Attach: "自定义数据说明",
  8. Description: "Image形象店-深圳腾大-QQ公仔",
  9. OutTradeNo: "5519778939773395659222498002", // 这里是商户订单号,不能重复提交给微信
  10. Payer: &request2.JSAPIPayer{
  11. OpenID: "o4QEk5Mf1Do7utS7-SF5Go30s8i4", // 用户的openid, 记得也是动态的。
  12. },
  13. })
  14. if err != nil {
  15. log.Fatalf("error: %s", err)
  16. }
  17. // 根据prepay_id, 拼接出jssdk所需要的config
  18. payConf, err := paymentService.JSSDK.BridgeConfig(response.PrepayID, true)
  19. if err != nil {
  20. panic(err)
  21. }
  22. log.Println("jssdk config: ", payConf)
  23. // --- output ---
  24. // {
  25. // "appId": "ww16143ea0101327c7",
  26. // "nonceStr": "e1L0z2JdBsFbTw4HvnvUG2Py7L3r1qbw",
  27. // "package": "prepay_id=wx2900182391460641c6c7a36f40675f0000",
  28. // "paySign": "vNGlVG7gmWA3sy8T2BygoJmjuIrw6QcSg/VtkKFk3dUj34vpePAG...63nQ==",
  29. // "signType": "RSA",
  30. // "timeStamp": "1630167503"
  31. // }