Home>Article>Backend Development> Case sharing: Alipay payment based on golang

Case sharing: Alipay payment based on golang

藏色散人
藏色散人 forward
2021-07-14 14:33:59 2401browse

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

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 }}
    官方文档原文: 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"

For more golang related technical articles, please visit thegolangtutorial 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!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete