paygent

package
v0.0.0-...-62f474b Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 21 Imported by: 0

README

Paygent

Paygent Golang SDK

Usage

// Initalize
import "github.com/qor/gomerchant/gateways/paygent"
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
Paygent.CreateCreditCard(gomerchant.CreateCreditCardParams{
  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
refundResponse.TransactionID

// 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 *time.Time  // payment created time
	Params                // extra params
}

3D Mode (SecureCode Mode)

authorizeResult, err := Paygent.SecureCodeAuthorize(100,
  paygent.SecureCodeParams{
    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:    "http://getqor.com/order/return",
    HttpAccept: "http",
  },
  gomerchant.AuthorizeParams{
    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 {
    return
  }
}

// In return controller (http://getqor.com/order/return)
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"})

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PaygentServerTimeZone, _ = time.LoadLocation("Asia/Tokyo")
View Source
var ResponseParser = regexp.MustCompile(`(?s)(\w+?)=(<!DOCTYPE.*HTML>|.*?)(\r\n|$)`)
View Source
var TelegramServiceDomain = "https://service.paygent.co.jp"
View Source
var TelegramServiceSandboxDomain = "https://sandbox.paygent.co.jp"
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",

	"270": "/n/rakutenid/request",
	"271": "/n/rakutenid/request",
	"272": "/n/rakutenid/request",
	"273": "/n/rakutenid/request",

	"420": "/n/paypay/request",
	"421": "/n/paypay/request",
	"422": "/n/paypay/request",
}

Functions

This section is empty.

Types

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
	SecurityCodeUse 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) InquiryNotification

func (paygent *Paygent) InquiryNotification(noticeID string) (response gomerchant.InquiryResponse, err error)

func (*Paygent) ListCreditCards

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

func (*Paygent) PayPayApplicationMessage

func (paygent *Paygent) PayPayApplicationMessage(amount uint64, params gomerchant.ApplicationParams) (gomerchant.ApplicationResponse, error)

Paypay authrioze function

func (*Paygent) PayPayCancelAndRefundMessage

func (paygent *Paygent) PayPayCancelAndRefundMessage(transactionID string, amount uint) (gomerchant.RefundResponse, error)

func (*Paygent) PayPaySalesMessage

func (paygent *Paygent) PayPaySalesMessage(transactionID string) (gomerchant.CaptureResponse, error)

func (*Paygent) Query

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

func (*Paygent) RakutePayApplicationMessage

func (paygent *Paygent) RakutePayApplicationMessage(amount uint64, params gomerchant.ApplicationParams) (gomerchant.ApplicationResponse, error)

This is rakuten pay authorize function Before user confirmed on rakuten page status is 10:already applid After user confirmed status change to 20: Authorization OK

func (*Paygent) RakutenPayCancellationMessage

func (paygent *Paygent) RakutenPayCancellationMessage(transactionID string) (gomerchant.VoidResponse, error)

This is rakuten pay void function

func (*Paygent) RakutenPayCorrectionMessage

func (paygent *Paygent) RakutenPayCorrectionMessage(transactionID string, amount uint) (gomerchant.RefundResponse, error)

func (*Paygent) RakutenPaySalesMessage

func (paygent *Paygent) RakutenPaySalesMessage(transactionID string) (gomerchant.CaptureResponse, error)

This is rakuten pay capture function

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
	gomerchant.Params
}

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