skus

package
v0.0.0-...-8a10f5f Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 77 Imported by: 0

README

Brave SKUs Service

Getting Started
  1. Begin with development setup steps 1 through 4 from the bat-go readme

  2. Bring up the SKUs containers locally with make docker-refresh-payment

  3. View container logs with docker logs grant-payment-refresh

  4. SKUs API will be available at localhost:3335

  5. Commit code and refresh the containers with docker restart grant-payment-refresh!

SKU Tokens

SKU Tokens represent cookie-like objects with domain specific caveats, new tokens can be created following the instructions in this readme

This is an example of one possible SKU token:

tokens:
  - id: "brave-together-paid sku token v1"
    version: 1
    location: "together.bsg.brave.software"
    first_party_caveats:
      - sku: "brave-together-paid"
      - price: 5
      - currency: "USD"
      - description: "One month paid subscription for Brave Together"
      - credential_type: "time-limited"
      - credential_valid_duration: "P1M"
      - payment_methods: ["stripe"]
Creating a Free Trial

Given the knowledge of a free trial SKU unlimited numbers of trials can be created. Care must be taken to keep free trial SKUs secret.

Certain SKU tokens do not have a price, and once users have created an order for them they may redeem credentials to access the related service. In this example, we will create a free trial order for Brave Talk:

Construct a POST request to /v1/orders with the following metadata

{
	"items": [{
		"sku": "MDAyOWxvY2F0aW9uIHRvZ2V0aGVyLmJzZy5icmF2ZS5zb2Z0d2FyZQowMDMwaWRlbnRpZmllciBicmF2ZS10b2dldGhlci1mcmVlIHNrdSB0b2tlbiB2MQowMDIwY2lkIHNrdT1icmF2ZS10b2dldGhlci1mcmVlCjAwMTBjaWQgcHJpY2U9MAowMDE1Y2lkIGN1cnJlbmN5PUJBVAowMDNjY2lkIGRlc2NyaXB0aW9uPU9uZSBtb250aCBmcmVlIHRyaWFsIGZvciBCcmF2ZSBUb2dldGhlcgowMDI1Y2lkIGNyZWRlbnRpYWxfdHlwZT10aW1lLWxpbWl0ZWQKMDAyNmNpZCBjcmVkZW50aWFsX3ZhbGlkX2R1cmF0aW9uPVAxTQowMDJmc2lnbmF0dXJlIGebBXoPnj06tvlJkPEDLp9nfWo6Wfc1Txj6jTlgxjrQCg==",
		"quantity": 1
	}]
}

Upon GET request to /v1/orders/:orderId, server will respond with:

{
	"id": "92aafa4b-da7e-46b1-99c1-e8d30b26bc0f",
	"createdAt": "2021-04-12T00:11:51.954386Z",
	"currency": "BAT",
	"updatedAt": "2021-04-12T00:11:51.954386Z",
	"totalPrice": "0",
	"merchantId": "brave.com",
	"location": "together.bsg.brave.software",
	"status": "paid",
	"items": [{
		"id": "0b573a13-3c3d-40b7-bdac-879c531d31fb",
		"orderId": "92aafa4b-da7e-46b1-99c1-e8d30b26bc0f",
		"sku": "brave-together-free",
		"createdAt": "2021-04-12T00:11:51.954386Z",
		"updatedAt": "2021-04-12T00:11:51.954386Z",
		"currency": "BAT",
		"quantity": 1,
		"price": "0",
		"subtotal": "0",
		"location": "together.bsg.brave.software",
		"description": "One month free trial for Brave Together",
		"type": "time-limited"
	}]
}

Because the status on this order is paid we may create and request credentials

Construct a POST request to /v1/orders/:orderId/credentials with the following metadata

{
	"itemId": <itemId>,
	"blindedCreds": [<Base64 Encoded Blinded Credentials>]
}

Server will respond with status 200 OK. To retrieve these credentials construct a GET request to /v1/orders/:orderId/credentials

Server will respond with the following payload:

[
  {
    "id": "0b573a13-3c3d-40b7-bdac-879c531d31fb",
    "orderId": "92aafa4b-da7e-46b1-99c1-e8d30b26bc0f",
    "issuedAt": "2021-04-12",
    "expiresAt": "2021-05-17",
    "token": "ZCtG5A8lvArgJtBOR4I4tfHmDsM+pBrb9STaa1k1qbOhGHaYO2HFA2MUvoJ9edGX"
  }
]
Creating a Paid Order

Similarly to a free order, we will submit a creation request, however we will include an email which will be needed for management of subscriptions

Construct a POST request to /v1/orders with the following metadata

{"items": [
{"sku": "MDAyOWxvY2F0aW9uIHRvZ2V0aGVyLmJzZy5icmF2ZS5zb2Z0d2FyZQowMDMwaWRlbnRpZmllciBicmF2ZS10b2dldGhlci1wYWlkIHNrdSB0b2tlbiB2MQowMDIwY2lkIHNrdT1icmF2ZS10b2dldGhlci1wYWlkCjAwMTBjaWQgcHJpY2U9NQowMDE1Y2lkIGN1cnJlbmN5PVVTRAowMDQzY2lkIGRlc2NyaXB0aW9uPU9uZSBtb250aCBwYWlkIHN1YnNjcmlwdGlvbiBmb3IgQnJhdmUgVG9nZXRoZXIKMDAyNWNpZCBjcmVkZW50aWFsX3R5cGU9dGltZS1saW1pdGVkCjAwMjZjaWQgY3JlZGVudGlhbF92YWxpZF9kdXJhdGlvbj1QMU0KMDAyZnNpZ25hdHVyZSDKLJ7NuuzP3KdmTdVnn0dI3JmIfNblQKmY+WBJOqnQJAo=", "quantity": 1}],
 "email": "customeremail@gmail.com"
}

Upon GET request to /v1/orders/:orderId, server will respond with:

{
	"id": "89ded3d9-55e1-4e26-bc18-228e76cf03ca",
	"createdAt": "2021-04-12T00:51:44.61976Z",
	"currency": "USD",
	"updatedAt": "2021-04-12T00:51:45.515351Z",
	"totalPrice": "5",
	"merchantId": "brave.com",
	"location": "together.bsg.brave.software",
	"status": "pending",
	"items": [{
		"id": "355ae321-0ceb-4698-9fed-158190da6fa4",
		"orderId": "89ded3d9-55e1-4e26-bc18-228e76cf03ca",
		"sku": "brave-together-paid",
		"createdAt": "2021-04-12T00:51:44.61976Z",
		"updatedAt": "2021-04-12T00:51:44.61976Z",
		"currency": "USD",
		"quantity": 1,
		"price": "5",
		"subtotal": "5",
		"location": "together.bsg.brave.software",
		"description": "One month paid subscription for Brave Together",
		"type": "time-limited"
	}],
	"stripeCheckoutSessionId": "cs_test_a1g0n8FWNT3ClB2p9shKlpchGTw7cDKQCOqLJ1dSBcRd9ZsLssrtDLbZgM"
}

Because this order is Stripe payable, we will receive a Stripe Checkout Session Id, this identifier can be used to fulfill the order via a credit card. For example if we construct the following sample script:

<html>

<head>
    <title>Buy cool new product</title>
    <script src="https://js.stripe.com/v3/"></script>
</head>

<body>
    <button id="checkout-button">Checkout</button>
    <script type="text/javascript">
        // Create an instance of the Stripe object with your publishable API key
        var stripe = Stripe('pk_test_51HlmudHof20bphG64WGsYJhhJ3OsgZw5DyVx5mM7PdW4K7gLJS5KoMiA624HEJIWXImp0DEj7nKg2x8l7nGT6zhk00dtatBliN');
        var checkoutButton = document.getElementById('checkout-button');
        checkoutButton.addEventListener('click', function () {
            // Create a new Checkout Session using the server-side endpoint you
            // created in step 3.
            return stripe.redirectToCheckout({ sessionId: 'cs_test_a1g0n8FWNT3ClB2p9shKlpchGTw7cDKQCOqLJ1dSBcRd9ZsLssrtDLbZgM' });
        });
    </script>
</body>

</html>

And host locally, we can redirect to a page similar to this:

Screen Shot 2021-04-11 at 9 18 10 PM

A credit card can then be entered, and upon successful payment, the corresponding order will become paid. Once paid, credentials may be created and requested as in the free trial.

Architecture

Documentation above refers to a general use of the payment service. In the context of Brave Talk, the order of various calls and the service making the call is outlined in the diagram below:

Screen Shot 2021-04-30 at 1 58 22 PM
Stripe Integration

For the stripe integration details refer to the diagram below with numbered interactions.

stripe integration diagram

Submitting a Receipt

In some circumstances it is desirable to submit a receipt for a particular order to prove it was paid, and have the skus service handle the validation of said receipt. Currently implemented there are two receipt providers of which SKUs is capable of validating payment was collected, android and ios.

curl -XPOST /v1/orders/<order_id>/submit-receipt -d '<base64 encoded json payload>'

The payload of the above call is a Base64 encoded string of a JSON document. Two examples follow:

{
    "type": "ios",
    "raw_receipt": "<vendor specific receipt string>",
    "package": "com.brave...", // android specific,
    "subscription_id": "brave-firewall-vpn-premium", // the sku string value of the subscription
}

The and example POST payload of the API call to submit receipt is the above json base64 encoded.

Submitting a Receipt

In some circumstances it is desirable to submit a receipt for a particular order to prove it was paid, and have the skus service handle the validation of said receipt. Currently implemented there are two receipt providers of which SKUs is capable of validating payment was collected, android and ios.

curl -XPOST /v1/orders/<order_id>/submit-receipt -d '<base64 encoded json payload>'

The payload of the above call is a Base64 encoded string of a JSON document. Two examples follow:

{
    "type": "ios",
    "raw_receipt": "<vendor specific receipt string>",
    "package": "com.brave...", // android specific,
    "subscription_id": "brave-firewall-vpn-premium", // the sku string value of the subscription
}

The and example POST payload of the API call to submit receipt is the above json base64 encoded.

Documentation

Overview

Package skus is a generated GoMock package.

Package skus is a generated GoMock package.

Index

Constants

View Source
const (
	// TODO(pavelb): Gradually replace it everywhere.
	//
	// OrderStatusCanceled - string literal used in db for canceled status
	OrderStatusCanceled = model.OrderStatusCanceled
	// OrderStatusPaid - string literal used in db for canceled status
	OrderStatusPaid = model.OrderStatusPaid
	// OrderStatusPending - string literal used in db for pending status
	OrderStatusPending = model.OrderStatusPending
)
View Source
const (
	// UserWalletVoteSKU - special vote sku to denote user wallet funding
	UserWalletVoteSKU string = "user-wallet-vote"
	// AnonCardVoteSKU - special vote sku to denote anon-card funding
	AnonCardVoteSKU = "anon-card-vote"
)

Variables

View Source
var (
	ErrOrderUnpaid                   = errors.New("order not paid")
	ErrOrderHasNoItems   model.Error = "order has no items"
	ErrCredsAlreadyExist model.Error = "credentials already exist"
)
View Source
var (
	// ErrInvalidSKUToken - the sku was invalid
	ErrInvalidSKUToken = errors.New("failed to validate sku token")
	// ErrInvalidSKUTokenSKU - the sku was invalid
	ErrInvalidSKUTokenSKU = fmt.Errorf("invalid sku in sku token: %w", ErrInvalidSKUToken)
	// ErrInvalidSKUTokenBadMerchant - the merchant in the sku is invalid
	ErrInvalidSKUTokenBadMerchant = fmt.Errorf("invalid merchant id in sku token: %w", ErrInvalidSKUToken)
)
View Source
var (
	// EncryptionKey for encrypting secrets.
	EncryptionKey = os.Getenv("ENCRYPTION_KEY")
)

Functions

func CancelOrder

func CancelOrder(service *Service) handlers.AppHandler

CancelOrder handles requests for cancelling orders.

func CreateAnonCardTransaction

func CreateAnonCardTransaction(service *Service) handlers.AppHandler

CreateAnonCardTransaction creates a transaction against an order

func CreateGeminiTransaction

func CreateGeminiTransaction(service *Service) handlers.AppHandler

CreateGeminiTransaction creates a transaction against an order

func CreateKey

func CreateKey(service *Service) handlers.AppHandler

CreateKey is the handler for creating keys for a merchant

func CreateOrderCreds

func CreateOrderCreds(svc *Service) handlers.AppHandler

CreateOrderCreds handles requests for creating credentials.

func CreateUpholdTransaction

func CreateUpholdTransaction(service *Service) handlers.AppHandler

CreateUpholdTransaction creates a transaction against an order

func CredentialRouter

func CredentialRouter(svc *Service, authMwr middlewareFn) chi.Router

CredentialRouter handles requests to /v1/credentials.

func CredentialV2Router

func CredentialV2Router(svc *Service, authMwr middlewareFn) chi.Router

CredentialV2Router handles requests to /v2/credentials.

func DeleteKey

func DeleteKey(service *Service) handlers.AppHandler

DeleteKey deletes a key

func DeleteOrderCreds

func DeleteOrderCreds(service *Service) handlers.AppHandler

DeleteOrderCreds handles requests for deleting order credentials.

func GenerateSecret

func GenerateSecret() (secret string, nonce string, err error)

GenerateSecret creates a random key for merchants

func GetKeys

func GetKeys(service *Service) handlers.AppHandler

GetKeys returns all keys for a specified merchant

func GetOrder

func GetOrder(service *Service) handlers.AppHandler

GetOrder is the handler for getting an order

func GetOrderCreds

func GetOrderCreds(service *Service) handlers.AppHandler

GetOrderCreds is the handler for fetching all order credentials associated with an order. This endpoint handles the retrieval of all order credential types i.e. single-use, time-limited and time-limited-v2.

func GetTransactions

func GetTransactions(service *Service) handlers.AppHandler

GetTransactions is the handler for listing the transactions for an order

func HandleAndroidWebhook

func HandleAndroidWebhook(service *Service) handlers.AppHandler

HandleAndroidWebhook is the handler for the Google Playstore webhooks

func HandleRadomWebhook

func HandleRadomWebhook(service *Service) handlers.AppHandler

HandleRadomWebhook handles Radom checkout session webhooks.

func InitEncryptionKeys

func InitEncryptionKeys()

InitEncryptionKeys copies the specified encryption key into memory once

func MakeVote

func MakeVote(service *Service) handlers.AppHandler

MakeVote is the handler for making a vote using credentials

func MerchantRouter

func MerchantRouter(service *Service) chi.Router

MerchantRouter handles calls made for the merchant

func MerchantTransactions

func MerchantTransactions(service *Service) handlers.AppHandler

MerchantTransactions is the handler for getting paginated merchant transactions

func NewAuthMwr

func NewAuthMwr(ks httpsignature.Keystore) func(http.Handler) http.Handler

NewAuthMwr returns a handler that authorises requests via http signature or simple tokens.

func NewCORSMwr

func NewCORSMwr(opts cors.Options, methods ...string) func(next http.Handler) http.Handler

func NewCORSOpts

func NewCORSOpts(origins []string, dbg bool) cors.Options

func Router

func Router(
	svc *Service,
	authMwr middlewareFn,
	metricsMwr middleware.InstrumentHandlerDef,
	copts cors.Options,
) chi.Router

func VerifyCredentialV1

func VerifyCredentialV1(service *Service) handlers.AppHandler

VerifyCredentialV1 is the handler for verifying subscription credentials

func VerifyCredentialV2

func VerifyCredentialV2(service *Service) handlers.AppHandler

VerifyCredentialV2 - version 2 of verify credential

func VoteRouter

func VoteRouter(service *Service, instrumentHandler middleware.InstrumentHandlerDef) chi.Router

VoteRouter for voting endpoint

func WebhookRouter

func WebhookRouter(service *Service) chi.Router

WebhookRouter - handles calls from various payment method webhooks informing payments of completion

Types

type AndroidNotification

type AndroidNotification struct {
	Message      AndroidNotificationMessage `json:"message" valid:"-"`
	Subscription string                     `json:"subscription" valid:"-"`
}

AndroidNotification - wrapping structure of an android notification

func (*AndroidNotification) Decode

func (an *AndroidNotification) Decode(ctx context.Context, data []byte) error

Decode - implement Decodable interface

func (*AndroidNotification) Validate

func (an *AndroidNotification) Validate(ctx context.Context) error

Validate - implement Validable interface

type AndroidNotificationMessage

type AndroidNotificationMessage struct {
	Attributes AndroidNotificationMessageAttrs `json:"attributes" valid:"-"`
	Data       string                          `json:"data" valid:"base64"`
	MessageID  string                          `json:"messageId" valid:"-"`
}

AndroidNotificationMessage - wrapping structure of an android notification

func (*AndroidNotificationMessage) Decode

func (anm *AndroidNotificationMessage) Decode(ctx context.Context, data []byte) error

Decode - implement Decodable interface

func (*AndroidNotificationMessage) GetDeveloperNotification

func (anm *AndroidNotificationMessage) GetDeveloperNotification() (*DeveloperNotification, error)

GetDeveloperNotification - Extract the developer notification from the android notification message

func (*AndroidNotificationMessage) Validate

func (anm *AndroidNotificationMessage) Validate(ctx context.Context) error

Validate - implement Validatable interface

type AndroidNotificationMessageAttrs

type AndroidNotificationMessageAttrs map[string]string

AndroidNotificationMessageAttrs - attributes of a notification message

type AreTimeLimitedV2CredsSubmittedResult

type AreTimeLimitedV2CredsSubmittedResult struct {
	AlreadySubmitted bool `db:"already_submitted"`
	Mismatch         bool `db:"mismatch"`
}

type CreateAnonCardTransactionRequest

type CreateAnonCardTransactionRequest struct {
	WalletID    uuid.UUID `json:"paymentId"`
	Transaction string    `json:"transaction"`
}

CreateAnonCardTransactionRequest includes information needed to create a anon card transaction

type CreateKeyRequest

type CreateKeyRequest struct {
	Name string `json:"name" valid:"required"`
}

CreateKeyRequest includes information needed to create a key

type CreateKeyResponse

type CreateKeyResponse struct {
	*Key
	SecretKey string `json:"secretKey"`
}

CreateKeyResponse includes information about the created key

type CreateOrderCredsRequest

type CreateOrderCredsRequest struct {
	ItemID       uuid.UUID `json:"itemId" valid:"-"`
	BlindedCreds []string  `json:"blindedCreds" valid:"base64"`
}

CreateOrderCredsRequest includes the item ID and blinded credentials which to be signed.

type CreateTransactionRequest

type CreateTransactionRequest struct {
	ExternalTransactionID string `json:"externalTransactionId" valid:"required,uuid"`
}

CreateTransactionRequest includes information needed to create a transaction

type CredentialBinding

type CredentialBinding struct {
	PublicKey     string `json:"publicKey" valid:"base64"`
	TokenPreimage string `json:"t" valid:"base64"`
	Signature     string `json:"signature" valid:"base64"`
}

CredentialBinding includes info needed to redeem a single credential

type Datastore

type Datastore interface {
	datastore.Datastore

	CreateOrder(ctx context.Context, dbi sqlx.ExtContext, oreq *model.OrderNew, items []model.OrderItem) (*model.Order, error)
	// SetOrderTrialDays - set the number of days of free trial for this order
	SetOrderTrialDays(ctx context.Context, orderID *uuid.UUID, days int64) (*Order, error)
	// GetOrder by ID
	GetOrder(orderID uuid.UUID) (*Order, error)
	// GetOrderByExternalID by the external id from the purchase vendor
	GetOrderByExternalID(externalID string) (*Order, error)
	// UpdateOrder updates an order when it has been paid
	UpdateOrder(orderID uuid.UUID, status string) error
	// UpdateOrderMetadata adds a key value pair to an order's metadata
	UpdateOrderMetadata(orderID uuid.UUID, key string, value string) error
	// CreateTransaction creates a transaction
	CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error)
	// UpdateTransaction creates a transaction
	UpdateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error)
	// GetTransaction returns a transaction given an external transaction id
	GetTransaction(externalTransactionID string) (*Transaction, error)
	// GetTransactions returns all the transactions for a specific order
	GetTransactions(orderID uuid.UUID) (*[]Transaction, error)
	// GetPagedMerchantTransactions returns all the transactions for a specific order
	GetPagedMerchantTransactions(ctx context.Context, merchantID uuid.UUID, pagination *inputs.Pagination) (*[]Transaction, int, error)
	// GetSumForTransactions gets a decimal sum of for transactions for an order
	GetSumForTransactions(orderID uuid.UUID) (decimal.Decimal, error)

	GetIssuerByPublicKey(publicKey string) (*Issuer, error)
	DeleteSingleUseOrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID, isSigned bool) error
	// GetOrderCredsByItemID retrieves an order credential by item id
	GetOrderCredsByItemID(orderID uuid.UUID, itemID uuid.UUID, isSigned bool) (*OrderCreds, error)
	GetKeysByMerchant(merchant string, showExpired bool) (*[]Key, error)
	GetKey(id uuid.UUID, showExpired bool) (*Key, error)
	CreateKey(merchant string, name string, encryptedSecretKey string, nonce string) (*Key, error)
	DeleteKey(id uuid.UUID, delaySeconds int) (*Key, error)
	GetUncommittedVotesForUpdate(ctx context.Context) (*sqlx.Tx, []*VoteRecord, error)
	CommitVote(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error
	MarkVoteErrored(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error
	InsertVote(ctx context.Context, vr VoteRecord) error
	CheckExpiredCheckoutSession(uuid.UUID) (bool, string, error)
	IsStripeSub(uuid.UUID) (bool, string, error)
	GetOrderItem(ctx context.Context, itemID uuid.UUID) (*OrderItem, error)
	InsertOrderCredsTx(ctx context.Context, tx *sqlx.Tx, creds *OrderCreds) error
	GetOrderCreds(orderID uuid.UUID, isSigned bool) ([]OrderCreds, error)
	SendSigningRequest(ctx context.Context, signingRequestWriter SigningRequestWriter) error
	InsertSignedOrderCredentialsTx(ctx context.Context, tx *sqlx.Tx, signedOrderResult *SigningOrderResult) error
	AreTimeLimitedV2CredsSubmitted(ctx context.Context, requestID uuid.UUID, blindedCreds ...string) (AreTimeLimitedV2CredsSubmittedResult, error)
	GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (*TimeLimitedV2Creds, error)
	GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID uuid.UUID) (*TimeLimitedV2Creds, error)
	DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error
	GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (*TimeLimitedV2Creds, error)
	InsertTimeLimitedV2OrderCredsTx(ctx context.Context, tx *sqlx.Tx, tlv2 TimeAwareSubIssuedCreds) error
	InsertSigningOrderRequestOutbox(ctx context.Context, requestID uuid.UUID, orderID uuid.UUID, itemID uuid.UUID, signingOrderRequest SigningOrderRequest) error
	GetSigningOrderRequestOutboxByRequestID(ctx context.Context, dbi sqlx.QueryerContext, reqID uuid.UUID) (*SigningOrderRequestOutbox, error)
	GetSigningOrderRequestOutboxByOrder(ctx context.Context, orderID uuid.UUID) ([]SigningOrderRequestOutbox, error)
	GetSigningOrderRequestOutboxByOrderItem(ctx context.Context, itemID uuid.UUID) ([]SigningOrderRequestOutbox, error)
	DeleteSigningOrderRequestOutboxByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error
	UpdateSigningOrderRequestOutboxTx(ctx context.Context, tx *sqlx.Tx, requestID uuid.UUID, completedAt time.Time) error
	SetOrderPaid(context.Context, *uuid.UUID) error
	AppendOrderMetadata(context.Context, *uuid.UUID, string, string) error
	AppendOrderMetadataInt(context.Context, *uuid.UUID, string, int) error
	AppendOrderMetadataInt64(context.Context, *uuid.UUID, string, int64) error
	GetOutboxMovAvgDurationSeconds() (int64, error)
}

Datastore abstracts over the underlying datastore.

func NewPostgres

func NewPostgres(
	orderRepo orderStore,
	orderItemRepo orderItemStore,
	orderPayHistory orderPayHistoryStore,
	issuerRepo issuerStore,
	databaseURL string,
	performMigration bool,
	migrationTrack string,
	dbStatsPrefix ...string,
) (Datastore, error)

NewPostgres creates a new Postgres Datastore.

type DatastoreWithPrometheus

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

DatastoreWithPrometheus implements Datastore interface with all methods wrapped with Prometheus metrics

func NewDatastoreWithPrometheus

func NewDatastoreWithPrometheus(base Datastore, instanceName string) DatastoreWithPrometheus

NewDatastoreWithPrometheus returns an instance of the Datastore decorated with prometheus summary metric

func (DatastoreWithPrometheus) AppendOrderMetadata

func (_d DatastoreWithPrometheus) AppendOrderMetadata(ctx context.Context, up1 *uuid.UUID, s1 string, s2 string) (err error)

AppendOrderMetadata implements Datastore

func (DatastoreWithPrometheus) AppendOrderMetadataInt

func (_d DatastoreWithPrometheus) AppendOrderMetadataInt(ctx context.Context, up1 *uuid.UUID, s1 string, i1 int) (err error)

AppendOrderMetadataInt implements Datastore

func (DatastoreWithPrometheus) AppendOrderMetadataInt64

func (_d DatastoreWithPrometheus) AppendOrderMetadataInt64(ctx context.Context, up1 *uuid.UUID, s1 string, i1 int64) (err error)

AppendOrderMetadataInt64 implements Datastore

func (DatastoreWithPrometheus) AreTimeLimitedV2CredsSubmitted

func (_d DatastoreWithPrometheus) AreTimeLimitedV2CredsSubmitted(ctx context.Context, requestID uuid.UUID, blindedCreds ...string) (a1 AreTimeLimitedV2CredsSubmittedResult, err error)

AreTimeLimitedV2CredsSubmitted implements Datastore

func (DatastoreWithPrometheus) BeginTx

func (_d DatastoreWithPrometheus) BeginTx() (tp1 *sqlx.Tx, err error)

BeginTx implements Datastore

func (DatastoreWithPrometheus) CheckExpiredCheckoutSession

func (_d DatastoreWithPrometheus) CheckExpiredCheckoutSession(u1 uuid.UUID) (b1 bool, s1 string, err error)

CheckExpiredCheckoutSession implements Datastore

func (DatastoreWithPrometheus) CommitVote

func (_d DatastoreWithPrometheus) CommitVote(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) (err error)

CommitVote implements Datastore

func (DatastoreWithPrometheus) CreateKey

func (_d DatastoreWithPrometheus) CreateKey(merchant string, name string, encryptedSecretKey string, nonce string) (kp1 *Key, err error)

CreateKey implements Datastore

func (DatastoreWithPrometheus) CreateOrder

func (_d DatastoreWithPrometheus) CreateOrder(ctx context.Context, dbi sqlx.ExtContext, oreq *model.OrderNew, items []model.OrderItem) (op1 *model.Order, err error)

CreateOrder implements Datastore

func (DatastoreWithPrometheus) CreateTransaction

func (_d DatastoreWithPrometheus) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (tp1 *Transaction, err error)

CreateTransaction implements Datastore

func (DatastoreWithPrometheus) DeleteKey

func (_d DatastoreWithPrometheus) DeleteKey(id uuid.UUID, delaySeconds int) (kp1 *Key, err error)

DeleteKey implements Datastore

func (DatastoreWithPrometheus) DeleteSigningOrderRequestOutboxByOrderTx

func (_d DatastoreWithPrometheus) DeleteSigningOrderRequestOutboxByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) (err error)

DeleteSigningOrderRequestOutboxByOrderTx implements Datastore

func (DatastoreWithPrometheus) DeleteSingleUseOrderCredsByOrderTx

func (_d DatastoreWithPrometheus) DeleteSingleUseOrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID, isSigned bool) (err error)

DeleteSingleUseOrderCredsByOrderTx implements Datastore

func (DatastoreWithPrometheus) DeleteTimeLimitedV2OrderCredsByOrderTx

func (_d DatastoreWithPrometheus) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) (err error)

DeleteTimeLimitedV2OrderCredsByOrderTx implements Datastore

func (DatastoreWithPrometheus) GetIssuerByPublicKey

func (_d DatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error)

GetIssuerByPublicKey implements Datastore

func (DatastoreWithPrometheus) GetKey

func (_d DatastoreWithPrometheus) GetKey(id uuid.UUID, showExpired bool) (kp1 *Key, err error)

GetKey implements Datastore

func (DatastoreWithPrometheus) GetKeysByMerchant

func (_d DatastoreWithPrometheus) GetKeysByMerchant(merchant string, showExpired bool) (kap1 *[]Key, err error)

GetKeysByMerchant implements Datastore

func (DatastoreWithPrometheus) GetOrder

func (_d DatastoreWithPrometheus) GetOrder(orderID uuid.UUID) (op1 *Order, err error)

GetOrder implements Datastore

func (DatastoreWithPrometheus) GetOrderByExternalID

func (_d DatastoreWithPrometheus) GetOrderByExternalID(externalID string) (op1 *Order, err error)

GetOrderByExternalID implements Datastore

func (DatastoreWithPrometheus) GetOrderCreds

func (_d DatastoreWithPrometheus) GetOrderCreds(orderID uuid.UUID, isSigned bool) (oa1 []OrderCreds, err error)

GetOrderCreds implements Datastore

func (DatastoreWithPrometheus) GetOrderCredsByItemID

func (_d DatastoreWithPrometheus) GetOrderCredsByItemID(orderID uuid.UUID, itemID uuid.UUID, isSigned bool) (op1 *OrderCreds, err error)

GetOrderCredsByItemID implements Datastore

func (DatastoreWithPrometheus) GetOrderItem

func (_d DatastoreWithPrometheus) GetOrderItem(ctx context.Context, itemID uuid.UUID) (op1 *OrderItem, err error)

GetOrderItem implements Datastore

func (DatastoreWithPrometheus) GetOutboxMovAvgDurationSeconds

func (_d DatastoreWithPrometheus) GetOutboxMovAvgDurationSeconds() (i1 int64, err error)

GetOutboxMovAvgDurationSeconds implements Datastore

func (DatastoreWithPrometheus) GetPagedMerchantTransactions

func (_d DatastoreWithPrometheus) GetPagedMerchantTransactions(ctx context.Context, merchantID uuid.UUID, pagination *inputs.Pagination) (tap1 *[]Transaction, i1 int, err error)

GetPagedMerchantTransactions implements Datastore

func (DatastoreWithPrometheus) GetSigningOrderRequestOutboxByOrder

func (_d DatastoreWithPrometheus) GetSigningOrderRequestOutboxByOrder(ctx context.Context, orderID uuid.UUID) (sa1 []SigningOrderRequestOutbox, err error)

GetSigningOrderRequestOutboxByOrder implements Datastore

func (DatastoreWithPrometheus) GetSigningOrderRequestOutboxByOrderItem

func (_d DatastoreWithPrometheus) GetSigningOrderRequestOutboxByOrderItem(ctx context.Context, itemID uuid.UUID) (sa1 []SigningOrderRequestOutbox, err error)

GetSigningOrderRequestOutboxByOrderItem implements Datastore

func (DatastoreWithPrometheus) GetSigningOrderRequestOutboxByRequestID

func (_d DatastoreWithPrometheus) GetSigningOrderRequestOutboxByRequestID(ctx context.Context, dbi sqlx.QueryerContext, reqID uuid.UUID) (sp1 *SigningOrderRequestOutbox, err error)

GetSigningOrderRequestOutboxByRequestID implements Datastore

func (DatastoreWithPrometheus) GetSumForTransactions

func (_d DatastoreWithPrometheus) GetSumForTransactions(orderID uuid.UUID) (d1 decimal.Decimal, err error)

GetSumForTransactions implements Datastore

func (DatastoreWithPrometheus) GetTLV2Creds

func (_d DatastoreWithPrometheus) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID uuid.UUID, itemID uuid.UUID, reqID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error)

GetTLV2Creds implements Datastore

func (DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrder

func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error)

GetTimeLimitedV2OrderCredsByOrder implements Datastore

func (DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrderItem

func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error)

GetTimeLimitedV2OrderCredsByOrderItem implements Datastore

func (DatastoreWithPrometheus) GetTransaction

func (_d DatastoreWithPrometheus) GetTransaction(externalTransactionID string) (tp1 *Transaction, err error)

GetTransaction implements Datastore

func (DatastoreWithPrometheus) GetTransactions

func (_d DatastoreWithPrometheus) GetTransactions(orderID uuid.UUID) (tap1 *[]Transaction, err error)

GetTransactions implements Datastore

func (DatastoreWithPrometheus) GetUncommittedVotesForUpdate

func (_d DatastoreWithPrometheus) GetUncommittedVotesForUpdate(ctx context.Context) (tp1 *sqlx.Tx, vpa1 []*VoteRecord, err error)

GetUncommittedVotesForUpdate implements Datastore

func (DatastoreWithPrometheus) InsertOrderCredsTx

func (_d DatastoreWithPrometheus) InsertOrderCredsTx(ctx context.Context, tx *sqlx.Tx, creds *OrderCreds) (err error)

InsertOrderCredsTx implements Datastore

func (DatastoreWithPrometheus) InsertSignedOrderCredentialsTx

func (_d DatastoreWithPrometheus) InsertSignedOrderCredentialsTx(ctx context.Context, tx *sqlx.Tx, signedOrderResult *SigningOrderResult) (err error)

InsertSignedOrderCredentialsTx implements Datastore

func (DatastoreWithPrometheus) InsertSigningOrderRequestOutbox

func (_d DatastoreWithPrometheus) InsertSigningOrderRequestOutbox(ctx context.Context, requestID uuid.UUID, orderID uuid.UUID, itemID uuid.UUID, signingOrderRequest SigningOrderRequest) (err error)

InsertSigningOrderRequestOutbox implements Datastore

func (DatastoreWithPrometheus) InsertTimeLimitedV2OrderCredsTx

func (_d DatastoreWithPrometheus) InsertTimeLimitedV2OrderCredsTx(ctx context.Context, tx *sqlx.Tx, tlv2 TimeAwareSubIssuedCreds) (err error)

InsertTimeLimitedV2OrderCredsTx implements Datastore

func (DatastoreWithPrometheus) InsertVote

func (_d DatastoreWithPrometheus) InsertVote(ctx context.Context, vr VoteRecord) (err error)

InsertVote implements Datastore

func (DatastoreWithPrometheus) IsStripeSub

func (_d DatastoreWithPrometheus) IsStripeSub(u1 uuid.UUID) (b1 bool, s1 string, err error)

IsStripeSub implements Datastore

func (DatastoreWithPrometheus) MarkVoteErrored

func (_d DatastoreWithPrometheus) MarkVoteErrored(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) (err error)

MarkVoteErrored implements Datastore

func (DatastoreWithPrometheus) Migrate

func (_d DatastoreWithPrometheus) Migrate(p1 ...uint) (err error)

Migrate implements Datastore

func (DatastoreWithPrometheus) NewMigrate

func (_d DatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)

NewMigrate implements Datastore

func (DatastoreWithPrometheus) RawDB

func (_d DatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)

RawDB implements Datastore

func (DatastoreWithPrometheus) RollbackTx

func (_d DatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)

RollbackTx implements Datastore

func (DatastoreWithPrometheus) RollbackTxAndHandle

func (_d DatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)

RollbackTxAndHandle implements Datastore

func (DatastoreWithPrometheus) SendSigningRequest

func (_d DatastoreWithPrometheus) SendSigningRequest(ctx context.Context, signingRequestWriter SigningRequestWriter) (err error)

SendSigningRequest implements Datastore

func (DatastoreWithPrometheus) SetOrderPaid

func (_d DatastoreWithPrometheus) SetOrderPaid(ctx context.Context, up1 *uuid.UUID) (err error)

SetOrderPaid implements Datastore

func (DatastoreWithPrometheus) SetOrderTrialDays

func (_d DatastoreWithPrometheus) SetOrderTrialDays(ctx context.Context, orderID *uuid.UUID, days int64) (op1 *Order, err error)

SetOrderTrialDays implements Datastore

func (DatastoreWithPrometheus) UpdateOrder

func (_d DatastoreWithPrometheus) UpdateOrder(orderID uuid.UUID, status string) (err error)

UpdateOrder implements Datastore

func (DatastoreWithPrometheus) UpdateOrderMetadata

func (_d DatastoreWithPrometheus) UpdateOrderMetadata(orderID uuid.UUID, key string, value string) (err error)

UpdateOrderMetadata implements Datastore

func (DatastoreWithPrometheus) UpdateSigningOrderRequestOutboxTx

func (_d DatastoreWithPrometheus) UpdateSigningOrderRequestOutboxTx(ctx context.Context, tx *sqlx.Tx, requestID uuid.UUID, completedAt time.Time) (err error)

UpdateSigningOrderRequestOutboxTx implements Datastore

func (DatastoreWithPrometheus) UpdateTransaction

func (_d DatastoreWithPrometheus) UpdateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (tp1 *Transaction, err error)

UpdateTransaction implements Datastore

type Decoder

type Decoder interface {
	Decode(message kafka.Message) (*SigningOrderResult, error)
}

Decoder - kafka message decoder interface

type DeleteKeyRequest

type DeleteKeyRequest struct {
	DelaySeconds int `json:"delaySeconds" valid:"-"`
}

DeleteKeyRequest includes information needed to delete a key

type DeveloperNotification

type DeveloperNotification struct {
	Version                  string                   `json:"version"`
	PackageName              string                   `json:"packageName"`
	SubscriptionNotification SubscriptionNotification `json:"subscriptionNotification"`
}

DeveloperNotification - developer notification details from AndroidNotificationMessage.Data

type IOSNotification

type IOSNotification struct {
	SignedPayload string `json:"signedPayload" valid:"-"`
	// contains filtered or unexported fields
}

IOSNotification - wrapping structure of an android notification

func (*IOSNotification) Decode

func (iosn *IOSNotification) Decode(ctx context.Context, data []byte) error

Decode - implement Decodable interface

func (*IOSNotification) GetRenewalInfo

GetRenewalInfo - from request get renewal information

func (*IOSNotification) GetTransactionInfo

func (iosn *IOSNotification) GetTransactionInfo(ctx context.Context) (*appstore.JWSTransactionDecodedPayload, error)

GetTransactionInfo - from request get renewal information

func (*IOSNotification) Validate

func (iosn *IOSNotification) Validate(ctx context.Context) error

Validate - implement Validable interface

type Issuer

type Issuer = model.Issuer

TODO(pavelb): Gradually replace these everywhere.

type Key

type Key struct {
	ID                 string     `json:"id" db:"id"`
	Name               string     `json:"name" db:"name"`
	Merchant           string     `json:"merchant" db:"merchant_id"`
	EncryptedSecretKey string     `json:"-" db:"encrypted_secret_key"`
	Nonce              string     `json:"-" db:"nonce"`
	CreatedAt          time.Time  `json:"createdAt" db:"created_at"`
	Expiry             *time.Time `json:"expiry" db:"expiry"`
}

Key represents a merchant's keys to validate skus

func (*Key) GetSecretKey

func (key *Key) GetSecretKey() (*string, error)

GetSecretKey decrypts the secret key from the database

type Metadata

type Metadata struct {
	ItemID         uuid.UUID `json:"itemId"`
	OrderID        uuid.UUID `json:"orderId"`
	IssuerID       uuid.UUID `json:"issuerId"`
	CredentialType string    `json:"credential_type"`
}

Metadata - skus metadata structure

type MockDatastore

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

MockDatastore is a mock of Datastore interface.

func NewMockDatastore

func NewMockDatastore(ctrl *gomock.Controller) *MockDatastore

NewMockDatastore creates a new mock instance.

func (*MockDatastore) AppendOrderMetadata

func (m *MockDatastore) AppendOrderMetadata(arg0 context.Context, arg1 *go_uuid.UUID, arg2, arg3 string) error

AppendOrderMetadata mocks base method.

func (*MockDatastore) AppendOrderMetadataInt

func (m *MockDatastore) AppendOrderMetadataInt(arg0 context.Context, arg1 *go_uuid.UUID, arg2 string, arg3 int) error

AppendOrderMetadataInt mocks base method.

func (*MockDatastore) AppendOrderMetadataInt64

func (m *MockDatastore) AppendOrderMetadataInt64(arg0 context.Context, arg1 *go_uuid.UUID, arg2 string, arg3 int64) error

AppendOrderMetadataInt64 mocks base method.

func (*MockDatastore) AreTimeLimitedV2CredsSubmitted

func (m *MockDatastore) AreTimeLimitedV2CredsSubmitted(ctx context.Context, requestID go_uuid.UUID, blindedCreds ...string) (AreTimeLimitedV2CredsSubmittedResult, error)

AreTimeLimitedV2CredsSubmitted mocks base method.

func (*MockDatastore) BeginTx

func (m *MockDatastore) BeginTx() (*sqlx.Tx, error)

BeginTx mocks base method.

func (*MockDatastore) CheckExpiredCheckoutSession

func (m *MockDatastore) CheckExpiredCheckoutSession(arg0 go_uuid.UUID) (bool, string, error)

CheckExpiredCheckoutSession mocks base method.

func (*MockDatastore) CommitVote

func (m *MockDatastore) CommitVote(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error

CommitVote mocks base method.

func (*MockDatastore) CreateKey

func (m *MockDatastore) CreateKey(merchant, name, encryptedSecretKey, nonce string) (*Key, error)

CreateKey mocks base method.

func (*MockDatastore) CreateOrder

func (m *MockDatastore) CreateOrder(ctx context.Context, dbi sqlx.ExtContext, oreq *model.OrderNew, items []model.OrderItem) (*model.Order, error)

CreateOrder mocks base method.

func (*MockDatastore) CreateTransaction

func (m *MockDatastore) CreateTransaction(orderID go_uuid.UUID, externalTransactionID, status, currency, kind string, amount decimal.Decimal) (*Transaction, error)

CreateTransaction mocks base method.

func (*MockDatastore) DeleteKey

func (m *MockDatastore) DeleteKey(id go_uuid.UUID, delaySeconds int) (*Key, error)

DeleteKey mocks base method.

func (*MockDatastore) DeleteSigningOrderRequestOutboxByOrderTx

func (m *MockDatastore) DeleteSigningOrderRequestOutboxByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID go_uuid.UUID) error

DeleteSigningOrderRequestOutboxByOrderTx mocks base method.

func (*MockDatastore) DeleteSingleUseOrderCredsByOrderTx

func (m *MockDatastore) DeleteSingleUseOrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID go_uuid.UUID, isSigned bool) error

DeleteSingleUseOrderCredsByOrderTx mocks base method.

func (*MockDatastore) DeleteTimeLimitedV2OrderCredsByOrderTx

func (m *MockDatastore) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID go_uuid.UUID) error

DeleteTimeLimitedV2OrderCredsByOrderTx mocks base method.

func (*MockDatastore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatastore) GetIssuerByPublicKey

func (m *MockDatastore) GetIssuerByPublicKey(publicKey string) (*Issuer, error)

GetIssuerByPublicKey mocks base method.

func (*MockDatastore) GetKey

func (m *MockDatastore) GetKey(id go_uuid.UUID, showExpired bool) (*Key, error)

GetKey mocks base method.

func (*MockDatastore) GetKeysByMerchant

func (m *MockDatastore) GetKeysByMerchant(merchant string, showExpired bool) (*[]Key, error)

GetKeysByMerchant mocks base method.

func (*MockDatastore) GetOrder

func (m *MockDatastore) GetOrder(orderID go_uuid.UUID) (*Order, error)

GetOrder mocks base method.

func (*MockDatastore) GetOrderByExternalID

func (m *MockDatastore) GetOrderByExternalID(externalID string) (*Order, error)

GetOrderByExternalID mocks base method.

func (*MockDatastore) GetOrderCreds

func (m *MockDatastore) GetOrderCreds(orderID go_uuid.UUID, isSigned bool) ([]OrderCreds, error)

GetOrderCreds mocks base method.

func (*MockDatastore) GetOrderCredsByItemID

func (m *MockDatastore) GetOrderCredsByItemID(orderID, itemID go_uuid.UUID, isSigned bool) (*OrderCreds, error)

GetOrderCredsByItemID mocks base method.

func (*MockDatastore) GetOrderItem

func (m *MockDatastore) GetOrderItem(ctx context.Context, itemID go_uuid.UUID) (*OrderItem, error)

GetOrderItem mocks base method.

func (*MockDatastore) GetOutboxMovAvgDurationSeconds

func (m *MockDatastore) GetOutboxMovAvgDurationSeconds() (int64, error)

GetOutboxMovAvgDurationSeconds mocks base method.

func (*MockDatastore) GetPagedMerchantTransactions

func (m *MockDatastore) GetPagedMerchantTransactions(ctx context.Context, merchantID go_uuid.UUID, pagination *inputs.Pagination) (*[]Transaction, int, error)

GetPagedMerchantTransactions mocks base method.

func (*MockDatastore) GetSigningOrderRequestOutboxByOrder

func (m *MockDatastore) GetSigningOrderRequestOutboxByOrder(ctx context.Context, orderID go_uuid.UUID) ([]SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByOrder mocks base method.

func (*MockDatastore) GetSigningOrderRequestOutboxByOrderItem

func (m *MockDatastore) GetSigningOrderRequestOutboxByOrderItem(ctx context.Context, itemID go_uuid.UUID) ([]SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByOrderItem mocks base method.

func (*MockDatastore) GetSigningOrderRequestOutboxByRequestID

func (m *MockDatastore) GetSigningOrderRequestOutboxByRequestID(ctx context.Context, dbi sqlx.QueryerContext, reqID go_uuid.UUID) (*SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByRequestID mocks base method.

func (*MockDatastore) GetSumForTransactions

func (m *MockDatastore) GetSumForTransactions(orderID go_uuid.UUID) (decimal.Decimal, error)

GetSumForTransactions mocks base method.

func (*MockDatastore) GetTLV2Creds

func (m *MockDatastore) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID go_uuid.UUID) (*TimeLimitedV2Creds, error)

GetTLV2Creds mocks base method.

func (*MockDatastore) GetTimeLimitedV2OrderCredsByOrder

func (m *MockDatastore) GetTimeLimitedV2OrderCredsByOrder(orderID go_uuid.UUID) (*TimeLimitedV2Creds, error)

GetTimeLimitedV2OrderCredsByOrder mocks base method.

func (*MockDatastore) GetTimeLimitedV2OrderCredsByOrderItem

func (m *MockDatastore) GetTimeLimitedV2OrderCredsByOrderItem(itemID go_uuid.UUID) (*TimeLimitedV2Creds, error)

GetTimeLimitedV2OrderCredsByOrderItem mocks base method.

func (*MockDatastore) GetTransaction

func (m *MockDatastore) GetTransaction(externalTransactionID string) (*Transaction, error)

GetTransaction mocks base method.

func (*MockDatastore) GetTransactions

func (m *MockDatastore) GetTransactions(orderID go_uuid.UUID) (*[]Transaction, error)

GetTransactions mocks base method.

func (*MockDatastore) GetUncommittedVotesForUpdate

func (m *MockDatastore) GetUncommittedVotesForUpdate(ctx context.Context) (*sqlx.Tx, []*VoteRecord, error)

GetUncommittedVotesForUpdate mocks base method.

func (*MockDatastore) InsertOrderCredsTx

func (m *MockDatastore) InsertOrderCredsTx(ctx context.Context, tx *sqlx.Tx, creds *OrderCreds) error

InsertOrderCredsTx mocks base method.

func (*MockDatastore) InsertSignedOrderCredentialsTx

func (m *MockDatastore) InsertSignedOrderCredentialsTx(ctx context.Context, tx *sqlx.Tx, signedOrderResult *SigningOrderResult) error

InsertSignedOrderCredentialsTx mocks base method.

func (*MockDatastore) InsertSigningOrderRequestOutbox

func (m *MockDatastore) InsertSigningOrderRequestOutbox(ctx context.Context, requestID, orderID, itemID go_uuid.UUID, signingOrderRequest SigningOrderRequest) error

InsertSigningOrderRequestOutbox mocks base method.

func (*MockDatastore) InsertTimeLimitedV2OrderCredsTx

func (m *MockDatastore) InsertTimeLimitedV2OrderCredsTx(ctx context.Context, tx *sqlx.Tx, tlv2 TimeAwareSubIssuedCreds) error

InsertTimeLimitedV2OrderCredsTx mocks base method.

func (*MockDatastore) InsertVote

func (m *MockDatastore) InsertVote(ctx context.Context, vr VoteRecord) error

InsertVote mocks base method.

func (*MockDatastore) IsStripeSub

func (m *MockDatastore) IsStripeSub(arg0 go_uuid.UUID) (bool, string, error)

IsStripeSub mocks base method.

func (*MockDatastore) MarkVoteErrored

func (m *MockDatastore) MarkVoteErrored(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error

MarkVoteErrored mocks base method.

func (*MockDatastore) Migrate

func (m *MockDatastore) Migrate(arg0 ...uint) error

Migrate mocks base method.

func (*MockDatastore) NewMigrate

func (m *MockDatastore) NewMigrate() (*v4.Migrate, error)

NewMigrate mocks base method.

func (*MockDatastore) RawDB

func (m *MockDatastore) RawDB() *sqlx.DB

RawDB mocks base method.

func (*MockDatastore) RollbackTx

func (m *MockDatastore) RollbackTx(tx *sqlx.Tx)

RollbackTx mocks base method.

func (*MockDatastore) RollbackTxAndHandle

func (m *MockDatastore) RollbackTxAndHandle(tx *sqlx.Tx) error

RollbackTxAndHandle mocks base method.

func (*MockDatastore) SendSigningRequest

func (m *MockDatastore) SendSigningRequest(ctx context.Context, signingRequestWriter SigningRequestWriter) error

SendSigningRequest mocks base method.

func (*MockDatastore) SetOrderPaid

func (m *MockDatastore) SetOrderPaid(arg0 context.Context, arg1 *go_uuid.UUID) error

SetOrderPaid mocks base method.

func (*MockDatastore) SetOrderTrialDays

func (m *MockDatastore) SetOrderTrialDays(ctx context.Context, orderID *go_uuid.UUID, days int64) (*Order, error)

SetOrderTrialDays mocks base method.

func (*MockDatastore) UpdateOrder

func (m *MockDatastore) UpdateOrder(orderID go_uuid.UUID, status string) error

UpdateOrder mocks base method.

func (*MockDatastore) UpdateOrderMetadata

func (m *MockDatastore) UpdateOrderMetadata(orderID go_uuid.UUID, key, value string) error

UpdateOrderMetadata mocks base method.

func (*MockDatastore) UpdateSigningOrderRequestOutboxTx

func (m *MockDatastore) UpdateSigningOrderRequestOutboxTx(ctx context.Context, tx *sqlx.Tx, requestID go_uuid.UUID, completedAt time.Time) error

UpdateSigningOrderRequestOutboxTx mocks base method.

func (*MockDatastore) UpdateTransaction

func (m *MockDatastore) UpdateTransaction(orderID go_uuid.UUID, externalTransactionID, status, currency, kind string, amount decimal.Decimal) (*Transaction, error)

UpdateTransaction mocks base method.

type MockDatastoreMockRecorder

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

MockDatastoreMockRecorder is the mock recorder for MockDatastore.

func (*MockDatastoreMockRecorder) AppendOrderMetadata

func (mr *MockDatastoreMockRecorder) AppendOrderMetadata(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

AppendOrderMetadata indicates an expected call of AppendOrderMetadata.

func (*MockDatastoreMockRecorder) AppendOrderMetadataInt

func (mr *MockDatastoreMockRecorder) AppendOrderMetadataInt(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

AppendOrderMetadataInt indicates an expected call of AppendOrderMetadataInt.

func (*MockDatastoreMockRecorder) AppendOrderMetadataInt64

func (mr *MockDatastoreMockRecorder) AppendOrderMetadataInt64(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

AppendOrderMetadataInt64 indicates an expected call of AppendOrderMetadataInt64.

func (*MockDatastoreMockRecorder) AreTimeLimitedV2CredsSubmitted

func (mr *MockDatastoreMockRecorder) AreTimeLimitedV2CredsSubmitted(ctx, requestID interface{}, blindedCreds ...interface{}) *gomock.Call

AreTimeLimitedV2CredsSubmitted indicates an expected call of AreTimeLimitedV2CredsSubmitted.

func (*MockDatastoreMockRecorder) BeginTx

func (mr *MockDatastoreMockRecorder) BeginTx() *gomock.Call

BeginTx indicates an expected call of BeginTx.

func (*MockDatastoreMockRecorder) CheckExpiredCheckoutSession

func (mr *MockDatastoreMockRecorder) CheckExpiredCheckoutSession(arg0 interface{}) *gomock.Call

CheckExpiredCheckoutSession indicates an expected call of CheckExpiredCheckoutSession.

func (*MockDatastoreMockRecorder) CommitVote

func (mr *MockDatastoreMockRecorder) CommitVote(ctx, vr, tx interface{}) *gomock.Call

CommitVote indicates an expected call of CommitVote.

func (*MockDatastoreMockRecorder) CreateKey

func (mr *MockDatastoreMockRecorder) CreateKey(merchant, name, encryptedSecretKey, nonce interface{}) *gomock.Call

CreateKey indicates an expected call of CreateKey.

func (*MockDatastoreMockRecorder) CreateOrder

func (mr *MockDatastoreMockRecorder) CreateOrder(ctx, dbi, oreq, items interface{}) *gomock.Call

CreateOrder indicates an expected call of CreateOrder.

func (*MockDatastoreMockRecorder) CreateTransaction

func (mr *MockDatastoreMockRecorder) CreateTransaction(orderID, externalTransactionID, status, currency, kind, amount interface{}) *gomock.Call

CreateTransaction indicates an expected call of CreateTransaction.

func (*MockDatastoreMockRecorder) DeleteKey

func (mr *MockDatastoreMockRecorder) DeleteKey(id, delaySeconds interface{}) *gomock.Call

DeleteKey indicates an expected call of DeleteKey.

func (*MockDatastoreMockRecorder) DeleteSigningOrderRequestOutboxByOrderTx

func (mr *MockDatastoreMockRecorder) DeleteSigningOrderRequestOutboxByOrderTx(ctx, tx, orderID interface{}) *gomock.Call

DeleteSigningOrderRequestOutboxByOrderTx indicates an expected call of DeleteSigningOrderRequestOutboxByOrderTx.

func (*MockDatastoreMockRecorder) DeleteSingleUseOrderCredsByOrderTx

func (mr *MockDatastoreMockRecorder) DeleteSingleUseOrderCredsByOrderTx(ctx, tx, orderID, isSigned interface{}) *gomock.Call

DeleteSingleUseOrderCredsByOrderTx indicates an expected call of DeleteSingleUseOrderCredsByOrderTx.

func (*MockDatastoreMockRecorder) DeleteTimeLimitedV2OrderCredsByOrderTx

func (mr *MockDatastoreMockRecorder) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, tx, orderID interface{}) *gomock.Call

DeleteTimeLimitedV2OrderCredsByOrderTx indicates an expected call of DeleteTimeLimitedV2OrderCredsByOrderTx.

func (*MockDatastoreMockRecorder) GetIssuerByPublicKey

func (mr *MockDatastoreMockRecorder) GetIssuerByPublicKey(publicKey interface{}) *gomock.Call

GetIssuerByPublicKey indicates an expected call of GetIssuerByPublicKey.

func (*MockDatastoreMockRecorder) GetKey

func (mr *MockDatastoreMockRecorder) GetKey(id, showExpired interface{}) *gomock.Call

GetKey indicates an expected call of GetKey.

func (*MockDatastoreMockRecorder) GetKeysByMerchant

func (mr *MockDatastoreMockRecorder) GetKeysByMerchant(merchant, showExpired interface{}) *gomock.Call

GetKeysByMerchant indicates an expected call of GetKeysByMerchant.

func (*MockDatastoreMockRecorder) GetOrder

func (mr *MockDatastoreMockRecorder) GetOrder(orderID interface{}) *gomock.Call

GetOrder indicates an expected call of GetOrder.

func (*MockDatastoreMockRecorder) GetOrderByExternalID

func (mr *MockDatastoreMockRecorder) GetOrderByExternalID(externalID interface{}) *gomock.Call

GetOrderByExternalID indicates an expected call of GetOrderByExternalID.

func (*MockDatastoreMockRecorder) GetOrderCreds

func (mr *MockDatastoreMockRecorder) GetOrderCreds(orderID, isSigned interface{}) *gomock.Call

GetOrderCreds indicates an expected call of GetOrderCreds.

func (*MockDatastoreMockRecorder) GetOrderCredsByItemID

func (mr *MockDatastoreMockRecorder) GetOrderCredsByItemID(orderID, itemID, isSigned interface{}) *gomock.Call

GetOrderCredsByItemID indicates an expected call of GetOrderCredsByItemID.

func (*MockDatastoreMockRecorder) GetOrderItem

func (mr *MockDatastoreMockRecorder) GetOrderItem(ctx, itemID interface{}) *gomock.Call

GetOrderItem indicates an expected call of GetOrderItem.

func (*MockDatastoreMockRecorder) GetOutboxMovAvgDurationSeconds

func (mr *MockDatastoreMockRecorder) GetOutboxMovAvgDurationSeconds() *gomock.Call

GetOutboxMovAvgDurationSeconds indicates an expected call of GetOutboxMovAvgDurationSeconds.

func (*MockDatastoreMockRecorder) GetPagedMerchantTransactions

func (mr *MockDatastoreMockRecorder) GetPagedMerchantTransactions(ctx, merchantID, pagination interface{}) *gomock.Call

GetPagedMerchantTransactions indicates an expected call of GetPagedMerchantTransactions.

func (*MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByOrder

func (mr *MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByOrder(ctx, orderID interface{}) *gomock.Call

GetSigningOrderRequestOutboxByOrder indicates an expected call of GetSigningOrderRequestOutboxByOrder.

func (*MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByOrderItem

func (mr *MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByOrderItem(ctx, itemID interface{}) *gomock.Call

GetSigningOrderRequestOutboxByOrderItem indicates an expected call of GetSigningOrderRequestOutboxByOrderItem.

func (*MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByRequestID

func (mr *MockDatastoreMockRecorder) GetSigningOrderRequestOutboxByRequestID(ctx, dbi, reqID interface{}) *gomock.Call

GetSigningOrderRequestOutboxByRequestID indicates an expected call of GetSigningOrderRequestOutboxByRequestID.

func (*MockDatastoreMockRecorder) GetSumForTransactions

func (mr *MockDatastoreMockRecorder) GetSumForTransactions(orderID interface{}) *gomock.Call

GetSumForTransactions indicates an expected call of GetSumForTransactions.

func (*MockDatastoreMockRecorder) GetTLV2Creds

func (mr *MockDatastoreMockRecorder) GetTLV2Creds(ctx, dbi, ordID, itemID, reqID interface{}) *gomock.Call

GetTLV2Creds indicates an expected call of GetTLV2Creds.

func (*MockDatastoreMockRecorder) GetTimeLimitedV2OrderCredsByOrder

func (mr *MockDatastoreMockRecorder) GetTimeLimitedV2OrderCredsByOrder(orderID interface{}) *gomock.Call

GetTimeLimitedV2OrderCredsByOrder indicates an expected call of GetTimeLimitedV2OrderCredsByOrder.

func (*MockDatastoreMockRecorder) GetTimeLimitedV2OrderCredsByOrderItem

func (mr *MockDatastoreMockRecorder) GetTimeLimitedV2OrderCredsByOrderItem(itemID interface{}) *gomock.Call

GetTimeLimitedV2OrderCredsByOrderItem indicates an expected call of GetTimeLimitedV2OrderCredsByOrderItem.

func (*MockDatastoreMockRecorder) GetTransaction

func (mr *MockDatastoreMockRecorder) GetTransaction(externalTransactionID interface{}) *gomock.Call

GetTransaction indicates an expected call of GetTransaction.

func (*MockDatastoreMockRecorder) GetTransactions

func (mr *MockDatastoreMockRecorder) GetTransactions(orderID interface{}) *gomock.Call

GetTransactions indicates an expected call of GetTransactions.

func (*MockDatastoreMockRecorder) GetUncommittedVotesForUpdate

func (mr *MockDatastoreMockRecorder) GetUncommittedVotesForUpdate(ctx interface{}) *gomock.Call

GetUncommittedVotesForUpdate indicates an expected call of GetUncommittedVotesForUpdate.

func (*MockDatastoreMockRecorder) InsertOrderCredsTx

func (mr *MockDatastoreMockRecorder) InsertOrderCredsTx(ctx, tx, creds interface{}) *gomock.Call

InsertOrderCredsTx indicates an expected call of InsertOrderCredsTx.

func (*MockDatastoreMockRecorder) InsertSignedOrderCredentialsTx

func (mr *MockDatastoreMockRecorder) InsertSignedOrderCredentialsTx(ctx, tx, signedOrderResult interface{}) *gomock.Call

InsertSignedOrderCredentialsTx indicates an expected call of InsertSignedOrderCredentialsTx.

func (*MockDatastoreMockRecorder) InsertSigningOrderRequestOutbox

func (mr *MockDatastoreMockRecorder) InsertSigningOrderRequestOutbox(ctx, requestID, orderID, itemID, signingOrderRequest interface{}) *gomock.Call

InsertSigningOrderRequestOutbox indicates an expected call of InsertSigningOrderRequestOutbox.

func (*MockDatastoreMockRecorder) InsertTimeLimitedV2OrderCredsTx

func (mr *MockDatastoreMockRecorder) InsertTimeLimitedV2OrderCredsTx(ctx, tx, tlv2 interface{}) *gomock.Call

InsertTimeLimitedV2OrderCredsTx indicates an expected call of InsertTimeLimitedV2OrderCredsTx.

func (*MockDatastoreMockRecorder) InsertVote

func (mr *MockDatastoreMockRecorder) InsertVote(ctx, vr interface{}) *gomock.Call

InsertVote indicates an expected call of InsertVote.

func (*MockDatastoreMockRecorder) IsStripeSub

func (mr *MockDatastoreMockRecorder) IsStripeSub(arg0 interface{}) *gomock.Call

IsStripeSub indicates an expected call of IsStripeSub.

func (*MockDatastoreMockRecorder) MarkVoteErrored

func (mr *MockDatastoreMockRecorder) MarkVoteErrored(ctx, vr, tx interface{}) *gomock.Call

MarkVoteErrored indicates an expected call of MarkVoteErrored.

func (*MockDatastoreMockRecorder) Migrate

func (mr *MockDatastoreMockRecorder) Migrate(arg0 ...interface{}) *gomock.Call

Migrate indicates an expected call of Migrate.

func (*MockDatastoreMockRecorder) NewMigrate

func (mr *MockDatastoreMockRecorder) NewMigrate() *gomock.Call

NewMigrate indicates an expected call of NewMigrate.

func (*MockDatastoreMockRecorder) RawDB

func (mr *MockDatastoreMockRecorder) RawDB() *gomock.Call

RawDB indicates an expected call of RawDB.

func (*MockDatastoreMockRecorder) RollbackTx

func (mr *MockDatastoreMockRecorder) RollbackTx(tx interface{}) *gomock.Call

RollbackTx indicates an expected call of RollbackTx.

func (*MockDatastoreMockRecorder) RollbackTxAndHandle

func (mr *MockDatastoreMockRecorder) RollbackTxAndHandle(tx interface{}) *gomock.Call

RollbackTxAndHandle indicates an expected call of RollbackTxAndHandle.

func (*MockDatastoreMockRecorder) SendSigningRequest

func (mr *MockDatastoreMockRecorder) SendSigningRequest(ctx, signingRequestWriter interface{}) *gomock.Call

SendSigningRequest indicates an expected call of SendSigningRequest.

func (*MockDatastoreMockRecorder) SetOrderPaid

func (mr *MockDatastoreMockRecorder) SetOrderPaid(arg0, arg1 interface{}) *gomock.Call

SetOrderPaid indicates an expected call of SetOrderPaid.

func (*MockDatastoreMockRecorder) SetOrderTrialDays

func (mr *MockDatastoreMockRecorder) SetOrderTrialDays(ctx, orderID, days interface{}) *gomock.Call

SetOrderTrialDays indicates an expected call of SetOrderTrialDays.

func (*MockDatastoreMockRecorder) UpdateOrder

func (mr *MockDatastoreMockRecorder) UpdateOrder(orderID, status interface{}) *gomock.Call

UpdateOrder indicates an expected call of UpdateOrder.

func (*MockDatastoreMockRecorder) UpdateOrderMetadata

func (mr *MockDatastoreMockRecorder) UpdateOrderMetadata(orderID, key, value interface{}) *gomock.Call

UpdateOrderMetadata indicates an expected call of UpdateOrderMetadata.

func (*MockDatastoreMockRecorder) UpdateSigningOrderRequestOutboxTx

func (mr *MockDatastoreMockRecorder) UpdateSigningOrderRequestOutboxTx(ctx, tx, requestID, completedAt interface{}) *gomock.Call

UpdateSigningOrderRequestOutboxTx indicates an expected call of UpdateSigningOrderRequestOutboxTx.

func (*MockDatastoreMockRecorder) UpdateTransaction

func (mr *MockDatastoreMockRecorder) UpdateTransaction(orderID, externalTransactionID, status, currency, kind, amount interface{}) *gomock.Call

UpdateTransaction indicates an expected call of UpdateTransaction.

type MockDecoder

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

MockDecoder is a mock of Decoder interface.

func NewMockDecoder

func NewMockDecoder(ctrl *gomock.Controller) *MockDecoder

NewMockDecoder creates a new mock instance.

func (*MockDecoder) Decode

func (m *MockDecoder) Decode(message kafka_go.Message) (*SigningOrderResult, error)

Decode mocks base method.

func (*MockDecoder) EXPECT

func (m *MockDecoder) EXPECT() *MockDecoderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockDecoderMockRecorder

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

MockDecoderMockRecorder is the mock recorder for MockDecoder.

func (*MockDecoderMockRecorder) Decode

func (mr *MockDecoderMockRecorder) Decode(message interface{}) *gomock.Call

Decode indicates an expected call of Decode.

type MockOrderWorker

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

MockOrderWorker is a mock of OrderWorker interface.

func NewMockOrderWorker

func NewMockOrderWorker(ctrl *gomock.Controller) *MockOrderWorker

NewMockOrderWorker creates a new mock instance.

func (*MockOrderWorker) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockOrderWorker) SignOrderCreds

func (m *MockOrderWorker) SignOrderCreds(ctx context.Context, orderID go_uuid.UUID, issuer Issuer, blindedCreds []string) (*OrderCreds, error)

SignOrderCreds mocks base method.

type MockOrderWorkerMockRecorder

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

MockOrderWorkerMockRecorder is the mock recorder for MockOrderWorker.

func (*MockOrderWorkerMockRecorder) SignOrderCreds

func (mr *MockOrderWorkerMockRecorder) SignOrderCreds(ctx, orderID, issuer, blindedCreds interface{}) *gomock.Call

SignOrderCreds indicates an expected call of SignOrderCreds.

type MockSigningRequestWriter

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

MockSigningRequestWriter is a mock of SigningRequestWriter interface.

func NewMockSigningRequestWriter

func NewMockSigningRequestWriter(ctrl *gomock.Controller) *MockSigningRequestWriter

NewMockSigningRequestWriter creates a new mock instance.

func (*MockSigningRequestWriter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSigningRequestWriter) WriteMessage

func (m *MockSigningRequestWriter) WriteMessage(ctx context.Context, message []byte) error

WriteMessage mocks base method.

func (*MockSigningRequestWriter) WriteMessages

func (m *MockSigningRequestWriter) WriteMessages(ctx context.Context, messages []SigningOrderRequestOutbox) error

WriteMessages mocks base method.

type MockSigningRequestWriterMockRecorder

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

MockSigningRequestWriterMockRecorder is the mock recorder for MockSigningRequestWriter.

func (*MockSigningRequestWriterMockRecorder) WriteMessage

func (mr *MockSigningRequestWriterMockRecorder) WriteMessage(ctx, message interface{}) *gomock.Call

WriteMessage indicates an expected call of WriteMessage.

func (*MockSigningRequestWriterMockRecorder) WriteMessages

func (mr *MockSigningRequestWriterMockRecorder) WriteMessages(ctx, messages interface{}) *gomock.Call

WriteMessages indicates an expected call of WriteMessages.

type MockgetContext

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

MockgetContext is a mock of getContext interface.

func NewMockgetContext

func NewMockgetContext(ctrl *gomock.Controller) *MockgetContext

NewMockgetContext creates a new mock instance.

func (*MockgetContext) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockgetContext) GetContext

func (m *MockgetContext) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

GetContext mocks base method.

type MockgetContextMockRecorder

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

MockgetContextMockRecorder is the mock recorder for MockgetContext.

func (*MockgetContextMockRecorder) GetContext

func (mr *MockgetContextMockRecorder) GetContext(ctx, dest, query interface{}, args ...interface{}) *gomock.Call

GetContext indicates an expected call of GetContext.

type MockissuerStore

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

MockissuerStore is a mock of issuerStore interface.

func NewMockissuerStore

func NewMockissuerStore(ctrl *gomock.Controller) *MockissuerStore

NewMockissuerStore creates a new mock instance.

func (*MockissuerStore) Create

Create mocks base method.

func (*MockissuerStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockissuerStore) GetByMerchID

func (m *MockissuerStore) GetByMerchID(ctx context.Context, dbi sqlx.QueryerContext, merchID string) (*model.Issuer, error)

GetByMerchID mocks base method.

func (*MockissuerStore) GetByPubKey

func (m *MockissuerStore) GetByPubKey(ctx context.Context, dbi sqlx.QueryerContext, pubKey string) (*model.Issuer, error)

GetByPubKey mocks base method.

type MockissuerStoreMockRecorder

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

MockissuerStoreMockRecorder is the mock recorder for MockissuerStore.

func (*MockissuerStoreMockRecorder) Create

func (mr *MockissuerStoreMockRecorder) Create(ctx, dbi, req interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockissuerStoreMockRecorder) GetByMerchID

func (mr *MockissuerStoreMockRecorder) GetByMerchID(ctx, dbi, merchID interface{}) *gomock.Call

GetByMerchID indicates an expected call of GetByMerchID.

func (*MockissuerStoreMockRecorder) GetByPubKey

func (mr *MockissuerStoreMockRecorder) GetByPubKey(ctx, dbi, pubKey interface{}) *gomock.Call

GetByPubKey indicates an expected call of GetByPubKey.

type MockorderItemStore

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

MockorderItemStore is a mock of orderItemStore interface.

func NewMockorderItemStore

func NewMockorderItemStore(ctrl *gomock.Controller) *MockorderItemStore

NewMockorderItemStore creates a new mock instance.

func (*MockorderItemStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockorderItemStore) FindByOrderID

func (m *MockorderItemStore) FindByOrderID(ctx context.Context, dbi sqlx.QueryerContext, orderID go_uuid.UUID) ([]model.OrderItem, error)

FindByOrderID mocks base method.

func (*MockorderItemStore) Get

Get mocks base method.

func (*MockorderItemStore) InsertMany

func (m *MockorderItemStore) InsertMany(ctx context.Context, dbi sqlx.ExtContext, items ...model.OrderItem) ([]model.OrderItem, error)

InsertMany mocks base method.

type MockorderItemStoreMockRecorder

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

MockorderItemStoreMockRecorder is the mock recorder for MockorderItemStore.

func (*MockorderItemStoreMockRecorder) FindByOrderID

func (mr *MockorderItemStoreMockRecorder) FindByOrderID(ctx, dbi, orderID interface{}) *gomock.Call

FindByOrderID indicates an expected call of FindByOrderID.

func (*MockorderItemStoreMockRecorder) Get

func (mr *MockorderItemStoreMockRecorder) Get(ctx, dbi, id interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockorderItemStoreMockRecorder) InsertMany

func (mr *MockorderItemStoreMockRecorder) InsertMany(ctx, dbi interface{}, items ...interface{}) *gomock.Call

InsertMany indicates an expected call of InsertMany.

type MockorderPayHistoryStore

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

MockorderPayHistoryStore is a mock of orderPayHistoryStore interface.

func NewMockorderPayHistoryStore

func NewMockorderPayHistoryStore(ctrl *gomock.Controller) *MockorderPayHistoryStore

NewMockorderPayHistoryStore creates a new mock instance.

func (*MockorderPayHistoryStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockorderPayHistoryStore) Insert

Insert mocks base method.

type MockorderPayHistoryStoreMockRecorder

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

MockorderPayHistoryStoreMockRecorder is the mock recorder for MockorderPayHistoryStore.

func (*MockorderPayHistoryStoreMockRecorder) Insert

func (mr *MockorderPayHistoryStoreMockRecorder) Insert(ctx, dbi, id, when interface{}) *gomock.Call

Insert indicates an expected call of Insert.

type MockorderStore

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

MockorderStore is a mock of orderStore interface.

func NewMockorderStore

func NewMockorderStore(ctrl *gomock.Controller) *MockorderStore

NewMockorderStore creates a new mock instance.

func (*MockorderStore) AppendMetadata

func (m *MockorderStore) AppendMetadata(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key, val string) error

AppendMetadata mocks base method.

func (*MockorderStore) AppendMetadataInt

func (m *MockorderStore) AppendMetadataInt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key string, val int) error

AppendMetadataInt mocks base method.

func (*MockorderStore) AppendMetadataInt64

func (m *MockorderStore) AppendMetadataInt64(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key string, val int64) error

AppendMetadataInt64 mocks base method.

func (*MockorderStore) Create

Create mocks base method.

func (*MockorderStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockorderStore) Get

Get mocks base method.

func (*MockorderStore) GetByExternalID

func (m *MockorderStore) GetByExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (*model.Order, error)

GetByExternalID mocks base method.

func (*MockorderStore) GetExpiredStripeCheckoutSessionID

func (m *MockorderStore) GetExpiredStripeCheckoutSessionID(ctx context.Context, dbi sqlx.QueryerContext, orderID go_uuid.UUID) (string, error)

GetExpiredStripeCheckoutSessionID mocks base method.

func (*MockorderStore) GetExpiresAtAfterISOPeriod

func (m *MockorderStore) GetExpiresAtAfterISOPeriod(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID) (time.Time, error)

GetExpiresAtAfterISOPeriod mocks base method.

func (*MockorderStore) GetMetadata

GetMetadata mocks base method.

func (*MockorderStore) HasExternalID

func (m *MockorderStore) HasExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (bool, error)

HasExternalID mocks base method.

func (*MockorderStore) SetExpiresAt

func (m *MockorderStore) SetExpiresAt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, when time.Time) error

SetExpiresAt mocks base method.

func (*MockorderStore) SetLastPaidAt

func (m *MockorderStore) SetLastPaidAt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, when time.Time) error

SetLastPaidAt mocks base method.

func (*MockorderStore) SetStatus

func (m *MockorderStore) SetStatus(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, status string) error

SetStatus mocks base method.

func (*MockorderStore) SetTrialDays

func (m *MockorderStore) SetTrialDays(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID, ndays int64) (*model.Order, error)

SetTrialDays mocks base method.

func (*MockorderStore) UpdateMetadata

func (m *MockorderStore) UpdateMetadata(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, data datastore.Metadata) error

UpdateMetadata mocks base method.

type MockorderStoreMockRecorder

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

MockorderStoreMockRecorder is the mock recorder for MockorderStore.

func (*MockorderStoreMockRecorder) AppendMetadata

func (mr *MockorderStoreMockRecorder) AppendMetadata(ctx, dbi, id, key, val interface{}) *gomock.Call

AppendMetadata indicates an expected call of AppendMetadata.

func (*MockorderStoreMockRecorder) AppendMetadataInt

func (mr *MockorderStoreMockRecorder) AppendMetadataInt(ctx, dbi, id, key, val interface{}) *gomock.Call

AppendMetadataInt indicates an expected call of AppendMetadataInt.

func (*MockorderStoreMockRecorder) AppendMetadataInt64

func (mr *MockorderStoreMockRecorder) AppendMetadataInt64(ctx, dbi, id, key, val interface{}) *gomock.Call

AppendMetadataInt64 indicates an expected call of AppendMetadataInt64.

func (*MockorderStoreMockRecorder) Create

func (mr *MockorderStoreMockRecorder) Create(ctx, dbi, oreq interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockorderStoreMockRecorder) Get

func (mr *MockorderStoreMockRecorder) Get(ctx, dbi, id interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockorderStoreMockRecorder) GetByExternalID

func (mr *MockorderStoreMockRecorder) GetByExternalID(ctx, dbi, extID interface{}) *gomock.Call

GetByExternalID indicates an expected call of GetByExternalID.

func (*MockorderStoreMockRecorder) GetExpiredStripeCheckoutSessionID

func (mr *MockorderStoreMockRecorder) GetExpiredStripeCheckoutSessionID(ctx, dbi, orderID interface{}) *gomock.Call

GetExpiredStripeCheckoutSessionID indicates an expected call of GetExpiredStripeCheckoutSessionID.

func (*MockorderStoreMockRecorder) GetExpiresAtAfterISOPeriod

func (mr *MockorderStoreMockRecorder) GetExpiresAtAfterISOPeriod(ctx, dbi, id interface{}) *gomock.Call

GetExpiresAtAfterISOPeriod indicates an expected call of GetExpiresAtAfterISOPeriod.

func (*MockorderStoreMockRecorder) GetMetadata

func (mr *MockorderStoreMockRecorder) GetMetadata(ctx, dbi, id interface{}) *gomock.Call

GetMetadata indicates an expected call of GetMetadata.

func (*MockorderStoreMockRecorder) HasExternalID

func (mr *MockorderStoreMockRecorder) HasExternalID(ctx, dbi, extID interface{}) *gomock.Call

HasExternalID indicates an expected call of HasExternalID.

func (*MockorderStoreMockRecorder) SetExpiresAt

func (mr *MockorderStoreMockRecorder) SetExpiresAt(ctx, dbi, id, when interface{}) *gomock.Call

SetExpiresAt indicates an expected call of SetExpiresAt.

func (*MockorderStoreMockRecorder) SetLastPaidAt

func (mr *MockorderStoreMockRecorder) SetLastPaidAt(ctx, dbi, id, when interface{}) *gomock.Call

SetLastPaidAt indicates an expected call of SetLastPaidAt.

func (*MockorderStoreMockRecorder) SetStatus

func (mr *MockorderStoreMockRecorder) SetStatus(ctx, dbi, id, status interface{}) *gomock.Call

SetStatus indicates an expected call of SetStatus.

func (*MockorderStoreMockRecorder) SetTrialDays

func (mr *MockorderStoreMockRecorder) SetTrialDays(ctx, dbi, id, ndays interface{}) *gomock.Call

SetTrialDays indicates an expected call of SetTrialDays.

func (*MockorderStoreMockRecorder) UpdateMetadata

func (mr *MockorderStoreMockRecorder) UpdateMetadata(ctx, dbi, id, data interface{}) *gomock.Call

UpdateMetadata indicates an expected call of UpdateMetadata.

type Order

type Order = model.Order

TODO(pavelb): Gradually replace these everywhere.

type OrderCreds

type OrderCreds struct {
	ID           uuid.UUID                  `json:"id" db:"item_id"`
	OrderID      uuid.UUID                  `json:"orderId" db:"order_id"`
	IssuerID     uuid.UUID                  `json:"issuerId" db:"issuer_id"`
	BlindedCreds jsonutils.JSONStringArray  `json:"blindedCreds" db:"blinded_creds"`
	SignedCreds  *jsonutils.JSONStringArray `json:"signedCreds" db:"signed_creds"`
	BatchProof   *string                    `json:"batchProof" db:"batch_proof"`
	PublicKey    *string                    `json:"publicKey" db:"public_key"`
}

OrderCreds encapsulates the credentials to be signed in response to a completed order

type OrderItem

type OrderItem = model.OrderItem

TODO(pavelb): Gradually replace these everywhere.

type OrderWorker

type OrderWorker interface {
	SignOrderCreds(ctx context.Context, orderID uuid.UUID, issuer Issuer, blindedCreds []string) (*OrderCreds, error)
}

OrderWorker attempts to work on an order job by signing the blinded credentials of the client

type Postgres

type Postgres struct {
	datastore.Postgres
	// contains filtered or unexported fields
}

Postgres is a Datastore wrapper around a postgres database

func (*Postgres) AppendOrderMetadata

func (pg *Postgres) AppendOrderMetadata(ctx context.Context, orderID *uuid.UUID, key, value string) error

AppendOrderMetadata appends the key and string value to an order's metadata.

func (*Postgres) AppendOrderMetadataInt

func (pg *Postgres) AppendOrderMetadataInt(ctx context.Context, orderID *uuid.UUID, key string, value int) error

AppendOrderMetadataInt appends the key and int value to an order's metadata.

func (*Postgres) AppendOrderMetadataInt64

func (pg *Postgres) AppendOrderMetadataInt64(ctx context.Context, orderID *uuid.UUID, key string, value int64) error

AppendOrderMetadataInt64 appends the key and int64 value to an order's metadata.

func (*Postgres) AreTimeLimitedV2CredsSubmitted

func (pg *Postgres) AreTimeLimitedV2CredsSubmitted(ctx context.Context, requestID uuid.UUID, blindedCreds ...string) (AreTimeLimitedV2CredsSubmittedResult, error)

func (*Postgres) CheckExpiredCheckoutSession

func (pg *Postgres) CheckExpiredCheckoutSession(orderID uuid.UUID) (bool, string, error)

CheckExpiredCheckoutSession indicates whether a Stripe checkout session is expired with its id for the given orderID.

TODO(pavelb): The boolean return value is unnecessary, and can be removed. If there is experied session, the session id is present. If there is no session, or it has not expired, the result is the same – no session id. It's the caller's responsibility (the business logic layer) to interpret the result.

func (*Postgres) CommitVote

func (pg *Postgres) CommitVote(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error

CommitVote - Update a vote to show it has been processed, designed to run on a transaction so a batch number of votes can be processed.

func (*Postgres) CreateKey

func (pg *Postgres) CreateKey(merchant string, name string, encryptedSecretKey string, nonce string) (*Key, error)

CreateKey creates an encrypted key in the database based on the merchant

func (*Postgres) CreateOrder

func (pg *Postgres) CreateOrder(ctx context.Context, dbi sqlx.ExtContext, oreq *model.OrderNew, items []model.OrderItem) (*model.Order, error)

CreateOrder creates an order from the given prototype, and inserts items.

func (*Postgres) CreateTransaction

func (pg *Postgres) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error)

CreateTransaction creates a transaction given an orderID, externalTransactionID, currency, and a kind of transaction

func (*Postgres) DeleteKey

func (pg *Postgres) DeleteKey(id uuid.UUID, delaySeconds int) (*Key, error)

DeleteKey updates a key with an expiration time based on the id

func (*Postgres) DeleteSigningOrderRequestOutboxByOrderTx

func (pg *Postgres) DeleteSigningOrderRequestOutboxByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error

DeleteSigningOrderRequestOutboxByOrderTx performs a hard delete of all signing order request outbox messages for a given orderID.

func (*Postgres) DeleteSingleUseOrderCredsByOrderTx

func (pg *Postgres) DeleteSingleUseOrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID, isSigned bool) error

DeleteSingleUseOrderCredsByOrderTx performs a hard delete all single use order credentials for a given OrderID.

func (*Postgres) DeleteTimeLimitedV2OrderCredsByOrderTx

func (pg *Postgres) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error

DeleteTimeLimitedV2OrderCredsByOrderTx performs a hard delete for all time limited v2 order credentials for a given OrderID.

func (*Postgres) GetIssuerByPublicKey deprecated

func (pg *Postgres) GetIssuerByPublicKey(pubKey string) (*Issuer, error)

GetIssuerByPublicKey returns an issuer by the pubKey.

Deprecated: Use the corresponding repository directly with GetByPubKey.

func (*Postgres) GetKey

func (pg *Postgres) GetKey(id uuid.UUID, showExpired bool) (*Key, error)

GetKey returns the specified key, conditionally checking if it is expired

func (*Postgres) GetKeysByMerchant

func (pg *Postgres) GetKeysByMerchant(merchant string, showExpired bool) (*[]Key, error)

GetKeysByMerchant returns a list of active API keys

func (*Postgres) GetOrder

func (pg *Postgres) GetOrder(orderID uuid.UUID) (*Order, error)

GetOrder returns an order from the database.

func (*Postgres) GetOrderByExternalID

func (pg *Postgres) GetOrderByExternalID(externalID string) (*Order, error)

GetOrderByExternalID returns an order by the external id from the purchase vendor.

func (*Postgres) GetOrderCreds

func (pg *Postgres) GetOrderCreds(orderID uuid.UUID, isSigned bool) ([]OrderCreds, error)

GetOrderCreds returns the order credentials for a OrderID

func (*Postgres) GetOrderCredsByItemID

func (pg *Postgres) GetOrderCredsByItemID(orderID uuid.UUID, itemID uuid.UUID, isSigned bool) (*OrderCreds, error)

GetOrderCredsByItemID returns the order credentials for a OrderID by the itemID.

func (*Postgres) GetOrderItem

func (pg *Postgres) GetOrderItem(ctx context.Context, itemID uuid.UUID) (*OrderItem, error)

GetOrderItem retrieves the order item for the given identifier.

It returns sql.ErrNoRows if the item is not found.

func (*Postgres) GetOrderTimeLimitedV2Creds

func (pg *Postgres) GetOrderTimeLimitedV2Creds(orderID uuid.UUID) (*[]TimeLimitedV2Creds, error)

GetOrderTimeLimitedV2Creds returns all order credentials for an order.

func (*Postgres) GetOrderTimeLimitedV2CredsByItemID

func (pg *Postgres) GetOrderTimeLimitedV2CredsByItemID(orderID uuid.UUID, itemID uuid.UUID) (*TimeLimitedV2Creds, error)

GetOrderTimeLimitedV2CredsByItemID returns the order credentials by order and item.

func (*Postgres) GetOutboxMovAvgDurationSeconds

func (pg *Postgres) GetOutboxMovAvgDurationSeconds() (int64, error)

GetOutboxMovAvgDurationSeconds - get the number of seconds it takes to clear the last 20 outbox messages

func (*Postgres) GetPagedMerchantTransactions

func (pg *Postgres) GetPagedMerchantTransactions(
	ctx context.Context, merchantID uuid.UUID, pagination *inputs.Pagination) (*[]Transaction, int, error)

GetPagedMerchantTransactions - get a paginated list of transactions for a merchant

func (*Postgres) GetSigningOrderRequestOutboxByOrder

func (pg *Postgres) GetSigningOrderRequestOutboxByOrder(ctx context.Context, orderID uuid.UUID) ([]SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByOrder retrieves the latest signing order from the outbox.

func (*Postgres) GetSigningOrderRequestOutboxByOrderItem

func (pg *Postgres) GetSigningOrderRequestOutboxByOrderItem(ctx context.Context, itemID uuid.UUID) ([]SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByOrderItem retrieves the latest signing order from the outbox. An empty result set is returned if no rows are found.

func (*Postgres) GetSigningOrderRequestOutboxByRequestID

func (pg *Postgres) GetSigningOrderRequestOutboxByRequestID(ctx context.Context, dbi sqlx.QueryerContext, reqID uuid.UUID) (*SigningOrderRequestOutbox, error)

GetSigningOrderRequestOutboxByRequestID retrieves the SigningOrderRequestOutbox by requestID.

An error is returned if the result set is empty.

func (*Postgres) GetSumForTransactions

func (pg *Postgres) GetSumForTransactions(orderID uuid.UUID) (decimal.Decimal, error)

GetSumForTransactions returns the calculated sum

func (*Postgres) GetTLV2Creds

func (pg *Postgres) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID uuid.UUID) (*TimeLimitedV2Creds, error)

GetTLV2Creds returns all the non expired tlv2 credentials for a given order, item and request ids.

If no credentials have been found, the method returns errNoTLV2Creds.

func (*Postgres) GetTimeLimitedV2OrderCredsByOrder

func (pg *Postgres) GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (*TimeLimitedV2Creds, error)

GetTimeLimitedV2OrderCredsByOrder returns all the non expired time limited v2 order credentials for a given order.

func (*Postgres) GetTimeLimitedV2OrderCredsByOrderItem

func (pg *Postgres) GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (*TimeLimitedV2Creds, error)

GetTimeLimitedV2OrderCredsByOrderItem returns all the order credentials for a single order item.

func (*Postgres) GetTransaction

func (pg *Postgres) GetTransaction(externalTransactionID string) (*Transaction, error)

GetTransaction returns a single of transaction given an external transaction Id

func (*Postgres) GetTransactions

func (pg *Postgres) GetTransactions(orderID uuid.UUID) (*[]Transaction, error)

GetTransactions returns the list of transactions given an orderID

func (*Postgres) GetUncommittedVotesForUpdate

func (pg *Postgres) GetUncommittedVotesForUpdate(ctx context.Context) (*sqlx.Tx, []*VoteRecord, error)

GetUncommittedVotesForUpdate - row locking on number of votes we will be pulling returns a transaction to commit, the vote records, and an error

func (*Postgres) InsertOrderCredsTx

func (pg *Postgres) InsertOrderCredsTx(ctx context.Context, tx *sqlx.Tx, creds *OrderCreds) error

InsertOrderCredsTx inserts the given order creds.

func (*Postgres) InsertSignedOrderCredentialsTx

func (pg *Postgres) InsertSignedOrderCredentialsTx(ctx context.Context, tx *sqlx.Tx, signedOrderResult *SigningOrderResult) error

InsertSignedOrderCredentialsTx inserts a signed order request. It handles both TimeLimitedV2Creds and SingleUse credentials. All SigningOrder's in the SigningOrderResult must be successful to persist the overall result.

func (*Postgres) InsertSigningOrderRequestOutbox

func (pg *Postgres) InsertSigningOrderRequestOutbox(ctx context.Context, requestID, orderID, itemID uuid.UUID, signingOrderRequest SigningOrderRequest) error

InsertSigningOrderRequestOutbox inserts the signing order request into the outbox.

func (*Postgres) InsertTimeLimitedV2OrderCredsTx

func (pg *Postgres) InsertTimeLimitedV2OrderCredsTx(ctx context.Context, tx *sqlx.Tx, tlv2 TimeAwareSubIssuedCreds) error

InsertTimeLimitedV2OrderCredsTx inserts time limited v2 credentials.

func (*Postgres) InsertVote

func (pg *Postgres) InsertVote(ctx context.Context, vr VoteRecord) error

InsertVote - Add a vote to our "queue" to be processed

func (*Postgres) IsStripeSub

func (pg *Postgres) IsStripeSub(orderID uuid.UUID) (bool, string, error)

IsStripeSub reports whether the order is associated with a stripe subscription, if true, subscription id is returned.

TODO(pavelb): This is a piece of business logic that leaked to the storage layer. Also, it unsuccessfully mimics the Go comma, ok idiom – bool and string should be swapped. But that's not necessary. If metadata was found, but there was no stripeSubscriptionId, it's known not to be a Stripe order.

func (*Postgres) MarkVoteErrored

func (pg *Postgres) MarkVoteErrored(ctx context.Context, vr VoteRecord, tx *sqlx.Tx) error

MarkVoteErrored - Update a vote to show it has errored, designed to run on a transaction so a batch number of votes can be processed.

func (*Postgres) SendSigningRequest

func (pg *Postgres) SendSigningRequest(ctx context.Context, signingRequestWriter SigningRequestWriter) error

SendSigningRequest sends batches of signing order requests to kafka for signing. Failed messages are logged and can be manually retried. Default batch size 10.

func (*Postgres) SetOrderPaid

func (pg *Postgres) SetOrderPaid(ctx context.Context, orderID *uuid.UUID) error

SetOrderPaid sets status to paid for the order, updates last paid and expiration.

func (*Postgres) SetOrderTrialDays

func (pg *Postgres) SetOrderTrialDays(ctx context.Context, orderID *uuid.UUID, days int64) (*Order, error)

SetOrderTrialDays sets the number of days of free trial for this order and returns the updated result.

func (*Postgres) UpdateOrder

func (pg *Postgres) UpdateOrder(orderID uuid.UUID, status string) error

UpdateOrder updates the orders status.

Status should either be one of pending, paid, fulfilled, or canceled.

TODO: rename it to better reflect the behaviour.

func (*Postgres) UpdateOrderMetadata deprecated

func (pg *Postgres) UpdateOrderMetadata(orderID uuid.UUID, key string, value string) error

UpdateOrderMetadata sets the order's metadata to the key and value.

Deprecated: This method is no longer used and should be deleted.

TODO(pavelb): Remove this method as it's dangerous and must not be used.

func (*Postgres) UpdateSigningOrderRequestOutboxTx

func (pg *Postgres) UpdateSigningOrderRequestOutboxTx(ctx context.Context, tx *sqlx.Tx, requestID uuid.UUID, completedAt time.Time) error

UpdateSigningOrderRequestOutboxTx updates a signing order request outbox message for the given requestID.

func (*Postgres) UpdateTransaction

func (pg *Postgres) UpdateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error)

UpdateTransaction creates a transaction given an orderID, externalTransactionID, currency, and a kind of transaction

type Service

type Service struct {

	// TODO: Eventually remove it.
	Datastore Datastore
	// contains filtered or unexported fields
}

Service contains datastore

func InitService

func InitService(ctx context.Context, datastore Datastore, walletService *wallet.Service, orderRepo orderStoreSvc, issuerRepo issuerStore) (*Service, error)

InitService creates a service using the passed datastore and clients configured from the environment.

func (*Service) CancelOrder

func (s *Service) CancelOrder(orderID uuid.UUID) error

CancelOrder cancels an order, propagates to stripe if needed.

TODO(pavelb): Refactor this.

func (*Service) CreateAnonCardTransaction

func (s *Service) CreateAnonCardTransaction(ctx context.Context, walletID uuid.UUID, transaction string, orderID uuid.UUID) (*Transaction, error)

CreateAnonCardTransaction takes a signed transaction and executes it on behalf of an anon card

func (*Service) CreateIssuer

func (s *Service) CreateIssuer(ctx context.Context, dbi sqlx.QueryerContext, merchID string, item *OrderItem) error

CreateIssuer creates a new v1 issuer if it does not exist.

This only happens in the event of a new sku being created.

func (*Service) CreateIssuerV3

func (s *Service) CreateIssuerV3(ctx context.Context, dbi sqlx.QueryerContext, merchID string, item *OrderItem, issuerCfg model.IssuerConfig) error

CreateIssuerV3 creates a new v3 issuer if it does not exist.

This only happens in the event of a new sku being created.

func (*Service) CreateOrder

func (s *Service) CreateOrder(ctx context.Context, req *model.CreateOrderRequestNew) (*Order, error)

func (*Service) CreateOrderFromRequest

func (s *Service) CreateOrderFromRequest(ctx context.Context, req model.CreateOrderRequest) (*Order, error)

CreateOrderFromRequest creates an order from the request

func (*Service) CreateOrderItemCredentials

func (s *Service) CreateOrderItemCredentials(ctx context.Context, orderID, itemID, requestID uuid.UUID, blindedCreds []string) error

CreateOrderItemCredentials creates credentials for the given order id and item with the supplied blinded credentials.

It handles only paid orders.

func (*Service) CreateOrderItemFromMacaroon

func (s *Service) CreateOrderItemFromMacaroon(ctx context.Context, sku string, quantity int) (*OrderItem, []string, *model.IssuerConfig, error)

CreateOrderItemFromMacaroon creates an order item from a macaroon

func (*Service) CreateTransactionFromRequest

func (s *Service) CreateTransactionFromRequest(ctx context.Context, req CreateTransactionRequest, orderID uuid.UUID, getCustodialTx getCustodialTxFn) (*Transaction, error)

CreateTransactionFromRequest queries the endpoints and creates a transaction

func (*Service) Decode

func (s *Service) Decode(message kafka.Message) (*SigningOrderResult, error)

Decode decodes the kafka message using from the avro schema.

func (*Service) DeleteOrderCreds

func (s *Service) DeleteOrderCreds(ctx context.Context, orderID uuid.UUID, isSigned bool) error

DeleteOrderCreds hard-deletes all the order credentials associated with the given orderID.

This includes both time-limited-v2 and single-use credentials. The isSigned param only applies to single use and will always be false for time-limited-v2. Credentials cannot be deleted when an order is in the process of being signed.

TODO(pavelb): - create repos for credentials; - move the corresponding methods there; - make those methods work on per-item basis.

func (*Service) GetActiveCredentialSigningKey

func (s *Service) GetActiveCredentialSigningKey(ctx context.Context, merchantID string) ([]byte, error)

GetActiveCredentialSigningKey get the current active signing key for this merchant

func (*Service) GetCredentialSigningKeys

func (s *Service) GetCredentialSigningKeys(ctx context.Context, merchantID string) ([][]byte, error)

GetCredentialSigningKeys get the current list of credential signing keys for this merchant

func (*Service) GetCredentials

func (s *Service) GetCredentials(ctx context.Context, orderID uuid.UUID) (interface{}, int, error)

GetCredentials returns credentials on the order.

This is a legacy method. For backward compatibility, similar to creating credentials, it uses item id as request id.

func (*Service) GetItemCredentials

func (s *Service) GetItemCredentials(ctx context.Context, orderID, itemID, reqID uuid.UUID) (interface{}, int, error)

GetItemCredentials returns credentials based on the order, item and request id.

func (*Service) GetOrder

func (s *Service) GetOrder(orderID uuid.UUID) (*Order, error)

GetOrder - business logic for getting an order, needs to validate the checkout session is not expired

func (*Service) GetSingleUseCreds

func (s *Service) GetSingleUseCreds(ctx context.Context, orderID, itemID, reqID uuid.UUID) ([]OrderCreds, int, error)

GetSingleUseCreds returns single use credentials for a given order, item and request.

If the credentials have been submitted but not yet signed it returns a http.StatusAccepted and an empty body. If the credentials have been signed it will return a http.StatusOK and the order credentials.

func (*Service) GetTimeLimitedCreds

func (s *Service) GetTimeLimitedCreds(ctx context.Context, order *Order, itemID, reqID uuid.UUID) ([]TimeLimitedCreds, int, error)

GetTimeLimitedCreds returns get an order's time limited creds.

func (*Service) GetTimeLimitedV2Creds

func (s *Service) GetTimeLimitedV2Creds(ctx context.Context, orderID, itemID, reqID uuid.UUID) ([]TimeAwareSubIssuedCreds, int, error)

GetTimeLimitedV2Creds returns all the tlv2 credentials for a given order, item and request id.

If the credentials have been submitted but not yet signed it returns a http.StatusAccepted and an empty body. If the credentials have been signed it will return a http.StatusOK and the time limited v2 credentials.

Browser's api_request_helper does not understand Go's nil slices, hence explicit empty slice is returned.

func (*Service) InitKafka

func (s *Service) InitKafka(ctx context.Context) error

InitKafka by creating a kafka writer and creating local copies of codecs

func (*Service) IsOrderPaid

func (s *Service) IsOrderPaid(orderID uuid.UUID) (bool, error)

IsOrderPaid determines if the order has been paid

func (*Service) IsPaused

func (s *Service) IsPaused() bool

IsPaused - is the worker paused?

func (*Service) Jobs

func (s *Service) Jobs() []srv.Job

Jobs - Implement srv.JobService interface

func (*Service) LookupVerifier

func (s *Service) LookupVerifier(ctx context.Context, keyID string) (context.Context, *httpsignature.Verifier, error)

LookupVerifier returns the merchant key corresponding to the keyID used for verifying requests

func (*Service) PauseWorker

func (s *Service) PauseWorker(until time.Time)

PauseWorker - pause worker until time specified

func (*Service) RenewOrder

func (s *Service) RenewOrder(ctx context.Context, orderID uuid.UUID) error

RenewOrder updates the order status to paid and records payment history.

Status should either be one of pending, paid, fulfilled, or canceled.

func (*Service) RunNextVoteDrainJob

func (s *Service) RunNextVoteDrainJob(ctx context.Context) (bool, error)

RunNextVoteDrainJob - Attempt to drain the vote queue

func (*Service) RunSendSigningRequestJob

func (s *Service) RunSendSigningRequestJob(ctx context.Context) (bool, error)

RunSendSigningRequestJob - send the order credentials signing requests

func (*Service) RunStoreSignedOrderCredentials

func (s *Service) RunStoreSignedOrderCredentials(ctx context.Context, backoff time.Duration)

RunStoreSignedOrderCredentials starts a signed order credentials consumer. This function creates a new signed order credentials consumer and starts processing messages. If the consumers errors we backoff, close the reader and restarts the consumer.

func (*Service) SetOrderTrialDays

func (s *Service) SetOrderTrialDays(ctx context.Context, orderID *uuid.UUID, days int64) error

func (*Service) SignOrderCreds

func (s *Service) SignOrderCreds(ctx context.Context, orderID uuid.UUID, issuer Issuer, blindedCreds []string) (*OrderCreds, error)

SignOrderCreds signs the blinded credentials

func (*Service) TransformStripeOrder

func (s *Service) TransformStripeOrder(order *Order) (*Order, error)

TransformStripeOrder updates checkout session if expired, checks the status of the checkout session.

func (*Service) UpdateOrderStatus

func (s *Service) UpdateOrderStatus(orderID uuid.UUID) error

UpdateOrderStatus checks to see if an order has been paid and updates it if so

func (*Service) UpdateOrderStatusPaidWithMetadata

func (s *Service) UpdateOrderStatusPaidWithMetadata(ctx context.Context, orderID *uuid.UUID, metadata datastore.Metadata) error

UpdateOrderStatusPaidWithMetadata - update the order status with metadata

func (*Service) UpdateTransactionFromRequest

func (s *Service) UpdateTransactionFromRequest(ctx context.Context, req CreateTransactionRequest, orderID uuid.UUID, getCustodialTx getCustodialTxFn) (*Transaction, error)

UpdateTransactionFromRequest queries the endpoints and creates a transaciton

func (*Service) Vote

func (s *Service) Vote(
	ctx context.Context, credentials []CredentialBinding, voteText string) error

Vote based on the browser's attention

func (*Service) WriteMessage

func (s *Service) WriteMessage(ctx context.Context, message []byte) error

WriteMessage writes a single message to the kafka topic configured on this writer.

func (*Service) WriteMessages

func (s *Service) WriteMessages(ctx context.Context, messages []SigningOrderRequestOutbox) error

WriteMessages writes a batch of SigningOrderRequestOutbox messages to the kafka topic configured on this writer.

type SignedOrder

type SignedOrder struct {
	PublicKey      string            `json:"public_key"`
	Proof          string            `json:"proof"`
	Status         SignedOrderStatus `json:"status"`
	SignedTokens   []string          `json:"signed_tokens"`
	BlindedTokens  []string          `json:"blinded_tokens"`
	ValidTo        *UnionNullString  `json:"valid_to"`
	ValidFrom      *UnionNullString  `json:"valid_from"`
	AssociatedData []byte            `json:"associated_data"`
}

SignedOrder - structure for a signed order

type SignedOrderCredentialsHandler

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

SignedOrderCredentialsHandler - this is the handler for getting the signed order credentials

func (*SignedOrderCredentialsHandler) Handle

func (s *SignedOrderCredentialsHandler) Handle(ctx context.Context, message kafka.Message) (err error)

Handle processes Kafka message of type SigningOrderResult.

type SignedOrderStatus

type SignedOrderStatus int

SignedOrderStatus - signed order status structure

const (
	// SignedOrderStatusOk - Okay status from signed order status
	SignedOrderStatusOk SignedOrderStatus = iota
	// SignedOrderStatusInvalidIssuer - invalid issuer
	SignedOrderStatusInvalidIssuer
	// SignedOrderStatusError - error status for signed order status
	SignedOrderStatusError
)

func (SignedOrderStatus) MarshalJSON

func (s SignedOrderStatus) MarshalJSON() ([]byte, error)

MarshalJSON - marshaller for signed order status

func (SignedOrderStatus) String

func (s SignedOrderStatus) String() string

String - stringer for signed order status

func (*SignedOrderStatus) UnmarshalJSON

func (s *SignedOrderStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for signed order status

type SigningOrder

type SigningOrder struct {
	AssociatedData []byte   `json:"associated_data"`
	BlindedTokens  []string `json:"blinded_tokens"`
	IssuerType     string   `json:"issuer_type"`
	IssuerCohort   int16    `json:"issuer_cohort"`
}

SigningOrder - signing order structure

type SigningOrderRequest

type SigningOrderRequest struct {
	RequestID string         `json:"request_id"`
	Data      []SigningOrder `json:"data"`
}

SigningOrderRequest - the structure of a signing order request

type SigningOrderRequestOutbox

type SigningOrderRequestOutbox struct {
	RequestID   uuid.UUID       `db:"request_id"`
	OrderID     uuid.UUID       `db:"order_id"`
	ItemID      uuid.UUID       `db:"item_id"`
	CompletedAt *time.Time      `db:"completed_at"`
	Message     json.RawMessage `db:"message_data" json:"message"`
}

SigningOrderRequestOutbox - model for the signing request outbox

type SigningOrderResult

type SigningOrderResult struct {
	RequestID string        `json:"request_id"`
	Data      []SignedOrder `json:"data"`
}

SigningOrderResult - structure of a signing result

type SigningOrderResultDecoder

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

SigningOrderResultDecoder - signed order result kafka message decoder interface

func (*SigningOrderResultDecoder) Decode

Decode decodes the kafka message using from the avro schema.

type SigningOrderResultErrorHandler

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

SigningOrderResultErrorHandler - error handler for signing results

func (*SigningOrderResultErrorHandler) Handle

func (s *SigningOrderResultErrorHandler) Handle(ctx context.Context, message kafka.Message, errorMessage error) error

Handle writes messages the SigningResultReader's dead letter queue.

type SigningRequestWriter

type SigningRequestWriter interface {
	WriteMessage(ctx context.Context, message []byte) error
	WriteMessages(ctx context.Context, messages []SigningOrderRequestOutbox) error
}

SigningRequestWriter is the interface implemented by types that can write signing request messages.

type SubscriptionNotification

type SubscriptionNotification struct {
	Version          string `json:"version"`
	NotificationType int    `json:"notificationType"`
	PurchaseToken    string `json:"purchaseToken"`
	SubscriptionID   string `json:"subscriptionId"`
}

SubscriptionNotification - an android subscription notification

type TimeAwareSubIssuedCreds

type TimeAwareSubIssuedCreds struct {
	OrderID      uuid.UUID                 `json:"orderId" db:"order_id"`
	ItemID       uuid.UUID                 `json:"itemId" db:"item_id"`
	IssuerID     uuid.UUID                 `json:"issuerId" db:"issuer_id"`
	ValidTo      time.Time                 `json:"validTo" db:"valid_to"`
	ValidFrom    time.Time                 `json:"validFrom" db:"valid_from"`
	BlindedCreds jsonutils.JSONStringArray `json:"blindedCreds" db:"blinded_creds"`
	SignedCreds  jsonutils.JSONStringArray `json:"signedCreds" db:"signed_creds"`
	BatchProof   string                    `json:"batchProof" db:"batch_proof"`
	PublicKey    string                    `json:"publicKey" db:"public_key"`
	RequestID    string                    `json:"-" db:"request_id"`
}

TimeAwareSubIssuedCreds sub issued time aware credentials

type TimeLimitedCreds

type TimeLimitedCreds struct {
	ID        uuid.UUID `json:"id"`
	OrderID   uuid.UUID `json:"orderId"`
	IssuedAt  string    `json:"issuedAt"`
	ExpiresAt string    `json:"expiresAt"`
	Token     string    `json:"token"`
}

TimeLimitedCreds encapsulates time-limited credentials

type TimeLimitedV2Creds

type TimeLimitedV2Creds struct {
	OrderID     uuid.UUID                 `json:"orderId"`
	IssuerID    uuid.UUID                 `json:"issuerId" `
	Credentials []TimeAwareSubIssuedCreds `json:"credentials"`
}

TimeLimitedV2Creds represent all the

type Transaction

type Transaction struct {
	ID                    uuid.UUID       `json:"id" db:"id"`
	OrderID               uuid.UUID       `json:"orderId" db:"order_id"`
	CreatedAt             time.Time       `json:"createdAt" db:"created_at"`
	UpdatedAt             time.Time       `json:"updatedAt" db:"updated_at"`
	ExternalTransactionID string          `json:"externalTransactionId" db:"external_transaction_id"`
	Status                string          `json:"status" db:"status"`
	Currency              string          `json:"currency" db:"currency"`
	Kind                  string          `json:"kind" db:"kind"`
	Amount                decimal.Decimal `json:"amount" db:"amount"`
}

Transaction includes information about a particular order. Status can be pending, failure, completed, or error.

type UnionNullString

type UnionNullString map[string]interface{}

UnionNullString - type describing

func (*UnionNullString) UnmarshalJSON

func (u *UnionNullString) UnmarshalJSON(data []byte) error

UnmarshalJSON - implement unmarshaling for union null string

func (UnionNullString) Value

func (u UnionNullString) Value() *string

Value - perform a valuer on unionnullstring

type VerifyCredentialOpaque

type VerifyCredentialOpaque struct {
	Type         string  `json:"type" valid:"in(single-use|time-limited|time-limited-v2)"`
	Version      float64 `json:"version" valid:"-"`
	Presentation string  `json:"presentation" valid:"base64"`
}

VerifyCredentialOpaque includes an opaque presentation blob

type VerifyCredentialRequestV1

type VerifyCredentialRequestV1 struct {
	Version      float64 `json:"version" valid:"-"`
	Type         string  `json:"type" valid:"in(single-use|time-limited|time-limited-v2)"`
	SKU          string  `json:"sku" valid:"-"`
	MerchantID   string  `json:"merchantId" valid:"-"`
	Presentation string  `json:"presentation" valid:"base64"`
}

VerifyCredentialRequestV1 includes an opaque subscription credential blob

func (*VerifyCredentialRequestV1) GetMerchantID

func (vcr *VerifyCredentialRequestV1) GetMerchantID(ctx context.Context) string

GetMerchantID - implement credential interface

func (*VerifyCredentialRequestV1) GetPresentation

func (vcr *VerifyCredentialRequestV1) GetPresentation(ctx context.Context) string

GetPresentation - implement credential interface

func (*VerifyCredentialRequestV1) GetSku

GetSku - implement credential interface

func (*VerifyCredentialRequestV1) GetType

func (vcr *VerifyCredentialRequestV1) GetType(ctx context.Context) string

GetType - implement credential interface

type VerifyCredentialRequestV2

type VerifyCredentialRequestV2 struct {
	SKU              string                  `json:"sku" valid:"-"`
	MerchantID       string                  `json:"merchantId" valid:"-"`
	Credential       string                  `json:"credential" valid:"base64"`
	CredentialOpaque *VerifyCredentialOpaque `json:"-" valid:"-"`
}

VerifyCredentialRequestV2 includes an opaque subscription credential blob

func (*VerifyCredentialRequestV2) Decode

func (vcr *VerifyCredentialRequestV2) Decode(ctx context.Context, data []byte) error

Decode - implement Decodable interface

func (*VerifyCredentialRequestV2) GetMerchantID

func (vcr *VerifyCredentialRequestV2) GetMerchantID(ctx context.Context) string

GetMerchantID - implement credential interface

func (*VerifyCredentialRequestV2) GetPresentation

func (vcr *VerifyCredentialRequestV2) GetPresentation(ctx context.Context) string

GetPresentation - implement credential interface

func (*VerifyCredentialRequestV2) GetSku

GetSku - implement credential interface

func (*VerifyCredentialRequestV2) GetType

func (vcr *VerifyCredentialRequestV2) GetType(ctx context.Context) string

GetType - implement credential interface

func (*VerifyCredentialRequestV2) Validate

func (vcr *VerifyCredentialRequestV2) Validate(ctx context.Context) error

Validate - implement Validable interface

type Vote

type Vote struct {
	Type          string `json:"type" valid:"in(auto-contribute|oneoff-tip|recurring-tip)"`
	Channel       string `json:"channel" valid:"-"`
	VoteTally     int64  `json:"-" valid:"-"`
	FundingSource string `json:"-" valid:"-"`
}

Vote encapsulates information from the browser about attention

func (*Vote) Base64Decode

func (v *Vote) Base64Decode(text string) error

Base64Decode unmarshalls the vote from a string.

func (*Vote) Decode

func (v *Vote) Decode(ctx context.Context, input []byte) error

Decode - implement inputs.Decodable interface for input

func (*Vote) Validate

func (v *Vote) Validate(ctx context.Context) error

Validate - implement inputs.Validatable interface for input

type VoteEvent

type VoteEvent struct {
	Type          string          `json:"type"`
	Channel       string          `json:"channel"`
	ID            uuid.UUID       `json:"id"`
	CreatedAt     time.Time       `json:"createdAt"`
	BaseVoteValue decimal.Decimal `json:"baseVoteValue"`
	VoteTally     int64           `json:"voteTally"`
	FundingSource string          `json:"fundingSource"`
}

VoteEvent encapsulates user and server provided information about a request to contribute kafka event

func NewVoteEvent

func NewVoteEvent(v Vote) (*VoteEvent, error)

NewVoteEvent - Create a new VoteEvent given a Vote

func (*VoteEvent) CodecDecode

func (ve *VoteEvent) CodecDecode(codec *goavro.Codec, binary []byte) error

CodecDecode - Decode using avro vote codec

func (*VoteEvent) CodecEncode

func (ve *VoteEvent) CodecEncode(codec *goavro.Codec) ([]byte, error)

CodecEncode - encode using avro vote codec

type VoteRecord

type VoteRecord struct {
	ID                 uuid.UUID
	RequestCredentials string
	VoteText           string
	VoteEventBinary    []byte
	Erred              bool
	Processed          bool
}

VoteRecord - how the ac votes are stored in the queue

type VoteRequest

type VoteRequest struct {
	Vote        string              `json:"vote" valid:"base64"`
	Credentials []CredentialBinding `json:"credentials"`
}

VoteRequest includes a suggestion payload and credentials to be redeemed

Directories

Path Synopsis
Package model provides data that the SKUs service operates on.
Package model provides data that the SKUs service operates on.
Package skustest provides utilities for testing skus.
Package skustest provides utilities for testing skus.
storage
repository
Package repository provides access to data available in SQL-based data store.
Package repository provides access to data available in SQL-based data store.

Jump to

Keyboard shortcuts

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