Documentation ¶
Overview ¶
Package payments provides the payment service
Index ¶
- Variables
- func GetAllValidTransitionSequences() [][]QLDBPaymentTransitionState
- func RevisionValidInTree(ctx context.Context, client wrappedQldbSdkClient, ...) (bool, error)
- func TransitionHistoryIsValid(transactionHistory []QLDBPaymentTransitionHistoryEntry) (bool, error)
- type BitflyerMachine
- func (bm *BitflyerMachine) Authorized() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) Failed() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) Initialized() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) Paid() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) Pending() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) Prepared() (QLDBPaymentTransitionState, error)
- func (bm *BitflyerMachine) SetVersion(version int)
- type GeminiMachine
- func (gm *GeminiMachine) Authorized() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) Failed() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) Initialized() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) Paid() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) Pending() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) Prepared() (QLDBPaymentTransitionState, error)
- func (gm *GeminiMachine) SetVersion(version int)
- type QLDBPaymentTransitionData
- type QLDBPaymentTransitionHistoryEntry
- type QLDBPaymentTransitionHistoryEntryData
- type QLDBPaymentTransitionHistoryEntryHash
- type QLDBPaymentTransitionHistoryEntryMetadata
- type QLDBPaymentTransitionHistoryEntrySignature
- type QLDBPaymentTransitionState
- type TxStateMachine
- type UpholdMachine
- func (um *UpholdMachine) Authorized() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) Failed() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) Initialized() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) Paid() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) Pending() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) Prepared() (QLDBPaymentTransitionState, error)
- func (um *UpholdMachine) SetVersion(version int)
Constants ¶
This section is empty.
Variables ¶
var Transitions = map[QLDBPaymentTransitionState][]QLDBPaymentTransitionState{ Initialized: {Prepared, Failed}, Prepared: {Authorized, Failed}, Authorized: {Pending, Failed}, Pending: {Paid, Failed}, Paid: {}, Failed: {}, }
Transitions represents the valid forward-transitions for each given state
Functions ¶
func GetAllValidTransitionSequences ¶
func GetAllValidTransitionSequences() [][]QLDBPaymentTransitionState
GetAllValidTransitionSequences returns all valid transition sequences
func RevisionValidInTree ¶
func RevisionValidInTree( ctx context.Context, client wrappedQldbSdkClient, transaction QLDBPaymentTransitionHistoryEntry, ) (bool, error)
RevisionValidInTree verifies a document revision in QLDB using a digest and the Merkle hashes to rederive the digest
func TransitionHistoryIsValid ¶
func TransitionHistoryIsValid(transactionHistory []QLDBPaymentTransitionHistoryEntry) (bool, error)
TransitionHistoryIsValid returns whether a slice of entries representing the entire state history for a given id include exculsively valid transitions.
Types ¶
type BitflyerMachine ¶
type BitflyerMachine struct {
// contains filtered or unexported fields
}
BitflyerMachine is an implementation of TxStateMachine for Bitflyer's use-case
func (*BitflyerMachine) Authorized ¶
func (bm *BitflyerMachine) Authorized() (QLDBPaymentTransitionState, error)
Authorized implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) Failed ¶
func (bm *BitflyerMachine) Failed() (QLDBPaymentTransitionState, error)
Failed implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) Initialized ¶
func (bm *BitflyerMachine) Initialized() (QLDBPaymentTransitionState, error)
Initialized implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) Paid ¶
func (bm *BitflyerMachine) Paid() (QLDBPaymentTransitionState, error)
Paid implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) Pending ¶
func (bm *BitflyerMachine) Pending() (QLDBPaymentTransitionState, error)
Pending implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) Prepared ¶
func (bm *BitflyerMachine) Prepared() (QLDBPaymentTransitionState, error)
Prepared implements TxStateMachine for the Bitflyer machine
func (*BitflyerMachine) SetVersion ¶
func (bm *BitflyerMachine) SetVersion(version int)
SetVersion assigns the version field in the BitflyerMachine to the specified int
type GeminiMachine ¶
type GeminiMachine struct {
// contains filtered or unexported fields
}
GeminiMachine is an implementation of TxStateMachine for Gemini's use-case
func (*GeminiMachine) Authorized ¶
func (gm *GeminiMachine) Authorized() (QLDBPaymentTransitionState, error)
Authorized implements TxStateMachine for the Gemini machine
func (*GeminiMachine) Failed ¶
func (gm *GeminiMachine) Failed() (QLDBPaymentTransitionState, error)
Failed implements TxStateMachine for the Gemini machine
func (*GeminiMachine) Initialized ¶
func (gm *GeminiMachine) Initialized() (QLDBPaymentTransitionState, error)
Initialized implements TxStateMachine for the Gemini machine
func (*GeminiMachine) Paid ¶
func (gm *GeminiMachine) Paid() (QLDBPaymentTransitionState, error)
Paid implements TxStateMachine for the Gemini machine
func (*GeminiMachine) Pending ¶
func (gm *GeminiMachine) Pending() (QLDBPaymentTransitionState, error)
Pending implements TxStateMachine for the Gemini machine
func (*GeminiMachine) Prepared ¶
func (gm *GeminiMachine) Prepared() (QLDBPaymentTransitionState, error)
Prepared implements TxStateMachine for the Gemini machine
func (*GeminiMachine) SetVersion ¶
func (gm *GeminiMachine) SetVersion(version int)
SetVersion assigns the version field in the GeminiMachine to the specified int
type QLDBPaymentTransitionData ¶
type QLDBPaymentTransitionData struct {
Status QLDBPaymentTransitionState `ion:"status"`
}
QLDBPaymentTransitionData represents the data for a transaction. It is stored in QLDB in a serialized format and needs to be separately deserialized from the QLDB ion deserialization.
type QLDBPaymentTransitionHistoryEntry ¶
type QLDBPaymentTransitionHistoryEntry struct { BlockAddress qldbPaymentTransitionHistoryEntryBlockAddress `ion:"blockAddress"` Hash QLDBPaymentTransitionHistoryEntryHash `ion:"hash"` Data QLDBPaymentTransitionHistoryEntryData `ion:"data"` Metadata QLDBPaymentTransitionHistoryEntryMetadata `ion:"metadata"` }
QLDBPaymentTransitionHistoryEntry defines top level entry for a QLDB transaction
func GetQLDBObject ¶
func GetQLDBObject(txn wrappedQldbTxnAPI, id string) (QLDBPaymentTransitionHistoryEntry, error)
GetQLDBObject returns the latests state of an entry for a given ID after validating its transition history.
func GetTransitionHistory ¶
func GetTransitionHistory(txn wrappedQldbTxnAPI, id string) ([]QLDBPaymentTransitionHistoryEntry, error)
GetTransitionHistory returns a slice of entries representing the entire state history for a given id.
func (QLDBPaymentTransitionHistoryEntry) BuildSigningBytes ¶
func (e QLDBPaymentTransitionHistoryEntry) BuildSigningBytes() ([]byte, error)
BuildSigningBytes returns the bytes that should be signed over when creating a signature for a QLDBPaymentTransitionHistoryEntry.
type QLDBPaymentTransitionHistoryEntryData ¶
type QLDBPaymentTransitionHistoryEntryData struct { Signature []byte `ion:"signature"` Data []byte `ion:"data"` }
QLDBPaymentTransitionHistoryEntryData defines data for QLDBPaymentTransitionHistoryEntry
type QLDBPaymentTransitionHistoryEntryHash ¶
type QLDBPaymentTransitionHistoryEntryHash string
QLDBPaymentTransitionHistoryEntryHash defines hash for QLDBPaymentTransitionHistoryEntry
type QLDBPaymentTransitionHistoryEntryMetadata ¶
type QLDBPaymentTransitionHistoryEntryMetadata struct { ID string `ion:"id"` Version int64 `ion:"version"` TxTime time.Time `ion:"txTime"` TxID string `ion:"txId"` }
QLDBPaymentTransitionHistoryEntryMetadata defines metadata for QLDBPaymentTransitionHistoryEntry
type QLDBPaymentTransitionHistoryEntrySignature ¶
type QLDBPaymentTransitionHistoryEntrySignature []byte
QLDBPaymentTransitionHistoryEntrySignature defines signature for QLDBPaymentTransitionHistoryEntry
func WriteQLDBObject ¶
func WriteQLDBObject( driver wrappedQldbDriverAPI, key ed25519.PrivateKey, object QLDBPaymentTransitionHistoryEntry, ) (QLDBPaymentTransitionHistoryEntrySignature, error)
WriteQLDBObject persists an object in a transaction after verifying that its change represents a valid state transition.
type QLDBPaymentTransitionState ¶
type QLDBPaymentTransitionState int64
QLDBPaymentTransitionState is an integer representing transaction status
const ( // Initialized represents the first state that a transaction record Initialized QLDBPaymentTransitionState = iota // Prepared represents a record that has been prepared for authorization Prepared // Authorized represents a record that has been authorized Authorized // Pending represents a record that is being or has been submitted to a processor Pending // Paid represents a record that has entered a finalzed success state with a processor Paid // Failed represents a record that has failed processing permanently Failed )
func Drive ¶
func Drive[T TxStateMachine]( ctx context.Context, machine T, currentTransactionState QLDBPaymentTransitionState, currentTransactionVersion int, ) (QLDBPaymentTransitionState, error)
Drive switches on the provided currentTransactionState and executes the appropriate method from the provided TxStateMachine to attempt to progress the state.
func (QLDBPaymentTransitionState) GetValidTransitions ¶
func (q QLDBPaymentTransitionState) GetValidTransitions() []QLDBPaymentTransitionState
GetValidTransitions returns valid transitions
type TxStateMachine ¶
type TxStateMachine interface { SetVersion(int) Initialized() (QLDBPaymentTransitionState, error) Prepared() (QLDBPaymentTransitionState, error) Authorized() (QLDBPaymentTransitionState, error) Pending() (QLDBPaymentTransitionState, error) Paid() (QLDBPaymentTransitionState, error) Failed() (QLDBPaymentTransitionState, error) }
TxStateMachine describes types with the appropriate methods to be Driven as a state machine
type UpholdMachine ¶
type UpholdMachine struct {
// contains filtered or unexported fields
}
UpholdMachine is an implementation of TxStateMachine for uphold's use-case
func (*UpholdMachine) Authorized ¶
func (um *UpholdMachine) Authorized() (QLDBPaymentTransitionState, error)
Authorized implements TxStateMachine for uphold machine
func (*UpholdMachine) Failed ¶
func (um *UpholdMachine) Failed() (QLDBPaymentTransitionState, error)
Failed implements TxStateMachine for uphold machine
func (*UpholdMachine) Initialized ¶
func (um *UpholdMachine) Initialized() (QLDBPaymentTransitionState, error)
Initialized implements TxStateMachine for uphold machine
func (*UpholdMachine) Paid ¶
func (um *UpholdMachine) Paid() (QLDBPaymentTransitionState, error)
Paid implements TxStateMachine for uphold machine
func (*UpholdMachine) Pending ¶
func (um *UpholdMachine) Pending() (QLDBPaymentTransitionState, error)
Pending implements TxStateMachine for uphold machine
func (*UpholdMachine) Prepared ¶
func (um *UpholdMachine) Prepared() (QLDBPaymentTransitionState, error)
Prepared implements TxStateMachine for uphold machine
func (*UpholdMachine) SetVersion ¶
func (um *UpholdMachine) SetVersion(version int)
SetVersion assigns the version field in the GeminiMachine to the specified int