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 ¶
- Variables
- type CheckoutRequest
- type PayPal
- func (p *PayPal) Capture(ctx context.Context, orderID string, zeroDecimal bool) (PayPalCapture, error)
- func (p *PayPal) CreateOrder(ctx context.Context, req CheckoutRequest, invoiceNumber string) (id, approve string, err error)
- func (p *PayPal) ParseWebhook(ctx context.Context, h http.Header, body []byte, webhookID string, ...) (PayPalCapture, error)
- type PayPalCapture
- type Stripe
- type StripePayment
Constants ¶
This section is empty.
Variables ¶
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.
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.