eef90a152e
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 19s
CI / ui (pull_request) Successful in 1m16s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m0s
Split the single Robokassa direct rail into one merchant shop per channel (web / android; ios later), chosen by the trusted X-Platform subtype, while every shop still credits the one `direct` wallet — merchant-account separation for accounting and receipts, not a new wallet. - config: a channel-keyed shops registry (web seeds from the legacy vars or _WEB_*, android from _ANDROID_*); an empty shop leaves the rail dormant; per-shop validation. - intake: the order picks its shop by subtype (unknown falls back to web); the per-shop Result callback is verified by that shop's own Password2 at /pay/robokassa/result/<channel> (the gateway extracts the channel; Caddy's /pay/* glob already forwards it — no Caddyfile change). - persistence: an additive `shop` column on the order (migration 00015), recorded from the payment context, surfaced per entry in the admin report. - standalone apps sign in by email only, so a direct purchase keeps its email anchor. - docs: PAYMENTS (+ru) topology, deploy env vars + compose mapping, the decisions log (D41 revised for the ИП / 54-ФЗ move; D42-D44), the plan. Contour-safe: dormant until shops are configured; the migration is additive (no wipe); no client wire change. Fiscalization (Receipt/Email) and the gateway `direct/android` subtype follow when the ИП / RuStore are live.
53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
package robokassa
|
|
|
|
import "testing"
|
|
|
|
func TestShopsShopRouting(t *testing.T) {
|
|
shops := Shops{
|
|
ChannelWeb: {MerchantLogin: "webshop", Password1: "w1", Password2: "w2"},
|
|
ChannelAndroid: {MerchantLogin: "androidshop", Password1: "a1", Password2: "a2"},
|
|
}
|
|
// Order side: the exact channel wins.
|
|
if c, ok := shops.Shop(ChannelAndroid); !ok || c.MerchantLogin != "androidshop" {
|
|
t.Errorf("Shop(android) = %q/%v, want androidshop/true", c.MerchantLogin, ok)
|
|
}
|
|
// Order side: an unknown or empty channel falls back to the web shop (safe — always credits direct).
|
|
if c, ok := shops.Shop("ios"); !ok || c.MerchantLogin != "webshop" {
|
|
t.Errorf("Shop(ios) = %q/%v, want webshop/true (web fallback)", c.MerchantLogin, ok)
|
|
}
|
|
if c, ok := shops.Shop(""); !ok || c.MerchantLogin != "webshop" {
|
|
t.Errorf("Shop(empty) = %q/%v, want webshop/true (web fallback)", c.MerchantLogin, ok)
|
|
}
|
|
// No web shop and an unknown channel → unconfigured.
|
|
if _, ok := (Shops{ChannelAndroid: {MerchantLogin: "androidshop", Password1: "a1", Password2: "a2"}}).Shop("ios"); ok {
|
|
t.Error("Shop(ios) with no web shop returned ok, want false")
|
|
}
|
|
}
|
|
|
|
func TestShopsVerifierIsStrict(t *testing.T) {
|
|
shops := Shops{
|
|
ChannelWeb: {MerchantLogin: "webshop", Password1: "w1", Password2: "w2"},
|
|
ChannelAndroid: {MerchantLogin: "androidshop", Password1: "a1", Password2: "a2"},
|
|
}
|
|
// Callback side: the exact channel's own credentials, no web fallback (each callback is verified
|
|
// only by its own shop's Password2).
|
|
if c, ok := shops.Verifier(ChannelAndroid); !ok || c.MerchantLogin != "androidshop" {
|
|
t.Errorf("Verifier(android) = %q/%v, want androidshop/true", c.MerchantLogin, ok)
|
|
}
|
|
if _, ok := shops.Verifier("ios"); ok {
|
|
t.Error("Verifier(ios) returned ok, want false (no fallback)")
|
|
}
|
|
}
|
|
|
|
func TestShopsConfigured(t *testing.T) {
|
|
if (Shops{}).Configured() {
|
|
t.Error("an empty set reported configured")
|
|
}
|
|
if (Shops{ChannelWeb: {}}).Configured() {
|
|
t.Error("a shop with no merchant login reported configured")
|
|
}
|
|
if !(Shops{ChannelWeb: {MerchantLogin: "s", Password1: "1", Password2: "2"}}).Configured() {
|
|
t.Error("a configured shop reported not configured")
|
|
}
|
|
}
|