more functions
This commit is contained in:
@@ -101,8 +101,8 @@ func msgSubscriptionAdded(itemId uint32, detailsId, orderRef string) *messages.S
|
||||
return &messages.SubscriptionAdded{ItemId: itemId, DetailsId: detailsId, OrderReference: orderRef}
|
||||
}
|
||||
|
||||
func msgPaymentDeclined() *messages.PaymentDeclined {
|
||||
return &messages.PaymentDeclined{}
|
||||
func msgPaymentDeclined(message, code string) *messages.PaymentDeclined {
|
||||
return &messages.PaymentDeclined{Message: message, Code: &code}
|
||||
}
|
||||
|
||||
func msgConfirmationViewed() *messages.ConfirmationViewed {
|
||||
@@ -650,12 +650,22 @@ func TestPaymentDeclined(t *testing.T) {
|
||||
g := newTestGrain()
|
||||
|
||||
g.CheckoutOrderId = "test-order"
|
||||
applyOK(t, reg, g, msgPaymentDeclined())
|
||||
applyOK(t, reg, g, msgPaymentDeclined("Payment failed due to insufficient funds", "INSUFFICIENT_FUNDS"))
|
||||
if g.PaymentStatus != "declined" || g.CheckoutOrderId != "" {
|
||||
t.Fatalf("payment declined not handled: status=%s checkoutId=%s", g.PaymentStatus, g.CheckoutOrderId)
|
||||
}
|
||||
if g.PaymentDeclinedAt.IsZero() {
|
||||
t.Fatalf("PaymentDeclinedAt not set")
|
||||
if len(g.PaymentDeclinedNotices) != 1 {
|
||||
t.Fatalf("expected 1 notice, got %d", len(g.PaymentDeclinedNotices))
|
||||
}
|
||||
notice := g.PaymentDeclinedNotices[0]
|
||||
if notice.Message != "Payment failed due to insufficient funds" {
|
||||
t.Fatalf("notice message not set correctly: %s", notice.Message)
|
||||
}
|
||||
if notice.Code == nil || *notice.Code != "INSUFFICIENT_FUNDS" {
|
||||
t.Fatalf("notice code not set correctly: %v", notice.Code)
|
||||
}
|
||||
if notice.Timestamp.IsZero() {
|
||||
t.Fatalf("notice timestamp not set")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user