diff --git a/apps/capi/src/capi_handler_webhooks.erl b/apps/capi/src/capi_handler_webhooks.erl index c0d7f30..f613995 100644 --- a/apps/capi/src/capi_handler_webhooks.erl +++ b/apps/capi/src/capi_handler_webhooks.erl @@ -199,6 +199,11 @@ encode_webhook_scope(#{<<"topic">> := <<"CustomersTopic">>, <<"shopID">> := Shop -define(PMTRFNDFAILED(), {failed, #webhooker_InvoicePaymentRefundFailed{}}). -define(PMTRFNDSUCCEEDED(), {succeeded, #webhooker_InvoicePaymentRefundSucceeded{}}). +-define(PMTUI(Value), #webhooker_InvoicePaymentUserInteractionChange{status = Value}). + +-define(PMTUISTATUSREQUESTED(), {requested, #webhooker_UserInteractionStatusRequested{}}). +-define(PMTUISTATUSCOMPLETED(), {completed, #webhooker_UserInteractionStatusCompleted{}}). + encode_invoice_event_type(<<"InvoiceCreated">>) -> {created, #webhooker_InvoiceCreated{}}; encode_invoice_event_type(<<"InvoicePaid">>) -> @@ -224,7 +229,11 @@ encode_invoice_event_type(<<"PaymentRefundCreated">>) -> encode_invoice_event_type(<<"PaymentRefundFailed">>) -> {payment, {invoice_payment_refund_change, ?PMTRFNDSTATUS(?PMTRFNDFAILED())}}; encode_invoice_event_type(<<"PaymentRefundSucceeded">>) -> - {payment, {invoice_payment_refund_change, ?PMTRFNDSTATUS(?PMTRFNDSUCCEEDED())}}. + {payment, {invoice_payment_refund_change, ?PMTRFNDSTATUS(?PMTRFNDSUCCEEDED())}}; +encode_invoice_event_type(<<"PaymentUserInteractionRequested">>) -> + {payment, {user_interaction, ?PMTUI(?PMTUISTATUSREQUESTED())}}; +encode_invoice_event_type(<<"PaymentUserInteractionCompleted">>) -> + {payment, {user_interaction, ?PMTUI(?PMTUISTATUSCOMPLETED())}}. encode_customer_event_type(<<"CustomerCreated">>) -> {created, #webhooker_CustomerCreated{}}; @@ -274,7 +283,9 @@ decode_invoice_event_type({payment, {status_changed, #webhooker_InvoicePaymentSt decode_invoice_event_type({payment, {invoice_payment_refund_change, ?PMTRFNDCREATED()}}) -> [<<"PaymentRefundCreated">>]; decode_invoice_event_type({payment, {invoice_payment_refund_change, ?PMTRFNDSTATUS(Value)}}) -> - [decode_payment_refund_status_event_type(Value)]. + [decode_payment_refund_status_event_type(Value)]; +decode_invoice_event_type({payment, {user_interaction, ?PMTUI(Value)}}) -> + [decode_payment_user_interaction_status_event_type(Value)]. decode_invoice_status_event_type(?INVPAID()) -> <<"InvoicePaid">>; decode_invoice_status_event_type(?INVCANCELLED()) -> <<"InvoiceCancelled">>; @@ -289,6 +300,9 @@ decode_payment_status_event_type(?PMTFAILED()) -> <<"PaymentFailed">>. decode_payment_refund_status_event_type(?PMTRFNDFAILED()) -> <<"PaymentRefundFailed">>; decode_payment_refund_status_event_type(?PMTRFNDSUCCEEDED()) -> <<"PaymentRefundSucceeded">>. +decode_payment_user_interaction_status_event_type(?PMTUISTATUSREQUESTED()) -> <<"PaymentUserInteractionRequested">>; +decode_payment_user_interaction_status_event_type(?PMTUISTATUSCOMPLETED()) -> <<"PaymentUserInteractionCompleted">>. + decode_customer_event_type({created, #webhooker_CustomerCreated{}}) -> <<"CustomerCreated">>; decode_customer_event_type({deleted, #webhooker_CustomerDeleted{}}) -> diff --git a/apps/capi/test/capi_base_api_token_tests_SUITE.erl b/apps/capi/test/capi_base_api_token_tests_SUITE.erl index 4e68ab2..7ecdd77 100644 --- a/apps/capi/test/capi_base_api_token_tests_SUITE.erl +++ b/apps/capi/test/capi_base_api_token_tests_SUITE.erl @@ -1769,7 +1769,9 @@ create_webhook_ok_test(Config) -> <<"PaymentFailed">>, <<"PaymentRefundCreated">>, <<"PaymentRefundFailed">>, - <<"PaymentRefundSucceeded">> + <<"PaymentRefundSucceeded">>, + <<"PaymentUserInteractionRequested">>, + <<"PaymentUserInteractionCompleted">> ] } }, diff --git a/apps/capi/test/capi_dummy_data.hrl b/apps/capi/test/capi_dummy_data.hrl index 27993ab..632776c 100644 --- a/apps/capi/test/capi_dummy_data.hrl +++ b/apps/capi/test/capi_dummy_data.hrl @@ -732,6 +732,20 @@ } } } + }}, + {payment, + { + user_interaction, + #webhooker_InvoicePaymentUserInteractionChange{ + status = {requested, #webhooker_UserInteractionStatusRequested{}} + } + }}, + {payment, + { + user_interaction, + #webhooker_InvoicePaymentUserInteractionChange{ + status = {completed, #webhooker_UserInteractionStatusCompleted{}} + } }} ]) }}, diff --git a/rebar.lock b/rebar.lock index c3ef4ef..8ec48b0 100644 --- a/rebar.lock +++ b/rebar.lock @@ -40,7 +40,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"23211ff8c0c45699fa6d78afa55f304e95dbee87"}}, + {ref,"a2f3317fa7edd7c44eafef64fa66f7a864a17833"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git", @@ -132,11 +132,11 @@ {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.7">>},2}, {<<"swag_client">>, {git,"https://github.com/valitydev/swag-payments", - {ref,"e48443679ff088e119a67d7e085ce7e0a078742d"}}, + {ref,"0b19804b5d4f3970923cac4e2c5daa6231a851de"}}, 0}, {<<"swag_server">>, {git,"https://github.com/valitydev/swag-payments", - {ref,"5fec0fc2c79f37a8176579ef19735e017ada9cab"}}, + {ref,"8d2e26e5c7b69de01952b00edb0f7d6190e8b8a4"}}, 0}, {<<"thrift">>, {git,"https://github.com/valitydev/thrift_erlang.git",