add some
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
guwandyk committed 2026-09-19 04:47:43 +05:00
1 parent 6c7c402390
commit 599c12ef87
9 files changed
+68 -25

No files matched your search

@@ -101,6 +101,7 @@ func (r *repository) Quote(ctx context.Context, orderID int64) (visamasterpay.Pa
Type: derefOrEmpty(orderType),
ExchangeRateUsd: usdRate,
MaxAmountTmt: round2(*amountUsd * usdRate),
PayableToday: isPayableDay(time.Now()),
}
if isSber(orderType) {
@@ -142,6 +143,10 @@ func (r *repository) Pay(ctx context.Context, orderID int64, dto visamasterpay.P
if err != nil {
return visamasterpay.PaymentInitResultDTO{}, err
}
if !isPayableDay(time.Now()) {
r.logStep(ctx, orderID, dto.CreatedBy, "rejected", map[string]string{"reason": "payment_window_closed"})
return visamasterpay.PaymentInitResultDTO{}, visamasterpay.ErrPaymentWindowClosed
}
if paid {
r.logStep(ctx, orderID, dto.CreatedBy, "rejected", map[string]string{"reason": "already_paid"})
return visamasterpay.PaymentInitResultDTO{}, visamasterpay.ErrAlreadyPaid
@@ -411,6 +416,20 @@ func (r *repository) fetchRate(ctx context.Context, from string) (float64, error
return strconv.ParseFloat(result.Currencies[0].Value.String(), 64)
}
// ashgabatZone is Turkmenistan's fixed UTC+5 offset (no DST observed).
var ashgabatZone = time.FixedZone("+05", 5*60*60)
// isPayableDay reports whether GBÜS payouts can be initiated on t's
// Ashgabat-local calendar day - false on Saturday/Sunday, since GBÜS/the
// bank does not process payouts on weekends. Because Saturday and Sunday
// are always adjacent, this alone also produces the right month-end cutoff
// (e.g. if the 31st is a Sunday, the 30th is a Saturday, so the 29th -
// Friday - is the last payable day) without any separate month-end logic.
func isPayableDay(t time.Time) bool {
wd := t.In(ashgabatZone).Weekday()
return wd != time.Saturday && wd != time.Sunday
}
func isSber(orderType *string) bool {
return orderType != nil && strings.EqualFold(strings.TrimSpace(*orderType), orderTypeSber)
}