conekta

package module
Version: v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 8 Imported by: 0

README

banner

Conekta GO

Requeriments

conekta-go is tested against against all officially supported releases (Go 1.12 and 1.13).

Installation

You can import conekta-go directly from github as follows:

import (
  conekta "github.com/conekta/conekta-go"
  "github.com/conekta/conekta-go/order"
  "github.com/conekta/conekta-go/customer"
  "time"
)

Usage

conekta.APIKey = "key_ZLy4aP2szht1HqzkCezDEA"

customerParams := &conekta.CustomerParams{
	Name:  "Cándida Eréndira",
	Email: "la.candida.erendira@gmail.com",
	Phone: "55-5555-5555",
}

lineItemParams := &conekta.LineItemsParams{
	Name:      "Naranjas Robadas",
	UnitPrice: 10000,
	Quantity:  2,
}

chargeParams := &conekta.ChargeParams{
	PaymentMethodParams: &conekta.PaymentMethodParams{
		Type:      "oxxo_cash",
		ExpiresAt: time.Now().AddDate(0, 0, 90).Unix(),
	},
}

orderParams := &conekta.OrderParams{}
orderParams.Currency = "MXN"
orderParams.CustomerInfo = customerParams
orderParams.LineItems = append(orderParams.LineItems, lineItemParams)
orderParams.Charges = append(orderParams.Charges, chargeParams)

ord, err := order.Create(orderParams)
if err != nil {
	code := err.(conekta.Error).Details[0].Code
	//do something
	fmt.Println(code)
} else {
	orderId := ord.ID
	chargeId := ord.Charges.Data[0].ID
	oxxoReference := ord.Charges.Data[0].PaymentMethod.Reference
	//do something
	fmt.Println(orderId)
	fmt.Println(chargeId)
	fmt.Println(oxxoReference)
}

Run Tests

go test -v ./...

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

  1. Fork the repository
  2. Clone the repository
    git clone git@github.com:yourUserName/conekta-go.git
  1. Create a branch
    git checkout develop
    git pull origin develop
    # You should choose the name of your branch
    git checkout -b <feature/my_branch>
  1. Make necessary changes and commit those changes
    git add .
    git commit -m "my changes"
  1. Push changes to GitHub
    git push origin <feature/my_branch>
  1. Submit your changes for review, create a pull request

    To create a pull request, you need to have made your code changes on a separate branch. This branch should be named like this: feature/my_feature or fix/my_fix.

    Make sure that, if you add new features to our library, be sure to add the corresponding unit tests.

    If you go to your repository on GitHub, you’ll see a Compare & pull request button. Click on that button.


License

Developed in Mexico by Conekta. Available with MIT License.

We are always hiring!

If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills. Send us your CV and GitHub to quieroser@conekta.com

Documentation

Index

Constants

View Source
const (
	// OrderRefundRequestedByClient is a reason for refund
	OrderRefundRequestedByClient = "requested_by_client"
	// OrderRefundCannotBeFulfilled is a reason for refund
	OrderRefundCannotBeFulfilled = "cannot_be_fulfilled"
	// OrderRefundDuplicatedTransaction is a reason for refund
	OrderRefundDuplicatedTransaction = "duplicated_transaction"
	// OrderRefundSuspectedFraud is a reason for refund
	OrderRefundSuspectedFraud = "suspected_fraud"
	// OrderRefundOther is a reason for refund
	OrderRefundOther = "other"
)
View Source
const TestKey = "key_ZLy4aP2szht1HqzkCezDEA"

TestKey is Conekta test key

View Source
const TestPublic = "key_OfWoJc2fw6oEydKspmyr76Q"

TestPublic is Conekta test public key

Variables

View Source
var APIKey string

APIKey is Conekta private_key For details see https://developers.conekta.com/api#authentication

View Source
var Locale string

Locale is a settings for localization language

View Source
var PubliAPIKey string

PubliAPIKey is Conekta private_key For details see https://developers.conekta.com/api#authentication

Functions

func BuildURL

func BuildURL(url string) string

BuildURL returns base api plus endpoint passed

func MakeRequest

func MakeRequest(method string, endpoint string, p ParamsConverter, v interface{}, customHeaders ...interface{}) error

MakeRequest creates a new Conekta request, it takes a method, endpoint, parameters and a reference struct of conekta's models like &conekta.Customer{} and fills it with the response if the response has a Conekta's error it returns it and keep empty the Conekta model

func RequestAPI

func RequestAPI(method string, url string, params ParamsConverter, customHeaders ...interface{}) ([]byte, error)

RequestAPI returns Conekta API response

Types

type Address

type Address struct {
	Street1     string `json:"street1,omitempty"`
	Street2     string `json:"street2,omitempty"`
	City        string `json:"city,omitempty"`
	State       string `json:"state,omitempty"`
	Country     string `json:"country,omitempty"`
	PostalCode  string `json:"postal_code,omitempty"`
	Object      string `json:"object,omitempty"`
	Residential bool   `json:"residential,omitempty"`
}

Address represents a Conekta common Adress

func (*Address) Mock

func (p *Address) Mock() *Address

Mock fills Address with dummy data

type CardParams

type CardParams struct {
	Number       string              `json:"number,omitempty"`
	Name         string              `json:"name,omitempty"`
	ExpYear      string              `json:"exp_year,omitempty"`
	ExpMonth     string              `json:"exp_month,omitempty"`
	Cvc          string              `json:"cvc,omitempty"`
	TokenAddress *TokenAddressParams `json:"address,omitempty"`
}

CardParams should be a struct of tokenization response

func (*CardParams) Mock

func (p *CardParams) Mock() *CardParams

Mock fills TokenParams with dummy data

type Charge

type Charge struct {
	ID                  string         `json:"id,omitempty"`
	Object              string         `json:"object,omitempty"`
	Status              string         `json:"status,omitempty"`
	Amount              int64          `json:"amount,omitempty"`
	Fee                 int64          `json:"fee,omitempty"`
	OrderID             string         `json:"order_id,omitempty"`
	CustomerID          string         `json:"customer_id,omitempty"`
	Livemode            bool           `json:"livemode,omitempty"`
	MonthlyInstallments int64          `json:"monthly_installments,omitempty"`
	CreatedAt           int64          `json:"created_at,omitempty"`
	PaidAt              int64          `json:"paid_at,omitempty"`
	Currency            string         `json:"currency,omitempty"`
	Description         string         `json:"description,omitempty"`
	PaymentMethod       *PaymentMethod `json:"payment_method,omitempty"`
}

Charge should be a struct of the api response

type ChargeParams

type ChargeParams struct {
	PaymentMethod *PaymentMethodParams `json:"payment_method,omitempty"`
}

ChargeParams is the object to fill after api call

func (*ChargeParams) Bytes

func (c *ChargeParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*ChargeParams) Mock

func (p *ChargeParams) Mock() *ChargeParams

Mock fills ChargeParams with dummy data

func (*ChargeParams) OxxoMock

func (p *ChargeParams) OxxoMock() *ChargeParams

OxxoMock fills ChargeParams with dummy data

type ChargesList

type ChargesList struct {
	ListMeta
	Data []*Charge `json:"data,omitempty"`
}

ChargesList is a list of shippingLines

type Customer

type Customer struct {
	ID                       string              `json:"id,omitempty"`
	Object                   string              `json:"object,omitempty"`
	Live                     bool                `json:"livemode,omitempty"`
	CreatedAt                int64               `json:"created_at,omitempty"`
	Name                     string              `json:"name,omitempty"`
	Email                    string              `json:"email,omitempty"`
	Phone                    string              `json:"phone,omitempty"`
	Corporate                bool                `json:"corporate,omitempty"`
	DefaultShippingContactID string              `json:"default_shipping_contact_id,omitempty"`
	DefaultPaymentSourceID   string              `json:"default_payment_source_id,omitempty"`
	PaymentSources           PaymentSourceList   `json:"payment_sources,omitempty"`
	ShippingContacts         ShippingContactList `json:"shipping_contacts,omitempty"`
	Subscription             *Subscription       `json:"subscription,omitempty"`
	Deleted                  bool                `json:"deleted,omitempty"`
}

Customer represents a Conekta customer. For details see https://developers.conekta.com/api#customer.

type CustomerInfo

type CustomerInfo struct {
	CustomerID string `json:"customer_id,omitempty"`
	*Customer
}

CustomerInfo describes customer info

type CustomerList

type CustomerList struct {
	ListMeta
	Data []*Customer `json:"data,omitempty"`
}

CustomerList is a list of customers

type CustomerParams

type CustomerParams struct {
	ID                     string                       `json:"customer_id,omitempty"`
	Name                   string                       `json:"name,omitempty"`
	Phone                  string                       `json:"phone,omitempty"`
	Email                  string                       `json:"email,omitempty"`
	PaymentSources         []*PaymentSourceCreateParams `json:"payment_sources,omitempty"`
	Corporate              bool                         `json:"corporate,omitempty"`
	DefaultPaymentSourceID string                       `json:"default_payment_source_id,omitempty"`
	ShippingContacts       []*ShippingContactParams     `json:"shipping_contacts,omitempty"`
}

CustomerParams is the set of parameters that can be used when creating or updating a customer. For details see https://developers.conekta.com/api#create-customer and https://developers.conekta.com/api#update-customer.

func (*CustomerParams) Bytes

func (p *CustomerParams) Bytes() []byte

Bytes converts a CustomerParams to []byte

func (*CustomerParams) Mock

func (p *CustomerParams) Mock() *CustomerParams

Mock fills CustomerParams with dummy data

func (*CustomerParams) MockCustomerPaymentSource

func (p *CustomerParams) MockCustomerPaymentSource() *CustomerParams

func (*CustomerParams) MockMinimal

func (p *CustomerParams) MockMinimal() *CustomerParams

MockMinimal fills CustomerParams with dummy data

type DefaultAddress

type DefaultAddress struct {
	Street1    string `json:"street1,omitempty"`
	Street2    string `json:"street2,omitempty"`
	City       string `json:"city,omitempty"`
	State      string `json:"state,omitempty"`
	Country    string `json:"country,omitempty"`
	Object     string `json:"object,omitempty"`
	PostalCode string `json:"postal_code,omitempty"`
}

DefaultAddress should be nested struct of PaymentMethod

type Destination

type Destination struct {
	ID                string `json:"id,omitempty"`
	PayeeID           string `json:"payee_id,omitempty"`
	Object            string `json:"object,omitempty"`
	CreatedAt         int64  `json:"created_at,omitempty"`
	Type              string `json:"type,omitempty"`
	Currency          string `json:"currency,omitempty"`
	Last4             string `json:"last4,omitempty"`
	AccountHolderName string `json:"account_holder_name,omitempty"`
	Bank              string `json:"bank,omitempty"`
}

Destination describes destination payee object response

type DestinationParams

type DestinationParams struct {
	Type              string `json:"type,omitempty"`
	AccountNumber     string `json:"account_number,omitempty"`
	AccountHolderName string `json:"account_holder_name,omitempty"`
}

DestinationParams describes params for destination payee object request

func (*DestinationParams) Bytes

func (p *DestinationParams) Bytes() []byte

Bytes converts a DestinationParams to []byte

func (*DestinationParams) Mock

Mock fills DestinationParams

type DiscountLines

type DiscountLines struct {
	Code     string `json:"code,omitempty"`
	Amount   int64  `json:"amount,omitempty"`
	Type     string `json:"type,omitempty"`
	Object   string `json:"object,omitempty"`
	ID       string `json:"id,omitempty"`
	ParentID string `json:"parent_id,omitempty"`
	Deleted  bool   `json:"deleted,omitempty"`
}

DiscountLines should be nested struct of order

type DiscountLinesList

type DiscountLinesList struct {
	ListMeta
	Data []*DiscountLines `json:"data,omitempty"`
}

DiscountLinesList is a list of DiscountLines

type DiscountLinesParams

type DiscountLinesParams struct {
	Code   string `json:"code,omitempty"`
	Amount int64  `json:"amount,omitempty"`
	Type   string `json:"type,omitempty"`
}

DiscountLinesParams is the object to fill after api call

func (*DiscountLinesParams) Bytes

func (c *DiscountLinesParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*DiscountLinesParams) Mock

Mock fills Address with dummy data

type EmptyParams

type EmptyParams struct{}

EmptyParams is used in requests that don't need params

func (*EmptyParams) Bytes

func (p *EmptyParams) Bytes() []byte

Bytes converts a EmptyParams to []byte

type Error

type Error struct {
	ErrorType string          `json:"type,omitempty"`
	LogID     string          `json:"log_id,omitempty"`
	Details   []ErrorDetails  `json:"details,omitempty"`
	Data      json.RawMessage `json:"data,omitempty"`
}

Error describes Conekta errors

func (Error) Error

func (e Error) Error() string

type ErrorDetails

type ErrorDetails struct {
	DebugMessage       string `json:"debug_message,omitempty"`
	MessageToPurchaser string `json:"message_to_purchaser,omitempty"`
	Message            string `json:"message,omitempty"`
	Param              string `json:"param,omitempty"`
	Code               string `json:"code,omitempty"`
}

ErrorDetails gives especific information about an error

type LineItems

type LineItems struct {
	ID        string `json:"id,omitempty"`
	Object    string `json:"object,omitempty"`
	Name      string `json:"name,omitempty"`
	UnitPrice int64  `json:"unit_price,omitempty"`
	Quantity  int    `json:"quantity,omitempty"`
	Deleted   bool   `json:"deleted,omitempty"`
}

LineItems should be nested struct of order

type LineItemsList

type LineItemsList struct {
	ListMeta
	Data []*LineItems `json:"data,omitempty"`
}

LineItemsList is a list of shippingLines

type LineItemsParams

type LineItemsParams struct {
	Name      string   `json:"name,omitempty"`
	UnitPrice int64    `json:"unit_price,omitempty"`
	Quantity  int      `json:"quantity,omitempty"`
	Metadata  struct{} `json:"metadata,omitempty"`
}

LineItemsParams should be response wrapper for api line_items endpoint

func (*LineItemsParams) Bytes

func (c *LineItemsParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*LineItemsParams) Mock

func (li *LineItemsParams) Mock() *LineItemsParams

Mock fills LineItemsParams with dummy data

type ListMeta

type ListMeta struct {
	Object      string `json:"object,omitempty"`
	HasMore     bool   `json:"has_more,omitempty"`
	NextPageURL string `json:"next_page_url,omitempty"`
}

ListMeta describes common metadata for lists

type Order

type Order struct {
	ID              string             `json:"id,omitempty"`
	Object          string             `json:"object,omitempty"`
	Livemode        bool               `json:"livemode,omitempty"`
	Amount          int64              `json:"amount,omitempty"`
	AmountRefunded  int64              `json:"amount_refunded,omitempty"`
	PaymentStatus   string             `json:"payment_status,omitempty"`
	Currency        string             `json:"currency,omitempty"`
	CreatedAt       int64              `json:"created_at,omitempty"`
	UpdatedAt       int64              `json:"updated_at,omitempty"`
	PreAuth         bool               `json:"pre_authorize,omitempty"`
	Metadata        struct{}           `json:"metadata,omitempty"`
	CustomerInfo    *CustomerInfo      `json:"customer_info,omitempty"`
	ShippingContact *ShippingContact   `json:"shipping_contact,omitempty"`
	LineItems       *LineItemsList     `json:"line_items,omitempty"`
	TaxLines        *TaxLinesList      `json:"tax_lines,omitempty"`
	ShippingLines   *ShippingLinesList `json:"shipping_lines,omitempty"`
	DiscountLines   *DiscountLinesList `json:"discount_lines,omitempty"`
	Charges         *ChargesList       `json:"charges,omitempty"`
}

Order should be a struct of the api response

type OrderList

type OrderList struct {
	ListMeta
	Data []*Order `json:"data,omitempty"`
}

OrderList is a list of shippingLines

type OrderParams

type OrderParams struct {
	Currency        string                 `json:"currency,omitempty"`
	PreAuth         bool                   `json:"pre_authorize,omitempty"`
	CustomerInfo    *CustomerParams        `json:"customer_info,omitempty"`
	LineItems       []*LineItemsParams     `json:"line_items,omitempty"`
	TaxLines        []*TaxLinesParams      `json:"tax_lines,omitempty"`
	ShippingContact *ShippingContactParams `json:"shipping_contact,omitempty"`
	DiscountLines   []*DiscountLinesParams `json:"discount_lines,omitempty"`
	ShippingLines   []*ShippingLinesParams `json:"shipping_lines,omitempty"`
	Metadata        struct{}               `json:"metadata,omitempty"`
	Charges         []*ChargeParams        `json:"charges,omitempty"`
}

OrderParams returns api response object filled

func (*OrderParams) Bytes

func (c *OrderParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*OrderParams) Mock

func (p *OrderParams) Mock() *OrderParams

Mock fills OrderParams with dummy data

func (*OrderParams) MockWithoutCharges

func (p *OrderParams) MockWithoutCharges() *OrderParams

MockWithoutCharges fills OrderParams with dummy data

func (*OrderParams) MockWithoutDiscountLines

func (p *OrderParams) MockWithoutDiscountLines() *OrderParams

MockWithoutDiscountLines fills OrderParams with dummy data

func (*OrderParams) OxxoMock

func (p *OrderParams) OxxoMock() *OrderParams

OxxoMock fills OrderParams with dummy data

type OrderRefundParams

type OrderRefundParams struct {
	Reason string `json:"reason,omitempty"`
	Amount int64  `json:"amount,omitempty"`
}

OrderRefundParams returns api response object filled

func (*OrderRefundParams) Bytes

func (c *OrderRefundParams) Bytes() []byte

Bytes converts a OrderRefundParams to []byte

func (*OrderRefundParams) Mock

Mock fills OrderRefundParams

type ParamsConverter

type ParamsConverter interface {
	Bytes() []byte
}

ParamsConverter is an interface to handle Conekta params conversions in requestor

type Payee

type Payee struct {
	ID                   string                     `json:"id,omitempty"`
	Email                string                     `json:"email,omitempty"`
	Name                 string                     `json:"name,omitempty"`
	Phone                string                     `json:"phone,omitempty"`
	LiveMode             bool                       `json:"livemode,omitempty"`
	BillingAddress       *PayeeBillingAddressParams `json:"billing_address,omitempty"`
	Object               string                     `json:"object,omitempty"`
	DefaultDestinationID string                     `json:"default_destination_id,omitempty"`
	CreatedAt            int64                      `json:"created_at,omitempty"`
	Destinations         []*Destination             `json:"destinations,omitempty"`
	Deleted              bool                       `json:"deleted,omitempty"`
}

Payee describes Payee response object

type PayeeBillingAddressParams

type PayeeBillingAddressParams struct {
	CompanyName string `json:"company_name,omitempty"`
	TaxID       string `json:"tax_id,omitempty"`
	Street1     string `json:"street1,omitempty"`
	Street2     string `json:"street2,omitempty"`
	Street3     string `json:"street3,omitempty"`
	City        string `json:"city,omitempty"`
	State       string `json:"state,omitempty"`
	Country     string `json:"country,omitempty"`
	PostalCode  string `json:"postal_code,omitempty"`
}

PayeeBillingAddressParams describes billing address of Payee object

func (*PayeeBillingAddressParams) Mock

Mock fills PayeeBillingAdressParams

type PayeeList

type PayeeList struct {
	ListMeta
	Data []*Payee `json:"data,omitempty"`
}

PayeeList is a list of payees

type PayeeParams

type PayeeParams struct {
	Name           string                     `json:"name,omitempty"`
	Email          string                     `json:"email,omitempty"`
	Phone          string                     `json:"phone,omitempty"`
	BillingAddress *PayeeBillingAddressParams `json:"billing_address,omitempty"`
}

PayeeParams is the set of parameters of Payee request Object

func (*PayeeParams) Bytes

func (c *PayeeParams) Bytes() []byte

Bytes converts a PayeeParams to []byte

func (*PayeeParams) Mock

func (p *PayeeParams) Mock() *PayeeParams

Mock fills PayeeParams

type PaymentMethod

type PaymentMethod struct {
	ID            string          `json:"id,omitempty"`
	Object        string          `json:"object,omitempty"`
	Type          string          `json:"type,omitempty"`
	CreatedAt     int64           `json:"created_at,omitempty"`
	Last4         string          `json:"last4,omitempty"`
	Bin           string          `json:"bin,omitempty"`
	ExpMonth      string          `json:"exp_month,omitempty"`
	ExpYear       string          `json:"exp_year,omitempty"`
	Brand         string          `json:"brand,omitempty"`
	Name          string          `json:"name,omitempty"`
	ParentID      string          `json:"parent_id,omitempty"`
	Default       bool            `json:"default,omitempty"`
	Reference     string          `json:"reference,omitempty"`
	StoreName     string          `json:"store_name,omitempty"`
	ServiceName   string          `json:"service_name,omitempty"`
	ServiceNumber string          `json:"service_number,omitempty"`
	ExpiresAt     int64           `json:"expires_at,omitempty"`
	Description   string          `json:"description,omitempty"`
	AuthCode      int64           `json:"auth_code,omitempty"`
	Store         string          `json:"store,omitempty"`
	Address       *DefaultAddress `json:"address,omitempty"`
}

PaymentMethod should be a struct of the api response

type PaymentMethodParams

type PaymentMethodParams struct {
	Type                string `json:"type,omitempty"`
	TokenID             string `json:"token_id,omitempty"`
	PaymentSourceID     string `json:"payment_source_id,omitempty"`
	MonthlyInstallments int64  `json:"monthly_installments,omitempty"`
	ExpiresAt           int64  `json:"expires_at,omitempty"`
}

PaymentMethodParams is the object to fill after api call

func (*PaymentMethodParams) Mock

Mock fills PaymentMethodParams with dummy data

func (*PaymentMethodParams) OxxoMock

OxxoMock fills PaymentMethodParams with dummy data

type PaymentSource

type PaymentSource struct {
	ID          string   `json:"id,omitempty"`
	Object      string   `json:"object,omitempty"`
	PaymentType string   `json:"type,omitempty"`
	Last4       string   `json:"last4,omitempty"`
	CreatedAt   int64    `json:"created_at,omitempty"`
	Name        string   `json:"name,omitempty"`
	ExpMonth    string   `json:"exp_month,omitempty"`
	ExpYear     string   `json:"exp_year,omitempty"`
	Brand       string   `json:"brand,omitempty"`
	ParentID    string   `json:"parent_id,omitempty"`
	Address     *Address `json:"address,omitempty"`
	Deleted     bool     `json:"deleted,omitempty"`
	Default     bool     `json:"default,omitempty"`
}

PaymentSource represents a Conekta payment source. For details see https://developers.conekta.com/api#payment-source.

type PaymentSourceCreateParams

type PaymentSourceCreateParams struct {
	TokenID     string `json:"token_id,omitempty"`
	PaymentType string `json:"type,omitempty"`
	ExpiresAt   int64  `json:"expires_at,omitempty"`
	*CardParams
}

PaymentSourceCreateParams is the set of parameters that can be used when creating a payment source. For details see https://developers.conekta.com/api#create-payment-source.

func (*PaymentSourceCreateParams) Bytes

func (p *PaymentSourceCreateParams) Bytes() []byte

Bytes converts a PaymentSourceParams to []byte

func (*PaymentSourceCreateParams) Mock

Mock fills PaymentSourceCreateParams with dummy data

type PaymentSourceList

type PaymentSourceList struct {
	ListMeta
	Data []*PaymentSource `json:"data,omitempty"`
}

PaymentSourceList is a list of payment sources.

type PaymentSourceUpdateParams

type PaymentSourceUpdateParams struct {
	Name     string   `json:"name,omitempty"`
	ExpMonth string   `json:"exp_month,omitempty"`
	ExpYear  string   `json:"exp_year,omitempty"`
	Address  *Address `json:"address,omitempty"`
}

PaymentSourceUpdateParams is the set of parameters that can be used when update a payment source. For details see https://developers.conekta.com/api#update-payment-source.

func (*PaymentSourceUpdateParams) Bytes

func (p *PaymentSourceUpdateParams) Bytes() []byte

Bytes converts a PaymentSourceParams to []byte

type Plan

type Plan struct {
	ID              string `json:"id,omitempty"`
	Livemode        bool   `json:"livemode,omitempty"`
	CreateAt        int64  `json:"create_at,omitempty"`
	Name            string `json:"name,omitempty"`
	Amount          int64  `json:"amount,omitempty"`
	Currency        int64  `json:"currency,omitempty"`
	Interval        string `json:"interval,omitempty"`
	Frequency       int64  `json:"frequency,omitempty"`
	ExpiryCount     int64  `json:"expiry_count,omitempty"`
	TrialPeriodDays int64  `json:"trial_period_days,omitempty"`
	Object          string `json:"object,omitempty"`
}

type PlanList

type PlanList struct {
	ListMeta
	Data []*Plan `json:"data,omitempty"`
}

type PlanParams

type PlanParams struct {
	ID              string `json:"id,omitempty"`
	Name            string `json:"name,omitempty"`
	Currency        string `json:"currency,omitempty"`
	Amount          int64  `json:"amount,omitempty"`
	Interval        string `json:"interval,omitempty"`
	Frequency       int64  `json:"frequency,omitempty"`
	TrialPeriodDays int64  `json:"trial_period_days,omitempty"`
	ExpiryCount     int64  `json:"expiry_count,omitempty"`
}

func (*PlanParams) Bytes

func (c *PlanParams) Bytes() []byte

func (*PlanParams) MockPlan

func (p *PlanParams) MockPlan() *PlanParams

func (*PlanParams) MockPlanCreate

func (p *PlanParams) MockPlanCreate() *PlanParams

Mock fills PlanParams

func (*PlanParams) MockPlanUpdate

func (p *PlanParams) MockPlanUpdate() *PlanParams

Mock fills Update PlanParams

type ShippingContact

type ShippingContact struct {
	ID             string   `json:"id,omitempty"`
	CreatedAt      int64    `json:"created_at,omitempty"`
	Receiver       string   `json:"receiver,omitempty"`
	Phone          string   `json:"phone,omitempty"`
	BetweenStreets string   `json:"between_streets,omitempty"`
	Object         string   `json:"object,omitempty"`
	ParentID       string   `json:"parent_id,omitempty"`
	Address        *Address `json:"address,omitempty"`
	Deleted        bool     `json:"deleted,omitempty"`
	Default        bool     `json:"default,omitempty"`
}

ShippingContact represents a Conekta shipping contact. For details see https://developers.conekta.com/api#shipping-contact.

type ShippingContactList

type ShippingContactList struct {
	ListMeta
	Data []*ShippingContact `json:"data,omitempty"`
}

ShippingContactList is a list of shipping contact.

type ShippingContactParams

type ShippingContactParams struct {
	Phone          string   `json:"phone,omitempty"`
	Receiver       string   `json:"receiver,omitempty"`
	BetweenStreets string   `json:"between_streets,omitempty"`
	Address        *Address `json:"address,omitempty"`
}

ShippingContactParams is the set of parameters that can be used when creating or updating a shipping contact.

func (*ShippingContactParams) Bytes

func (p *ShippingContactParams) Bytes() []byte

Bytes converts a CustomerParams to []byte

func (*ShippingContactParams) Mock

Mock fills ShippingContactParams with dummy data

type ShippingLines

type ShippingLines struct {
	Amount         int64  `json:"amount,omitempty"`
	Carrier        string `json:"carrier,omitempty"`
	Method         string `json:"method,omitempty"`
	TrackingNumber string `json:"tracking_number,omitempty"`
	Object         string `json:"object,omitempty"`
	ID             string `json:"id,omitempty"`
	ParentID       string `json:"parent_id,omitempty"`
	Deleted        bool   `json:"deleted,omitempty"`
}

ShippingLines should be nested struct of order

type ShippingLinesList

type ShippingLinesList struct {
	ListMeta
	Data []*ShippingLines `json:"data,omitempty"`
}

ShippingLinesList is a list of shippingLines

type ShippingLinesParams

type ShippingLinesParams struct {
	Amount         int64  `json:"amount,omitempty"`
	TrackingNumber string `json:"tracking_number,omitempty"`
	Carrier        string `json:"carrier,omitempty"`
	Method         string `json:"method,omitempty"`
}

ShippingLinesParams is the set of parameters that can be used when creating or updating a shipping contact.

func (*ShippingLinesParams) Bytes

func (c *ShippingLinesParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*ShippingLinesParams) Mock

Mock fills Address with dummy data

type Subscription

type Subscription struct {
	ID                string `json:"id,omitempty"`
	Status            string `json:"status,omitempty"`
	Object            string `json:"object,omitempty"`
	ChargeID          string `json:"charge_id,omitempty"`
	CreateAt          string `json:"create_at,omitempty"`
	SubscriptionStart int64  `json:"subscription_start,omitempty"`
	BillingCycleStart int64  `json:"billing_cycle_start,omitempty"`
	BillingCycleEnd   int64  `json:"billing_cycle_end,omitempty"`
	PlanID            string `json:"plan_id,omitempty"`
	CustomerID        string `json:"customer_id,omitempty"`
	CardID            string `json:"card_id,omitempty"`
}

func (*Subscription) Bytes

func (p *Subscription) Bytes() []byte

type SubscriptionList

type SubscriptionList struct {
	ListMeta
	Data []*Subscription `json:"data,omitempty"`
}

type SubscriptionParams

type SubscriptionParams struct {
	CardID     string `json:"card,omitempty"`
	CustomerID string `json:"customer_id,omitempty"`
	PlanID     string `json:"plan,omitempty"`
}

func (*SubscriptionParams) Bytes

func (p *SubscriptionParams) Bytes() []byte

type TaxLines

type TaxLines struct {
	ID          string `json:"id,omitempty"`
	Description string `json:"description,omitempty"`
	Amount      int64  `json:"amount,omitempty"`
	ParentID    string `json:"parent_id,omitempty"`
	Object      string `json:"object,omitempty"`
	Deleted     bool   `json:"deleted,omitempty"`
}

TaxLines should be nested struct of order

type TaxLinesList

type TaxLinesList struct {
	ListMeta
	Data []*TaxLines `json:"data,omitempty"`
}

TaxLinesList is a list of shippingLines

type TaxLinesParams

type TaxLinesParams struct {
	Description string `json:"description,omitempty"`
	Amount      int64  `json:"amount,omitempty"`
}

TaxLinesParams should return api object response filled in the struct

func (*TaxLinesParams) Bytes

func (c *TaxLinesParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*TaxLinesParams) Mock

func (p *TaxLinesParams) Mock() *TaxLinesParams

Mock fills TaxLinesParams with dummy data

type Token

type Token struct {
	ID                 string `json:"id,omitempty"`
	Object             string `json:"object,omitempty"`
	Used               bool   `json:"used,omitempty"`
	Livemode           bool   `json:"livemode,omitempty"`
	Type               string `json:"type,omitempty"`
	Message            string `json:"message,omitempty"`
	MessageToPurchaser string `json:"message_to_purchaser,omitempty"`
	ErrorCode          string `json:"error_code,omitempty"`
	Code               string `json:"code,omitempty"`
	Param              string `json:"param,omitempty"`
}

Token is used when user tries to tokenize

type TokenAddressParams

type TokenAddressParams struct {
	Street1 string `json:"street1,omitempty"`
	Street2 string `json:"street2,omitempty"`
	City    string `json:"city,omitempty"`
	State   string `json:"state,omitempty"`
	Zip     string `json:"zip,omitempty"`
	Country string `json:"country,omitempty"`
}

TokenAddressParams token return address as submodel of TokenParams

type TokenList

type TokenList struct {
	ListMeta
	Data []*Token `json:"data,omitempty"`
}

TokenList is a list of Token's

type TokenParams

type TokenParams struct {
	Card *CardParams `json:"card,omitempty"`
}

TokenParams should be a struct of tokenization response

func (*TokenParams) Bytes

func (c *TokenParams) Bytes() []byte

Bytes converts a ChargeParams to []byte

func (*TokenParams) Mock

func (p *TokenParams) Mock() *TokenParams

Mock Fills token api response

type Transfer

type Transfer struct {
	ID                   string       `json:"id,omitempty"`
	Amount               int64        `json:"amount,omitempty"`
	Currency             string       `json:"currency,omitempty"`
	Livemode             bool         `json:"livemode,omitempty"`
	Object               string       `json:"object,omitempty"`
	CreatedAt            int64        `json:"created_at,omitempty"`
	Status               string       `json:"status,omitempty"`
	StatementReference   string       `json:"statement_reference,omitempty"`
	StatementDescription string       `json:"statement_description,omitempty"`
	Destination          *Destination `json:"destination,omitempty"`
}

Transfer describes Transfer object response

type TransferParams

type TransferParams struct {
	Amount   int64  `json:"amount,omitempty"`
	Currency string `json:"currency,omitempty"`
	PayeeID  string `json:"payee,omitempty"`
}

TransferParams describes params for Transfer object request

func (*TransferParams) Bytes

func (p *TransferParams) Bytes() []byte

Bytes converts a TransferParams to []byte

func (*TransferParams) Mock

func (p *TransferParams) Mock() *TransferParams

Mock fills TransferParams

type Webhook

type Webhook struct {
	ID                 string   `json:"id,omitempty"`
	Object             string   `json:"object,omitempty"`
	Status             string   `json:"status,omitempty"`
	Deleted            bool     `json:"deleted,omitempty"`
	URL                string   `json:"url,omitempty"`
	ProductionEnabled  bool     `json:"production_enabled,omitempty"`
	DevelopmentEnabled bool     `json:"development_enabled,omitempty"`
	SubscribedEvents   []string `json:"subscribed_events,omitempty"`
}

Webhook represents a Conekta webhook. For details see https://developers.conekta.com/api#events.

type WebhookList

type WebhookList struct {
	ListMeta
	Data []*Webhook `json:"data,omitempty"`
}

WebhookList is a list of webhooks

type WebhookLog

type WebhookLog struct {
	ID                     string `json:"id,omitempty"`
	URL                    string `json:"url,omitempty"`
	FailedAttempts         string `json:"failed_attempts,omitempty"`
	LastHTTPResponseStatus string `json:"last_http_response_status,omitempty"`
	Object                 string `json:"object,omitempty"`
	LastAttemptedAt        string `json:"last_attempted_at,omitempty"`
}

WebhookLog describes webhook log object

type WebhookNotification

type WebhookNotification struct {
	Livemode      bool                     `json:"livemode,omitempty"`
	ID            string                   `json:"id,omitempty"`
	Object        string                   `json:"object,omitempty"`
	TypeWebhook   string                   `json:"type,omitempty"`
	WebhookStatus string                   `json:"webhook_status,omitempty"`
	CreatedAt     int64                    `json:"created_at,omitempty"`
	Data          *WebhookNotificationData `json:"data,omitempty"`
}

WebhookNotification represents a Conekta webhook notification.

type WebhookNotificationData

type WebhookNotificationData struct {
	Object             *WebhookNotificationObject                 `json:"object,omitempty"`
	PreviousAttributes *WebhookNotificationDataPreviousAttributes `json:"previous_attributes,omitempty"`
}

WebhookNotificationData represents the data of Conekta webhook notification.

type WebhookNotificationDataPreviousAttributes

type WebhookNotificationDataPreviousAttributes struct {
	Status string `json:"status,omitempty"`
}

WebhookNotificationDataPreviousAttributes represents previous attributes of Conekta webhook notification.

type WebhookNotificationMethod

type WebhookNotificationMethod struct {
	CreatedAt     int64  `json:"created_at,omitempty"`
	PayeeID       string `json:"payee_id,omitempty"`
	Object        string `json:"object,omitempty"`
	AccountNumber string `json:"account_number,omitempty"`
	AccountHolder string `json:"account_holder,omitempty"`
	Bank          string `json:"bank,omitempty"`
}

WebhookNotificationMethod is the inheritance object for Payee webhook

type WebhookNotificationObject

type WebhookNotificationObject struct {
	ID             string                     `json:"id,omitempty"`
	Status         string                     `json:"status,omitempty"`
	Currency       string                     `json:"currency,omitempty"`
	Description    string                     `json:"description,omitempty"`
	FailureCode    string                     `json:"failure_code,omitempty"`
	FailureMessage string                     `json:"failure_message,omitempty"`
	Object         string                     `json:"object,omitempty"`
	PaymentStatus  string                     `json:"payment_status,omitempty"`
	CustomerID     string                     `json:"customer_id,omitempty"`
	OrderID        string                     `json:"order_id,omitempty"`
	CreatedAt      int64                      `json:"created_at,omitempty"`
	UpdatedAt      int64                      `json:"updated_at,omitempty"`
	PaidAt         int64                      `json:"paid_at,omitempty"`
	Fee            int64                      `json:"fee,omitempty"`
	AmountRefunded int64                      `json:"amount_refunded,omitempty"`
	Amount         int64                      `json:"amount,omitempty"`
	Livemode       bool                       `json:"livemode,omitempty"`
	Method         *WebhookNotificationMethod `json:"method,omitempty"`
	PaymentMethod  *PaymentMethod             `json:"payment_method,omitempty"`
	LineItems      *LineItemsList             `json:"line_items,omitempty"`
	Charges        *ChargesList               `json:"charges,omitempty"`
	CustomerInfo   *Customer                  `json:"customer_info,omitempty"`
	WebhookLogs    []*WebhookLog              `json:"webhook_logs,omitempty"`
}

WebhookNotificationObject describes webhook object

type WebhookParams

type WebhookParams struct {
	URL                string `json:"url,omitempty"`
	ProductionEnabled  bool   `json:"production_enabled,omitempty"`
	DevelopmentEnabled bool   `json:"development_enabled,omitempty"`
}

WebhookParams is the set of parameters that can be used when creating or updating a webhook. For details see https://developers.conekta.com/api#create-customer and https://developers.conekta.com/api#update-customer.

func (*WebhookParams) Bytes

func (p *WebhookParams) Bytes() []byte

Bytes converts a WebhookParams to []byte

func (*WebhookParams) Mock

func (p *WebhookParams) Mock() *WebhookParams

Mock fills WebhookParams with dummy data

Jump to

Keyboard shortcuts

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