GithubHelp home page GithubHelp logo

walterpaes / go-pagseguro Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 0.0 68 KB

A Library to implement the integration with PagSeguro API v.4.0

License: MIT License

Go 100.00%
go go-modules pagseguro pagseguro-api payment-gateway golang

go-pagseguro's Introduction

License: MIT

GoPagSeguro

This Lib was developed for implement some features of the new PagSeguro's api using Go Lang

Import and Usage

go get github.com/WalterPaes/go-pagseguro

Create a New Integration

config := pagseguro.Config{
	Url: "PAGSEG_URL",
	Token: "PAGSEG_TOKEN",
}
client := pagseguro.NewClient(config)
integration := pagseguro.NewIntegration(client)

Generating a Boleto Charge

// Create a boleto charge struct to payload
boletoCharge := pagseguro.NewBoletoCharge(
	"12345",
	"Teste",
	"BRL",
	1000,
	&pagseguro.Boleto{
		DueDate: "2024-12-31",
		InstructionLines: &pagseguro.BoletoInstructionLines{
			Line1: "Pagamento Teste3 processado para DESC Fatura",
			Line2: "Via PagSeguro Teste3",
		},
		Holder: &pagseguro.Holder{
			Name: "Waltin",
			TaxID: "27908347096",
			Email: "[email protected]",
			Address: &pagseguro.Address{
				Street: "Rua Teste",
				Number: "524545",
				Locality: "Umarizal",
				City: "Belém",
				Region: "Pará",
				RegionCode: "PA",
				Country: "Brasil",
				PostalCode: "88025010",
			},
		},
	},
)

// Call function to do request
newCharge, err := integration.BoletoCharge(boleto)

Create a credit card Authorization

// Create a credit card charge struct to payload
creditCardCharge = pagseguro.NewCardCharge(
	"12345",
	"Teste Card 01",
	"BRL",
	108701,
	2,
	true,
	"My store",
	&pagseguro.Card{
		Number: "4111111111111111",
		ExpMonth: "12",
		ExpYear: "2030",
		SecurityCode: "123",
		Holder: &pagseguro.Holder{
			Name: "Waltin",
		},
	},
)

// Call function to do request
newCharge, err := integration.CardCharge(card)

Do a Capture after Pre-Authorization

chargeID := "CHAR_344a0907-8aa6-4b7a-943c-897383adf45f"
amount := &pagseguro.Amount{
    Value: 1000,
    Currency: "BRL",
}

// Call function to do request
newCapture, err := integration.Capture(chargeID, amount)

Get a charge

chargeID := "CHAR_344a0907-8aa6-4b7a-943c-897383adf45f"

// Call function to do request
newCapture, err := integration.GetCharge(chargeID)

Refund and Cancel

chargeID := "CHAR_344a0907-8aa6-4b7a-943c-897383adf45f"
amount := &pagseguro.Amount{
    Value:    1000,
    Currency: "BRL",
}

// Call function to do request
charge, err := integration.RefundAndCancel(chargeID, amount)

🚀 Technologies

This project was developed with the following technologies:

Made by Walter Junior

go-pagseguro's People

Contributors

walterpaes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.