go get github.com/WalterPaes/go-pagseguro
config := pagseguro.Config{
Url: "PAGSEG_URL",
Token: "PAGSEG_TOKEN",
}
client := pagseguro.NewClient(config)
integration := pagseguro.NewIntegration(client)
// 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 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)
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)
chargeID := "CHAR_344a0907-8aa6-4b7a-943c-897383adf45f"
// Call function to do request
newCapture, err := integration.GetCharge(chargeID)
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)
This project was developed with the following technologies:
Made by Walter Junior