Skip to content

mnavarrocarter/transbank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Transbank SDK

A solid and well tested Transbank SDK for Golang

go get github.com/mmavarrocarter/transbank

Implemented Transbank Services

  • Webpay Plus - Normal
  • Webpay Plus - Deferred
  • Webpay Plus - Mall
  • OneClick - Mall
  • Pos Integrado

Webpay Usage

package main

import (
	"context"
	"crypto/rand"
	"github.com/mnavarrocarter/transbank/webpay"
	"net/http"
)

func handleInitTransaction(client *webpay.Client) http.HandlerFunc {
	return func(rw http.ResponseWriter, req *http.Request) {
		// In the real world, you obtain some of this data from another source
		transaction := &webpay.Transaction{
			BuyOrder:  "order1234",
			SessionId: "session1234",
			Amount: 12344,
			ReturnUrl: "https://my.app.com/webpay/callback",
		}

		// Create the transaction in webpay
		resp, err := client.CreateTransaction(context.Background(), transaction)

		// Handle any errors
		if err != nil {
			http.Error(rw, err.Error(), http.StatusBadGateway)
			return
		}

		// Render the webpay payment form with a self-posting js form
		err = resp.Render(rw, rand.Reader)
		if err != nil {
			panic(err)
        }
	}
}

About

Transbank SDK written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published