gpay

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gpay

golang payment for alipay, wechatpay

Alipay, Wechatpay Golang Client

AlipayClient Api

  • GetOrderString
  • GetOrderQrCode
  • ReturnVerify
  • NotifyVerify

import (
    "time"
)
import (
    "github.com/sanxia/gpay/alipay"
)

var alipayClient *alipay.AlipayClient

func init(){
    appId := "you app id"
    appPrivate := "you app single line private"
    alipayPublicKey := "alipay single line public"
    alipayClient = alipay.NewAlipayClient(appId, appPrivate, alipayPublicKey)
}

func AlipayOrder() (string, error){
    outTradeNo := "test-1234567890"
    subject := "mall produce test123"
    body := "mall product info test123"
    amount := 0.01
    passbackParams := ""
    creationDate := time.Now()
    orderString, err := alipayClient.GetOrderString(
        outTradeNo,
        subject,
        body,
        amount,
        passbackParams,
        creationDate)

    return orderString, nil
}

func AlipayQrOrder() (string, error){
    outTradeNo := "test-1234567890"
    subject := "mall produce test123"
    body := "mall product info test123"
    amount := 0.01
    orderQrCode, err := alipayClient.GetOrderQrCode(
        outTradeNo,
        subject,
        body,
        amount)

    return orderQrCode, nil
}

WechatpayClient Api

  • UnifiedOrder

import (
    "time"
)
import (
    "github.com/sanxia/gpay/wechatpay"
)

var wechatpayClient *wechatpay.WechatpayClient

func init(){
    appId := "you app id"
    partnerId := "you partner id"
    apiSecret := "you api secret"
    wechatpayClient = wechatpay.NewWechatpayClient(appId, partnerId, apiSecret)
}

func WechatpayUnifiedOrder() (*wechatpay.UnifiedOrderResponse, error){
    outTradeNo := "test-1234567890"
    body := "mall product info test123"
    amount := 1
    attach := ""
    ip := "127.0.0.1"

    goodsDetail := &wechatpay.UnifiedOrderDetailItem{
        GoodsId: "test123",
        GoodsName: "test product",
        Quantity: 1,
        Price: amount,
    }
    unifiedOrderDetail := &wechatpay
    .UnifiedOrderDetail{
        GoodsDetail: []*UnifiedOrderDetailItem{
            goodsDetail
        },
    }

    return wechatpayClient.UnifiedOrder(
        outTradeNo,
        body,
        amount,
        attach,
        ip,
        unifiedOrderDetail)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TradeInfo

type TradeInfo struct {
	OutTradeNo   string    `form:"out_trade_no" json:"out_trade_no"`   //外部唯一交易号
	Subject      string    `form:"subject" json:"subject"`             //主题
	Body         string    `form:"body" json:"body"`                   //内容体
	Amount       float64   `form:"amount" json:"amount"`               //金额
	CreationDate time.Time `form:"creation_date" json:"creation_date"` //创建日期
	Extend       string    `form:"extend" json:"extend"`               //扩展数据
}

================================================================================ * TradeInfo数据域结构 * api: alipay.open.auth.token.app.query * qq group: 582452342 * email : 2091938785@qq.com * author : 美丽的地球啊 - mliu * ================================================================================

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL