94 lines
4.3 KiB
Go
94 lines
4.3 KiB
Go
package visamasterpay
|
|
|
|
import (
|
|
"time"
|
|
|
|
"online-back/internal/shared"
|
|
)
|
|
|
|
// PaymentQuoteDTO is what the "Töleg" modal loads before the operator picks
|
|
// an amount. Which fields are populated depends on the order's type:
|
|
// Visa/Master orders use BankFeeTmt + GbusFeeTmt against the USD rate;
|
|
// Sber orders have no GBÜS fee but add a USD-denominated TVEB fee (shown
|
|
// both as-is and converted to TMT) and also show the RUB rate for
|
|
// reference, using their own SberBankFeeTmt instead of BankFeeTmt.
|
|
// PayableToday is false on Saturday/Sunday (Asia/Ashgabat) - GBÜS/the bank
|
|
// does not process payouts on weekends, so the frontend should disable the
|
|
// Pay action rather than let the request fail.
|
|
type PaymentQuoteDTO struct {
|
|
Type string `json:"type"`
|
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
|
MaxAmountTmt float64 `json:"maxAmountTmt"`
|
|
PayableToday bool `json:"payableToday"`
|
|
}
|
|
|
|
// PayOrderDTO starts a payout attempt for a visa/master/sber order.
|
|
// AmountTmt is optional: if omitted, the full requested amount
|
|
// (amount_usd * rate) is used; if provided (the modal's amount field is
|
|
// editable, capped at the max), it's validated against that max instead.
|
|
// PaymentPeriod is optional too - only the Visa/Master modal shows a
|
|
// payment-month picker; Sber orders default to the current month when
|
|
// omitted.
|
|
type PayOrderDTO struct {
|
|
PaymentPeriod *shared.FlexibleTime `json:"paymentPeriod" swaggertype:"string" format:"date"`
|
|
AmountTmt *float64 `json:"amountTmt"`
|
|
CreatedBy *int64 `json:"-"`
|
|
}
|
|
|
|
// PaymentInitResultDTO is the immediate result of starting a payout:
|
|
// GBÜS only registers the payment and hands back a hosted-payment-page URL
|
|
// - the customer (or the operator, in-branch) must complete payment there.
|
|
// The definitive outcome only becomes known once GBÜS redirects back to
|
|
// our callback, which verifies and finalizes it - see PaymentResultDTO.
|
|
// SuccessUrl is that same callback URL (embedded in the GBÜS register
|
|
// request as ReturnURL) - the frontend can watch for navigation to it
|
|
// inside the hosted-payment-page webview to know the flow has ended.
|
|
type PaymentInitResultDTO struct {
|
|
PaymentId int64 `json:"paymentId"`
|
|
OrderId int64 `json:"orderId"`
|
|
OrderNumber string `json:"orderNumber"`
|
|
FormUrl string `json:"formUrl"`
|
|
SuccessUrl string `json:"successUrl"`
|
|
}
|
|
|
|
// CallbackResultDTO is what the GBÜS callback responds with, once GBÜS
|
|
// redirects the browser back after payment. Paid reflects the verified
|
|
// server-to-server outcome (not merely that GBÜS redirected here), and Data
|
|
// is a Turkmen-language message describing the result for display.
|
|
type CallbackResultDTO struct {
|
|
Paid bool `json:"paid"`
|
|
Data string `json:"data"`
|
|
}
|
|
|
|
// PaymentResultDTO is one payout attempt's final, verified state, recorded
|
|
// as its own row in visa_master_order_payments (a full audit trail -
|
|
// failed attempts are kept, not overwritten by a retry) - deliberately not
|
|
// the full order+branch+user DTO owned by cards/visamaster (fetch that
|
|
// separately via GET /visa-master-payment-orders/:id).
|
|
type PaymentResultDTO struct {
|
|
Id int64 `json:"id"`
|
|
OrderId int64 `json:"orderId"`
|
|
OrderNumber string `json:"orderNumber"`
|
|
Type string `json:"type"`
|
|
Paid bool `json:"paid"`
|
|
AmountUsd float64 `json:"amountUsd"`
|
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
|
AmountTmt float64 `json:"amountTmt"`
|
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
|
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
|
PaymentPeriod time.Time `json:"paymentPeriod"`
|
|
GatewayStatus string `json:"gatewayStatus"`
|
|
GatewayReference *string `json:"gatewayReference,omitempty"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|