merchant

package
v0.0.0-...-8f31e64 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AuthMethodExternal = "external"

AuthMethodExternal gives authorization responsibility to another layer, like the Apache HTTPserver. Taler will accept direct unauthenticated requests.

View Source
const AuthMethodToken = "token"

AuthMethodToken expects the correct user/password combination in the HTTP Authorization header.

Variables

This section is empty.

Functions

func NewOrderPath

func NewOrderPath(
	endpoint string,
	orderID string,
	token string,
) string

func NewRefundPath

func NewRefundPath(
	endpoint string,
	orderID string,
	hContract string,
) string

Types

type Address

type Address struct{}

type AuthMethod

type AuthMethod struct{}

method can be 'external'

"auth" : {
  "method" : "token",
  "token" : "secret-token:booknook"
}

type BearerAuthClient

type BearerAuthClient struct {
	HTTPRequester
	Username string
	Password string
}

func WithBearerAuth

func WithBearerAuth(
	cli HTTPRequester,
	username, password string,
) *BearerAuthClient

cover this in examples

func (*BearerAuthClient) Do

func (s *BearerAuthClient) Do(req *http.Request) (*http.Response, error)

type CheckPaymentClaimedResponse

type CheckPaymentClaimedResponse struct {
	// OrderStatus always "claimed"
	OrderStatus string `json:"order_status"`
}

type CheckPaymentPaidResponse

type CheckPaymentPaidResponse struct {
	// OrderStatus always "paid"
	OrderStatus    string                  `json:"order_status"`
	Refunded       bool                    `json:"refunded"`
	RefundPending  bool                    `json:"refund_pending"`
	Wired          bool                    `json:"wired"`
	DepositTotal   api.Amount              `json:"deposit_total"`
	ExchangeEC     int64                   `json:"exchange_ec"`
	ExchangeHC     int64                   `json:"exchange_hc"`
	RefundAmount   api.Amount              `json:"refund_amount"`
	RefundDetails  []RefundDetails         `json:"refund_details"`
	OrderStatusURL string                  `json:"order_status_url"`
	ContractTerms  ContractTermsIncomplete `json:"contract_terms"`
}

type CheckPaymentUnpaidResponse

type CheckPaymentUnpaidResponse struct {
	// OrderStatus always "unpaid"
	OrderStatus                string        `json:"order_status"`
	TalerPayURI                string        `json:"taler_pay_uri"`
	CreationTime               api.Timestamp `json:"creation_time"`
	Summary                    string        `json:"summary"`
	TotalAmount                api.Amount    `json:"total_amount"`
	AlreadyPaidOrderID         *string       `json:"already_paid_order_id"`
	AlreadyPaidFullfillmentURL *string       `json:"already_paid_fullfillment_url"`
	OrderStatusURL             string        `json:"order_status_url"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	cli HTTPRequester,
	basePath string,
) *Client

func (*Client) CreateInstance

func (s *Client) CreateInstance(arg CreateInstanceRequest) error

func (*Client) CreateOrder

func (s *Client) CreateOrder(instance string, arg CreateOrderRequest) (*PostOrderReponse, error)

func (*Client) CreateProduct

func (s *Client) CreateProduct(instanceID string, req CreateProductRequest) error

func (*Client) GetOrder

func (s *Client) GetOrder(
	instance, orderID string,
	query GetOrderQuery,
) (*MerchantOrderStatusResponse, error)

func (*Client) GetOrders

func (s *Client) GetOrders(
	instanceID string,
	query GetOrdersQuery,
) (*OrderHistory, error)

func (*Client) RefundOrder

func (s *Client) RefundOrder(
	instance, orderID string,
	req RefundOrderRequest,
) (*MerchantRefundResponse, error)

func (Client) Request

func (s Client) Request(
	method string,
	statusCode *int,
	path string,
	req, resp interface{},
) (int, error)

type ContractTermsIncomplete

type ContractTermsIncomplete struct {
	Amount               *api.Amount       `json:"amount,omitempty"`
	AutoRefund           *api.RelativeTime `json:"auto_refund,omitempty"`
	RefundDeadline       *api.Timestamp    `json:"refund_deadline,omitempty"`
	WireTransferDeadline *api.Timestamp    `json:"wire_transfer_deadline,omitempty"`
}

type CreateInstanceRequest

type CreateInstanceRequest struct {
	Address                    Address
	Auth                       AuthMethod
	DefaultMaxDepositFee       api.Amount
	DefaultMaxWireFee          api.Amount
	DefaultWireFeeAmortization int // Check what this means
	DefaultWireTransferDelay   api.RelativeTime
	ID                         string
	Jurisdiction               interface{} // Check
	Name                       string
	PaytoURIs                  []api.PayToURI
}

type CreateOrderRequest

type CreateOrderRequest struct {
	InventoryProducts []InventoryProducts `json:"inventory_products,omitempty"`
	Order             Order               `json:"order,omitempty"`
	RefundDelay       *api.RelativeTime   `json:"refund_delay,omitempty"`
	PaymentTarget     string              `json:"payment_target,omitempty"`
	LockUUIDs         []UUID              `json:"lock_uuids,omitempty"`
	CreateToken       *bool               `json:"create_token,omitempty"`
}

type CreateProductRequest

type CreateProductRequest struct {
	Price       api.Amount `json:"price"`
	ProductID   string     `json:"product_id"`
	TotalStock  int        `json:"total_stock"`
	Unit        Unit       `json:"unit"`
	Image       HTMLImage  `json:"image"`
	Description string     `json:"description"`
	Taxes       []Tax      `json:"taxes"`
}

type GetOrderQuery

type GetOrderQuery struct {
	SessionID *string        `schema:"session_id,omitempty"`
	Transfer  *api.QueryBool `schema:"transfer,omitempty"`
	TimeoutMS *int64         `schema:"timeout_ms,omitempty"`
}

type GetOrdersQuery

type GetOrdersQuery struct {
	Paid      *api.QueryBool `schema:"paid,omitempty"`
	Refunded  *api.QueryBool `schema:"refunded,omitempty"`
	Wired     *api.QueryBool `schema:"wired,omitempty"`
	DateMS    *int64         `schema:"date_ms,omitempty"`
	Start     *int64         `schema:"start,omitempty"`
	Delta     *int64         `schema:"delta,omitempty"`
	TimeoutMS *int64         `schema:"timeout_ms,omitempty"`
}

type HTMLImage

type HTMLImage string

type HTTPRequester

type HTTPRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

type Instance

type Instance struct {
}

type InventoryProducts

type InventoryProducts struct {
	Quantity  int    `json:"quantity"`
	ProductID string `json:"product_id"`
}

"inventory_products" : [

{
   "quantity" : 1,
   "product_id" : "2"
}

],

type MerchantOrderStatusResponse

type MerchantOrderStatusResponse struct {
	OrderStatus OrderStatus `json:"order_status"`
	*CheckPaymentPaidResponse
	*CheckPaymentClaimedResponse
	*CheckPaymentUnpaidResponse
}

func (*MerchantOrderStatusResponse) MarshalJSON

func (s *MerchantOrderStatusResponse) MarshalJSON() ([]byte, error)

func (*MerchantOrderStatusResponse) UnmarshalJSON

func (s *MerchantOrderStatusResponse) UnmarshalJSON(buf []byte) error

type MerchantRefundResponse

type MerchantRefundResponse struct {
	TalerRefundURI string `json:"taler_refund_uri"`
	HContract      string `json:"h_contract"`
}

type Order

type Order struct {
	ContractTermsIncomplete
	Amount         *api.Amount `json:"amount"` // this is an odd format 'KUDOS:1'
	FulfillmentUrl *string     `json:"fulfillment_url,omitempty"`
	Summary        string      `json:"summary"`
}

type OrderHistory

type OrderHistory struct {
	Orders []OrderHistoryEntry `json:"orders"`
}

type OrderHistoryEntry

type OrderHistoryEntry struct {
	OrderID    string        `json:"order_id"`
	RowID      int64         `json:"row_id"`
	Timestamp  api.Timestamp `json:"timestamp"`
	Amount     api.Amount    `json:"amount"`
	Summary    string        `json:"summary"`
	Refundable bool          `json:"refundable"`
	Paid       bool          `json:"paid"`
}

type OrderStatus

type OrderStatus string
var (
	OrderStatusUnknown OrderStatus = ""
	OrderStatusClaimed OrderStatus = "claimed"
	OrderStatusPaid    OrderStatus = "paid"
	OrderStatusUnpaid  OrderStatus = "unpaid"
)

type PostOrderReponse

type PostOrderReponse struct {
	OrderID string  `json:"order_id"`
	Token   *string `json:"token"`
}

type RefundDetails

type RefundDetails struct {
	Reason    string        `json:"reason"`
	Timestamp api.Timestamp `json:"timestamp"`
	Amount    api.Amount    `json:"amount"`
}

type RefundOrderRequest

type RefundOrderRequest struct {
	Refund api.Amount `json:"refund"`
	Reason string     `json:"reason"`
}

type Tax

type Tax string

type UUID

type UUID = string

type Unit

type Unit string

Jump to

Keyboard shortcuts

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