44 lines
2.1 KiB
Go
44 lines
2.1 KiB
Go
package visamasterpay
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// ErrAlreadyPaid is returned when the order has already been paid out (or
|
|
// was paid by a concurrent request that won the race).
|
|
var ErrAlreadyPaid = errors.New("order already paid")
|
|
|
|
// ErrAmountExceedsMax is returned when the submitted amountTmt is above the
|
|
// admin-configured max amount (settings.MaxAmountUsd) converted at the
|
|
// current rate.
|
|
var ErrAmountExceedsMax = errors.New("amount exceeds the configured max amount")
|
|
|
|
// ErrPaymentNotFound is returned when a callback references a payment
|
|
// attempt id that doesn't exist.
|
|
var ErrPaymentNotFound = errors.New("payment attempt not found")
|
|
|
|
// ErrPaymentWindowClosed is returned when today is not a business day
|
|
// (Saturday/Sunday) - GBÜS/the bank does not process payouts on weekends.
|
|
var ErrPaymentWindowClosed = errors.New("payment window is closed on weekends")
|
|
|
|
type Repository interface {
|
|
// OwnerInfo returns the order's owner/branch so the handler can run
|
|
// rbac.GuardOrder without importing cards/visamaster.
|
|
OwnerInfo(ctx context.Context, orderID int64) (userID *int64, branchID int64, err error)
|
|
Quote(ctx context.Context, orderID int64) (PaymentQuoteDTO, error)
|
|
// Pay registers the payout with GBÜS and returns the hosted-payment-page
|
|
// URL - it does not know the final outcome yet, see HandleCallback.
|
|
Pay(ctx context.Context, orderID int64, dto PayOrderDTO) (PaymentInitResultDTO, error)
|
|
// HandleCallback verifies a payment attempt's real outcome with GBÜS
|
|
// (never trusting the callback request itself) and finalizes it.
|
|
HandleCallback(ctx context.Context, paymentID int64) (PaymentResultDTO, error)
|
|
// Status re-checks the order's latest payment attempt the same way
|
|
// HandleCallback does - for the frontend to call (authenticated,
|
|
// order-scoped) when it can't rely on GBÜS having redirected the
|
|
// browser back to the callback, e.g. the user closed the hosted
|
|
// payment page before the redirect fired. requestedBy is the caller,
|
|
// recorded on the payment log.
|
|
Status(ctx context.Context, orderID int64, requestedBy *int64) (PaymentResultDTO, error)
|
|
}
|