gateway

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package gateway talks to payment providers over plain HTTPS (no SDKs): Stripe Checkout and PayPal Orders v2. Both only report payments; the panel decides what a payment pays.

Index

Constants

This section is empty.

Variables

View Source
var ErrIgnored = errors.New("event ignored")

ErrIgnored means the webhook event is valid but not a completed payment.

Functions

This section is empty.

Types

type CheckoutRequest

type CheckoutRequest struct {
	InvoiceID, Description, Currency string
	Amount                           int64 // Ammonode amount
	ZeroDecimal                      bool  // Ammonode counts this currency in whole units
	SuccessURL, CancelURL            string
	CustomerEmail                    string
}

CheckoutRequest describes the invoice to pay.

type PayPal

type PayPal struct {
	ClientID, Secret string
	Sandbox          bool
	BaseURL          string // overrides the live/sandbox host (tests)
	Client           *http.Client
	// contains filtered or unexported fields
}

PayPal is a PayPal REST client (Orders v2).

func (*PayPal) Capture

func (p *PayPal) Capture(ctx context.Context, orderID string, zeroDecimal bool) (PayPalCapture, error)

Capture captures an approved order (idempotent on PayPal's side for an already-captured order).

func (*PayPal) CreateOrder

func (p *PayPal) CreateOrder(ctx context.Context, req CheckoutRequest, invoiceNumber string) (id, approve string, err error)

CreateOrder starts a PayPal order and returns its ID and the approval URL.

func (*PayPal) ParseWebhook

func (p *PayPal) ParseWebhook(ctx context.Context, h http.Header, body []byte, webhookID string, zeroDecimal bool) (PayPalCapture, error)

ParseWebhook verifies a PayPal webhook with PayPal's verification API and extracts a completed capture (PAYMENT.CAPTURE.COMPLETED).

type PayPalCapture

type PayPalCapture struct {
	InvoiceID string // custom_id
	Ref       string // capture ID
	Amount    int64
	Currency  string
}

PayPalCapture is a completed capture.

type Stripe

type Stripe struct {
	SecretKey string
	BaseURL   string // https://api.stripe.com (tests replace it)
	Client    *http.Client
}

Stripe is a Stripe API client.

func (*Stripe) CreateCheckout

func (s *Stripe) CreateCheckout(ctx context.Context, req CheckoutRequest) (id, redirect string, err error)

CreateCheckout starts a Stripe Checkout session and returns its ID and the URL to send the customer to.

type StripePayment

type StripePayment struct {
	InvoiceID string
	Ref       string // payment intent (or session) ID: unique per payment
	Amount    int64  // Ammonode amount
	Currency  string
}

StripePayment is a completed payment from a webhook.

func ParseStripeWebhook

func ParseStripeWebhook(body []byte, sigHeader, secret string, now time.Time, zeroDecimal bool) (StripePayment, error)

ParseStripeWebhook verifies the Stripe-Signature header (HMAC-SHA256 over "t.body", within tolerance) and extracts a completed Checkout payment.

Jump to

Keyboard shortcuts

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