// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.26.0
// source: stripe_card_payment.sql

package payment

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
	"github.com/shopspring/decimal"
)

const create = `-- name: Create :exec
INSERT INTO stripe_card_payments
    (order_id, user_id, billing_address_id, payment_intent_id, payment_method_id, amount, currency, status, client_secret, last_error, card_last4, card_brand, created_at)
VALUES
    ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
`

func (q *Queries) Create(ctx context.Context, orderID int64, userID *int64, billingAddressID int64, paymentIntentID string, paymentMethodID *string, amount decimal.Decimal, currency string, status string, clientSecret *string, lastError *string, cardLast4 string, cardBrand string, createdAt pgtype.Timestamptz) error {
	_, err := q.db.Exec(ctx, create,
		orderID,
		userID,
		billingAddressID,
		paymentIntentID,
		paymentMethodID,
		amount,
		currency,
		status,
		clientSecret,
		lastError,
		cardLast4,
		cardBrand,
		createdAt,
	)
	return err
}

const getByOrderID = `-- name: GetByOrderID :one
SELECT id, order_id, user_id, billing_address_id, payment_intent_id, payment_method_id, amount, currency, status, client_secret, last_error, card_last4, card_brand, created_at, updated_at FROM stripe_card_payments
WHERE order_id = $1
`

func (q *Queries) GetByOrderID(ctx context.Context, orderID int64) (*StripeCardPayment, error) {
	row := q.db.QueryRow(ctx, getByOrderID, orderID)
	var i StripeCardPayment
	err := row.Scan(
		&i.ID,
		&i.OrderID,
		&i.UserID,
		&i.BillingAddressID,
		&i.PaymentIntentID,
		&i.PaymentMethodID,
		&i.Amount,
		&i.Currency,
		&i.Status,
		&i.ClientSecret,
		&i.LastError,
		&i.CardLast4,
		&i.CardBrand,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return &i, err
}
