Documentation ¶
Index ¶
- type Amount
- type AmountFromResponse
- type Card
- type Confirmation
- type ConfirmationFromResponse
- type ConfirmationType
- type FromResponse
- type Items
- type Kassa
- type List
- type Metadata
- type Method
- type MethodData
- type Payment
- func (p *Payment) Do() (*YooKassaResponse, error)
- func (p *Payment) SetAmount(value decimal.Decimal, moneyType string) *Payment
- func (p *Payment) SetCapture(cap bool) *Payment
- func (p *Payment) SetConfirmation(conf Confirmation) *Payment
- func (p *Payment) SetDescription(desc string) *Payment
- func (p *Payment) SetIdempotenceKey(key string) *Payment
- func (p *Payment) SetKassa(kassa *Kassa) *Payment
- func (p *Payment) SetPaymentMethodDataType(t string) *Payment
- func (p *Payment) SetPaymentMethodID(id string) *Payment
- func (p *Payment) SetSavePaymentMethod(save bool) *Payment
- type Recipient
- type YooKassaErrorResponse
- type YooKassaResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amount ¶
type Amount struct { // Value is how much money you want to get from someone Value decimal.Decimal `json:"value"` // Currency is three letter currency code (ex: RUB) Currency string `json:"currency,omitempty"` }
Amount (payment amount)
Sometimes YooMoney's partners charge additional commission from the users that is not included in this amount.
type AmountFromResponse ¶
type Confirmation ¶
type Confirmation struct { // Type Confirmation scenario code Type string `json:"type"` // Enforce a request for making a payment with authentication by 3-D Secure. // // It works if you accept bank card payments without user confirmation by default. // In other cases, the 3-D Secure authentication will be handled by YooMoney. // If you would like to accept payments without additional confirmation by the user, contact your YooMoney manager. // // Works only with ConfirmationType == Redirect Enforce bool `json:"enforce"` // ReturnURL is the URL that the user will return to after confirming or canceling the payment on the webpage ReturnURL string `json:"return_url"` }
Confirmation information required to initiate the selected payment confirmation scenario by the user.
More about confirmation scenarios: https://yookassa.ru/en/developers/payments/payment-process#user-confirmation
type ConfirmationType ¶
type ConfirmationType int
ConfirmationType is one of the Confirmation scenarios
More about confirmation scenarios: https://yookassa.ru/en/developers/payments/payment-process#confirmation-scenarios
const ( // Embedded confirmation scenario: actions required for payment confirmation will depend on the payment method // selected by the user in the YooMoney Checkout Widget. // YooMoney will receive the confirmation from the user: all you need to do is embed the widget to your page. Embedded ConfirmationType = iota // External confirmation scenario: // to continue, the user takes action in an external system (for example, responds to a text message). // All you need to do is let them know how to proceed. External // The MobileApplication confirmation scenario: to confirm a payment, the user needs to complete an action // in a mobile app (for example, in an online banking app). // You need to redirect the user to the ConfirmationURL (ConfirmationFromResponse) received in the payment. // After the payment is made successfully (or if something goes wrong), YooMoney will redirect the user back // to the return_url that you send in your request for creating the payment. // This payment confirmation scenario only works on mobile devices (via mobile app or mobile web version). MobileApplication // QR confirmation scenario: to confirm the payment, the user scans a QR code. // You will need to generate the QR code using any available tools and display it on the payment page. QR // Redirect confirmation scenario: the user takes action on the YooMoney’s page or its partner’s page // (for example, enters bank card details or completes identification process via 3-D Secure). // You must redirect the user to ConfirmationURL (ConfirmationFromResponse) received in the payment. // If the payment is successful (or if something goes wrong), // YooMoney will return the user to return_url that you’ll send in the payment creation request. Redirect )
func (ConfirmationType) String ¶
func (c ConfirmationType) String() string
type FromResponse ¶
type FromResponse struct { ID string `json:"id"` Status string `json:"status"` Paid bool `json:"paid"` Amount struct { Value string `json:"value"` Currency string `json:"currency"` } `json:"amount"` CreatedAt time.Time `json:"created_at"` Description string `json:"description"` ExpiresAt time.Time `json:"expires_at"` Metadata struct { } `json:"metadata"` PaymentMethod struct { Type string `json:"type"` ID string `json:"id"` Saved bool `json:"saved"` Card struct { First6 string `json:"first6"` Last4 string `json:"last4"` ExpiryMonth string `json:"expiry_month"` ExpiryYear string `json:"expiry_year"` CardType string `json:"card_type"` IssuerCountry string `json:"issuer_country"` IssuerName string `json:"issuer_name"` } `json:"card"` Title string `json:"title"` } `json:"payment_method"` Recipient struct { AccountID string `json:"account_id"` GatewayID string `json:"gateway_id"` } `json:"recipient"` Refundable bool `json:"refundable"` Test bool `json:"test"` }
type Items ¶
type Items struct { ID string `json:"id"` Status string `json:"status"` Paid bool `json:"paid"` Amount Amount `json:"amount"` CreatedAt time.Time `json:"created_at"` Description string `json:"description"` ExpiresAt time.Time `json:"expires_at"` Metadata Metadata `json:"metadata"` PaymentMethod Method `json:"payment_method"` Recipient Recipient `json:"recipient"` Refundable bool `json:"refundable"` Test bool `json:"test"` }
type Kassa ¶
type Kassa struct { // ShopID is your, well, shop id ShopID string // SecretKey It is required for sending requests to API, // and it allows making any transaction in YooMoney using your name. // // Keep your key in a safe place: if you lose it, it will need to be reissued. SecretKey string }
Kassa struct is used to provide basic auth for YooKassa's endpoint
func NewKassa ¶
func NewKassa() *Kassa
NewKassa creates and initializes a new Kassa (YooKassa shop id and shop secret key)
func (*Kassa) GetPayment ¶
func (c *Kassa) GetPayment(id string) *FromResponse
func (*Kassa) ListPayments ¶
func (*Kassa) SetSecretKey ¶
SetSecretKey sets Kassa's secret key
You can find it under API keys section: https://yookassa.ru/my/merchant/integration/api-keys
type MethodData ¶
type MethodData struct {
Type string `json:"type"`
}
type Payment ¶
type Payment struct { *Kassa `json:"-"` // IdempotenceKey in the context of API, idempotence is the concept of multiple requests having the same effect // as a single request. // // Upon receiving a new request with identical parameters, // YooMoney will respond with results of the original request. // // Such behavior helps prevent unwanted repetition of transactions: // for example, if during the payment process the Internet connection was interrupted due to network problems, // you’ll be able to safely repeat the request for an unlimited number of times. IdempotenceKey string `json:"-"` Amount Amount `json:"amount"` // Capture that was set to true means you will receive the money immediately after the payment. // If the value is false, the required amount will be held on the user’s account, // and you’ll be able to capture it whenever convenient for you // // See more at: https://yookassa.ru/en/developers/payments/payment-process#capture-and-cancel Capture bool `json:"capture,omitempty"` // Confirmation information required to initiate the selected payment confirmation scenario by the user. // // More about confirmation scenarios: https://yookassa.ru/en/developers/payments/payment-process#user-confirmation Confirmation *Confirmation `json:"confirmation,omitempty"` // PaymentMethodData is used in recurrent payments // // More info: https://yookassa.ru/en/developers/payments/recurring-payments#save PaymentMethodData *MethodData `json:"payment_method_data,omitempty"` // Description is used if you want to add a payment description that’ll be displayed in the Merchant Profile to you, // and during the payment to the user // // Also description must not exceed 128 characters Description string `json:"description,omitempty"` // SavePaymentMethod is used for recurrent payments // // Learn more at: https://yookassa.ru/en/developers/payments/recurring-payments SavePaymentMethod bool `json:"save_payment_method,omitempty"` // PaymentMethodID is used for recurrent payments // // Recurring payments are only enabled by default in the demo store. // If you want to enable them in your real store, contact the YooMoney manager. // // Learn more at: https://yookassa.ru/en/developers/payments/recurring-payments?lang=bash#pay-with-saved PaymentMethodID string `json:"payment_method_id,omitempty"` }
func NewPayment ¶
func NewPayment() *Payment
NewPayment creates and initializes a new Payment
Learn more: https://yookassa.ru/en/developers/api#create_payment
func (*Payment) Do ¶
func (p *Payment) Do() (*YooKassaResponse, error)
Do sends an HTTP request to YooKassa payment endpoint
func (*Payment) SetAmount ¶
SetAmount sets payment's amount of money and money's type
Example: payment.NewPayment().SetAmount(decimal.NewFromInt(500), "RUB")
func (*Payment) SetCapture ¶
SetCapture sets payment's capture bool value
func (*Payment) SetConfirmation ¶
func (p *Payment) SetConfirmation(conf Confirmation) *Payment
SetConfirmation sets payment's confirmation info
func (*Payment) SetDescription ¶
SetDescription sets payment's description (128 character max)
func (*Payment) SetIdempotenceKey ¶
SetIdempotenceKey sets payment's idempotence key
func (*Payment) SetPaymentMethodDataType ¶
SetPaymentMethodDataType sets payment method. Like bank card
More info: https://yookassa.ru/en/developers/payments/recurring-payments#save
func (*Payment) SetPaymentMethodID ¶
SetPaymentMethodID sets payment method ID. You can obtain ID from payment where you saved payment method (SetSavePaymentMethod)
func (*Payment) SetSavePaymentMethod ¶
SetSavePaymentMethod saves the payment method, used in recurrent payments
type Recipient ¶
Recipient Payment.
Required for separating payment flows within one account or making payments to other accounts.
type YooKassaErrorResponse ¶
type YooKassaErrorResponse struct { Type string `json:"type"` ID string `json:"id"` Code string `json:"code"` Description string `json:"description"` Parameter string `json:"parameter"` }
YooKassaErrorResponse is used for handling error responses from YooKassa's endpoint
func (*YooKassaErrorResponse) Error ¶
func (y *YooKassaErrorResponse) Error() string
type YooKassaResponse ¶
type YooKassaResponse struct { ID string `json:"id"` Status string `json:"status"` Paid bool `json:"paid"` Amount AmountFromResponse `json:"amount"` Confirmation ConfirmationFromResponse `json:"confirmation"` CreatedAt time.Time `json:"created_at"` Description string `json:"description"` Recipient Recipient `json:"recipient"` Refundable bool `json:"refundable"` Test bool `json:"test"` }
YooKassaResponse is default YooKassa endpoint response to payment creation request