fix: pin payment read paths to provider snapshots
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
dbent "github.com/Wei-Shaw/sub2api/ent"
|
||||
"github.com/Wei-Shaw/sub2api/internal/payment"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -240,3 +241,26 @@ func TestExpectedNotificationProviderKeyPrefersOrderSnapshotProviderKey(t *testi
|
||||
expectedNotificationProviderKey(registry, payment.TypeAlipay, payment.TypeEasyPay, ""),
|
||||
)
|
||||
}
|
||||
|
||||
func TestExpectedNotificationProviderKeyForOrderUsesSnapshotProviderKey(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
registry := payment.NewRegistry()
|
||||
registry.Register(paymentFulfillmentTestProvider{
|
||||
key: payment.TypeAlipay,
|
||||
supportedTypes: []payment.PaymentType{payment.TypeAlipay},
|
||||
})
|
||||
|
||||
order := &dbent.PaymentOrder{
|
||||
PaymentType: payment.TypeAlipay,
|
||||
ProviderSnapshot: map[string]any{
|
||||
"schema_version": 1,
|
||||
"provider_key": payment.TypeEasyPay,
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t,
|
||||
payment.TypeEasyPay,
|
||||
expectedNotificationProviderKeyForOrder(registry, order, ""),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user