iamport

package module
v0.0.0-...-f07e9e7 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 8 Imported by: 0

README

go-iamport

Go Language 아임포트 Rest API Client
https://api.iamport.kr

설치

$ go get github.com/mgsmurf/go-iamport

예제

client := &http.Client{} // 상황에 맞는 클라이언트 사용
iam := iamport.NewClient("<your_api_key>", "<your_api_secret>", client)
pay, err := iam.GetPaymentImpUID("<some imp_uid>")
if err != nil {
  fmt.Println(err)
  return
}

fmt.Println(pay.Amount)
fmt.Println(pay.MerchantUID)
App Engine
client := urlfetch.Client(ctx)
iam := iamport.NewClient("<your_api_key>", "<your_api_secret>", client)
...

구현되어있는 기능 - https://api.iamport.kr

  • authenticate
    • POST /users/getToken
  • payments
    • GET /payments/{imp_uid}
    • GET /payments/find/{merchant_uid}
    • GET /payments/status/{payment_status}
    • POST /payments/cancel
  • payments.validation
    • POST /payments/prepare
    • GET /payments/prepare/merchant_uid
미구현
  • subscribe
    • POST /subscribe/payments/ontime
    • POST /subscribe/payments/again
    • POST /subscribe/payments/schedule
    • POST /subscribe/payments/unschedule
  • subscribe.customer
    • DELETE /subscribe/customers/{customer_uid}
    • GET /subscribe/customers/{customer_uid}
    • POST /subscribe/customers/{customer_uid}

Documentation

Index

Constants

View Source
const (
	// StatusAll 전체
	StatusAll = "all"
	// StatusReady 미결제
	StatusReady = "ready"
	// StatusPaid 결제 완료
	StatusPaid = "paid"
	// StatusCanceled 결제 취소
	StatusCanceled = "canceled"
	// StatusFailed 결제 실패
	StatusFailed = "failed"
)
View Source
const (
	// Bank기업은행 기업은행
	Bank기업은행 = Bank("03")
	// Bank국민은행 국민은행
	Bank국민은행 = Bank("04")
	// Bank외환은행 외환은행
	Bank외환은행 = Bank("05")
	// Bank수협중앙회 수협중앙회
	Bank수협중앙회 = Bank("07")
	// Bank농협중앙회 농협중앙회
	Bank농협중앙회 = Bank("11")
	// Bank우리은행 우리은행
	Bank우리은행 = Bank("20")
	// BankSC제일은행 SC제일은행
	BankSC제일은행 = Bank("23")
	// Bank대구은행 대구은행
	Bank대구은행 = Bank("31")
	// Bank부산은행 부산은행
	Bank부산은행 = Bank("32")
	// Bank광주은행 광주은행
	Bank광주은행 = Bank("34")
	// Bank전북은행 전북은행
	Bank전북은행 = Bank("37")
	// Bank경남은행 경남은행
	Bank경남은행 = Bank("39")
	// Bank한국씨티은행 한국씨티은행
	Bank한국씨티은행 = Bank("53")
	// Bank우체국 우체국
	Bank우체국 = Bank("71")
	// Bank하나은행 하나은행
	Bank하나은행 = Bank("81")
	// Bank통합신한은행 통합신한은행
	Bank통합신한은행 = Bank("88")
	// Bank동양종합금융증권 동양종합금융증권
	Bank동양종합금융증권 = Bank("D1")
	// Bank현대증권 현대증권
	Bank현대증권 = Bank("D2")
	// Bank미래에셋증권 미래에셋증권
	Bank미래에셋증권 = Bank("D3")
	// Bank한국투자증권 한국투자증권
	Bank한국투자증권 = Bank("D4")
	// Bank우리투자증권 우리투자증권
	Bank우리투자증권 = Bank("D5")
	// Bank하이투자증권 하이투자증권
	Bank하이투자증권 = Bank("D6")
	// BankHMC투자증권 HMC투자증권
	BankHMC투자증권 = Bank("D7")
	// BankSK증권 SK증권
	BankSK증권 = Bank("D8")
	// Bank대신증권 대신증권
	Bank대신증권 = Bank("D9")
	// Bank하나대투증권 하나대투증권
	Bank하나대투증권 = Bank("DA")
	// Bank굿모닝신한증권 굿모닝신한증권
	Bank굿모닝신한증권 = Bank("DB")
	// Bank동부증권 동부증권
	Bank동부증권 = Bank("DC")
	// Bank유진투자증권 유진투자증권
	Bank유진투자증권 = Bank("DE")
	// Bank신영증권 신영증권
	Bank신영증권 = Bank("DF")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bank

type Bank string

Bank 은행코드

type CancelOptions

type CancelOptions struct {
	Amount        string
	Reason        string
	RefundHolder  string
	RefundBank    Bank
	RefundAccount string
}

CancelOptions 결제 취소 옵션

type Client

type Client struct {
	APIKey      string
	APISecret   string
	AccessToken accessToken
	HTTP        *http.Client
}

Client 아임포트 서버와 통신하는 클라이언트

func NewClient

func NewClient(apiKey string, apiSecret string, cli *http.Client) *Client

NewClient 아임포트로 부터 부여받은 API Key와 Api Secret을 사용하여 클라이언트를 새로 만든다.

func (*Client) CancelPaymentImpUID

func (cli *Client) CancelPaymentImpUID(iuid string, options *CancelOptions) (Payment, error)

CancelPaymentImpUID imp_uid로 결제 취소하기

GET /payments/cancel

func (*Client) CancelPaymentMerchantUID

func (cli *Client) CancelPaymentMerchantUID(muid string, options *CancelOptions) (Payment, error)

CancelPaymentMerchantUID merchant_uid로 결제 취소하기

GET /payments/cancel

func (*Client) GetPaymentImpUID

func (cli *Client) GetPaymentImpUID(iuid string) (Payment, error)

GetPaymentImpUID imp_uid로 결제 정보 가져오기

GET /payments/{imp_uid}

func (*Client) GetPaymentMerchantUID

func (cli *Client) GetPaymentMerchantUID(muid string) (Payment, error)

GetPaymentMerchantUID merchant_uid로 결제 정보 가져오기

GET /payments/find/{merchant_uid}

func (*Client) GetPaymentsStatus

func (cli *Client) GetPaymentsStatus(status Status, page int) (PagedPayments, error)

GetPaymentsStatus 결제 상태에 따른 결제 정보들 가져오기

GET /payments/status/{payment_status}

func (*Client) GetPreparedPayment

func (cli *Client) GetPreparedPayment(muid string) (Prepared, error)

GetPreparedPayment 사전 등록된 결제 정보 보기

GET /payments/prepare/{merchant_uid}

func (*Client) GetToken

func (cli *Client) GetToken() error

GetToken APIKey와 APISecret을 사용하여 AccessToken을 받아 온다.

func (*Client) PreparePayment

func (cli *Client) PreparePayment(muid string, amount int64) (Prepared, error)

PreparePayment 결제 정보 사전 등록하기

POST /payments/prepare

type PagedPayments

type PagedPayments struct {
	Total    int       `json:"total"`
	Previous int       `json:"previous"`
	Next     int       `json:"next"`
	Payments []Payment `json:"list"`
}

PagedPayments 다수의 결제 정보

type Payment

type Payment struct {
	ImpUID        string `json:"imp_uid"`
	MerchantUID   string `json:"merchant_uid"`
	PayMethod     string `json:"pay_method"`
	PGProvider    string `json:"pg_provider"`
	PGTID         string `json:"pg_tid"`
	ApplyNum      string `json:"apply_num"`
	CardName      string `json:"card_name"`
	CardQuota     int    `json:"card_quota"`
	VBankName     string `json:"vbank_name"`
	VBankNum      string `json:"vbank_num"`
	VBankHolder   string `json:"vbank_holder"`
	Name          string `json:"name"`
	Amount        int64  `json:"amount"`
	CancelAmount  int64  `json:"cancel_amount"`
	BuyerName     string `json:"buyer_name"`
	BuyerEmail    string `json:"buyer_email"`
	BuyerTel      string `json:"buyer_tel"`
	BuyerAddr     string `json:"buyer_addr"`
	BuyerPostCode string `json:"buyer_postcode"`
	CustomData    string `json:"custom_data"`
	UserAgent     string `json:"user_agent"`
	Status        string `json:"status"`
	PaidAt        int64  `json:"paid_at"`
	FailedAt      int64  `json:"failed_at"`
	CanceledAt    int64  `json:"canceled_at"`
	FailReason    string `json:"fail_reason"`
	CancelReason  string `json:"cancel_reason"`
	ReceiptURL    string `json:"receipt_url"`
}

Payment 결제 정보

type Prepared

type Prepared struct {
	MerchantUID string `json:"merchant_uid"`
	Amount      int64  `json:"amount"`
}

Prepared 사전 등록된 결제 정보

type Status

type Status string

Status 결제 상태

Jump to

Keyboard shortcuts

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