131 lines
4.0 KiB
Go
131 lines
4.0 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
|
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: payment_mappings.sql
|
|
|
|
package stripe
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const countPaymentMappingsOutsideMode = `-- name: CountPaymentMappingsOutsideMode :one
|
|
SELECT COUNT(*) FROM stripe.payment_mappings
|
|
WHERE livemode IS NOT NULL AND livemode <> $1::boolean
|
|
`
|
|
|
|
func (q *Queries) CountPaymentMappingsOutsideMode(ctx context.Context, keyLivemode bool) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countPaymentMappingsOutsideMode, keyLivemode)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const getPaymentMappingByPaymentID = `-- name: GetPaymentMappingByPaymentID :one
|
|
SELECT payment_id, stripe_payment_intent_id, sync_status, created_at, updated_at, livemode FROM stripe.payment_mappings
|
|
WHERE payment_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPaymentMappingByPaymentID(ctx context.Context, paymentID string) (PaymentMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getPaymentMappingByPaymentID, paymentID)
|
|
var i PaymentMapping
|
|
err := row.Scan(
|
|
&i.PaymentID,
|
|
&i.StripePaymentIntentID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Livemode,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPaymentMappingByStripePaymentIntentID = `-- name: GetPaymentMappingByStripePaymentIntentID :one
|
|
SELECT payment_id, stripe_payment_intent_id, sync_status, created_at, updated_at, livemode FROM stripe.payment_mappings
|
|
WHERE stripe_payment_intent_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPaymentMappingByStripePaymentIntentID(ctx context.Context, stripePaymentIntentID sql.NullString) (PaymentMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getPaymentMappingByStripePaymentIntentID, stripePaymentIntentID)
|
|
var i PaymentMapping
|
|
err := row.Scan(
|
|
&i.PaymentID,
|
|
&i.StripePaymentIntentID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Livemode,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertPaymentMapping = `-- name: InsertPaymentMapping :one
|
|
INSERT INTO stripe.payment_mappings (payment_id, stripe_payment_intent_id, sync_status, livemode)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING payment_id, stripe_payment_intent_id, sync_status, created_at, updated_at, livemode
|
|
`
|
|
|
|
type InsertPaymentMappingParams struct {
|
|
PaymentID string `json:"payment_id"`
|
|
StripePaymentIntentID sql.NullString `json:"stripe_payment_intent_id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
Livemode sql.NullBool `json:"livemode"`
|
|
}
|
|
|
|
// livemode is the invoice object's own flag inside the stored payload
|
|
// (stripe-environment-stamp D1): the payment is projected from the
|
|
// invoice, and its payment intent lives in the same Stripe environment.
|
|
func (q *Queries) InsertPaymentMapping(ctx context.Context, arg InsertPaymentMappingParams) (PaymentMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, insertPaymentMapping,
|
|
arg.PaymentID,
|
|
arg.StripePaymentIntentID,
|
|
arg.SyncStatus,
|
|
arg.Livemode,
|
|
)
|
|
var i PaymentMapping
|
|
err := row.Scan(
|
|
&i.PaymentID,
|
|
&i.StripePaymentIntentID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Livemode,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listPaymentIDsOutsideMode = `-- name: ListPaymentIDsOutsideMode :many
|
|
SELECT payment_id FROM stripe.payment_mappings
|
|
WHERE livemode IS NOT NULL AND livemode <> $1::boolean
|
|
`
|
|
|
|
// The payments the operator view excludes under the current key
|
|
// (stripe-environment-stamp D7). A NULL livemode is unverified and shows
|
|
// under either key, so it is not in this list.
|
|
func (q *Queries) ListPaymentIDsOutsideMode(ctx context.Context, keyLivemode bool) ([]string, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPaymentIDsOutsideMode, keyLivemode)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []string{}
|
|
for rows.Next() {
|
|
var payment_id string
|
|
if err := rows.Scan(&payment_id); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, payment_id)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|