reevit

package module
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 13 Imported by: 0

README

Reevit Go SDK

The official Go SDK for Reevit — a unified payment orchestration platform for Africa.

Go Reference

Installation

go get github.com/Reevit-Platform/go-sdk@v0.9.0

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	reevit "github.com/Reevit-Platform/go-sdk"
)

func main() {
	// Initialize the client
	client := reevit.NewClient("pfk_live_xxx", "org_123")

	// Create a payment intent
	idempotencyKey := reevit.GenerateIdempotencyKey(map[string]any{
		"amount":    45000,
		"currency":  "GHS",
		"reference": "order_12345",
	})
	payment, err := client.Payments.CreateIntent(context.Background(), &reevit.PaymentIntentRequest{
		Amount:   45000,
		Currency: "GHS",
		Method:   "momo",
		Country:  "GH",
		Metadata: map[string]interface{}{
			"order_id": "12345",
		},
	}, reevit.WithIdempotencyKey(idempotencyKey))
	if err != nil {
		log.Fatal(err)
	}

fmt.Printf("Payment created: %s (Status: %s)\n", payment.ID, payment.Status)
}

Server-created checkout sessions

Create checkout sessions on your server, then pass session.SessionSecret to a browser SDK — @reevit/react, @reevit/vue, or @reevit/svelte — to render the checkout UI.

session, err := client.CheckoutSessions.Create(ctx, &reevit.PaymentIntentRequest{
	Amount:   5000,
	Currency: "GHS",
	Method:   "mobile_money",
	Country:  "GH",
}, reevit.WithIdempotencyKey("order_12345"))

Idempotency

Use WithIdempotencyKey to safely retry intent creation without creating duplicates.

key := reevit.GenerateIdempotencyKey(map[string]any{
	"amount":   45000,
	"currency": "GHS",
})

payment, err := client.Payments.CreateIntent(ctx, req, reevit.WithIdempotencyKey(key))

Services

  • Payments: client.Payments (CreateIntent, Get, List, UpdateIntent, Confirm, ConfirmIntent, Cancel, Retry, Refund, GetStats)
  • Connections: client.Connections (Create, List, Get, Delete, Validate, ListAudit, UpdateLabels, UpdateStatus, Test)
  • Subscriptions: client.Subscriptions (Create, List, Get, Update, Cancel, Resume)
  • Fraud: client.Fraud (Get, Update)
  • Customers: client.Customers
  • Payment Links: client.PaymentLinks
  • Checkout Sessions: client.CheckoutSessions
  • Webhooks: client.Webhooks
  • Routing Rules: client.RoutingRules
  • Invoices: client.Invoices

Webhook Verification

Reevit sends webhooks to notify your application of payment events. Always verify webhook signatures.

Understanding Webhooks

There are two types of webhooks in Reevit:

  1. Inbound Webhooks (PSP → Reevit): Webhooks from payment providers (Paystack, Flutterwave, etc.) to Reevit. Configure these in the PSP dashboard. Reevit handles them automatically.

  2. Outbound Webhooks (Reevit → Your App): Webhooks from Reevit to your application. Configure in Reevit Dashboard and create a handler in your app.

Signature Format
  • Header: X-Reevit-Signature: sha256=<hex-signature>
  • Signature: HMAC-SHA256(request_body, signing_secret)
Getting Your Signing Secret
  1. Go to Reevit Dashboard > Developers > Webhooks
  2. Configure your webhook endpoint URL
  3. Copy the signing secret (starts with whsec_)
  4. Set environment variable: REEVIT_WEBHOOK_SECRET=whsec_xxx...
Webhook Handler Example
package main

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"encoding/json"
	"io"
	"log"
	"net/http"
	"os"
	"strings"
)

// PaymentData represents payment event data
type PaymentData struct {
	ID         string            `json:"id"`
	Status     string            `json:"status"`
	Amount     int64             `json:"amount"`
	Currency   string            `json:"currency"`
	Provider   string            `json:"provider"`
	CustomerID string            `json:"customer_id,omitempty"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

// SubscriptionData represents subscription event data
type SubscriptionData struct {
	ID            string `json:"id"`
	CustomerID    string `json:"customer_id"`
	PlanID        string `json:"plan_id"`
	Status        string `json:"status"`
	Amount        int64  `json:"amount"`
	Currency      string `json:"currency"`
	Interval      string `json:"interval"`
	NextRenewalAt string `json:"next_renewal_at,omitempty"`
}

// WebhookPayload represents the webhook event structure
type WebhookPayload struct {
	ID        string          `json:"id"`
	Type      string          `json:"type"`
	OrgID     string          `json:"org_id"`
	CreatedAt string          `json:"created_at"`
	Data      json.RawMessage `json:"data,omitempty"`
	Message   string          `json:"message,omitempty"`
}

// VerifySignature verifies the webhook signature using HMAC-SHA256
func VerifySignature(payload []byte, signature, secret string) bool {
	if !strings.HasPrefix(signature, "sha256=") {
		return false
	}

	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write(payload)
	expected := hex.EncodeToString(mac.Sum(nil))
	received := signature[7:] // Remove "sha256=" prefix

	return hmac.Equal([]byte(received), []byte(expected))
}

func webhookHandler(w http.ResponseWriter, r *http.Request) {
	// Read the raw body
	body, err := io.ReadAll(r.Body)
	if err != nil {
		http.Error(w, "Failed to read body", http.StatusBadRequest)
		return
	}
	defer r.Body.Close()

	// Get signature and secret
	signature := r.Header.Get("X-Reevit-Signature")
	secret := os.Getenv("REEVIT_WEBHOOK_SECRET")

	// Verify signature (required in production)
	if secret != "" && !VerifySignature(body, signature, secret) {
		log.Println("[Webhook] Invalid signature")
		http.Error(w, "Invalid signature", http.StatusUnauthorized)
		return
	}

	// Parse the event
	var event WebhookPayload
	if err := json.Unmarshal(body, &event); err != nil {
		http.Error(w, "Invalid JSON", http.StatusBadRequest)
		return
	}

	log.Printf("[Webhook] Received: %s (%s)", event.Type, event.ID)

	// Handle different event types
	switch event.Type {
	// Test event
	case "reevit.webhook.test":
		log.Printf("[Webhook] Test received: %s", event.Message)

	// Payment events
	case "payment.succeeded":
		var data PaymentData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handlePaymentSucceeded(data)
		}

	case "payment.failed":
		var data PaymentData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handlePaymentFailed(data)
		}

	case "payment.refunded":
		var data PaymentData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handlePaymentRefunded(data)
		}

	case "payment.pending":
		var data PaymentData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			log.Printf("[Webhook] Payment pending: %s", data.ID)
		}

	// Subscription events
	case "subscription.created":
		var data SubscriptionData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handleSubscriptionCreated(data)
		}

	case "subscription.renewed":
		var data SubscriptionData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handleSubscriptionRenewed(data)
		}

	case "subscription.canceled":
		var data SubscriptionData
		if err := json.Unmarshal(event.Data, &data); err == nil {
			handleSubscriptionCanceled(data)
		}

	default:
		log.Printf("[Webhook] Unhandled event: %s", event.Type)
	}

	// Acknowledge receipt
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	json.NewEncoder(w).Encode(map[string]bool{"received": true})
}

// Payment handlers
func handlePaymentSucceeded(data PaymentData) {
	orderID := data.Metadata["order_id"]
	log.Printf("[Webhook] Payment succeeded: %s for order %s", data.ID, orderID)

	// TODO: Implement your business logic
	// - Update order status to "paid"
	// - Send confirmation email to customer
	// - Trigger fulfillment process
}

func handlePaymentFailed(data PaymentData) {
	log.Printf("[Webhook] Payment failed: %s", data.ID)

	// TODO: Implement your business logic
	// - Update order status to "payment_failed"
	// - Send notification to customer
	// - Allow retry
}

func handlePaymentRefunded(data PaymentData) {
	orderID := data.Metadata["order_id"]
	log.Printf("[Webhook] Payment refunded: %s for order %s", data.ID, orderID)

	// TODO: Implement your business logic
	// - Update order status to "refunded"
	// - Restore inventory if applicable
}

// Subscription handlers
func handleSubscriptionCreated(data SubscriptionData) {
	log.Printf("[Webhook] Subscription created: %s for customer %s", data.ID, data.CustomerID)

	// TODO: Implement your business logic
	// - Grant access to subscription features
	// - Send welcome email
}

func handleSubscriptionRenewed(data SubscriptionData) {
	log.Printf("[Webhook] Subscription renewed: %s", data.ID)

	// TODO: Implement your business logic
	// - Extend access period
	// - Send renewal confirmation
}

func handleSubscriptionCanceled(data SubscriptionData) {
	log.Printf("[Webhook] Subscription canceled: %s", data.ID)

	// TODO: Implement your business logic
	// - Revoke access at end of billing period
	// - Send cancellation confirmation
}

func main() {
	http.HandleFunc("/webhooks/reevit", webhookHandler)
	log.Println("Webhook server listening on :8080")
	log.Fatal(http.ListenAndServe(":8080", nil))
}
Using the webhooks Subpackage

For convenience, use the webhooks subpackage:

import "github.com/Reevit-Platform/go-sdk/webhooks"

// Verify signature
isValid := webhooks.VerifySignature(body, signature, secret)

Supported PSPs

Provider Countries Payment Methods
Paystack NG, GH, ZA, KE Card, Mobile Money, Bank Transfer
Flutterwave NG, GH, KE, ZA + Card, Mobile Money, Bank Transfer
Hubtel GH Mobile Money
Stripe Global (50+) Card, Apple Pay, Google Pay
Monnify NG Card, Bank Transfer, USSD
M-Pesa KE, TZ Mobile Money (STK Push)

Environment Variables

export REEVIT_API_KEY=pfk_live_xxx
export REEVIT_ORG_ID=org_xxx
export REEVIT_WEBHOOK_SECRET=whsec_xxx  # Get from Dashboard > Developers > Webhooks

Release Notes

v0.9.0
  • Added server-created checkout sessions
  • Version alignment across all Reevit SDKs
  • Updated documentation and webhook examples
  • Added support for Apple Pay and Google Pay
  • Updated supported PSPs and payment methods documentation
v0.3.0
  • Updated API client to connect to production and sandbox URLs based on API key
  • Added Bearer authentication headers for secure API communication
  • Added Get, Confirm, and Cancel methods to the payments service
  • Removed orgID parameter from client initialization (simplified API)
  • Added .gitignore file to exclude unnecessary files from version control
  • Updated README.md with corrected quick start example

Support

License

MIT License - see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIdempotencyKey added in v0.9.1

func GenerateIdempotencyKey(params map[string]any) string

GenerateIdempotencyKey creates a deterministic idempotency key from input parameters. It uses a stable key ordering and a 5-minute time bucket (matching JS SDK behavior).

Types

type APIError

type APIError struct {
	StatusCode int
	Code       string
	Message    string
	Details    map[string]interface{}
}

APIError represents a Reevit API error.

func (*APIError) Error

func (e *APIError) Error() string

type CheckoutSession added in v0.9.1

type CheckoutSession struct {
	ID            string    `json:"id"`
	ClientSecret  string    `json:"client_secret"`
	SessionSecret string    `json:"session_secret"`
	PaymentIntent *Payment  `json:"payment_intent"`
	ExpiresAt     time.Time `json:"expires_at"`
}

CheckoutSession represents a server-created checkout session.

type CheckoutSessionsService added in v0.9.1

type CheckoutSessionsService service

CheckoutSessionsService handles server-created checkout sessions for browser SDKs.

func (*CheckoutSessionsService) Create added in v0.9.1

Create creates a checkout session that can be handed to browser SDKs.

API Docs: POST /v1/checkout/sessions

type Client

type Client struct {

	// Services
	Payments         *PaymentsService
	Connections      *ConnectionsService
	Subscriptions    *SubscriptionsService
	Fraud            *FraudService
	Customers        *CustomersService
	PaymentLinks     *PaymentLinksService
	CheckoutSessions *CheckoutSessionsService
	Webhooks         *WebhooksService
	RoutingRules     *RoutingRulesService
	Invoices         *InvoicesService
	// contains filtered or unexported fields
}

Client is the Reevit API client.

func NewClient

func NewClient(apiKey, orgID string, opts ...Option) *Client

NewClient returns a new Reevit API client.

type Connection

type Connection struct {
	ID           string                 `json:"id"`
	Provider     string                 `json:"provider"`
	Mode         string                 `json:"mode"`
	Status       string                 `json:"status"`
	Capabilities map[string]interface{} `json:"capabilities"`
	RoutingHints *RoutingHints          `json:"routing_hints"`
	Labels       []string               `json:"labels"`
	CreatedAt    time.Time              `json:"created_at"`
	UpdatedAt    time.Time              `json:"updated_at"`
}

Connection represents a connection object.

type ConnectionAuditEntry added in v0.9.1

type ConnectionAuditEntry struct {
	ID        string                 `json:"id"`
	Action    string                 `json:"action"`
	ActorID   string                 `json:"actor_id"`
	ActorType string                 `json:"actor_type"`
	Metadata  map[string]interface{} `json:"metadata"`
	CreatedAt time.Time              `json:"created_at"`
}

ConnectionAuditEntry describes an audit trail item for a connection.

type ConnectionLabelsUpdate added in v0.9.1

type ConnectionLabelsUpdate struct {
	Labels []string `json:"labels"`
}

ConnectionLabelsUpdate updates the labels applied to a connection.

type ConnectionListOptions added in v0.9.1

type ConnectionListOptions struct {
	Limit    int
	Offset   int
	Provider string
	Mode     string
	Status   string
}

ConnectionListOptions contains filters for connection listing.

type ConnectionRequest

type ConnectionRequest struct {
	Provider     string                 `json:"provider"`
	Mode         string                 `json:"mode"`
	Credentials  map[string]interface{} `json:"credentials"`
	Capabilities map[string]interface{} `json:"capabilities,omitempty"`
	RoutingHints *RoutingHints          `json:"routing_hints,omitempty"`
	Labels       []string               `json:"labels,omitempty"`
}

ConnectionRequest represents a request to create a connection.

type ConnectionStatusUpdate added in v0.9.1

type ConnectionStatusUpdate struct {
	Status string `json:"status"`
}

ConnectionStatusUpdate updates a connection status.

type ConnectionsService

type ConnectionsService service

ConnectionsService handles communication with the connection related methods of the Reevit API.

func (*ConnectionsService) Create

Create creates a new connection.

API Docs: POST /v1/connections

func (*ConnectionsService) Delete added in v0.9.1

func (s *ConnectionsService) Delete(ctx context.Context, connectionID string, opts ...RequestOption) error

Delete removes a connection.

API Docs: DELETE /v1/connections/{id}

func (*ConnectionsService) Get added in v0.9.1

func (s *ConnectionsService) Get(ctx context.Context, connectionID string) (*Connection, error)

Get retrieves a connection by ID.

API Docs: GET /v1/connections/{id}

func (*ConnectionsService) List

List returns a list of connections.

API Docs: GET /v1/connections

func (*ConnectionsService) ListAudit added in v0.9.1

func (s *ConnectionsService) ListAudit(ctx context.Context, connectionID string, options ...ConnectionListOptions) ([]ConnectionAuditEntry, error)

ListAudit returns the audit history for a connection.

API Docs: GET /v1/connections/{id}/audit

func (*ConnectionsService) Test

Test tests a connection.

API Docs: POST /v1/connections/test

func (*ConnectionsService) UpdateLabels added in v0.9.1

func (s *ConnectionsService) UpdateLabels(ctx context.Context, connectionID string, req *ConnectionLabelsUpdate, opts ...RequestOption) (*Connection, error)

UpdateLabels updates connection labels.

API Docs: PATCH /v1/connections/{id}/labels

func (*ConnectionsService) UpdateStatus added in v0.9.1

func (s *ConnectionsService) UpdateStatus(ctx context.Context, connectionID string, req *ConnectionStatusUpdate, opts ...RequestOption) (*Connection, error)

UpdateStatus updates connection status.

API Docs: PATCH /v1/connections/{id}/status

func (*ConnectionsService) Validate added in v0.9.1

func (s *ConnectionsService) Validate(ctx context.Context, connectionID string, opts ...RequestOption) (*Connection, error)

Validate validates a connection configuration.

API Docs: POST /v1/connections/{id}/validate

type CreateCustomerRequest added in v0.9.1

type CreateCustomerRequest struct {
	ExternalID string                 `json:"external_id,omitempty"`
	Email      string                 `json:"email,omitempty"`
	Phone      string                 `json:"phone,omitempty"`
	Name       string                 `json:"name,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

CreateCustomerRequest represents a request to create a customer.

type CreatePaymentLinkRequest added in v0.9.1

type CreatePaymentLinkRequest struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Amount      int64                  `json:"amount"`
	Currency    string                 `json:"currency"`
	Reference   string                 `json:"reference,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

CreatePaymentLinkRequest represents a request to create a payment link.

type Customer added in v0.9.1

type Customer struct {
	ID         string                 `json:"id"`
	ExternalID string                 `json:"external_id"`
	Email      string                 `json:"email"`
	Phone      string                 `json:"phone"`
	Name       string                 `json:"name"`
	Metadata   map[string]interface{} `json:"metadata"`
	CreatedAt  time.Time              `json:"created_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
}

Customer represents a customer in Reevit.

type CustomerListOptions added in v0.9.1

type CustomerListOptions struct {
	Limit      int
	Offset     int
	Email      string
	ExternalID string
}

CustomerListOptions contains supported filters for customer listing.

type CustomersService added in v0.9.1

type CustomersService service

CustomersService handles communication with customer related methods of the Reevit API.

func (*CustomersService) Create added in v0.9.1

Create creates a new customer.

func (*CustomersService) Delete added in v0.9.1

func (s *CustomersService) Delete(ctx context.Context, customerID string, opts ...RequestOption) error

Delete removes a customer.

func (*CustomersService) Get added in v0.9.1

func (s *CustomersService) Get(ctx context.Context, customerID string) (*Customer, error)

Get fetches a customer by ID.

func (*CustomersService) List added in v0.9.1

func (s *CustomersService) List(ctx context.Context, options ...CustomerListOptions) ([]Customer, error)

List returns customers for the current org.

func (*CustomersService) ListPayments added in v0.9.1

func (s *CustomersService) ListPayments(ctx context.Context, customerID string, options ...PaginationOptions) ([]PaymentSummary, error)

ListPayments returns payment history for a customer.

func (*CustomersService) Lookup added in v0.9.1

func (s *CustomersService) Lookup(ctx context.Context, externalID string) (*Customer, error)

Lookup fetches a customer by external ID.

func (*CustomersService) Top added in v0.9.1

func (s *CustomersService) Top(ctx context.Context, options ...TopCustomersOptions) ([]Customer, error)

Top returns top customers by value or volume.

func (*CustomersService) Update added in v0.9.1

func (s *CustomersService) Update(ctx context.Context, customerID string, req *UpdateCustomerRequest, opts ...RequestOption) (*Customer, error)

Update updates a customer by ID.

type FraudPolicy

type FraudPolicy struct {
	Prefer               []string `json:"prefer"`
	MaxAmount            int64    `json:"max_amount"`
	BlockedBins          []string `json:"blocked_bins"`
	AllowedBins          []string `json:"allowed_bins"`
	VelocityMaxPerMinute int      `json:"velocity_max_per_minute"`
}

FraudPolicy represents the fraud policy configuration.

type FraudPolicyInput

type FraudPolicyInput struct {
	Prefer               []string `json:"prefer,omitempty"`
	MaxAmount            int64    `json:"max_amount,omitempty"`
	BlockedBins          []string `json:"blocked_bins,omitempty"`
	AllowedBins          []string `json:"allowed_bins,omitempty"`
	VelocityMaxPerMinute int      `json:"velocity_max_per_minute,omitempty"`
}

FraudPolicyInput represents the fraud policy configuration for a payment.

type FraudService

type FraudService service

FraudService handles communication with the fraud policy related methods of the Reevit API.

func (*FraudService) Get

func (s *FraudService) Get(ctx context.Context) (*FraudPolicy, error)

Get retrieves the current fraud policy.

API Docs: GET /v1/policies/fraud

func (*FraudService) Update

func (s *FraudService) Update(ctx context.Context, policy *FraudPolicy, opts ...RequestOption) (*FraudPolicy, error)

Update updates the fraud policy.

API Docs: POST /v1/policies/fraud

type Invoice added in v0.9.1

type Invoice struct {
	ID         string                 `json:"id"`
	CustomerID string                 `json:"customer_id"`
	Status     string                 `json:"status"`
	Amount     int64                  `json:"amount"`
	Currency   string                 `json:"currency"`
	DueDate    *time.Time             `json:"due_date"`
	Metadata   map[string]interface{} `json:"metadata"`
	CreatedAt  time.Time              `json:"created_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
}

Invoice represents an invoice resource.

type InvoiceListOptions added in v0.9.1

type InvoiceListOptions struct {
	Limit      int
	Offset     int
	Status     string
	CustomerID string
}

InvoiceListOptions contains supported list filters.

type InvoiceUpdateRequest added in v0.9.1

type InvoiceUpdateRequest struct {
	Status   string                 `json:"status,omitempty"`
	DueDate  string                 `json:"due_date,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

InvoiceUpdateRequest represents a partial invoice update payload.

type InvoicesService added in v0.9.1

type InvoicesService service

InvoicesService handles invoice related methods of the Reevit API.

func (*InvoicesService) Cancel added in v0.9.1

func (s *InvoicesService) Cancel(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Cancel cancels an invoice.

func (*InvoicesService) Get added in v0.9.1

func (s *InvoicesService) Get(ctx context.Context, invoiceID string) (*Invoice, error)

Get fetches an invoice by ID.

func (*InvoicesService) List added in v0.9.1

func (s *InvoicesService) List(ctx context.Context, options ...InvoiceListOptions) ([]Invoice, error)

List returns invoices for the current org.

func (*InvoicesService) Retry added in v0.9.1

func (s *InvoicesService) Retry(ctx context.Context, invoiceID string, opts ...RequestOption) (*Invoice, error)

Retry retries invoice collection.

func (*InvoicesService) Update added in v0.9.1

func (s *InvoicesService) Update(ctx context.Context, invoiceID string, req *InvoiceUpdateRequest, opts ...RequestOption) (*Invoice, error)

Update updates an invoice.

type Option

type Option func(*Client)

Option is a functional option for configuring the Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the base URL for the API.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the HTTP client used for requests.

type OutboundWebhook added in v0.9.1

type OutboundWebhook struct {
	ID           string    `json:"id"`
	EventID      string    `json:"event_id"`
	URL          string    `json:"url"`
	Status       string    `json:"status"`
	ResponseCode int       `json:"response_code"`
	AttemptCount int       `json:"attempt_count"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

OutboundWebhook represents an outbound webhook delivery.

type PaginationOptions added in v0.9.1

type PaginationOptions struct {
	Limit  int
	Offset int
}

PaginationOptions contains basic offset pagination filters.

type Payment

type Payment struct {
	ID            string                 `json:"id"`
	ConnectionID  string                 `json:"connection_id"`
	Provider      string                 `json:"provider"`
	ProviderRefID string                 `json:"provider_ref_id"`
	Method        string                 `json:"method"`
	Status        string                 `json:"status"`
	Amount        int64                  `json:"amount"`
	Currency      string                 `json:"currency"`
	FeeAmount     int64                  `json:"fee_amount"`
	FeeCurrency   string                 `json:"fee_currency"`
	NetAmount     int64                  `json:"net_amount"`
	CustomerID    string                 `json:"customer_id"`
	ClientSecret  string                 `json:"client_secret"`
	Metadata      map[string]interface{} `json:"metadata"`
	Route         []PaymentRouteAttempt  `json:"route"`
	Reference     string                 `json:"reference"`
	CreatedAt     time.Time              `json:"created_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
}

Payment represents a payment object.

type PaymentIntentRequest

type PaymentIntentRequest struct {
	Amount     int64                  `json:"amount"`
	Currency   string                 `json:"currency"`
	Method     string                 `json:"method"`
	Country    string                 `json:"country"`
	CustomerID string                 `json:"customer_id,omitempty"`
	Reference  string                 `json:"reference,omitempty"`
	Policy     *FraudPolicyInput      `json:"policy,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

PaymentIntentRequest represents a request to create a payment intent.

type PaymentIntentUpdateRequest added in v0.9.1

type PaymentIntentUpdateRequest struct {
	Amount   *int64                 `json:"amount,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

PaymentIntentUpdateRequest represents a partial update to a payment intent.

type PaymentLink struct {
	ID          string                 `json:"id"`
	Code        string                 `json:"code"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	URL         string                 `json:"url"`
	Status      string                 `json:"status"`
	Amount      int64                  `json:"amount"`
	Currency    string                 `json:"currency"`
	Metadata    map[string]interface{} `json:"metadata"`
	CreatedAt   time.Time              `json:"created_at"`
	UpdatedAt   time.Time              `json:"updated_at"`
}

PaymentLink represents a hosted payment link.

type PaymentLinkListOptions added in v0.9.1

type PaymentLinkListOptions struct {
	Limit  int
	Offset int
	Status string
}

PaymentLinkListOptions contains supported list filters.

type PaymentLinkStats added in v0.9.1

type PaymentLinkStats struct {
	Visits         int64   `json:"visits"`
	PaymentsCount  int64   `json:"payments_count"`
	TotalAmount    int64   `json:"total_amount"`
	ConversionRate float64 `json:"conversion_rate"`
}

PaymentLinkStats contains aggregate link performance data.

type PaymentLinksService added in v0.9.1

type PaymentLinksService service

PaymentLinksService handles communication with payment link related methods of the Reevit API.

func (*PaymentLinksService) Create added in v0.9.1

Create creates a payment link.

func (*PaymentLinksService) Delete added in v0.9.1

func (s *PaymentLinksService) Delete(ctx context.Context, paymentLinkID string, opts ...RequestOption) error

Delete removes a payment link.

func (*PaymentLinksService) Get added in v0.9.1

func (s *PaymentLinksService) Get(ctx context.Context, paymentLinkID string) (*PaymentLink, error)

Get fetches a payment link by ID.

func (*PaymentLinksService) GetByCode added in v0.9.1

func (s *PaymentLinksService) GetByCode(ctx context.Context, code string) (*PaymentLink, error)

GetByCode resolves a public payment link by code.

func (*PaymentLinksService) GetStats added in v0.9.1

func (s *PaymentLinksService) GetStats(ctx context.Context, paymentLinkID string) (*PaymentLinkStats, error)

GetStats returns aggregate stats for a payment link.

func (*PaymentLinksService) List added in v0.9.1

List returns payment links for the current org.

func (*PaymentLinksService) ListPayments added in v0.9.1

func (s *PaymentLinksService) ListPayments(ctx context.Context, paymentLinkID string, options ...PaginationOptions) ([]PaymentSummary, error)

ListPayments lists payments created from a payment link.

func (*PaymentLinksService) Update added in v0.9.1

func (s *PaymentLinksService) Update(ctx context.Context, paymentLinkID string, req *UpdatePaymentLinkRequest, opts ...RequestOption) (*PaymentLink, error)

Update updates a payment link.

type PaymentRouteAttempt

type PaymentRouteAttempt struct {
	ConnectionID string        `json:"connection_id"`
	Provider     string        `json:"provider"`
	Status       string        `json:"status"`
	Error        string        `json:"error"`
	Labels       []string      `json:"labels"`
	RoutingHints *RoutingHints `json:"routing_hints"`
}

PaymentRouteAttempt represents a routing attempt.

type PaymentStats added in v0.9.1

type PaymentStats struct {
	Count           int64                  `json:"count"`
	SuccessCount    int64                  `json:"success_count"`
	FailedCount     int64                  `json:"failed_count"`
	PendingCount    int64                  `json:"pending_count"`
	TotalAmount     int64                  `json:"total_amount"`
	FeeAmount       int64                  `json:"fee_amount"`
	NetAmount       int64                  `json:"net_amount"`
	Currency        string                 `json:"currency"`
	SuccessRate     float64                `json:"success_rate"`
	AverageLatency  float64                `json:"average_latency_ms"`
	AdditionalStats map[string]interface{} `json:"-"`
}

PaymentStats captures aggregated payment metrics.

type PaymentStatsOptions added in v0.9.1

type PaymentStatsOptions struct {
	From     string
	To       string
	Country  string
	Method   string
	Provider string
	Status   string
	Interval string
}

PaymentStatsOptions contains filters for payment stats queries.

type PaymentSummary

type PaymentSummary struct {
	ID           string                 `json:"id"`
	ConnectionID string                 `json:"connection_id"`
	Provider     string                 `json:"provider"`
	Method       string                 `json:"method"`
	Status       string                 `json:"status"`
	Amount       int64                  `json:"amount"`
	Currency     string                 `json:"currency"`
	FeeAmount    int64                  `json:"fee_amount"`
	FeeCurrency  string                 `json:"fee_currency"`
	NetAmount    int64                  `json:"net_amount"`
	CustomerID   string                 `json:"customer_id"`
	Metadata     map[string]interface{} `json:"metadata"`
	Reference    string                 `json:"reference"`
	CreatedAt    time.Time              `json:"created_at"`
}

PaymentSummary represents a summary of a payment object.

type PaymentsService

type PaymentsService service

PaymentsService handles communication with the payment related methods of the Reevit API.

func (*PaymentsService) Cancel

func (s *PaymentsService) Cancel(ctx context.Context, paymentID string, opts ...RequestOption) (*Payment, error)

Cancel cancels a payment.

API Docs: POST /v1/payments/{id}/cancel

func (*PaymentsService) Confirm

func (s *PaymentsService) Confirm(ctx context.Context, paymentID string, opts ...RequestOption) (*Payment, error)

Confirm confirms a payment after PSP callback.

API Docs: POST /v1/payments/{id}/confirm

func (*PaymentsService) ConfirmIntent added in v0.9.1

func (s *PaymentsService) ConfirmIntent(ctx context.Context, paymentID, clientSecret string, opts ...RequestOption) (*Payment, error)

ConfirmIntent confirms a payment intent using its client secret.

API Docs: POST /v1/payments/{id}/confirm-intent

func (*PaymentsService) CreateIntent

func (s *PaymentsService) CreateIntent(ctx context.Context, req *PaymentIntentRequest, opts ...RequestOption) (*Payment, error)

CreateIntent creates a new payment intent.

API Docs: POST /v1/payments/intents

func (*PaymentsService) Get

func (s *PaymentsService) Get(ctx context.Context, paymentID string) (*Payment, error)

Get retrieves a payment by ID.

API Docs: GET /v1/payments/{id}

func (*PaymentsService) GetStats added in v0.9.1

func (s *PaymentsService) GetStats(ctx context.Context, options *PaymentStatsOptions) (*PaymentStats, error)

GetStats returns aggregated payment stats.

API Docs: GET /v1/payments/stats

func (*PaymentsService) List

func (s *PaymentsService) List(ctx context.Context, limit, offset int) ([]PaymentSummary, error)

List returns a list of payments.

API Docs: GET /v1/payments

func (*PaymentsService) Refund added in v0.9.1

func (s *PaymentsService) Refund(ctx context.Context, paymentID string, req *RefundRequest, opts ...RequestOption) (*Refund, error)

Refund creates a refund for a payment.

API Docs: POST /v1/payments/{id}/refund

func (*PaymentsService) Retry added in v0.9.1

func (s *PaymentsService) Retry(ctx context.Context, paymentID string, opts ...RequestOption) (*Payment, error)

Retry retries a payment with the orchestration layer.

API Docs: POST /v1/payments/{id}/retry

func (*PaymentsService) UpdateIntent added in v0.9.1

func (s *PaymentsService) UpdateIntent(ctx context.Context, paymentID string, req *PaymentIntentUpdateRequest, opts ...RequestOption) (*Payment, error)

UpdateIntent updates a payment intent.

API Docs: PATCH /v1/payments/intents/{id}

type Refund added in v0.9.1

type Refund struct {
	ID        string    `json:"id"`
	PaymentID string    `json:"payment_id"`
	Status    string    `json:"status"`
	Amount    int64     `json:"amount"`
	Currency  string    `json:"currency"`
	Reason    string    `json:"reason"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Refund represents a refund record returned by the API.

type RefundRequest added in v0.9.1

type RefundRequest struct {
	Amount int64  `json:"amount,omitempty"`
	Reason string `json:"reason,omitempty"`
}

RefundRequest represents a payment refund request.

type RequestOption

type RequestOption func(*http.Request)

RequestOption is a functional option for configuring API requests.

func WithIdempotencyKey

func WithIdempotencyKey(key string) RequestOption

WithIdempotencyKey sets the idempotency key for the request.

type RoutingHints

type RoutingHints struct {
	CountryPreference []string          `json:"country_preference"`
	MethodBias        map[string]string `json:"method_bias"`
	FallbackOnly      bool              `json:"fallback_only"`
}

RoutingHints represents routing preferences.

type RoutingRule added in v0.9.1

type RoutingRule struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name"`
	Status     string                 `json:"status"`
	Priority   int                    `json:"priority"`
	Conditions map[string]interface{} `json:"conditions"`
	Action     map[string]interface{} `json:"action"`
	Metadata   map[string]interface{} `json:"metadata"`
	CreatedAt  time.Time              `json:"created_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
}

RoutingRule represents a routing rule resource.

type RoutingRuleCreateRequest added in v0.9.1

type RoutingRuleCreateRequest struct {
	Name       string                 `json:"name"`
	Status     string                 `json:"status,omitempty"`
	Priority   int                    `json:"priority,omitempty"`
	Conditions map[string]interface{} `json:"conditions,omitempty"`
	Action     map[string]interface{} `json:"action,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

RoutingRuleCreateRequest represents a routing rule create payload.

type RoutingRuleUpdateRequest added in v0.9.1

type RoutingRuleUpdateRequest struct {
	Name       string                 `json:"name,omitempty"`
	Status     string                 `json:"status,omitempty"`
	Priority   int                    `json:"priority,omitempty"`
	Conditions map[string]interface{} `json:"conditions,omitempty"`
	Action     map[string]interface{} `json:"action,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

RoutingRuleUpdateRequest represents a routing rule update payload.

type RoutingRulesService added in v0.9.1

type RoutingRulesService service

RoutingRulesService handles routing rule related methods of the Reevit API.

func (*RoutingRulesService) Create added in v0.9.1

Create creates a routing rule.

func (*RoutingRulesService) Delete added in v0.9.1

func (s *RoutingRulesService) Delete(ctx context.Context, ruleID string, opts ...RequestOption) error

Delete removes a routing rule.

func (*RoutingRulesService) Get added in v0.9.1

func (s *RoutingRulesService) Get(ctx context.Context, ruleID string) (*RoutingRule, error)

Get fetches a routing rule by ID.

func (*RoutingRulesService) List added in v0.9.1

List returns routing rules for the current org.

func (*RoutingRulesService) Update added in v0.9.1

Update updates a routing rule.

type Subscription

type Subscription struct {
	ID            string                 `json:"id"`
	OrgID         string                 `json:"org_id"`
	CustomerID    string                 `json:"customer_id"`
	PlanID        string                 `json:"plan_id"`
	Amount        int64                  `json:"amount"`
	Currency      string                 `json:"currency"`
	Method        string                 `json:"method"`
	Interval      string                 `json:"interval"`
	Status        string                 `json:"status"`
	NextRenewalAt time.Time              `json:"next_renewal_at"`
	Metadata      map[string]interface{} `json:"metadata"`
	CreatedAt     time.Time              `json:"created_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
}

Subscription represents a subscription object.

type SubscriptionListOptions added in v0.9.1

type SubscriptionListOptions struct {
	Limit      int
	Offset     int
	Status     string
	CustomerID string
	PlanID     string
}

SubscriptionListOptions contains list filters for subscriptions.

type SubscriptionRequest

type SubscriptionRequest struct {
	CustomerID string                 `json:"customer_id"`
	PlanID     string                 `json:"plan_id"`
	Amount     int64                  `json:"amount"`
	Currency   string                 `json:"currency"`
	Method     string                 `json:"method"`
	Interval   string                 `json:"interval"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

SubscriptionRequest represents a request to create a subscription.

type SubscriptionUpdateRequest added in v0.9.1

type SubscriptionUpdateRequest struct {
	PlanID   string                 `json:"plan_id,omitempty"`
	Method   string                 `json:"method,omitempty"`
	Interval string                 `json:"interval,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

SubscriptionUpdateRequest represents a partial update to a subscription.

type SubscriptionsService

type SubscriptionsService service

SubscriptionsService handles communication with the subscription related methods of the Reevit API.

func (*SubscriptionsService) Cancel added in v0.9.1

func (s *SubscriptionsService) Cancel(ctx context.Context, subscriptionID string, opts ...RequestOption) (*Subscription, error)

Cancel cancels a subscription.

API Docs: POST /v1/subscriptions/{id}/cancel

func (*SubscriptionsService) Create

Create creates a new subscription.

API Docs: POST /v1/subscriptions

func (*SubscriptionsService) Get added in v0.9.1

func (s *SubscriptionsService) Get(ctx context.Context, subscriptionID string) (*Subscription, error)

Get retrieves a subscription by ID.

API Docs: GET /v1/subscriptions/{id}

func (*SubscriptionsService) List

List returns a list of subscriptions.

API Docs: GET /v1/subscriptions

func (*SubscriptionsService) Resume added in v0.9.1

func (s *SubscriptionsService) Resume(ctx context.Context, subscriptionID string, opts ...RequestOption) (*Subscription, error)

Resume resumes a canceled subscription.

API Docs: POST /v1/subscriptions/{id}/resume

func (*SubscriptionsService) Update added in v0.9.1

func (s *SubscriptionsService) Update(ctx context.Context, subscriptionID string, req *SubscriptionUpdateRequest, opts ...RequestOption) (*Subscription, error)

Update updates a subscription.

API Docs: PATCH /v1/subscriptions/{id}

type TopCustomersOptions added in v0.9.1

type TopCustomersOptions struct {
	Limit    int
	Currency string
	Country  string
	From     string
	To       string
}

TopCustomersOptions contains filters for top customer queries.

type UpdateCustomerRequest added in v0.9.1

type UpdateCustomerRequest struct {
	ExternalID string                 `json:"external_id,omitempty"`
	Email      string                 `json:"email,omitempty"`
	Phone      string                 `json:"phone,omitempty"`
	Name       string                 `json:"name,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

UpdateCustomerRequest represents a partial customer update.

type UpdatePaymentLinkRequest added in v0.9.1

type UpdatePaymentLinkRequest struct {
	Name        string                 `json:"name,omitempty"`
	Description string                 `json:"description,omitempty"`
	Status      string                 `json:"status,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

UpdatePaymentLinkRequest represents a partial payment link update.

type WebhookConfig added in v0.9.1

type WebhookConfig struct {
	ID        string                 `json:"id"`
	URL       string                 `json:"url"`
	Status    string                 `json:"status"`
	Events    []string               `json:"events"`
	Metadata  map[string]interface{} `json:"metadata"`
	CreatedAt time.Time              `json:"created_at"`
	UpdatedAt time.Time              `json:"updated_at"`
}

WebhookConfig represents the org-level outbound webhook configuration.

type WebhookConfigRequest added in v0.9.1

type WebhookConfigRequest struct {
	URL      string                 `json:"url"`
	Events   []string               `json:"events,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

WebhookConfigRequest represents a webhook config upsert payload.

type WebhookEvent added in v0.9.1

type WebhookEvent struct {
	ID           string                 `json:"id"`
	Type         string                 `json:"type"`
	Status       string                 `json:"status"`
	AttemptCount int                    `json:"attempt_count"`
	Data         map[string]interface{} `json:"data"`
	CreatedAt    time.Time              `json:"created_at"`
}

WebhookEvent represents a recorded webhook event.

type WebhookEventListOptions added in v0.9.1

type WebhookEventListOptions struct {
	Limit  int
	Offset int
	Type   string
	Status string
}

WebhookEventListOptions contains filters for webhook event listing.

type WebhooksService added in v0.9.1

type WebhooksService service

WebhooksService handles communication with webhook related methods of the Reevit API.

func (*WebhooksService) DeleteConfig added in v0.9.1

func (s *WebhooksService) DeleteConfig(ctx context.Context, opts ...RequestOption) error

DeleteConfig removes the outbound webhook configuration.

func (*WebhooksService) GetConfig added in v0.9.1

func (s *WebhooksService) GetConfig(ctx context.Context) (*WebhookConfig, error)

GetConfig fetches the current outbound webhook configuration.

func (*WebhooksService) GetEvent added in v0.9.1

func (s *WebhooksService) GetEvent(ctx context.Context, eventID string) (*WebhookEvent, error)

GetEvent fetches a single webhook event.

func (*WebhooksService) GetOutbound added in v0.9.1

func (s *WebhooksService) GetOutbound(ctx context.Context, outboundID string) (*OutboundWebhook, error)

GetOutbound fetches a single outbound delivery.

func (*WebhooksService) ListEvents added in v0.9.1

func (s *WebhooksService) ListEvents(ctx context.Context, options ...WebhookEventListOptions) ([]WebhookEvent, error)

ListEvents returns recorded webhook events.

func (*WebhooksService) ListOutbound added in v0.9.1

func (s *WebhooksService) ListOutbound(ctx context.Context, options ...PaginationOptions) ([]OutboundWebhook, error)

ListOutbound returns outbound deliveries.

func (*WebhooksService) ReplayEvent added in v0.9.1

func (s *WebhooksService) ReplayEvent(ctx context.Context, eventID string, opts ...RequestOption) (map[string]interface{}, error)

ReplayEvent replays a recorded webhook event.

func (*WebhooksService) SendTest added in v0.9.1

func (s *WebhooksService) SendTest(ctx context.Context, opts ...RequestOption) (map[string]interface{}, error)

SendTest dispatches a test webhook.

func (*WebhooksService) UpsertConfig added in v0.9.1

func (s *WebhooksService) UpsertConfig(ctx context.Context, req *WebhookConfigRequest, opts ...RequestOption) (*WebhookConfig, error)

UpsertConfig creates or updates the outbound webhook configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL