mirror of
https://github.com/valitydev/capi-v2.git
synced 2024-11-06 10:05:21 +00:00
TD-385: Add new ips (#21)
This commit is contained in:
parent
dec70d64d4
commit
10050fd975
@ -33,7 +33,9 @@ encode_contact_info(ContactInfo) ->
|
|||||||
encode_client_info(ClientInfo) ->
|
encode_client_info(ClientInfo) ->
|
||||||
#domain_ClientInfo{
|
#domain_ClientInfo{
|
||||||
fingerprint = maps:get(<<"fingerprint">>, ClientInfo),
|
fingerprint = maps:get(<<"fingerprint">>, ClientInfo),
|
||||||
ip_address = maps:get(<<"ip">>, ClientInfo)
|
ip_address = maps:get(<<"ip">>, ClientInfo),
|
||||||
|
peer_ip_address = maps:get(<<"peer_ip">>, ClientInfo),
|
||||||
|
user_ip_address = maps:get(<<"user_ip">>, ClientInfo)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-spec encode_residence(binary() | undefined) -> atom().
|
-spec encode_residence(binary() | undefined) -> atom().
|
||||||
|
@ -263,32 +263,10 @@ decode_event_filter({customer, #webhooker_CustomerEventFilter{shop_id = ShopID,
|
|||||||
|
|
||||||
decode_invoice_event_type({created, #webhooker_InvoiceCreated{}}) ->
|
decode_invoice_event_type({created, #webhooker_InvoiceCreated{}}) ->
|
||||||
[<<"InvoiceCreated">>];
|
[<<"InvoiceCreated">>];
|
||||||
decode_invoice_event_type({status_changed, #webhooker_InvoiceStatusChanged{value = undefined}}) ->
|
|
||||||
% TODO seems unmaintainable
|
|
||||||
[
|
|
||||||
decode_invoice_status_event_type(V)
|
|
||||||
|| V <- [
|
|
||||||
?INVPAID(),
|
|
||||||
?INVCANCELLED(),
|
|
||||||
?INVFULFILLED()
|
|
||||||
]
|
|
||||||
];
|
|
||||||
decode_invoice_event_type({status_changed, #webhooker_InvoiceStatusChanged{value = Value}}) ->
|
decode_invoice_event_type({status_changed, #webhooker_InvoiceStatusChanged{value = Value}}) ->
|
||||||
[decode_invoice_status_event_type(Value)];
|
[decode_invoice_status_event_type(Value)];
|
||||||
decode_invoice_event_type({payment, {created, #webhooker_InvoicePaymentCreated{}}}) ->
|
decode_invoice_event_type({payment, {created, #webhooker_InvoicePaymentCreated{}}}) ->
|
||||||
[<<"PaymentStarted">>];
|
[<<"PaymentStarted">>];
|
||||||
decode_invoice_event_type({payment, {status_changed, #webhooker_InvoicePaymentStatusChanged{value = undefined}}}) ->
|
|
||||||
% TODO seems unmaintainable
|
|
||||||
[
|
|
||||||
decode_payment_status_event_type(V)
|
|
||||||
|| V <- [
|
|
||||||
?PMTPROCESSED(),
|
|
||||||
?PMTCAPTURED(),
|
|
||||||
?PMTCANCELLED(),
|
|
||||||
?PMTREFUNDED(),
|
|
||||||
?PMTFAILED()
|
|
||||||
]
|
|
||||||
];
|
|
||||||
decode_invoice_event_type({payment, {status_changed, #webhooker_InvoicePaymentStatusChanged{value = Value}}}) ->
|
decode_invoice_event_type({payment, {status_changed, #webhooker_InvoicePaymentStatusChanged{value = Value}}}) ->
|
||||||
[decode_payment_status_event_type(Value)];
|
[decode_payment_status_event_type(Value)];
|
||||||
decode_invoice_event_type({payment, {invoice_payment_refund_change, ?PMTRFNDCREATED()}}) ->
|
decode_invoice_event_type({payment, {invoice_payment_refund_change, ?PMTRFNDCREATED()}}) ->
|
||||||
|
@ -1115,7 +1115,9 @@
|
|||||||
<<"paymentSession">> => Session,
|
<<"paymentSession">> => Session,
|
||||||
<<"clientInfo">> => #{
|
<<"clientInfo">> => #{
|
||||||
<<"fingerprint">> => <<"test fingerprint">>,
|
<<"fingerprint">> => <<"test fingerprint">>,
|
||||||
<<"ip">> => <<"::ffff:127.0.0.1">>
|
<<"ip">> => <<"::ffff:127.0.0.1">>,
|
||||||
|
<<"peer_ip">> => <<"::ffff:127.0.0.1">>,
|
||||||
|
<<"user_ip">> => <<"::ffff:127.127.0.1">>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
).
|
).
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
create_payment_crypto_ok_test/1,
|
create_payment_crypto_ok_test/1,
|
||||||
create_payment_mobile_commerce_ok_test/1,
|
create_payment_mobile_commerce_ok_test/1,
|
||||||
create_payment_with_empty_cvv_ok_test/1,
|
create_payment_with_empty_cvv_ok_test/1,
|
||||||
|
check_ip_on_payment_creation_ok_test/1,
|
||||||
get_payments_ok_test/1,
|
get_payments_ok_test/1,
|
||||||
get_payment_by_id_ok_test/1,
|
get_payment_by_id_ok_test/1,
|
||||||
get_payment_by_id_trx_ok_test/1,
|
get_payment_by_id_trx_ok_test/1,
|
||||||
@ -77,6 +78,7 @@ invoice_access_token_tests() ->
|
|||||||
create_payment_ok_test,
|
create_payment_ok_test,
|
||||||
create_payment_expired_test,
|
create_payment_expired_test,
|
||||||
create_payment_with_empty_cvv_ok_test,
|
create_payment_with_empty_cvv_ok_test,
|
||||||
|
check_ip_on_payment_creation_ok_test,
|
||||||
get_payments_ok_test,
|
get_payments_ok_test,
|
||||||
create_payment_qiwi_access_token_ok_test,
|
create_payment_qiwi_access_token_ok_test,
|
||||||
create_payment_crypto_ok_test,
|
create_payment_crypto_ok_test,
|
||||||
@ -406,6 +408,50 @@ create_payment_w_payment_tool(PaymentTool, Config) ->
|
|||||||
},
|
},
|
||||||
capi_client_payments:create_payment(?config(context, Config), Req, ?STRING).
|
capi_client_payments:create_payment(?config(context, Config), Req, ?STRING).
|
||||||
|
|
||||||
|
-spec check_ip_on_payment_creation_ok_test(_) -> _.
|
||||||
|
check_ip_on_payment_creation_ok_test(Config) ->
|
||||||
|
PaymentTool = {bank_card, ?BANK_CARD(<<"visa">>, ?EXP_DATE(2, 2020))},
|
||||||
|
ClientInfo = #domain_ClientInfo{
|
||||||
|
fingerprint = <<"test fingerprint">>,
|
||||||
|
ip_address = <<"::ffff:127.0.0.1">>,
|
||||||
|
peer_ip_address = <<"::ffff:127.0.0.1">>,
|
||||||
|
user_ip_address = <<"::ffff:127.127.0.1">>
|
||||||
|
},
|
||||||
|
_ = capi_ct_helper:mock_services(
|
||||||
|
[
|
||||||
|
{invoicing, fun
|
||||||
|
('Get', _) ->
|
||||||
|
{ok, ?PAYPROC_INVOICE};
|
||||||
|
('StartPayment', {_InvoiceID, Params}) ->
|
||||||
|
?assertMatch(
|
||||||
|
{payment_resource, #payproc_PaymentResourcePayerParams{
|
||||||
|
resource = #domain_DisposablePaymentResource{
|
||||||
|
payment_tool = PaymentTool,
|
||||||
|
client_info = ClientInfo
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
Params#payproc_InvoicePaymentParams.payer
|
||||||
|
),
|
||||||
|
{ok, ?PAYPROC_PAYMENT(?PAYMENT(?STRING, ?PAYMENT_STATUS_PENDING, ?PAYER(PaymentTool)))}
|
||||||
|
end},
|
||||||
|
{generator, fun('GenerateID', _) ->
|
||||||
|
capi_ct_helper_bender:generate_id(?STRING)
|
||||||
|
end}
|
||||||
|
],
|
||||||
|
Config
|
||||||
|
),
|
||||||
|
_ = capi_ct_helper_bouncer:mock_assert_invoice_op_ctx(<<"CreatePayment">>, ?STRING, ?STRING, ?STRING, Config),
|
||||||
|
Req = #{
|
||||||
|
<<"flow">> => #{<<"type">> => <<"PaymentFlowInstant">>},
|
||||||
|
<<"payer">> => #{
|
||||||
|
<<"payerType">> => <<"PaymentResourcePayer">>,
|
||||||
|
<<"paymentSession">> => ?TEST_PAYMENT_SESSION,
|
||||||
|
<<"paymentToolToken">> => encrypt_payment_tool(PaymentTool),
|
||||||
|
<<"contactInfo">> => #{<<"email">> => ?EMAIL}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ok, _} = capi_client_payments:create_payment(?config(context, Config), Req, ?STRING).
|
||||||
|
|
||||||
-spec get_payments_ok_test(config()) -> _.
|
-spec get_payments_ok_test(config()) -> _.
|
||||||
get_payments_ok_test(Config) ->
|
get_payments_ok_test(Config) ->
|
||||||
Payment0 = ?PAYPROC_PAYMENT(?PAYMENT_WITH_CUSTOMER_PAYER, [?REFUND], [?ADJUSTMENT], [?PAYPROC_CHARGEBACK]),
|
Payment0 = ?PAYPROC_PAYMENT(?PAYMENT_WITH_CUSTOMER_PAYER, [?REFUND], [?ADJUSTMENT], [?PAYPROC_CHARGEBACK]),
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1},
|
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1},
|
||||||
{<<"damsel">>,
|
{<<"damsel">>,
|
||||||
{git,"https://github.com/valitydev/damsel.git",
|
{git,"https://github.com/valitydev/damsel.git",
|
||||||
{ref,"9362c08657d1681240d70f923fc04642bbfecc0a"}},
|
{ref,"60474970af1d5e58752f4e5680e67c65ff64dda9"}},
|
||||||
0},
|
0},
|
||||||
{<<"dmt_client">>,
|
{<<"dmt_client">>,
|
||||||
{git,"https://github.com/valitydev/dmt_client.git",
|
{git,"https://github.com/valitydev/dmt_client.git",
|
||||||
|
Loading…
Reference in New Issue
Block a user