payjp

package
v0.0.0-...-3bdd5ca Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package payjp contains REST based payment API for PAY.JP. It supports paying in each case and subscription paying, customer management and more.

PAY.JPは、RESTをベースに構成された決済APIです。都度の支払い、定期的な支払い、 顧客情報の管理など、ビジネス運用における様々なことができます。

- PAY.JP Getting Started Guide: https://pay.jp/docs/started

- PAY.JP API Docs: https://pay.jp/docs/api/

Installation

You can download Pay.jp Golang SDK by the following command:

$ go get github.com/D-Technologies/payjp-go/v1

How To Use

Entry point of this package is payjp.New():

pay := payjp.New("api key", nil)

pay has several children like Token, Customer, Plan, Subscription etc:

customer := pay.Customer.Retrieve("customer ID")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountResponse

type AccountResponse struct {
	ID        string    // acct_で始まる一意なオブジェクトを示す文字列
	Email     string    // メールアドレス
	CreatedAt time.Time // このアカウント作成時のタイムスタンプ
	Merchant  struct {
		ID                  string    // acct_mch_で始まる一意なオブジェクトを示す文字列
		BankEnabled         bool      // 入金先銀行口座情報が設定済みかどうか
		BrandsAccepted      []string  // 本番環境で利用可能なカードブランドのリスト
		CurrenciesSupported []string  // 対応通貨のリスト
		DefaultCurrency     string    // 3文字のISOコード(現状 “jpy” のみサポート)
		BusinessType        string    // 業務形態
		ContactPhone        string    // 電話番号
		Country             string    // 所在国
		ChargeType          []string  // 支払い方法種別のリスト
		ProductDetail       string    // 販売商品の詳細
		ProductName         string    // 販売商品名
		ProductType         []string  // 販売商品の種類リスト
		DetailsSubmitted    bool      // 本番環境申請情報が提出済みかどうか
		LiveModeEnabled     bool      // 本番環境が有効かどうか
		LiveModeActivatedAt time.Time // 本番環境が許可された日時のタイムスタンプ
		SitePublished       bool      // 申請対象のサイトがオープン済みかどうか

		URL       string    // 申請対象サイトのURL
		CreatedAt time.Time // 作成時のタイムスタンプ
	} // マーチャントアカウントの詳細情報
}

AccountResponse はAccount.Retrieve()メソッドが返す構造体です

func (*AccountResponse) UnmarshalJSON

func (a *AccountResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService はあなたのアカウント情報を返します。

func (*AccountService) Retrieve

func (t *AccountService) Retrieve(ctx context.Context) (*AccountResponse, error)

Retrieve account object. あなたのアカウント情報を取得します。

type Card

type Card struct {
	Name         interface{}       // カード保有者名(e.g. YUI ARAGAKI)
	Number       interface{}       // カード番号
	ExpMonth     interface{}       // 有効期限月
	ExpYear      interface{}       // 有効期限年
	CVC          interface{}       // CVCコード
	Country      interface{}       // 2桁のISOコード(e.g. JP)
	AddressZip   interface{}       // 郵便番号
	AddressState interface{}       // 都道府県
	AddressCity  interface{}       // 市区町村
	AddressLine1 interface{}       // 番地など
	AddressLine2 interface{}       // 建物名など
	Metadata     map[string]string // メタデータ
}

Card はCustomerやTokenのAPIでカード情報を設定する時に使う構造体です

type CardResponse

type CardResponse struct {
	CreatedAt       time.Time         // カード作成時のタイムスタンプ
	ID              string            // car_で始まる一意なオブジェクトを示す文字列
	Name            string            // カード保有者名(e.g. YUI ARAGAKI)
	Last4           string            // カード番号の下四桁
	ExpMonth        int               // 有効期限月
	ExpYear         int               // 有効期限年
	Brand           string            // カードブランド名(e.g. Visa)
	CvcCheck        string            // CVCコードチェックの結果
	Fingerprint     string            // このクレジットカード番号に紐づけられた一意(他と重複しない)キー
	Country         string            // 2桁のISOコード(e.g. JP)
	AddressZip      string            // 郵便番号
	AddressZipCheck string            // 郵便番号存在チェックの結果
	AddressState    string            // 都道府県
	AddressCity     string            // 市区町村
	AddressLine1    string            // 番地など
	AddressLine2    string            // 建物名など
	Metadata        map[string]string // メタデータ
	// contains filtered or unexported fields
}

CardResponse はCustomerやTokenのAPIが返す構造体です

func (*CardResponse) Delete

func (c *CardResponse) Delete(ctx context.Context) error

Delete メソッドは顧客に登録されているカードを削除します Customer情報から得られるカードでしか削除はできません

func (*CardResponse) UnmarshalJSON

func (c *CardResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

func (*CardResponse) Update

func (c *CardResponse) Update(ctx context.Context, card Card) error

Update メソッドはカードの内容を更新します Customer情報から得られるカードでしか更新はできません

type Charge

type Charge struct {
	Currency       string            // 必須: 3文字のISOコード(現状 “jpy” のみサポート)
	CustomerID     string            // 顧客ID (CardかCustomerのどちらかは必須パラメータ)
	Card           Card              // カードオブジェクト(cardかcustomerのどちらかは必須)
	CardToken      string            // トークンID (CardかCustomerのどちらかは必須パラメータ)
	CustomerCardID string            // 顧客のカードID
	Capture        bool              // 支払い処理を確定するかどうか (falseの場合、カードの認証と支払い額の確保のみ行う)
	Description    string            // 概要
	ExpireDays     interface{}       // デフォルトで7日となっており、1日~60日の間で設定が可能
	TenantID       string            // テナントの指定(Platform APIを使用時に必要)
	PlatformFee    int               // プラットフォーマーの入金金額
	Metadata       map[string]string // メタデータ
}

Charge 構造体はCharge.Createのパラメータを設定するのに使用します

type ChargeListCaller

type ChargeListCaller struct {
	// contains filtered or unexported fields
}

ChargeListCaller はリスト取得に使用する構造体です。

Fluentインタフェースを提供しており、最後にDoを呼ぶことでリストが取得できます:

pay := payjp.New("api-key", nil)
charges, err := pay.Charge.List().Limit(50).Offset(150).Do()

func (*ChargeListCaller) CustomerID

func (c *ChargeListCaller) CustomerID(id string) *ChargeListCaller

CustomerID を指定すると、指定した顧客の支払いのみを取得します

func (*ChargeListCaller) Do

Do は指定されたクエリーを元に支払いのリストを配列で取得します。

func (*ChargeListCaller) Limit

func (c *ChargeListCaller) Limit(limit int) *ChargeListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*ChargeListCaller) Offset

func (c *ChargeListCaller) Offset(offset int) *ChargeListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*ChargeListCaller) Since

func (c *ChargeListCaller) Since(since time.Time) *ChargeListCaller

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*ChargeListCaller) SubscriptionID

func (c *ChargeListCaller) SubscriptionID(id string) *ChargeListCaller

SubscriptionID を指定すると、指定した定期購読の支払いのみを取得します

func (*ChargeListCaller) TenantID

func (c *ChargeListCaller) TenantID(id string) *ChargeListCaller

TenantID を指定すると、指定したテナントの決済情報のみを取得します

func (*ChargeListCaller) Until

func (c *ChargeListCaller) Until(until time.Time) *ChargeListCaller

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type ChargeResponse

type ChargeResponse struct {
	ID               string            // ch_で始まる一意なオブジェクトを示す文字列
	LiveMode         bool              // 本番環境かどうか
	CreatedAt        time.Time         // この支払い作成時のタイムスタンプ
	Amount           int               // 支払額
	Currency         string            // 3文字のISOコード(現状 “jpy” のみサポート)
	Paid             bool              // 認証処理が成功しているかどうか。
	ExpiredAt        time.Time         // 認証状態が自動的に失効される日時のタイムスタンプ
	Captured         bool              // 支払い処理を確定しているかどうか
	CapturedAt       time.Time         // 支払い処理確定時のタイムスタンプ
	Card             CardResponse      // 支払いされたクレジットカードの情報
	CustomerID       string            // 顧客ID
	Description      string            // 概要
	FailureCode      string            // 失敗した支払いのエラーコード
	FailureMessage   string            // 失敗した支払いの説明
	Refunded         bool              // 返金済みかどうか
	AmountRefunded   int               // この支払いに対しての返金額
	RefundReason     string            // 返金理由
	SubscriptionID   string            // sub_から始まる定期課金のID
	TenantID         string            // テナントID
	TotalPlatformFee int               // プラットフォーム利用料総額
	PlatformFee      int               // プラットフォーマーに振り分けられる入金金額。
	PlatformFeeRate  string            // テナント作成時に指定したプラットフォーム利用料率(%)
	Metadata         map[string]string // メタデータ
	// contains filtered or unexported fields
}

ChargeResponse はCharge.Getなどで返される、支払いに関する情報を持った構造体です

func (*ChargeResponse) Capture

func (c *ChargeResponse) Capture(ctx context.Context) error

Capture は認証状態となった処理待ちの支払い処理を確定させます。具体的には Captured="false" となった支払いが該当します。

amount をセットすることで、支払い生成時の金額と異なる金額の支払い処理を行うことができます。 ただし amount は、支払い生成時の金額よりも少額である必要があるためご注意ください。

amount をセットした場合、AmountRefunded に認証時の amount との差額が入ります。

例えば、認証時に amount=500 で作成し、 amount=400 で支払い確定を行った場合、 AmountRefunded=100 となり、確定金額が400円に変更された状態で支払いが確定されます。

func (*ChargeResponse) Refund

func (c *ChargeResponse) Refund(ctx context.Context, reason string, amount ...int) error

Refund 支払い済みとなった処理を返金します。 全額返金、及び amount を指定することで金額の部分返金を行うことができます。ただし部分返金を最初に行った場合、2度目の返金は全額返金しか行うことができないため、ご注意ください。

func (*ChargeResponse) UnmarshalJSON

func (c *ChargeResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

func (*ChargeResponse) Update

func (c *ChargeResponse) Update(ctx context.Context, description string, metadata ...map[string]string) error

Update は支払い情報のDescriptionとメタデータ(オプション)を更新します

type ChargeService

type ChargeService struct {
	// contains filtered or unexported fields
}

ChargeService 都度の支払いや定期購入の引き落としのときに生成される、支払い情報を取り扱います。

func (ChargeService) Capture

func (c ChargeService) Capture(ctx context.Context, chargeID string) (*ChargeResponse, error)

Capture は認証状態となった処理待ちの支払い処理を確定させます。具体的には Captured="false" となった支払いが該当します。

amount をセットすることで、支払い生成時の金額と異なる金額の支払い処理を行うことができます。 ただし amount は、支払い生成時の金額よりも少額である必要があるためご注意ください。

amount をセットした場合、AmountRefunded に認証時の amount との差額が入ります。

例えば、認証時に amount=500 で作成し、 amount=400 で支払い確定を行った場合、 AmountRefunded=100 となり、確定金額が400円に変更された状態で支払いが確定されます。

func (ChargeService) Create

func (c ChargeService) Create(ctx context.Context, amount int, charge Charge) (*ChargeResponse, error)

Create はトークンID、カードを保有している顧客ID、カードオブジェクトのいずれかのパラメーターを指定して支払いを作成します。 顧客IDを使って支払いを作成する場合は CustomerCardID に顧客の保有するカードのIDを指定でき、省略された場合はデフォルトカードとして登録されているものが利用されます。 テスト用のキーでは、本番用の決済ネットワークへは接続されず、実際の請求が行われることもありません。 本番用のキーでは、決済ネットワークで処理が行われ、実際の請求が行われます。

支払いを確定せずに、カードの認証と支払い額のみ確保する場合は、 Capture に false を指定してください。 このとき ExpireDays を指定することで、認証の期間を定めることができます。 ExpireDays はデフォルトで7日となっており、1日~60日の間で設定が可能です。

func (ChargeService) List

func (c ChargeService) List() *ChargeListCaller

List は生成した支払い情報のリストを取得します。リストは、直近で生成された順番に取得されます。

func (ChargeService) Refund

func (c ChargeService) Refund(ctx context.Context, chargeID, reason string, amount ...int) (*ChargeResponse, error)

Refund は支払い済みとなった処理を返金します。 Amount省略時は全額返金、指定時に金額の部分返金を行うことができます。 ただし部分返金を最初に行った場合、2度目の返金は全額返金しか行うことができないため、ご注意ください。

func (ChargeService) Retrieve

func (c ChargeService) Retrieve(ctx context.Context, chargeID string) (*ChargeResponse, error)

Retrieve charge object. 支払い情報を取得します。

func (ChargeService) Update

func (c ChargeService) Update(ctx context.Context, chargeID, description string, metadata ...map[string]string) (*ChargeResponse, error)

Update は支払い情報のDescriptionを更新します。

type Config

type Config struct {
	APIBase string // APIのエンドポイントのURL(省略時は'https://api.pay.jp/v1')
}

Config 構造体はNewに渡すパラメータを設定するのに使用します。

type Customer

type Customer struct {
	Email       interface{}       // メールアドレス
	Description interface{}       // 概要
	ID          interface{}       // 一意の顧客ID
	CardToken   interface{}       // トークンID
	DefaultCard interface{}       // デフォルトカード
	Card        Card              // カード
	Metadata    map[string]string // メタデータ
}

Customer は顧客の登録や更新時に使用する構造体です

type CustomerCardListCaller

type CustomerCardListCaller struct {
	// contains filtered or unexported fields
}

CustomerCardListCaller はカードのリスト取得に使用する構造体です。

Fluentインタフェースを提供しており、最後にDoを呼ぶことでリストが取得できます:

pay := payjp.New("api-key", nil)
cards, err := pay.Customer.ListCard("userID").Limit(50).Offset(150).Do()

func (*CustomerCardListCaller) Do

Do は指定されたクエリーを元に支払いのリストを配列で取得します。

func (*CustomerCardListCaller) Limit

Limit はリストの要素数の最大値を設定します(1-100)

func (*CustomerCardListCaller) Offset

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*CustomerCardListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*CustomerCardListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type CustomerListCaller

type CustomerListCaller struct {
	// contains filtered or unexported fields
}

CustomerListCaller はリスト取得に使用する構造体です。

Fluentインタフェースを提供しており、最後にDoを呼ぶことでリストが取得できます:

pay := payjp.New("api-key", nil)
customers, err := pay.Customer.List().Limit(50).Offset(150).Do()

func (*CustomerListCaller) Do

Do は指定されたクエリーを元に顧客のリストを配列で取得します。

func (*CustomerListCaller) Limit

func (c *CustomerListCaller) Limit(limit int) *CustomerListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*CustomerListCaller) Offset

func (c *CustomerListCaller) Offset(offset int) *CustomerListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*CustomerListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*CustomerListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type CustomerResponse

type CustomerResponse struct {
	ID            string                  // 一意なオブジェクトを示す文字列
	LiveMode      bool                    // 本番環境かどうか
	CreatedAt     time.Time               // この顧客作成時のタイムスタンプ
	DefaultCard   string                  // 支払いに使用されるカードのcar_から始まるID
	Cards         []*CardResponse         // この顧客に紐づけられているカードのリスト
	Email         string                  // メールアドレス
	Description   string                  // 概要
	Subscriptions []*SubscriptionResponse // この顧客が購読している定期課金のリスト
	Metadata      map[string]string       // メタデータ
	// contains filtered or unexported fields
}

CustomerResponse はCustomerService.GetやCustomerService.Listで返される顧客を表す構造体です

func (*CustomerResponse) AddCard

func (c *CustomerResponse) AddCard(ctx context.Context, card Card) (*CardResponse, error)

AddCard はカード情報のパラメーターを指定して、新たにカードを追加します。ただし同じカード番号および同じ有効期限年/月のカードは、重複追加することができません。

func (*CustomerResponse) AddCardToken

func (c *CustomerResponse) AddCardToken(ctx context.Context, token string) (*CardResponse, error)

AddCardToken はトークンIDを指定して、新たにカードを追加します。ただし同じカード番号および同じ有効期限年/月のカードは、重複追加することができません。

func (*CustomerResponse) Delete

func (c *CustomerResponse) Delete(ctx context.Context) error

Delete は生成した顧客情報を削除します。削除した顧客情報は、もう一度生成することができないためご注意ください。

func (CustomerResponse) DeleteCard

func (c CustomerResponse) DeleteCard(ctx context.Context, cardID string) error

DeleteCard は顧客の特定のカードを削除します。

func (*CustomerResponse) GetCard

func (c *CustomerResponse) GetCard(ctx context.Context, cardID string) (*CardResponse, error)

GetCard は顧客の特定のカード情報を取得します。

func (*CustomerResponse) GetSubscription

func (c *CustomerResponse) GetSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResponse, error)

GetSubscription は顧客の特定の定期課金情報を取得します。

func (*CustomerResponse) ListCard

ListCard は顧客の保持しているカードリストを取得します。リストは、直近で生成された順番に取得されます。

func (*CustomerResponse) ListSubscription

func (c *CustomerResponse) ListSubscription() *SubscriptionListCaller

ListSubscription は顧客の定期課金リストを取得します。リストは、直近で生成された順番に取得されます。

func (*CustomerResponse) UnmarshalJSON

func (c *CustomerResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

func (*CustomerResponse) Update

func (c *CustomerResponse) Update(ctx context.Context, customer Customer) error

Update は生成した顧客情報を更新したり、新たなカードを顧客に追加することができます。

また default_card に保持しているカードIDを指定することで、メイン利用のカードを変更することもできます。

func (CustomerResponse) UpdateCard

func (c CustomerResponse) UpdateCard(ctx context.Context, cardID string, card Card) (*CardResponse, error)

UpdateCard は顧客の特定のカード情報を更新します。

type CustomerService

type CustomerService struct {
	// contains filtered or unexported fields
}

CustomerService は顧客を管理する機能を提供します。

顧客における都度の支払いや定期購入、複数カードの管理など、さまざまなことができます。 作成した顧客は、あとからカードを追加・更新・削除したり、顧客自体を削除することができます。

func (CustomerService) AddCard

func (c CustomerService) AddCard(ctx context.Context, customerID string, card Card) (*CardResponse, error)

AddCard はカード情報のパラメーターを指定して、新たにカードを追加します。ただし同じカード番号および同じ有効期限年/月のカードは、重複追加することができません。

func (CustomerService) AddCardToken

func (c CustomerService) AddCardToken(ctx context.Context, customerID, token string) (*CardResponse, error)

AddCardToken はトークンIDを指定して、新たにカードを追加します。ただし同じカード番号および同じ有効期限年/月のカードは、重複追加することができません。

func (CustomerService) Create

func (c CustomerService) Create(ctx context.Context, customer Customer) (*CustomerResponse, error)

Create はメールアドレスやIDなどを指定して顧客を作成します。

作成と同時にカード情報を登録する場合、トークンIDかカードオブジェクトのどちらかを指定します。

作成した顧客やカード情報はあとから更新・削除することができます。

DefaultCardは更新時のみ設定が可能です

func (CustomerService) Delete

func (c CustomerService) Delete(ctx context.Context, id string) error

Delete は生成した顧客情報を削除します。削除した顧客情報は、もう一度生成することができないためご注意ください。

func (CustomerService) DeleteCard

func (c CustomerService) DeleteCard(ctx context.Context, customerID, cardID string) error

DeleteCard は顧客の特定のカードを削除します。

func (CustomerService) GetCard

func (c CustomerService) GetCard(ctx context.Context, customerID, cardID string) (*CardResponse, error)

GetCard は顧客の特定のカード情報を取得します。

func (CustomerService) GetSubscription

func (c CustomerService) GetSubscription(ctx context.Context, customerID, subscriptionID string) (*SubscriptionResponse, error)

GetSubscription は顧客の特定の定期課金情報を取得します。

func (CustomerService) List

List は生成した顧客情報のリストを取得します。リストは、直近で生成された順番に取得されます。

func (CustomerService) ListCard

func (c CustomerService) ListCard(customerID string) *CustomerCardListCaller

ListCard は顧客の保持しているカードリストを取得します。リストは、直近で生成された順番に取得されます。

func (CustomerService) ListSubscription

func (c CustomerService) ListSubscription(customerID string) *SubscriptionListCaller

ListSubscription は顧客の定期課金リストを取得します。リストは、直近で生成された順番に取得されます。

func (CustomerService) Retrieve

func (c CustomerService) Retrieve(ctx context.Context, id string) (*CustomerResponse, error)

Retrieve customer object. 顧客情報を取得します。

func (CustomerService) Update

func (c CustomerService) Update(ctx context.Context, id string, customer Customer) (*CustomerResponse, error)

Update は生成した顧客情報を更新したり、新たなカードを顧客に追加します。

また default_card に保持しているカードIDを指定することで、メイン利用のカードを変更することもできます。

func (CustomerService) UpdateCard

func (c CustomerService) UpdateCard(ctx context.Context, customerID, cardID string, card Card) (*CardResponse, error)

UpdateCard は顧客の特定のカード情報を更新します。

type DeleteResponse

type DeleteResponse struct {
	Deleted  bool   `json:"deleted"`
	ID       string `json:"id"`
	LiveMode bool   `json:"livemode"`
}

DeleteResponse はイベントの種類がDeleteEventの時にDeleteData()が返す構造体です。

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Param   string `json:"param"`
	Status  int    `json:"status"`
	Type    string `json:"type"`
}

Error はPAY.JP固有のエラーを表す構造体です

func (Error) Error

func (ce Error) Error() string

type EventListCaller

type EventListCaller struct {
	// contains filtered or unexported fields
}

EventListCaller はイベントのリスト取得に使用する構造体です。

func (*EventListCaller) Do

Do は指定されたクエリーを元にイベントのリストを配列で取得します。

func (*EventListCaller) Limit

func (e *EventListCaller) Limit(limit int) *EventListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*EventListCaller) Object

func (e *EventListCaller) Object(object string) *EventListCaller

Object は取得するeventに紐づくAPIリソースのオブジェクト名を設定します (e.g. customer, charge)

func (*EventListCaller) Offset

func (e *EventListCaller) Offset(offset int) *EventListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*EventListCaller) ResourceID

func (e *EventListCaller) ResourceID(id string) *EventListCaller

ResourceID は取得するeventに紐づくAPIリソースのIDを設定します (e.g. customer.id)

func (*EventListCaller) Since

func (e *EventListCaller) Since(since time.Time) *EventListCaller

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*EventListCaller) Type

func (e *EventListCaller) Type(typeString string) *EventListCaller

Type は取得するeventのtypeを設定します

func (*EventListCaller) Until

func (e *EventListCaller) Until(until time.Time) *EventListCaller

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type EventResponse

type EventResponse struct {
	CreatedAt       time.Time
	ID              string
	LiveMode        bool
	Type            string
	PendingWebHooks int
	ResultType      EventType
	// contains filtered or unexported fields
}

EventResponse は、EventService.Retrieve()/EventService.List()が返す構造体です。

func (EventResponse) CardData

func (e EventResponse) CardData() (*CardResponse, error)

CardData は、イベントの種類がCardEventの時にCardResponse構造体を返します。

func (EventResponse) ChargeData

func (e EventResponse) ChargeData() (*ChargeResponse, error)

ChargeData は、イベントの種類がChargeEventの時にChargeResponse構造体を返します。

func (EventResponse) CustomerData

func (e EventResponse) CustomerData() (*CustomerResponse, error)

CustomerData は、イベントの種類がCustomerEventの時にCustomerResponse構造体を返します。

func (EventResponse) DeleteData

func (e EventResponse) DeleteData() (*DeleteResponse, error)

DeleteData は、イベントの種類がDeleteEventの時にDeleteResponse構造体を返します。

func (EventResponse) PlanData

func (e EventResponse) PlanData() (*PlanResponse, error)

PlanData は、イベントの種類がPlanEventの時にPlanResponse構造体を返します。

func (EventResponse) SubscriptionData

func (e EventResponse) SubscriptionData() (*SubscriptionResponse, error)

SubscriptionData は、イベントの種類がSubscriptionEventの時にSubscriptionResponse構造体を返します。

func (EventResponse) TokenData

func (e EventResponse) TokenData() (*TokenResponse, error)

TokenData は、イベントの種類がTokenEventの時にTokenResponse構造体を返します。

func (EventResponse) TransferData

func (e EventResponse) TransferData() (*TransferResponse, error)

TransferData は、イベントの種類がTransferEventの時にTransferResponse構造体を返します。

func (*EventResponse) UnmarshalJSON

func (e *EventResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

type EventService

type EventService struct {
	// contains filtered or unexported fields
}

EventService は作成、更新、削除などのイベントを表示するサービスです。

イベント情報は、Webhookで任意のURLへ通知設定をすることができます。

func (EventService) List

func (e EventService) List() *EventListCaller

List はイベントリストを取得します。リストは、直近で生成された順番に取得されます。

func (EventService) Retrieve

func (e EventService) Retrieve(ctx context.Context, id string) (*EventResponse, error)

Retrieve event object. 特定のイベント情報を取得します。

type EventType

type EventType int

EventType は、イベントのレスポンスの型を表す列挙型です。 EventResponse.ResultTypeで種類を表すのに使用されます。

const (
	// ChargeEvent の場合はイベントに含まれるのがCharge型です
	ChargeEvent EventType = iota
	// TokenEvent の場合はイベントに含まれるのがToken型です
	TokenEvent
	// CustomerEvent の場合はイベントに含まれるのがCustomer型です
	CustomerEvent
	// CardEvent の場合はイベントに含まれるのがCard型です
	CardEvent
	// PlanEvent の場合はイベントに含まれるのがPlan型です
	PlanEvent
	// DeleteEvent の場合はイベントに含まれるのがDelete型です
	DeleteEvent
	// SubscriptionEvent の場合はイベントに含まれるのがSubscription型です
	SubscriptionEvent
	// TransferEvent の場合はイベントに含まれるのがTransfer型です
	TransferEvent
)

type Plan

type Plan struct {
	Amount     int               // 必須: 金額。50~9,999,999の整数
	Currency   string            // 3文字のISOコード(現状 “jpy” のみサポート)
	Interval   string            // month のみ指定可能
	ID         string            // プランID
	Name       string            // プランの名前
	TrialDays  int               // トライアル日数
	BillingDay int               // 支払いの実行日(1〜31)
	Metadata   map[string]string // メタデータ
}

Plan はプランの作成時に使用する構造体です。

type PlanListCaller

type PlanListCaller struct {
	// contains filtered or unexported fields
}

PlanListCaller はプランのリスト取得に使用する構造体です。

func (*PlanListCaller) Do

Do は指定されたクエリーを元にプランのリストを配列で取得します。

func (*PlanListCaller) Limit

func (c *PlanListCaller) Limit(limit int) *PlanListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*PlanListCaller) Offset

func (c *PlanListCaller) Offset(offset int) *PlanListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*PlanListCaller) Since

func (c *PlanListCaller) Since(since time.Time) *PlanListCaller

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*PlanListCaller) Until

func (c *PlanListCaller) Until(until time.Time) *PlanListCaller

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type PlanResponse

type PlanResponse struct {
	ID         string            // 一意なオブジェクトを示す文字列
	LiveMode   bool              // 本番環境かどうか
	CreatedAt  time.Time         // このプラン作成時のタイムスタンプ
	Amount     int               // プラン金額
	Currency   string            // 3文字のISOコード(現状 “jpy” のみサポート)
	Interval   string            // 課金周期(現状"month"のみサポート)
	Name       string            // プラン名
	TrialDays  int               // トライアル日数
	BillingDay int               // 課金日(1-31)
	Metadata   map[string]string // メタデータ
	// contains filtered or unexported fields
}

PlanResponse はPlanService.はPlanService.Listで返されるプランを表す構造体です

func (*PlanResponse) Delete

func (p *PlanResponse) Delete(ctx context.Context) error

Delete はプランを削除します。

func (*PlanResponse) UnmarshalJSON

func (p *PlanResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

func (*PlanResponse) Update

func (p *PlanResponse) Update(ctx context.Context, name string) error

Update はプラン情報を更新します。

type PlanService

type PlanService struct {
	// contains filtered or unexported fields
}

PlanService は定期購入のときに使用する静的なプラン情報を扱います。

金額、支払い実行日(1-31)、トライアル日数などを指定して、 あなたのビジネスに必要なさまざまなプランを生成することができます。

生成したプランは、顧客と紐付けて定期購入処理を行うことができます。

func (PlanService) Create

func (p PlanService) Create(ctx context.Context, plan Plan) (*PlanResponse, error)

Create は金額や通貨などを指定して定期購入に利用するプランを生成します。

トライアル日数を指定することで、トライアル付きのプランを生成することができます。

また、支払いの実行日を指定すると、支払い日の固定されたプランを生成することができます。

func (PlanService) Delete

func (p PlanService) Delete(ctx context.Context, id string) error

Delete はプランを削除します。

func (PlanService) List

func (p PlanService) List() *PlanListCaller

List は生成したプランのリストを取得します。リストは、直近で生成された順番に取得されます。

func (PlanService) Retrieve

func (p PlanService) Retrieve(ctx context.Context, id string) (*PlanResponse, error)

Retrieve plan object. 特定のプラン情報を取得します。

func (PlanService) Update

func (p PlanService) Update(ctx context.Context, id, name string) (*PlanResponse, error)

Update はプラン情報を更新します。

type Service

type Service struct {
	Client *http.Client

	Charge         *ChargeService         // 支払いに関するAPI
	Customer       *CustomerService       // 顧客情報に関するAPI
	Plan           *PlanService           // プランに関するAPI
	Subscription   *SubscriptionService   // 定期課金に関するAPI
	Token          *TokenService          // トークンに関するAPI
	Transfer       *TransferService       // 入金に関するAPI
	Event          *EventService          // イベント情報に関するAPI
	Account        *AccountService        // アカウント情報に関するAPI
	Tenant         *TenantService         // テナント情報に関するAPI
	TenantTransfer *TenantTransferService // テナントの入金に関するAPI
	// contains filtered or unexported fields
}

Service 構造体はPAY.JPのすべてのAPIの起点となる構造体です。 New()を使ってインスタンスを生成します。

func New

func New(apiKey string, client *http.Client, config ...Config) *Service

New はPAY.JPのAPIを初期化する関数です。

apiKeyはPAY.JPのウェブサイトで作成したキーを指定します。

clientは特別な設定をしたhttp.Clientを使用する場合に渡します。nilを指定するとデフォルトのもhttp.Clientを指定します。

configは追加の設定が必要な場合に渡します。現状で設定できるのはAPIのエントリーポイントのURLのみです。省略できます。

func (Service) APIBase

func (s Service) APIBase() string

APIBase はPAY.JPのエントリーポイントの基底部分のURLを返します。

type Subscription

type Subscription struct {
	TrialEndAt      time.Time         // トライアルの終了時期
	SkipTrial       interface{}       // トライアルをしない(bool)
	PlanID          interface{}       // プランID(string)
	NextCyclePlanID interface{}       // 次サイクルから適用するプランID(string, 更新時のみ設定可能)
	Prorate         interface{}       // 日割り課金をするかどうか(bool)
	Metadata        map[string]string // メタデータ
}

Subscription はSubscribeやUpdateの引数を設定するのに使用する構造体です。

type SubscriptionListCaller

type SubscriptionListCaller struct {
	// contains filtered or unexported fields
}

SubscriptionListCaller はリスト取得に使用する構造体です。

func (*SubscriptionListCaller) Do

Do は指定されたクエリーを元に顧客のリストを配列で取得します。

func (*SubscriptionListCaller) Limit

Limit はリストの要素数の最大値を設定します(1-100)

func (*SubscriptionListCaller) Offset

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*SubscriptionListCaller) PlanID

PlanID はプランIDで結果を絞ります

func (*SubscriptionListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*SubscriptionListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type SubscriptionResponse

type SubscriptionResponse struct {
	ID                   string             // sub_で始まる一意なオブジェクトを示す文字列
	LiveMode             bool               // 本番環境かどうか
	CreatedAt            time.Time          // この定期課金作成時のタイムスタンプ
	StartAt              time.Time          // この定期課金開始時のタイムスタンプ
	CustomerID           string             // この定期課金を購読している顧客のID
	Plan                 Plan               // この定期課金のプラン情報
	NextCyclePlan        *Plan              // この定期課金の次のサイクルから適用されるプラン情報
	Status               SubscriptionStatus // この定期課金の現在の状態
	Prorate              bool               // 日割り課金が有効かどうか
	CurrentPeriodStartAt time.Time          // 現在の購読期間開始時のタイムスタンプ
	CurrentPeriodEndAt   time.Time          // 現在の購読期間終了時のタイムスタンプ
	TrialStartAt         time.Time          // トライアル期間開始時のタイムスタンプ
	TrialEndAt           time.Time          // 	トライアル期間終了時のタイムスタンプ
	PausedAt             time.Time          // 定期課金が停止状態になった時のタイムスタンプ
	CanceledAt           time.Time          // 定期課金がキャンセル状態になった時のタイムスタンプ
	ResumedAt            time.Time          // 停止またはキャンセル状態の定期課金が有効状態になった時のタイムスタンプ
	Metadata             map[string]string  // メタデータ
	// contains filtered or unexported fields
}

SubscriptionResponse はSubscriptionService.GetやSubscriptionService.Listで返される 定期購読情報持つ構造体です。

func (*SubscriptionResponse) Cancel

func (s *SubscriptionResponse) Cancel(ctx context.Context) error

Cancel は定期課金をキャンセルし、現在の周期の終了日をもって定期課金を終了させます。

func (*SubscriptionResponse) Delete

func (s *SubscriptionResponse) Delete(ctx context.Context) error

Delete は定期課金をすぐに削除します。次回以降の課金は行われずに、一度削除した定期課金は、 再び戻すことができません。

func (*SubscriptionResponse) Pause

func (s *SubscriptionResponse) Pause(ctx context.Context) error

Pause は引き落としの失敗やカードが不正である、また定期課金を停止したい場合はこのリクエストで定期購入を停止させます。

func (*SubscriptionResponse) Resume

func (s *SubscriptionResponse) Resume(ctx context.Context, subscription Subscription) error

Resume は停止もしくはキャンセル状態の定期課金を再開させます。

func (*SubscriptionResponse) UnmarshalJSON

func (s *SubscriptionResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

func (*SubscriptionResponse) Update

func (s *SubscriptionResponse) Update(ctx context.Context, subscription Subscription) error

Update はトライアル期間を新たに設定したり、プランの変更を行うことができます。

type SubscriptionService

type SubscriptionService struct {
	// contains filtered or unexported fields
}

SubscriptionService は月単位で定期的な支払い処理を行うサービスです。顧客IDとプランIDを指定して生成します。

stauts=SubscriptionTrial の場合は支払いは行われず、status=SubscriptionActive の場合のみ支払いが行われます。

支払い処理は、はじめに定期課金を生成した瞬間に行われ、そこを基準にして定期的な支払いが行われていきます。 定期課金は、顧客に複数紐付けるができ、生成した定期課金は停止・再開・キャンセル・削除することができます。

func (SubscriptionService) Cancel

func (s SubscriptionService) Cancel(ctx context.Context, subscriptionID string) (*SubscriptionResponse, error)

Cancel は定期課金をキャンセルし、現在の周期の終了日をもって定期課金を終了させます。

終了日以前であれば、定期課金の再開リクエスト(Resume)を行うことで、 キャンセルを取り消すことができます。終了日をむかえた定期課金は、 自動的に削除されますのでご注意ください。

func (SubscriptionService) Delete

func (s SubscriptionService) Delete(ctx context.Context, subscriptionID string) error

Delete は定期課金をすぐに削除します。次回以降の課金は行われずに、一度削除した定期課金は、 再び戻すことができません。

func (SubscriptionService) List

List は顧客の定期課金リストを取得します。リストは、直近で生成された順番に取得されます。

func (SubscriptionService) Pause

func (s SubscriptionService) Pause(ctx context.Context, subscriptionID string) (*SubscriptionResponse, error)

Pause は引き落としの失敗やカードが不正である、また定期課金を停止したい場合はこのリクエストで定期購入を停止させます。

定期課金を停止させると、再開されるまで引き落とし処理は一切行われません。

func (SubscriptionService) Resume

func (s SubscriptionService) Resume(ctx context.Context, subscriptionID string, subscription Subscription) (*SubscriptionResponse, error)

Resume は停止もしくはキャンセル状態の定期課金を再開させます。 トライアル日数が残っていて再開日がトライアル終了日時より前の場合、 トライアル状態で定期課金が再開されます。

TrialEndを指定することで、トライアル終了日を任意の日時に再指定する事ができます。

支払いの失敗が原因で停止状態にある定期課金の再開時は未払い分の支払いを行います。

未払い分の支払いに失敗すると、定期課金は再開されません。 この場合は、有効なカードを顧客のデフォルトカードにセットしてから、 再度定期課金の再開を行ってください。

またProrate を指定することで、日割り課金を有効化することができます。 日割り課金が有効な場合は、 再開日より課金日までの日数分で課金額を日割りします。

func (SubscriptionService) Retrieve

func (s SubscriptionService) Retrieve(ctx context.Context, customerID, subscriptionID string) (*SubscriptionResponse, error)

Retrieve subscription object. 特定の定期課金情報を取得します。

func (SubscriptionService) Subscribe

func (s SubscriptionService) Subscribe(ctx context.Context, customerID string, subscription Subscription) (*SubscriptionResponse, error)

Subscribe は顧客IDとプランIDを指定して、定期課金を開始することができます。 TrialEndを指定することで、プラン情報を上書きするトライアル設定も可能です。 最初の支払いは定期課金作成時に実行されます。 支払い実行日(BillingDay)が指定されているプランの場合は日割り設定(Prorate)を有効化しない限り、 作成時よりもあとの支払い実行日に最初の課金が行われます。またトライアル設定がある場合は、 トライアル終了時に支払い処理が行われ、そこを基準にして定期課金が開始されます。

func (SubscriptionService) Update

func (s SubscriptionService) Update(ctx context.Context, subscriptionID string, subscription Subscription) (*SubscriptionResponse, error)

Update はトライアル期間を新たに設定したり、プランの変更を行うことができます。

トライアル期間を更新する場合、トライアル期間終了時に支払い処理が行われ、 そこを基準としてプランに沿った周期で定期課金が再開されます。 このトライアル期間を利用すれば、定期課金の開始日を任意の日にずらすこともできます。 また SkipTrial=true とする事により、トライアル期間中の定期課金を即時開始できます。

プランを変更する場合は、 PlanID に新しいプランのIDを指定してください。 同時に Prorate=true とする事により、 日割り課金を有効化できます。

type SubscriptionStatus

type SubscriptionStatus int

SubscriptionStatus は定期購読のステータスを表すEnumです。

const (

	// SubscriptionActive はアクティブ状態を表す定数
	SubscriptionActive SubscriptionStatus
	// SubscriptionTrial はトライアル状態を表す定数
	SubscriptionTrial
	// SubscriptionCanceled はキャンセル状態を表す定数
	SubscriptionCanceled
	// SubscriptionPaused は停止状態を表す定数
	SubscriptionPaused
)

type Tenant

type Tenant struct {
	ID                    string            // ten_で始まる自動生成された一意な文字列、または作成時に指定した任意の文字列
	Name                  string            // テナント名
	LiveMode              bool              // 本番環境かどうか
	Object                string            // “tenant"の固定文字列
	PlatformFeeRate       string            // テナントのプラットフォーム利用料率(%)。 小数点以下2桁までの数値。
	MinimumTransferAmount int               // 最低入金額。デフォルトは1万円で下限は1000円。締め日にこの金額以上の売上が貯まっていると入金手数料250円を引いた金額が振り込まれる。
	BankCode              string            // 4桁の銀行コード
	BankBranchCode        string            // 3桁の支店コード
	BankAccountType       string            // 預金種別
	BankAccountStatus     string            // 口座状態。pending:未確認, success:入金確認済み, failed:入金不可能
	BankAccountHolderName string            // 口座名義
	BankAccountNumber     string            // 口座番号
	Metadata              map[string]string // メタデータ
}

type TenantListCaller

type TenantListCaller struct {
	// contains filtered or unexported fields
}

TenantListCaller はリスト取得に使用する構造体です。

Fluentインタフェースを提供しており、最後にDoを呼ぶことでリストが取得できます:

pay := payjp.New("api-key", nil)
charges, err := pay.Tenant.List().Limit(50).Offset(150).Do()

func (*TenantListCaller) Do

Do は指定されたクエリーを元にテナントのリストを配列で取得します。

func (*TenantListCaller) Limit

func (c *TenantListCaller) Limit(limit int) *TenantListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*TenantListCaller) Offset

func (c *TenantListCaller) Offset(offset int) *TenantListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*TenantListCaller) Since

func (c *TenantListCaller) Since(since time.Time) *TenantListCaller

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*TenantListCaller) Until

func (c *TenantListCaller) Until(until time.Time) *TenantListCaller

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type TenantResponse

type TenantResponse struct {
	ID                    string            // ten_で始まる自動生成された一意な文字列、または作成時に指定した任意の文字列
	Name                  string            // テナント名
	LiveMode              bool              // 本番環境かどうか
	Object                string            // “tenant"の固定文字列
	PlatformFeeRate       string            // テナントのプラットフォーム利用料率(%)。 小数点以下2桁までの数値の文字列型。
	MinimumTransferAmount int               // 最低入金額。デフォルトは1万円で下限は1000円。締め日にこの金額以上の売上が貯まっていると入金手数料250円を引いた金額が振り込まれる。
	BankCode              string            // 4桁の銀行コード
	BankBranchCode        string            // 3桁の支店コード
	BankAccountType       string            // 預金種別
	BankAccountStatus     string            // 口座状態。pending:未確認, success:入金確認済み, failed:入金不可能
	BankAccountHolderName string            // 口座名義
	BankAccountNumber     string            // 口座番号
	Metadata              map[string]string // メタデータ
	// contains filtered or unexported fields
}

func (*TenantResponse) UnmarshalJSON

func (t *TenantResponse) UnmarshalJSON(b []byte) error

type TenantService

type TenantService struct {
	// contains filtered or unexported fields
}

func (*TenantService) Create

func (t *TenantService) Create(ctx context.Context, tenant Tenant) (*TenantResponse, error)

func (TenantService) Delete

func (p TenantService) Delete(ctx context.Context, id string) error

Delete はプランを削除します。

func (TenantService) List

func (c TenantService) List() *TenantListCaller

func (TenantService) Retrieve

func (t TenantService) Retrieve(ctx context.Context, id string) (*TenantResponse, error)

Retrieve tenant object. 特定のテナント情報を取得します。

func (TenantService) Update

func (t TenantService) Update(ctx context.Context, tenant Tenant) (*TenantResponse, error)

type TenantTransferChargeListCaller

type TenantTransferChargeListCaller struct {
	// contains filtered or unexported fields
}

func (*TenantTransferChargeListCaller) CustomerID

CustomerID を指定すると、指定した顧客の支払いのみを取得します

func (*TenantTransferChargeListCaller) Do

Do は指定されたクエリーを元に支払いのリストを配列で取得します。

func (*TenantTransferChargeListCaller) Limit

Limit はリストの要素数の最大値を設定します(1-100)

func (*TenantTransferChargeListCaller) Offset

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*TenantTransferChargeListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*TenantTransferChargeListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type TenantTransferListCaller

type TenantTransferListCaller struct {
	// contains filtered or unexported fields
}

TenantTransferListCaller は支払いのリスト取得に使用する構造体です。

func (*TenantTransferListCaller) Do

Do は指定されたクエリーを元に入金のリストを配列で取得します。

func (*TenantTransferListCaller) Limit

Limit はリストの要素数の最大値を設定します(1-100)

func (*TenantTransferListCaller) Offset

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*TenantTransferListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*TenantTransferListCaller) Status

Status はここで指定されたステータスのデータを取得します

func (*TenantTransferListCaller) TenantID

TenantID を指定すると、指定したテナントの決済情報のみを取得します

func (*TenantTransferListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type TenantTransferResponse

type TenantTransferResponse struct {
	ID             string            // ten_tr_で始まる一意なオブジェクトを示す文字列
	Amount         int               // 入金予定額
	CarriedBalance interface{}       // 繰越金
	Charges        []*ChargeResponse // この入金に含まれる支払いのリスト
	CreatedAt      time.Time         // この入金作成時のタイムスタンプ
	Currency       string            // 3文字のISOコード(現状 “jpy” のみサポート)
	LiveMode       bool              // 本番環境かどうか
	ScheduledDate  string            // 入金予定日
	Status         TransferStatus    // この入金の処理状態
	Summary        struct {
		ChargeCount      int // 支払い総数
		ChargeFee        int // 支払い手数料
		TotalPlatformFee int // プラットフォーム利用料総額
		ChargeGross      int // 総売上
		Net              int // 差引額
		RefundAmount     int // 返金総額
		RefundCount      int // 返金総額
	} // この入金に関する集計情報
	TenantID    string    // テナントID
	TermEndAt   time.Time //
	TermStartAt time.Time
	// contains filtered or unexported fields
}

func (*TenantTransferResponse) UnmarshalJSON

func (t *TenantTransferResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

type TenantTransferService

type TenantTransferService struct {
	// contains filtered or unexported fields
}

func (TenantTransferService) ChargeList

func (t TenantTransferService) ChargeList(tenantTransferID string) *TenantTransferChargeListCaller

func (TenantTransferService) List

List は入金リストを取得します。リストは、直近で生成された順番に取得されます。

func (TenantTransferService) Retrieve

func (t TenantTransferService) Retrieve(ctx context.Context, tenantTransferID string) (*TenantTransferResponse, error)

Retrieve transfer object. 入金情報を取得します。

type TokenResponse

type TokenResponse struct {
	Card      CardResponse // クレジットカードの情報
	CreatedAt time.Time    // このトークン作成時間
	ID        string       // tok_で始まる一意なオブジェクトを示す文字列
	LiveMode  bool         // 本番環境かどうか
	Used      bool         // トークンが使用済みかどうか
}

TokenResponse はToken.Create(), Token.Retrieve()が返す構造体です。

func (*TokenResponse) UnmarshalJSON

func (t *TokenResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

type TokenService

type TokenService struct {
	// contains filtered or unexported fields
}

TokenService はカード情報を代替するトークンオブジェクトを扱います。

トークンは、カード番号やCVCなどのセキュアなデータを隠しつつも、カードと同じように扱うことができます。

顧客にカードを登録するときや、支払い処理を行うときにカード代わりとして使用します。

一度使用したトークンは再び使用することはできませんが、 顧客にカードを登録すれば、顧客IDを支払い手段として用いることで、 何度でも同じカードで支払い処理ができるようになります。

func (TokenService) Create

func (t TokenService) Create(ctx context.Context, card Card) (*TokenResponse, error)

Create メソッドカード情報を指定して、トークンを生成します。

トークンはサーバーサイドからのリクエストでも生成可能ですが、通常は チェックアウトや payjp.js を利用して、ブラウザ経由でパブリックキーとカード情報を指定して生成します。 トークンは二度以上使用することができません。

チェックアウトやpayjp.jsを使ったトークン化の実装方法については チュートリアル - カード情報のトークン化(https://pay.jp/docs/cardtoken)をご覧ください。

Card構造体で引数を設定しますが、Number/ExpMonth/ExpYearが必須パラメータです。

func (TokenService) Retrieve

func (t TokenService) Retrieve(ctx context.Context, id string) (*TokenResponse, error)

Retrieve token object. 特定のトークン情報を取得します。

type TransferChargeListCaller

type TransferChargeListCaller struct {
	// contains filtered or unexported fields
}

TransferChargeListCaller は入金内訳のリスト取得に使用する構造体です。

func (*TransferChargeListCaller) CustomerID

CustomerID はここに指定した顧客IDを持つデータを取得します

func (*TransferChargeListCaller) Do

Do は指定されたクエリーを元に入金内訳のリストを配列で取得します。

func (*TransferChargeListCaller) Limit

Limit はリストの要素数の最大値を設定します(1-100)

func (*TransferChargeListCaller) Offset

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*TransferChargeListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*TransferChargeListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type TransferListCaller

type TransferListCaller struct {
	// contains filtered or unexported fields
}

TransferListCaller は支払いのリスト取得に使用する構造体です。

func (*TransferListCaller) Do

Do は指定されたクエリーを元に入金のリストを配列で取得します。

func (*TransferListCaller) Limit

func (c *TransferListCaller) Limit(limit int) *TransferListCaller

Limit はリストの要素数の最大値を設定します(1-100)

func (*TransferListCaller) Offset

func (c *TransferListCaller) Offset(offset int) *TransferListCaller

Offset は取得するリストの先頭要素のインデックスのオフセットを設定します

func (*TransferListCaller) Since

Since はここに指定したタイムスタンプ以降に作成されたデータを取得します

func (*TransferListCaller) Status

Status はここで指定されたステータスのデータを取得します

func (*TransferListCaller) Until

Until はここに指定したタイムスタンプ以前に作成されたデータを取得します

type TransferResponse

type TransferResponse struct {
	ID             string            // tr_で始まる一意なオブジェクトを示す文字列
	LiveMode       bool              // 本番環境かどうか
	CreatedAt      time.Time         // この入金作成時のタイムスタンプ
	Amount         int               // 入金予定額
	CarriedBalance int               // 繰越金
	Currency       string            // 3文字のISOコード(現状 “jpy” のみサポート)
	Status         TransferStatus    // この入金の処理状態
	Charges        []*ChargeResponse // この入金に含まれる支払いのリスト
	ScheduledDate  string            // 入金予定日
	Summary        struct {
		ChargeCount  int // 支払い総数
		ChargeFee    int // 支払い手数料
		ChargeGross  int // 総売上
		Net          int // 差引額
		RefundAmount int // 返金総額
		RefundCount  int // 返金総額
	} // この入金に関する集計情報
	Description    string    // 概要
	TermStartAt    time.Time // 集計期間開始時のタイムスタンプ
	TermEndAt      time.Time // 集計期間終了時のタイムスタンプ
	TransferAmount int       // 	入金額
	TransferDate   string    // 入金日
	// contains filtered or unexported fields
}

TransferResponse はTransferService.Get、TransferService.Listによって返される、 入金状態を示す構造体です。

func (*TransferResponse) UnmarshalJSON

func (t *TransferResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON はJSONパース用の内部APIです。

type TransferService

type TransferService struct {
	// contains filtered or unexported fields
}

TransferService は入金に関するサービスです。

入金は毎月15日と月末に締め、翌月15日と月末に入金されます。入金は、締め日までのデータがそれぞれ生成されます。

func (TransferService) ChargeList

func (t TransferService) ChargeList(transferID string) *TransferChargeListCaller

ChargeList は支払いは入金内訳リストを取得します。リストは、直近で生成された順番に取得されます。

func (TransferService) List

List は入金リストを取得します。リストは、直近で生成された順番に取得されます。

func (TransferService) Retrieve

func (t TransferService) Retrieve(ctx context.Context, transferID string) (*TransferResponse, error)

Retrieve transfer object. 入金情報を取得します。

type TransferStatus

type TransferStatus int

TransferStatus は入金状態を示すステータスです

const (

	// TransferPending は支払い前のステータスを表す定数
	TransferPending TransferStatus
	// TransferPaid は支払い済みのステータスを表す定数
	TransferPaid
	// TransferFailed は支払い失敗のステータスを表す定数
	TransferFailed
	// TransferCanceled は支払いキャンセルのステータスを表す定数
	TransferCanceled
)

Jump to

Keyboard shortcuts

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