alipay_TradeCreate.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package alipay
  2. import (
  3. "fmt"
  4. "github.com/iGoogle-ink/gopay"
  5. "github.com/iGoogle-ink/gopay/alipay"
  6. )
  7. func TradeCreate() {
  8. //aliPayPublicKey := "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1wn1sU/8Q0rYLlZ6sq3enrPZw2ptp6FecHR2bBFLjJ+sKzepROd0bKddgj+Mr1ffr3Ej78mLdWV8IzLfpXUi945DkrQcOUWLY0MHhYVG2jSs/qzFfpzmtut2Cl2TozYpE84zom9ei06u2AXLMBkU6VpznZl+R4qIgnUfByt3Ix5b3h4Cl6gzXMAB1hJrrrCkq+WvWb3Fy0vmk/DUbJEz8i8mQPff2gsHBE1nMPvHVAMw1GMk9ImB4PxucVek4ZbUzVqxZXphaAgUXFK2FSFU+Q+q1SPvHbUsjtIyL+cLA6H/6ybFF9Ffp27Y14AHPw29+243/SpMisbGcj2KD+evBwIDAQAB"
  9. //privateKey := "MIIEpgIBAAKCAQEA5JwIRwps/xrBFLCRHL727tofHEDE74I+NMkUkHCEd0qI7lOYrz72761hjw0/Np+io8DQDNf3AV0+HJGQAuMadhgmcLUnfB7BJwEL1wgc2Uk8oj8XBIJUKmc+APtJ3NhUgd7s4p63IVKjQfp8oMbGZS3/dJdamBEqGJn3bep7WlKyJy5bL3KY+fX5F1DNif8xfHBSygkniKhTt/pkKaEP6uiEvhZuorPKGTowU99cqJZAqNVGcZV/30UEerR9BHV5g3iZHRxebGNbC9WSBqVWoGhdo23Xl0QG6KmuZ1akF7mdq1e7Qlpm0SkYimqipRhSflu2N/mIW2pesypX2DRE8wIDAQABAoIBAQDDvkJsKaYoTI00nPaziWPAIm3u8BpwBbIj2mTMRDt4NQ7IGjYrH5uqn2dgaHRO3iMRWYAK70RlG6SaK50Gi9RVd9o6OTKk2WSDdCbiKOUiu826EpEv4DQW1q3Fg2S8P1MknG9yn3mog6ycStE5j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J1ADugC4vI2sNdvt7618pnT3HEJxb8J6r4gKzYzbszlGlURQQAuMfKcP7RVtO1ZYkRyhmLxM4aZxNA9I+boVrlFWDAchzg+8VuunBwIslgLHx0/4EoUWLzd1/OGtco6oU1HXhI9J9pRGjqfO1iiIifN/ujwqx7AFNknayG/YkQKBgD6yNgA/ak12rovYzXKdp14Axn+39k2dPp6J6R8MnyLlB3yruwW6NSbNhtzTD1GZ+wCQepQvYvlPPc8zm+t3tl1r+Rtx3ORf5XBZc3iPkGdPOLubTssrrAnA+U9vph61W+OjqwLJ9sHUNK9pSHhHSIS4k6ycM2YAHyIC9NGTgB0PAoGAJjwd1DgMaQldtWnuXjvohPOo8cQudxXYcs6zVRbx6vtjKe2v7e+eK1SSVrR5qFV9AqxDfGwq8THenRa0LC3vNNplqostuehLhkWCKE7Y75vXMR7N6KU1kdoVWgN4BhXSwuRxmHMQfSY7q3HG3rDGz7mzXo1FVMr/uE4iDGm0IXY="
  11. //初始化支付宝客户端
  12. // appId:应用ID
  13. // privateKey:应用私钥,支持PKCS1和PKCS8
  14. // isProd:是否是正式环境
  15. client := alipay.NewClient("2016091200494382", privateKey, false)
  16. //配置公共参数
  17. client.SetCharset("utf-8").
  18. SetSignType(alipay.RSA2).
  19. SetPrivateKeyType(alipay.PKCS1).
  20. SetNotifyUrl("https://www.gopay.ink")
  21. //请求参数
  22. body := make(gopay.BodyMap)
  23. body.Set("subject", "创建订单")
  24. body.Set("buyer_id", "2088802095984694")
  25. body.Set("out_trade_no", "GZ201901301040355709")
  26. body.Set("total_amount", "0.01")
  27. //创建订单
  28. aliRsp, err := client.TradeCreate(body)
  29. if err != nil {
  30. fmt.Println("err:", err)
  31. return
  32. }
  33. fmt.Println("aliRsp:", *aliRsp)
  34. fmt.Println("aliRsp.TradeNo:", aliRsp.Response.TradeNo)
  35. }