Skip to content

conekta/conekta-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO api

conekta Go API Library

Go Reference

Conekta sdk

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

Prerequisites

Installation

Download conekta-go package:

go get -u github.com/conekta/conekta-go

Using the library

In order to submit http request to Conekta API you need to initialize the client. The following example makes a order request:

package main

import (
    "context"
	"net/http"
	
    "github.com/conekta/conekta-go"
)

func main() {
	// Create a OrderRequest
	const acceptLanguage = "es"
	const accessToken = "Your merchant XAPI key"

	// create the http client
	config := conekta.NewConfiguration()
	client := conekta.NewAPIClient(config)

	ctx := context.WithValue(context.TODO(), conekta.ContextAccessToken, accessToken)

	// create customer
	customer := conekta.Customer{
		Name:  "test go",
		Phone: "+573143159063",
		Email: "test@conekta.com",
	}
	customerResponse, httpResponse, err := client.CustomersApi.CreateCustomer(ctx).
		Customer(customer).
		AcceptLanguage(acceptLanguage).
		Execute()
	if err != nil {
		panic(err)
	}
	if httpResponse.StatusCode != http.StatusCreated {
		panic("invalid response statusCode")
	}

	// Create OrderRequest
	chargeRequest := conekta.ChargeRequest{
		Amount:        conekta.PtrInt32(1555),
		PaymentMethod: *conekta.NewChargeRequestPaymentMethod("cash"),
	}
	productLine := conekta.Product{
		Name:      "toshiba",
		Quantity:  1,
		UnitPrice: 1555,
	}
	orderRequest := conekta.OrderRequest{
		Charges: []conekta.ChargeRequest{
			chargeRequest,
		},
		Currency: "MXN",
		CustomerInfo: conekta.OrderRequestCustomerInfo{
			CustomerInfoJustCustomerId: conekta.NewCustomerInfoJustCustomerId(customerResponse.Id),
		},
		LineItems: []conekta.Product{
			productLine,
		},
	}

	//Make the call to the service. This example code makes a call to /orders
	orderResponse, httpResponse, err := client.OrdersApi.CreateOrder(ctx).
		OrderRequest(orderRequest).
		AcceptLanguage(acceptLanguage).
		Execute()
	if err != nil {
		panic(err)
	}
	if httpResponse.StatusCode != http.StatusCreated {
		panic("invalid response statusCode")
	}
	println(*orderResponse)   
}

Running tests

Navigate to conekta-go folder and run the following commands.

docker-compose up -d
go test -v --race ./...

Documentation for API Endpoints

All URIs are relative to https://api.conekta.io

Class Method HTTP request Description
AntifraudAPI CreateRuleBlacklist Post /antifraud/blacklists Create blacklisted rule
AntifraudAPI CreateRuleWhitelist Post /antifraud/whitelists Create whitelisted rule
AntifraudAPI DeleteRuleBlacklist Delete /antifraud/blacklists/{id} Delete blacklisted rule
AntifraudAPI DeleteRuleWhitelist Delete /antifraud/whitelists/{id} Delete whitelisted rule
AntifraudAPI GetRuleBlacklist Get /antifraud/blacklists Get list of blacklisted rules
AntifraudAPI GetRuleWhitelist Get /antifraud/whitelists Get a list of whitelisted rules
ApiKeysAPI CreateApiKey Post /api_keys Create Api Key
ApiKeysAPI DeleteApiKey Delete /api_keys/{id} Delete Api Key
ApiKeysAPI GetApiKey Get /api_keys/{id} Get Api Key
ApiKeysAPI GetApiKeys Get /api_keys Get list of Api Keys
ApiKeysAPI UpdateApiKey Put /api_keys/{id} Update Api Key
BalancesAPI GetBalance Get /balance Get a company's balance
ChargesAPI GetCharges Get /charges Get A List of Charges
ChargesAPI OrdersCreateCharge Post /orders/{id}/charges Create charge
ChargesAPI UpdateCharge Put /charges/{id} Update a charge
CompaniesAPI GetCompanies Get /companies Get List of Companies
CompaniesAPI GetCompany Get /companies/{id} Get Company
CustomersAPI CreateCustomer Post /customers Create customer
CustomersAPI CreateCustomerFiscalEntities Post /customers/{id}/fiscal_entities Create Fiscal Entity
CustomersAPI DeleteCustomerById Delete /customers/{id} Delete Customer
CustomersAPI GetCustomerById Get /customers/{id} Get Customer
CustomersAPI GetCustomers Get /customers Get a list of customers
CustomersAPI UpdateCustomer Put /customers/{id} Update customer
CustomersAPI UpdateCustomerFiscalEntities Put /customers/{id}/fiscal_entities/{fiscal_entities_id} Update Fiscal Entity
DiscountsAPI OrdersCreateDiscountLine Post /orders/{id}/discount_lines Create Discount
DiscountsAPI OrdersDeleteDiscountLines Delete /orders/{id}/discount_lines/{discount_lines_id} Delete Discount
DiscountsAPI OrdersGetDiscountLine Get /orders/{id}/discount_lines/{discount_lines_id} Get Discount
DiscountsAPI OrdersGetDiscountLines Get /orders/{id}/discount_lines Get a List of Discount
DiscountsAPI OrdersUpdateDiscountLines Put /orders/{id}/discount_lines/{discount_lines_id} Update Discount
EventsAPI GetEvent Get /events/{id} Get Event
EventsAPI GetEvents Get /events Get list of Events
EventsAPI ResendEvent Post /events/{event_id}/webhook_logs/{webhook_log_id}/resend Resend Event
LogsAPI GetLogById Get /logs/{id} Get Log
LogsAPI GetLogs Get /logs Get List Of Logs
OrdersAPI CancelOrder Post /orders/{id}/cancel Cancel Order
OrdersAPI CreateOrder Post /orders Create order
OrdersAPI GetOrderById Get /orders/{id} Get Order
OrdersAPI GetOrders Get /orders Get a list of Orders
OrdersAPI OrderCancelRefund Delete /orders/{id}/refunds/{refund_id} Cancel Refund
OrdersAPI OrderRefund Post /orders/{id}/refunds Refund Order
OrdersAPI OrdersCreateCapture Post /orders/{id}/capture Capture Order
OrdersAPI UpdateOrder Put /orders/{id} Update Order
PaymentLinkAPI CancelCheckout Put /checkouts/{id}/cancel Cancel Payment Link
PaymentLinkAPI CreateCheckout Post /checkouts Create Unique Payment Link
PaymentLinkAPI EmailCheckout Post /checkouts/{id}/email Send an email
PaymentLinkAPI GetCheckout Get /checkouts/{id} Get a payment link by ID
PaymentLinkAPI GetCheckouts Get /checkouts Get a list of payment links
PaymentLinkAPI SmsCheckout Post /checkouts/{id}/sms Send an sms
PaymentMethodsAPI CreateCustomerPaymentMethods Post /customers/{id}/payment_sources Create Payment Method
PaymentMethodsAPI DeleteCustomerPaymentMethods Delete /customers/{id}/payment_sources/{payment_method_id} Delete Payment Method
PaymentMethodsAPI GetCustomerPaymentMethods Get /customers/{id}/payment_sources Get Payment Methods
PaymentMethodsAPI UpdateCustomerPaymentMethods Put /customers/{id}/payment_sources/{payment_method_id} Update Payment Method
PayoutOrdersAPI CreatePayoutOrder Post /payout_orders Create payout order
PayoutOrdersAPI GetPayoutOrderById Get /payout_orders/{id} Get Payout Order
PayoutOrdersAPI GetPayoutOrders Get /payout_orders Get a list of Payout Orders
PlansAPI CreatePlan Post /plans Create Plan
PlansAPI DeletePlan Delete /plans/{id} Delete Plan
PlansAPI GetPlan Get /plans/{id} Get Plan
PlansAPI GetPlans Get /plans Get A List of Plans
PlansAPI UpdatePlan Put /plans/{id} Update Plan
ProductsAPI OrdersCreateProduct Post /orders/{id}/line_items Create Product
ProductsAPI OrdersDeleteProduct Delete /orders/{id}/line_items/{line_item_id} Delete Product
ProductsAPI OrdersUpdateProduct Put /orders/{id}/line_items/{line_item_id} Update Product
ShippingContactsAPI CreateCustomerShippingContacts Post /customers/{id}/shipping_contacts Create a shipping contacts
ShippingContactsAPI DeleteCustomerShippingContacts Delete /customers/{id}/shipping_contacts/{shipping_contacts_id} Delete shipping contacts
ShippingContactsAPI UpdateCustomerShippingContacts Put /customers/{id}/shipping_contacts/{shipping_contacts_id} Update shipping contacts
ShippingsAPI OrdersCreateShipping Post /orders/{id}/shipping_lines Create Shipping
ShippingsAPI OrdersDeleteShipping Delete /orders/{id}/shipping_lines/{shipping_id} Delete Shipping
ShippingsAPI OrdersUpdateShipping Put /orders/{id}/shipping_lines/{shipping_id} Update Shipping
SubscriptionsAPI CancelSubscription Post /customers/{id}/subscription/cancel Cancel Subscription
SubscriptionsAPI CreateSubscription Post /customers/{id}/subscription Create Subscription
SubscriptionsAPI GetAllEventsFromSubscription Get /customers/{id}/subscription/events Get Events By Subscription
SubscriptionsAPI GetSubscription Get /customers/{id}/subscription Get Subscription
SubscriptionsAPI PauseSubscription Post /customers/{id}/subscription/pause Pause Subscription
SubscriptionsAPI ResumeSubscription Post /customers/{id}/subscription/resume Resume Subscription
SubscriptionsAPI UpdateSubscription Put /customers/{id}/subscription Update Subscription
TaxesAPI OrdersCreateTaxes Post /orders/{id}/tax_lines Create Tax
TaxesAPI OrdersDeleteTaxes Delete /orders/{id}/tax_lines/{tax_id} Delete Tax
TaxesAPI OrdersUpdateTaxes Put /orders/{id}/tax_lines/{tax_id} Update Tax
TokensAPI CreateToken Post /tokens Create Token
TransactionsAPI GetTransaction Get /transactions/{id} Get transaction
TransactionsAPI GetTransactions Get /transactions Get List transactions
TransfersAPI GetTransfer Get /transfers/{id} Get Transfer
TransfersAPI GetTransfers Get /transfers Get a list of transfers
WebhookKeysAPI CreateWebhookKey Post /webhook_keys Create Webhook Key
WebhookKeysAPI DeleteWebhookKey Delete /webhook_keys/{id} Delete Webhook key
WebhookKeysAPI GetWebhookKey Get /webhook_keys/{id} Get Webhook Key
WebhookKeysAPI GetWebhookKeys Get /webhook_keys Get List of Webhook Keys
WebhookKeysAPI UpdateWebhookKey Put /webhook_keys/{id} Update Webhook Key
WebhooksAPI CreateWebhook Post /webhooks Create Webhook
WebhooksAPI DeleteWebhook Delete /webhooks/{id} Delete Webhook
WebhooksAPI GetWebhook Get /webhooks/{id} Get Webhook
WebhooksAPI GetWebhooks Get /webhooks Get List of Webhooks
WebhooksAPI TestWebhook Post /webhooks/{id}/test Test Webhook
WebhooksAPI UpdateWebhook Put /webhooks/{id} Update Webhook

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

engineering@conekta.com