Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidCurrency(currency string) bool
- type Client
- type CodePayload
- type CodePayloadType
- type CreatePaymentRequestResponse
- type CurrencyCode
- type GetIntentStateResponse
- type IdempotencyKey
- type IntentOption
- type IntentState
- type KeyPair
- type PaymentRequestIntent
- type PaymentRequestOption
- type PrivateKey
- type PublicKey
Constants ¶
const ( KinMintDecimals = 5 QuarksPerKin = 100000 )
Variables ¶
var (
ErrInvalidCurrency = errors.New("currency is invalid")
)
var (
KinTokenMint, _ = NewPublicKeyFromString("kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6")
)
Functions ¶
func IsValidCurrency ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWebClient ¶
func NewWebClient() *Client
func (*Client) CreatePaymentRequest ¶
func (c *Client) CreatePaymentRequest( ctx context.Context, intent *PaymentRequestIntent, opts ...PaymentRequestOption, ) (*CreatePaymentRequestResponse, error)
CreatePaymentRequest creates a payment request intent. The response object can be used directly as the return value for the Code SDK on the browser.
func (*Client) GetIntentStatus ¶
func (c *Client) GetIntentStatus(ctx context.Context, intentId string) (*GetIntentStateResponse, error)
GetIntentStatus returns the state of the intent
type CodePayload ¶
type CodePayload struct {
// contains filtered or unexported fields
}
CodePayload is the payload format for scan codes.
func NewCodePayload ¶
func NewCodePayload(kind CodePayloadType, currency CurrencyCode, amount float64, nonce IdempotencyKey) (*CodePayload, error)
type CodePayloadType ¶
type CodePayloadType uint8
const ( CodePayloadCash CodePayloadType = iota CodePayloadGiftCard CodePayloadPaymentRequest )
type CurrencyCode ¶
type CurrencyCode string
const ( KIN CurrencyCode = "kin" AED CurrencyCode = "aed" AFN CurrencyCode = "afn" ALL CurrencyCode = "all" AMD CurrencyCode = "amd" ANG CurrencyCode = "ang" AOA CurrencyCode = "aoa" ARS CurrencyCode = "ars" AUD CurrencyCode = "aud" AWG CurrencyCode = "awg" AZN CurrencyCode = "azn" BAM CurrencyCode = "bam" BBD CurrencyCode = "bbd" BDT CurrencyCode = "bdt" BGN CurrencyCode = "bgn" BHD CurrencyCode = "bhd" BIF CurrencyCode = "bif" BMD CurrencyCode = "bmd" BND CurrencyCode = "bnd" BOB CurrencyCode = "bob" BRL CurrencyCode = "brl" BSD CurrencyCode = "bsd" BTN CurrencyCode = "btn" BWP CurrencyCode = "bwp" BYN CurrencyCode = "byn" BZD CurrencyCode = "bzd" CAD CurrencyCode = "cad" CDF CurrencyCode = "cdf" CHF CurrencyCode = "chf" CLP CurrencyCode = "clp" CNY CurrencyCode = "cny" COP CurrencyCode = "cop" CRC CurrencyCode = "crc" CUP CurrencyCode = "cup" CVE CurrencyCode = "cve" CZK CurrencyCode = "czk" DJF CurrencyCode = "djf" DKK CurrencyCode = "dkk" DOP CurrencyCode = "dop" DZD CurrencyCode = "dzd" EGP CurrencyCode = "egp" ERN CurrencyCode = "ern" ETB CurrencyCode = "etb" EUR CurrencyCode = "eur" FJD CurrencyCode = "fjd" FKP CurrencyCode = "fkp" GBP CurrencyCode = "gbp" GEL CurrencyCode = "gel" GHS CurrencyCode = "ghs" GIP CurrencyCode = "gip" GMD CurrencyCode = "gmd" GNF CurrencyCode = "gnf" GTQ CurrencyCode = "gtq" GYD CurrencyCode = "gyd" HKD CurrencyCode = "hkd" HNL CurrencyCode = "hnl" HRK CurrencyCode = "hrk" HTG CurrencyCode = "htg" HUF CurrencyCode = "huf" IDR CurrencyCode = "idr" ILS CurrencyCode = "ils" INR CurrencyCode = "inr" IQD CurrencyCode = "iqd" IRR CurrencyCode = "irr" ISK CurrencyCode = "isk" JMD CurrencyCode = "jmd" JOD CurrencyCode = "jod" JPY CurrencyCode = "jpy" KES CurrencyCode = "kes" KGS CurrencyCode = "kgs" KHR CurrencyCode = "khr" KMF CurrencyCode = "kmf" KPW CurrencyCode = "kpw" KRW CurrencyCode = "krw" KWD CurrencyCode = "kwd" KYD CurrencyCode = "kyd" KZT CurrencyCode = "kzt" LAK CurrencyCode = "lak" LBP CurrencyCode = "lbp" LKR CurrencyCode = "lkr" LRD CurrencyCode = "lrd" LYD CurrencyCode = "lyd" MAD CurrencyCode = "mad" MDL CurrencyCode = "mdl" MGA CurrencyCode = "mga" MKD CurrencyCode = "mkd" MMK CurrencyCode = "mmk" MNT CurrencyCode = "mnt" MOP CurrencyCode = "mop" MRU CurrencyCode = "mru" MUR CurrencyCode = "mur" MVR CurrencyCode = "mvr" MWK CurrencyCode = "mwk" MXN CurrencyCode = "mxn" MYR CurrencyCode = "myr" MZN CurrencyCode = "mzn" NAD CurrencyCode = "nad" NGN CurrencyCode = "ngn" NIO CurrencyCode = "nio" NOK CurrencyCode = "nok" NPR CurrencyCode = "npr" NZD CurrencyCode = "nzd" OMR CurrencyCode = "omr" PAB CurrencyCode = "pab" PEN CurrencyCode = "pen" PGK CurrencyCode = "pgk" PHP CurrencyCode = "php" PKR CurrencyCode = "pkr" PLN CurrencyCode = "pln" PYG CurrencyCode = "pyg" QAR CurrencyCode = "qar" RON CurrencyCode = "ron" RSD CurrencyCode = "rsd" RUB CurrencyCode = "rub" RWF CurrencyCode = "rwf" SAR CurrencyCode = "sar" SBD CurrencyCode = "sbd" SCR CurrencyCode = "scr" SDG CurrencyCode = "sdg" SEK CurrencyCode = "sek" SGD CurrencyCode = "sgd" SHP CurrencyCode = "shp" SLL CurrencyCode = "sll" SOS CurrencyCode = "sos" SRD CurrencyCode = "srd" SSP CurrencyCode = "ssp" STN CurrencyCode = "stn" SYP CurrencyCode = "syp" SZL CurrencyCode = "szl" THB CurrencyCode = "thb" TJS CurrencyCode = "tjs" TMT CurrencyCode = "tmt" TND CurrencyCode = "tnd" TOP CurrencyCode = "top" TRY CurrencyCode = "try" TTD CurrencyCode = "ttd" TWD CurrencyCode = "twd" TZS CurrencyCode = "tzs" UAH CurrencyCode = "uah" UGX CurrencyCode = "ugx" USD CurrencyCode = "usd" UYU CurrencyCode = "uyu" UZS CurrencyCode = "uzs" VES CurrencyCode = "ves" VND CurrencyCode = "vnd" VUV CurrencyCode = "vuv" WST CurrencyCode = "wst" XAF CurrencyCode = "xaf" XCD CurrencyCode = "xcd" XOF CurrencyCode = "xof" XPF CurrencyCode = "xpf" YER CurrencyCode = "yer" ZAR CurrencyCode = "zar" ZMW CurrencyCode = "zmw" )
type GetIntentStateResponse ¶
type GetIntentStateResponse struct {
Status IntentState `json:"status"`
}
type IdempotencyKey ¶
type IdempotencyKey [codePayloadNonceSize]byte
Idempotency key is a globally unique value for guaranteeing an action is executed once. Along with other payment details, it is used to derive a consistent rendezvous key and intent ID.
func GenerateIdempotencyKey ¶
func GenerateIdempotencyKey() IdempotencyKey
func NewIdempotencyKeyFromClientSecret ¶
func NewIdempotencyKeyFromClientSecret(data string) (IdempotencyKey, error)
func NewIdempotencyKeyFromSeed ¶
func NewIdempotencyKeyFromSeed(seed string) IdempotencyKey
func (IdempotencyKey) String ¶
func (k IdempotencyKey) String() string
type IntentOption ¶
type IntentOption func(*optionalIntentParameters)
func WithIdempotencyKey ¶
func WithIdempotencyKey(idempotencyKey IdempotencyKey) IntentOption
type IntentState ¶
type IntentState string
The state of an intent
const ( // The intent doesn't exist IntentStateUnknown IntentState = "unknown" // The intent exists, but the user hasn't submitted a payment IntentStatePending IntentState = "pending" // The user has submitted a payment. Fulfillment on the blockchain is either // in progress, or completed, by the Code sequencer. IntentStateConfirmed IntentState = "confirmed" )
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
func GenerateKeyPair ¶
func GenerateRendezvousKey ¶
func GenerateRendezvousKey(p *CodePayload) (*KeyPair, error)
func NewKeyPairFromRawValue ¶
func NewKeyPairFromRawValue(rawValue ed25519.PrivateKey) (*KeyPair, error)
func NewKeyPairFromSeed ¶
func (*KeyPair) GetPrivateKey ¶
func (k *KeyPair) GetPrivateKey() *PrivateKey
func (*KeyPair) GetPublicKey ¶
type PaymentRequestIntent ¶
type PaymentRequestIntent struct {
// contains filtered or unexported fields
}
PaymentRequestIntent is an intent to request a payment be made to a destination for a specifc amount. For fiat values, exchange rates are computed dynamically at time of payment.
func NewPaymentRequestIntent ¶
func NewPaymentRequestIntent( currency CurrencyCode, amount float64, destination string, opts ...IntentOption, ) (*PaymentRequestIntent, error)
func (*PaymentRequestIntent) GetClientSecret ¶
func (p *PaymentRequestIntent) GetClientSecret() string
GetClientSecret returns a secret value required by the Code SDK at the browser to reconstruct the intent. Your server should never share this value until the intent is successfully created against Code server.
func (*PaymentRequestIntent) GetIntentId ¶
func (p *PaymentRequestIntent) GetIntentId() string
GetIntentId is the unique ID for the intent. It is the public key of the rendezvous key pair.
func (*PaymentRequestIntent) GetRendezvousKey ¶
func (p *PaymentRequestIntent) GetRendezvousKey() *KeyPair
GetRendezvousKey returns a unique key pair for the scan code payload for the intent, which is used during the scanning process to establish a secure communication channel anonymously to coordinate a flow.
type PaymentRequestOption ¶
type PaymentRequestOption func(*optionalPaymentRequestParameters)
func WithWebhookUrl ¶
func WithWebhookUrl(webhookUrl string) PaymentRequestOption
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func NewPrivateKeyFromBytes ¶
func NewPrivateKeyFromBytes(value []byte) (*PrivateKey, error)
func NewPrivateKeyFromString ¶
func NewPrivateKeyFromString(value string) (*PrivateKey, error)
func (*PrivateKey) GetPublicKey ¶
func (k *PrivateKey) GetPublicKey() *PublicKey
func (*PrivateKey) Sign ¶
func (k *PrivateKey) Sign(message []byte) []byte
func (*PrivateKey) ToBase58 ¶
func (k *PrivateKey) ToBase58() string
func (*PrivateKey) ToBytes ¶
func (k *PrivateKey) ToBytes() ed25519.PrivateKey
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}