Recover SUCCESS/FAILED outcomes from Chapa when webhooks were missed, then expire any rows still pending. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestParseChapaDirectChargeType(t *testing.T) {
|
|
got, err := ParseChapaDirectChargeType("telebirr")
|
|
if err != nil || got != ChapaDirectChargeTelebirr {
|
|
t.Fatalf("got %q err=%v", got, err)
|
|
}
|
|
}
|
|
|
|
func TestIsChapaPaymentMethod(t *testing.T) {
|
|
if !IsChapaPaymentMethod("CHAPA") {
|
|
t.Fatal("expected CHAPA")
|
|
}
|
|
if !IsChapaPaymentMethod("CHAPA_DIRECT:telebirr") {
|
|
t.Fatal("expected CHAPA_DIRECT prefix")
|
|
}
|
|
if IsChapaPaymentMethod("ARIFPAY") {
|
|
t.Fatal("did not expect ARIFPAY")
|
|
}
|
|
}
|
|
|
|
func TestShouldAttemptChapaVerify(t *testing.T) {
|
|
cases := []struct {
|
|
method string
|
|
want bool
|
|
}{
|
|
{"CHAPA", true},
|
|
{"CHAPA_DIRECT:telebirr", true},
|
|
{"telebirr", true},
|
|
{"", true},
|
|
{"ARIFPAY", false},
|
|
{"ADMIN_GRANT", false},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := ShouldAttemptChapaVerify(tc.method); got != tc.want {
|
|
t.Fatalf("method=%q got %v want %v", tc.method, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestChapaDirectChargePaymentMethod(t *testing.T) {
|
|
if got := ChapaDirectChargePaymentMethod(ChapaDirectChargeTelebirr); got != "CHAPA_DIRECT:telebirr" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|