Documentation ¶
Overview ¶
Package satisgo helps people make more money having less commissions. Easy of use and automatic deposits to your bank account once the ammount is over the setted limit.
Index ¶
- Constants
- type Ammount
- type Charge
- func (c *Charge) CancelCharge(p *Satis) error
- func (c *Charge) CreateCharge(p *Satis) error
- func (c *Charge) NewRefund() (*Refund, error)
- func (c *Charge) NewRefundWithAmount(a float64) (*Refund, error)
- func (c *Charge) SetAmmount(a float64) error
- func (c *Charge) SetCallbackURL(s string) error
- func (c *Charge) SetDescription(s string) error
- func (c *Charge) SetExpiration(d time.Duration) error
- func (c *Charge) SetMetadata(key, value string) error
- func (c *Charge) UpdateChargeDescription(p *Satis) error
- func (c *Charge) UpdateChargeMetadata(p *Satis) error
- type Refund
- type Satis
- func (p *Satis) AmmountSpecificDate(year, month, day int) (*Ammount, error)
- func (p *Satis) AmmountSpecificYear(year int) (*Ammount, error)
- func (p *Satis) AmmountThisMonth() (*Ammount, error)
- func (p *Satis) AmmountThisWeek() (*Ammount, error)
- func (p *Satis) AmmountThisYear() (*Ammount, error)
- func (p *Satis) AmmountToday() (*Ammount, error)
- func (p *Satis) AmmountYesterday() (*Ammount, error)
- func (p *Satis) GetAllCharges() (*[]Charge, error)
- func (p *Satis) GetAllRefunds() (*[]Refund, error)
- func (p *Satis) GetAllUsers() (*[]User, error)
- func (p *Satis) GetCharge(id string) (*Charge, error)
- func (p *Satis) GetRefund(id string) (*Refund, error)
- func (p *Satis) GetRefundFromChargeID(chargeID string) (*[]Refund, error)
- func (p *Satis) GetRefundSinceChargeID(chargeID string) (*[]Refund, error)
- func (p *Satis) UserFromID(id string) (*User, error)
- func (p *Satis) UserFromPhone(phone string) (*User, error)
- func (p *Satis) Verify() error
- type User
Constants ¶
const ( //Required represent a status waiting for a payment Required = "REQUIRED" //Success represent "payment successfull" Success = "SUCCESS" //Failure represent payment Failure Failure = "FAILURE" //ErrDeclined represent a cancellation from the user ErrDeclined = "DECLINED_BY_PAYER" //ErrFalseRequest represent a cancellation by the wrong user ErrFalseRequest = "DECLINED_BY_PAYER_NOT_REQUIRED" //ErrNewer is the cancellation of the charge because the user received a new one ErrNewer = "CANCEL_BY_NEW_CHARGE" //ErrInternal represent a failure from the server ErrInternal = "INTERNAL_FAILURE" //ErrExpired the user took to long to respond to the charge request ErrExpired = "EXPIRED" )
const ( //ReasonDuplicate happens when two of the same charge appears ReasonDuplicate = "DUPLICATE" //ReasonFraud happens when someone else creates and approves a transaction for a user. ReasonFraud = "FRAUDULENT" //ReasonCustomerRequest if the customer requested a refund (if allowed by company policy) ReasonCustomerRequest = "REQUESTED_BY_CUSTOMER" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ammount ¶
type Ammount struct { TotalCharge int `json:"total_charge_amount_unit"` TotalRefund int `json:"total_refund_amount_unit"` Currency string `json:"currency"` }
Ammount is used to calculate total "sales" and refunds
type Charge ¶
type Charge struct { //ID is the unique charge_id ID string `json:"id,omitempty"` //Description is the about the charge Description string `json:"description,omitempty"` //for now only "EUR" is supported Currency string `json:"currency,omitempty"` //Amount is expressed in EuroCents Amount uint64 `json:"amount,omitempty"` //Status can have one of 3 states: REQUIRED,SUCCESS,FAILURE Status string `json:"status,omitempty"` //StatusDetails is helpfull identifing the problem when FAILURE is display as status StatusDetails string `json:"status_detail,omitempty"` //UserID is the user unique indentifier UserID string `json:"user_id,omitempty"` //UserShortName is given by webButton UserShortName string `json:"user_short_name,omitempty"` //Metadata has max 20 fields(key value storage for charges) Metadata map[string]string `json:"metadata,omitempty,omitempty"` //Return a string of "true" or "false" Paid bool `json:"paid,omitempty"` //ChargeDate is the date in which the payment has been made ChargeDate string `json:"charge_date,omitempty"` //Refund is the ammount of the charge that has gone in a Refund Refund uint64 `json:"refund_amount,omitempty"` //EmailOnSuccess takes "true" or "false" and send an email after a payment has occurred (true by default with this library) EmailOnSuccess bool `json:"required_success_email,omitempty"` //ExpireIn represent the number of seconds the user has to approve the payment before it expires ExpireIn int `json:"expire_in,omitempty"` //Expire date is the rielaboration of the ExpireIN from the server ExpireDate string `json:"expire_date,omitempty"` //Is given to get notified when a "status" change in a charge CallbackURL string `json:"callback_url,omitempty"` }
Charge is the type that handles charges for the user
func (*Charge) CancelCharge ¶
CancelCharge cancel a charge not yet approved by client
func (*Charge) CreateCharge ¶
CreateCharge is the function that makes the call to Satispay API
func (*Charge) NewRefundWithAmount ¶
NewRefundWithAmount generates a refund based on the given charge and the ammount supplied
func (*Charge) SetAmmount ¶
SetAmmount helps inserting a description into the charge THIS IS MANDATORY
func (*Charge) SetCallbackURL ¶
SetCallbackURL is used to change the default 15 minutes expiration time for approving a charge THIS IS NOT MANDATORY
func (*Charge) SetDescription ¶
SetDescription helps inserting a description into the charge THIS IS NOT MANDATORY BUT HIGHLY SUGGESTED
func (*Charge) SetExpiration ¶
SetExpiration is used to change the default 15 minutes expiration time for approving a charge THIS IS NOT MANDATORY
func (*Charge) SetMetadata ¶
SetMetadata is used to add metadata to a charge without making any mess around THere are some limits: max 20pairs, key length max 45 chars, value max 500 chars THIS IS NOT MANDATORY
func (*Charge) UpdateChargeDescription ¶
UpdateChargeDescription returns a modified Charge provided one
func (*Charge) UpdateChargeMetadata ¶
UpdateChargeMetadata returns a modified Charge provided one
type Refund ¶
type Refund struct { //ID is the unique charge_id ID string `json:"id,omitempty"` //ChargeID is the charge unique indentifier ChargeID string `json:"charge_id,omitempty"` //Description is the about the charge Description string `json:"description,omitempty"` //for now only "EUR" is supported Currency string `json:"currency,omitempty"` //Amount is expressed in EuroCents Amount uint64 `json:"amount,omitempty"` //Metadata has max 20 fields(key value storage for charges) Metadata map[string]string `json:"metadata,omitempty"` //Created is the time in UnixMilli of the creation of the refund Created string `json:"reason,omitempty"` //Reason is the reason a refund occurred Reason string `json:"reason,omitempty"` }
Refund is the type that handles charges for the user
func (*Refund) CreateRefund ¶
CreateRefund is the function that makes the call to Satispay API to request a refund with the given parameters
func (*Refund) SetAmmount ¶
SetAmmount helps inserting a description into the refund THIS IS MANDATORY
func (*Refund) SetDescription ¶
SetDescription helps inserting a description into the refund THIS IS NOT MANDATORY BUT HIGHLY SUGGESTED
func (*Refund) SetMetadata ¶
SetMetadata is used to add metadata to a refund without making any mess around THere are some limits: max 20pairs, key length max 45 chars, value max 500 chars THIS IS NOT MANDATORY
func (*Refund) SetReason ¶
SetReason helps inserting a reason into the refund instance THIS IS NOT MANDATORY BUT HIGHLY SUGGESTED Only few reasons are allowed (use of package costants is suggested)
func (*Refund) UpdateRefundMetadata ¶
UpdateRefundMetadata returns a modified Refund provided one
type Satis ¶
type Satis struct {
// contains filtered or unexported fields
}
Satis is the base unit for a payment/action with the satispay API
func (*Satis) AmmountSpecificDate ¶
AmmountSpecificDate return the total ammount of charges for the past week
func (*Satis) AmmountSpecificYear ¶
AmmountSpecificYear is cool for accountability
func (*Satis) AmmountThisMonth ¶
AmmountThisMonth is cool for accountability
func (*Satis) AmmountThisWeek ¶
AmmountThisWeek return the total ammount of charges for the past week
func (*Satis) AmmountThisYear ¶
AmmountThisYear is cool for accountability
func (*Satis) AmmountToday ¶
AmmountToday return the total ammount of charges for the past week
func (*Satis) AmmountYesterday ¶
AmmountYesterday return the total ammount of charges for the past week
func (*Satis) GetAllCharges ¶
GetAllCharges returns all charges from the beginning
func (*Satis) GetAllRefunds ¶
GetAllRefunds returns all charges from the beginning
func (*Satis) GetAllUsers ¶
GetAllUsers returns all charges from the beginning
func (*Satis) GetRefundFromChargeID ¶
GetRefundFromChargeID returns all charges from the beginning
func (*Satis) GetRefundSinceChargeID ¶
GetRefundSinceChargeID returns all charges from the beginning
func (*Satis) UserFromID ¶
UserFromID is the way to get a phone number with an id
func (*Satis) UserFromPhone ¶
UserFromPhone is the way to get an identifier with a phone number