Documentation
¶
Index ¶
- Constants
- Variables
- type Processor
- func (p *Processor) AddOrder(ctx context.Context, orderID *big.Int, price *big.Int, ...) (txHash common.Hash, err error)
- func (p *Processor) CancelOrder(ctx context.Context, orderID *big.Int, dealHash *big.Int, cancelReason string) (txHash common.Hash, err error)
- func (p *Processor) ProcessPayment(ctx context.Context, orderID *big.Int, dealHash *big.Int) (txHash common.Hash, err error)
- func (p *Processor) RefundPayment(ctx context.Context, orderID *big.Int, dealHash *big.Int, refundReason string) (txHash common.Hash, err error)
- func (p *Processor) SecurePay(ctx context.Context, orderID, price *big.Int) (txHash common.Hash, err error)
- func (p *Processor) SecureTokenPay(ctx context.Context, tokenAddress common.Address, gasLimit *big.Int, ...) (txHash common.Hash, err error)
- func (p *Processor) WithdrawRefund(ctx context.Context, orderID *big.Int) (txHash common.Hash, err error)
- func (p *Processor) WithdrawTokenRefund(ctx context.Context, orderID *big.Int) (txHash common.Hash, err error)
Constants ¶
View Source
const ( // OrderStateNull = 0, order's state in Ethereum storage OrderStateNull = iota // OrderStateCreated = 1, order's state in Ethereum storage OrderStateCreated // OrderStatePaid = 2, order's state in Ethereum storage OrderStatePaid // OrderStateFinalized = 3, order's state in Ethereum storage OrderStateFinalized // OrderStateRefunding = 4, order's state in Ethereum storage OrderStateRefunding // OrderStateRefunded = 5, order's state in Ethereum storage OrderStateRefunded // OrderStateCanceled = 6, order's state in Ethereum storage OrderStateCanceled )
Variables ¶
View Source
var ( // ErrContractNotFound error returned when PaymentProcessorContract could not be instantiated on the given address ErrContractNotFound = errors.New("processor: PaymentProcessorContract not found") // ErrOrderStateNotNull error returned when Order's state is not Null ErrOrderStateNotNull = errors.New("processor: can not execute addOrder order's state is not Null") // ErrOrderNotCreated error returned when Order's state is not Created ErrOrderNotCreated = errors.New("processor: could not execute SecurePay order's state is not Created") //ErrAlwaysFailingTransaction error returned when Transaction could not be submitted to blockchain ErrAlwaysFailingTransaction = errors.New("processor: could not submit a transaction. Gas limit exceeds limits or always failing transaction") )
Functions ¶
This section is empty.
Types ¶
type Processor ¶
type Processor struct {
*eth.Session
ContractAddress common.Address
ContractHandler *contracts.PaymentProcessorContract
}
Processor executes methods necessary for payment processing on chain
func NewProcessor ¶
NewProcessor converts session to Processor
func (*Processor) AddOrder ¶
func (p *Processor) AddOrder(ctx context.Context, orderID *big.Int, price *big.Int, originAddress common.Address, tokenAddress common.Address, vouchersApplied *big.Int) (txHash common.Hash, err error)
AddOrder creates order in Ethereum storage with the given parameters
func (*Processor) CancelOrder ¶
func (p *Processor) CancelOrder(ctx context.Context, orderID *big.Int, dealHash *big.Int, cancelReason string) (txHash common.Hash, err error)
CancelOrder cancels the order. Canceling an order is possible only if Order was not paid yet
func (*Processor) ProcessPayment ¶
func (p *Processor) ProcessPayment(ctx context.Context, orderID *big.Int, dealHash *big.Int) (txHash common.Hash, err error)
ProcessPayment unlocks funds from the contract and transfers them to MerchantWallet
func (*Processor) RefundPayment ¶
func (p *Processor) RefundPayment(ctx context.Context, orderID *big.Int, dealHash *big.Int, refundReason string) (txHash common.Hash, err error)
RefundPayment initiates process of refund for particular Order.
func (*Processor) SecurePay ¶
func (p *Processor) SecurePay(ctx context.Context, orderID, price *big.Int) (txHash common.Hash, err error)
SecurePay makes a secure transfer of funds from Customer's address to PaymentProcessor contract
func (*Processor) SecureTokenPay ¶
func (p *Processor) SecureTokenPay(ctx context.Context, tokenAddress common.Address, gasLimit *big.Int, orderID *big.Int) (txHash common.Hash, err error)
SecureTokenPay makes a secure transfer of ERC20 funds from Customer's address to PaymentProcessor contract
Click to show internal directories.
Click to hide internal directories.