File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
33import (
44 "fmt"
55 "log"
6+ "strings"
67
78 "github.com/FoxComm/highlander/middlewarehouse/models/activities"
89 "github.com/FoxComm/highlander/middlewarehouse/shared/phoenix"
@@ -38,9 +39,17 @@ func (h CaptureConsumer) Handler(message metamorphosis.AvroMessage) error {
3839 return err
3940 }
4041 if err := h .phoenixClient .CapturePayment (capture ); err != nil {
42+ // If the order is already captured, we don't want to fail because it's
43+ // possible that this was already captured by the customer.
44+ if strings .Contains (err .Error (), "is not in Auth state" ) || strings .Contains (err .Error (), "has already been captured" ) {
45+ log .Printf ("Attempted to capture order %s that has already be captured" , capture .ReferenceNumber )
46+ return nil
47+ }
48+
4149 log .Printf ("Unable to capture payment with error: %s" , err .Error ())
4250 return err
4351 }
4452
53+ log .Printf ("Successfully captured order %s" , capture .ReferenceNumber )
4554 return nil
4655}
Original file line number Diff line number Diff line change @@ -35,6 +35,6 @@ func main() {
3535 log .Panicf ("Failed to start middlewarehouse with error %s" , err .Error ())
3636 }
3737
38- port := os .Getenv ("PORT" )
38+ port := os .Getenv ("PORT" )
3939 engine .Run (":" + port )
4040}
You can’t perform that action at this time.
0 commit comments