Skip to content

Go SDK

Terminal window
go get github.com/gryphem-pay/gryphem-pay-go
client, err := gryphempay.New(os.Getenv("GRYPHEM_API_KEY"),
gryphempay.WithBaseURL("https://api.feitpay.com"),
gryphempay.WithMaxRetries(2),
)
intent, err := client.PaymentIntents.Create(ctx, &gryphempay.PaymentIntentCreateParams{
StoreID: "store_YOUR_STORE_ID", Amount: "59.90", Currency: "EUR", IdempotencyKey: "order-123",
})
for pi, err := range client.PaymentIntents.All(ctx, &gryphempay.PaymentIntentListParams{
Status: []gryphempay.PaymentStatus{gryphempay.StatusConfirmed},
}) {
if err != nil {
return err
}
fmt.Println(pi.ID, pi.Fulfillable)
}

Errors are *gryphempay.Error with Type, Code, Param, Status, RequestID and RetryAfter; use gryphempay.ErrorType(err) for quick checks. The client is safe for concurrent use; reuse one instance.

Services: PaymentIntents (Create, Get, List, All, Cancel, Resolve, Timeline), CheckoutSessions, WebhookEndpoints (Create, List, RotateSecret, SendTest), WebhookDeliveries (Get, Retry) and Platform (Capabilities). For other endpoints, see the API reference.

event, err := webhook.Verify(body, r.Header.Get(webhook.SignatureHeader), []string{secret, previousSecret}, nil)
if err != nil {
http.Error(w, string(webhook.ReasonOf(err)), http.StatusBadRequest)
return
}
data, _ := event.PaymentData()

webhook.Options{Tolerance: …, Now: …} customises tolerance and time for tests; webhook.GenerateTestHeader creates valid headers.