2727-export ([payment_success_empty_cvv /1 ]).
2828-export ([payment_has_optional_fields /1 ]).
2929-export ([payment_last_trx_correct /1 ]).
30+ -export ([payment_success_trace /1 ]).
3031
3132-type config () :: hg_ct_helper :config ().
3233-type test_case_name () :: hg_ct_helper :test_case_name ().
@@ -60,10 +61,10 @@ groups() ->
6061 {group , pool_payments }
6162 ]},
6263 {pool_payments , [parallel ], lists :foldl (fun (_ , Acc ) -> [payment_ok_test | Acc ] end , [], lists :seq (1 , 100 ))},
63- {payments , [], [payment_success ]},
64- {paymentsx , [parallel ], [
64+ {payments , [parallel ], [
6565 payment_start_idempotency ,
6666 payment_success ,
67+ payment_success_trace ,
6768 payment_w_first_blacklisted_success ,
6869 payment_w_all_blacklisted ,
6970 register_payment_success ,
@@ -243,15 +244,58 @@ payment_success(C) ->
243244 Payment
244245 ),
245246
247+ ? assertMatch (
248+ # domain_TransactionInfo {
249+ extra = #{
250+ <<" payment.payer_session_info.redirect_url" >> := RedirectURL
251+ }
252+ },
253+ Trx
254+ ).
255+
256+ -spec payment_success_trace (config ()) -> test_return ().
257+ payment_success_trace (C ) ->
258+ Client = cfg (client , C ),
259+ InvoiceID = start_invoice (<<" rubberduck" >>, make_due_date (10 ), 42000 , C ),
260+ Context = # base_Content {
261+ type = <<" application/x-erlang-binary" >>,
262+ data = erlang :term_to_binary ({you , 643 , " not" , [<<" welcome" >>, here ]})
263+ },
264+ PayerSessionInfo = # domain_PayerSessionInfo {
265+ redirect_url = <<" https://redirectly.io/merchant" >>
266+ },
267+ PaymentParams = (make_payment_params (? pmt_sys (<<" visa-ref" >>)))# payproc_InvoicePaymentParams {
268+ payer_session_info = PayerSessionInfo ,
269+ context = Context
270+ },
271+ PaymentID = process_payment (InvoiceID , PaymentParams , Client ),
272+ PaymentID = await_payment_capture (InvoiceID , PaymentID , Client ),
273+
246274 RootUrl = unicode :characters_to_binary (cfg (root_url , C )),
247- FullUrl = <<RootUrl /binary , " /traces/internal/invoice/" , InvoiceID /binary >>,
248- {ok , _Status , _Headers , Ref } = hackney :get (FullUrl ),
249- {ok , Body } = hackney :body (Ref ),
275+ UrlInternal = <<RootUrl /binary , " /traces/internal/invoice/" , InvoiceID /binary >>,
276+ UrlJaeger = <<RootUrl /binary , " /traces/jaeger/invoice/" , InvoiceID /binary >>,
277+ {ok , _Status , _Headers , RefInternal } = hackney :get (UrlInternal ),
278+ {ok , BodyInternal } = hackney :body (RefInternal ),
250279 [
251280 #{
252- <<" args" >> := _ ,
281+ <<" args" >> := #{
282+ <<" content_type" >> := <<" thrift_call" >>,
283+ <<" content" >> := #{
284+ <<" call" >> := #{
285+ <<" function" >> := <<" Create" >>,
286+ <<" service" >> := <<" Invoicing" >>
287+ },
288+ <<" params" >> := _
289+ }
290+ },
253291 <<" error" >> := null ,
254- <<" events" >> := _ ,
292+ <<" events" >> := [
293+ #{
294+ <<" event_id" >> := 1 ,
295+ <<" event_payload" >> := _ ,
296+ <<" event_timestamp" >> := _
297+ }
298+ ],
255299 <<" finished" >> := _ ,
256300 <<" otel_trace_id" >> := _ ,
257301 <<" retry_attempts" >> := 0 ,
@@ -263,30 +307,103 @@ payment_success(C) ->
263307 <<" task_status" >> := <<" finished" >>,
264308 <<" task_type" >> := <<" init" >>
265309 },
266- _ ,
267- _ ,
268- _ ,
269- _ ,
270- _ ,
271- _ ,
272- _ ,
273- _ ,
274- _ ,
275- _ ,
276- _ ,
277- _ ,
278- _ ,
279- _
280- ] = json :decode (Body ),
281-
282- ? assertMatch (
283- # domain_TransactionInfo {
284- extra = #{
285- <<" payment.payer_session_info.redirect_url" >> := RedirectURL
310+ #{<<" task_type" >> := <<" call" >>, <<" task_status" >> := <<" finished" >>},
311+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
312+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
313+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
314+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
315+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
316+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
317+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
318+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
319+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
320+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
321+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
322+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" finished" >>},
323+ #{<<" task_type" >> := <<" timeout" >>, <<" task_status" >> := <<" cancelled" >>}
324+ ] = json :decode (BodyInternal ),
325+ {ok , _Status2 , _Headers2 , RefJaeger } = hackney :get (UrlJaeger ),
326+ {ok , BodyJaeger } = hackney :body (RefJaeger ),
327+ #{
328+ <<" data" >> := [
329+ #{
330+ <<" traceId" >> := _ ,
331+ <<" processes" >> := #{
332+ InvoiceID := #{
333+ <<" service_name" >> := <<" hellgate_invoice" >>,
334+ <<" tags" >> := []
335+ }
336+ },
337+ <<" spans" >> := [
338+ #{
339+ <<" operationName" >> := <<" init" >>,
340+ <<" process" >> := #{
341+ <<" service_name" >> := <<" hellgate_invoice" >>,
342+ <<" tags" >> := []
343+ },
344+ <<" processID" >> := InvoiceID ,
345+ <<" spanId" >> := _ ,
346+ <<" traceId" >> := _ ,
347+ <<" startTime" >> := _ ,
348+ <<" duration" >> := _ ,
349+ <<" tags" >> := [
350+ #{
351+ <<" key" >> := <<" task.status" >>,
352+ <<" type" >> := <<" string" >>,
353+ <<" value" >> := <<" finished" >>
354+ },
355+ #{
356+ <<" key" >> := <<" task.retries" >>,
357+ <<" type" >> := <<" int64" >>,
358+ <<" value" >> := 0
359+ },
360+ #{
361+ <<" key" >> := <<" task.input" >>,
362+ <<" type" >> := <<" string" >>,
363+ <<" value" >> := _NestedJsonArgs
364+ }
365+ ],
366+ <<" logs" >> := [
367+ #{
368+ <<" timestamp" >> := _ ,
369+ <<" fields" >> := [
370+ #{
371+ <<" key" >> := <<" event.id" >>,
372+ <<" type" >> := <<" int64" >>,
373+ <<" value" >> := 1
374+ },
375+ #{
376+ <<" key" >> := <<" event.payload" >>,
377+ <<" type" >> := <<" string" >>,
378+ <<" value" >> := _NestedJsonEvent
379+ }
380+ ]
381+ }
382+ ]
383+ },
384+ #{<<" operationName" >> := <<" call" >>},
385+ #{<<" operationName" >> := <<" timeout" >>},
386+ #{<<" operationName" >> := <<" timeout" >>},
387+ #{<<" operationName" >> := <<" timeout" >>},
388+ #{<<" operationName" >> := <<" timeout" >>},
389+ #{<<" operationName" >> := <<" timeout" >>},
390+ #{<<" operationName" >> := <<" timeout" >>},
391+ #{<<" operationName" >> := <<" timeout" >>},
392+ #{<<" operationName" >> := <<" timeout" >>},
393+ #{<<" operationName" >> := <<" timeout" >>},
394+ #{<<" operationName" >> := <<" timeout" >>},
395+ #{<<" operationName" >> := <<" timeout" >>},
396+ #{<<" operationName" >> := <<" timeout" >>},
397+ #{<<" operationName" >> := <<" timeout" >>}
398+ ]
286399 }
287- },
288- Trx
289- ).
400+ ]
401+ } = json :decode (BodyJaeger ),
402+ BadInvoiceUrl = <<RootUrl /binary , " /traces/internal/invoice/UnknownInvoice" >>,
403+ {ok , 404 , _ , _ } = hackney :get (BadInvoiceUrl ),
404+ BadFormatUrl = <<RootUrl /binary , " /traces/external/invoice/" , InvoiceID /binary >>,
405+ {ok , 400 , _ , _ } = hackney :get (BadFormatUrl ),
406+ ok .
290407
291408-spec payment_w_first_blacklisted_success (config ()) -> test_return ().
292409payment_w_first_blacklisted_success (C ) ->
0 commit comments