SDK Libraries
Go SDK
Install the official MakePay Go SDK for payment links, settings, and webhook verification.
MakePay Go SDK
Overview
The MakePay Go SDK is a dependency-free Go module for server-side MakePay integrations. It wraps API-key authentication, payment-link operations, MakePay settings, checkout URL generation, and signed webhook verification.
Module:
github.com/makecryptoio/makepay-go
Package documentation:
https://pkg.go.dev/github.com/makecryptoio/makepay-go
Installation
go get github.com/makecryptoio/makepay-go
The module targets Go 1.22 or newer and uses only the Go standard library.
Authentication
Create a MakePay API key from the MakeCrypto merchant developer area and keep the key secret only on your server.
client, err := makepay.NewClient(makepay.ClientOptions{
KeyID: os.Getenv("MAKEPAY_KEY_ID"),
KeySecret: os.Getenv("MAKEPAY_KEY_SECRET"),
// Optional: override only when MakePay gives you a custom checkout origin.
CheckoutBaseURL: "https://makepay.io",
})
if err != nil {
return err
}
The SDK sends X-MakeCrypto-Key-Id and X-MakeCrypto-Key-Secret headers to
the MakePay partner API.
Create Payment Link
response, err := client.CreatePaymentLink(context.Background(), makepay.PaymentLinkPayload{
"title": "Order #1042",
"description": "Checkout for order #1042",
"amount": "129.99",
"currency": "USDT",
"orderId": "order_1042",
"customerEmail": "buyer@example.com",
"returnUrl": "https://merchant.example/orders/1042",
"successUrl": "https://merchant.example/orders/1042/success",
"failureUrl": "https://merchant.example/orders/1042/pay",
"expirationTime": "12h",
}, nil)
if err != nil {
return err
}
fmt.Println(response["paymentLink"])
Send a MakePay payment request email during creation:
_, err := client.CreatePaymentLink(ctx, payload, &makepay.CreatePaymentLinkOptions{
SendPaymentRequestEmail: true,
})
Embedded Checkout
Use hosted checkout URLs for redirects, or the embed helpers when your frontend keeps the shopper on the merchant page.
hostedURL, err := client.HostedCheckoutURL("PAYMENT_LINK_UID")
if err != nil {
return err
}
embeddedURL, err := client.EmbeddedCheckoutURL(
"PAYMENT_LINK_UID",
"https://merchant.example",
)
if err != nil {
return err
}
buttonHTML, err := client.EmbedButtonHTML("PAYMENT_LINK_UID", makepay.EmbedSnippetOptions{
ButtonLabel: "Pay with crypto",
})
if err != nil {
return err
}
iframeHTML, err := client.IframeHTML("PAYMENT_LINK_UID", makepay.EmbedSnippetOptions{
IframeTitle: "Secure MakePay checkout",
})
Read And Update Links
links, err := client.ListPaymentLinks(ctx, map[string]any{"limit": 50})
detail, err := client.GetPaymentLink(ctx, "PAYMENT_LINK_UID")
updated, err := client.UpdatePaymentLink(ctx, "PAYMENT_LINK_UID", map[string]any{
"status": "paused",
})
sent, err := client.SendPaymentRequestEmail(
ctx,
"PAYMENT_LINK_UID",
"buyer@example.com",
)
_, _, _, _ = links, detail, updated, sent
Settings
settings, err := client.GetSettings(ctx)
updated, err := client.UpdateSettings(ctx, map[string]any{
"callbackUrl": "https://merchant.example/webhooks/makepay",
})
_, _ = settings, updated
Webhook Verification
Read the exact raw body before parsing JSON.
func handleMakePayWebhook(writer http.ResponseWriter, request *http.Request) {
rawBody, err := io.ReadAll(request.Body)
if err != nil {
http.Error(writer, "invalid body", http.StatusBadRequest)
return
}
event, err := makepay.ParseWebhook(
rawBody,
request.Header.Get("x-makepay-signature"),
os.Getenv("MAKEPAY_WEBHOOK_SECRET"),
)
if err != nil {
http.Error(writer, "invalid signature", http.StatusUnauthorized)
return
}
if event["event"] != nil {
// Update your local order.
}
writer.WriteHeader(http.StatusOK)
}
Use VerifyWebhook when you only need a boolean result.
Error Handling
API calls return *makepay.Error. It includes the HTTP status, decoded response
body, and raw response bytes.
response, err := client.GetPaymentLink(ctx, "PAYMENT_LINK_UID")
if err != nil {
var makePayError *makepay.Error
if errors.As(err, &makePayError) {
log.Println(makePayError.StatusCode, makePayError.ResponseBody)
}
return err
}
_ = response
Source Layout
The canonical monorepo source lives in apps/plugins/go-sdk. The public
repository at https://github.com/makecryptoio/makepay-go mirrors only the SDK
files so pkg.go.dev and Go users can install or inspect it without the full
MakeCrypto workspace.
Release Notes
The module is released by tagging the public repository as
github.com/makecryptoio/makepay-go. After the tag is pushed, pkg.go.dev indexes
the version from the Go module proxy.