gofondy is GO client for the Fondy Payment Gate API.
go get github.com/stremovskyy/gofondy
create a new Fondy client with default options
fondyGateway := gofondy.New(models.DefaultOptions())
Merchant account is a structure that contains all the necessary information for the client to work with the Fondy API.
merchAccount := &models.MerchantAccount{
MerchantID: examples.TechMerchantId,
MerchantKey: examples.TechMerchantKey,
MerchantString: "Test Merchant",
MerchantDesignID: examples.DesignId,
IsTechnical: true,
}
verificationLink, err := fondyGateway.VerificationLink(merchAccount, uuid.New(), nil, "test", consts.CurrencyCodeUAH)
if err != nil {
log.Fatal(err)
}
fmt.Printf("\nVerification link: %s\n", verificationLink.String())
invoiceId := uuid.New()
holdAmount := float64(3)
paymentByToken, err := fondyGateway.Hold(merchAccount, &invoiceId, &holdAmount, examples.CardToken)
if err != nil {
log.Fatal(err)
}
if *paymentByToken.ResponseStatus == consts.FondyResponseStatusSuccess {
fmt.Printf("Order (%s) status: %s\n", paymentByToken.OrderID, *paymentByToken.OrderStatus)
} else {
fmt.Printf("Error: %s\n", *paymentByToken.ErrorMessage)
}
invoiceId := uuid.MustParse("767f44ef-2997-4623-961f-9ee081ef730f")
captureAmount := float64(3)
capturePayment, err := fondyGateway.Capture(merchAccount, &invoiceId, &captureAmount)
if err != nil {
log.Fatal(err)
}
if *capturePayment.ResponseStatus == consts.FondyResponseStatusSuccess {
fmt.Printf("Order (%s) Capture Status: %s\n", capturePayment.OrderID.String(), *capturePayment.CaptureStatus)
} else {
fmt.Printf("Error: %s\n", *capturePayment.ErrorMessage)
}
refundPayment, err := fondyGateway.Refund(merchAccount, &invoiceId, &captureAmount)
if err != nil {
log.Fatal(err)
}
if *refundPayment.ResponseStatus == consts.FondyResponseStatusSuccess {
fmt.Printf("Order (%s) Reversed: %s\n", refundPayment.OrderID.String(), *refundPayment.ReversalAmount)
} else {
fmt.Printf("Error: %s\n", *refundPayment.ErrorMessage)
}
status, err := fondyGateway.Status(merchAccount, &invoiceId)
if err != nil {
log.Fatal(err)
}
if *status.ResponseStatus == consts.FondyResponseStatusSuccess {
fmt.Printf("Order status: %s\n", *status.OrderStatus)
} else {
fmt.Printf("Error: %s\n", *status.ErrorMessage)
}
This project is licensed under the MIT License - see the LICENSE file for details
- Anton Stremovskyy - Initial work - stremovskyy
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
- Add tests
- Add more examples
- Add more API methods