cryptomus

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 8 Imported by: 0

README

Cryptomus SDK Go

Cryptomus SDK Go is a Go library for interacting with the Cryptomus API. You can see the documentation for the Cryptomus API at https://doc.cryptomus.com/.

Features

  • Payments Integration (Create Invoice, Get Invoice, Get Invoices, Cancel Invoice, etc.)
  • Payout Integration (Create Payout, Get Payout, Get Payouts, Cancel Payout, etc.)
  • Recurring Payment Integration (Create Recurring Payment, Get Recurring Payment, Get Recurring, Cancel Recurring Payment, etc.)
  • Webhooks Integration (Verify Webhook, Resend Webhook)
  • Static Wallet
  • Support Balance Information
  • Support Exchange Rate Information

Installation

To install the Cryptomus SDK Go, you need to run the following command:

go get github.com/Aldiwildan77/cryptomus-sdk-go

Usage

Here is an example of how to use the Cryptomus SDK Go, you can see the full example in the examples directory.

Create Invoice
package main

import (
 "log"

 cryptomus "github.com/Aldiwildan77/cryptomus-sdk-go"
)

func main() {
 sdk := cryptomus.New(
  cryptomus.WithMerchant("fill your merchant id"),
  cryptomus.WithPaymentToken("fill your payment token"),
 )

 result, err := sdk.CreateInvoice(&cryptomus.CreateInvoiceRequest{
  Amount:   "15",
  Currency: "USD",
  OrderID:  "123456",
  Lifetime: 3600,
 })

 if err != nil {
  log.Fatal(err)
 }

 log.Println("Create invoice successfully.")
 log.Printf("Create invoice: %#+v", result)
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Muhammad Wildan Aldiansyah

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Host = "https://api.cryptomus.com"
)

Functions

func DefaultHTTPClient

func DefaultHTTPClient() *req.Client

func FromJSONString

func FromJSONString[T any](v string) (T, error)

FromJSONString converts a JSON string to a struct.

Example:

type ExchangeRate struct {
	From   string `json:"from,omitempty"`
	To     string `json:"to,omitempty"`
	Course string `json:"course,omitempty"`
}

exchangeRate, err := FromJSONString[ExchangeRate](`{"from":"ETH","to":"BTC","course":"0.0001"}`)
if err != nil {
	log.Fatal(err)
}

func Sign

func Sign(apiKey string, data interface{}) string

func ToJSON

func ToJSON[T any](v T) ([]byte, error)

ToJSON converts a struct to a JSON byte array.

Example:

type ExchangeRate struct {
	From   string `json:"from,omitempty"`
	To     string `json:"to,omitempty"`
	Course string `json:"course,omitempty"`
}

exchangeRate := ExchangeRate{
	From:   "ETH",
	To:     "BTC",
	Course: "0.0001",
}

resByte, err := ToJSON[ExchangeRate](exchangeRate)
if err != nil {
	log.Fatal(err)
}

Types

type Balance

type Balance struct {
	Merchant []Merchant `json:"merchant"`
	User     []User     `json:"user"`
}

Balance represents a list of balances.

The list of balances includes Business (merchant) and Personal (user) wallets.

type BalanceResponse

type BalanceResponse struct {
	*HTTPResponse
	Result []BalanceResult `json:"result,omitempty"`
}

type BalanceResult

type BalanceResult struct {
	Balance Balance `json:"balance"`
}

type BlockStaticWalletData

type BlockStaticWalletData struct {
	UUID   string                  `json:"uuid"`
	Status BlockStaticWalletStatus `json:"status"`
}

type BlockStaticWalletRequest

type BlockStaticWalletRequest struct {
	UUID          string `json:"uuid,omitempty"`
	OrderID       string `json:"order_id,omitempty"`
	IsForceRefund bool   `json:"is_force_refund"`
}

type BlockStaticWalletResponse

type BlockStaticWalletResponse struct {
	*HTTPResponse
	Result BlockStaticWalletData `json:"result"`
}

type BlockStaticWalletStatus

type BlockStaticWalletStatus string
const (
	BlockStaticWalletStatusBlocked  BlockStaticWalletStatus = "blocked"
	BlockStaticWalletStatusActive   BlockStaticWalletStatus = "active"
	BlockStaticWalletStatusInActive BlockStaticWalletStatus = "in_active"
)

type CancelRecurringPaymentRequest

type CancelRecurringPaymentRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
}

type CancelRecurringPaymentResponse

type CancelRecurringPaymentResponse struct {
	*HTTPResponse
	Result RecurringPaymentData `json:"result,omitempty"`
}

type CreateInvoiceData

type CreateInvoiceData struct {
	UUID            string    `json:"uuid"`
	OrderID         string    `json:"order_id"`
	Amount          string    `json:"amount"`
	PaymentAmount   int       `json:"payment_amount"`
	PayerAmount     int       `json:"payer_amount"`
	DiscountPercent int       `json:"discount_percent"`
	Discount        string    `json:"discount"`
	PayerCurrency   string    `json:"payer_currency"`
	Currency        string    `json:"currency"`
	MerchantAmount  int       `json:"merchant_amount"`
	Network         string    `json:"network"`
	Address         string    `json:"address"`
	From            string    `json:"from"`
	Txid            string    `json:"txid"`
	PaymentStatus   string    `json:"payment_status"`
	URL             string    `json:"url"`
	ExpiredAt       int       `json:"expired_at"`
	Status          string    `json:"status"`
	IsFinal         bool      `json:"is_final"`
	AdditionalData  string    `json:"additional_data"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type CreateInvoiceRequest

type CreateInvoiceRequest struct {
	Amount                 string     `json:"amount"`
	Currency               string     `json:"currency"`
	OrderID                string     `json:"order_id"`
	Network                string     `json:"network"`
	URLReturn              string     `json:"url_return"`
	URLSuccess             string     `json:"url_success"`
	URLCallback            string     `json:"url_callback"`
	IsPaymentMultiple      bool       `json:"is_payment_multiple"`
	Lifetime               int        `json:"lifetime"`
	ToCurrency             string     `json:"to_currency"`
	Subtract               int        `json:"subtract"`
	AccuracyPaymentPercent int        `json:"accuracy_payment_percent"`
	AdditionalData         string     `json:"additional_data"`
	Currencies             Currencies `json:"currencies"`
	ExceptCurrencies       Currencies `json:"except_currencies"`
	CourseSource           string     `json:"course_source"`
	FromReferralCode       string     `json:"from_referral_code"`
	DiscountPercent        int        `json:"discount_percent"`
	IsRefresh              bool       `json:"is_refresh"`
}

type CreateInvoiceResponse

type CreateInvoiceResponse struct {
	*HTTPResponse
	Result CreateInvoiceData `json:"result"`
}

type CreatePayoutRequest

type CreatePayoutRequest struct {
	Amount       string `json:"amount"`
	Currency     string `json:"currency" validate:"required"`
	OrderID      string `json:"order_id"`
	Address      string `json:"address"`
	IsSubtract   bool   `json:"is_subtract"`
	Network      string `json:"network"`
	URLCallback  string `json:"url_callback"`
	ToCurrency   string `json:"to_currency"`
	CourseSource string `json:"course_source"`
	FromCurrency string `json:"from_currency"`
	Priority     string `json:"priority"`
	Memo         string `json:"memo"`
}

type CreatePayoutResponse

type CreatePayoutResponse struct {
	*HTTPResponse
	Result *PayoutData `json:"result"`
}

type CreateRecurringPaymentRequest

type CreateRecurringPaymentRequest struct {
	Amount         string                 `json:"amount"`
	Currency       string                 `json:"currency"`
	Name           string                 `json:"name"`
	Period         RecurringPaymentPeriod `json:"period"`
	ToCurrency     string                 `json:"to_currency,omitempty"`
	OrderID        string                 `json:"order_id,omitempty"`
	URLCallback    string                 `json:"url_callback,omitempty"`
	DiscountDays   int                    `json:"discount_days,omitempty"`
	DiscountAmount string                 `json:"discount_amount,omitempty"`
	AdditionalData string                 `json:"additional_data,omitempty"`
}

type CreateRecurringPaymentResponse

type CreateRecurringPaymentResponse struct {
	*HTTPResponse
	Result RecurringPaymentData `json:"result,omitempty"`
}

type CreateStaticWalletData

type CreateStaticWalletData struct {
	WalletUUID string `json:"wallet_uuid"`
	UUID       string `json:"uuid"`
	Address    string `json:"address"`
	Network    string `json:"network"`
	Currency   string `json:"currency"`
	URL        string `json:"url"`
}

type CreateStaticWalletRequest

type CreateStaticWalletRequest struct {
	Currency         string `json:"currency"`
	Network          string `json:"network"`
	OrderID          string `json:"order_id"`
	URLCallback      string `json:"url_callback,omitempty"`
	FromReferralCode string `json:"from_referral_code,omitempty"`
}

type CreateStaticWalletResponse

type CreateStaticWalletResponse struct {
	*HTTPResponse
	Result CreateStaticWalletData `json:"result"`
}

type Cryptomus

type Cryptomus struct {
	HttpClient   *req.Client
	Merchant     string
	PaymentToken string
	PayoutToken  string
}

func DefaultCryptomus

func DefaultCryptomus() *Cryptomus

func New

func New(options ...Option) *Cryptomus

New creates a new Cryptomus SDK instance.

Make sure to set the Merchant and PaymentToken before using the SDK. follow the example at https://doc.cryptomus.com/business/general/getting-api-keys

Also check the request format at https://doc.cryptomus.com/business/general/request-format

You could set the PaymentToken and PayoutToken for the each instance of the SDK.

func (*Cryptomus) Balance

func (sdk *Cryptomus) Balance() (*BalanceResponse, error)

Balance returns a list of balances.

Details: https://doc.cryptomus.com/business/balance

Example:

result, err := sdk.Balance()
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) BalanceWithContext

func (sdk *Cryptomus) BalanceWithContext(ctx context.Context) (*BalanceResponse, error)

BalanceWithContext returns a list of balances.

Details: https://doc.cryptomus.com/business/balance

Example:

result, err := sdk.BalanceWithContext(ctx)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) BlockStaticWallet

func (sdk *Cryptomus) BlockStaticWallet(payload *BlockStaticWalletRequest) (*BlockStaticWalletResponse, error)

BlockStaticWallet blocks a static wallet.

Details: https://doc.cryptomus.com/business/payments/block-wallet

When you need to block your clients static wallet, all the further payments will not be credited to his balance. You can make a refund of this funds only once. The funds will be returned to the addresses from which they came.

You need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.BlockStaticWallet(&BlockStaticWalletRequest{
	UUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) BlockStaticWalletWithContext

func (sdk *Cryptomus) BlockStaticWalletWithContext(ctx context.Context, payload *BlockStaticWalletRequest) (*BlockStaticWalletResponse, error)

BlockStaticWalletWithContext blocks a static wallet.

Details: https://doc.cryptomus.com/business/payments/block-wallet

When you need to block your clients static wallet, all the further payments will not be credited to his balance. You can make a refund of this funds only once. The funds will be returned to the addresses from which they came.

You need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.BlockStaticWalletWithContext(ctx, &BlockStaticWalletRequest{
	UUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CancelRecurringPayment

func (sdk *Cryptomus) CancelRecurringPayment(payload CancelRecurringPaymentRequest) (*CancelRecurringPaymentResponse, error)

CancelRecurringPayment cancels a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/cancel

To cancel the recurring payment you need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.CancelRecurringPayment(CancelRecurringPaymentRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CancelRecurringPaymentWithContext

func (sdk *Cryptomus) CancelRecurringPaymentWithContext(ctx context.Context, payload CancelRecurringPaymentRequest) (*CancelRecurringPaymentResponse, error)

CancelRecurringPaymentWithContext cancels a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/cancel

To cancel the recurring payment you need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.CancelRecurringPaymentWithContext(ctx, CancelRecurringPaymentRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateInvoice

func (sdk *Cryptomus) CreateInvoice(payload *CreateInvoiceRequest) (*CreateInvoiceResponse, error)

CreateInvoice creates an invoice.

Details: https://doc.cryptomus.com/business/payments/creating-invoice

The invoice will have a specific cryptocurrency and address at the time of creation only if currency or to_currency parameter is a cryptocurrency and the network parameter is passed (or a cryptocurrency has only one network, for example BTC).

Example:

result, err := sdk.CreateInvoice(&CreateInvoiceRequest{
	Amount:     "15",
	Currency:   "USD",
	OrderID: 	"9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateInvoiceWithContext

func (sdk *Cryptomus) CreateInvoiceWithContext(ctx context.Context, payload *CreateInvoiceRequest) (*CreateInvoiceResponse, error)

CreateInvoiceWithContext creates an invoice.

Details: https://doc.cryptomus.com/business/payments/creating-invoice

The invoice will have a specific cryptocurrency and address at the time of creation only if currency or to_currency parameter is a cryptocurrency and the network parameter is passed (or a cryptocurrency has only one network, for example BTC).

Example:

result, err := sdk.CreateInvoiceWithContext(ctx, &CreateInvoiceRequest{
	Amount:     "15",
	Currency:   "USD",
	OrderID: 	"9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreatePayout

func (sdk *Cryptomus) CreatePayout(payload *CreatePayoutRequest) (*CreatePayoutResponse, error)

CreatePayout creates a payout.

Details: https://doc.cryptomus.com/business/payout/creating

The payouts through API are made only from your business wallets balances.

Payouts can be made in different ways:

- You can choose to receive the payout in a specific cryptocurrency and the payout will then be automatically processed in that specific cryptocurrency. To do so, ensure that you have sufficient balance in that particular currency to cover all associated fees.

- Alternatively, you have the option to specify the payout amount in a fiat currency. In this case, the amount will be automatically converted to a specific cryptocurrency from your available balance. For instance, if you request a payout of 20 USD in LTC, the equivalent value will be deducted from your LTC balance. It is important to have enough funds in the corresponding cryptocurrency to cover all applicable fees.

- Another possibility is to specify the payout amount in a fiat currency, which will be automatically converted to a specific cryptocurrency using your USDT balance. This option is particularly useful when you have autoconvert enabled, as funds from your invoices are automatically converted to USDT. For example, if you want to make a payout of 20 USD in LTC but only have a balance in USDT, make sure you have sufficient USDT funds to cover all fees.

- Additionally, you can choose to specify the payout amount in any cryptocurrency of your preference. The payout will then be automatically processed in that specific cryptocurrency, utilizing your available USDT balance. It is crucial to have enough USDT balance to cover all associated fees.

Example:

result, err := sdk.CreatePayout(&CreatePayoutRequest{
	Amount:   "5",
	Currency: "USDT",
	Network:  "TRON",
	Address:  "TJ5Zrj8z6bJ7bk9Kf8fz1yQFbJ7b7bJ7b7b",
	OrderID: "1",
	URLCallback: "https://example.com/callback",
	IsSubtract: true,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreatePayoutWithContext

func (sdk *Cryptomus) CreatePayoutWithContext(ctx context.Context, payload *CreatePayoutRequest) (*CreatePayoutResponse, error)

CreatePayoutWithContext creates a payout.

Details: https://doc.cryptomus.com/business/payout/creating

The payouts through API are made only from your business wallets balances.

Payouts can be made in different ways:

- You can choose to receive the payout in a specific cryptocurrency and the payout will then be automatically processed in that specific cryptocurrency. To do so, ensure that you have sufficient balance in that particular currency to cover all associated fees.

- Alternatively, you have the option to specify the payout amount in a fiat currency. In this case, the amount will be automatically converted to a specific cryptocurrency from your available balance. For instance, if you request a payout of 20 USD in LTC, the equivalent value will be deducted from your LTC balance. It is important to have enough funds in the corresponding cryptocurrency to cover all applicable fees.

- Another possibility is to specify the payout amount in a fiat currency, which will be automatically converted to a specific cryptocurrency using your USDT balance. This option is particularly useful when you have autoconvert enabled, as funds from your invoices are automatically converted to USDT. For example, if you want to make a payout of 20 USD in LTC but only have a balance in USDT, make sure you have sufficient USDT funds to cover all fees.

- Additionally, you can choose to specify the payout amount in any cryptocurrency of your preference. The payout will then be automatically processed in that specific cryptocurrency, utilizing your available USDT balance. It is crucial to have enough USDT balance to cover all associated fees.

Example:

result, err := sdk.CreatePayout(ctx, &CreatePayoutRequest{
	Amount:   "5",
	Currency: "USDT",
	Network:  "TRON",
	Address:  "TJ5Zrj8z6bJ7bk9Kf8fz1yQFbJ7b7bJ7b7b",
	OrderID: "1",
	URLCallback: "https://example.com/callback",
	IsSubtract: true,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateRecurringPayment

func (sdk *Cryptomus) CreateRecurringPayment(request CreateRecurringPaymentRequest) (*CreateRecurringPaymentResponse, error)

CreateRecurringPayment creates a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/creating

Example:

result, err := sdk.CreateRecurringPayment(CreateRecurringPaymentRequest{
	Amount:   "0.0001",
	Currency: "BTC",
	Name:     "Test recurring payment",
	Period:   RecurringPaymentPeriodWeekly,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateRecurringPaymentWithContext

func (sdk *Cryptomus) CreateRecurringPaymentWithContext(ctx context.Context, payload CreateRecurringPaymentRequest) (*CreateRecurringPaymentResponse, error)

CreateRecurringPaymentWithContext creates a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/creating

Recurring payments in cryptocurrency are a way to automate regular transactions using digital assets. They can be useful for subscription-based services, donations, memberships, and other recurring payments.

To use recurring payments, you need to create a payment that specifies the amount, currency, and frequency of the payments, and then share it with your payers. The payer will be redirected to the cryptomus website, where he will need to log in to confirm the payment plan and make the first payment. After that, payments will be made automatically according to the plan.

Example:

result, err := sdk.CreateRecurringPaymentWithContext(ctx, CreateRecurringPaymentRequest{
	Amount:   "0.0001",
	Currency: "BTC",
	Name:     "Test recurring payment",
	Period:   RecurringPaymentPeriodWeekly,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateStaticWallet

func (sdk *Cryptomus) CreateStaticWallet(payload *CreateStaticWalletRequest) (*CreateStaticWalletResponse, error)

CreateStaticWallet creates a static wallet.

Details: https://doc.cryptomus.com/business/payments/creating-static

Example:

result, err := sdk.CreateStaticWallet(&CreateStaticWalletRequest{
	Currency: "USDT",
	Network:  "tron",
	OrderID:  "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	URLCallback: "https://example.com/callback",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) CreateStaticWalletWithContext

func (sdk *Cryptomus) CreateStaticWalletWithContext(ctx context.Context, payload *CreateStaticWalletRequest) (*CreateStaticWalletResponse, error)

CreateStaticWalletWithContext creates a static wallet.

Details: https://doc.cryptomus.com/business/payments/creating-static

Example:

result, err := sdk.CreateStaticWalletWithContext(ctx, &CreateStaticWalletRequest{
	Currency: "USDT",
	Network:  "tron",
	OrderID:  "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	URLCallback: "https://example.com/callback",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ExchangeRateList

func (sdk *Cryptomus) ExchangeRateList(currency string) (*ExchangeRateResponse, error)

ExchangeRateList returns a list of exchange rates.

Details: https://doc.cryptomus.com/business/exchange-rates/list

Example:

result, err := sdk.ExchangeRateList("ETH")
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ExchangeRateListWithContext

func (sdk *Cryptomus) ExchangeRateListWithContext(ctx context.Context, currency string) (*ExchangeRateResponse, error)

ExchangeRateListWithContext returns a list of exchange rates.

Details: https://doc.cryptomus.com/business/exchange-rates/list

Example:

result, err := sdk.ExchangeRateListWithContext(ctx, "ETH")
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) GenerateQRCodeInvoice

func (sdk *Cryptomus) GenerateQRCodeInvoice(payload *GenerateQRCodeInvoiceRequest) (*GenerateQRCodeInvoiceResponse, error)

GenerateQRCodeInvoice generates a QR code for an invoice.

Details: https://doc.cryptomus.com/business/payments/qr-code-pay-form

You can generate a QR-code for a static wallet address or for an invoice address. Scanning it, the user will receive the address for depositing funds.

Example:

result, err := sdk.GenerateQRCodeInvoice(&GenerateQRCodeInvoiceRequest{
	MerchantPaymentUUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) GenerateQRCodeInvoiceWithContext

func (sdk *Cryptomus) GenerateQRCodeInvoiceWithContext(ctx context.Context, payload *GenerateQRCodeInvoiceRequest) (*GenerateQRCodeInvoiceResponse, error)

GenerateQRCodeInvoiceWithContext generates a QR code for an invoice.

Details: https://doc.cryptomus.com/business/payments/qr-code-pay-form

You can generate a QR-code for a static wallet address or for an invoice address. Scanning it, the user will receive the address for depositing funds.

Example:

result, err := sdk.GenerateQRCodeInvoiceWithContext(ctx, &GenerateQRCodeInvoiceRequest{
	MerchantPaymentUUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) GenerateQRStaticWallet

func (sdk *Cryptomus) GenerateQRStaticWallet(payload *GenerateQRCodeWalletRequest) (*GenerateQRCodeWalletResponse, error)

GenerateQRStaticWallet generates a QR code for a static wallet.

Details: https://doc.cryptomus.com/business/payments/qr-code-pay-form

You can generate a QR-code for a static wallet address or for an invoice address. Scanning it, the user will receive the address for depositing funds.

Example:

result, err := sdk.GenerateQRStaticWallet(&GenerateQRCodeWalletRequest{
	WalletAddressUUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) GenerateQRStaticWalletWithContext

func (sdk *Cryptomus) GenerateQRStaticWalletWithContext(ctx context.Context, payload *GenerateQRCodeWalletRequest) (*GenerateQRCodeWalletResponse, error)

GenerateQRStaticWalletWithContext generates a QR code for a static wallet.

Details: https://doc.cryptomus.com/business/payments/qr-code-pay-form

You can generate a QR-code for a static wallet address or for an invoice address. Scanning it, the user will receive the address for depositing funds.

Example:

result, err := sdk.GenerateQRStaticWalletWithContext(ctx, &GenerateQRCodeWalletRequest{
	WalletAddressUUID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ListOfDiscount

func (sdk *Cryptomus) ListOfDiscount() (*ListOfDiscountResponse, error)

ListOfDiscount returns a list of discounts.

Details: https://doc.cryptomus.com/business/discount/list

Example:

result, err := sdk.ListOfDiscount()
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ListOfDiscountWithContext

func (sdk *Cryptomus) ListOfDiscountWithContext(ctx context.Context) (*ListOfDiscountResponse, error)

ListOfDiscountWithContext returns a list of discounts.

Details: https://doc.cryptomus.com/business/discount/list

Example:

result, err := sdk.ListOfDiscountWithContext(ctx)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ListRecurringPayments

func (sdk *Cryptomus) ListRecurringPayments(request ListRecurringPaymentsRequest) (*ListRecurringPaymentsResponse, error)

ListRecurringPayments returns a list of recurring payments.

Details: https://doc.cryptomus.com/business/recurring/list

Example:

result, err := sdk.ListRecurringPayments(ListRecurringPaymentsRequest{
	Cursor: "eyJpZCI6MjEyLCJfcG9pbnRzVzVG9OZhXh0SXRlbXMiOnRydWV9",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ListRecurringPaymentsWithContext

func (sdk *Cryptomus) ListRecurringPaymentsWithContext(ctx context.Context, payload ListRecurringPaymentsRequest) (*ListRecurringPaymentsResponse, error)

ListRecurringPaymentsWithContext returns a list of recurring payments.

Details: https://doc.cryptomus.com/business/recurring/list

Example:

result, err := sdk.ListRecurringPaymentsWithContext(ctx, ListRecurringPaymentsRequest{
	Cursor: "eyJpZCI6MjEyLCJfcG9pbnRzVzFG9OZhXh0SXRlbXMiOnRydWV9",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentHistory

func (sdk *Cryptomus) PaymentHistory(payload *PaymentHistoryRequest) (*PaymentHistoryResponse, error)

PaymentHistory returns payment history.

Details: https://doc.cryptomus.com/business/payments/payment-history

To get next/previous page entries, specify the next/previous cursor hash

Example:

result, err := sdk.PaymentHistory(&PaymentHistoryRequest{
	DateFrom: "2021-01-01 00:00:00",
	DateTo:   "2021-12-31 23:59:59",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentHistoryWithContext

func (sdk *Cryptomus) PaymentHistoryWithContext(ctx context.Context, payload *PaymentHistoryRequest) (*PaymentHistoryResponse, error)

PaymentHistoryWithContext returns payment history.

Details: https://doc.cryptomus.com/business/payments/payment-history

To get next/previous page entries, specify the next/previous cursor hash

Example:

result, err := sdk.PaymentHistoryWithContext(ctx, &PaymentHistoryRequest{
	DateFrom: "2021-01-01 00:00:00",
	DateTo:   "2021-12-31 23:59:59",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentInformation

func (sdk *Cryptomus) PaymentInformation(payload *PaymentInformationRequest) (*PaymentInformationResponse, error)

PaymentInformation returns payment information.

Details: https://doc.cryptomus.com/business/payments/payment-information

To get the invoice status you need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.PaymentInformation(&PaymentInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentInformationWithContext

func (sdk *Cryptomus) PaymentInformationWithContext(ctx context.Context, payload *PaymentInformationRequest) (*PaymentInformationResponse, error)

PaymentInformationWithContext returns payment information.

Details: https://doc.cryptomus.com/business/payments/payment-information

To get the invoice status you need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.PaymentInformationWithContext(ctx, &PaymentInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentListOfServices

func (sdk *Cryptomus) PaymentListOfServices() (*PaymentListOfServicesResponse, error)

PaymentListOfServices returns a list of services.

Details: https://doc.cryptomus.com/business/payments/list-of-services

Returns a list of available payment services. Payment services store settings that are taken into account when creating an invoice. For example. currencies, networks, minimum and maximum limits, commissions.

Example:

result, err := sdk.PaymentListOfServices()
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PaymentListOfServicesWithContext

func (sdk *Cryptomus) PaymentListOfServicesWithContext(ctx context.Context) (*PaymentListOfServicesResponse, error)

PaymentListOfServicesWithContext returns a list of services.

Details: https://doc.cryptomus.com/business/payments/list-of-services

Returns a list of available payment services. Payment services store settings that are taken into account when creating an invoice. For example. currencies, networks, minimum and maximum limits, commissions.

Example:

result, err := sdk.PaymentListOfServicesWithContext(ctx)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutHistory

func (sdk *Cryptomus) PayoutHistory(payload *PayoutHistoryRequest) (*PayoutHistoryResponse, error)

PayoutHistory returns a list of payouts.

Details: https://doc.cryptomus.com/business/payouts/payout-history

Example:

result, err := sdk.PayoutHistory(&PayoutHistoryRequest{
	DateFrom: "2022-01-01 00:00:00",
	DateTo: "2022-01-31 23:59:59",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutHistoryWithContext

func (sdk *Cryptomus) PayoutHistoryWithContext(ctx context.Context, payload *PayoutHistoryRequest) (*PayoutHistoryResponse, error)

PayoutHistoryWithContext returns a list of payouts.

Details: https://doc.cryptomus.com/business/payouts/payout-history

Example:

result, err := sdk.PayoutHistoryWithContext(ctx, &PayoutHistoryRequest{
	DateFrom: "2022-01-01 00:00:00",
	DateTo: "2022-01-31 23:59:59",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutInformation

func (sdk *Cryptomus) PayoutInformation(payload *PayoutInformationRequest) (*PayoutInformationResponse, error)

PayoutInformation returns information about a payout.

Details: https://doc.cryptomus.com/business/payouts/payout-information

To get the payout information you need to pass one of the parameters, if you pass both, the payout will be identified by order_id

Example:

result, err := sdk.PayoutInformation(&PayoutInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutInformationWithContext

func (sdk *Cryptomus) PayoutInformationWithContext(ctx context.Context, payload *PayoutInformationRequest) (*PayoutInformationResponse, error)

PayoutInformationWithContext returns information about a payout.

Details: https://doc.cryptomus.com/business/payouts/payout-information

To get the payout information you need to pass one of the parameters, if you pass both, the payout will be identified by order_id

Example:

result, err := sdk.PayoutInformationWithContext(ctx, &PayoutInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutListOfServices

func (sdk *Cryptomus) PayoutListOfServices() (*PayoutListOfServicesResponse, error)

PayoutListOfServices returns a list of services for payouts.

Details: https://doc.cryptomus.com/business/payouts/list-of-services

Returns a list of available payout services. Payout services store settings that are taken into account when creating a payout. For example. currencies, networks, minimum and maximum limits, commissions.

Example:

result, err := sdk.PayoutListOfServices()
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) PayoutListOfServicesWithContext

func (sdk *Cryptomus) PayoutListOfServicesWithContext(ctx context.Context) (*PayoutListOfServicesResponse, error)

PayoutListOfServicesWithContext returns a list of services for payouts.

Details: https://doc.cryptomus.com/business/payouts/list-of-services

Returns a list of available payout services. Payout services store settings that are taken into account when creating a payout. For example. currencies, networks, minimum and maximum limits, commissions.

Example:

result, err := sdk.PayoutListOfServicesWithContext(ctx)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) RecurringPaymentInformation

func (sdk *Cryptomus) RecurringPaymentInformation(request RecurringPaymentInformationRequest) (*RecurringPaymentInformationResponse, error)

RecurringPaymentInformation returns information about a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/info

Example:

result, err := sdk.RecurringPaymentInformation(RecurringPaymentInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) RecurringPaymentInformationWithContext

func (sdk *Cryptomus) RecurringPaymentInformationWithContext(ctx context.Context, payload RecurringPaymentInformationRequest) (*RecurringPaymentInformationResponse, error)

RecurringPaymentInformationWithContext returns information about a recurring payment.

Details: https://doc.cryptomus.com/business/recurring/info

To get the recurring payment status you need to pass one of the required parameters, if you pass both, the account will be identified by order_id

Example:

result, err := sdk.RecurringPaymentInformationWithContext(ctx, RecurringPaymentInformationRequest{
	UUID: "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) Refund

func (sdk *Cryptomus) Refund(payload *RefundRequest) (*RefundResponse, error)

Refund refunds a payment.

Details: https://doc.cryptomus.com/business/payments/refund

Invoice is identified by order_id or uuid, if you pass both, the account will be identified by uuid

Example:

result, err := sdk.Refund(&RefundRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	Address: "0x...",
	IsSubtract: true,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) RefundPaymentOnBlockedAddress

func (sdk *Cryptomus) RefundPaymentOnBlockedAddress(payload *RefundPaymentOnBlockedAddressRequest) (*RefundPaymentOnBlockedAddressResponse, error)

RefundPaymentOnBlockedAddress refunds a payment on a blocked address.

Details: https://doc.cryptomus.com/business/payments/refundblocked

You can make a refund only once.

To refund payments you need to pass either uuid or order_id, if you pass both, the static wallet will be identified by uuid

Example:

result, err := sdk.RefundPaymentOnBlockedAddress(&RefundPaymentOnBlockedAddressRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	Address: "0x...",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) RefundPaymentOnBlockedAddressWithContext

func (sdk *Cryptomus) RefundPaymentOnBlockedAddressWithContext(ctx context.Context, payload *RefundPaymentOnBlockedAddressRequest) (*RefundPaymentOnBlockedAddressResponse, error)

RefundPaymentOnBlockedAddressWithContext refunds a payment on a blocked address.

Details: https://doc.cryptomus.com/business/payments/refundblocked

You can make a refund only once.

To refund payments you need to pass either uuid or order_id, if you pass both, the static wallet will be identified by uuid

Example:

result, err := sdk.RefundPaymentOnBlockedAddressWithContext(ctx, &RefundPaymentOnBlockedAddressRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	Address: "0x...",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) RefundWithContext

func (sdk *Cryptomus) RefundWithContext(ctx context.Context, payload *RefundRequest) (*RefundResponse, error)

RefundWithContext refunds a payment.

Details: https://doc.cryptomus.com/business/payments/refund

Invoice is identified by order_id or uuid, if you pass both, the account will be identified by uuid

Example:

result, err := sdk.RefundWithContext(ctx, &RefundRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
	Address: "0x...",
	IsSubtract: true,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ResendWebhook

func (sdk *Cryptomus) ResendWebhook(payload *ResendWebhookRequest) (*ResendWebhookResponse, error)

ResendWebhook resends a webhook.

Details: https://doc.cryptomus.com/business/payments/resend-webhook

Resend the webhook by invoice. You can resend the webhook only for finalized invoices, that is, invoices in statuses: wrong_amount, paid, paid_over.

To resend the webhook on the invoice, the url_callback must be specified at the time of invoice creation.

Example:

result, err := sdk.ResendWebhook(&ResendWebhookRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) ResendWebhookWithContext

func (sdk *Cryptomus) ResendWebhookWithContext(ctx context.Context, payload *ResendWebhookRequest) (*ResendWebhookResponse, error)

ResendWebhookWithContext resends a webhook.

Details: https://doc.cryptomus.com/business/payments/resend-webhook

Resend the webhook by invoice. You can resend the webhook only for finalized invoices, that is, invoices in statuses: wrong_amount, paid, paid_over.

To resend the webhook on the invoice, the url_callback must be specified at the time of invoice creation.

Example:

result, err := sdk.ResendWebhookWithContext(ctx, &ResendWebhookRequest{
	OrderID: "9d7f7b9b-3b7b-4b7b-9b7b-7b9d7f7b9b7b",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) SetDiscountToPaymentMethod

func (sdk *Cryptomus) SetDiscountToPaymentMethod(payload SetDiscountToPaymentMethodRequest) (*SetDiscountToPaymentMethodResponse, error)

SetDiscountToPaymentMethod sets a discount to a payment method.

Details: https://doc.cryptomus.com/business/discount/set

Discount Percent:

  • Positive Numbers (>0): Provides buyers a discount for paying with a coin. Useful for promotions or encouraging payments with a particular cryptocurrency.
  • Negative Numbers (<0): Adds a percentage (padding) for paying with a coin. This can help cover crypto/fiat conversion costs or adjust for local exchange differences.

Example:

err := sdk.SetDiscountToPaymentMethod(payload)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) SetDiscountToPaymentMethodWithContext

func (sdk *Cryptomus) SetDiscountToPaymentMethodWithContext(ctx context.Context, payload SetDiscountToPaymentMethodRequest) (*SetDiscountToPaymentMethodResponse, error)

SetDiscountToPaymentMethodWithContext sets a discount to a payment method.

Details: https://doc.cryptomus.com/business/discount/set

Discount Percent:

  • Positive Numbers (>0): Provides buyers a discount for paying with a coin. Useful for promotions or encouraging payments with a particular cryptocurrency.
  • Negative Numbers (<0): Adds a percentage (padding) for paying with a coin. This can help cover crypto/fiat conversion costs or adjust for local exchange differences.

Example:

err := sdk.SetDiscountToPaymentMethodWithContext(ctx, payload)
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookPayment

func (sdk *Cryptomus) TestingWebhookPayment(payload *TestingWebhookPaymentRequest) (*TestingWebhookPaymentResponse, error)

TestingWebhookPayment tests a webhook.

Details: https://doc.cryptomus.com/business/payments/testing-webhook

To validate the signature from the webhook data array, use the payment API key.

To ensure that you are correctly receiving webhooks and can validate the signature, you should use this method to test webhooks for payment. Please note that no data is saved to the database, and any data received in the webhook is only stored in an array for testing purposes to ensure the correctness of the signature and to test the retrieval of this array from us.

To test a webhook with an existing invoice, please provide its uuid or order ID. If these parameters are not provided, the webhook will be sent with a test invoice.

You may to pass one of the uuid or order_id parameters, if you pass both, the account will be identified by uuid

Example:

result, err := sdk.TestingWebhookPayment(&TestingWebhookRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PaymentStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookPaymentWithContext

func (sdk *Cryptomus) TestingWebhookPaymentWithContext(ctx context.Context, payload *TestingWebhookPaymentRequest) (*TestingWebhookPaymentResponse, error)

TestingWebhookPaymentWithContext tests a webhook.

Details: https://doc.cryptomus.com/business/payments/testing-webhook

To validate the signature from the webhook data array, use the payment API key.

To ensure that you are correctly receiving webhooks and can validate the signature, you should use this method to test webhooks for payment. Please note that no data is saved to the database, and any data received in the webhook is only stored in an array for testing purposes to ensure the correctness of the signature and to test the retrieval of this array from us.

To test a webhook with an existing invoice, please provide its uuid or order ID. If these parameters are not provided, the webhook will be sent with a test invoice.

You may to pass one of the uuid or order_id parameters, if you pass both, the account will be identified by uuid

Example:

result, err := sdk.TestingWebhookPaymentWithContext(ctx, &TestingWebhookRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PaymentStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookPayout

func (sdk *Cryptomus) TestingWebhookPayout(payload *TestingWebhookPayoutRequest) (*TestingWebhookPayoutResponse, error)

Example:

result, err := sdk.TestingWebhookPayout(&TestingWebhookPayoutRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PayoutStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookPayoutWithContext

func (sdk *Cryptomus) TestingWebhookPayoutWithContext(ctx context.Context, payload *TestingWebhookPayoutRequest) (*TestingWebhookPayoutResponse, error)

Example:

result, err := sdk.TestingWebhookPayoutWithContext(ctx, &TestingWebhookPayoutRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PayoutStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookWallet

func (sdk *Cryptomus) TestingWebhookWallet(payload *TestingWebhookWalletRequest) (*TestingWebhookWalletResponse, error)

TestingWebhookWallet tests a webhook.

Details: https://doc.cryptomus.com/business/payments/testing-webhook

To validate the signature from the webhook data array, use the payment API key.

Example:

result, err := sdk.TestingWebhookWallet(&TestingWebhookWalletRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PaymentStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TestingWebhookWalletWithContext

func (sdk *Cryptomus) TestingWebhookWalletWithContext(ctx context.Context, payload *TestingWebhookWalletRequest) (*TestingWebhookWalletResponse, error)

TestingWebhookWalletWithContext tests a webhook.

Details: https://doc.cryptomus.com/business/payments/testing-webhook

To validate the signature from the webhook data array, use the payment API key.

Example:

result, err := sdk.TestingWebhookWalletWithContext(ctx, &TestingWebhookWalletRequest{
	UUID:        "4b1b3b7b-7b1b-4b1b-7b1b-4b1b3b7b1b4b",
	URLCallback: "https://example.com/callback",
	Currency:    "USD",
	Network:     "btc",
	Status:      PaymentStatusPaid,
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TransferToBusinessWallet

func (sdk *Cryptomus) TransferToBusinessWallet(payload *TransferToBusinessWalletRequest) (*TransferToBusinessWalletResponse, error)

TransferToBusinessWallet transfers funds from a personal wallet to a business wallet.

Details: https://doc.cryptomus.com/business/payouts/transfer-to-business

Example:

result, err := sdk.TransferToBusinessWallet(&TransferToBusinessWalletRequest{
	Amount:   "5",
	Currency: "USDT",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TransferToBusinessWalletWithContext

func (sdk *Cryptomus) TransferToBusinessWalletWithContext(ctx context.Context, payload *TransferToBusinessWalletRequest) (*TransferToBusinessWalletResponse, error)

TransferToBusinessWalletWithContext transfers funds from a personal wallet to a business wallet.

Details: https://doc.cryptomus.com/business/payouts/transfer-to-business

Example:

result, err := sdk.TransferToBusinessWalletWithContext(ctx, &TransferToBusinessWalletRequest{
	Amount:   "5",
	Currency: "USDT",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TransferToPersonalWallet

func (sdk *Cryptomus) TransferToPersonalWallet(payload *TransferToPersonalWalletRequest) (*TransferToPersonalWalletResponse, error)

TransferToPersonalWallet transfers funds from a business wallet to a personal wallet.

Details: https://doc.cryptomus.com/business/payouts/transfer-to-personal

Example:

result, err := sdk.TransferToPersonalWallet(&TransferToPersonalWalletRequest{
	Amount:   "5",
	Currency: "USDT",
})
if err != nil {
    log.Fatal(err)
}

func (*Cryptomus) TransferToPersonalWalletWithContext

func (sdk *Cryptomus) TransferToPersonalWalletWithContext(ctx context.Context, payload *TransferToPersonalWalletRequest) (*TransferToPersonalWalletResponse, error)

TransferToPersonalWalletWithContext transfers funds from a business wallet to a personal wallet.

Details: https://doc.cryptomus.com/business/payouts/transfer-to-personal

Example:

result, err := sdk.TransferToPersonalWalletWithContext(ctx, &TransferToPersonalWalletRequest{
	Amount:   "5",
	Currency: "USDT",
})
if err != nil {
    log.Fatal(err)
}

type Currencies

type Currencies []Currency

type Currency

type Currency struct {
	Currency string `json:"currency"`
	Network  string `json:"network"`
}

type Discount

type Discount struct {
	// Currency code (e.g. BTC, ETH, USDT, etc.)
	Currency string `json:"currency"`
	// Blockchain network (e.g. ARBITRUM, AVALANCHE, BCH, etc.)
	Network string `json:"network"`
	// Discount percent (e.g. 5, 10, -15, etc.)
	Discount int `json:"discount"`
}

type Endpoint

type Endpoint string
var (
	CreateInvoiceEndpoint                 Endpoint = "/v1/payment"
	CreateStaticWalletEndpoint            Endpoint = "/v1/wallet"
	GenerateQRCodeWalletEndpoint          Endpoint = "/v1/wallet/qr"
	GenerateQRCodeInvoiceEndpoint         Endpoint = "/v1/payment/qr"
	BlockStaticWalletEndpoint             Endpoint = "/v1/wallet/block-address"
	RefundPaymentOnBlockedAddressEndpoint Endpoint = "/v1/wallet/blocked-address-refund"
	PaymentInformationEndpoint            Endpoint = "/v1/payment/info"
	RefundEndpoint                        Endpoint = "/v1/payment/refund"
	ResendWebhookEndpoint                 Endpoint = "/v1/payment/resend"
	PaymentListOfServicesEndpoint         Endpoint = "/v1/payment/services"
	PaymentHistoryEndpoint                Endpoint = "/v1/payment/list"

	TestingWebhookPaymentEndpoint Endpoint = "/v1/test-webhook/payment"
	TestingWebhookPayoutEndpoint  Endpoint = "/v1/test-webhook/payout"
	TestingWebhookWalletEndpoint  Endpoint = "/v1/test-webhook/wallet"

	CreatePayoutEndpoint             Endpoint = "/v1/payout"
	PayoutInformationEndpoint        Endpoint = "/v1/payout/info"
	PayoutHistoryEndpoint            Endpoint = "/v1/payout/list"
	PayoutListOfServicesEndpoint     Endpoint = "/v1/payout/services"
	TransferToPersonalWalletEndpoint Endpoint = "/v1/transfer/to-personal"
	TransferToBusinessWalletEndpoint Endpoint = "/v1/transfer/to-business"

	CreateRecurringPaymentEndpoint      Endpoint = "/v1/recurrence/create"
	RecurringPaymentInformationEndpoint Endpoint = "/v1/recurrence/info"
	ListRecurringPaymentsEndpoint       Endpoint = "/v1/recurrence/list"
	CancelRecurringPaymentEndpoint      Endpoint = "/v1/recurrence/cancel"

	ExchangeRateListEndpoint Endpoint = "/v1/exchange-rate/%s/list"

	ListOfDiscountsEndpoint            Endpoint = "/v1/payment/discount/list"
	SetDiscountToPaymentMethodEndpoint Endpoint = "/v1/payment/discount/set"

	BalanceEndpoint Endpoint = "/v1/balance"
)

func (Endpoint) String

func (e Endpoint) String() string

func (Endpoint) URL

func (e Endpoint) URL() string

type Errors

type Errors map[string][]string

type ExchangeRate

type ExchangeRate struct {
	// From Currency code (e.g. BTC, ETH, USDT, etc.)
	From string `json:"from,omitempty"`
	// To Currency code (e.g. BTC, ETH, USDT, etc.)
	To string `json:"to,omitempty"`
	// Exchange rate (e.g. 0.0001, 0.0002, 0.0003, etc.)
	Course string `json:"course,omitempty"`
}

type ExchangeRateList

type ExchangeRateList []ExchangeRate

type ExchangeRateResponse

type ExchangeRateResponse struct {
	*HTTPResponse
	Result ExchangeRateList `json:"result,omitempty"`
}

type GenerateQRCodeInvoiceData

type GenerateQRCodeInvoiceData struct {
	Image string `json:"image"`
}

type GenerateQRCodeInvoiceRequest

type GenerateQRCodeInvoiceRequest struct {
	MerchantPaymentUUID string `json:"merchant_payment_uuid"`
}

type GenerateQRCodeInvoiceResponse

type GenerateQRCodeInvoiceResponse struct {
	*HTTPResponse
	Result GenerateQRCodeInvoiceData `json:"result"`
}

type GenerateQRCodeWalletData

type GenerateQRCodeWalletData struct {
	Image string `json:"image"`
}

type GenerateQRCodeWalletRequest

type GenerateQRCodeWalletRequest struct {
	WalletAddressUUID string `json:"wallet_address_uuid"`
}

type GenerateQRCodeWalletResponse

type GenerateQRCodeWalletResponse struct {
	*HTTPResponse
	Result GenerateQRCodeWalletData `json:"result"`
}

type HTTPResponse

type HTTPResponse struct {
	State   int    `json:"state,omitempty"`
	Code    int    `json:"code,omitempty"`
	Errors  Errors `json:"errors,omitempty"`
	Error   string `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
}

type ListOfDiscount

type ListOfDiscount []Discount

type ListOfDiscountResponse

type ListOfDiscountResponse struct {
	*HTTPResponse
	Result ListOfDiscount `json:"result"`
}

type ListRecurringPaymentsData

type ListRecurringPaymentsData struct {
	Items    []RecurringPaymentData `json:"items"`
	Paginate *Pagination            `json:"paginate"`
}

type ListRecurringPaymentsRequest

type ListRecurringPaymentsRequest struct {
	Cursor string `json:"cursor,omitempty"`
}

type ListRecurringPaymentsResponse

type ListRecurringPaymentsResponse struct {
	*HTTPResponse
	Result ListRecurringPaymentsData `json:"result,omitempty"`
}

type Merchant

type Merchant struct {
	// Wallet UUID
	UUID string `json:"uuid"`
	// Business wallet balance
	Balance string `json:"balance"`
	// Wallet Currency code (e.g. BTC, ETH, USDT, etc.)
	CurrencyCode string `json:"currency_code"`
}

Merchant represents a business account.

type Option

type Option func(*Cryptomus)

func WithHttpClient

func WithHttpClient(client *req.Client) Option

func WithMerchant

func WithMerchant(merchant string) Option

func WithPaymentToken

func WithPaymentToken(token string) Option

func WithPayoutToken

func WithPayoutToken(token string) Option

type Pagination

type Pagination struct {
	Count          int    `json:"count"`
	HasPages       bool   `json:"hasPages"`
	NextCursor     string `json:"nextCursor,omitempty"`
	PreviousCursor string `json:"previousCursor,omitempty"`
	PerPage        int    `json:"perPage"`
}

type PaymentHistoryData

type PaymentHistoryData struct {
	Items    []CreateInvoiceData `json:"items"`
	Paginate *Pagination         `json:"paginate"`
}

type PaymentHistoryRequest

type PaymentHistoryRequest struct {
	DateFrom string `json:"date_from,omitempty"`
	DateTo   string `json:"date_to,omitempty"`
	Cursor   string `json:"-"`
}

type PaymentHistoryResponse

type PaymentHistoryResponse struct {
	*HTTPResponse
	Result PaymentHistoryData `json:"result"`
}

type PaymentInformationData

type PaymentInformationData struct {
	*CreateInvoiceData
}

type PaymentInformationRequest

type PaymentInformationRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
}

type PaymentInformationResponse

type PaymentInformationResponse struct {
	*HTTPResponse
	Result PaymentInformationData `json:"result"`
}

type PaymentListOfServiceCommission

type PaymentListOfServiceCommission struct {
	FeeAmount string `json:"fee_amount"`
	Percent   string `json:"percent"`
}

type PaymentListOfServiceLimit

type PaymentListOfServiceLimit struct {
	MinAmount string `json:"min_amount"`
	MaxAmount string `json:"max_amount"`
}

type PaymentListOfServicesData

type PaymentListOfServicesData struct {
	Network     string                         `json:"network"`
	Currency    string                         `json:"currency"`
	IsAvailable bool                           `json:"is_available"`
	Limit       PaymentListOfServiceLimit      `json:"limit"`
	Commission  PaymentListOfServiceCommission `json:"commission"`
}

type PaymentListOfServicesResponse

type PaymentListOfServicesResponse struct {
	*HTTPResponse
	Result []PaymentListOfServicesData `json:"result"`
}

type PaymentStatus

type PaymentStatus string
const (
	PaymentStatusProcess            PaymentStatus = "process"              // Payment in processing.
	PaymentStatusCheck              PaymentStatus = "check"                // Waiting for the transaction to appear on the blockchain.
	PaymentStatusConfirmCheck       PaymentStatus = "confirm_check"        // We have seen the transaction in the blockchain and are waiting for the required number of network confirmations.
	PaymentStatusWrongAmountWaiting PaymentStatus = "wrong_amount_waiting" // The client paid less than required, with the possibility of an additional payment.
	PaymentStatusPaid               PaymentStatus = "paid"                 // The payment was successful and the client paid exactly as much as required.
	PaymentStatusPaidOver           PaymentStatus = "paid_over"            // The payment was successful and client paid more than required.
	PaymentStatusFail               PaymentStatus = "fail"                 // Payment error.
	PaymentStatusWrongAmount        PaymentStatus = "wrong_amount"         // The client paid less than required.
	PaymentStatusCancel             PaymentStatus = "cancel"               // Payment cancelled, the client did not pay.
	PaymentStatusSystemFail         PaymentStatus = "system_fail"          // A system error has occurred.
	PaymentStatusRefundProcess      PaymentStatus = "refund_process"       // The refund is being processed.
	PaymentStatusRefundFail         PaymentStatus = "refund_fail"          // An error occurred during the refund.
	PaymentStatusRefundPaid         PaymentStatus = "refund_paid"          // The refund was successful.
	PaymentStatusLocked             PaymentStatus = "locked"               // Funds are locked due to the AML program.
)

type PayoutData

type PayoutData struct {
	UUID          string       `json:"uuid"`
	Amount        string       `json:"amount"`
	Currency      string       `json:"currency"`
	Network       string       `json:"network"`
	Address       string       `json:"address"`
	TxID          string       `json:"txid"`
	Status        PayoutStatus `json:"status"`
	IsFinal       bool         `json:"is_final"`
	Balance       int64        `json:"balance"`
	PayerCurrency string       `json:"payer_currency"`
	PayerAmount   int64        `json:"payer_amount"`
	CreatedAt     time.Time    `json:"created_at"`
	UpdatedAt     time.Time    `json:"updated_at"`
}

type PayoutHistoryData

type PayoutHistoryData struct {
	MerchantUUID string        `json:"merchant_uuid"`
	Items        []*PayoutData `json:"items"`
	Paginate     *Pagination   `json:"paginate"`
}

type PayoutHistoryRequest

type PayoutHistoryRequest struct {
	DateFrom string `json:"date_from,omitempty"`
	DateTo   string `json:"date_to,omitempty"`
}

type PayoutHistoryResponse

type PayoutHistoryResponse struct {
	*HTTPResponse
	Result *PayoutHistoryData `json:"result"`
}

type PayoutInformationRequest

type PayoutInformationRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
}

type PayoutInformationResponse

type PayoutInformationResponse struct {
	*HTTPResponse
	Result *PayoutData `json:"result"`
}

type PayoutListOfServiceCommission

type PayoutListOfServiceCommission struct {
	FeeAmount string `json:"fee_amount"`
	Percent   string `json:"percent"`
}

type PayoutListOfServiceLimit

type PayoutListOfServiceLimit struct {
	MinAmount string `json:"min_amount"`
	MaxAmount string `json:"max_amount"`
}

type PayoutListOfServicesData

type PayoutListOfServicesData struct {
	Network     string                         `json:"network"`
	Currency    string                         `json:"currency"`
	IsAvailable bool                           `json:"is_available"`
	Limit       PaymentListOfServiceLimit      `json:"limit"`
	Commission  PaymentListOfServiceCommission `json:"commission"`
}

type PayoutListOfServicesResponse

type PayoutListOfServicesResponse struct {
	*HTTPResponse
	Result []*PayoutListOfServicesData `json:"result"`
}

type PayoutStatus

type PayoutStatus string

The payout status comes in the body of the response of some methods and indicates at what stage the payout is at the moment

Details: https://doc.cryptomus.com/business/payouts/payout-statuses

const (
	PayoutStatusProcess    PayoutStatus = "process"     // Payout is in process
	PayoutStatusCheck      PayoutStatus = "check"       // The payout is being verified
	PayoutStatusPaid       PayoutStatus = "paid"        // The payout was successful
	PayoutStatusFail       PayoutStatus = "fail"        // Payout failed
	PayoutStatusCancel     PayoutStatus = "cancel"      // Payout cancelled
	PayoutStatusSystemFail PayoutStatus = "system_fail" // A system error has occurred
)

type RecurringPaymentData

type RecurringPaymentData struct {
	UUID           string     `json:"uuid"`
	Name           string     `json:"name"`
	OrderID        string     `json:"order_id,omitempty"`
	Amount         string     `json:"amount"`
	Currency       string     `json:"currency"`
	PayerCurrency  string     `json:"payer_currency,omitempty"`
	PayerAmountUSD string     `json:"payer_amount_usd"`
	PayerAmount    string     `json:"payer_amount,omitempty"`
	URLCallback    string     `json:"url_callback,omitempty"`
	Period         string     `json:"period"`
	Status         string     `json:"status"`
	URL            string     `json:"url"`
	LastPayOff     *time.Time `json:"last_pay_off,omitempty"`
}

type RecurringPaymentInformationRequest

type RecurringPaymentInformationRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
}

type RecurringPaymentInformationResponse

type RecurringPaymentInformationResponse struct {
	*HTTPResponse
	Result RecurringPaymentData `json:"result,omitempty"`
}

type RecurringPaymentPeriod

type RecurringPaymentPeriod string
const (
	RecurringPaymentPeriodWeekly     RecurringPaymentPeriod = "weekly"
	RecurringPaymentPeriodMonthly    RecurringPaymentPeriod = "monthly"
	RecurringPaymentPeriodThreeMonth RecurringPaymentPeriod = "three_month"
)

type RefundData

type RefundData struct{}

type RefundPaymentOnBlockedAddressData

type RefundPaymentOnBlockedAddressData struct {
	Commission string `json:"commission"`
	Amount     string `json:"amount"`
}

type RefundPaymentOnBlockedAddressRequest

type RefundPaymentOnBlockedAddressRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
	Address string `json:"address"`
}

type RefundPaymentOnBlockedAddressResponse

type RefundPaymentOnBlockedAddressResponse struct {
	*HTTPResponse
	Result RefundPaymentOnBlockedAddressData `json:"result"`
}

type RefundRequest

type RefundRequest struct {
	Address    string `json:"address"`
	IsSubtract bool   `json:"is_subtract"`
	UUID       string `json:"uuid,omitempty"`
	OrderID    string `json:"order_id,omitempty"`
}

type RefundResponse

type RefundResponse struct {
	*HTTPResponse
	Result []RefundData `json:"result"`
}

type ResendWebhookData

type ResendWebhookData struct{}

type ResendWebhookRequest

type ResendWebhookRequest struct {
	UUID    string `json:"uuid,omitempty"`
	OrderID string `json:"order_id,omitempty"`
}

type ResendWebhookResponse

type ResendWebhookResponse struct {
	*HTTPResponse
	Result []ResendWebhookData `json:"result"`
}

type SetDiscountToPaymentMethodRequest

type SetDiscountToPaymentMethodRequest struct {
	// Currency code (e.g. BTC, ETH, USDT, etc.)
	Currency string `json:"currency"`
	// Blockchain network (e.g. ARBITRUM, AVALANCHE, BCH, etc.)
	Network string `json:"network"`
	// Discount percent (e.g. 5, 10, -15, etc.)
	Discount int `json:"discount_percent"`
}

type SetDiscountToPaymentMethodResponse

type SetDiscountToPaymentMethodResponse struct {
	*HTTPResponse
	Result Discount `json:"result,omitempty"`
}

type TestingWebhookPaymentData

type TestingWebhookPaymentData struct{}

type TestingWebhookPaymentRequest

type TestingWebhookPaymentRequest struct {
	URLCallback string        `json:"url_callback"`
	Currency    string        `json:"currency"`
	Network     string        `json:"network"`
	UUID        string        `json:"uuid,omitempty"`
	OrderID     string        `json:"order_id,omitempty"`
	Status      PaymentStatus `json:"status"`
}

type TestingWebhookPaymentResponse

type TestingWebhookPaymentResponse struct {
	*HTTPResponse
	Result []TestingWebhookPaymentData `json:"result"`
}

type TestingWebhookPayoutData

type TestingWebhookPayoutData struct{}

type TestingWebhookPayoutRequest

type TestingWebhookPayoutRequest struct {
	URLCallback string       `json:"url_callback"`
	Currency    string       `json:"currency"`
	Network     string       `json:"network"`
	UUID        string       `json:"uuid,omitempty"`
	OrderID     string       `json:"order_id,omitempty"`
	Status      PayoutStatus `json:"status"`
}

type TestingWebhookPayoutResponse

type TestingWebhookPayoutResponse struct {
	*HTTPResponse
	Result []TestingWebhookPayoutData `json:"result"`
}

type TestingWebhookWalletData

type TestingWebhookWalletData struct{}

type TestingWebhookWalletRequest

type TestingWebhookWalletRequest struct {
	URLCallback string        `json:"url_callback"`
	Currency    string        `json:"currency"`
	Network     string        `json:"network"`
	UUID        string        `json:"uuid,omitempty"`
	OrderID     string        `json:"order_id,omitempty"`
	Status      PaymentStatus `json:"status"`
}

type TestingWebhookWalletResponse

type TestingWebhookWalletResponse struct {
	*HTTPResponse
	Result []TestingWebhookWalletData `json:"result"`
}

type TransferToBusinessWalletData

type TransferToBusinessWalletData struct {
	UserWalletTransactionUUID string `json:"user_wallet_transaction_uuid"`
	UserWalletBalance         string `json:"user_wallet_balance"`
	MerchantTransactionUUID   string `json:"merchant_transaction_uuid"`
	MerchantBalance           string `json:"merchant_balance"`
}

type TransferToBusinessWalletRequest

type TransferToBusinessWalletRequest struct {
	Amount   string `json:"amount" validate:"required"`
	Currency string `json:"currency" validate:"required"`
}

type TransferToBusinessWalletResponse

type TransferToBusinessWalletResponse struct {
	*HTTPResponse
	Result *TransferToBusinessWalletData `json:"result"`
}

type TransferToPersonalWalletData

type TransferToPersonalWalletData struct {
	UserWalletTransactionUUID string `json:"user_wallet_transaction_uuid"`
	UserWalletBalance         string `json:"user_wallet_balance"`
	MerchantTransactionUUID   string `json:"merchant_transaction_uuid"`
	MerchantBalance           string `json:"merchant_balance"`
}

type TransferToPersonalWalletRequest

type TransferToPersonalWalletRequest struct {
	Amount   string `json:"amount" validate:"required"`
	Currency string `json:"currency" validate:"required"`
}

type TransferToPersonalWalletResponse

type TransferToPersonalWalletResponse struct {
	*HTTPResponse
	Result *TransferToPersonalWalletData `json:"result"`
}

type User

type User struct {
	// Wallet UUID
	UUID string `json:"uuid"`
	// Personal wallet balance
	Balance string `json:"balance"`
	// Wallet Currency code (e.g. BTC, ETH, USDT, etc.)
	CurrencyCode string `json:"currency_code"`
}

User represents a personal account.

Jump to

Keyboard shortcuts

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