@@ -237,12 +237,14 @@ func (s *LineEngineTestSuite) createMeteredDraftInvoiceWaitingForCollectionForAp
237237}
238238
239239func (s * LineEngineTestSuite ) markInvoicePaid (ctx context.Context , invoiceID ombilling.InvoiceID ) ombilling.StandardInvoice {
240+ appType := s .mustGetInvoiceAppType (ctx , invoiceID )
241+
240242 s .Require ().NoError (s .BillingService .TriggerInvoice (ctx , ombilling.InvoiceTriggerServiceInput {
241243 InvoiceTriggerInput : ombilling.InvoiceTriggerInput {
242244 Invoice : invoiceID ,
243245 Trigger : ombilling .TriggerPaid ,
244246 },
245- AppType : app . AppTypeSandbox ,
247+ AppType : appType ,
246248 Capability : app .CapabilityTypeCollectPayments ,
247249 }))
248250
@@ -255,12 +257,14 @@ func (s *LineEngineTestSuite) markInvoicePaid(ctx context.Context, invoiceID omb
255257}
256258
257259func (s * LineEngineTestSuite ) markInvoiceAuthorized (ctx context.Context , invoiceID ombilling.InvoiceID ) ombilling.StandardInvoice {
260+ appType := s .mustGetInvoiceAppType (ctx , invoiceID )
261+
258262 s .Require ().NoError (s .BillingService .TriggerInvoice (ctx , ombilling.InvoiceTriggerServiceInput {
259263 InvoiceTriggerInput : ombilling.InvoiceTriggerInput {
260264 Invoice : invoiceID ,
261265 Trigger : ombilling .TriggerAuthorized ,
262266 },
263- AppType : app . AppTypeSandbox ,
267+ AppType : appType ,
264268 Capability : app .CapabilityTypeCollectPayments ,
265269 }))
266270
@@ -272,6 +276,25 @@ func (s *LineEngineTestSuite) markInvoiceAuthorized(ctx context.Context, invoice
272276 return invoice
273277}
274278
279+ func (s * LineEngineTestSuite ) mustGetInvoiceAppType (ctx context.Context , invoiceID ombilling.InvoiceID ) app.AppType {
280+ invoice , err := s .BillingService .GetStandardInvoiceById (ctx , ombilling.GetStandardInvoiceByIdInput {
281+ Invoice : invoiceID ,
282+ })
283+ s .Require ().NoError (err )
284+
285+ if invoice .Workflow .Apps != nil && invoice .Workflow .Apps .Invoicing != nil {
286+ return invoice .Workflow .Apps .Invoicing .GetType ()
287+ }
288+
289+ invoicingApp , err := s .AppService .GetApp (ctx , app.GetAppInput {
290+ Namespace : invoice .Namespace ,
291+ ID : invoice .Workflow .AppReferences .Invoicing .ID ,
292+ })
293+ s .Require ().NoError (err )
294+
295+ return invoicingApp .GetType ()
296+ }
297+
275298func (s * LineEngineTestSuite ) TestCollectionCompletedErrorsBecomeValidationIssues () {
276299 var (
277300 ctx = context .Background ()
0 commit comments