v1.0.1 Latest Latest

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 20 Imported by: 0



Paygent Golang SDK


// Initalize
import ""
Paygent = paygent.New(&paygent.Config{
  MerchantID:      "PaygentMerchantID",
  ConnectID:       "PaygentConnectID",
  ConnectPassword: "PaygentConnectPassword",
  ClientFilePath:  "PaygentClientFilePath",
  CertPassword:    "CertPassword",
  CAFilePath:      "CAFilePath",
  TelegramVersion: "1.0",
  ProductionMode:  false, // production or sandbox mode

// Store Credit Card
  CustomerID: "customer_id",
  CreditCard: &gomerchant.CreditCard{
    Name:     "holder name",
    Number:   "3580876521284076",
    ExpMonth: 10,
    ExpYear:  2017,

// Get Credit Card
Paygent.GetCreditCard(gomerchant.GetCreditCardParams{CustomerID: "customer_id", CreditCardID: "3580876521284076"})

// Delete Stored Credit Card
Paygent.DeleteCreditCard(gomerchant.DeleteCreditCardParams{CustomerID: "customer_id", CreditCardID: "3580876521284076"})

// List Stored Credit Cards
Paygent.ListCreditCards(gomerchant.ListCreditCardsParams{CustomerID: "customer_id"})

// Take Auth
Paygent.Authorize(100, gomerchant.AuthorizeParams{
  Currency: "JPY",
  OrderID:  "order_id",
  PaymentMethod: &gomerchant.PaymentMethod{
    CreditCard: &gomerchant.CreditCard{
      Name:     "holder name",
      Number:   "3580876521284076",
      ExpMonth: 2,
      ExpYear:  2017,

// Take Auth with stored credit card
Paygent.Authorize(100, gomerchant.AuthorizeParams{
  Currency: "JPY",
  OrderID:  "order_id",
  PaymentMethod: &gomerchant.PaymentMethod{
    SavedCreditCard: &gomerchant.SavedCreditCard{
      CustomerID:   "customer id",
      CreditCardID: "stored card id",

// Capture
Paygent.Capture("payment_id from paygent", gomerchant.CaptureParams{})

// Refund Auth, 100 is the refuned amount
refundResponse, err := Paygent.Refund("payment id from paygent", 100, gomerchant.RefundParams{})
// after refund, paygent will return a new transaction id, get it from response

// Refund & Capture
refundResponse, err := Paygent.Refund("payment id from paygent", 100, gomerchant.RefundParams{Captured: true})

// Void Auth
Paygent.Void("payment id from paygent", gomerchant.VoidParams{})

// Void Captured Transaction
Paygent.Void("payment id from paygent", gomerchant.VoidParams{Captured: true})

// Query payment
transaction, err := Paygent.Query("payment id from paygent")

type Transaction struct {
	ID        string      // transaction id
	Amount    int         // payment amount
	Currency  string      // currency
	Captured  bool        // authorized and captured
	Paid      bool        // authorized OR captured
	Cancelled bool        // cancelled
	Status    string      // status code from paygent
	CreatedAt int64  // payment created time
	Params                // extra params

3D Mode (SecureCode Mode)

authorizeResult, err := Paygent.SecureCodeAuthorize(100,
    UserAgent: "User-Agent	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12",
    TermURL:    "",
    HttpAccept: "http",
    OrderID:  "order id",
    PaymentMethod: &gomerchant.PaymentMethod{
      CreditCard: &gomerchant.CreditCard{
        Name:     "holder name",
        Number:   "3580876521284076",
        ExpMonth: 10,
        ExpYear:  2019,

// In your controller
if authorizeResult.HandleRequest {
  if err := authorizeResult.RequestHandler(writer, request, gomerchant.Params{}); err == nil {

// In return controller (
var params gomerchant.CompleteAuthorizeParams
params.Set("request", request)
Paygent.CompleteAuthorize("payment id from paygent when get auth", params)

Advanced Mode

// Construct API request by yourself
Paygent.Request(telegramKind, gomerchant.Params{})

// For example
paygent.Request("094", gomerchant.Params{"payment_id": "payment id from paygent"})


Released under the MIT License.




This section is empty.


View Source
var PaygentServerTimeZone, _ = time.LoadLocation("Asia/Tokyo")
View Source
var ResponseParser = regexp.MustCompile(`(?s)(\w+?)=(<!DOCTYPE.*HTML>|.*?)(\r\n|$)`)
View Source
var TelegramServiceDomain = ""
View Source
var TelegramServiceSandboxDomain = ""
View Source
var TelegramServiceURLs = map[string]string{

	"01": "/n/atm/request",

	"02": "/n/card/request",

	"11": "/n/card/request",

	"03": "/n/conveni/request",

	"04": "/n/conveni/request_print",

	"05": "/n/bank/request",

	"06": "/n/bank/requestasp",

	"07": "/n/virtualaccount/request",

	"09": "/n/ref/request",

	"091": "/n/ref/paynotice",

	"093": "/n/ref/runnotice",
	"094": "/n/ref/paymentref",

	"10": "/n/c/request",

	"12": "/n/c/request",

	"20": "/n/o/requestdata",

	"13": "/n/paypal/request",

	"15": "/n/emoney/request",


This section is empty.


type Config

type Config struct {
	MerchantID      string `required:"true"`
	ConnectID       string `required:"true"`
	ConnectPassword string `required:"true"`
	TelegramVersion string

	CertPassword      string
	ClientFilePath    string // this is required, if ClientFileContent is blank
	ClientFileContent string // this is required, if ClientFilePath is blank
	CAFilePath        string // this is required, if CAFileContent is blank
	CAFileContent     string // this is required, if CAFilePath is blank

	ProductionMode bool

type Paygent

type Paygent struct {
	Config *Config

func New

func New(config *Config) *Paygent

func (*Paygent) Authorize

func (paygent *Paygent) Authorize(amount uint64, params gomerchant.AuthorizeParams) (gomerchant.AuthorizeResponse, error)

func (*Paygent) Capture

func (paygent *Paygent) Capture(transactionID string, params gomerchant.CaptureParams) (gomerchant.CaptureResponse, error)

func (*Paygent) Client

func (paygent *Paygent) Client() (*http.Client, error)

func (*Paygent) CompleteAuthorize

func (paygent *Paygent) CompleteAuthorize(paymentID string, params gomerchant.CompleteAuthorizeParams) (gomerchant.CompleteAuthorizeResponse, error)

func (*Paygent) CreateCreditCard

func (paygent *Paygent) CreateCreditCard(creditCardParams gomerchant.CreateCreditCardParams) (gomerchant.CreditCardResponse, error)

func (*Paygent) DeleteCreditCard

func (paygent *Paygent) DeleteCreditCard(deleteCreditCardParams gomerchant.DeleteCreditCardParams) (gomerchant.DeleteCreditCardResponse, error)

func (*Paygent) GetCreditCard

func (paygent *Paygent) GetCreditCard(getCreditCardParams gomerchant.GetCreditCardParams) (gomerchant.GetCreditCardResponse, error)

func (*Paygent) ListCreditCards

func (paygent *Paygent) ListCreditCards(listCreditCardsParams gomerchant.ListCreditCardsParams) (gomerchant.ListCreditCardsResponse, error)

func (*Paygent) Query

func (paygent *Paygent) Query(transactionID string) (gomerchant.Transaction, error)

func (*Paygent) Refund

func (paygent *Paygent) Refund(transactionID string, amount uint, params gomerchant.RefundParams) (response gomerchant.RefundResponse, err error)

func (*Paygent) Request

func (paygent *Paygent) Request(telegramKind string, params gomerchant.Params) (Response, error)

func (*Paygent) SecureCodeAuthorize

func (paygent *Paygent) SecureCodeAuthorize(amount uint64, secureCodeParams SecureCodeParams, params gomerchant.AuthorizeParams) (gomerchant.AuthorizeResponse, error)

func (*Paygent) Void

func (paygent *Paygent) Void(transactionID string, params gomerchant.VoidParams) (response gomerchant.VoidResponse, err error)

type Response

type Response struct {
	RawBody        string
	Result         string
	ResponseCode   string
	ResponseDetail string

type SecureCodeParams

type SecureCodeParams struct {
	UserAgent  string
	TermURL    string
	HttpAccept string

Jump to

Keyboard shortcuts

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