visamasterpay: keep a payment pending while GBÜS still reports it in progress
A status check that ran before the card was entered (orderStatus 0, "no payment attempts") finalized the payment as failed, and later callbacks returned it as already finalized without asking GBÜS again - so cardholderName/maskedPan stayed null and a real payment was never recorded. Unpaid in-progress statuses (0, 1, 5) now keep the row pending with the latest response stored, and rows already failed that way are re-checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,27 @@ func TestRegisterResultSuccess(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusResultInProgress(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
r StatusResult
|
||||
want bool
|
||||
}{
|
||||
{"registered, not attempted", StatusResult{OrderStatus: 0, ErrorCode: "0"}, true},
|
||||
{"pre-authorized", StatusResult{OrderStatus: 1}, true},
|
||||
{"3-D Secure", StatusResult{OrderStatus: 5, ErrorCode: "0"}, true},
|
||||
{"paid", StatusResult{Paid: true, OrderStatus: 2}, false},
|
||||
{"reversed", StatusResult{OrderStatus: 3}, false},
|
||||
{"declined", StatusResult{OrderStatus: 6, ErrorCode: "0"}, false},
|
||||
{"gateway error", StatusResult{OrderStatus: 0, ErrorCode: "6"}, false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := c.r.InProgress(); got != c.want {
|
||||
t.Errorf("%s: InProgress()=%v want %v", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogClientAlwaysPaid(t *testing.T) {
|
||||
c := NewLogClient(nil)
|
||||
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
|
||||
@@ -74,8 +95,8 @@ func TestHTTPClientCheckStatusPaidMapping(t *testing.T) {
|
||||
body string
|
||||
paid bool
|
||||
}{
|
||||
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
||||
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
||||
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
||||
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
||||
{`{"orderStatus":6,"actionCode":"declined"}`, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user