Documentation ¶
Index ¶
- Constants
- Variables
- type APIError
- type Address
- type Card
- type CardArgs
- type CardTokenArgs
- type Charge
- type ChargeArgs
- type Customer
- func (c *Customer) AddCard(args *CardArgs) (*Card, error)
- func (c *Customer) AddCardWithToken(args *CardTokenArgs) (*Card, error)
- func (c *Customer) AddSubscription(args *SubscriptionArgs) (*Subscription, error)
- func (c *Customer) ChargeCustomer(data interface{}) (*Charge, error)
- func (c *Customer) DeleteCard(id string) error
- func (c *Customer) DeleteSubscription(id string) error
- func (c *Customer) GetCard(id string) (*Card, error)
- func (c *Customer) GetSubscription(id string) (*Subscription, error)
- func (c *Customer) GetSubscriptions() ([]Subscription, error)
- func (c *Customer) UpdateSubscription(id string, data *Subscription) (*Subscription, error)
- type CustomerArgs
- type Merchant
- func (m *Merchant) AddCard(args *CardArgs) (*Card, error)
- func (m *Merchant) AddCardWithToken(args *CardTokenArgs) (*Card, error)
- func (m *Merchant) AddCustomer(args *CustomerArgs) (*Customer, error)
- func (m *Merchant) DeleteCard(id string) error
- func (m *Merchant) DeleteCustomer(id string) error
- func (m *Merchant) GetCard(id string) (*Card, error)
- func (m *Merchant) GetCustomer(id string) (*Customer, error)
- func (m *Merchant) GetCustomers() ([]Customer, error)
- func (m *Merchant) UpdateCustomer(id string, data *Customer) (*Customer, error)
- type StoreReference
- type Subscription
- type SubscriptionArgs
- type SubscriptionStatus
Constants ¶
const ( ActiveStatus SubscriptionStatus = "active" TrialStatus = "trial" PastDueStatus = "past_due" UnpaidStatus = "unpaid" CancelledStatus = "cancelled" )
Available status options
Variables ¶
var ( ErrNilClient = errors.New("nil client") ErrNilMerchant = errors.New("this resource doesn't point to a merchant") ErrNoResourceID = errors.New("this resource has no ID") )
standard errors
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Category string `json:"category"` ErrorCode int `json:"error_code"` Description string `json:"description"` HTTPCode int `json:"http_code"` RequestID string `json:"request_id"` FraudRules []string `json:"fraud_rules"` }
APIError represents an error returned by the Openpay API
type Address ¶
type Address struct { Line1 string `json:"line1"` Line2 string `json:"line2"` Line3 string `json:"line3"` PostalCode string `json:"postal_code"` State string `json:"state"` City string `json:"city"` CountryCode string `json:"country_code"` }
Address represents a customer's address.
type Card ¶
type Card struct { CardArgs CreationDate time.Time `json:"creation_date,omitempty"` AllowsCharges bool `json:"allows_charges"` AllowsPayouts bool `json:"allows_payouts"` Brand string `json:"brand,omitempty"` Type string `json:"type"` BankName string `json:"bank_name"` BankCode string `json:"bank_code"` CustomerID string `json:"customer_id"` PointsCard bool `json:"points_card"` }
Card represents a credit or debit card.
type CardArgs ¶
type CardArgs struct { ID string `json:"id"` HolderName string `json:"holder_name"` CardNumber string `json:"card_number"` CVV2 string `json:"cvv2,omitempty"` ExpirationMonth string `json:"expiration_month"` ExpirationYear string `json:"expiration_year"` Address Address `json:"address,omitempty"` }
CardArgs represents the arguments sent to the Openpay API to create a new card.
type CardTokenArgs ¶
type CardTokenArgs struct { TokenID string `json:"token_id"` DeviceSessionID string `json:"device_session_id"` }
CardTokenArgs represents the data sent to the Openpay API to create a new card from previously tokenized information.
type Charge ¶
type Charge struct { ID string `json:"id"` Authorization string `json:"authorization"` OperationType string `json:"operation_type"` Method string `json:"method"` TransactionType string `json:"transaction_type"` Card struct { ID string `json:"id"` Type string `json:"type"` Brand string `json:"brand"` Address Address `json:"address"` CardNumber string `json:"card_number"` HolderName string `json:"holder_name"` ExpirationYear string `json:"expiration_year"` ExpirationMonth string `json:"expiration_month"` AllowsCharges bool `json:"allows_charges"` AllowsPayouts bool `json:"allows_payouts"` CreationDate string `json:"creation_date"` BankName string `json:"bank_name"` PointsType string `json:"points_type"` PointsCard bool `json:"points_card"` CustomerID string `json:"customer_id"` BankCode string `json:"bank_code"` } `json:"card"` Status string `json:"status"` Conciliated bool `json:"conciliated"` CreationDate string `json:"creation_date"` OperationDate string `json:"operation_date"` Description string `json:"description"` ErrorMessage *string `json:"error_message"` OrderID string `json:"order_id"` CustomerID string `json:"customer_id"` Amount float64 `json:"amount"` Currency string `json:"currency"` Fee struct { Amount float64 `json:"amount"` Tax float64 `json:"tax"` } `json:"fee"` }
type ChargeArgs ¶
type ChargeArgs struct { Source_id string `json:"source_id"` Method string `json:"method"` Amount float64 `json:"amount"` Currency string `json:"currency"` Description string `json:"description"` Order_id string `json:"order_id"` Device_session_id string `json:"device_session_id"` }
ChargeArgs is the object sent to the Openpay API when a new charge is made for a customer.
type Customer ¶
type Customer struct { ID string `json:"id,omitempty"` CreationDate time.Time `json:"creation_date"` Name string `json:"name"` LastName string `json:"last_name"` Email string `json:"email"` PhoneNumber string `json:"phone_number"` Status string `json:"status"` Balance float64 `json:"balance"` CLABE string `json:"clabe"` Address Address `json:"address"` Store StoreReference `json:"store"` // Merchant will be set automatically if obtained from through an API call. // Otherwise, you must set it yourself. Merchant *Merchant }
Customer is an Openpay customer.
func (*Customer) AddCardWithToken ¶
func (c *Customer) AddCardWithToken(args *CardTokenArgs) (*Card, error)
AddCardWithToken saves a card to the customer's account, using a card token generated with the JavaScript library.
func (*Customer) AddSubscription ¶
func (c *Customer) AddSubscription(args *SubscriptionArgs) (*Subscription, error)
AddSubscription subscribes a customer to a plan
func (*Customer) ChargeCustomer ¶
func (*Customer) DeleteCard ¶
DeleteCard removes a card saved on the customer's account
func (*Customer) DeleteSubscription ¶
DeleteSubscription cancels a subscription immediately
func (*Customer) GetSubscription ¶
func (c *Customer) GetSubscription(id string) (*Subscription, error)
GetSubscription retrieves a subscription with the specified ID
func (*Customer) GetSubscriptions ¶
func (c *Customer) GetSubscriptions() ([]Subscription, error)
GetSubscriptions gets all of a customer's subscriptions
func (*Customer) UpdateSubscription ¶
func (c *Customer) UpdateSubscription(id string, data *Subscription) (*Subscription, error)
UpdateSubscription updates a subscription with the provided data
type CustomerArgs ¶
type CustomerArgs struct { ExternalID string `json:"external_id,omitempty"` Name string `json:"name"` LastName string `json:"last_name,omitempty"` Email string `json:"email"` RequiresAccount bool `json:"requires_acount"` PhoneNumber string `json:"phone_number,omitempty"` Address Address `json:"address,omitempty"` }
CustomerArgs is the object sent to the Openpay API when a new customer is created.
type Merchant ¶
type Merchant struct {
// contains filtered or unexported fields
}
Merchant represents your Openpay account
func NewMerchant ¶
NewMerchant initializes a merchant instance, which is at the same time an Openpay API consumer
func (*Merchant) AddCardWithToken ¶
func (m *Merchant) AddCardWithToken(args *CardTokenArgs) (*Card, error)
AddCardWithToken saves a card to your merchant account, using a card token generated with the JavaScript library.
func (*Merchant) AddCustomer ¶
func (m *Merchant) AddCustomer(args *CustomerArgs) (*Customer, error)
AddCustomer creates a new customer on the Openpay API.
func (*Merchant) DeleteCard ¶
DeleteCard removes a card saved on your merchant account.
func (*Merchant) DeleteCustomer ¶
DeleteCustomer deletes an Openpay customer.
func (*Merchant) GetCustomer ¶
GetCustomer gets an Openpay customer.
func (*Merchant) GetCustomers ¶
GetCustomers lists all available customers.
type StoreReference ¶
type StoreReference struct { Reference string `json:"reference"` BarcodeURL string `json:"barcode_url"` PaybinReference string `json:"paybin_reference"` BarcodePaybinURL string `json:"barcode_paybin_url"` }
StoreReference represents a customer's store reference.
type Subscription ¶
type Subscription struct { ID string `json:"id"` CreationDate time.Time `json:"creation_date"` CancelAtPeriodEnd bool `json:"cancel_at_period_end"` ChargeDate time.Time `json:"charge_date"` CurrentPeriodNumber int `json:"current_period_number"` PerdiodEndDate time.Time `json:"period_end_date"` TrialEndDate time.Time `json:"trial_end_date"` PlanID int `json:"plan_id"` Status SubscriptionStatus `json:"status"` CustomerID int `json:"customer_id"` Card Card `json:"card"` }
Subscription represents a customer's subscription to a plan
type SubscriptionArgs ¶
type SubscriptionArgs struct { PlanID int `json:"plan_id"` TrialEndDate string `json:"trial_end_date"` SourceID string `json:"source_id,omitempty"` Card Card `json:"card,omitempty"` }
SubscriptionArgs is the object sent to the Openpay API when a new subscription is created
type SubscriptionStatus ¶
type SubscriptionStatus string
SubscriptionStatus is a subscription's current status