omise

package module
Version: v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 13 Imported by: 3

README

⚠️ This is not OMG, the blockchain. Visit https://omg.network/ for that. ⚠️


OMISE GO CLIENT

GoDoc omise-go v1

Omise is a payment service provider currently operating in Thailand. Omise provides a set of clean APIs that helps merchants of any size accept credit cards online.

This library offers GO integration to the Omise API.

Install with:

go get github.com/omise/omise-go

COMPLIANCE WARNING

Card data should never transit through your server. This library provides means to create tokens on the server side but should only be used for testing or only if you currently have a valid PCI-DSS Attestation of Compliance (AoC) delivered by a certified QSA Auditor.

Instead we recommend that you follow our guide on how to safely collect credit information.

USAGE

See godoc.org in tandem with the Omise API Documentation for usage instruction.

Example:

package main

import (
	"log"

	"github.com/omise/omise-go"
	"github.com/omise/omise-go/operations"
)

const (
	// Read these from environment variables or configuration files!
	OmisePublicKey = "pkey_test_521w1g1t7w4x4rd22z0"
	OmiseSecretKey = "skey_test_521w1g1t6yh7sx4pu8n"
)

func main() {
	client, e := omise.NewClient(OmisePublicKey, OmiseSecretKey)
	if e != nil {
		log.Fatal(e)
	}

  /** Retrieve a token from a request
   * A token should be created from a client side by using our client-side libraries
   * https://www.omise.co/libraries#client-side-libraries
   * More information:
   * - https://www.omise.co/collecting-card-information
   * - https://www.omise.co/security-best-practices
   **/
	token := "tokn_xxxxxxxxxxxxx"

	// Creates a charge from the token
	charge, createCharge := &omise.Charge{}, &operations.CreateCharge{
		Amount:   100000, // ฿ 1,000.00
		Currency: "thb",
		Card:     token.ID,
	}
	if e := client.Do(charge, createCharge); e != nil {
		log.Fatal(e)
	}

	log.Printf("charge: %s  amount: %s %d\n", charge.ID, charge.Currency, charge.Amount)
}

API VERSION

You can choose which API version to use with Omise. Each new API version has new features and might not be compatible with previous versions. You can change the default version by visiting your Omise Dashboard.

The version configured here will have higher priority than the version set in your Omise account. This is useful if you have multiple environments with different API versions for testing. (e.g. Development on the latest version but production is on an older version).

client.APIVersion = "2015-11-06"

It is highly recommended to set this version to the current version you're using. You can learn more about this feature in our versioning guide.

LICENSE

See LICENSE file.

Documentation

Overview

Package omise provides GO binding for Omise REST API. Full REST API documentation is available at https://www.omise.co/docs.

Usage

Create a client with omise.NewClient, supply your public and secret key. Then use the client.Do method with operation objects from the operations subpackage to perform API calls. The first parameter to client.Do lets you supply a struct to unmarshal the result into.

Example:

client, e := omise.NewClient(OMISE_PUBKEY, OMISE_KEY)
if e != nil {
	panic(e)
}

charge, create := &omise.Charge{}, &operations.CreateCharge{
	Amount:   100000, // ฿1,000.00
	Currency: "thb",
	Card:     "tok_1234",
}

if e := client.Do(charge, create); e != nil {
	panic(e)
}

fmt.Printf("%#v\n", charge)

Handling nils

For REQUESTS: Where optional parameters are concerned, empty values are considered as not sending the value except where doing so may have undesirable implications. This is to avoid the need for pointer indirections when creating the struct.

For RESPONSES: Optional fields always use nillable types or types with well-defined "empty" value. For example, an optional `string` field will have `*string` type.

Test keys

You will need to supply a valid Omise API keys in order to run tests. Refer to the official documentation on Authentication at https://www.omise.co/api-authentication for more information.

To specify the keys, set the environment variables before running the tests as follows:

export OMISE_PUBKEY=pkey_test_yourpublickey
export OMISE_KEY=skey_test_yoursecretkey

Live tests

Tests are run against fixtures by default. If you want to run network test against Omise test servers you can do so by supplying valid test keys *and* setting NETWORK environment variable to 1.

cd $GOPATH/src/github.com/omise/omise-go
NETWORK=1 go test -v ./operations

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("invalid public or secret key")

ErrInvalidKey represents missing or bad API key errors.

Functions

func WebhookHTTPHandler

func WebhookHTTPHandler(handler EventHandler) http.Handler

WebhookHTTPHandler creates an http.Handler that you can use to receive Omise's webhook API calls for events. The returned handler will automatically consume the request body and unmarshals an Event object from JSON for you.

See https://www.omise.co/api-webhooks for more information.

Types

type Account

type Account struct {
	Base
	Email string `json:"email"`
}

Account represents Omise's account object. See https://www.omise.co/account-api for more information.

type AccountList

type AccountList struct {
	List
	Data []*Account `json:"data"`
}

AccountList represents the list structure returned by Omise's REST API that contains Account struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*AccountList) Find

func (list *AccountList) Find(id string) *Account

Find finds and returns Account with the given id. Returns nil if not found.

type Balance

type Balance struct {
	Base
	Available int64  `json:"available"`
	Total     int64  `json:"total"`
	Currency  string `json:"currency"`
}

Balance represents Omise's balance object. See https://www.omise.co/balance-api for more information.

type BalanceList

type BalanceList struct {
	List
	Data []*Balance `json:"data"`
}

BalanceList represents the list structure returned by Omise's REST API that contains Balance struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*BalanceList) Find

func (list *BalanceList) Find(id string) *Balance

Find finds and returns Balance with the given id. Returns nil if not found.

type Bank added in v1.0.6

type Bank struct {
	Code   string `json:"code"`
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

Bank represents a bank object in the payment method of the capability object.

type BankAccount

type BankAccount struct {
	Base
	Brand      string `json:"brand"`
	Number     string `json:"number"`
	LastDigits string `json:"last_digits"`
	Name       string `json:"name"`

	// for Omise Japan
	BankCode    string          `json:"bank_code"`
	BranchCode  string          `json:"branch_code"`
	AccountType BankAccountType `json:"account_type"`
}

BankAccount represents Omise's bank account object. See https://www.omise.co/bank-account-api for more information.

type BankAccountList

type BankAccountList struct {
	List
	Data []*BankAccount `json:"data"`
}

BankAccountList represents the list structure returned by Omise's REST API that contains BankAccount struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*BankAccountList) Find

func (list *BankAccountList) Find(id string) *BankAccount

Find finds and returns BankAccount with the given id. Returns nil if not found.

type BankAccountType

type BankAccountType string

BankAccountType BankAccount an enumeration of possible types of BackAccount(s) which can be

const (
	Normal  BankAccountType = "normal"
	Current BankAccountType = "current"
)

BankAccountType can be one of the following list of constants:

type Base

type Base struct {
	Object   string    `json:"object"`
	ID       string    `json:"id"`
	Live     bool      `json:"livemode"`
	Location *string   `json:"location"`
	Created  time.Time `json:"created"`
}

Base structure contains fields that are common to objects returned by the Omise's REST API.

type Capability added in v1.0.6

type Capability struct {
	Object                   string          `json:"object"`
	Location                 string          `json:"location"`
	Banks                    []string        `json:"banks"`
	Country                  string          `json:"country"`
	PaymentMethods           []PaymentMethod `json:"payment_methods"`
	ZeroInterestInstallments bool            `json:"zero_interest_installments"`
}

Capability represents Omise's capability object. See https://www.omise.co/capability-api for more information.

type Card

type Card struct {
	Base
	Country    string `json:"country"`
	City       string `json:"city"`
	Bank       string `json:"bank"`
	PostalCode string `json:"postal_code"`
	Financing  string `json:"financing"`
	LastDigits string `json:"last_digits"`
	Brand      string `json:"brand"`

	ExpirationMonth time.Month `json:"expiration_month"`
	ExpirationYear  int        `json:"expiration_year"`

	Fingerprint       string `json:"fingerprint"`
	Name              string `json:"name"`
	SecurityCodeCheck bool   `json:"security_code_check"`
}

Card represents Omise's card object. See https://www.omise.co/cards-api for more information.

type CardList

type CardList struct {
	List
	Data []*Card `json:"data"`
}

CardList represents the list structure returned by Omise's REST API that contains Card struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*CardList) Find

func (list *CardList) Find(id string) *Card

Find finds and returns Card with the given id. Returns nil if not found.

type Charge

type Charge struct {
	Base
	Status      ChargeStatus `json:"status"`
	Amount      int64        `json:"amount"`
	Currency    string       `json:"currency"`
	Description *string      `json:"description"`

	Capture    bool `json:"capture"`
	Authorized bool `json:"authorized"`
	Reversed   bool `json:"reversed"`
	Paid       bool `json:"paid"`

	Transaction string `json:"transaction"`
	Card        *Card  `json:"card"`

	Refunded       int64       `json:"refunded"`
	Refunds        *RefundList `json:"refunds"`
	FailureCode    *string     `json:"failure_code"`
	FailureMessage *string     `json:"failure_message"`

	CustomerID string   `json:"customer"`
	IP         *string  `json:"ip"`
	Dispute    *Dispute `json:"dispute"`

	ReturnURI    string `json:"return_uri"`
	AuthorizeURI string `json:"authorize_uri"`

	SourceOfFund SourceOfFunds `json:"source_of_fund"`
	Offsite      OffsiteTypes  `json:"offsite"`

	Source   *Source                `json:"source"`
	Metadata map[string]interface{} `json:"metadata"`
}

Charge represents Omise's charge object. See https://www.omise.co/charges-api for more information.

type ChargeList

type ChargeList struct {
	List
	Data []*Charge `json:"data"`
}

ChargeList represents the list structure returned by Omise's REST API that contains Charge struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*ChargeList) Find

func (list *ChargeList) Find(id string) *Charge

Find finds and returns Charge with the given id. Returns nil if not found.

type ChargeSearchResult

type ChargeSearchResult struct {
	SearchResult
	Data []*Charge `json:"data"`
}

ChargeSearchResult represents search result structure returned by Omise's Search API that contains Charge struct as result elements.

type ChargeStatus

type ChargeStatus string

ChargeStatus represents an enumeration of possible status of a Charge object.

const (
	ChargeFailed     ChargeStatus = "failed"
	ChargePending    ChargeStatus = "pending"
	ChargeSuccessful ChargeStatus = "successful"
	ChargeReversed   ChargeStatus = "reversed"
)

ChargeStatus can be one of the following list of constants:

type Client

type Client struct {
	*http.Client

	// Overrides
	Endpoints map[internal.Endpoint]string

	// configuration
	APIVersion string
	GoVersion  string
	// contains filtered or unexported fields
}

Client helps you configure and perform HTTP operations against Omise's REST API. It should be used with operation structures from the operations subpackage.

func NewClient

func NewClient(pkey, skey string) (*Client, error)

NewClient creates and returns a Client with the given public key and secret key. Signs in to http://omise.co and visit https://dashboard.omise.co/test/dashboard to obtain your test (or live) keys.

func (*Client) Do

func (c *Client) Do(result interface{}, operation internal.Operation) error

Do performs the supplied operation against Omise's REST API and unmarshal the response into the given result parameter. Results are usually basic objects or a list that corresponds to the operations being done.

If the operation is successful, result should contains the response data. Otherwise a non-nil error should be returned. Error maybe of the omise-go.Error struct type, in which case you can further inspect the Code and Message field for more information.

Example
// gets your API keys
pkey, skey := "pkey_test_4yq6tct0llin5nyyi5l", "skey_test_4yq6tct0lblmed2yp5t"

// creates a client
client, err := NewClient(pkey, skey)
if err != nil {
	log.Fatal(err)
}

// creates a charge
charge, create := &Charge{}, &operations.CreateCharge{
	Amount:   100000, // ¥10,000
	Currency: "jpy",
	Card:     "tok_1234",
}

// checks for error
if err := client.Do(charge, create); err != nil {
	if omiseErr, ok := err.(*Error); ok {
		log.Fatal(omiseErr.Code + " " + omiseErr.Message)
	} else {
		log.Fatal("transport error: " + err.Error())
	}
}

// verify
fmt.Printf("authorized charge: %#v\n", charge)
Output:

func (*Client) Request

func (c *Client) Request(operation internal.Operation) (req *http.Request, err error)

Request creates a new *http.Request that should performs the supplied Operation. Most people should use the Do method instead.

type Customer

type Customer struct {
	Base
	DefaultCard string    `json:"default_card"`
	Email       string    `json:"email"`
	Description string    `json:"description"`
	Cards       *CardList `json:"cards"`

	Metadata map[string]interface{} `json:"metadata"`
}

Customer represents Omise's customer object. See https://www.omise.co/customers-api for more information.

type CustomerList

type CustomerList struct {
	List
	Data []*Customer `json:"data"`
}

CustomerList represents the list structure returned by Omise's REST API that contains Customer struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*CustomerList) Find

func (list *CustomerList) Find(id string) *Customer

Find finds and returns Customer with the given id. Returns nil if not found.

type CustomerSearchResult

type CustomerSearchResult struct {
	SearchResult
	Data []*Customer `json:"data"`
}

CustomerSearchResult represents search result structure returned by Omise's Search API that contains Customer struct as result elements.

type Date

type Date time.Time

Date type for marshal/unmarshal JSON without time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON Date type

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON Date type

type Deletion

type Deletion struct {
	Base
	Deleted bool `json:"deleted"`
}

Deletion struct is used to receive deletion responses from delete operations.

type DeletionList

type DeletionList struct {
	List
	Data []*Deletion `json:"data"`
}

DeletionList represents the list structure returned by Omise's REST API that contains Deletion struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*DeletionList) Find

func (list *DeletionList) Find(id string) *Deletion

Find finds and returns Deletion with the given id. Returns nil if not found.

type Dispute

type Dispute struct {
	Base
	Amount   int64                  `json:"amount"`
	Currency string                 `json:"currency"`
	Status   DisputeStatus          `json:"status"`
	Message  string                 `json:"message"`
	Charge   string                 `json:"charge"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

Dispute represents Omise's dispute object. See https://www.omise.co/disputes-api for more information.

type DisputeList

type DisputeList struct {
	List
	Data []*Dispute `json:"data"`
}

DisputeList represents the list structure returned by Omise's REST API that contains Dispute struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*DisputeList) Find

func (list *DisputeList) Find(id string) *Dispute

Find finds and returns Dispute with the given id. Returns nil if not found.

type DisputeSearchResult

type DisputeSearchResult struct {
	SearchResult
	Data []*Dispute `json:"data"`
}

DisputeSearchResult represents search result structure returned by Omise's Search API that contains Dispute struct as result elements.

type DisputeStatus

type DisputeStatus string

DisputeStatus represents an enumeration of possible status of a Dispute object.

const (
	Open    DisputeStatus = "open"
	Pending DisputeStatus = "pending"
	Won     DisputeStatus = "won"
	Lost    DisputeStatus = "lost"
	Closed  DisputeStatus = "closed" // meta-status only for querying, does not actually appear.
)

DisputeStatus can be one of the following list of constants:

type Document

type Document struct {
	Base
	Filename string `json:"filename"`
}

Document represents Omise's document object. See https://www.omise.co/documents-api for more information.

type DocumentList

type DocumentList struct {
	List
	Data []*Document `json:"data"`
}

DocumentList represents the list structure returned by Omise's REST API that contains Document struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*DocumentList) Find

func (list *DocumentList) Find(id string) *Document

Find finds and returns Document with the given id. Returns nil if not found.

type ErrInternal

type ErrInternal string

ErrInternal represents internal library error. If you encounter this, it is mostly likely due to a bug in the omise-go library itself. Please report it by opening a new GitHub issue or contacting support.

func (ErrInternal) Error

func (err ErrInternal) Error() string

type ErrTransport

type ErrTransport struct {
	Err    error
	Buffer []byte
}

ErrTransport wraps error returned by omise-go internal HTTP transport implementation.

func (ErrTransport) Error

func (err ErrTransport) Error() string

type Error

type Error struct {
	Location   string `json:"location"`
	StatusCode int    `json:"status"`
	Code       string `json:"code"`
	Message    string `json:"message"`
}

Error struct represents errors that may be returned from Omise's REST API. You can use the Code or the HTTP StatusCode field to test for the exact error condition in your code.

func (*Error) Error

func (err *Error) Error() string

func (*Error) String

func (err *Error) String() string

type Event

type Event struct {
	Base
	Key  string      `json:"key"`
	Data interface{} `json:"data"`
}

Event represents Omise's event object.

func (*Event) UnmarshalJSON

func (ev *Event) UnmarshalJSON(buffer []byte) error

UnmarshalJSON unmarshals the buffer into an internal shim structure first, in order to determine the right structure to use for the .Data field. Then will re-unmarshal the structure as normal.

type EventHandler

type EventHandler interface {
	HandleEvent(http.ResponseWriter, *http.Request, *Event)
}

EventHandler is an interface for handling events from the webhook http.Handler.

type EventHandlerFunc

type EventHandlerFunc func(http.ResponseWriter, *http.Request, *Event)

EventHandlerFunc lets you use a plain function as an EventHandler type.

func (EventHandlerFunc) HandleEvent

func (f EventHandlerFunc) HandleEvent(resp http.ResponseWriter, req *http.Request, event *Event)

HandleEvent implements the EventHandler interface by calling the underlying funciton.

type EventList

type EventList struct {
	List
	Data []*Event `json:"data"`
}

EventList represents the list structure returned by Omise's REST API that contains Event struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*EventList) Find

func (list *EventList) Find(id string) *Event

Find finds and returns Event with the given id. Returns nil if not found.

type Link struct {
	Base
	Amount     int64  `json:"amount"`
	Currency   string `json:"currency"`
	Used       bool   `json:"used"`
	Multiple   bool   `json:"multiple"`
	PaymentURI string `json:"payment_uri"`

	Title       string     `json:"title"`
	Description string     `json:"description"`
	Charges     ChargeList `json:"charges"`
}

Link represents Omise's link object. See https://www.omise.co/links-api for more information.

type LinkList struct {
	List
	Data []*Link `json:"data"`
}

LinkList represents the list structure returned by Omise's REST API that contains Link struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*LinkList) Find

func (list *LinkList) Find(id string) *Link

Find finds and returns Link with the given id. Returns nil if not found.

type LinkSearchResult

type LinkSearchResult struct {
	SearchResult
	Data []*Link `json:"data"`
}

LinkSearchResult represents search result structure returned by Omise's Search API that contains Link struct as result elements.

type List

type List struct {
	Base
	From string `json:"from"`
	To   string `json:"to"`

	Offset int `json:"offset"`
	Limit  int `json:"limit"`
	Total  int `json:"total"`

	Order Ordering `json:"order"`
}

List structure contains fields that are common to list objects returned by the Omise's REST API. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

type Occurrence

type Occurrence struct {
	Base
	Schedule     string                    `json:"schedule"`
	ScheduleDate Date                      `json:"schedule_date"`
	RetryDate    Date                      `json:"retry_date"`
	ProcessedAt  time.Time                 `json:"processed_at"`
	Status       schedule.OccurrenceStatus `json:"status"`
	Message      string                    `json:"message"`
	Result       string                    `json:"result"`
}

Occurrence represents occurrence charge from Schedule

type OccurrenceList

type OccurrenceList struct {
	List
	Data []*Occurrence `json:"data"`
}

OccurrenceList represents the list structure returned by Omise's REST API that contains Occurrence struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*OccurrenceList) Find

func (list *OccurrenceList) Find(id string) *Occurrence

Find finds and returns Occurrence with the given id. Returns nil if not found.

type OccurrenceStatus

type OccurrenceStatus string

OccurrenceStatus represents an enumeration of possible status of a Occurrence object.

const (
	OccurrenceSkip       OccurrenceStatus = "skipped"
	OccurrenceFailed     OccurrenceStatus = "failed"
	OccurrenceSuccessful OccurrenceStatus = "successful"
)

OccurrenceStatus can be one of the following list of constants:

type OffsiteTypes

type OffsiteTypes string

OffsiteTypes represents an enumeration of possible types of offsite charges.

const (
	InternetBankingSCB OffsiteTypes = "internet_banking_scb"
	InternetBankingBBL OffsiteTypes = "internet_banking_bbl"
	InternetBankingKTB OffsiteTypes = "internet_banking_ktb"
	InternetBankingBAY OffsiteTypes = "internet_banking_bay"
	Alipay             OffsiteTypes = "alipay"
)

OffsiteTypes can be one of the following list of constants:

type Ordering

type Ordering string

Ordering represents an enumeration of possible values for list ordering while performing operations against the Omise API that result in List objects being returned.

const (
	UnspecifiedOrder     Ordering = ""
	Chronological        Ordering = "chronological"
	ReverseChronological Ordering = "reverse_chronological"
)

Ordering can be one of the following list of constants:

type PaymentMethod added in v1.0.6

type PaymentMethod struct {
	Object           string   `json:"object"`
	Name             string   `json:"name"`
	Currencies       []string `json:"currencies"`
	CardBrands       []string `json:"card_brands"`
	InstallmentTerms []int    `json:"installment_terms"`
	Banks            []Bank   `json:"banks"`
}

PaymentMethod represents a payment method in the Omise's capability object.

type Receipt

type Receipt struct {
	Base
	Number                string    `json:"number"`
	Date                  time.Time `json:"date"`
	CustomerName          string    `json:"customer_name"`
	CustomerAddress       string    `json:"customer_address"`
	CustomerTaxID         string    `json:"customer_tax_id"`
	CustomerEmail         string    `json:"customer_email"`
	CustomerStatementName string    `json:"customer_statement_name"`

	CompanyName    string `json:"company_name"`
	CompanyAddress string `json:"company_address"`
	CompanyTaxID   string `json:"company_tax_id"`

	ChargeFee   int64  `json:"charge_fee"`
	VoidedFee   int64  `json:"voided_fee"`
	TransferFee int64  `json:"transfer_fee"`
	SubTotal    int64  `json:"subtotal"`
	VAT         int64  `json:"vat"`
	WHT         int64  `json:"wht"`
	Total       int64  `json:"total"`
	CreditNote  bool   `json:"credit_note"`
	Currency    string `json:"currency"`
}

Receipt represents Omise's receipt object. See https://www.omise.co/receipt-api for more information.

type ReceiptList

type ReceiptList struct {
	List
	Data []*Receipt `json:"data"`
}

ReceiptList represents the list structure returned by Omise's REST API that contains Receipt struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*ReceiptList) Find

func (list *ReceiptList) Find(id string) *Receipt

Find finds and returns Receipt with the given id. Returns nil if not found.

type Recipient

type Recipient struct {
	Base
	Verified    bool          `json:"verified"`
	Active      bool          `json:"active"`
	Name        string        `json:"name"`
	Email       string        `json:"email"`
	Description *string       `json:"description"`
	Type        RecipientType `json:"type"`
	TaxID       *string       `json:"tax_id"`
	BankAccount *BankAccount  `json:"bank_account"`
	FailureCode *string       `json:"failure_code"`
}

Recipient represents Omise's recipient object. See https://www.omise.co/recipients-api for more information.

type RecipientList

type RecipientList struct {
	List
	Data []*Recipient `json:"data"`
}

RecipientList represents the list structure returned by Omise's REST API that contains Recipient struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*RecipientList) Find

func (list *RecipientList) Find(id string) *Recipient

Find finds and returns Recipient with the given id. Returns nil if not found.

type RecipientSearchResult

type RecipientSearchResult struct {
	SearchResult
	Data []*Recipient `json:"data"`
}

RecipientSearchResult represents search result structure returned by Omise's Search API that contains Recipient struct as result elements.

type RecipientType

type RecipientType string

RecipientType represents an enumeration of possible types of Recipient(s).

const (
	Individual  RecipientType = "individual"
	Corporation RecipientType = "corporation"
)

RecipientType can be one of the following list of constants:

type Refund

type Refund struct {
	Base
	Amount      int64                  `json:"amount"`
	Currency    string                 `json:"currency"`
	Charge      string                 `json:"charge"`
	Transaction string                 `json:"transaction"`
	Metadata    map[string]interface{} `json:"metadata"`
}

Refund represents Omise's refund object. See https://www.omise.co/refunds-api for more information.

type RefundList

type RefundList struct {
	List
	Data []*Refund `json:"data"`
}

RefundList represents the list structure returned by Omise's REST API that contains Refund struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*RefundList) Find

func (list *RefundList) Find(id string) *Refund

Find finds and returns Refund with the given id. Returns nil if not found.

type RefundSearchResult

type RefundSearchResult struct {
	SearchResult
	Data []*Refund `json:"data"`
}

RefundSearchResult represents search result structure returned by Omise's Search API that contains Refund struct as result elements.

type Schedule

type Schedule struct {
	Base
	Status          schedule.Status          `json:"status"`
	Every           int                      `json:"every"`
	Period          schedule.Period          `json:"period"`
	On              schedule.On              `json:"on"`
	InWords         string                   `json:"in_words"`
	StartDate       Date                     `json:"start_date"`
	EndDate         Date                     `json:"end_date"`
	Charge          *schedule.ChargeDetail   `json:"charge"`
	Transfer        *schedule.TransferDetail `json:"transfer"`
	Occurrences     OccurrenceList           `json:"occurrences"`
	NextOccurrences []Date                   `json:"next_occurrences"`
}

Schedule represents Omise's schedule object. See https://www.omise.co/schedule-api for more information.

type ScheduleList

type ScheduleList struct {
	List
	Data []*Schedule `json:"data"`
}

ScheduleList represents the list structure returned by Omise's REST API that contains Schedule struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*ScheduleList) Find

func (list *ScheduleList) Find(id string) *Schedule

Find finds and returns Schedule with the given id. Returns nil if not found.

type SearchResult

type SearchResult struct {
	Base
	Scope   SearchScope       `json:"scope"`
	Query   string            `json:"query"`
	Filters map[string]string `json:"filters"`

	Page       int `json:"page"`
	Total      int `json:"total"`
	TotalPages int `json:"total_pages"`

	Order Ordering `json:"order"`
}

SearchResult structure contains fields that are common to search result objects returned by Omise's REST API.

type SearchScope

type SearchScope string

SearchScope represents an enumeration of possible scopes that can be used with the Search API.

const (
	UnspecifiedScope SearchScope = ""

	ChargeScope    SearchScope = "charge"
	DisputeScope   SearchScope = "dispute"
	RecipientScope SearchScope = "recipient"
	CustomerScope  SearchScope = "customer"
	RefundScope    SearchScope = "refund"
	TransferScope  SearchScope = "transfer"
	LinkScope      SearchScope = "link"
)

SearchScope can be one of the following constants:

type Source

type Source struct {
	Object   string  `json:"object"`
	ID       string  `json:"id"`
	Live     bool    `json:"livemode"`
	Location *string `json:"location"`
	Type     string  `json:"type"`
	Flow     string  `json:"flow"`
	Amount   int64   `json:"amount"`
	Currency string  `json:"currency"`
}

Source represents Omise's source object. See https://www.omise.co/source-api for more information.

type SourceOfFunds

type SourceOfFunds string

SourceOfFunds represents an enumeration of possible source of funds on a Charge object.

const (
	FromCard    SourceOfFunds = "card"
	FromOffsite SourceOfFunds = "offsite"
)

SourceOfFunds can be one the following list of constants:

type Token

type Token struct {
	Base
	Used bool  `json:"used"`
	Card *Card `json:"card"`
}

Token represents Omise's token object. See https://www.omise.co/tokens-api for more information.

!!! IMPORTANT !!! - Full Credit Card data should never go through your server.

Sending card data from server requires a valid PCI-DSS certification. You can learn more about this on the Security Best Practices page at https://www.omise.co/security-best-practices

type TokenList

type TokenList struct {
	List
	Data []*Token `json:"data"`
}

TokenList represents the list structure returned by Omise's REST API that contains Token struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*TokenList) Find

func (list *TokenList) Find(id string) *Token

Find finds and returns Token with the given id. Returns nil if not found.

type Transaction

type Transaction struct {
	Base
	Source string          `json:"source"`
	Type   TransactionType `json:"type"`

	Amount       int64     `json:"amount"`
	Currency     string    `json:"currency"`
	Transferable time.Time `json:"transferable"`
}

Transaction represents Omise's transaction object. See https://www.omise.co/transactions-api for more information.

type TransactionList

type TransactionList struct {
	List
	Data []*Transaction `json:"data"`
}

TransactionList represents the list structure returned by Omise's REST API that contains Transaction struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*TransactionList) Find

func (list *TransactionList) Find(id string) *Transaction

Find finds and returns Transaction with the given id. Returns nil if not found.

type TransactionType

type TransactionType string

TransactionType represents an enumeration of possible types of Transaction.

const (
	Credit TransactionType = "credit"
	Debit  TransactionType = "debit"
)

TransactionType can be one of the following list of constants:

type Transfer

type Transfer struct {
	Base
	Recipient   string       `json:"recipient"`
	BankAccount *BankAccount `json:"bank_account"`

	Sent     bool   `json:"sent"`
	Paid     bool   `json:"paid"`
	Fee      int64  `json:"fee"`
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`

	FailureCode    *string `json:"failure_code"`
	FailureMessage *string `json:"failure_message"`
	Transaction    *string `json:"transaction"`

	Metadata map[string]interface{} `json:"metadata"`
}

Transfer represents Omise's transfer object. See https://www.omise.co/transfers-api for more information.

type TransferList

type TransferList struct {
	List
	Data []*Transfer `json:"data"`
}

TransferList represents the list structure returned by Omise's REST API that contains Transfer struct as member elements. See the pagination and lists documentation at https://www.omise.co/api-pagination for more information.

func (*TransferList) Find

func (list *TransferList) Find(id string) *Transfer

Find finds and returns Transfer with the given id. Returns nil if not found.

type TransferSearchResult

type TransferSearchResult struct {
	SearchResult
	Data []*Transfer `json:"data"`
}

TransferSearchResult represents search result structure returned by Omise's Search API that contains Transfer struct as result elements.

Directories

Path Synopsis
Package operations provide operation objects for use with Client.
Package operations provide operation objects for use with Client.

Jump to

Keyboard shortcuts

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