modulepackage
0.0.0-20210113230652-8941b6ac11f4
Repository: https://github.com/camilohernandez/go-flow.git
Documentation: pkg.go.dev
# README
go-flow
A simple pure Go implementation of the Flow payment API, with handlers for the callbacks and easy access to payment creation and validation.
Example
package main
import (
"fmt"
"github.com/CamiloHernandez/go-flow"
"net/http"
)
func main() {
c := flow.NewClient("your api key", "your secret key")
c.SetSandbox()
result, err := c.CreateOrder(flow.OrderRequest{
CommerceOrder: "123123",
Subject: "Test Order",
Amount: 1000,
PayerEmail: "[email protected]",
ConfirmationURL: "http://example.com/confirmation",
ReturnURL: "http://example.com/return",
})
if err != nil {
panic(err)
}
fmt.Println("ID:", result.FlowID)
fmt.Println("Token:", result.Token)
fmt.Println("URL:", result.GetPaymentURL())
http.HandleFunc("/confirm", c.HTTPOrderConfirmationCallback(func(o *flow.Order) {
fmt.Println("Order", o.CommerceOrder, "confirmed with status", o.Status)
}))
http.HandleFunc("/return", func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("Order completed!"))
})
panic(http.ListenAndServe(":80", nil))
}
# Packages
No description provided by the author
# Functions
NewClient creates a *Client with the given keys.
# Constants
OrderStatusAwaitingPayment indicates that the order's payment is still pending.
OrderStatusCanceled indicates that some party canceled the order before it was fulfilled.
OrderStatusPayed indicates that the order has been successfully payed and should be accepted.
OrderStatusRejected indicates that the payment failed because it was rejected.
No description provided by the author
RefundStatusAccepted is a refund accepted and ready to be transferred.
RefundStatusCanceled is a refund that was canceled by one of the parties.
RefundStatusCreated is a refund created and awaiting processing.
RefundStatusRefunded is a refund that was accepted and transferred.
RefundStatusRejected is a refund that was not accepted.
No description provided by the author
# Structs
Client contains the authentication data and the canonical URL used for requests to the Flow API/.
Optional contains optional fields like RUT and ID.
Order represents a payment order.
OrderRequest is the data needed to start a payment order.
OrderResponse is the values sent by Flow if an order is successfully created.
PaymentData contains additional information about the payment.
PendingInfo reports if a media is still waiting on the payment, and the date since it's waiting.
Refund represents a request for a refund.
RefundStatus is the data related to a refund.