processor

package
v0.0.0-...-ddb3e2c Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: LGPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

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

func NewProcessor(s *eth.Session, contractAddress common.Address) *Processor

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

func (*Processor) WithdrawRefund

func (p *Processor) WithdrawRefund(ctx context.Context,
	orderID *big.Int) (txHash common.Hash, err error)

WithdrawRefund transfers funds equal to Order.price back to an address from which SecurePay was executed

func (*Processor) WithdrawTokenRefund

func (p *Processor) WithdrawTokenRefund(ctx context.Context,
	orderID *big.Int) (txHash common.Hash, err error)

WithdrawTokenRefund transfers funds equal to Order.price back to an address from which SecureTokenPay was executed

Jump to

Keyboard shortcuts

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