Documentation
¶
Index ¶
- type Card
- type CardPayment
- type Fee
- type FeeConfigReader
- type Installment
- type InstallmentTerm
- func (p *InstallmentTerm) GetAdminFee() *payment.Money
- func (p *InstallmentTerm) GetAdminFeeConfig(currency string) *Fee
- func (p *InstallmentTerm) GetGateway() payment.Gateway
- func (p *InstallmentTerm) GetInstallmentFee() *payment.Money
- func (p *InstallmentTerm) GetInstallmentFeeConfig(currency string) *Fee
- func (p *InstallmentTerm) GetPaymentWaitingTime() *time.Duration
- func (p *InstallmentTerm) MarshalJSON() ([]byte, error)
- type NonCard
- type NonCardPayment
- type PaymentConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct {
PaymentType payment.PaymentType `yaml:"payment_type" json:"payment_type"`
IconURLs []string `yaml:"icon_urls" json:"icon_urls"`
Installments []Installment `yaml:"installments" json:"installments"`
}
Card represent the credit card payment config retrieved from the yaml config file
func (Card) GetInstallment ¶
func (cfg Card) GetInstallment(bank payment.Bank, aType payment.InstallmentType) (*Installment, error)
GetInstallment returns an installment information for a given bank and its type
type CardPayment ¶
type CardPayment struct {
Card
// contains filtered or unexported fields
}
CardPayment represent credit card based payment method. This struct might have information about the value of a product will be paid by using cards.
func NewCardPayment ¶
func NewCardPayment(cfg Card, value *payment.Money) *CardPayment
NewCardPayment creates a new CardPayment. if value is provided, each installment within this payment can calculate its own admin/installment fee in money notation. Otherwise, it just returns the percentage and/or the value of the fee.
type Fee ¶
type Fee struct {
PercentageVal float64 `yaml:"val_percentage"`
CurrencyVal float64 `yaml:"val_currency"`
Currency string `yaml:"currency" json:"currency"`
}
Fee stores fee information in percentage / in currenc value
type FeeConfigReader ¶
type FeeConfigReader interface {
GetGateway() payment.Gateway
GetPaymentWaitingTime() *time.Duration
GetAdminFeeConfig(currency string) *Fee
GetInstallmentFeeConfig(currency string) *Fee
}
FeeConfigReader holds function used for retrieving payment method's information (gateway and fee)
type Installment ¶
type Installment struct {
Gateway payment.Gateway `yaml:"gateway" json:"-"`
DisplayName string `yaml:"display_name" json:"display_name"`
Type payment.InstallmentType `yaml:"type" json:"type"`
Bank payment.Bank `yaml:"bank" json:"bank"`
Channel string `yaml:"channel" json:"-"`
IsActive bool `yaml:"active" json:"-"`
IsDefault bool `yaml:"default" json:"-"`
Terms []InstallmentTerm `yaml:"terms" json:"terms"`
}
Installment contains information about the package of the installment, issuer bank, its type, and installment terms along with its fee information
func (Installment) GetTerm ¶
func (i Installment) GetTerm(term int) (*InstallmentTerm, error)
GetTerm finds an installment given its term. If it doesn't exist, it returns ErrNotFound error
func (*Installment) SetValue ¶
func (i *Installment) SetValue(val *payment.Money) error
SetValue sets the value of money which will be used for admin/installment fee
func (*Installment) UnmarshalYAML ¶
func (i *Installment) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML custom unmarshall for installment. This will add payment gateway info to each terms in an installment
type InstallmentTerm ¶
type InstallmentTerm struct {
Gateway payment.Gateway `yaml:"-" json:"-"`
Term int `yaml:"term" json:"term"`
AdminFee map[string]Fee `yaml:"admin_fee,omitempty" json:"-"`
InstalmentFee map[string]Fee `yaml:"installment_fee,omitempty" json:"-"`
// contains filtered or unexported fields
}
InstallmentTerm stores information about the admin/installment fee applicable for a particular term
func (*InstallmentTerm) GetAdminFee ¶
func (p *InstallmentTerm) GetAdminFee() *payment.Money
GetAdminFee returns the admin fee of an installment term in money notation
func (*InstallmentTerm) GetAdminFeeConfig ¶
func (p *InstallmentTerm) GetAdminFeeConfig(currency string) *Fee
GetAdminFeeConfig returns admin fee rules of an installment term
func (*InstallmentTerm) GetGateway ¶
func (p *InstallmentTerm) GetGateway() payment.Gateway
GetGateway returns payment gateway for current installment term
func (*InstallmentTerm) GetInstallmentFee ¶
func (p *InstallmentTerm) GetInstallmentFee() *payment.Money
GetInstallmentFee returns the installment fee of an installment term in money notation
func (*InstallmentTerm) GetInstallmentFeeConfig ¶
func (p *InstallmentTerm) GetInstallmentFeeConfig(currency string) *Fee
GetInstallmentFeeConfig returns installment fee rules of an installment term
func (*InstallmentTerm) GetPaymentWaitingTime ¶
func (p *InstallmentTerm) GetPaymentWaitingTime() *time.Duration
GetPaymentWaitingTime is the max waiting time for payment completion after customer initiate the payment
func (*InstallmentTerm) MarshalJSON ¶
func (p *InstallmentTerm) MarshalJSON() ([]byte, error)
MarshalJSON augments admin and installment fee in money notation to installment term struct
type NonCard ¶
type NonCard struct {
PaymentType payment.PaymentType `yaml:"payment_type" json:"payment_type"`
IconURLs []string `yaml:"icon_urls" json:"icon_urls"`
Gateway payment.Gateway `yaml:"gateway" json:"-"`
DisplayName string `yaml:"display_name" json:"display_name"`
AdminFee map[string]Fee `yaml:"admin_fee,omitempty" json:"-"`
WaitingTime *waitingTime `yaml:"waiting_time" json:"-"`
}
NonCard represent the configuration for non cards payment (ewallet, retail outlet, cardless credit, virtual account).
func (*NonCard) GetAdminFeeConfig ¶
GetAdminFeeConfig returns the fee configuration for a given currency.
func (*NonCard) GetGateway ¶
GetGateway returns the payment gateway used for this payment methods
func (*NonCard) GetInstallmentFeeConfig ¶
GetInstallmentFeeConfig returns nil since the non card payment method doesn't has installment feature
func (*NonCard) GetPaymentWaitingTime ¶
GetPaymentWaitingTime is the max waiting time for payment completion after customer initiate the payment
type NonCardPayment ¶
type NonCardPayment struct {
NonCard
// contains filtered or unexported fields
}
NonCardPayment represent all payment method other than cards. This includes ewallet, virtual account, retail outlet, and cardless credit. This struct might have information about the value of a product will be paid by using cards.
func NewNonCardPayment ¶
func NewNonCardPayment(cfg NonCard, value *payment.Money) *NonCardPayment
NewNonCardPayment returns new NonCardPayment. if value is not nil, the admin fee of this payment method can be calculated.
func (*NonCardPayment) GetAdminFee ¶
func (p *NonCardPayment) GetAdminFee() *payment.Money
GetAdminFee returns the admin fee in money notation
func (*NonCardPayment) GetInstallmentFee ¶
func (p *NonCardPayment) GetInstallmentFee() *payment.Money
GetInstallmentFee returns nil since non card payment has no installment
func (*NonCardPayment) MarshalJSON ¶
func (p *NonCardPayment) MarshalJSON() ([]byte, error)
type PaymentConfig ¶
type PaymentConfig struct {
CardPayment Card `yaml:"card_payment" json:"card_payment"`
BankTransfers []NonCard `yaml:"bank_transfers" json:"bank_transfers"`
EWallets []NonCard `yaml:"ewallets" json:"ewallets"`
CStores []NonCard `yaml:"cstores" json:"cstores"`
CardlessCredits []NonCard `yaml:"cardless_credits" json:"cardless_credits"`
}
PaymentConfig stores all configuration for payment methods. This struct represent the yaml config file used for storing information about payment method fee (admin and installment fee), its max waiting time, also payment gateway information
func LoadPaymentConfigs ¶
func LoadPaymentConfigs(data []byte) (*PaymentConfig, error)
LoadPaymentConfigs reads payment yaml config file