GithubHelp home page GithubHelp logo

unionpay's Introduction

unionpay

**银联接口 golang实现方法,可做后台请求银联使用

使用方法

package main

import (
	"fmt"

	"github.com/panjjo/unionpay"
)

func main() {
	var err error
	//初始化证书
	//pfxpath和pfxpwd同时存在,privatepath和certpath同时存在,两组传任意一组皆可
	err = unionpay.LoadCert(&unionpay.Config{

		//银联提供的pfx证书存放路径,商户私钥
		PfxPath: "/tmp/up/700000000000001_acp.pfx",

		//pfx证书密码
		PfxPwd: "000000",

		//数据加密证书路径,银联公钥
		EncryptCertPath: "/tmp/up/verify_sign_acp.cer",

		//用户私钥地址,私钥通过pfx解析得到
		// openssl pkcs12 -in xxxx.pfx -nodes -out server.pem 生成为原生格式pem 私钥
		// openssl rsa -in server.pem -out server.key  生成为rsa格式私钥文件
		PrivatePath: "/tmp/up/private.key",

		//用户证书,通过pfx解析得到
		// openssl pkcs12 -in xxxx.pfx -clcerts -nokeys -out key.cert
		CertPath: "/tmp/up/key.cert",
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	//配置环境信息
	unionpay.SetConfig(&unionpay.Config{
		// 商户号
		MerId: "777290058143951",
		//域名信息
		Url: "https://gateway.test.95516.com",
	})
	//实例化 代付
	payforanthoer, err := unionpay.NewPayForAnother(unionpay.ApiConfig{
		//域名信息
		Url: "https://gateway.test.95516.com",
	})
	fmt.Println(err)
	customer := unionpay.CustomerInfo{}
	customer.CustomerNm = "全渠道"
	customer.PhoneNo = "13552535506"
	read := unionpay.RequestParams{}
	read.AccNo = "6216261000000000018"
	read.Customer = &customer
	//实名认证
	/*result, err := payforanthoer.RealNameAuth("1233", &read)
	fmt.Println(result, err)*/
	//支付
	result, err := payforanthoer.Pay(100, &read)
	fmt.Println(result, err)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.