Case sharing: Alipay payment based on golang

藏色散人
Release: 2021-07-14 14:33:59
forward
2500 people have browsed it

A small case of Alipay payment based on golang

  • golang [Single case mode] Implement Alipay web page scan code payment and mobile payment

Usage steps

git clone git@github.com:yangliang4488/ali_pay_demo.git

cd ali_pay_demo

cp .env.example .env   (.env 里请配置相关  appid 、公钥和私钥)go run main.go
Copy after login

Avoid pitfalls

  • When viper loads the envfile configuration file, refer to the following:

    viper.SetConfigName(".env")viper.SetConfigType("env")  //  env 类型viper.AddConfigPath("./")if err := viper.ReadInConfig(); err != nil {
      fmt.Println(err)
      if _, ok := err.(viper.ConfigFileNotFoundError); ok {
          fmt.Println(".env 配置文件未找到")
          return
          }}
    Copy after login
    官方文档原文: viper.SetConfigType("json") // because there is no file extension in a stream of bytes,  supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv"
    Copy after login

For more golang related technical articles, please visit the golang tutorial column!

The above is the detailed content of Case sharing: Alipay payment based on golang. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template