gustavotero7 / go-conekta

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pipeline status coverage report Go Report Card

Go-Conekta

A Wrapper for use conekta's api v2 in golang inspired in sait/go-conekta

This tutorial assumes the next:

  • Have a conekta account
  • Have a frontend that tokenize cards
  • Knowledge of conekta's api

Usage

First get the package

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

Import in your project

import (
	"github.com/gustavotero7/go-conekta/client"
	"github.com/gustavotero7/go-conekta/customers"
	"github.com/gustavotero7/go-conekta/models"
)

Simple Example

package main

import (
	"log"

	"github.com/gustavotero7/go-conekta/client"
	"github.com/gustavotero7/go-conekta/customers"
	"github.com/gustavotero7/go-conekta/models"
)

func main() {
	client.APIKey = "your_private_key"
	customer, err := customers.Create(models.Customer{
		Name:  "Fulano Perez",
		Email: "fulano@example.com",
		Phone: "+5215555555555",
	})
	if err != nil {
		log.Println("Err: ", err)
		return
	}
	log.Println("Response: ", customer)

	// customers.Update(models.Customer{})
	// customers.Delete("customer_id")
	// customers.CreatePaymentSource("customer_id", models.PaymentSource{})
	// orders.Create(models.Order{})
	// ...
}

You only need to set client.APIKey once

Resources

https://godoc.org/github.com/gustavotero7/go-conekta

https://developers.conekta.com/libraries/javascript

https://developers.conekta.com/api

https://developers.conekta.com/tutorials/card

About

License:MIT License


Languages

Language:Go 100.0%