// Code generated by ent, DO NOT EDIT.

package ent

import (
	"fmt"
	"strings"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"github.com/Wei-Shaw/sub2api/ent/paymentorder"
	"github.com/Wei-Shaw/sub2api/ent/user"
)

// PaymentOrder is the model entity for the PaymentOrder schema.
type PaymentOrder struct {
	config `json:"-"`
	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// UserID holds the value of the "user_id" field.
	UserID int64 `json:"user_id,omitempty"`
	// UserEmail holds the value of the "user_email" field.
	UserEmail string `json:"user_email,omitempty"`
	// UserName holds the value of the "user_name" field.
	UserName string `json:"user_name,omitempty"`
	// UserNotes holds the value of the "user_notes" field.
	UserNotes *string `json:"user_notes,omitempty"`
	// Amount holds the value of the "amount" field.
	Amount float64 `json:"amount,omitempty"`
	// PayAmount holds the value of the "pay_amount" field.
	PayAmount float64 `json:"pay_amount,omitempty"`
	// FeeRate holds the value of the "fee_rate" field.
	FeeRate float64 `json:"fee_rate,omitempty"`
	// RechargeCode holds the value of the "recharge_code" field.
	RechargeCode string `json:"recharge_code,omitempty"`
	// OutTradeNo holds the value of the "out_trade_no" field.
	OutTradeNo string `json:"out_trade_no,omitempty"`
	// PaymentType holds the value of the "payment_type" field.
	PaymentType string `json:"payment_type,omitempty"`
	// PaymentTradeNo holds the value of the "payment_trade_no" field.
	PaymentTradeNo string `json:"payment_trade_no,omitempty"`
	// PayURL holds the value of the "pay_url" field.
	PayURL *string `json:"pay_url,omitempty"`
	// QrCode holds the value of the "qr_code" field.
	QrCode *string `json:"qr_code,omitempty"`
	// QrCodeImg holds the value of the "qr_code_img" field.
	QrCodeImg *string `json:"qr_code_img,omitempty"`
	// OrderType holds the value of the "order_type" field.
	OrderType string `json:"order_type,omitempty"`
	// PlanID holds the value of the "plan_id" field.
	PlanID *int64 `json:"plan_id,omitempty"`
	// SubscriptionGroupID holds the value of the "subscription_group_id" field.
	SubscriptionGroupID *int64 `json:"subscription_group_id,omitempty"`
	// SubscriptionDays holds the value of the "subscription_days" field.
	SubscriptionDays *int `json:"subscription_days,omitempty"`
	// ProviderInstanceID holds the value of the "provider_instance_id" field.
	ProviderInstanceID *string `json:"provider_instance_id,omitempty"`
	// ProviderKey holds the value of the "provider_key" field.
	ProviderKey *string `json:"provider_key,omitempty"`
	// Status holds the value of the "status" field.
	Status string `json:"status,omitempty"`
	// RefundAmount holds the value of the "refund_amount" field.
	RefundAmount float64 `json:"refund_amount,omitempty"`
	// RefundReason holds the value of the "refund_reason" field.
	RefundReason *string `json:"refund_reason,omitempty"`
	// RefundAt holds the value of the "refund_at" field.
	RefundAt *time.Time `json:"refund_at,omitempty"`
	// ForceRefund holds the value of the "force_refund" field.
	ForceRefund bool `json:"force_refund,omitempty"`
	// RefundRequestedAt holds the value of the "refund_requested_at" field.
	RefundRequestedAt *time.Time `json:"refund_requested_at,omitempty"`
	// RefundRequestReason holds the value of the "refund_request_reason" field.
	RefundRequestReason *string `json:"refund_request_reason,omitempty"`
	// RefundRequestedBy holds the value of the "refund_requested_by" field.
	RefundRequestedBy *string `json:"refund_requested_by,omitempty"`
	// ExpiresAt holds the value of the "expires_at" field.
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	// PaidAt holds the value of the "paid_at" field.
	PaidAt *time.Time `json:"paid_at,omitempty"`
	// CompletedAt holds the value of the "completed_at" field.
	CompletedAt *time.Time `json:"completed_at,omitempty"`
	// FailedAt holds the value of the "failed_at" field.
	FailedAt *time.Time `json:"failed_at,omitempty"`
	// FailedReason holds the value of the "failed_reason" field.
	FailedReason *string `json:"failed_reason,omitempty"`
	// ClientIP holds the value of the "client_ip" field.
	ClientIP string `json:"client_ip,omitempty"`
	// SrcHost holds the value of the "src_host" field.
	SrcHost string `json:"src_host,omitempty"`
	// SrcURL holds the value of the "src_url" field.
	SrcURL *string `json:"src_url,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the PaymentOrderQuery when eager-loading is set.
	Edges        PaymentOrderEdges `json:"edges"`
	selectValues sql.SelectValues
}

// PaymentOrderEdges holds the relations/edges for other nodes in the graph.
type PaymentOrderEdges struct {
	// User holds the value of the user edge.
	User *User `json:"user,omitempty"`
	// loadedTypes holds the information for reporting if a
	// type was loaded (or requested) in eager-loading or not.
	loadedTypes [1]bool
}

// UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e PaymentOrderEdges) UserOrErr() (*User, error) {
	if e.User != nil {
		return e.User, nil
	} else if e.loadedTypes[0] {
		return nil, &NotFoundError{label: user.Label}
	}
	return nil, &NotLoadedError{edge: "user"}
}

// scanValues returns the types for scanning values from sql.Rows.
func (*PaymentOrder) scanValues(columns []string) ([]any, error) {
	values := make([]any, len(columns))
	for i := range columns {
		switch columns[i] {
		case paymentorder.FieldForceRefund:
			values[i] = new(sql.NullBool)
		case paymentorder.FieldAmount, paymentorder.FieldPayAmount, paymentorder.FieldFeeRate, paymentorder.FieldRefundAmount:
			values[i] = new(sql.NullFloat64)
		case paymentorder.FieldID, paymentorder.FieldUserID, paymentorder.FieldPlanID, paymentorder.FieldSubscriptionGroupID, paymentorder.FieldSubscriptionDays:
			values[i] = new(sql.NullInt64)
		case paymentorder.FieldUserEmail, paymentorder.FieldUserName, paymentorder.FieldUserNotes, paymentorder.FieldRechargeCode, paymentorder.FieldOutTradeNo, paymentorder.FieldPaymentType, paymentorder.FieldPaymentTradeNo, paymentorder.FieldPayURL, paymentorder.FieldQrCode, paymentorder.FieldQrCodeImg, paymentorder.FieldOrderType, paymentorder.FieldProviderInstanceID, paymentorder.FieldProviderKey, paymentorder.FieldStatus, paymentorder.FieldRefundReason, paymentorder.FieldRefundRequestReason, paymentorder.FieldRefundRequestedBy, paymentorder.FieldFailedReason, paymentorder.FieldClientIP, paymentorder.FieldSrcHost, paymentorder.FieldSrcURL:
			values[i] = new(sql.NullString)
		case paymentorder.FieldRefundAt, paymentorder.FieldRefundRequestedAt, paymentorder.FieldExpiresAt, paymentorder.FieldPaidAt, paymentorder.FieldCompletedAt, paymentorder.FieldFailedAt, paymentorder.FieldCreatedAt, paymentorder.FieldUpdatedAt:
			values[i] = new(sql.NullTime)
		default:
			values[i] = new(sql.UnknownType)
		}
	}
	return values, nil
}

// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the PaymentOrder fields.
func (_m *PaymentOrder) assignValues(columns []string, values []any) error {
	if m, n := len(values), len(columns); m < n {
		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
	}
	for i := range columns {
		switch columns[i] {
		case paymentorder.FieldID:
			value, ok := values[i].(*sql.NullInt64)
			if !ok {
				return fmt.Errorf("unexpected type %T for field id", value)
			}
			_m.ID = int64(value.Int64)
		case paymentorder.FieldUserID:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field user_id", values[i])
			} else if value.Valid {
				_m.UserID = value.Int64
			}
		case paymentorder.FieldUserEmail:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field user_email", values[i])
			} else if value.Valid {
				_m.UserEmail = value.String
			}
		case paymentorder.FieldUserName:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field user_name", values[i])
			} else if value.Valid {
				_m.UserName = value.String
			}
		case paymentorder.FieldUserNotes:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field user_notes", values[i])
			} else if value.Valid {
				_m.UserNotes = new(string)
				*_m.UserNotes = value.String
			}
		case paymentorder.FieldAmount:
			if value, ok := values[i].(*sql.NullFloat64); !ok {
				return fmt.Errorf("unexpected type %T for field amount", values[i])
			} else if value.Valid {
				_m.Amount = value.Float64
			}
		case paymentorder.FieldPayAmount:
			if value, ok := values[i].(*sql.NullFloat64); !ok {
				return fmt.Errorf("unexpected type %T for field pay_amount", values[i])
			} else if value.Valid {
				_m.PayAmount = value.Float64
			}
		case paymentorder.FieldFeeRate:
			if value, ok := values[i].(*sql.NullFloat64); !ok {
				return fmt.Errorf("unexpected type %T for field fee_rate", values[i])
			} else if value.Valid {
				_m.FeeRate = value.Float64
			}
		case paymentorder.FieldRechargeCode:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field recharge_code", values[i])
			} else if value.Valid {
				_m.RechargeCode = value.String
			}
		case paymentorder.FieldOutTradeNo:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field out_trade_no", values[i])
			} else if value.Valid {
				_m.OutTradeNo = value.String
			}
		case paymentorder.FieldPaymentType:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field payment_type", values[i])
			} else if value.Valid {
				_m.PaymentType = value.String
			}
		case paymentorder.FieldPaymentTradeNo:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field payment_trade_no", values[i])
			} else if value.Valid {
				_m.PaymentTradeNo = value.String
			}
		case paymentorder.FieldPayURL:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field pay_url", values[i])
			} else if value.Valid {
				_m.PayURL = new(string)
				*_m.PayURL = value.String
			}
		case paymentorder.FieldQrCode:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field qr_code", values[i])
			} else if value.Valid {
				_m.QrCode = new(string)
				*_m.QrCode = value.String
			}
		case paymentorder.FieldQrCodeImg:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field qr_code_img", values[i])
			} else if value.Valid {
				_m.QrCodeImg = new(string)
				*_m.QrCodeImg = value.String
			}
		case paymentorder.FieldOrderType:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field order_type", values[i])
			} else if value.Valid {
				_m.OrderType = value.String
			}
		case paymentorder.FieldPlanID:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field plan_id", values[i])
			} else if value.Valid {
				_m.PlanID = new(int64)
				*_m.PlanID = value.Int64
			}
		case paymentorder.FieldSubscriptionGroupID:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field subscription_group_id", values[i])
			} else if value.Valid {
				_m.SubscriptionGroupID = new(int64)
				*_m.SubscriptionGroupID = value.Int64
			}
		case paymentorder.FieldSubscriptionDays:
			if value, ok := values[i].(*sql.NullInt64); !ok {
				return fmt.Errorf("unexpected type %T for field subscription_days", values[i])
			} else if value.Valid {
				_m.SubscriptionDays = new(int)
				*_m.SubscriptionDays = int(value.Int64)
			}
		case paymentorder.FieldProviderInstanceID:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field provider_instance_id", values[i])
			} else if value.Valid {
				_m.ProviderInstanceID = new(string)
				*_m.ProviderInstanceID = value.String
			}
		case paymentorder.FieldProviderKey:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field provider_key", values[i])
			} else if value.Valid {
				_m.ProviderKey = new(string)
				*_m.ProviderKey = value.String
			}
		case paymentorder.FieldStatus:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field status", values[i])
			} else if value.Valid {
				_m.Status = value.String
			}
		case paymentorder.FieldRefundAmount:
			if value, ok := values[i].(*sql.NullFloat64); !ok {
				return fmt.Errorf("unexpected type %T for field refund_amount", values[i])
			} else if value.Valid {
				_m.RefundAmount = value.Float64
			}
		case paymentorder.FieldRefundReason:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field refund_reason", values[i])
			} else if value.Valid {
				_m.RefundReason = new(string)
				*_m.RefundReason = value.String
			}
		case paymentorder.FieldRefundAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field refund_at", values[i])
			} else if value.Valid {
				_m.RefundAt = new(time.Time)
				*_m.RefundAt = value.Time
			}
		case paymentorder.FieldForceRefund:
			if value, ok := values[i].(*sql.NullBool); !ok {
				return fmt.Errorf("unexpected type %T for field force_refund", values[i])
			} else if value.Valid {
				_m.ForceRefund = value.Bool
			}
		case paymentorder.FieldRefundRequestedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field refund_requested_at", values[i])
			} else if value.Valid {
				_m.RefundRequestedAt = new(time.Time)
				*_m.RefundRequestedAt = value.Time
			}
		case paymentorder.FieldRefundRequestReason:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field refund_request_reason", values[i])
			} else if value.Valid {
				_m.RefundRequestReason = new(string)
				*_m.RefundRequestReason = value.String
			}
		case paymentorder.FieldRefundRequestedBy:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field refund_requested_by", values[i])
			} else if value.Valid {
				_m.RefundRequestedBy = new(string)
				*_m.RefundRequestedBy = value.String
			}
		case paymentorder.FieldExpiresAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field expires_at", values[i])
			} else if value.Valid {
				_m.ExpiresAt = value.Time
			}
		case paymentorder.FieldPaidAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field paid_at", values[i])
			} else if value.Valid {
				_m.PaidAt = new(time.Time)
				*_m.PaidAt = value.Time
			}
		case paymentorder.FieldCompletedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field completed_at", values[i])
			} else if value.Valid {
				_m.CompletedAt = new(time.Time)
				*_m.CompletedAt = value.Time
			}
		case paymentorder.FieldFailedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field failed_at", values[i])
			} else if value.Valid {
				_m.FailedAt = new(time.Time)
				*_m.FailedAt = value.Time
			}
		case paymentorder.FieldFailedReason:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field failed_reason", values[i])
			} else if value.Valid {
				_m.FailedReason = new(string)
				*_m.FailedReason = value.String
			}
		case paymentorder.FieldClientIP:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field client_ip", values[i])
			} else if value.Valid {
				_m.ClientIP = value.String
			}
		case paymentorder.FieldSrcHost:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field src_host", values[i])
			} else if value.Valid {
				_m.SrcHost = value.String
			}
		case paymentorder.FieldSrcURL:
			if value, ok := values[i].(*sql.NullString); !ok {
				return fmt.Errorf("unexpected type %T for field src_url", values[i])
			} else if value.Valid {
				_m.SrcURL = new(string)
				*_m.SrcURL = value.String
			}
		case paymentorder.FieldCreatedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field created_at", values[i])
			} else if value.Valid {
				_m.CreatedAt = value.Time
			}
		case paymentorder.FieldUpdatedAt:
			if value, ok := values[i].(*sql.NullTime); !ok {
				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
			} else if value.Valid {
				_m.UpdatedAt = value.Time
			}
		default:
			_m.selectValues.Set(columns[i], values[i])
		}
	}
	return nil
}

// Value returns the ent.Value that was dynamically selected and assigned to the PaymentOrder.
// This includes values selected through modifiers, order, etc.
func (_m *PaymentOrder) Value(name string) (ent.Value, error) {
	return _m.selectValues.Get(name)
}

// QueryUser queries the "user" edge of the PaymentOrder entity.
func (_m *PaymentOrder) QueryUser() *UserQuery {
	return NewPaymentOrderClient(_m.config).QueryUser(_m)
}

// Update returns a builder for updating this PaymentOrder.
// Note that you need to call PaymentOrder.Unwrap() before calling this method if this PaymentOrder
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *PaymentOrder) Update() *PaymentOrderUpdateOne {
	return NewPaymentOrderClient(_m.config).UpdateOne(_m)
}

// Unwrap unwraps the PaymentOrder entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *PaymentOrder) Unwrap() *PaymentOrder {
	_tx, ok := _m.config.driver.(*txDriver)
	if !ok {
		panic("ent: PaymentOrder is not a transactional entity")
	}
	_m.config.driver = _tx.drv
	return _m
}

// String implements the fmt.Stringer.
func (_m *PaymentOrder) String() string {
	var builder strings.Builder
	builder.WriteString("PaymentOrder(")
	builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
	builder.WriteString("user_id=")
	builder.WriteString(fmt.Sprintf("%v", _m.UserID))
	builder.WriteString(", ")
	builder.WriteString("user_email=")
	builder.WriteString(_m.UserEmail)
	builder.WriteString(", ")
	builder.WriteString("user_name=")
	builder.WriteString(_m.UserName)
	builder.WriteString(", ")
	if v := _m.UserNotes; v != nil {
		builder.WriteString("user_notes=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("amount=")
	builder.WriteString(fmt.Sprintf("%v", _m.Amount))
	builder.WriteString(", ")
	builder.WriteString("pay_amount=")
	builder.WriteString(fmt.Sprintf("%v", _m.PayAmount))
	builder.WriteString(", ")
	builder.WriteString("fee_rate=")
	builder.WriteString(fmt.Sprintf("%v", _m.FeeRate))
	builder.WriteString(", ")
	builder.WriteString("recharge_code=")
	builder.WriteString(_m.RechargeCode)
	builder.WriteString(", ")
	builder.WriteString("out_trade_no=")
	builder.WriteString(_m.OutTradeNo)
	builder.WriteString(", ")
	builder.WriteString("payment_type=")
	builder.WriteString(_m.PaymentType)
	builder.WriteString(", ")
	builder.WriteString("payment_trade_no=")
	builder.WriteString(_m.PaymentTradeNo)
	builder.WriteString(", ")
	if v := _m.PayURL; v != nil {
		builder.WriteString("pay_url=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	if v := _m.QrCode; v != nil {
		builder.WriteString("qr_code=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	if v := _m.QrCodeImg; v != nil {
		builder.WriteString("qr_code_img=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("order_type=")
	builder.WriteString(_m.OrderType)
	builder.WriteString(", ")
	if v := _m.PlanID; v != nil {
		builder.WriteString("plan_id=")
		builder.WriteString(fmt.Sprintf("%v", *v))
	}
	builder.WriteString(", ")
	if v := _m.SubscriptionGroupID; v != nil {
		builder.WriteString("subscription_group_id=")
		builder.WriteString(fmt.Sprintf("%v", *v))
	}
	builder.WriteString(", ")
	if v := _m.SubscriptionDays; v != nil {
		builder.WriteString("subscription_days=")
		builder.WriteString(fmt.Sprintf("%v", *v))
	}
	builder.WriteString(", ")
	if v := _m.ProviderInstanceID; v != nil {
		builder.WriteString("provider_instance_id=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	if v := _m.ProviderKey; v != nil {
		builder.WriteString("provider_key=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("status=")
	builder.WriteString(_m.Status)
	builder.WriteString(", ")
	builder.WriteString("refund_amount=")
	builder.WriteString(fmt.Sprintf("%v", _m.RefundAmount))
	builder.WriteString(", ")
	if v := _m.RefundReason; v != nil {
		builder.WriteString("refund_reason=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	if v := _m.RefundAt; v != nil {
		builder.WriteString("refund_at=")
		builder.WriteString(v.Format(time.ANSIC))
	}
	builder.WriteString(", ")
	builder.WriteString("force_refund=")
	builder.WriteString(fmt.Sprintf("%v", _m.ForceRefund))
	builder.WriteString(", ")
	if v := _m.RefundRequestedAt; v != nil {
		builder.WriteString("refund_requested_at=")
		builder.WriteString(v.Format(time.ANSIC))
	}
	builder.WriteString(", ")
	if v := _m.RefundRequestReason; v != nil {
		builder.WriteString("refund_request_reason=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	if v := _m.RefundRequestedBy; v != nil {
		builder.WriteString("refund_requested_by=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("expires_at=")
	builder.WriteString(_m.ExpiresAt.Format(time.ANSIC))
	builder.WriteString(", ")
	if v := _m.PaidAt; v != nil {
		builder.WriteString("paid_at=")
		builder.WriteString(v.Format(time.ANSIC))
	}
	builder.WriteString(", ")
	if v := _m.CompletedAt; v != nil {
		builder.WriteString("completed_at=")
		builder.WriteString(v.Format(time.ANSIC))
	}
	builder.WriteString(", ")
	if v := _m.FailedAt; v != nil {
		builder.WriteString("failed_at=")
		builder.WriteString(v.Format(time.ANSIC))
	}
	builder.WriteString(", ")
	if v := _m.FailedReason; v != nil {
		builder.WriteString("failed_reason=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("client_ip=")
	builder.WriteString(_m.ClientIP)
	builder.WriteString(", ")
	builder.WriteString("src_host=")
	builder.WriteString(_m.SrcHost)
	builder.WriteString(", ")
	if v := _m.SrcURL; v != nil {
		builder.WriteString("src_url=")
		builder.WriteString(*v)
	}
	builder.WriteString(", ")
	builder.WriteString("created_at=")
	builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
	builder.WriteString(", ")
	builder.WriteString("updated_at=")
	builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
	builder.WriteByte(')')
	return builder.String()
}

// PaymentOrders is a parsable slice of PaymentOrder.
type PaymentOrders []*PaymentOrder
