package wepay import ( "context" "fmt" "testing" "time" "quyun/app/service/testx" . "github.com/smartystreets/goconvey/convey" "github.com/stretchr/testify/suite" "go.ipao.vip/atom/contracts" "go.uber.org/dig" ) type WePayInjectParams struct { dig.In Initials []contracts.Initial `group:"initials"` Client *Client } type WePayTestSuite struct { suite.Suite WePayInjectParams } func Test_WePay(t *testing.T) { providers := testx.Default().With(Provide) testx.Serve(providers, t, func(params WePayInjectParams) { suite.Run(t, &WePayTestSuite{WePayInjectParams: params}) }) } func (s *WePayTestSuite) Test_PrePay() { Convey("get prepay", s.T(), func() { Convey("prepay", func() { resp, err := s.Client.V3TransactionJsapi(context.Background(), func(bm *BodyMap) { bm. OutTradeNo(fmt.Sprintf("test_trade_no_%d", time.Now().Unix())). Description("Test transaction"). Payer("o5Bzk644x3LOMJsKSZRlqWin74IU") }) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) s.T().Logf("prepay response: %+v", resp) sign, err := resp.PaySignOfJSAPI() So(err, ShouldBeNil) s.T().Logf("Sign: %+v", sign) }) }) }