Go-Payu is a feature-rich GoLang client library that provides seamless integration with the PayU payment gateway. It allows developers to easily process online payments, securely handle transactions, and streamline payment workflows within their Go applications. With Go-Payu, building robust and reliable payment solutions becomes a breeze.
- Simple and intuitive API for PayU integration
- Support for multiple payment methods, including credit/debit cards, online banking, and more
- Tokenization for secure and quick recurring payments
- Easy management of refunds and cancellations
- Query transaction status and history
- Customizable request and response handling
- Comprehensive documentation and examples
To use Go-Payu in your Go project, you need to install it using go get
:
go get github.com/runnart/go-payu
- Import the Go-Payu package into your Go code:
import payu "github.com/runnart/go-payu"
- Initialize the PayU client with your credentials:
client, err := payu.NewClient(os.Getenv("SERVER_URL"))
if err != nil {
panic(err)
}
- Make requests and handle responses:
// TokensPost creates a new token for credit card information on the PayU server.
// If there is an error, the code panics. In a production application, handle errors gracefully.
// The response (resp) contains the token information returned from the PayU server.
resp, err := client.TokensPost(context.TODO(), payu.OptTokensPostReq{
Value: payu.TokensPostReq{
TokenType: payu.TokenTypeCreditCard,
CreditCardCvv: "123",
CardNumber: "4111111111111111",
ExpirationDate: "10/29",
HolderName: "John Mark",
BillingAddress: payu.BillingAddress{
Country: "USA",
State: "NY",
City: "NYC",
Line1: "fifth avenue 10th",
},
},
Set: true,
}, payu.TokensPostParams{
AppID: payu.OptString{
Value: os.Getenv("APP_ID"),
},
PublicKey: payu.OptString{
Value: os.Getenv("PUBLIC_KEY"),
},
XPaymentsOsEnv: payu.OptString{
Value: os.Getenv("PAYMENT_ENV"),
},
APIVersion: payu.OptString{
Value: "1.3.0",
},
})
// Handle errors by panicking. In real-world scenarios, implement appropriate error handling.
if err != nil {
panic(err)
}
For more detailed examples and API documentation, please refer to the GoDoc page.
We welcome contributions from the community! If you have suggestions, bug reports, or new features to add, please open an issue or submit a pull request.
Go-Payu is licensed under the MIT License. See the LICENSE file for details.