Documentation
¶
Overview ¶
Package acppayment serves the ACP Delegated Payment API.
Delegated Payment tokenizes a credential for controlled use by the merchant's payment service provider under the request's Allowance. The stable specification currently supports card credentials.
Implement Provider and pass it to NewHandler. See the standalone example for an in-memory implementation.
Index ¶
- type APIVersion
- type AcceptLanguage
- type Address
- type Allowance
- type AllowanceReason
- type Authorization
- type ContentType
- type DelegatePaymentJSONRequestBody
- type DelegatePaymentParams
- type DelegatePaymentRequest
- type DelegatePaymentResponse
- type Handler
- type IdempotencyKey
- type Option
- type PaymentMethodCard
- type PaymentMethodCardCardNumberType
- type PaymentMethodCardChecksPerformed
- type PaymentMethodCardDisplayCardFundingType
- type PaymentMethodCardType
- type Provider
- type RequestId
- type RiskSignal
- type RiskSignalAction
- type RiskSignalType
- type Signature
- type Timestamp
- type UserAgent
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// City City or locality
City string `json:"city"`
// Country ISO-3166-1 alpha-2 country code
Country string `json:"country"`
// LineOne Street address line 1 (e.g., street and number)
LineOne string `json:"line_one"`
// LineTwo Street address line 2 (e.g., apartment, suite, unit)
LineTwo *string `json:"line_two,omitempty"`
// Name Full name of the person at this address
Name string `json:"name"`
// PostalCode ZIP or postal code
PostalCode string `json:"postal_code"`
// State State, province, or region
State string `json:"state"`
}
Address Physical address for billing or shipping purposes
type Allowance ¶
type Allowance struct {
// CheckoutSessionId Identifier of the checkout session this payment is for
CheckoutSessionId string `json:"checkout_session_id"`
// Currency ISO-4217 three-letter lowercase currency code (e.g., usd)
Currency string `json:"currency"`
// ExpiresAt ISO 8601 timestamp when this allowance expires
ExpiresAt time.Time `json:"expires_at"`
// MaxAmount Maximum charge amount in minor units (e.g. 100 cents for $1.00 or 100 for ¥100)
MaxAmount int `json:"max_amount"`
// MerchantId Unique identifier for the merchant authorized to use this token
MerchantId string `json:"merchant_id"`
// Reason Usage pattern for this allowance; currently only one_time is supported
Reason AllowanceReason `json:"reason"`
}
Allowance Constraints on how the delegated payment method can be used (amount limit, expiration, merchant)
type AllowanceReason ¶
type AllowanceReason string
AllowanceReason Usage pattern for this allowance; currently only one_time is supported
const (
OneTime AllowanceReason = "one_time"
)
Defines values for AllowanceReason.
func (AllowanceReason) Valid ¶
func (e AllowanceReason) Valid() bool
Valid indicates whether the value is a known member of the AllowanceReason enum.
type DelegatePaymentJSONRequestBody ¶
type DelegatePaymentJSONRequestBody = DelegatePaymentRequest
DelegatePaymentJSONRequestBody defines body for DelegatePayment for application/json ContentType.
type DelegatePaymentParams ¶
type DelegatePaymentParams struct {
// Authorization Bearer token for API authentication (e.g., Bearer sk_live_123)
Authorization Authorization `json:"Authorization"`
// ContentType Must be application/json
ContentType ContentType `json:"Content-Type"`
// AcceptLanguage Preferred language for response messages (e.g., en-US)
AcceptLanguage *AcceptLanguage `json:"Accept-Language,omitempty"`
// UserAgent Client application identifier
UserAgent *UserAgent `json:"User-Agent,omitempty"`
// IdempotencyKey Idempotency key. MUST be present on all POST requests. Opaque string, max 255 characters. UUID v4 recommended. Scoped to authenticated identity + endpoint.
IdempotencyKey IdempotencyKey `json:"Idempotency-Key"`
// RequestId Unique identifier for request tracking and debugging
RequestId *RequestId `json:"Request-Id,omitempty"`
// Signature Detached JSON signature for request verification
Signature *Signature `json:"Signature,omitempty"`
// Timestamp ISO 8601 timestamp for request timing validation
Timestamp *Timestamp `json:"Timestamp,omitempty"`
// APIVersion API version date in format YYYY-MM-DD (e.g., 2026-04-17)
APIVersion APIVersion `json:"API-Version"`
}
DelegatePaymentParams defines parameters for DelegatePayment.
type DelegatePaymentRequest ¶
type DelegatePaymentRequest struct {
// Allowance Constraints on how the payment method can be used
Allowance Allowance `json:"allowance"`
// BillingAddress Billing address associated with the payment method
BillingAddress *Address `json:"billing_address,omitempty"`
// Metadata Additional metadata for the request
Metadata map[string]string `json:"metadata"`
// PaymentMethod The card payment method to tokenize for delegated use
PaymentMethod PaymentMethodCard `json:"payment_method"`
// RiskSignals List of risk assessment signals from fraud detection
RiskSignals []RiskSignal `json:"risk_signals"`
}
DelegatePaymentRequest Request to tokenize a payment method for delegated use by a merchant
type DelegatePaymentResponse ¶
type DelegatePaymentResponse struct {
// Created ISO 8601 timestamp when the token was created
Created time.Time `json:"created"`
// Id Unique vault token identifier (vt_...)
Id string `json:"id"`
// Metadata Metadata echoed from the request plus system-added fields
Metadata map[string]string `json:"metadata"`
}
DelegatePaymentResponse Response containing the vault token identifier for the delegated payment method
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler exposes the delegate payment API over net/http.
func NewHandler ¶
func NewHandler(service Provider, authorizer acpauth.Authorizer, opts ...Option) *Handler
NewHandler returns a Handler that serves the ACP delegated payment API.
Example ¶
package main
import (
"context"
"errors"
"fmt"
"github.com/sumup/acp/acpauth"
"github.com/sumup/acp/acppayment"
)
type paymentProvider struct{}
func (paymentProvider) DelegatePayment(context.Context, acppayment.DelegatePaymentRequest) (*acppayment.DelegatePaymentResponse, error) {
return nil, errors.ErrUnsupported
}
func main() {
handler := acppayment.NewHandler(
paymentProvider{},
acpauth.StaticTokenAuthorizer("api_key_123"),
)
fmt.Printf("%T\n", handler)
}
Output: *acppayment.Handler
type Option ¶
type Option func(*config)
Option configures a Handler during construction.
func WithServeMux ¶
WithServeMux registers ACP payment routes on mux instead of creating a new http.ServeMux.
type PaymentMethodCard ¶
type PaymentMethodCard struct {
// CardNumberType Whether the number is a raw card number (fpan) or a network token
CardNumberType PaymentMethodCardCardNumberType `json:"card_number_type"`
// ChecksPerformed List of verification checks performed on the card
ChecksPerformed *[]PaymentMethodCardChecksPerformed `json:"checks_performed,omitempty"`
// Cryptogram Dynamic cryptogram for tokenized card transactions
Cryptogram *string `json:"cryptogram,omitempty"`
// Cvc Card verification code (3 or 4 digits)
Cvc *string `json:"cvc,omitempty"`
// DisplayBrand Card brand for display purposes (e.g., visa, mastercard)
DisplayBrand *string `json:"display_brand,omitempty"`
// DisplayCardFundingType Card funding type for display purposes
DisplayCardFundingType PaymentMethodCardDisplayCardFundingType `json:"display_card_funding_type"`
// DisplayLast4 Last 4 digits of card number for display purposes
DisplayLast4 *string `json:"display_last4,omitempty"`
// DisplayWalletType Digital wallet provider if card is from a wallet (e.g., Apple Pay, Google Pay)
DisplayWalletType *string `json:"display_wallet_type,omitempty"`
// EciValue Electronic Commerce Indicator for 3DS authentication status
EciValue *string `json:"eci_value,omitempty"`
// ExpMonth Two-digit expiration month (01-12)
ExpMonth *string `json:"exp_month,omitempty"`
// ExpYear Four-digit expiration year (e.g., 2026)
ExpYear *string `json:"exp_year,omitempty"`
// Iin Issuer Identification Number (first 6 digits of card)
Iin *string `json:"iin,omitempty"`
// Metadata Additional metadata about the payment method
Metadata map[string]string `json:"metadata"`
// Name Cardholder name as it appears on the card
Name *string `json:"name,omitempty"`
// Number network token or fallback fpan value
Number string `json:"number"`
// Type Payment method type, always 'card'
Type PaymentMethodCardType `json:"type"`
// Virtual Whether this is a virtual card number
Virtual *bool `json:"virtual,omitempty"`
}
PaymentMethodCard Card payment method details including card number, expiration, and verification data
type PaymentMethodCardCardNumberType ¶
type PaymentMethodCardCardNumberType string
PaymentMethodCardCardNumberType Whether the number is a raw card number (fpan) or a network token
const ( Fpan PaymentMethodCardCardNumberType = "fpan" NetworkToken PaymentMethodCardCardNumberType = "network_token" )
Defines values for PaymentMethodCardCardNumberType.
func (PaymentMethodCardCardNumberType) Valid ¶
func (e PaymentMethodCardCardNumberType) Valid() bool
Valid indicates whether the value is a known member of the PaymentMethodCardCardNumberType enum.
type PaymentMethodCardChecksPerformed ¶
type PaymentMethodCardChecksPerformed string
PaymentMethodCardChecksPerformed defines model for PaymentMethodCard.ChecksPerformed.
const ( Ani PaymentMethodCardChecksPerformed = "ani" Auth0 PaymentMethodCardChecksPerformed = "auth0" Avs PaymentMethodCardChecksPerformed = "avs" Cvv PaymentMethodCardChecksPerformed = "cvv" )
Defines values for PaymentMethodCardChecksPerformed.
func (PaymentMethodCardChecksPerformed) Valid ¶
func (e PaymentMethodCardChecksPerformed) Valid() bool
Valid indicates whether the value is a known member of the PaymentMethodCardChecksPerformed enum.
type PaymentMethodCardDisplayCardFundingType ¶
type PaymentMethodCardDisplayCardFundingType string
PaymentMethodCardDisplayCardFundingType Card funding type for display purposes
const ( Credit PaymentMethodCardDisplayCardFundingType = "credit" Debit PaymentMethodCardDisplayCardFundingType = "debit" Prepaid PaymentMethodCardDisplayCardFundingType = "prepaid" )
Defines values for PaymentMethodCardDisplayCardFundingType.
func (PaymentMethodCardDisplayCardFundingType) Valid ¶
func (e PaymentMethodCardDisplayCardFundingType) Valid() bool
Valid indicates whether the value is a known member of the PaymentMethodCardDisplayCardFundingType enum.
type PaymentMethodCardType ¶
type PaymentMethodCardType string
PaymentMethodCardType Payment method type, always 'card'
const (
Card PaymentMethodCardType = "card"
)
Defines values for PaymentMethodCardType.
func (PaymentMethodCardType) Valid ¶
func (e PaymentMethodCardType) Valid() bool
Valid indicates whether the value is a known member of the PaymentMethodCardType enum.
type Provider ¶
type Provider interface {
// DelegatePayment tokenizes the supplied payment method for later checkout completion.
DelegatePayment(ctx context.Context, req DelegatePaymentRequest) (*DelegatePaymentResponse, error)
}
Provider owns delegated payment tokenization.
type RiskSignal ¶
type RiskSignal struct {
// Action Recommended action based on risk assessment
Action RiskSignalAction `json:"action"`
// Score Risk score indicating severity level
Score int `json:"score"`
// Type Type of risk signal detected
Type RiskSignalType `json:"type"`
}
RiskSignal Fraud detection signal indicating detected risk patterns and recommended actions
type RiskSignalAction ¶
type RiskSignalAction string
RiskSignalAction Recommended action based on risk assessment
const ( Authorized RiskSignalAction = "authorized" Blocked RiskSignalAction = "blocked" ManualReview RiskSignalAction = "manual_review" )
Defines values for RiskSignalAction.
func (RiskSignalAction) Valid ¶
func (e RiskSignalAction) Valid() bool
Valid indicates whether the value is a known member of the RiskSignalAction enum.
type RiskSignalType ¶
type RiskSignalType string
RiskSignalType Type of risk signal detected
const (
CardTesting RiskSignalType = "card_testing"
)
Defines values for RiskSignalType.
func (RiskSignalType) Valid ¶
func (e RiskSignalType) Valid() bool
Valid indicates whether the value is a known member of the RiskSignalType enum.