Skip to main content
The SDK’s recipes package provides opinionated, end-to-end workflows that combine multiple API calls into a single operation. Each recipe handles authentication, error mapping, and secure credential management.

OTP login

Sign in a user via WhatsApp OTP:
import (
    "context"
    "fmt"

    "github.com/ZeamMoney/zeam-sdk-go"
    "github.com/ZeamMoney/zeam-sdk-go/auth"
    "github.com/ZeamMoney/zeam-sdk-go/recipes"
)

client, _ := zeam.New(
    zeam.WithEnvironment(zeam.EnvironmentProduction),
    zeam.WithTokenStore(auth.NewMemoryStore()),
)

sess, err := recipes.LoginOTP(ctx, client, recipes.LoginOTPInput{
    MobileNumber: "+27821234567",
    AskCode: func(ctx context.Context, hint recipes.OTPHint) (string, error) {
        fmt.Printf("OTP sent to %s. Enter code: ", hint.MaskedDestination)
        // Collect from user via your UI
        return userInput, nil
    },
    Subject: "payment-flow",  // optional tag for the session
})
// sess is on TrackBusiness and persisted in the token store

Ed25519 login

Authenticate a backend service via Stellar challenge-response:
import "github.com/ZeamMoney/zeam-sdk-go/recipes"

sess, err := recipes.ConnectLogin(ctx, client, recipes.ConnectLoginInput{
    StellarSeed: seed,       // from your secret manager — zeroed after use
    PublicKey:   publicKey,
})
// sess is on TrackConnect and persisted in the token store
// The keypair is zeroed in memory immediately after authentication

Application registration

Register a new integrator application and securely capture one-time credentials:
import "github.com/ZeamMoney/zeam-sdk-go/recipes"

result, err := recipes.RegisterApplication(ctx, client, recipes.RegisterAppInput{
    Session: businessSession,
    Payload: map[string]any{
        "associationId":   "assoc-uuid",
        "applicationName": "My Payment Service",
        "webhookUrl":      "https://example.com/webhooks/zeam",
        "webhookMethod":   "POST",
    },
    CaptureOneTimeSecrets: func(ctx context.Context, s recipes.OneTimeSecrets) error {
        // This callback fires exactly once. Store ALL credentials NOW:
        //   s.StellarSeed      — Stellar seed for Ed25519 auth
        //   s.StellarPublicKey — Stellar public key
        //   s.ConnectSecret    — Connect lane secret
        //   s.APIKey           — x-zeam-auth header value
        //   s.WebhookSecret    — HMAC signing secret
        //   s.WebhookID        — Webhook identifier
        return saveToVault(ctx, s)
    },
})
// Secrets are zeroed in memory immediately after the callback returns

fmt.Printf("Registered: integrator=%s, publicKey=%s\n",
    result.IntegratorID, result.StellarPublicKey)

Connect payment (9-step off-ramp)

The flagship recipe — orchestrates the full off-ramp payment flow:
import (
    "github.com/ZeamMoney/zeam-sdk-go/recipes"
    "github.com/ZeamMoney/zeam-sdk-go/stellar"
)

flow := recipes.NewConnectPayment(client, recipes.ConnectPaymentInput{
    BusinessSession:      businessSession,
    ApplicationSeed:      seed,
    ApplicationPublicKey: publicKey,
    AssociationID:        "assoc-uuid",
    WalletID:             "wallet-uuid",
    FundingAsset:         stellar.Asset{Code: "USDC", Issuer: "GABC..."},
    BeneficiaryID:        "beneficiary-uuid",
    Method:               "BANK",
    CountryISO:           "ZA",
    SendAmount:           "100.00",
})

// Run all 9 steps
result, err := flow.Do(ctx)

Driving steps individually

You can pause between steps to show confirmation UIs or add custom logic:
// Steps 1-3: Business data
associations, _ := flow.ListAssociations(ctx)
wallets, _ := flow.ListWallets(ctx)
beneficiary, _ := flow.GetBeneficiary(ctx)

// Step 4: Connect authentication
connectSession, _ := flow.SignInConnect(ctx)

// Step 5: Discovery
connectors, _ := flow.DiscoverConnectors(ctx)
flow.SelectConnector()  // picks first active match

// Step 6: Quote — pause here for user confirmation
quote, _ := flow.GetConnectQuote(ctx)
fmt.Printf("Quote: send %s %s, beneficiary receives %s\n",
    quote.SendAmount, quote.AcceptedAsset, quote.DestinationAmount)

// Step 7: Stellar quote (only if cross-asset)
if flow.RequiresStellarQuote() {
    stellarQuote, _ := flow.GetStellarQuote(ctx)
}

// Step 8-9: Execute
txHash, _ := flow.ExecuteStellarTransaction(ctx)
executeResult, _ := flow.ExecuteConnectPayment(ctx)

Credential rotation

Rotate API keys or webhook secrets:
import "github.com/ZeamMoney/zeam-sdk-go/recipes"

newCreds, err := recipes.RotateCredential(ctx, client, recipes.RotateInput{
    Session:       businessSession,
    ApplicationID: "app-uuid",
    CredentialType: recipes.CredentialTypeAPIKey,  // or CredentialTypeWebhookSecret
})
// Store the new credential before discarding the old one

Recipe design

All recipes follow these principles:
  • Explicit context — every call takes ctx context.Context
  • Secure by default — secrets are zeroed in memory after use
  • No globals — configuration flows through the client and input structs
  • Composable — recipes use the same sub-clients you’d use directly
  • Concurrent-safe — safe for concurrent use across distinct inputs