virtual

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package virtual implements an in-memory gateway for development and tests.

It talks to nobody: payments live in a map, the payer is sent straight back to the callback URL, and the whole purchase/verify/refund cycle behaves like a real provider. Point your staging configuration at "virtual" and the rest of your code does not change.

Index

Constants

View Source
const (
	// TokenParam carries the payment token.
	TokenParam = "payvand_token"
	// StatusParam carries "OK" or "NOK".
	StatusParam = "payvand_status"
)

Callback parameters the virtual gateway returns the payer with.

View Source
const CardNumber = "603799******1234"

CardNumber is the masked PAN reported by every virtual payment.

View Source
const Name core.Name = "virtual"

Name is the registry name of this gateway.

Variables

This section is empty.

Functions

func WithDecline

func WithDecline(enabled bool) core.Option

WithDecline makes every payment come back declined.

func WithFailingVerify

func WithFailingVerify(enabled bool) core.Option

WithFailingVerify makes Gateway.Verify fail, so the caller's recovery path can be tested.

func WithRedirectURL

func WithRedirectURL(redirectURL string) core.Option

WithRedirectURL sends the payer to a page of your own instead of straight back to the callback URL, which is useful when you want to render a fake bank page in development.

Types

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway is the in-memory implementation of core.Gateway.

func New

func New(cfg core.Config, opts ...core.Option) (*Gateway, error)

New builds a virtual gateway. No credential is required.

func (*Gateway) Capabilities

func (g *Gateway) Capabilities() core.Capabilities

Capabilities reports what the virtual gateway offers, which is everything.

func (*Gateway) Inquiry

Inquiry reports the state of a recorded payment.

func (*Gateway) Name

func (g *Gateway) Name() core.Name

Name returns the gateway name.

func (*Gateway) ParseCallback

func (g *Gateway) ParseCallback(r *http.Request) (core.Callback, error)

ParseCallback reads the parameters the virtual redirect carries.

func (*Gateway) Purchase

Purchase records a payment and returns a redirect back to the callback URL.

func (*Gateway) Refund

Refund reverses a settled payment.

func (*Gateway) Verify

Verify settles a recorded payment.

Jump to

Keyboard shortcuts

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