Categorygithub.com/conekta/conekta-go
repositorypackage
6.0.6+incompatible
Repository: https://github.com/conekta/conekta-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

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: "[email protected]",
	}
	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

ClassMethodHTTP requestDescription
AntifraudAPICreateRuleBlacklistPost /antifraud/blacklistsCreate blacklisted rule
AntifraudAPICreateRuleWhitelistPost /antifraud/whitelistsCreate whitelisted rule
AntifraudAPIDeleteRuleBlacklistDelete /antifraud/blacklists/{id}Delete blacklisted rule
AntifraudAPIDeleteRuleWhitelistDelete /antifraud/whitelists/{id}Delete whitelisted rule
AntifraudAPIGetRuleBlacklistGet /antifraud/blacklistsGet list of blacklisted rules
AntifraudAPIGetRuleWhitelistGet /antifraud/whitelistsGet a list of whitelisted rules
ApiKeysAPICreateApiKeyPost /api_keysCreate Api Key
ApiKeysAPIDeleteApiKeyDelete /api_keys/{id}Delete Api Key
ApiKeysAPIGetApiKeyGet /api_keys/{id}Get Api Key
ApiKeysAPIGetApiKeysGet /api_keysGet list of Api Keys
ApiKeysAPIUpdateApiKeyPut /api_keys/{id}Update Api Key
BalancesAPIGetBalanceGet /balanceGet a company's balance
ChargesAPIGetChargesGet /chargesGet A List of Charges
ChargesAPIOrdersCreateChargePost /orders/{id}/chargesCreate charge
ChargesAPIUpdateChargePut /charges/{id}Update a charge
CompaniesAPIGetCompaniesGet /companiesGet List of Companies
CompaniesAPIGetCompanyGet /companies/{id}Get Company
CustomersAPICreateCustomerPost /customersCreate customer
CustomersAPICreateCustomerFiscalEntitiesPost /customers/{id}/fiscal_entitiesCreate Fiscal Entity
CustomersAPIDeleteCustomerByIdDelete /customers/{id}Delete Customer
CustomersAPIGetCustomerByIdGet /customers/{id}Get Customer
CustomersAPIGetCustomersGet /customersGet a list of customers
CustomersAPIUpdateCustomerPut /customers/{id}Update customer
CustomersAPIUpdateCustomerFiscalEntitiesPut /customers/{id}/fiscal_entities/{fiscal_entities_id}Update Fiscal Entity
DiscountsAPIOrdersCreateDiscountLinePost /orders/{id}/discount_linesCreate Discount
DiscountsAPIOrdersDeleteDiscountLinesDelete /orders/{id}/discount_lines/{discount_lines_id}Delete Discount
DiscountsAPIOrdersGetDiscountLineGet /orders/{id}/discount_lines/{discount_lines_id}Get Discount
DiscountsAPIOrdersGetDiscountLinesGet /orders/{id}/discount_linesGet a List of Discount
DiscountsAPIOrdersUpdateDiscountLinesPut /orders/{id}/discount_lines/{discount_lines_id}Update Discount
EventsAPIGetEventGet /events/{id}Get Event
EventsAPIGetEventsGet /eventsGet list of Events
EventsAPIResendEventPost /events/{event_id}/webhook_logs/{webhook_log_id}/resendResend Event
LogsAPIGetLogByIdGet /logs/{id}Get Log
LogsAPIGetLogsGet /logsGet List Of Logs
OrdersAPICancelOrderPost /orders/{id}/cancelCancel Order
OrdersAPICreateOrderPost /ordersCreate order
OrdersAPIGetOrderByIdGet /orders/{id}Get Order
OrdersAPIGetOrdersGet /ordersGet a list of Orders
OrdersAPIOrderCancelRefundDelete /orders/{id}/refunds/{refund_id}Cancel Refund
OrdersAPIOrderRefundPost /orders/{id}/refundsRefund Order
OrdersAPIOrdersCreateCapturePost /orders/{id}/captureCapture Order
OrdersAPIUpdateOrderPut /orders/{id}Update Order
PaymentLinkAPICancelCheckoutPut /checkouts/{id}/cancelCancel Payment Link
PaymentLinkAPICreateCheckoutPost /checkoutsCreate Unique Payment Link
PaymentLinkAPIEmailCheckoutPost /checkouts/{id}/emailSend an email
PaymentLinkAPIGetCheckoutGet /checkouts/{id}Get a payment link by ID
PaymentLinkAPIGetCheckoutsGet /checkoutsGet a list of payment links
PaymentLinkAPISmsCheckoutPost /checkouts/{id}/smsSend an sms
PaymentMethodsAPICreateCustomerPaymentMethodsPost /customers/{id}/payment_sourcesCreate Payment Method
PaymentMethodsAPIDeleteCustomerPaymentMethodsDelete /customers/{id}/payment_sources/{payment_method_id}Delete Payment Method
PaymentMethodsAPIGetCustomerPaymentMethodsGet /customers/{id}/payment_sourcesGet Payment Methods
PaymentMethodsAPIUpdateCustomerPaymentMethodsPut /customers/{id}/payment_sources/{payment_method_id}Update Payment Method
PayoutOrdersAPICreatePayoutOrderPost /payout_ordersCreate payout order
PayoutOrdersAPIGetPayoutOrderByIdGet /payout_orders/{id}Get Payout Order
PayoutOrdersAPIGetPayoutOrdersGet /payout_ordersGet a list of Payout Orders
PlansAPICreatePlanPost /plansCreate Plan
PlansAPIDeletePlanDelete /plans/{id}Delete Plan
PlansAPIGetPlanGet /plans/{id}Get Plan
PlansAPIGetPlansGet /plansGet A List of Plans
PlansAPIUpdatePlanPut /plans/{id}Update Plan
ProductsAPIOrdersCreateProductPost /orders/{id}/line_itemsCreate Product
ProductsAPIOrdersDeleteProductDelete /orders/{id}/line_items/{line_item_id}Delete Product
ProductsAPIOrdersUpdateProductPut /orders/{id}/line_items/{line_item_id}Update Product
ShippingContactsAPICreateCustomerShippingContactsPost /customers/{id}/shipping_contactsCreate a shipping contacts
ShippingContactsAPIDeleteCustomerShippingContactsDelete /customers/{id}/shipping_contacts/{shipping_contacts_id}Delete shipping contacts
ShippingContactsAPIUpdateCustomerShippingContactsPut /customers/{id}/shipping_contacts/{shipping_contacts_id}Update shipping contacts
ShippingsAPIOrdersCreateShippingPost /orders/{id}/shipping_linesCreate Shipping
ShippingsAPIOrdersDeleteShippingDelete /orders/{id}/shipping_lines/{shipping_id}Delete Shipping
ShippingsAPIOrdersUpdateShippingPut /orders/{id}/shipping_lines/{shipping_id}Update Shipping
SubscriptionsAPICancelSubscriptionPost /customers/{id}/subscription/cancelCancel Subscription
SubscriptionsAPICreateSubscriptionPost /customers/{id}/subscriptionCreate Subscription
SubscriptionsAPIGetAllEventsFromSubscriptionGet /customers/{id}/subscription/eventsGet Events By Subscription
SubscriptionsAPIGetSubscriptionGet /customers/{id}/subscriptionGet Subscription
SubscriptionsAPIPauseSubscriptionPost /customers/{id}/subscription/pausePause Subscription
SubscriptionsAPIResumeSubscriptionPost /customers/{id}/subscription/resumeResume Subscription
SubscriptionsAPIUpdateSubscriptionPut /customers/{id}/subscriptionUpdate Subscription
TaxesAPIOrdersCreateTaxesPost /orders/{id}/tax_linesCreate Tax
TaxesAPIOrdersDeleteTaxesDelete /orders/{id}/tax_lines/{tax_id}Delete Tax
TaxesAPIOrdersUpdateTaxesPut /orders/{id}/tax_lines/{tax_id}Update Tax
TokensAPICreateTokenPost /tokensCreate Token
TransactionsAPIGetTransactionGet /transactions/{id}Get transaction
TransactionsAPIGetTransactionsGet /transactionsGet List transactions
TransfersAPIGetTransferGet /transfers/{id}Get Transfer
TransfersAPIGetTransfersGet /transfersGet a list of transfers
WebhookKeysAPICreateWebhookKeyPost /webhook_keysCreate Webhook Key
WebhookKeysAPIDeleteWebhookKeyDelete /webhook_keys/{id}Delete Webhook key
WebhookKeysAPIGetWebhookKeyGet /webhook_keys/{id}Get Webhook Key
WebhookKeysAPIGetWebhookKeysGet /webhook_keysGet List of Webhook Keys
WebhookKeysAPIUpdateWebhookKeyPut /webhook_keys/{id}Update Webhook Key
WebhooksAPICreateWebhookPost /webhooksCreate Webhook
WebhooksAPIDeleteWebhookDelete /webhooks/{id}Delete Webhook
WebhooksAPIGetWebhookGet /webhooks/{id}Get Webhook
WebhooksAPIGetWebhooksGet /webhooksGet List of Webhooks
WebhooksAPITestWebhookPost /webhooks/{id}/testTest Webhook
WebhooksAPIUpdateWebhookPut /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

[email protected]