INT-973: Add Requested and Completed statuses of UI to WH (#43)

* INT-973: Add Requested and Completed statuses of UI to WH

* Add tests

* Fix test

* a
This commit is contained in:
ndiezel0 2024-02-27 20:25:20 +05:00 committed by GitHub
parent 14a41f5526
commit bdcea3648a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 6 deletions

View File

@ -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{}}) ->

View File

@ -1769,7 +1769,9 @@ create_webhook_ok_test(Config) ->
<<"PaymentFailed">>,
<<"PaymentRefundCreated">>,
<<"PaymentRefundFailed">>,
<<"PaymentRefundSucceeded">>
<<"PaymentRefundSucceeded">>,
<<"PaymentUserInteractionRequested">>,
<<"PaymentUserInteractionCompleted">>
]
}
},

View File

@ -732,6 +732,20 @@
}
}
}
}},
{payment,
{
user_interaction,
#webhooker_InvoicePaymentUserInteractionChange{
status = {requested, #webhooker_UserInteractionStatusRequested{}}
}
}},
{payment,
{
user_interaction,
#webhooker_InvoicePaymentUserInteractionChange{
status = {completed, #webhooker_UserInteractionStatusCompleted{}}
}
}}
])
}},

View File

@ -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",