mirror of
https://github.com/valitydev/capi-v2.git
synced 2024-11-06 01:55:20 +00:00
TD-266: Change merch stat to magista proto (#14)
* added magista proto * changed to magista proto * bumped magista proto * fixed * added error test case * tried to feat cover * added some error cases * fixed * added tests * added tests * bumped all * added filters * added requested changes
This commit is contained in:
parent
cf18b3d955
commit
289a0e9903
4
.env
4
.env
@ -2,6 +2,6 @@
|
||||
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
|
||||
# are the same. See: https://github.com/erlware/relx/pull/902
|
||||
SERVICE_NAME=capi
|
||||
OTP_VERSION=24.2.0
|
||||
OTP_VERSION=24.3.4
|
||||
REBAR_VERSION=3.18
|
||||
THRIFT_VERSION=0.14.2.2
|
||||
THRIFT_VERSION=0.14.2.3
|
||||
|
@ -29,7 +29,8 @@
|
||||
bouncer_client,
|
||||
token_keeper_client,
|
||||
party_client,
|
||||
payout_manager_proto
|
||||
payout_manager_proto,
|
||||
magista_proto
|
||||
]},
|
||||
{env, []}
|
||||
]}.
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_allocation).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-export([validate/1]).
|
||||
-export([transaction_error/1]).
|
||||
@ -11,7 +13,7 @@
|
||||
-type allocation_prototype() :: dmsl_domain_thrift:'AllocationPrototype'().
|
||||
-type decode_data() :: _.
|
||||
-type validate_error() :: allocation_duplicate | allocation_wrong_cart.
|
||||
-type invalid_transaction() :: dmsl_payment_processing_thrift:'AllocationInvalidTransaction'().
|
||||
-type invalid_transaction() :: dmsl_payproc_thrift:'AllocationInvalidTransaction'().
|
||||
|
||||
-spec validate(list() | undefined) -> ok | validate_error().
|
||||
validate(undefined) ->
|
||||
@ -93,10 +95,10 @@ encode_parts(#{<<"m">> := M, <<"exp">> := Exp}) ->
|
||||
case Exp < 0 of
|
||||
true ->
|
||||
Q = erlang:trunc(math:pow(10, -Exp)),
|
||||
#'Rational'{p = M, q = Q};
|
||||
#base_Rational{p = M, q = Q};
|
||||
_ ->
|
||||
P = M * erlang:trunc(math:pow(10, Exp)),
|
||||
#'Rational'{p = P, q = 1}
|
||||
#base_Rational{p = P, q = 1}
|
||||
end.
|
||||
|
||||
-spec decode(allocation() | undefined) -> decode_data() | undefined.
|
||||
@ -167,7 +169,7 @@ decode_fee(Fee, FeeTarget, FeeAmount) ->
|
||||
}.
|
||||
|
||||
decode_parts(Parts) ->
|
||||
#'Rational'{p = P, q = Q} = Parts,
|
||||
#base_Rational{p = P, q = Q} = Parts,
|
||||
Exponent = erlang:trunc(math:log10(Q)),
|
||||
#{
|
||||
<<"m">> => P,
|
||||
@ -272,7 +274,8 @@ decode_test() ->
|
||||
#domain_InvoiceLine{
|
||||
product = <<"info">>,
|
||||
quantity = 2,
|
||||
price = make_cash(16)
|
||||
price = make_cash(16),
|
||||
metadata = #{}
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -331,6 +334,6 @@ decode_test() ->
|
||||
|
||||
make_cash(Amount) -> #domain_Cash{amount = Amount, currency = #domain_CurrencyRef{symbolic_code = <<"RUB">>}}.
|
||||
make_decimal(M, E) -> #{<<"m">> => M, <<"exp">> => E}.
|
||||
make_rational(P, Q) -> #'Rational'{p = P, q = Q}.
|
||||
make_rational(P, Q) -> #base_Rational{p = P, q = Q}.
|
||||
|
||||
-endif.
|
||||
|
@ -128,7 +128,7 @@ issue_access_token(TokenSpec, WoodyContext) ->
|
||||
-define(DEFAULT_INVOICE_ACCESS_TOKEN_LIFETIME, 259200).
|
||||
-define(DEFAULT_CUSTOMER_ACCESS_TOKEN_LIFETIME, 259200).
|
||||
|
||||
-include_lib("bouncer_proto/include/bouncer_context_v1_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_v1_thrift.hrl").
|
||||
|
||||
create_context_fragment(TokenSpec) ->
|
||||
AuthContext = resolve_auth_context(TokenSpec),
|
||||
@ -162,9 +162,9 @@ resolve_auth_scope(TokenSpec) ->
|
||||
TokenSpec
|
||||
).
|
||||
|
||||
resolve_auth_method(#{scope := {invoice, _}}) -> ?BCTX_V1_AUTHMETHOD_INVOICEACCESSTOKEN;
|
||||
resolve_auth_method(#{scope := {customer, _}}) -> ?BCTX_V1_AUTHMETHOD_CUSTOMERACCESSTOKEN;
|
||||
resolve_auth_method(#{scope := {invoice_template, _}}) -> ?BCTX_V1_AUTHMETHOD_INVOICETEMPLATEACCESSTOKEN.
|
||||
resolve_auth_method(#{scope := {invoice, _}}) -> ?CTX_V1_AUTHMETHOD_INVOICEACCESSTOKEN;
|
||||
resolve_auth_method(#{scope := {customer, _}}) -> ?CTX_V1_AUTHMETHOD_CUSTOMERACCESSTOKEN;
|
||||
resolve_auth_method(#{scope := {invoice_template, _}}) -> ?CTX_V1_AUTHMETHOD_INVOICETEMPLATEACCESSTOKEN.
|
||||
|
||||
resolve_auth_expiration(TokenSpec) ->
|
||||
case get_token_lifetime(TokenSpec) of
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module(capi_bender).
|
||||
|
||||
-include_lib("bender_proto/include/bender_thrift.hrl").
|
||||
-include_lib("bender_proto/include/bender_bender_thrift.hrl").
|
||||
|
||||
-type id() :: binary().
|
||||
-type idempotent_key_prefix() :: binary() | atom().
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module(capi_bouncer).
|
||||
|
||||
-include_lib("bouncer_proto/include/bouncer_context_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_thrift.hrl").
|
||||
|
||||
-export([gather_context_fragments/4]).
|
||||
-export([judge/2]).
|
||||
|
@ -1,8 +1,10 @@
|
||||
-module(capi_bouncer_context).
|
||||
|
||||
-include_lib("bouncer_proto/include/bouncer_context_v1_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_v1_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_base_thrift.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_webhooker_thrift.hrl").
|
||||
-include_lib("reporter_proto/include/reporter_reports_thrift.hrl").
|
||||
-include_lib("payout_manager_proto/include/payouts_payout_manager_thrift.hrl").
|
||||
@ -67,8 +69,8 @@
|
||||
-type invoice_template_id() :: dmsl_domain_thrift:'InvoiceTemplateID'().
|
||||
-type invoice_template() :: dmsl_domain_thrift:'InvoiceTemplate'().
|
||||
|
||||
-type customer_id() :: dmsl_payment_processing_thrift:'CustomerID'().
|
||||
-type customer() :: dmsl_payment_processing_thrift:'Customer'().
|
||||
-type customer_id() :: dmsl_payproc_thrift:'CustomerID'().
|
||||
-type customer() :: dmsl_payproc_thrift:'Customer'().
|
||||
|
||||
-type webhook_id() :: dmsl_webhooker_thrift:'WebhookID'().
|
||||
-type webhook() :: dmsl_webhooker_thrift:'Webhook'().
|
||||
@ -109,9 +111,9 @@ build(Prototypes, {Acc0, External}, WoodyCtx) ->
|
||||
{Acc1, External}.
|
||||
|
||||
build(operation, Params = #{id := OperationID}, Acc, _WoodyCtx) ->
|
||||
Acc#bctx_v1_ContextFragment{
|
||||
capi = #bctx_v1_ContextCommonAPI{
|
||||
op = #bctx_v1_CommonAPIOperation{
|
||||
Acc#ctx_v1_ContextFragment{
|
||||
capi = #ctx_v1_ContextCommonAPI{
|
||||
op = #ctx_v1_CommonAPIOperation{
|
||||
id = operation_id_to_binary(OperationID),
|
||||
party = maybe_entity(party, Params),
|
||||
shop = maybe_entity(shop, Params),
|
||||
@ -131,8 +133,8 @@ build(operation, Params = #{id := OperationID}, Acc, _WoodyCtx) ->
|
||||
}
|
||||
};
|
||||
build(payproc, Params = #{}, Acc, WoodyCtx) ->
|
||||
Acc#bctx_v1_ContextFragment{
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
Acc#ctx_v1_ContextFragment{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice = maybe_with(
|
||||
invoice,
|
||||
Params,
|
||||
@ -151,8 +153,8 @@ build(payproc, Params = #{}, Acc, WoodyCtx) ->
|
||||
}
|
||||
};
|
||||
build(webhooks, Params = #{}, Acc, WoodyCtx) ->
|
||||
Acc#bctx_v1_ContextFragment{
|
||||
webhooks = #bctx_v1_ContextWebhooks{
|
||||
Acc#ctx_v1_ContextFragment{
|
||||
webhooks = #ctx_v1_ContextWebhooks{
|
||||
webhook = maybe_with(
|
||||
webhook,
|
||||
Params,
|
||||
@ -161,8 +163,8 @@ build(webhooks, Params = #{}, Acc, WoodyCtx) ->
|
||||
}
|
||||
};
|
||||
build(reports, Params = #{}, Acc, WoodyCtx) ->
|
||||
Acc#bctx_v1_ContextFragment{
|
||||
reports = #bctx_v1_ContextReports{
|
||||
Acc#ctx_v1_ContextFragment{
|
||||
reports = #ctx_v1_ContextReports{
|
||||
report = maybe_with(
|
||||
report,
|
||||
Params,
|
||||
@ -175,12 +177,12 @@ build(payouts, Params = #{}, Acc, WoodyCtx) ->
|
||||
build_payout_ctx(V, WoodyCtx)
|
||||
end),
|
||||
Payout = maybe(Payout0, fun(_Payout0) ->
|
||||
Payout0#bctx_v1_Payout{
|
||||
Payout0#ctx_v1_Payout{
|
||||
contract = maybe_entity(contract, Params)
|
||||
}
|
||||
end),
|
||||
Acc#bctx_v1_ContextFragment{
|
||||
payouts = #bctx_v1_ContextPayouts{
|
||||
Acc#ctx_v1_ContextFragment{
|
||||
payouts = #ctx_v1_ContextPayouts{
|
||||
payout = Payout
|
||||
}
|
||||
}.
|
||||
@ -199,7 +201,7 @@ build_invoice_ctx(Invoice, _WoodyCtx) ->
|
||||
build_invoice_ctx(Invoice).
|
||||
|
||||
build_invoice_ctx(#payproc_Invoice{invoice = Invoice, payments = Payments}) ->
|
||||
#bctx_v1_Invoice{
|
||||
#ctx_v1_Invoice{
|
||||
id = Invoice#domain_Invoice.id,
|
||||
party = build_entity(Invoice#domain_Invoice.owner_id),
|
||||
shop = build_entity(Invoice#domain_Invoice.shop_id),
|
||||
@ -207,7 +209,7 @@ build_invoice_ctx(#payproc_Invoice{invoice = Invoice, payments = Payments}) ->
|
||||
}.
|
||||
|
||||
build_payment_ctx(#payproc_InvoicePayment{payment = Payment, refunds = Refunds}) ->
|
||||
#bctx_v1_Payment{
|
||||
#ctx_v1_Payment{
|
||||
id = Payment#domain_InvoicePayment.id,
|
||||
refunds = build_set(lists:map(fun build_refund_ctx/1, Refunds))
|
||||
}.
|
||||
@ -227,7 +229,7 @@ build_invoice_template_ctx(InvoiceTemplate, _WoodyCtx) ->
|
||||
build_invoice_template_ctx(InvoiceTemplate).
|
||||
|
||||
build_invoice_template_ctx(#domain_InvoiceTemplate{id = ID, owner_id = OwnerID, shop_id = ShopID}) ->
|
||||
#bctx_v1_InvoiceTemplate{
|
||||
#ctx_v1_InvoiceTemplate{
|
||||
id = ID,
|
||||
party = build_entity(OwnerID),
|
||||
shop = build_entity(ShopID)
|
||||
@ -245,7 +247,7 @@ build_customer_ctx(Customer, _WoodyCtx) ->
|
||||
build_customer_ctx(Customer).
|
||||
|
||||
build_customer_ctx(#payproc_Customer{id = ID, owner_id = OwnerID, shop_id = ShopID, bindings = Bindings}) ->
|
||||
#bctx_v1_Customer{
|
||||
#ctx_v1_Customer{
|
||||
id = ID,
|
||||
party = build_entity(OwnerID),
|
||||
shop = build_entity(ShopID),
|
||||
@ -267,7 +269,7 @@ build_payout_ctx(#payouts_Payout{
|
||||
party_id = PartyID,
|
||||
shop_id = ShopID
|
||||
}) ->
|
||||
#bctx_v1_Payout{
|
||||
#ctx_v1_Payout{
|
||||
id = ID,
|
||||
party = build_entity(PartyID),
|
||||
shop = build_entity(ShopID)
|
||||
@ -281,7 +283,7 @@ build_webhook_ctx(Webhook, _WoodyCtx) ->
|
||||
build_webhook_ctx(Webhook).
|
||||
|
||||
build_webhook_ctx(#webhooker_Webhook{id = ID, party_id = PartyID, event_filter = Filter}) ->
|
||||
#bctx_v1_Webhook{
|
||||
#ctx_v1_Webhook{
|
||||
id = integer_to_binary(ID),
|
||||
party = build_entity(PartyID),
|
||||
filter = build_webhook_filter(Filter)
|
||||
@ -290,15 +292,15 @@ build_webhook_ctx(#webhooker_Webhook{id = ID, party_id = PartyID, event_filter =
|
||||
build_webhook_filter({Type, Filter}) ->
|
||||
build_webhook_filter_details(
|
||||
Filter,
|
||||
#bctx_v1_WebhookFilter{topic = erlang:atom_to_binary(Type, utf8)}
|
||||
#ctx_v1_WebhookFilter{topic = erlang:atom_to_binary(Type, utf8)}
|
||||
).
|
||||
|
||||
build_webhook_filter_details(#webhooker_PartyEventFilter{}, Ctx) ->
|
||||
Ctx;
|
||||
build_webhook_filter_details(#webhooker_InvoiceEventFilter{shop_id = ShopID}, Ctx) ->
|
||||
Ctx#bctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)};
|
||||
Ctx#ctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)};
|
||||
build_webhook_filter_details(#webhooker_CustomerEventFilter{shop_id = ShopID}, Ctx) ->
|
||||
Ctx#bctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)};
|
||||
Ctx#ctx_v1_WebhookFilter{shop = maybe(ShopID, fun build_entity/1)};
|
||||
build_webhook_filter_details(#webhooker_WalletEventFilter{}, Ctx) ->
|
||||
Ctx.
|
||||
|
||||
@ -310,7 +312,7 @@ build_report_ctx(Report, _WoodyCtx) ->
|
||||
build_report_ctx(Report).
|
||||
|
||||
build_report_ctx(#reports_Report{report_id = ID, party_id = PartyID, shop_id = ShopID, files = Files}) ->
|
||||
#bctx_v1_Report{
|
||||
#ctx_v1_Report{
|
||||
id = integer_to_binary(ID),
|
||||
party = build_entity(PartyID),
|
||||
shop = maybe(ShopID, fun build_entity/1),
|
||||
@ -348,9 +350,9 @@ maybe_entity(Name, Params) ->
|
||||
maybe_with(Name, Params, fun build_entity/1).
|
||||
|
||||
build_entity(ID) when is_binary(ID) ->
|
||||
#bouncer_base_Entity{id = ID};
|
||||
#base_Entity{id = ID};
|
||||
build_entity(ID) when is_integer(ID) ->
|
||||
#bouncer_base_Entity{id = integer_to_binary(ID)}.
|
||||
#base_Entity{id = integer_to_binary(ID)}.
|
||||
|
||||
build_set(L) when is_list(L) ->
|
||||
ordsets:from_list(L).
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module(capi_crypto).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_tool_token_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_paytool_token_thrift.hrl").
|
||||
|
||||
-type token() :: binary().
|
||||
-type token_data() :: #{
|
||||
@ -8,8 +8,8 @@
|
||||
valid_until := deadline()
|
||||
}.
|
||||
-type payment_tool() :: dmsl_domain_thrift:'PaymentTool'().
|
||||
-type payment_tool_token() :: dmsl_payment_tool_token_thrift:'PaymentToolToken'().
|
||||
-type payment_tool_token_payload() :: dmsl_payment_tool_token_thrift:'PaymentToolTokenPayload'().
|
||||
-type payment_tool_token() :: dmsl_paytool_token_thrift:'PaymentToolToken'().
|
||||
-type payment_tool_token_payload() :: dmsl_paytool_token_thrift:'PaymentToolTokenPayload'().
|
||||
-type deadline() :: capi_utils:deadline().
|
||||
|
||||
-export_type([token/0]).
|
||||
@ -21,7 +21,7 @@
|
||||
-spec encode_token(token_data()) -> token().
|
||||
encode_token(TokenData) ->
|
||||
PaymentToolToken = encode_payment_tool_token(TokenData),
|
||||
ThriftType = {struct, struct, {dmsl_payment_tool_token_thrift, 'PaymentToolToken'}},
|
||||
ThriftType = {struct, struct, {dmsl_paytool_token_thrift, 'PaymentToolToken'}},
|
||||
{ok, EncodedToken} = lechiffre:encode(ThriftType, PaymentToolToken),
|
||||
TokenVersion = token_version(),
|
||||
<<TokenVersion/binary, ".", EncodedToken/binary>>.
|
||||
@ -43,11 +43,11 @@ token_version() ->
|
||||
<<"v2">>.
|
||||
|
||||
decrypt_token(EncryptedPaymentToolToken) ->
|
||||
ThriftType = {struct, struct, {dmsl_payment_tool_token_thrift, 'PaymentToolToken'}},
|
||||
ThriftType = {struct, struct, {dmsl_paytool_token_thrift, 'PaymentToolToken'}},
|
||||
case lechiffre:decode(ThriftType, EncryptedPaymentToolToken) of
|
||||
{ok, PaymentToolToken} ->
|
||||
Payload = PaymentToolToken#ptt_PaymentToolToken.payload,
|
||||
ValidUntil = PaymentToolToken#ptt_PaymentToolToken.valid_until,
|
||||
Payload = PaymentToolToken#paytool_token_PaymentToolToken.payload,
|
||||
ValidUntil = PaymentToolToken#paytool_token_PaymentToolToken.valid_until,
|
||||
{ok, #{
|
||||
payment_tool => decode_payment_tool_token_payload(Payload),
|
||||
valid_until => decode_deadline(ValidUntil)
|
||||
@ -60,7 +60,7 @@ decrypt_token(EncryptedPaymentToolToken) ->
|
||||
encode_payment_tool_token(TokenData) ->
|
||||
Payload = maps:get(payment_tool, TokenData),
|
||||
ValidUntil = maps:get(valid_until, TokenData),
|
||||
#ptt_PaymentToolToken{
|
||||
#paytool_token_PaymentToolToken{
|
||||
payload = encode_payment_tool_token_payload(Payload),
|
||||
valid_until = encode_deadline(ValidUntil)
|
||||
}.
|
||||
@ -73,23 +73,23 @@ encode_deadline(Deadline) ->
|
||||
|
||||
-spec encode_payment_tool_token_payload(payment_tool()) -> payment_tool_token_payload().
|
||||
encode_payment_tool_token_payload({bank_card, BankCard}) ->
|
||||
{bank_card_payload, #ptt_BankCardPayload{
|
||||
{bank_card_payload, #paytool_token_BankCardPayload{
|
||||
bank_card = BankCard
|
||||
}};
|
||||
encode_payment_tool_token_payload({payment_terminal, PaymentTerminal}) ->
|
||||
{payment_terminal_payload, #ptt_PaymentTerminalPayload{
|
||||
{payment_terminal_payload, #paytool_token_PaymentTerminalPayload{
|
||||
payment_terminal = PaymentTerminal
|
||||
}};
|
||||
encode_payment_tool_token_payload({digital_wallet, DigitalWallet}) ->
|
||||
{digital_wallet_payload, #ptt_DigitalWalletPayload{
|
||||
{digital_wallet_payload, #paytool_token_DigitalWalletPayload{
|
||||
digital_wallet = DigitalWallet
|
||||
}};
|
||||
encode_payment_tool_token_payload({crypto_currency, CryptoCurrency}) ->
|
||||
{crypto_currency_payload, #ptt_CryptoCurrencyPayload{
|
||||
{crypto_currency_payload, #paytool_token_CryptoCurrencyPayload{
|
||||
crypto_currency = CryptoCurrency
|
||||
}};
|
||||
encode_payment_tool_token_payload({mobile_commerce, MobileCommerce}) ->
|
||||
{mobile_commerce_payload, #ptt_MobileCommercePayload{
|
||||
{mobile_commerce_payload, #paytool_token_MobileCommercePayload{
|
||||
mobile_commerce = MobileCommerce
|
||||
}}.
|
||||
|
||||
@ -103,13 +103,13 @@ decode_deadline(Deadline) ->
|
||||
decode_payment_tool_token_payload(PaymentToolToken) ->
|
||||
case PaymentToolToken of
|
||||
{bank_card_payload, Payload} ->
|
||||
{bank_card, Payload#ptt_BankCardPayload.bank_card};
|
||||
{bank_card, Payload#paytool_token_BankCardPayload.bank_card};
|
||||
{payment_terminal_payload, Payload} ->
|
||||
{payment_terminal, Payload#ptt_PaymentTerminalPayload.payment_terminal};
|
||||
{payment_terminal, Payload#paytool_token_PaymentTerminalPayload.payment_terminal};
|
||||
{digital_wallet_payload, Payload} ->
|
||||
{digital_wallet, Payload#ptt_DigitalWalletPayload.digital_wallet};
|
||||
{digital_wallet, Payload#paytool_token_DigitalWalletPayload.digital_wallet};
|
||||
{crypto_currency_payload, Payload} ->
|
||||
{crypto_currency, Payload#ptt_CryptoCurrencyPayload.crypto_currency};
|
||||
{crypto_currency, Payload#paytool_token_CryptoCurrencyPayload.crypto_currency};
|
||||
{mobile_commerce_payload, Payload} ->
|
||||
{mobile_commerce, Payload#ptt_MobileCommercePayload.mobile_commerce}
|
||||
{mobile_commerce, Payload#paytool_token_MobileCommercePayload.mobile_commerce}
|
||||
end.
|
||||
|
@ -1,7 +1,7 @@
|
||||
-module(capi_domain).
|
||||
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_config_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_conf_thrift.hrl").
|
||||
|
||||
-export([get_payment_institution/2]).
|
||||
-export([get_payment_institutions/1]).
|
||||
@ -37,7 +37,7 @@ get_payment_institutions(Context) ->
|
||||
try
|
||||
Opts = make_opts(Context),
|
||||
|
||||
#'VersionedObject'{
|
||||
#'domain_conf_VersionedObject'{
|
||||
version = Version,
|
||||
object = {globals, #domain_GlobalsObject{data = Globals}}
|
||||
} = dmt_client:checkout_versioned_object(latest, globals(), Opts),
|
||||
@ -61,7 +61,7 @@ get_payment_institutions(Context) ->
|
||||
|
||||
{ok, PaymentInstitutions}
|
||||
catch
|
||||
throw:#'ObjectNotFound'{} ->
|
||||
throw:#'domain_conf_ObjectNotFound'{} ->
|
||||
{error, not_found}
|
||||
end.
|
||||
|
||||
@ -72,7 +72,7 @@ get(Ref, Context) ->
|
||||
{_Type, Object} = dmt_client:checkout_object(latest, Ref, Opts),
|
||||
{ok, Object}
|
||||
catch
|
||||
throw:#'ObjectNotFound'{} ->
|
||||
throw:#'domain_conf_ObjectNotFound'{} ->
|
||||
{error, not_found}
|
||||
end.
|
||||
|
||||
|
@ -97,7 +97,6 @@ map_error(validation_error, Error) ->
|
||||
|
||||
get_handlers() ->
|
||||
[
|
||||
capi_handler_analytics,
|
||||
capi_handler_categories,
|
||||
capi_handler_claims,
|
||||
capi_handler_contracts,
|
||||
|
@ -1,133 +0,0 @@
|
||||
-module(capi_handler_analytics).
|
||||
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
-export([prepare/3]).
|
||||
|
||||
-import(capi_handler_utils, [logic_error/2]).
|
||||
|
||||
-spec prepare(
|
||||
OperationID :: capi_handler:operation_id(),
|
||||
Req :: capi_handler:request_data(),
|
||||
Context :: capi_handler:processing_context()
|
||||
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
|
||||
prepare(OperationID, Req, Context) when
|
||||
OperationID =:= 'GetPaymentConversionStats' orelse
|
||||
OperationID =:= 'GetPaymentRevenueStats' orelse
|
||||
OperationID =:= 'GetPaymentGeoStats' orelse
|
||||
OperationID =:= 'GetPaymentRateStats' orelse
|
||||
OperationID =:= 'GetPaymentMethodStats'
|
||||
->
|
||||
Authorize = fun() ->
|
||||
PartyID = capi_handler_utils:get_party_id(Context),
|
||||
Prototypes = [{operation, #{id => OperationID, party => PartyID}}],
|
||||
{ok, capi_auth:authorize_operation(Prototypes, Context)}
|
||||
end,
|
||||
Process = fun() -> process_request(OperationID, Context, Req) end,
|
||||
{ok, #{authorize => Authorize, process => Process}};
|
||||
prepare(_OperationID, _Req, _Context) ->
|
||||
{error, noimpl}.
|
||||
|
||||
-spec process_request(
|
||||
OperationID :: capi_handler:operation_id(),
|
||||
Context :: capi_handler:processing_context(),
|
||||
ReqState :: capi_handler:request_state()
|
||||
) -> {ok, capi_handler:response()}.
|
||||
process_request('GetPaymentConversionStats', Context, Req) ->
|
||||
process_merchant_stat(payments_conversion_stat, Req, Context);
|
||||
process_request('GetPaymentRevenueStats', Context, Req) ->
|
||||
process_merchant_stat(payments_turnover, Req, Context);
|
||||
process_request('GetPaymentGeoStats', Context, Req) ->
|
||||
process_merchant_stat(payments_geo_stat, Req, Context);
|
||||
process_request('GetPaymentRateStats', Context, Req) ->
|
||||
process_merchant_stat(customers_rate_stat, Req, Context);
|
||||
process_request('GetPaymentMethodStats', Context, Req) ->
|
||||
'bankCard' = maps:get('paymentMethod', Req),
|
||||
StatType = payments_pmt_cards_stat,
|
||||
process_merchant_stat(StatType, Req, Context).
|
||||
|
||||
%%
|
||||
|
||||
create_stat_dsl(StatType, Req, Context) ->
|
||||
FromTime = capi_handler_utils:get_time('fromTime', Req),
|
||||
ToTime = capi_handler_utils:get_time('toTime', Req),
|
||||
SplitInterval =
|
||||
case StatType of
|
||||
customers_rate_stat ->
|
||||
capi_handler_utils:get_time_diff(FromTime, ToTime);
|
||||
_ ->
|
||||
SplitUnit = genlib_map:get('splitUnit', Req),
|
||||
SplitSize = genlib_map:get('splitSize', Req),
|
||||
capi_handler_utils:get_split_interval(SplitSize, SplitUnit)
|
||||
end,
|
||||
Query = #{
|
||||
<<"merchant_id">> => capi_handler_utils:get_party_id(Context),
|
||||
<<"shop_id">> => genlib_map:get('shopID', Req),
|
||||
<<"from_time">> => FromTime,
|
||||
<<"to_time">> => ToTime,
|
||||
<<"split_interval">> => SplitInterval
|
||||
},
|
||||
capi_handler_utils:create_dsl(StatType, Query, #{}).
|
||||
|
||||
process_merchant_stat(StatType, Req, Context) ->
|
||||
CallArgs = {capi_handler_encoder:encode_stat_request(create_stat_dsl(StatType, Req, Context))},
|
||||
Call = {merchant_stat, 'GetStatistics', CallArgs},
|
||||
process_merchant_stat_result(StatType, capi_handler_utils:service_call(Call, Context)).
|
||||
|
||||
process_merchant_stat_result(customers_rate_stat = StatType, {ok, #merchstat_StatResponse{data = {records, Stats}}}) ->
|
||||
Resp =
|
||||
case Stats of
|
||||
[] -> #{<<"uniqueCount">> => 0};
|
||||
[StatResponse] -> decode_stat_info(StatType, StatResponse)
|
||||
end,
|
||||
{ok, {200, #{}, Resp}};
|
||||
process_merchant_stat_result(StatType, Result) ->
|
||||
case Result of
|
||||
{ok, #merchstat_StatResponse{data = {'records', Stats}}} ->
|
||||
Resp = [decode_stat_info(StatType, S) || S <- Stats],
|
||||
{ok, {200, #{}, Resp}};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #merchstat_BadToken{}} ->
|
||||
{ok, logic_error('invalidRequest', <<"Invalid token">>)}
|
||||
end.
|
||||
|
||||
decode_stat_info(payments_conversion_stat, Response) ->
|
||||
#{
|
||||
<<"offset">> => genlib:to_int(maps:get(<<"offset">>, Response)),
|
||||
<<"successfulCount">> => genlib:to_int(maps:get(<<"successful_count">>, Response)),
|
||||
<<"totalCount">> => genlib:to_int(maps:get(<<"total_count">>, Response)),
|
||||
<<"conversion">> => genlib:to_float(maps:get(<<"conversion">>, Response))
|
||||
};
|
||||
decode_stat_info(payments_geo_stat, Response) ->
|
||||
#{
|
||||
<<"offset">> => genlib:to_int(maps:get(<<"offset">>, Response)),
|
||||
<<"geoID">> => genlib:to_int(maps:get(<<"city_id">>, Response)),
|
||||
<<"currency">> => maps:get(<<"currency_symbolic_code">>, Response),
|
||||
<<"profit">> => genlib:to_int(maps:get(<<"amount_with_fee">>, Response)),
|
||||
<<"revenue">> => genlib:to_int(maps:get(<<"amount_without_fee">>, Response))
|
||||
};
|
||||
decode_stat_info(payments_turnover, Response) ->
|
||||
#{
|
||||
<<"offset">> => genlib:to_int(maps:get(<<"offset">>, Response)),
|
||||
<<"currency">> => maps:get(<<"currency_symbolic_code">>, Response),
|
||||
<<"profit">> => genlib:to_int(maps:get(<<"amount_with_fee">>, Response)),
|
||||
<<"revenue">> => genlib:to_int(maps:get(<<"amount_without_fee">>, Response))
|
||||
};
|
||||
decode_stat_info(customers_rate_stat, Response) ->
|
||||
#{
|
||||
<<"uniqueCount">> => genlib:to_int(maps:get(<<"unic_count">>, Response))
|
||||
};
|
||||
decode_stat_info(payments_pmt_cards_stat, Response) ->
|
||||
#{
|
||||
%% @TODO deal with nested responses decoding
|
||||
<<"statType">> => <<"PaymentMethodBankCardStat">>,
|
||||
<<"offset">> => genlib:to_int(maps:get(<<"offset">>, Response)),
|
||||
<<"totalCount">> => genlib:to_int(maps:get(<<"total_count">>, Response)),
|
||||
<<"paymentSystem">> => maps:get(<<"payment_system">>, Response),
|
||||
<<"profit">> => genlib:to_int(maps:get(<<"amount_with_fee">>, Response)),
|
||||
<<"revenue">> => genlib:to_int(maps:get(<<"amount_without_fee">>, Response))
|
||||
}.
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_claims).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
@ -66,7 +68,7 @@ prepare(OperationID = 'CreateClaim', Req, Context) ->
|
||||
{ok, logic_error('changesetConflict', <<"Changeset conflict">>)};
|
||||
{error, #payproc_InvalidChangeset{}} ->
|
||||
{ok, logic_error('invalidChangeset', <<"Invalid changeset">>)};
|
||||
{error, #'InvalidRequest'{errors = Errors}} ->
|
||||
{error, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)}
|
||||
end
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_contracts).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_customers).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
-module(capi_handler_decoder_invoicing).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merchstat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_user_interaction_thrift.hrl").
|
||||
|
||||
-export([decode_user_interaction_form/1]).
|
||||
-export([decode_user_interaction/1]).
|
||||
@ -31,8 +34,8 @@
|
||||
decode_user_interaction({payment_terminal_reciept, TerminalReceipt}) ->
|
||||
#{
|
||||
<<"interactionType">> => <<"PaymentTerminalReceipt">>,
|
||||
<<"shortPaymentID">> => TerminalReceipt#'PaymentTerminalReceipt'.short_payment_id,
|
||||
<<"dueDate">> => TerminalReceipt#'PaymentTerminalReceipt'.due
|
||||
<<"shortPaymentID">> => TerminalReceipt#user_interaction_PaymentTerminalReceipt.short_payment_id,
|
||||
<<"dueDate">> => TerminalReceipt#user_interaction_PaymentTerminalReceipt.due
|
||||
};
|
||||
decode_user_interaction({redirect, BrowserRequest}) ->
|
||||
#{
|
||||
@ -47,48 +50,51 @@ decode_user_interaction({qr_code_display_request, QrCodeDisplayRequest}) ->
|
||||
decode_user_interaction({crypto_currency_transfer_request, CryptoCurrencyTransferRequest}) ->
|
||||
#{
|
||||
<<"interactionType">> => <<"CryptoCurrencyTransferRequest">>,
|
||||
<<"cryptoAddress">> => CryptoCurrencyTransferRequest#'CryptoCurrencyTransferRequest'.crypto_address,
|
||||
<<"cryptoAddress">> =>
|
||||
CryptoCurrencyTransferRequest#'user_interaction_CryptoCurrencyTransferRequest'.crypto_address,
|
||||
<<"symbolicCode">> => decode_crypto_symcode(CryptoCurrencyTransferRequest),
|
||||
<<"cryptoAmount">> => decode_crypto_amount(CryptoCurrencyTransferRequest)
|
||||
}.
|
||||
|
||||
decode_browser_request({get_request, #'BrowserGetRequest'{uri = UriTemplate}}) ->
|
||||
decode_browser_request({get_request, #'user_interaction_BrowserGetRequest'{uri = UriTemplate}}) ->
|
||||
#{
|
||||
<<"requestType">> => <<"BrowserGetRequest">>,
|
||||
<<"uriTemplate">> => UriTemplate
|
||||
};
|
||||
decode_browser_request({post_request, #'BrowserPostRequest'{uri = UriTemplate, form = UserInteractionForm}}) ->
|
||||
decode_browser_request(
|
||||
{post_request, #'user_interaction_BrowserPostRequest'{uri = UriTemplate, form = UserInteractionForm}}
|
||||
) ->
|
||||
#{
|
||||
<<"requestType">> => <<"BrowserPostRequest">>,
|
||||
<<"uriTemplate">> => UriTemplate,
|
||||
<<"form">> => decode_user_interaction_form(UserInteractionForm)
|
||||
}.
|
||||
|
||||
decode_qr_code(#'QrCodeDisplayRequest'{qr_code = QrCode}) ->
|
||||
QrCode#'QrCode'.payload.
|
||||
decode_qr_code(#'user_interaction_QrCodeDisplayRequest'{qr_code = QrCode}) ->
|
||||
QrCode#'user_interaction_QrCode'.payload.
|
||||
|
||||
decode_crypto_symcode(#'CryptoCurrencyTransferRequest'{crypto_cash = Cash}) ->
|
||||
Cash#'CryptoCash'.crypto_symbolic_code.
|
||||
decode_crypto_symcode(#'user_interaction_CryptoCurrencyTransferRequest'{crypto_cash = Cash}) ->
|
||||
Cash#'user_interaction_CryptoCash'.crypto_symbolic_code.
|
||||
|
||||
decode_crypto_amount(#'CryptoCurrencyTransferRequest'{crypto_cash = Cash}) ->
|
||||
decode_crypto_amount(#'user_interaction_CryptoCurrencyTransferRequest'{crypto_cash = Cash}) ->
|
||||
% apparently Q is always a power of ten
|
||||
Amount = Cash#'CryptoCash'.crypto_amount,
|
||||
Amount = Cash#'user_interaction_CryptoCash'.crypto_amount,
|
||||
ok = ensure_correct_exponent(Amount),
|
||||
Integral = decode_integral_part(Amount),
|
||||
Fractional = decode_fractional_part(Amount),
|
||||
build_decoded_crypto_amount(Integral, Fractional).
|
||||
|
||||
ensure_correct_exponent(#'Rational'{q = Q}) ->
|
||||
ensure_correct_exponent(#base_Rational{q = Q}) ->
|
||||
Log = math:log10(Q),
|
||||
case Log - trunc(Log) of
|
||||
0.0 -> ok;
|
||||
_ -> error('expected a power of 10 denominator')
|
||||
end.
|
||||
|
||||
decode_integral_part(#'Rational'{p = P, q = Q}) ->
|
||||
decode_integral_part(#base_Rational{p = P, q = Q}) ->
|
||||
erlang:integer_to_binary(P div Q).
|
||||
|
||||
decode_fractional_part(#'Rational'{p = P, q = Q}) ->
|
||||
decode_fractional_part(#base_Rational{p = P, q = Q}) ->
|
||||
Exponent = get_exponent(Q),
|
||||
build_fractional(P rem Q, Exponent).
|
||||
|
||||
@ -579,8 +585,8 @@ crypto_amount_decoder_test() ->
|
||||
?assertEqual(<<"0.110007">>, decode_crypto_amount(build_request(11000700, 100000000))).
|
||||
|
||||
build_request(P, Q) ->
|
||||
Amount = #'Rational'{p = P, q = Q},
|
||||
Cash = #'CryptoCash'{crypto_amount = Amount, crypto_symbolic_code = <<>>},
|
||||
#'CryptoCurrencyTransferRequest'{crypto_address = <<>>, crypto_cash = Cash}.
|
||||
Amount = #base_Rational{p = P, q = Q},
|
||||
Cash = #'user_interaction_CryptoCash'{crypto_amount = Amount, crypto_symbolic_code = <<>>},
|
||||
#'user_interaction_CryptoCurrencyTransferRequest'{crypto_address = <<>>, crypto_cash = Cash}.
|
||||
|
||||
-endif.
|
||||
|
@ -1,7 +1,9 @@
|
||||
-module(capi_handler_decoder_party).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merchstat_thrift.hrl").
|
||||
|
||||
-export([decode_shop_location/1]).
|
||||
-export([decode_shop_details/1]).
|
||||
|
@ -1,6 +1,7 @@
|
||||
-module(capi_handler_decoder_utils).
|
||||
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-export([decode_map/2]).
|
||||
-export([decode_currency/1]).
|
||||
@ -20,8 +21,6 @@
|
||||
-export([decode_metadata/1]).
|
||||
-export([decode_namespaced_metadata/1]).
|
||||
|
||||
-export([convert_crypto_currency_to_swag/1]).
|
||||
|
||||
-export_type([decode_data/0]).
|
||||
|
||||
-type decode_data() :: #{binary() => term()}.
|
||||
@ -101,7 +100,7 @@ decode_category_ref(#domain_CategoryRef{id = CategoryRef}) ->
|
||||
CategoryRef.
|
||||
|
||||
-spec decode_context(capi_handler_encoder:encode_data()) -> decode_data() | undefined.
|
||||
decode_context(#'Content'{type = <<"application/json">>, data = InvoiceContext}) ->
|
||||
decode_context(#base_Content{type = <<"application/json">>, data = InvoiceContext}) ->
|
||||
% @TODO deal with non json contexts
|
||||
jsx:decode(InvoiceContext, [return_maps]);
|
||||
decode_context(undefined) ->
|
||||
@ -123,9 +122,3 @@ when
|
||||
NS :: binary().
|
||||
decode_namespaced_metadata(NamespacedMD) ->
|
||||
maps:map(fun(_NS, MD) -> decode_metadata(MD) end, NamespacedMD).
|
||||
|
||||
-spec convert_crypto_currency_to_swag(atom()) -> binary().
|
||||
convert_crypto_currency_to_swag(bitcoin_cash) ->
|
||||
<<"bitcoinCash">>;
|
||||
convert_crypto_currency_to_swag(CryptoCurrency) when is_atom(CryptoCurrency) ->
|
||||
atom_to_binary(CryptoCurrency, utf8).
|
||||
|
@ -1,7 +1,9 @@
|
||||
-module(capi_handler_encoder).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merchstat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-export([encode_contact_info/1]).
|
||||
-export([encode_client_info/1]).
|
||||
@ -11,13 +13,11 @@
|
||||
-export([encode_invoice_cart/1]).
|
||||
-export([encode_invoice_cart/2]).
|
||||
-export([encode_invoice_bank_account/1]).
|
||||
-export([encode_stat_request/1]).
|
||||
-export([encode_invoice_context/1]).
|
||||
-export([encode_payment_context/1]).
|
||||
-export([encode_invoice_line_meta/1]).
|
||||
-export([encode_residence/1]).
|
||||
-export([encode_content/2]).
|
||||
-export([encode_stat_request/2]).
|
||||
|
||||
-export_type([encode_data/0]).
|
||||
|
||||
@ -136,20 +136,7 @@ encode_payment_context(#{}) ->
|
||||
|
||||
-spec encode_content(json, term()) -> encode_data().
|
||||
encode_content(json, Data) ->
|
||||
#'Content'{
|
||||
#base_Content{
|
||||
type = <<"application/json">>,
|
||||
data = jsx:encode(Data)
|
||||
}.
|
||||
|
||||
-spec encode_stat_request(map() | binary()) -> encode_data().
|
||||
encode_stat_request(Dsl) ->
|
||||
encode_stat_request(Dsl, undefined).
|
||||
|
||||
-spec encode_stat_request(map() | binary(), binary() | undefined) -> encode_data().
|
||||
encode_stat_request(Dsl, ContinuationToken) when is_map(Dsl) ->
|
||||
encode_stat_request(jsx:encode(Dsl), ContinuationToken);
|
||||
encode_stat_request(Dsl, ContinuationToken) when is_binary(Dsl) ->
|
||||
#merchstat_StatRequest{
|
||||
dsl = Dsl,
|
||||
continuation_token = ContinuationToken
|
||||
}.
|
||||
|
@ -1,7 +1,8 @@
|
||||
-module(capi_handler_invoice_templates).
|
||||
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
@ -35,7 +36,7 @@ prepare('CreateInvoiceTemplate' = OperationID, Req, Context) ->
|
||||
of
|
||||
{ok, InvoiceTpl} ->
|
||||
{ok, {201, #{}, make_invoice_tpl_and_token(InvoiceTpl, Context)}};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_PartyNotFound{}} ->
|
||||
@ -90,7 +91,7 @@ prepare('UpdateInvoiceTemplate' = OperationID, Req, Context) ->
|
||||
of
|
||||
{ok, UpdatedInvoiceTpl} ->
|
||||
{ok, {200, #{}, decode_invoice_tpl(UpdatedInvoiceTpl)}};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_InvalidPartyStatus{}} ->
|
||||
@ -157,7 +158,7 @@ prepare('CreateInvoiceWithTemplate' = OperationID, Req, Context) ->
|
||||
try create_invoice(PartyID, InvoiceTplID, InvoiceParams, Context, OperationID) of
|
||||
{ok, #'payproc_Invoice'{invoice = Invoice}} ->
|
||||
{ok, {201, #{}, capi_handler_decoder_invoicing:make_invoice_and_token(Invoice, Context)}};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_InvalidPartyStatus{}} ->
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_invoices).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
@ -36,7 +38,7 @@ prepare('CreateInvoice' = OperationID, Req, Context) ->
|
||||
{ok, {201, #{}, capi_handler_decoder_invoicing:make_invoice_and_token(Invoice, Context)}};
|
||||
{exception, #'payproc_PartyNotFound'{}} ->
|
||||
{ok, logic_error('invalidPartyID', <<"Party not found">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_ShopNotFound{}} ->
|
||||
@ -215,7 +217,7 @@ prepare('GetInvoiceEvents' = OperationID, Req, Context) ->
|
||||
{ok, general_error(404, <<"Invoice not found">>)};
|
||||
{exception, #payproc_EventNotFound{}} ->
|
||||
{ok, general_error(404, <<"Event not found">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)}
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
-module(capi_handler_parties).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
-module(capi_handler_payment_institutions).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_payments).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
@ -38,7 +40,7 @@ prepare(OperationID = 'CreatePayment', Req, Context) ->
|
||||
{ok, logic_error('invalidInvoiceStatus', <<"Invalid invoice status">>)};
|
||||
{exception, #payproc_InvoicePaymentPending{}} ->
|
||||
{ok, logic_error('invoicePaymentPending', <<"Invoice payment pending">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_InvalidPartyStatus{}} ->
|
||||
@ -168,7 +170,7 @@ prepare(OperationID = 'CapturePayment', Req, Context) ->
|
||||
{ok, logic_error('invalidPaymentStatus', <<"Invalid payment status">>)};
|
||||
{exception, #payproc_InvoiceNotFound{}} ->
|
||||
{ok, general_error(404, <<"Invoice not found">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_OperationNotPermitted{}} ->
|
||||
@ -229,7 +231,7 @@ prepare(OperationID = 'CancelPayment', Req, Context) ->
|
||||
{ok, logic_error('invalidPaymentStatus', <<"Invalid payment status">>)};
|
||||
{exception, #payproc_InvoiceNotFound{}} ->
|
||||
{ok, general_error(404, <<"Invoice not found">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_OperationNotPermitted{}} ->
|
||||
@ -283,7 +285,7 @@ prepare(OperationID = 'CreateRefund', Req, Context) ->
|
||||
{ok, logic_error('invoicePaymentAmountExceeded', <<"Payment amount exceeded">>)};
|
||||
{exception, #payproc_InconsistentRefundCurrency{}} ->
|
||||
{ok, logic_error('inconsistentRefundCurrency', <<"Inconsistent refund currency">>)};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #payproc_AllocationNotAllowed{}} ->
|
||||
|
@ -1,7 +1,8 @@
|
||||
-module(capi_handler_payouts).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("payout_manager_proto/include/payouts_payout_manager_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -181,7 +181,7 @@ create_report(PartyID, Req, Context) ->
|
||||
{ok, {201, #{}, decode_report(Report)}};
|
||||
{exception, Exception} ->
|
||||
case Exception of
|
||||
#reporter_base_InvalidRequest{errors = Errors} ->
|
||||
#base_InvalidRequest{errors = Errors} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
#reports_ShopNotFound{} ->
|
||||
@ -223,7 +223,7 @@ get_reports(PartyID, Req, Context) ->
|
||||
{ok, {200, #{}, [decode_report(R) || R <- Reports]}};
|
||||
{exception, Exception} ->
|
||||
case Exception of
|
||||
#reporter_base_InvalidRequest{errors = Errors} ->
|
||||
#base_InvalidRequest{errors = Errors} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
#reports_DatasetTooBig{limit = Limit} ->
|
||||
@ -261,7 +261,7 @@ generate_report_presigned_url(FileID, Context) ->
|
||||
{ok, {200, #{}, #{<<"url">> => URL}}};
|
||||
{exception, Exception} ->
|
||||
case Exception of
|
||||
#reporter_base_InvalidRequest{errors = Errors} ->
|
||||
#base_InvalidRequest{errors = Errors} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
#reports_FileNotFound{} ->
|
||||
|
@ -1,6 +1,8 @@
|
||||
-module(capi_handler_search).
|
||||
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("magista_proto/include/magista_magista_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
@ -13,194 +15,129 @@
|
||||
Req :: capi_handler:request_data(),
|
||||
Context :: capi_handler:processing_context()
|
||||
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
|
||||
prepare(OperationID, Req, Context) when OperationID =:= 'SearchInvoices' ->
|
||||
Prototypes = build_prototypes(OperationID, Context, Req),
|
||||
Authorize = fun() -> {ok, capi_auth:authorize_operation(Prototypes, Context)} end,
|
||||
Process = fun() ->
|
||||
Query = make_query(Context, Req),
|
||||
Opts = #{
|
||||
thrift_fun => 'GetInvoices',
|
||||
decode_fun => fun decode_stat_invoice/2
|
||||
},
|
||||
process_search_request(invoices, Query, Req, Context, Opts)
|
||||
end,
|
||||
{ok, #{authorize => Authorize, process => Process}};
|
||||
prepare(OperationID, Req, Context) when OperationID =:= 'SearchPayments' ->
|
||||
Prototypes = build_prototypes(OperationID, Context, Req),
|
||||
Authorize = fun() -> {ok, capi_auth:authorize_operation(Prototypes, Context)} end,
|
||||
Process = fun() ->
|
||||
Query = make_query(Context, Req),
|
||||
Query = make_query(payments, Context, Req),
|
||||
Opts = #{
|
||||
thrift_fun => 'GetPayments',
|
||||
thrift_fun => 'SearchPayments',
|
||||
decode_fun => fun decode_stat_payment/2
|
||||
},
|
||||
process_search_request(payments, Query, Req, Context, Opts)
|
||||
end,
|
||||
{ok, #{authorize => Authorize, process => Process}};
|
||||
prepare(OperationID, Req, Context) when OperationID =:= 'SearchRefunds' ->
|
||||
Prototypes = build_prototypes(OperationID, Context, Req),
|
||||
Authorize = fun() -> {ok, capi_auth:authorize_operation(Prototypes, Context)} end,
|
||||
Process = fun() ->
|
||||
Query = make_query(Context, Req),
|
||||
Opts = #{
|
||||
thrift_fun => 'GetRefunds',
|
||||
decode_fun => fun decode_stat_refund/2
|
||||
},
|
||||
process_search_request(refunds, Query, Req, Context, Opts)
|
||||
end,
|
||||
{ok, #{authorize => Authorize, process => Process}};
|
||||
prepare(OperationID, Req, Context) when OperationID =:= 'SearchPayouts' ->
|
||||
Prototypes = build_prototypes(OperationID, Context, Req),
|
||||
Authorize = fun() -> {ok, capi_auth:authorize_operation(Prototypes, Context)} end,
|
||||
Process = fun() ->
|
||||
Query = make_query(Context, Req),
|
||||
Opts = #{
|
||||
thrift_fun => 'GetPayouts',
|
||||
decode_fun => fun decode_stat_payout/2
|
||||
},
|
||||
process_search_request(payouts, Query, Req, Context, Opts)
|
||||
end,
|
||||
{ok, #{authorize => Authorize, process => Process}};
|
||||
prepare(_OperationID, _Req, _Context) ->
|
||||
{error, noimpl}.
|
||||
|
||||
%%
|
||||
|
||||
make_query(Context, Req) ->
|
||||
#{
|
||||
<<"merchant_id">> => capi_handler_utils:get_party_id(Context),
|
||||
<<"shop_id">> => genlib_map:get('shopID', Req),
|
||||
<<"invoice_id">> => genlib_map:get('invoiceID', Req),
|
||||
<<"from_time">> => capi_handler_utils:get_time('fromTime', Req),
|
||||
<<"to_time">> => capi_handler_utils:get_time('toTime', Req),
|
||||
<<"payment_status">> => genlib_map:get('paymentStatus', Req),
|
||||
<<"payment_flow">> => genlib_map:get('paymentFlow', Req),
|
||||
<<"payment_method">> => encode_payment_method(genlib_map:get('paymentMethod', Req)),
|
||||
<<"payment_terminal_provider">> => genlib_map:get('paymentTerminalProvider', Req),
|
||||
<<"payment_customer_id">> => genlib_map:get('customerID', Req),
|
||||
<<"payment_id">> => genlib_map:get('paymentID', Req),
|
||||
<<"payment_email">> => genlib_map:get('payerEmail', Req),
|
||||
<<"payment_ip">> => genlib_map:get('payerIP', Req),
|
||||
<<"payment_fingerprint">> => genlib_map:get('payerFingerprint', Req),
|
||||
<<"payment_token_provider">> => genlib_map:get('bankCardTokenProvider', Req),
|
||||
<<"payment_system">> => genlib_map:get('bankCardPaymentSystem', Req),
|
||||
<<"payment_first6">> => genlib_map:get('first6', Req),
|
||||
<<"payment_last4">> => genlib_map:get('last4', Req),
|
||||
<<"payment_rrn">> => genlib_map:get('rrn', Req),
|
||||
<<"payment_approval_code">> => genlib_map:get('approvalCode', Req),
|
||||
<<"refund_id">> => genlib_map:get('refundID', Req),
|
||||
<<"refund_status">> => genlib_map:get('refundStatus', Req),
|
||||
<<"invoice_status">> => genlib_map:get('invoiceStatus', Req),
|
||||
<<"payout_id">> => genlib_map:get('payoutID', Req),
|
||||
<<"payout_type">> => encode_payout_type(genlib_map:get('payoutToolType', Req))
|
||||
make_query(payments, Context, Req) ->
|
||||
CommonSearchQueryParams = #magista_CommonSearchQueryParams{
|
||||
to_time = capi_handler_utils:get_time('toTime', Req),
|
||||
from_time = capi_handler_utils:get_time('fromTime', Req),
|
||||
shop_ids = [genlib_map:get('shopID', Req)],
|
||||
party_id = capi_handler_utils:get_party_id(Context),
|
||||
continuation_token = genlib_map:get('continuationToken', Req),
|
||||
limit = genlib_map:get('limit', Req)
|
||||
},
|
||||
PaymentParams = #magista_PaymentParams{
|
||||
payment_id = genlib_map:get('paymentID', Req),
|
||||
payment_status = encode_payment_status(genlib_map:get('paymentStatus', Req)),
|
||||
payment_flow = encode_payment_flow(genlib_map:get('paymentFlow', Req)),
|
||||
payment_tool = encode_payment_method(genlib_map:get('paymentMethod', Req)),
|
||||
payment_email = genlib_map:get('payerEmail', Req),
|
||||
payment_ip = genlib_map:get('payerIP', Req),
|
||||
payment_fingerprint = genlib_map:get('payerFingerprint', Req),
|
||||
payment_first6 = genlib_map:get('first6', Req),
|
||||
payment_system = encode_payment_system_ref(genlib_map:get('bankCardPaymentSystem', Req)),
|
||||
payment_last4 = genlib_map:get('last4', Req),
|
||||
payment_customer_id = genlib_map:get('customerID', Req),
|
||||
payment_amount = genlib_map:get('paymentAmount', Req),
|
||||
payment_rrn = genlib_map:get('rrn', Req),
|
||||
payment_approval_code = genlib_map:get('approvalCode', Req),
|
||||
payment_token_provider = encode_payment_token_provider(genlib_map:get('BankCardTokenProvider', Req))
|
||||
},
|
||||
#magista_PaymentSearchQuery{
|
||||
common_search_query_params = CommonSearchQueryParams,
|
||||
payment_params = PaymentParams,
|
||||
invoice_ids = [genlib_map:get('invoiceID', Req)]
|
||||
}.
|
||||
|
||||
process_search_request(QueryType, Query, Req, Context, Opts = #{thrift_fun := ThriftFun}) ->
|
||||
QueryParams = #{
|
||||
<<"size">> => genlib_map:get('limit', Req),
|
||||
<<"from">> => genlib_map:get('offset', Req)
|
||||
},
|
||||
ContinuationToken = genlib_map:get('continuationToken', Req),
|
||||
Call = {
|
||||
merchant_stat,
|
||||
ThriftFun,
|
||||
{
|
||||
capi_handler_encoder:encode_stat_request(
|
||||
capi_handler_utils:create_dsl(QueryType, Query, QueryParams),
|
||||
ContinuationToken
|
||||
)
|
||||
}
|
||||
},
|
||||
process_search_request(QueryType, Query, _Req, Context, Opts = #{thrift_fun := ThriftFun}) ->
|
||||
Call = {magista, ThriftFun, {Query}},
|
||||
process_search_request_result(QueryType, capi_handler_utils:service_call(Call, Context), Context, Opts).
|
||||
|
||||
process_search_request_result(QueryType, Result, Context, #{decode_fun := DecodeFun}) ->
|
||||
process_search_request_result(payments, Result, Context, #{decode_fun := DecodeFun}) ->
|
||||
case Result of
|
||||
{ok, #merchstat_StatResponse{
|
||||
data = {QueryType, Data},
|
||||
total_count = TotalCount,
|
||||
{ok, #magista_StatPaymentResponse{
|
||||
payments = Payments,
|
||||
continuation_token = ContinuationToken
|
||||
}} ->
|
||||
DecodedData = [DecodeFun(D, Context) || D <- Data],
|
||||
DecodedData = [DecodeFun(Payment, Context) || Payment <- Payments],
|
||||
Resp = genlib_map:compact(#{
|
||||
<<"result">> => DecodedData,
|
||||
<<"totalCount">> => TotalCount,
|
||||
<<"totalCount">> => length(DecodedData),
|
||||
<<"continuationToken">> => ContinuationToken
|
||||
}),
|
||||
{ok, {200, #{}, Resp}};
|
||||
{exception, #'InvalidRequest'{errors = Errors}} ->
|
||||
{exception, #base_InvalidRequest{errors = Errors}} ->
|
||||
FormattedErrors = capi_handler_utils:format_request_errors(Errors),
|
||||
{ok, logic_error('invalidRequest', FormattedErrors)};
|
||||
{exception, #merchstat_BadToken{}} ->
|
||||
{exception, #magista_LimitExceeded{}} ->
|
||||
{ok, logic_error('invalidRequest', <<"Invalid limit">>)};
|
||||
{exception, #magista_BadContinuationToken{}} ->
|
||||
{ok, logic_error('invalidRequest', <<"Invalid token">>)}
|
||||
end.
|
||||
|
||||
%%
|
||||
|
||||
encode_payment_method('bankCard') -> <<"bank_card">>;
|
||||
encode_payment_method('paymentTerminal') -> <<"payment_terminal">>;
|
||||
encode_payment_status(pending) -> pending;
|
||||
encode_payment_status(processed) -> processed;
|
||||
encode_payment_status(captured) -> captured;
|
||||
encode_payment_status(cancelled) -> cancelled;
|
||||
encode_payment_status(refunded) -> refunded;
|
||||
encode_payment_status(failed) -> failed;
|
||||
encode_payment_status(undefined) -> undefined.
|
||||
|
||||
encode_payment_flow(instant) -> instant;
|
||||
encode_payment_flow(hold) -> hold;
|
||||
encode_payment_flow(undefined) -> undefined.
|
||||
|
||||
encode_payment_method('bankCard') -> bank_card;
|
||||
encode_payment_method('paymentTerminal') -> payment_terminal;
|
||||
encode_payment_method(undefined) -> undefined.
|
||||
|
||||
encode_payout_type('PayoutAccount') -> <<"bank_account">>;
|
||||
encode_payout_type('Wallet') -> <<"wallet_info">>;
|
||||
encode_payout_type('PaymentInstitutionAccount') -> <<"payment_institution_account">>;
|
||||
encode_payout_type(undefined) -> undefined.
|
||||
encode_payment_system_ref(ID) when is_binary(ID) -> #domain_PaymentSystemRef{id = ID};
|
||||
encode_payment_system_ref(undefined) -> undefined.
|
||||
|
||||
encode_payment_token_provider(ID) when is_binary(ID) -> #domain_BankCardTokenServiceRef{id = ID};
|
||||
encode_payment_token_provider(undefined) -> undefined.
|
||||
|
||||
%%
|
||||
|
||||
decode_stat_invoice(Invoice, _Context) ->
|
||||
capi_handler_utils:merge_and_compact(
|
||||
#{
|
||||
<<"id">> => Invoice#merchstat_StatInvoice.id,
|
||||
<<"shopID">> => Invoice#merchstat_StatInvoice.shop_id,
|
||||
<<"createdAt">> => Invoice#merchstat_StatInvoice.created_at,
|
||||
<<"dueDate">> => Invoice#merchstat_StatInvoice.due,
|
||||
<<"amount">> => Invoice#merchstat_StatInvoice.amount,
|
||||
<<"currency">> => Invoice#merchstat_StatInvoice.currency_symbolic_code,
|
||||
<<"metadata">> => capi_handler_decoder_utils:decode_context(Invoice#merchstat_StatInvoice.context),
|
||||
<<"product">> => Invoice#merchstat_StatInvoice.product,
|
||||
<<"description">> => Invoice#merchstat_StatInvoice.description,
|
||||
<<"cart">> => capi_handler_decoder_invoicing:decode_invoice_cart(Invoice#merchstat_StatInvoice.cart),
|
||||
<<"allocation">> => capi_allocation:decode(Invoice#merchstat_StatInvoice.allocation)
|
||||
},
|
||||
decode_stat_invoice_status(Invoice#merchstat_StatInvoice.status)
|
||||
).
|
||||
|
||||
decode_stat_invoice_status({Status, StatusInfo}) ->
|
||||
Reason =
|
||||
case StatusInfo of
|
||||
#merchstat_InvoiceCancelled{details = Details} -> Details;
|
||||
#merchstat_InvoiceFulfilled{details = Details} -> Details;
|
||||
_ -> undefined
|
||||
end,
|
||||
#{
|
||||
<<"status">> => genlib:to_binary(Status),
|
||||
<<"reason">> => Reason
|
||||
}.
|
||||
|
||||
decode_stat_payment(Stat, Context) ->
|
||||
capi_handler_utils:merge_and_compact(
|
||||
#{
|
||||
<<"id">> => Stat#merchstat_StatPayment.id,
|
||||
<<"shortID">> => Stat#merchstat_StatPayment.short_id,
|
||||
<<"invoiceID">> => Stat#merchstat_StatPayment.invoice_id,
|
||||
<<"shopID">> => Stat#merchstat_StatPayment.shop_id,
|
||||
<<"createdAt">> => Stat#merchstat_StatPayment.created_at,
|
||||
<<"amount">> => Stat#merchstat_StatPayment.amount,
|
||||
<<"fee">> => Stat#merchstat_StatPayment.fee,
|
||||
<<"currency">> => Stat#merchstat_StatPayment.currency_symbolic_code,
|
||||
<<"payer">> => decode_stat_payer(Stat#merchstat_StatPayment.payer),
|
||||
<<"flow">> => decode_stat_payment_flow(Stat#merchstat_StatPayment.flow),
|
||||
<<"geoLocationInfo">> => decode_geo_location_info(Stat#merchstat_StatPayment.location_info),
|
||||
<<"metadata">> => capi_handler_decoder_utils:decode_context(Stat#merchstat_StatPayment.context),
|
||||
<<"transactionInfo">> => decode_stat_tx_info(Stat#merchstat_StatPayment.additional_transaction_info),
|
||||
<<"statusChangedAt">> => decode_status_changed_at(Stat#merchstat_StatPayment.status),
|
||||
<<"id">> => Stat#magista_StatPayment.id,
|
||||
<<"shortID">> => Stat#magista_StatPayment.short_id,
|
||||
<<"invoiceID">> => Stat#magista_StatPayment.invoice_id,
|
||||
<<"shopID">> => Stat#magista_StatPayment.shop_id,
|
||||
<<"createdAt">> => Stat#magista_StatPayment.created_at,
|
||||
<<"amount">> => Stat#magista_StatPayment.amount,
|
||||
<<"fee">> => Stat#magista_StatPayment.fee,
|
||||
<<"currency">> => Stat#magista_StatPayment.currency_symbolic_code,
|
||||
<<"payer">> => decode_stat_payer(Stat#magista_StatPayment.payer),
|
||||
<<"flow">> => decode_stat_payment_flow(Stat#magista_StatPayment.flow),
|
||||
<<"metadata">> => capi_handler_decoder_utils:decode_context(Stat#magista_StatPayment.context),
|
||||
<<"transactionInfo">> => decode_stat_tx_info(Stat#magista_StatPayment.additional_transaction_info),
|
||||
<<"statusChangedAt">> => Stat#magista_StatPayment.status_changed_at,
|
||||
<<"makeRecurrent">> => capi_handler_decoder_invoicing:decode_make_recurrent(
|
||||
Stat#merchstat_StatPayment.make_recurrent
|
||||
Stat#magista_StatPayment.make_recurrent
|
||||
),
|
||||
<<"cart">> => capi_handler_decoder_invoicing:decode_invoice_cart(Stat#merchstat_StatPayment.cart),
|
||||
<<"allocation">> => capi_allocation:decode(Stat#merchstat_StatPayment.allocation)
|
||||
<<"cart">> => capi_handler_decoder_invoicing:decode_invoice_cart(Stat#magista_StatPayment.cart)
|
||||
},
|
||||
decode_stat_payment_status(Stat#merchstat_StatPayment.status, Context)
|
||||
decode_stat_payment_status(Stat#magista_StatPayment.status, Context)
|
||||
).
|
||||
|
||||
decode_stat_tx_info(undefined) ->
|
||||
@ -215,7 +152,7 @@ decode_stat_tx_info(TransactionInfo) ->
|
||||
genlib_map:compact(ParsedTransactionInfo).
|
||||
|
||||
decode_stat_payer(
|
||||
{customer, #merchstat_CustomerPayer{
|
||||
{customer, #magista_CustomerPayer{
|
||||
customer_id = ID,
|
||||
payment_tool = PaymentTool
|
||||
}}
|
||||
@ -226,11 +163,13 @@ decode_stat_payer(
|
||||
<<"customerID">> => ID
|
||||
};
|
||||
decode_stat_payer(
|
||||
{recurrent, #merchstat_RecurrentPayer{
|
||||
{recurrent, #domain_RecurrentPayer{
|
||||
payment_tool = PaymentTool,
|
||||
recurrent_parent = RecurrentParent,
|
||||
phone_number = PhoneNumber,
|
||||
email = Email
|
||||
contact_info = #domain_ContactInfo{
|
||||
phone_number = PhoneNumber,
|
||||
email = Email
|
||||
}
|
||||
}}
|
||||
) ->
|
||||
#{
|
||||
@ -243,13 +182,19 @@ decode_stat_payer(
|
||||
<<"recurrentParentPayment">> => capi_handler_decoder_invoicing:decode_recurrent_parent(RecurrentParent)
|
||||
};
|
||||
decode_stat_payer(
|
||||
{payment_resource, #merchstat_PaymentResourcePayer{
|
||||
payment_tool = PaymentTool,
|
||||
session_id = PaymentSession,
|
||||
fingerprint = Fingerprint,
|
||||
ip_address = IP,
|
||||
phone_number = PhoneNumber,
|
||||
email = Email
|
||||
{payment_resource, #domain_PaymentResourcePayer{
|
||||
resource = #domain_DisposablePaymentResource{
|
||||
payment_tool = PaymentTool,
|
||||
payment_session_id = PaymentSession,
|
||||
client_info = #domain_ClientInfo{
|
||||
ip_address = IP,
|
||||
fingerprint = Fingerprint
|
||||
}
|
||||
},
|
||||
contact_info = #domain_ContactInfo{
|
||||
phone_number = PhoneNumber,
|
||||
email = Email
|
||||
}
|
||||
}}
|
||||
) ->
|
||||
genlib_map:compact(#{
|
||||
@ -269,7 +214,7 @@ decode_stat_payer(
|
||||
decode_stat_payment_flow({instant, _}) ->
|
||||
#{<<"type">> => <<"PaymentFlowInstant">>};
|
||||
decode_stat_payment_flow(
|
||||
{hold, #merchstat_InvoicePaymentFlowHold{
|
||||
{hold, #magista_InvoicePaymentFlowHold{
|
||||
on_hold_expiration = OnHoldExpiration,
|
||||
held_until = HeldUntil
|
||||
}}
|
||||
@ -283,7 +228,7 @@ decode_stat_payment_flow(
|
||||
decode_stat_payment_status({Status, StatusInfo}, Context) ->
|
||||
Error =
|
||||
case StatusInfo of
|
||||
#merchstat_InvoicePaymentFailed{failure = OperationFailure} ->
|
||||
#domain_InvoicePaymentFailed{failure = OperationFailure} ->
|
||||
capi_handler_decoder_invoicing:decode_payment_operation_failure(OperationFailure, Context);
|
||||
_ ->
|
||||
undefined
|
||||
@ -302,10 +247,10 @@ decode_stat_payment_tool_details({digital_wallet, V}) ->
|
||||
decode_stat_payment_tool_details({crypto_currency, CryptoCurrency}) ->
|
||||
#{
|
||||
<<"detailsType">> => <<"PaymentToolDetailsCryptoWallet">>,
|
||||
<<"cryptoCurrency">> => capi_handler_decoder_utils:convert_crypto_currency_to_swag(CryptoCurrency)
|
||||
<<"cryptoCurrency">> => decode_crypto_wallet_details(CryptoCurrency)
|
||||
};
|
||||
decode_stat_payment_tool_details({mobile_commerce, MobileCommerce}) ->
|
||||
#merchstat_MobileCommerce{
|
||||
#domain_MobileCommerce{
|
||||
phone = Phone
|
||||
} = MobileCommerce,
|
||||
PhoneNumber = gen_phone_number(decode_mobile_phone(Phone)),
|
||||
@ -315,11 +260,11 @@ decode_stat_payment_tool_details({mobile_commerce, MobileCommerce}) ->
|
||||
}.
|
||||
|
||||
decode_bank_card_details(BankCard, V) ->
|
||||
LastDigits = capi_handler_decoder_utils:decode_last_digits(BankCard#merchstat_BankCard.masked_pan),
|
||||
Bin = capi_handler_decoder_utils:decode_bank_card_bin(BankCard#merchstat_BankCard.bin),
|
||||
PaymentSystem = capi_handler_decoder_utils:decode_payment_system_ref(BankCard#merchstat_BankCard.payment_system),
|
||||
LastDigits = BankCard#domain_BankCard.last_digits,
|
||||
Bin = capi_handler_decoder_utils:decode_bank_card_bin(BankCard#domain_BankCard.bin),
|
||||
PaymentSystem = capi_handler_decoder_utils:decode_payment_system_ref(BankCard#domain_BankCard.payment_system),
|
||||
BankCardTokenServiceRef = capi_utils:maybe(
|
||||
BankCard#merchstat_BankCard.payment_token,
|
||||
BankCard#domain_BankCard.payment_token,
|
||||
fun capi_handler_decoder_utils:decode_bank_card_token_service_ref/1
|
||||
),
|
||||
capi_handler_utils:merge_and_compact(V, #{
|
||||
@ -330,101 +275,26 @@ decode_bank_card_details(BankCard, V) ->
|
||||
<<"tokenProvider">> => BankCardTokenServiceRef
|
||||
}).
|
||||
|
||||
decode_payment_terminal_details(#merchstat_PaymentTerminal{terminal_type_deprecated = Type}, V) ->
|
||||
decode_payment_terminal_details(
|
||||
#domain_PaymentTerminal{payment_service = #domain_PaymentServiceRef{id = Provider}},
|
||||
V
|
||||
) ->
|
||||
V#{
|
||||
<<"provider">> => genlib:to_binary(Type)
|
||||
<<"provider">> => Provider
|
||||
}.
|
||||
|
||||
decode_digital_wallet_details(#merchstat_DigitalWallet{provider_deprecated = qiwi, id = ID}, V) ->
|
||||
decode_digital_wallet_details(#domain_DigitalWallet{payment_service = #domain_PaymentServiceRef{id = Provider}}, V) ->
|
||||
V#{
|
||||
<<"digitalWalletDetailsType">> => <<"DigitalWalletDetailsQIWI">>,
|
||||
<<"phoneNumberMask">> => mask_phone_number(ID)
|
||||
<<"provider">> => Provider
|
||||
}.
|
||||
|
||||
decode_crypto_wallet_details(#domain_CryptoCurrencyRef{id = Provider}) ->
|
||||
Provider.
|
||||
|
||||
mask_phone_number(PhoneNumber) ->
|
||||
capi_utils:redact(PhoneNumber, <<"^\\+\\d(\\d{1,10}?)\\d{2,4}$">>).
|
||||
|
||||
decode_geo_location_info(#columbus_LocationInfo{city_geo_id = CityID, country_geo_id = CountryID}) ->
|
||||
#{
|
||||
<<"cityGeoID">> => CityID,
|
||||
<<"countryGeoID">> => CountryID
|
||||
};
|
||||
decode_geo_location_info(undefined) ->
|
||||
undefined.
|
||||
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentPending{}}) ->
|
||||
undefined;
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentProcessed{at = ChangedAt}}) ->
|
||||
ChangedAt;
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentCaptured{at = ChangedAt}}) ->
|
||||
ChangedAt;
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentCancelled{at = ChangedAt}}) ->
|
||||
ChangedAt;
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentRefunded{at = ChangedAt}}) ->
|
||||
ChangedAt;
|
||||
decode_status_changed_at({_, #merchstat_InvoicePaymentFailed{at = ChangedAt}}) ->
|
||||
ChangedAt.
|
||||
|
||||
decode_stat_payout(Payout, _Context) ->
|
||||
capi_handler_utils:merge_and_compact(
|
||||
#{
|
||||
<<"id">> => Payout#merchstat_StatPayout.id,
|
||||
<<"shopID">> => Payout#merchstat_StatPayout.shop_id,
|
||||
<<"createdAt">> => Payout#merchstat_StatPayout.created_at,
|
||||
<<"amount">> => Payout#merchstat_StatPayout.amount,
|
||||
<<"fee">> => Payout#merchstat_StatPayout.fee,
|
||||
<<"currency">> => Payout#merchstat_StatPayout.currency_symbolic_code,
|
||||
<<"payoutToolDetails">> => decode_payout_tool_details(Payout#merchstat_StatPayout.payout_tool_info)
|
||||
},
|
||||
decode_stat_payout_status(Payout#merchstat_StatPayout.status)
|
||||
).
|
||||
|
||||
decode_stat_payout_status({cancelled, #merchstat_PayoutCancelled{details = Details}}) ->
|
||||
#{
|
||||
<<"status">> => <<"cancelled">>,
|
||||
<<"cancellationDetails">> => genlib:to_binary(Details)
|
||||
};
|
||||
decode_stat_payout_status({Status, _}) ->
|
||||
#{
|
||||
<<"status">> => genlib:to_binary(Status)
|
||||
}.
|
||||
|
||||
decode_payout_tool_details(ToolInfo) ->
|
||||
capi_handler_decoder_party:decode_payout_tool_details(ToolInfo).
|
||||
|
||||
decode_stat_refund(Refund, _Context) ->
|
||||
capi_handler_utils:merge_and_compact(
|
||||
#{
|
||||
<<"invoiceID">> => Refund#merchstat_StatRefund.invoice_id,
|
||||
<<"paymentID">> => Refund#merchstat_StatRefund.payment_id,
|
||||
<<"id">> => Refund#merchstat_StatRefund.id,
|
||||
<<"externalID">> => Refund#merchstat_StatRefund.external_id,
|
||||
<<"createdAt">> => Refund#merchstat_StatRefund.created_at,
|
||||
<<"amount">> => Refund#merchstat_StatRefund.amount,
|
||||
<<"currency">> => Refund#merchstat_StatRefund.currency_symbolic_code,
|
||||
<<"reason">> => Refund#merchstat_StatRefund.reason,
|
||||
<<"cart">> => capi_handler_decoder_invoicing:decode_invoice_cart(
|
||||
Refund#merchstat_StatRefund.cart
|
||||
),
|
||||
<<"allocation">> => capi_allocation:decode(Refund#merchstat_StatRefund.allocation)
|
||||
},
|
||||
decode_stat_refund_status(Refund#merchstat_StatRefund.status)
|
||||
).
|
||||
|
||||
decode_stat_refund_status({Status, StatusInfo}) ->
|
||||
Error =
|
||||
case StatusInfo of
|
||||
#merchstat_InvoicePaymentRefundFailed{failure = OperationFailure} ->
|
||||
capi_handler_decoder_utils:decode_operation_failure(OperationFailure);
|
||||
_ ->
|
||||
undefined
|
||||
end,
|
||||
#{
|
||||
<<"status">> => genlib:to_binary(Status),
|
||||
<<"error">> => Error
|
||||
}.
|
||||
|
||||
decode_mobile_phone(#merchstat_MobilePhone{cc = Cc, ctn = Ctn}) ->
|
||||
decode_mobile_phone(#domain_MobilePhone{cc = Cc, ctn = Ctn}) ->
|
||||
#{<<"cc">> => Cc, <<"ctn">> => Ctn}.
|
||||
|
||||
gen_phone_number(#{<<"cc">> := Cc, <<"ctn">> := Ctn}) ->
|
||||
|
@ -1,6 +1,7 @@
|
||||
-module(capi_handler_shops).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module(capi_handler_utils).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-export([conflict_error/1]).
|
||||
@ -34,17 +34,15 @@
|
||||
|
||||
-export([get_invoice_by_id/2]).
|
||||
-export([get_payment_by_id/3]).
|
||||
-export([get_refund_by_id/4]).
|
||||
-export([get_payment_methods/3]).
|
||||
|
||||
-export([create_dsl/3]).
|
||||
-export([emplace_token_provider_data/3]).
|
||||
|
||||
-type processing_context() :: capi_handler:processing_context().
|
||||
-type response() :: capi_handler:response().
|
||||
-type entity() ::
|
||||
dmsl_domain_thrift:'Invoice'()
|
||||
| dmsl_payment_processing_thrift:'Customer'()
|
||||
| dmsl_payproc_thrift:'Customer'()
|
||||
| dmsl_domain_thrift:'InvoiceTemplate'().
|
||||
-type token_source() :: capi_auth:token_spec() | entity().
|
||||
|
||||
@ -273,10 +271,6 @@ get_invoice_by_id(InvoiceID, Context) ->
|
||||
get_payment_by_id(InvoiceID, PaymentID, Context) ->
|
||||
service_call({invoicing, 'GetPayment', {InvoiceID, PaymentID}}, Context).
|
||||
|
||||
-spec get_refund_by_id(binary(), binary(), binary(), processing_context()) -> woody:result().
|
||||
get_refund_by_id(InvoiceID, PaymentID, RefundID, Context) ->
|
||||
service_call({invoicing, 'GetPaymentRefund', {InvoiceID, PaymentID, RefundID}}, Context).
|
||||
|
||||
-spec get_payment_methods(atom(), tuple(), processing_context()) -> woody:result().
|
||||
get_payment_methods(ServiceName, Args, Context) ->
|
||||
case service_call({ServiceName, 'ComputeTerms', Args}, Context) of
|
||||
@ -292,13 +286,6 @@ get_payment_methods(ServiceName, Args, Context) ->
|
||||
Error
|
||||
end.
|
||||
|
||||
-spec create_dsl(atom(), map(), map()) -> map().
|
||||
create_dsl(QueryType, QueryBody, QueryParams) ->
|
||||
merge_and_compact(
|
||||
#{<<"query">> => maps:put(genlib:to_binary(QueryType), genlib_map:compact(QueryBody), #{})},
|
||||
QueryParams
|
||||
).
|
||||
|
||||
-spec assert_party_accessible(binary(), binary()) -> ok.
|
||||
assert_party_accessible(PartyID, PartyID) ->
|
||||
ok;
|
||||
|
@ -1,7 +1,7 @@
|
||||
-module(capi_handler_webhooks).
|
||||
|
||||
-include_lib("damsel/include/dmsl_webhooker_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
|
||||
-behaviour(capi_handler).
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
-module(capi_merchant_id).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_tool_provider_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_paytool_provider_thrift.hrl").
|
||||
|
||||
-type party_id() :: dmsl_domain_thrift:'PartyID'().
|
||||
-type shop_id() :: dmsl_domain_thrift:'ShopID'().
|
||||
-type realm() :: dmsl_domain_thrift:'PaymentInstitutionRealm'().
|
||||
-type merchant_data() :: dmsl_payment_tool_provider_thrift:'MerchantID'().
|
||||
-type merchant_data() :: dmsl_paytool_provider_thrift:'MerchantID'().
|
||||
-type merchant_id() :: binary().
|
||||
|
||||
-export([party_id/1]).
|
||||
@ -15,23 +15,23 @@
|
||||
-export([encode/1]).
|
||||
-export([decode/1]).
|
||||
|
||||
-define(THRIFT_TYPE, {struct, struct, {dmsl_payment_tool_provider_thrift, 'MerchantID'}}).
|
||||
-define(THRIFT_TYPE, {struct, struct, {dmsl_paytool_provider_thrift, 'MerchantID'}}).
|
||||
|
||||
-spec party_id(merchant_data()) -> party_id().
|
||||
party_id(#paytoolprv_MerchantID{party_id = PartyID}) ->
|
||||
party_id(#paytool_provider_MerchantID{party_id = PartyID}) ->
|
||||
PartyID.
|
||||
|
||||
-spec shop_id(merchant_data()) -> shop_id().
|
||||
shop_id(#paytoolprv_MerchantID{shop_id = ShopID}) ->
|
||||
shop_id(#paytool_provider_MerchantID{shop_id = ShopID}) ->
|
||||
ShopID.
|
||||
|
||||
-spec realm(merchant_data()) -> realm() | undefined.
|
||||
realm(#paytoolprv_MerchantID{realm = Realm}) ->
|
||||
realm(#paytool_provider_MerchantID{realm = Realm}) ->
|
||||
Realm.
|
||||
|
||||
-spec encode(realm(), party_id(), shop_id()) -> merchant_id().
|
||||
encode(Realm, PartyID, ShopID) ->
|
||||
encode(#paytoolprv_MerchantID{
|
||||
encode(#paytool_provider_MerchantID{
|
||||
party_id = PartyID,
|
||||
shop_id = ShopID,
|
||||
realm = Realm
|
||||
|
@ -1,77 +0,0 @@
|
||||
%%%
|
||||
%%% Msgpack manipulation employed by damsel interfaces.
|
||||
|
||||
%%% Copy from machinery
|
||||
|
||||
-module(capi_msgpack).
|
||||
|
||||
-include_lib("damsel/include/dmsl_msgpack_thrift.hrl").
|
||||
|
||||
%% API
|
||||
|
||||
-export([wrap/1]).
|
||||
-export([unwrap/1]).
|
||||
|
||||
-type t() :: dmsl_msgpack_thrift:'Value'().
|
||||
|
||||
-export_type([t/0]).
|
||||
|
||||
%%
|
||||
|
||||
-spec wrap
|
||||
(null) -> t();
|
||||
(boolean()) -> t();
|
||||
(integer()) -> t();
|
||||
(float()) -> t();
|
||||
%% string
|
||||
(binary()) -> t();
|
||||
%% binary
|
||||
({binary, binary()}) -> t();
|
||||
([t()]) -> t();
|
||||
(#{t() => t()}) -> t().
|
||||
wrap(null) ->
|
||||
{nl, #msgpack_Nil{}};
|
||||
wrap(V) when is_boolean(V) ->
|
||||
{b, V};
|
||||
wrap(V) when is_integer(V) ->
|
||||
{i, V};
|
||||
wrap(V) when is_float(V) ->
|
||||
V;
|
||||
wrap(V) when is_binary(V) ->
|
||||
% Assuming well-formed UTF-8 bytestring.
|
||||
{str, V};
|
||||
wrap({binary, V}) when is_binary(V) ->
|
||||
{bin, V};
|
||||
wrap(V) when is_list(V) ->
|
||||
{arr, [wrap(ListItem) || ListItem <- V]};
|
||||
wrap(V) when is_map(V) ->
|
||||
{obj, maps:fold(fun(Key, Value, Map) -> Map#{wrap(Key) => wrap(Value)} end, #{}, V)}.
|
||||
|
||||
-spec unwrap(t()) ->
|
||||
null
|
||||
| boolean()
|
||||
| integer()
|
||||
| float()
|
||||
%% string
|
||||
| binary()
|
||||
%% binary
|
||||
| {binary, binary()}
|
||||
| [t()]
|
||||
| #{t() => t()}.
|
||||
unwrap({nl, #msgpack_Nil{}}) ->
|
||||
null;
|
||||
unwrap({b, V}) when is_boolean(V) ->
|
||||
V;
|
||||
unwrap({i, V}) when is_integer(V) ->
|
||||
V;
|
||||
unwrap({flt, V}) when is_float(V) ->
|
||||
V;
|
||||
unwrap({str, V}) when is_binary(V) ->
|
||||
% Assuming well-formed UTF-8 bytestring.
|
||||
V;
|
||||
unwrap({bin, V}) when is_binary(V) ->
|
||||
{binary, V};
|
||||
unwrap({arr, V}) when is_list(V) ->
|
||||
[unwrap(ListItem) || ListItem <- V];
|
||||
unwrap({obj, V}) when is_map(V) ->
|
||||
maps:fold(fun(Key, Value, Map) -> Map#{unwrap(Key) => unwrap(Value)} end, #{}, V).
|
@ -3,7 +3,7 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("jose/include/jose_jwk.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
|
@ -3,10 +3,12 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_errors_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_error_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_webhooker_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merchstat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("reporter_proto/include/reporter_reports_thrift.hrl").
|
||||
-include_lib("payout_manager_proto/include/payouts_payout_manager_thrift.hrl").
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
@ -37,7 +39,14 @@
|
||||
create_customer_access_token_ok_test/1,
|
||||
rescind_invoice_ok_test/1,
|
||||
fulfill_invoice_ok_test/1,
|
||||
get_merchant_payment_status_test/1,
|
||||
get_payment_status_preauthorization_failed_test/1,
|
||||
get_payment_status_payment_tool_rejected_test/1,
|
||||
get_payment_status_account_limit_exceeded_test/1,
|
||||
get_payment_status_account_blocked_test/1,
|
||||
get_payment_status_rejected_by_issuer_test/1,
|
||||
get_payment_status_account_not_found_test/1,
|
||||
get_payment_status_insufficient_funds_test/1,
|
||||
|
||||
create_payment_ok_test/1,
|
||||
create_refund/1,
|
||||
create_refund_blocked_error/1,
|
||||
@ -97,15 +106,6 @@
|
||||
get_webhooks/1,
|
||||
get_webhook_by_id/1,
|
||||
delete_webhook_by_id/1,
|
||||
search_invoices_ok_test/1,
|
||||
search_payments_ok_test/1,
|
||||
search_refunds_ok_test/1,
|
||||
search_payouts_ok_test/1,
|
||||
get_payment_conversion_stats_ok_test/1,
|
||||
get_payment_revenue_stats_ok_test/1,
|
||||
get_payment_geo_stats_ok_test/1,
|
||||
get_payment_rate_stats_ok_test/1,
|
||||
get_payment_method_stats_ok_test/1,
|
||||
get_reports_ok_test/1,
|
||||
get_reports_for_party_ok_test/1,
|
||||
get_report_ok_test/1,
|
||||
@ -234,7 +234,13 @@ groups() ->
|
||||
get_refunds,
|
||||
get_refund_by_external_id,
|
||||
check_no_internal_id_for_external_id_test,
|
||||
get_merchant_payment_status_test,
|
||||
get_payment_status_preauthorization_failed_test,
|
||||
get_payment_status_payment_tool_rejected_test,
|
||||
get_payment_status_account_limit_exceeded_test,
|
||||
get_payment_status_account_blocked_test,
|
||||
get_payment_status_rejected_by_issuer_test,
|
||||
get_payment_status_account_not_found_test,
|
||||
get_payment_status_insufficient_funds_test,
|
||||
|
||||
get_payment_institutions,
|
||||
get_payment_institution_by_ref,
|
||||
@ -266,16 +272,7 @@ groups() ->
|
||||
create_payout_autorization_error,
|
||||
get_payout,
|
||||
get_payout_fail,
|
||||
search_invoices_ok_test,
|
||||
search_payments_ok_test,
|
||||
search_refunds_ok_test,
|
||||
search_payouts_ok_test,
|
||||
|
||||
get_payment_conversion_stats_ok_test,
|
||||
get_payment_revenue_stats_ok_test,
|
||||
get_payment_geo_stats_ok_test,
|
||||
get_payment_rate_stats_ok_test,
|
||||
get_payment_method_stats_ok_test,
|
||||
get_reports_ok_test,
|
||||
get_reports_for_party_ok_test,
|
||||
get_report_ok_test,
|
||||
@ -650,35 +647,111 @@ fulfill_invoice_ok_test(Config) ->
|
||||
),
|
||||
ok = capi_client_invoices:fulfill_invoice(?config(context, Config), ?STRING, ?STRING).
|
||||
|
||||
-spec get_merchant_payment_status_test(config()) -> _.
|
||||
get_merchant_payment_status_test(Config) ->
|
||||
-spec get_payment_status_preauthorization_failed_test(config()) -> _.
|
||||
get_payment_status_preauthorization_failed_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
MappedFailure = #{
|
||||
<<"code">> => <<"preauthorization_failed">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => <<"unknown">>
|
||||
}
|
||||
},
|
||||
Failure =
|
||||
payproc_errors:construct(
|
||||
'PaymentFailure',
|
||||
{preauthorization_failed, {unknown, #payproc_error_GeneralFailure{}}},
|
||||
<<"Reason">>
|
||||
),
|
||||
get_merchant_payment_status_test_impl(MappedFailure, Failure, Config).
|
||||
|
||||
-spec get_payment_status_payment_tool_rejected_test(config()) -> _.
|
||||
get_payment_status_payment_tool_rejected_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
MappedFailure = #{
|
||||
<<"code">> => <<"authorization_failed">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => <<"payment_tool_rejected">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => <<"bank_card_rejected">>,
|
||||
<<"subError">> => #{<<"code">> => <<"cvv_invalid">>}
|
||||
}
|
||||
}
|
||||
},
|
||||
Failure =
|
||||
payproc_errors:construct(
|
||||
'PaymentFailure',
|
||||
{authorization_failed,
|
||||
{payment_tool_rejected, {bank_card_rejected, {cvv_invalid, #payprocerr_GeneralFailure{}}}}},
|
||||
{payment_tool_rejected, {bank_card_rejected, {cvv_invalid, #payproc_error_GeneralFailure{}}}}},
|
||||
<<"Reason">>
|
||||
),
|
||||
get_merchant_payment_status_test_impl(MappedFailure, Failure, Config).
|
||||
|
||||
-spec get_payment_status_account_limit_exceeded_test(config()) -> _.
|
||||
get_payment_status_account_limit_exceeded_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
MappedFailure = #{
|
||||
<<"code">> => <<"authorization_failed">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => <<"account_limit_exceeded">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => <<"unknown">>
|
||||
}
|
||||
}
|
||||
},
|
||||
Failure =
|
||||
payproc_errors:construct(
|
||||
'PaymentFailure',
|
||||
{authorization_failed, {account_limit_exceeded, {unknown, #payproc_error_GeneralFailure{}}}},
|
||||
<<"Reason">>
|
||||
),
|
||||
get_merchant_payment_status_test_impl(MappedFailure, Failure, Config).
|
||||
|
||||
-spec get_payment_status_account_blocked_test(config()) -> _.
|
||||
get_payment_status_account_blocked_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
get_merchant_payment_status_test_(account_blocked, Config).
|
||||
|
||||
-spec get_payment_status_rejected_by_issuer_test(config()) -> _.
|
||||
get_payment_status_rejected_by_issuer_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
get_merchant_payment_status_test_(rejected_by_issuer, Config).
|
||||
|
||||
-spec get_payment_status_account_not_found_test(config()) -> _.
|
||||
get_payment_status_account_not_found_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
get_merchant_payment_status_test_(account_not_found, Config).
|
||||
|
||||
-spec get_payment_status_insufficient_funds_test(config()) -> _.
|
||||
get_payment_status_insufficient_funds_test(Config) ->
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
get_merchant_payment_status_test_(insufficient_funds, Config).
|
||||
|
||||
get_merchant_payment_status_test_(SubErrorCode, Config) ->
|
||||
MappedFailure6 = #{
|
||||
<<"code">> => <<"authorization_failed">>,
|
||||
<<"subError">> => #{
|
||||
<<"code">> => atom_to_binary(SubErrorCode)
|
||||
}
|
||||
},
|
||||
Failure6 =
|
||||
payproc_errors:construct(
|
||||
'PaymentFailure',
|
||||
{authorization_failed, {SubErrorCode, #payproc_error_GeneralFailure{}}},
|
||||
<<"Reason">>
|
||||
),
|
||||
get_merchant_payment_status_test_impl(MappedFailure6, Failure6, Config).
|
||||
|
||||
get_merchant_payment_status_test_impl(MappedFailure, Failure, Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{invoicing, fun('Get', _) -> {ok, ?PAYPROC_INVOICE([?PAYPROC_FAILED_PAYMENT({failure, Failure})])} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(capi_ct_helper_bouncer:judge_always_allowed(), Config),
|
||||
?assertMatch(
|
||||
{ok, #{
|
||||
<<"status">> := <<"failed">>,
|
||||
<<"error">> := #{
|
||||
<<"code">> := <<"authorization_failed">>,
|
||||
<<"subError">> := #{
|
||||
<<"code">> := <<"payment_tool_rejected">>,
|
||||
<<"subError">> := #{
|
||||
<<"code">> := <<"bank_card_rejected">>,
|
||||
<<"subError">> := #{<<"code">> := <<"cvv_invalid">>}
|
||||
}
|
||||
}
|
||||
}
|
||||
<<"error">> := MappedFailure
|
||||
}},
|
||||
capi_client_payments:get_payment_by_id(?config(context, Config), ?STRING, ?STRING)
|
||||
).
|
||||
@ -1538,7 +1611,7 @@ get_contract_by_id_ok_test(Config) ->
|
||||
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_CONTRACT_OP(<<"GetContractByID">>, ?STRING, _))
|
||||
}
|
||||
),
|
||||
@ -1771,9 +1844,9 @@ get_payout_fail(Config) ->
|
||||
_ = capi_ct_helper:mock_services([{payouts, fun('GetPayout', _) -> {ok, Payout} end}], Config),
|
||||
_ = capi_ct_helper_bouncer:mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_PAYOUT_OP(<<"GetPayout">>, ?STRING, ?STRING)),
|
||||
payouts = #bctx_v1_ContextPayouts{
|
||||
payouts = #ctx_v1_ContextPayouts{
|
||||
payout = undefined
|
||||
}
|
||||
}
|
||||
@ -1887,256 +1960,6 @@ delete_webhook_by_id(Config) ->
|
||||
),
|
||||
ok = capi_client_webhooks:delete_webhook_by_id(?config(context, Config), ?INTEGER_BINARY).
|
||||
|
||||
-spec search_invoices_ok_test(config()) -> _.
|
||||
search_invoices_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{invoicing, fun('Get', _) -> {ok, ?PAYPROC_INVOICE} end},
|
||||
{customer_management, fun('Get', _) -> {ok, ?CUSTOMER} end},
|
||||
{merchant_stat, fun('GetInvoices', _) -> {ok, ?STAT_RESPONSE_INVOICES} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_invoice_op_ctx(
|
||||
<<"SearchInvoices">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
<<"testCustomerID">>,
|
||||
Config
|
||||
),
|
||||
ok = search_invoices_ok_test_(<<"applepay">>, Config),
|
||||
ok = search_invoices_ok_test_(<<"yandexpay">>, Config).
|
||||
|
||||
search_invoices_ok_test_(BankCardTokenProvider, Config) ->
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'invoiceStatus', <<"fulfilled">>},
|
||||
{'payerEmail', <<"test@test.ru">>},
|
||||
{'payerIP', <<"192.168.0.1">>},
|
||||
{'paymentStatus', <<"processed">>},
|
||||
{'paymentFlow', <<"instant">>},
|
||||
{'paymentMethod', <<"bankCard">>},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'customerID', <<"testCustomerID">>},
|
||||
{'payerFingerprint', <<"blablablalbalbal">>},
|
||||
{'first6', <<"424242">>},
|
||||
{'last4', <<"2222">>},
|
||||
{'rrn', <<"090909090909">>},
|
||||
{'bankCardTokenProvider', BankCardTokenProvider},
|
||||
{'bankCardPaymentSystem', <<"visa">>},
|
||||
{'paymentAmount', 10000},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
{ok, _, _} = capi_client_searches:search_invoices(?config(context, Config), ?STRING, Query),
|
||||
ok.
|
||||
|
||||
-spec search_payments_ok_test(config()) -> _.
|
||||
search_payments_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{invoicing, fun('Get', _) -> {ok, ?PAYPROC_INVOICE} end},
|
||||
{merchant_stat, fun('GetPayments', _) -> {ok, ?STAT_RESPONSE_PAYMENTS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
|
||||
<<"SearchPayments">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
Config
|
||||
),
|
||||
ok = search_payments_ok_(<<"applepay">>, Config),
|
||||
ok = search_payments_ok_(<<"yandexpay">>, Config).
|
||||
|
||||
search_payments_ok_(BankCardTokenProvider, Config) ->
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'payerEmail', <<"test@test.ru">>},
|
||||
{'payerIP', <<"192.168.0.1">>},
|
||||
{'paymentStatus', <<"processed">>},
|
||||
{'paymentFlow', <<"instant">>},
|
||||
{'paymentMethod', <<"bankCard">>},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'payerFingerprint', <<"blablablalbalbal">>},
|
||||
{'first6', <<"424242">>},
|
||||
{'last4', <<"2222">>},
|
||||
{'rrn', <<"090909090909">>},
|
||||
{'approvalCode', <<"808080">>},
|
||||
{'bankCardTokenProvider', BankCardTokenProvider},
|
||||
{'bankCardPaymentSystem', <<"visa">>},
|
||||
{'paymentAmount', 10000},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
{ok, _, _} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query),
|
||||
ok.
|
||||
|
||||
-spec search_refunds_ok_test(config()) -> _.
|
||||
search_refunds_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{invoicing, fun('Get', _) -> {ok, ?PAYPROC_INVOICE} end},
|
||||
{customer_management, fun('Get', _) -> {ok, ?CUSTOMER} end},
|
||||
{merchant_stat, fun('GetRefunds', _) -> {ok, ?STAT_RESPONSE_REFUNDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_refund_op_ctx(
|
||||
<<"SearchRefunds">>,
|
||||
?STRING,
|
||||
<<"testShopID">>,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
<<"testRefundID">>,
|
||||
Config
|
||||
),
|
||||
ShopID = <<"testShopID">>,
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'shopID', ShopID},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'refundID', <<"testRefundID">>},
|
||||
% {rrn, <<"090909090909">>},
|
||||
% {approvalCode, <<"808080">>},
|
||||
{'refundStatus', <<"succeeded">>}
|
||||
],
|
||||
|
||||
{ok, _, _} = capi_client_searches:search_refunds(?config(context, Config), ShopID, Query).
|
||||
|
||||
-spec search_payouts_ok_test(config()) -> _.
|
||||
search_payouts_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[{merchant_stat, fun('GetPayouts', _) -> {ok, ?STAT_RESPONSE_PAYOUTS} end}],
|
||||
Config
|
||||
),
|
||||
ShopID = <<"testShopID">>,
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payout_op_ctx(
|
||||
<<"SearchPayouts">>,
|
||||
?STRING,
|
||||
ShopID,
|
||||
<<"testPayoutID">>,
|
||||
Config
|
||||
),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'payoutID', <<"testPayoutID">>},
|
||||
{'payoutToolType', <<"Wallet">>}
|
||||
],
|
||||
|
||||
{ok, _, _} = capi_client_searches:search_payouts(?config(context, Config), ShopID, Query).
|
||||
|
||||
-spec get_payment_conversion_stats_ok_test(_) -> _.
|
||||
get_payment_conversion_stats_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetStatistics', _) -> {ok, ?STAT_RESPONSE_RECORDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_party_op_ctx(<<"GetPaymentConversionStats">>, ?STRING, Config),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{split_unit, minute},
|
||||
{split_size, 1}
|
||||
],
|
||||
{ok, _} = capi_client_analytics:get_payment_conversion_stats(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec get_payment_revenue_stats_ok_test(config()) -> _.
|
||||
get_payment_revenue_stats_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetStatistics', _) -> {ok, ?STAT_RESPONSE_RECORDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_party_op_ctx(<<"GetPaymentRevenueStats">>, ?STRING, Config),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 36}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 36}}},
|
||||
{split_unit, hour},
|
||||
{split_size, 1}
|
||||
],
|
||||
{ok, _} = capi_client_analytics:get_payment_revenue_stats(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec get_payment_geo_stats_ok_test(config()) -> _.
|
||||
get_payment_geo_stats_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetStatistics', _) -> {ok, ?STAT_RESPONSE_RECORDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_party_op_ctx(<<"GetPaymentGeoStats">>, ?STRING, Config),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 0},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 37}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 37}}},
|
||||
{split_unit, day},
|
||||
{split_size, 1}
|
||||
],
|
||||
{ok, _} = capi_client_analytics:get_payment_geo_stats(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec get_payment_rate_stats_ok_test(config()) -> _.
|
||||
get_payment_rate_stats_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetStatistics', _) -> {ok, ?STAT_RESPONSE_RECORDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_party_op_ctx(<<"GetPaymentRateStats">>, ?STRING, Config),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 0},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 38}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 38}}},
|
||||
{split_unit, week},
|
||||
{split_size, 1}
|
||||
],
|
||||
{ok, _} = capi_client_analytics:get_payment_rate_stats(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec get_payment_method_stats_ok_test(config()) -> _.
|
||||
get_payment_method_stats_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetStatistics', _) -> {ok, ?STAT_RESPONSE_RECORDS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_party_op_ctx(<<"GetPaymentMethodStats">>, ?STRING, Config),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{offset, 0},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{split_unit, month},
|
||||
{split_size, 1},
|
||||
{'paymentMethod', <<"bankCard">>}
|
||||
],
|
||||
{ok, _} = capi_client_analytics:get_payment_method_stats(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec get_reports_ok_test(config()) -> _.
|
||||
get_reports_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services([{reporting, fun('GetReports', _) -> {ok, ?FOUND_REPORTS} end}], Config),
|
||||
|
@ -1,87 +1,89 @@
|
||||
-ifndef(capi_bouncer_data_included__).
|
||||
-define(capi_bouncer_data_included__, ok).
|
||||
|
||||
-include_lib("bouncer_proto/include/bouncer_decisions_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_context_v1_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_decision_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_base_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_thrift.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_v1_thrift.hrl").
|
||||
|
||||
-define(JUDGEMENT(Resolution), #bdcs_Judgement{resolution = Resolution}).
|
||||
-define(ALLOWED, {allowed, #bdcs_ResolutionAllowed{}}).
|
||||
-define(FORBIDDEN, {forbidden, #bdcs_ResolutionForbidden{}}).
|
||||
-define(JUDGEMENT(Resolution), #decision_Judgement{resolution = Resolution}).
|
||||
-define(ALLOWED, {allowed, #decision_ResolutionAllowed{}}).
|
||||
-define(FORBIDDEN, {forbidden, #decision_ResolutionForbidden{}}).
|
||||
|
||||
-define(CTX_ENTITY(ID), #bouncer_base_Entity{id = ID}).
|
||||
-define(CTX_ENTITY(ID), #base_Entity{id = ID}).
|
||||
|
||||
-define(CTX_CAPI(Op), #bctx_v1_ContextCommonAPI{op = Op}).
|
||||
-define(CTX_CAPI(Op), #ctx_v1_ContextCommonAPI{op = Op}).
|
||||
|
||||
-define(CTX_CAPI_OP(ID), #bctx_v1_CommonAPIOperation{id = ID}).
|
||||
-define(CTX_CAPI_OP(ID), #ctx_v1_CommonAPIOperation{id = ID}).
|
||||
|
||||
-define(CTX_PARTY_OP(ID, PartyID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_PARTY_OP(ID, PartyID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID)
|
||||
}).
|
||||
|
||||
-define(CTX_SHOP_OP(ID, PartyID, ShopID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_SHOP_OP(ID, PartyID, ShopID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID)
|
||||
}).
|
||||
|
||||
-define(CTX_CONTRACT_OP(ID, PartyID, ContractID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_CONTRACT_OP(ID, PartyID, ContractID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
contract = ?CTX_ENTITY(ContractID)
|
||||
}).
|
||||
|
||||
-define(CTX_INVOICE_OP(ID, InvoiceID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_INVOICE_OP(ID, InvoiceID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
invoice = ?CTX_ENTITY(InvoiceID)
|
||||
}).
|
||||
|
||||
-define(CTX_PAYMENT_OP(ID, InvoiceID, PaymentID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_PAYMENT_OP(ID, InvoiceID, PaymentID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
invoice = ?CTX_ENTITY(InvoiceID),
|
||||
payment = ?CTX_ENTITY(PaymentID)
|
||||
}).
|
||||
|
||||
-define(CTX_PAYMENT_OP(ID, InvoiceID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_PAYMENT_OP(ID, InvoiceID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
invoice = ?CTX_ENTITY(InvoiceID)
|
||||
}).
|
||||
|
||||
-define(CTX_REFUND_OP(ID, InvoiceID, PaymentID, RefundID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_REFUND_OP(ID, InvoiceID, PaymentID, RefundID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
invoice = ?CTX_ENTITY(InvoiceID),
|
||||
payment = ?CTX_ENTITY(PaymentID),
|
||||
refund = ?CTX_ENTITY(RefundID)
|
||||
}).
|
||||
|
||||
-define(CTX_INVOICE_TPL_OP(ID, InvoiceTemplateID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_INVOICE_TPL_OP(ID, InvoiceTemplateID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
invoice_template = ?CTX_ENTITY(InvoiceTemplateID)
|
||||
}).
|
||||
|
||||
-define(CTX_CUSTOMER_OP(ID, CustomerID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_CUSTOMER_OP(ID, CustomerID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
customer = ?CTX_ENTITY(CustomerID)
|
||||
}).
|
||||
|
||||
-define(CTX_BINDING_OP(ID, CustomerID, BindingID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_BINDING_OP(ID, CustomerID, BindingID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
customer = ?CTX_ENTITY(CustomerID),
|
||||
binding = ?CTX_ENTITY(BindingID)
|
||||
}).
|
||||
|
||||
-define(CTX_WEBHOOK_OP(ID, WebhookID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_WEBHOOK_OP(ID, WebhookID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
webhook = ?CTX_ENTITY(WebhookID)
|
||||
}).
|
||||
|
||||
-define(CTX_PAYOUT_OP(ID, PayoutID, PartyID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_PAYOUT_OP(ID, PayoutID, PartyID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
payout = ?CTX_ENTITY(PayoutID),
|
||||
party = ?CTX_ENTITY(PartyID)
|
||||
}).
|
||||
|
||||
-define(CTX_SEARCH_INVOICE_OP(ID, PartyID, ShopID, InvoiceID, PaymentID, CustomerID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_SEARCH_INVOICE_OP(ID, PartyID, ShopID, InvoiceID, PaymentID, CustomerID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
@ -90,7 +92,7 @@
|
||||
customer = ?CTX_ENTITY(CustomerID)
|
||||
}).
|
||||
|
||||
-define(CTX_SEARCH_PAYMENT_OP(ID, PartyID, ShopID, InvoiceID, PaymentID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_SEARCH_PAYMENT_OP(ID, PartyID, ShopID, InvoiceID, PaymentID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
@ -98,19 +100,19 @@
|
||||
payment = ?CTX_ENTITY(PaymentID)
|
||||
}).
|
||||
|
||||
-define(CTX_SEARCH_PAYOUT_OP(ID, PartyID, ShopID, PayoutID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_SEARCH_PAYOUT_OP(ID, PartyID, ShopID, PayoutID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
payout = ?CTX_ENTITY(PayoutID)
|
||||
}).
|
||||
|
||||
-define(CTX_REPORT_OP(ID, ReportID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_REPORT_OP(ID, ReportID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
report = ?CTX_ENTITY(ReportID)
|
||||
}).
|
||||
|
||||
-define(CTX_REPORT_OP(ID, PartyID, ShopID, ReportID, FileID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_REPORT_OP(ID, PartyID, ShopID, ReportID, FileID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
@ -118,13 +120,13 @@
|
||||
file = ?CTX_ENTITY(FileID)
|
||||
}).
|
||||
|
||||
-define(CTX_FILE_OP(ID, ReportID, FileID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_FILE_OP(ID, ReportID, FileID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
report = ?CTX_ENTITY(ReportID),
|
||||
file = ?CTX_ENTITY(FileID)
|
||||
}).
|
||||
|
||||
-define(CTX_SEARCH_REFUND_OP(ID, PartyID, ShopID, InvoiceID, PaymentID, RefundID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_SEARCH_REFUND_OP(ID, PartyID, ShopID, InvoiceID, PaymentID, RefundID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
@ -143,7 +145,7 @@
|
||||
PayoutID,
|
||||
RefundID
|
||||
),
|
||||
#bctx_v1_CommonAPIOperation{
|
||||
#ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
@ -155,59 +157,59 @@
|
||||
}
|
||||
).
|
||||
|
||||
-define(CTX_CLAIM_OP(ID, PartyID, ClaimID), #bctx_v1_CommonAPIOperation{
|
||||
-define(CTX_CLAIM_OP(ID, PartyID, ClaimID), #ctx_v1_CommonAPIOperation{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
claim = ?CTX_ENTITY(ClaimID)
|
||||
}).
|
||||
|
||||
-define(CTX_INVOICE(ID, PartyID, ShopID), #bctx_v1_Invoice{
|
||||
-define(CTX_INVOICE(ID, PartyID, ShopID), #ctx_v1_Invoice{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID)
|
||||
}).
|
||||
|
||||
-define(CTX_INVOICE(ID, PartyID, ShopID, Payments), #bctx_v1_Invoice{
|
||||
-define(CTX_INVOICE(ID, PartyID, ShopID, Payments), #ctx_v1_Invoice{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
payments = Payments
|
||||
}).
|
||||
|
||||
-define(CTX_PAYMENT(ID), #bctx_v1_Payment{id = ID}).
|
||||
-define(CTX_PAYMENT(ID), #ctx_v1_Payment{id = ID}).
|
||||
|
||||
-define(CTX_INVOICE_TPL(ID, PartyID, ShopID), #bctx_v1_InvoiceTemplate{
|
||||
-define(CTX_INVOICE_TPL(ID, PartyID, ShopID), #ctx_v1_InvoiceTemplate{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID)
|
||||
}).
|
||||
|
||||
-define(CTX_CUSTOMER(ID, PartyID, ShopID), #bctx_v1_Customer{
|
||||
-define(CTX_CUSTOMER(ID, PartyID, ShopID), #ctx_v1_Customer{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID)
|
||||
}).
|
||||
|
||||
-define(CTX_WEBHOOK(ID, PartyID), #bctx_v1_Webhook{
|
||||
-define(CTX_WEBHOOK(ID, PartyID), #ctx_v1_Webhook{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID)
|
||||
}).
|
||||
|
||||
-define(CTX_PAYOUT(ID, PartyID, ContractID, ShopID), #bctx_v1_Payout{
|
||||
-define(CTX_PAYOUT(ID, PartyID, ContractID, ShopID), #ctx_v1_Payout{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
contract = ?CTX_ENTITY(ContractID),
|
||||
shop = ?CTX_ENTITY(ShopID)
|
||||
}).
|
||||
|
||||
-define(CTX_REPORT(ID, PartyID, ShopID, Files), #bctx_v1_Report{
|
||||
-define(CTX_REPORT(ID, PartyID, ShopID, Files), #ctx_v1_Report{
|
||||
id = ID,
|
||||
party = ?CTX_ENTITY(PartyID),
|
||||
shop = ?CTX_ENTITY(ShopID),
|
||||
files = Files
|
||||
}).
|
||||
|
||||
-define(CTX_CONTEXT_REPORTS(Report), #bctx_v1_ContextReports{
|
||||
-define(CTX_CONTEXT_REPORTS(Report), #ctx_v1_ContextReports{
|
||||
report = Report
|
||||
}).
|
||||
|
||||
@ -218,7 +220,7 @@
|
||||
catch
|
||||
error:AssertMatchError:Stacktrace ->
|
||||
logger:error("failed ~p at ~p", [AssertMatchError, Stacktrace]),
|
||||
{throwing, #bdcs_InvalidContext{}}
|
||||
{throwing, #decision_InvalidContext{}}
|
||||
end
|
||||
end).
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
-include_lib("capi_token_keeper_data.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_config_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_conf_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
|
||||
-export([init_suite/2]).
|
||||
-export([init_suite/3]).
|
||||
@ -53,7 +55,7 @@ init_suite(Module, Config, CapiEnv) ->
|
||||
[
|
||||
{
|
||||
'Repository',
|
||||
{dmsl_domain_config_thrift, 'Repository'},
|
||||
{dmsl_domain_conf_thrift, 'Repository'},
|
||||
fun
|
||||
('Checkout', _) -> {ok, ?SNAPSHOT};
|
||||
('PullRange', _) -> {ok, #{}}
|
||||
@ -273,11 +275,11 @@ get_service_name({ServiceName, _WoodyService, _Fun}) ->
|
||||
ServiceName.
|
||||
|
||||
mock_service_handler({generator, Fun}) ->
|
||||
mock_service_handler('Generator', {bender_thrift, 'Generator'}, Fun);
|
||||
mock_service_handler('Generator', {bender_bender_thrift, 'Generator'}, Fun);
|
||||
mock_service_handler({bender, Fun}) ->
|
||||
mock_service_handler('Bender', {bender_thrift, 'Bender'}, Fun);
|
||||
mock_service_handler('Bender', {bender_bender_thrift, 'Bender'}, Fun);
|
||||
mock_service_handler({party_management, Fun}) ->
|
||||
mock_service_handler(party_management, {dmsl_payment_processing_thrift, 'PartyManagement'}, Fun);
|
||||
mock_service_handler(party_management, {dmsl_payproc_thrift, 'PartyManagement'}, Fun);
|
||||
mock_service_handler({ServiceName, Fun}) ->
|
||||
mock_service_handler(ServiceName, capi_woody_client:get_service_modname(ServiceName), Fun);
|
||||
mock_service_handler({ServiceName, WoodyService, Fun}) ->
|
||||
|
@ -1,10 +1,10 @@
|
||||
-module(capi_ct_helper_bender).
|
||||
|
||||
-include_lib("bender_proto/include/bender_thrift.hrl").
|
||||
-include_lib("bender_proto/include/bender_bender_thrift.hrl").
|
||||
|
||||
-type tid() :: any().
|
||||
-type internal_id() :: binary().
|
||||
-type msg_pack() :: msgpack_thrift:'Value'().
|
||||
-type msg_pack() :: msgp_msgpack_thrift:'Value'().
|
||||
|
||||
-export([get_result/1]).
|
||||
-export([get_result/2]).
|
||||
@ -20,16 +20,17 @@
|
||||
|
||||
-spec create_storage() -> tid().
|
||||
-spec del_storage(tid()) -> true.
|
||||
-spec get_internal_id(tid(), internal_id(), msg_pack()) -> {ok, bender_thrift:'GenerationResult'()}.
|
||||
-spec get_internal_id(tid(), internal_id()) -> {ok, bender_thrift:'GetInternalIDResult'()}.
|
||||
-spec generate_id(binary()) -> {ok, bender_thrift:'GeneratedID'()}.
|
||||
-spec generate_id(tid(), binary(), binary(), msg_pack()) -> {ok, bender_thrift:'GenerationResult'()}.
|
||||
-spec get_internal_id(tid(), internal_id(), msg_pack()) -> {ok, bender_bender_thrift:'GenerationResult'()}.
|
||||
-spec get_internal_id(tid(), internal_id()) -> {ok, bender_bender_thrift:'GetInternalIDResult'()}.
|
||||
-spec generate_id(binary()) -> {ok, bender_bender_thrift:'GeneratedID'()}.
|
||||
-spec generate_id(tid(), binary(), binary(), msg_pack()) -> {ok, bender_bender_thrift:'GenerationResult'()}.
|
||||
|
||||
-spec get_result(binary()) -> bender_thrift:'GenerationResult'().
|
||||
-spec get_result(binary(), msgpack_thrift:'Value'() | undefined) -> bender_thrift:'GenerationResult'().
|
||||
-spec get_internal_id_result(binary(), msgpack_thrift:'Value'() | undefined) -> bender_thrift:'GetInternalIDResult'().
|
||||
-spec get_result(binary()) -> bender_bender_thrift:'GenerationResult'().
|
||||
-spec get_result(binary(), msgp_msgpack_thrift:'Value'() | undefined) -> bender_bender_thrift:'GenerationResult'().
|
||||
-spec get_internal_id_result(binary(), msgp_msgpack_thrift:'Value'() | undefined) ->
|
||||
bender_bender_thrift:'GetInternalIDResult'().
|
||||
|
||||
-spec no_internal_id() -> bender_thrift:'InternalIDNotFound'().
|
||||
-spec no_internal_id() -> bender_bender_thrift:'InternalIDNotFound'().
|
||||
|
||||
create_storage() ->
|
||||
ets:new(bender_storage, [set, public]).
|
||||
|
@ -36,7 +36,7 @@
|
||||
mock_assert_op_ctx(Op, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_CAPI_OP(Op))
|
||||
}
|
||||
),
|
||||
@ -47,7 +47,7 @@ mock_assert_op_ctx(Op, Config) ->
|
||||
mock_assert_party_op_ctx(Op, PartyID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_PARTY_OP(Op, PartyID))
|
||||
}
|
||||
),
|
||||
@ -58,7 +58,7 @@ mock_assert_party_op_ctx(Op, PartyID, Config) ->
|
||||
mock_assert_shop_op_ctx(Op, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_SHOP_OP(Op, PartyID, ShopID))
|
||||
}
|
||||
),
|
||||
@ -69,7 +69,7 @@ mock_assert_shop_op_ctx(Op, PartyID, ShopID, Config) ->
|
||||
mock_assert_contract_op_ctx(Op, PartyID, ContractID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_CONTRACT_OP(Op, PartyID, ContractID))
|
||||
}
|
||||
),
|
||||
@ -80,9 +80,9 @@ mock_assert_contract_op_ctx(Op, PartyID, ContractID, Config) ->
|
||||
mock_assert_invoice_op_ctx(Op, InvoiceID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_INVOICE_OP(Op, InvoiceID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice = ?CTX_INVOICE(InvoiceID, PartyID, ShopID)
|
||||
}
|
||||
}
|
||||
@ -94,9 +94,9 @@ mock_assert_invoice_op_ctx(Op, InvoiceID, PartyID, ShopID, Config) ->
|
||||
mock_assert_payment_op_ctx(Op, InvoiceID, PaymentID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_PAYMENT_OP(Op, InvoiceID, PaymentID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice = ?CTX_INVOICE(InvoiceID, PartyID, ShopID, [?CTX_PAYMENT(PaymentID)])
|
||||
}
|
||||
}
|
||||
@ -108,9 +108,9 @@ mock_assert_payment_op_ctx(Op, InvoiceID, PaymentID, PartyID, ShopID, Config) ->
|
||||
mock_assert_payment_op_ctx(Op, InvoiceID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_PAYMENT_OP(Op, InvoiceID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice = ?CTX_INVOICE(InvoiceID, PartyID, ShopID, [])
|
||||
}
|
||||
}
|
||||
@ -122,9 +122,9 @@ mock_assert_payment_op_ctx(Op, InvoiceID, PartyID, ShopID, Config) ->
|
||||
mock_assert_refund_op_ctx(Op, InvoiceID, PaymentID, RefundID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_REFUND_OP(Op, InvoiceID, PaymentID, RefundID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice = ?CTX_INVOICE(InvoiceID, PartyID, ShopID, [?CTX_PAYMENT(PaymentID)])
|
||||
}
|
||||
}
|
||||
@ -136,9 +136,9 @@ mock_assert_refund_op_ctx(Op, InvoiceID, PaymentID, RefundID, PartyID, ShopID, C
|
||||
mock_assert_invoice_tpl_op_ctx(Op, InvoiceTemplateID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_INVOICE_TPL_OP(Op, InvoiceTemplateID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
invoice_template = ?CTX_INVOICE_TPL(InvoiceTemplateID, PartyID, ShopID)
|
||||
}
|
||||
}
|
||||
@ -150,9 +150,9 @@ mock_assert_invoice_tpl_op_ctx(Op, InvoiceTemplateID, PartyID, ShopID, Config) -
|
||||
mock_assert_customer_op_ctx(Op, CustomerID, PartyID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_CUSTOMER_OP(Op, CustomerID)),
|
||||
payment_processing = #bctx_v1_ContextPaymentProcessing{
|
||||
payment_processing = #ctx_v1_ContextPaymentProcessing{
|
||||
customer = ?CTX_CUSTOMER(CustomerID, PartyID, ShopID)
|
||||
}
|
||||
}
|
||||
@ -164,7 +164,7 @@ mock_assert_customer_op_ctx(Op, CustomerID, PartyID, ShopID, Config) ->
|
||||
mock_assert_claim_op_ctx(Op, PartyID, ClaimID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_CLAIM_OP(Op, PartyID, ClaimID))
|
||||
}
|
||||
),
|
||||
@ -175,9 +175,9 @@ mock_assert_claim_op_ctx(Op, PartyID, ClaimID, Config) ->
|
||||
mock_assert_webhook_op_ctx(Op, WebhookID, PartyID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_WEBHOOK_OP(Op, WebhookID)),
|
||||
webhooks = #bctx_v1_ContextWebhooks{
|
||||
webhooks = #ctx_v1_ContextWebhooks{
|
||||
webhook = ?CTX_WEBHOOK(WebhookID, PartyID)
|
||||
}
|
||||
}
|
||||
@ -189,9 +189,9 @@ mock_assert_webhook_op_ctx(Op, WebhookID, PartyID, Config) ->
|
||||
mock_assert_payout_op_ctx(Op, PayoutID, PartyID, ContractID, ShopID, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_PAYOUT_OP(Op, PayoutID, PartyID)),
|
||||
payouts = #bctx_v1_ContextPayouts{
|
||||
payouts = #ctx_v1_ContextPayouts{
|
||||
payout = ?CTX_PAYOUT(PayoutID, PartyID, ContractID, ShopID)
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,7 @@ mock_assert_search_payment_op_ctx(Op, PartyID, ShopID, InvoiceID, PaymentID, Con
|
||||
),
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(SearchCtx)
|
||||
}
|
||||
),
|
||||
@ -229,7 +229,7 @@ mock_assert_search_invoice_op_ctx(Op, PartyID, ShopID, InvoiceID, PaymentID, Cus
|
||||
),
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(SearchCtx)
|
||||
}
|
||||
),
|
||||
@ -248,7 +248,7 @@ mock_assert_search_refund_op_ctx(Op, PartyID, ShopID, InvoiceID, PaymentID, Refu
|
||||
),
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(SearchCtx)
|
||||
}
|
||||
),
|
||||
@ -264,7 +264,7 @@ mock_assert_search_payout_op_ctx(Op, PartyID, ShopID, PayoutID, Config) ->
|
||||
),
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(SearchCtx)
|
||||
}
|
||||
),
|
||||
@ -275,7 +275,7 @@ mock_assert_search_payout_op_ctx(Op, PartyID, ShopID, PayoutID, Config) ->
|
||||
mock_assert_report_op_ctx(Op, PartyID, ShopID, ReportID, Files, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_REPORT_OP(Op, ReportID)),
|
||||
reports = ?CTX_CONTEXT_REPORTS(?CTX_REPORT(ReportID, PartyID, ShopID, Files))
|
||||
}
|
||||
@ -287,7 +287,7 @@ mock_assert_report_op_ctx(Op, PartyID, ShopID, ReportID, Files, Config) ->
|
||||
mock_assert_report_op_ctx(Op, PartyID, ShopID, ReportID, FileID, Files, Config) ->
|
||||
mock_arbiter(
|
||||
?assertContextMatches(
|
||||
#bctx_v1_ContextFragment{
|
||||
#ctx_v1_ContextFragment{
|
||||
capi = ?CTX_CAPI(?CTX_FILE_OP(Op, ReportID, FileID)),
|
||||
reports = ?CTX_CONTEXT_REPORTS(?CTX_REPORT(ReportID, PartyID, ShopID, Files))
|
||||
}
|
||||
@ -308,7 +308,7 @@ mock_client(SupOrConfig) ->
|
||||
[
|
||||
{
|
||||
org_management,
|
||||
{orgmgmt_auth_context_provider_thrift, 'AuthContextProvider'},
|
||||
{orgmgmt_authctx_provider_thrift, 'AuthContextProvider'},
|
||||
fun('GetUserContext', {UserID}) ->
|
||||
{encoded_fragment, Fragment} = bouncer_client:bake_context_fragment(
|
||||
bouncer_context_helpers:make_user_fragment(#{
|
||||
@ -332,7 +332,7 @@ mock_arbiter(JudgeFun, SupOrConfig) ->
|
||||
[
|
||||
{
|
||||
bouncer,
|
||||
{bouncer_decisions_thrift, 'Arbiter'},
|
||||
{bouncer_decision_thrift, 'Arbiter'},
|
||||
fun('Judge', {?TEST_RULESET_ID, Context}) ->
|
||||
Fragments = decode_context(Context),
|
||||
Combined = combine_fragments(Fragments),
|
||||
@ -344,11 +344,11 @@ mock_arbiter(JudgeFun, SupOrConfig) ->
|
||||
)
|
||||
).
|
||||
|
||||
decode_context(#bdcs_Context{fragments = Fragments}) ->
|
||||
decode_context(#decision_Context{fragments = Fragments}) ->
|
||||
maps:map(fun(_, Fragment) -> decode_fragment(Fragment) end, Fragments).
|
||||
|
||||
decode_fragment(#bctx_ContextFragment{type = v1_thrift_binary, content = Content}) ->
|
||||
Type = {struct, struct, {bouncer_context_v1_thrift, 'ContextFragment'}},
|
||||
decode_fragment(#ctx_ContextFragment{type = v1_thrift_binary, content = Content}) ->
|
||||
Type = {struct, struct, {bouncer_ctx_v1_thrift, 'ContextFragment'}},
|
||||
Codec = thrift_strict_binary_codec:new(Content),
|
||||
{ok, Fragment, _} = thrift_strict_binary_codec:read(Codec, Type),
|
||||
Fragment.
|
||||
@ -365,7 +365,7 @@ combine_fragments(Fragments) ->
|
||||
[Fragment | Rest] = maps:values(Fragments),
|
||||
lists:foldl(fun combine_fragments/2, Fragment, Rest).
|
||||
|
||||
combine_fragments(Fragment1 = #bctx_v1_ContextFragment{}, Fragment2 = #bctx_v1_ContextFragment{}) ->
|
||||
combine_fragments(Fragment1 = #ctx_v1_ContextFragment{}, Fragment2 = #ctx_v1_ContextFragment{}) ->
|
||||
combine_records(Fragment1, Fragment2).
|
||||
|
||||
combine_records(Record1, Record2) ->
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
-include_lib("token_keeper_proto/include/tk_token_keeper_thrift.hrl").
|
||||
-include_lib("token_keeper_proto/include/tk_context_thrift.hrl").
|
||||
-include_lib("capi_token_keeper_data.hrl").
|
||||
-include_lib("bouncer_proto/include/bouncer_ctx_thrift.hrl").
|
||||
|
||||
-define(PARTY_ID, ?STRING).
|
||||
-define(USER_ID, ?STRING).
|
||||
@ -200,13 +200,13 @@ create_bouncer_context(AuthParams, UserParams) ->
|
||||
%%
|
||||
|
||||
encode_context(Context) ->
|
||||
#bctx_ContextFragment{
|
||||
#ctx_ContextFragment{
|
||||
type = v1_thrift_binary,
|
||||
content = encode_context_content(Context)
|
||||
}.
|
||||
|
||||
encode_context_content(Context) ->
|
||||
Type = {struct, struct, {bouncer_context_v1_thrift, 'ContextFragment'}},
|
||||
Type = {struct, struct, {bouncer_ctx_v1_thrift, 'ContextFragment'}},
|
||||
Codec = thrift_strict_binary_codec:new(),
|
||||
case thrift_strict_binary_codec:write(Codec, Type, Context) of
|
||||
{ok, Codec1} ->
|
||||
|
@ -3,7 +3,9 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
|
@ -18,7 +18,7 @@
|
||||
-define(API_TOKEN, <<"letmein">>).
|
||||
-define(EMAIL, <<"test@test.ru">>).
|
||||
|
||||
-define(RATIONAL, #'Rational'{p = ?INTEGER, q = ?INTEGER}).
|
||||
-define(RATIONAL, #base_Rational{p = ?INTEGER, q = ?INTEGER}).
|
||||
|
||||
-define(DETAILS, #domain_InvoiceDetails{
|
||||
product = ?STRING,
|
||||
@ -33,7 +33,7 @@
|
||||
}
|
||||
}).
|
||||
|
||||
-define(CONTENT, #'Content'{
|
||||
-define(CONTENT, #base_Content{
|
||||
type = <<"application/json">>,
|
||||
data = ?JSON_SERIAL
|
||||
}).
|
||||
@ -196,7 +196,7 @@
|
||||
token = PS,
|
||||
payment_system = #domain_PaymentSystemRef{id = PS},
|
||||
bin = <<"411111">>,
|
||||
last_digits = <<"411111******1111">>
|
||||
last_digits = <<"1111">>
|
||||
}).
|
||||
|
||||
-define(BANK_CARD(PS, ExpDate), ?BANK_CARD(PS, ExpDate, <<"CARD HODLER">>)).
|
||||
@ -863,57 +863,25 @@
|
||||
enabled = true
|
||||
}).
|
||||
|
||||
-define(STAT_RESPONSE(Data), #merchstat_StatResponse{
|
||||
data = Data,
|
||||
total_count = ?INTEGER,
|
||||
-define(STAT_RESPONSE_PAYMENTS, #magista_StatPaymentResponse{
|
||||
payments = [
|
||||
?STAT_PAYMENT(
|
||||
?STAT_CUSTOMER_PAYER({digital_wallet, ?DIGITAL_WALLET(?STRING, ?STRING, ?STRING)}),
|
||||
?STAT_PAYMENT_STATUS_PENDING
|
||||
),
|
||||
?STAT_PAYMENT(?STAT_CUSTOMER_PAYER({bank_card, ?BANK_CARD}), ?STAT_PAYMENT_STATUS_FAILED),
|
||||
?STAT_PAYMENT(?RECURRENT_PAYER, ?STAT_PAYMENT_STATUS_PENDING),
|
||||
?STAT_PAYMENT(?PAYER, ?STAT_PAYMENT_STATUS_CAPTURED),
|
||||
?STAT_PAYMENT(
|
||||
?PAYER,
|
||||
?STAT_PAYMENT_STATUS_PENDING,
|
||||
{hold, #magista_InvoicePaymentFlowHold{on_hold_expiration = cancel, held_until = ?TIMESTAMP}}
|
||||
)
|
||||
],
|
||||
continuation_token = ?STRING
|
||||
}).
|
||||
|
||||
-define(STAT_RESPONSE_INVOICES, ?STAT_RESPONSE({invoices, [?STAT_INVOICE]})).
|
||||
|
||||
-define(STAT_RESPONSE_PAYMENTS,
|
||||
?STAT_RESPONSE(
|
||||
{payments, [
|
||||
?STAT_PAYMENT(?STAT_CUSTOMER_PAYER({bank_card, ?STAT_BANK_CARD}), ?STAT_PAYMENT_STATUS_PENDING),
|
||||
?STAT_PAYMENT(?STAT_RECURRENT_PAYER({bank_card, ?STAT_BANK_CARD}), ?STAT_PAYMENT_STATUS_PENDING),
|
||||
?STAT_PAYMENT(?STAT_PAYER({bank_card, ?STAT_BANK_CARD}), ?STAT_PAYMENT_STATUS_CAPTURED),
|
||||
?STAT_PAYMENT(?STAT_PAYER({bank_card, ?STAT_BANK_CARD_WITH_TP}), ?STAT_PAYMENT_STATUS_PENDING)
|
||||
]}
|
||||
)
|
||||
).
|
||||
|
||||
-define(STAT_RESPONSE_RECORDS, ?STAT_RESPONSE({records, [?STAT_RECORD]})).
|
||||
|
||||
-define(STAT_RESPONSE_REFUNDS, ?STAT_RESPONSE({refunds, [?STAT_REFUND]})).
|
||||
|
||||
-define(STAT_RESPONSE_PAYOUTS,
|
||||
?STAT_RESPONSE(
|
||||
{payouts, [
|
||||
?STAT_PAYOUT(?WALLET_INFO),
|
||||
?STAT_PAYOUT(?RUSSIAN_BANK_ACCOUNT),
|
||||
?STAT_PAYOUT(?INTERNATIONAL_BANK_ACCOUNT),
|
||||
?STAT_PAYOUT(?PAYMENT_INSTITUTION_ACCOUNT)
|
||||
]}
|
||||
)
|
||||
).
|
||||
|
||||
-define(STAT_INVOICE, #merchstat_StatInvoice{
|
||||
id = ?STRING,
|
||||
owner_id = ?STRING,
|
||||
shop_id = ?STRING,
|
||||
created_at = ?TIMESTAMP,
|
||||
status = {unpaid, #merchstat_InvoiceUnpaid{}},
|
||||
product = ?STRING,
|
||||
description = ?STRING,
|
||||
due = ?TIMESTAMP,
|
||||
amount = ?INTEGER,
|
||||
currency_symbolic_code = ?RUB,
|
||||
context = ?CONTENT,
|
||||
external_id = ?STRING,
|
||||
allocation = ?ALLOCATION
|
||||
}).
|
||||
|
||||
-define(STAT_PAYMENT(Payer, Status), #merchstat_StatPayment{
|
||||
-define(STAT_PAYMENT(Payer, Status, Flow), #magista_StatPayment{
|
||||
id = ?STRING,
|
||||
invoice_id = ?STRING,
|
||||
owner_id = ?STRING,
|
||||
@ -925,13 +893,13 @@
|
||||
currency_symbolic_code = ?RUB,
|
||||
payer = Payer,
|
||||
context = ?CONTENT,
|
||||
flow = {instant, #merchstat_InvoicePaymentFlowInstant{}},
|
||||
flow = Flow,
|
||||
domain_revision = ?INTEGER,
|
||||
additional_transaction_info = ?ADDITIONAL_TX_INFO,
|
||||
external_id = ?STRING,
|
||||
allocation = ?ALLOCATION
|
||||
additional_transaction_info = ?ADDITIONAL_TX_INFO
|
||||
}).
|
||||
|
||||
-define(STAT_PAYMENT(Payer, Status), ?STAT_PAYMENT(Payer, Status, {instant, #magista_InvoicePaymentFlowInstant{}})).
|
||||
|
||||
-define(TX_INFO, #domain_TransactionInfo{
|
||||
id = ?STRING,
|
||||
timestamp = ?TIMESTAMP,
|
||||
@ -958,10 +926,10 @@
|
||||
).
|
||||
|
||||
-define(STAT_CUSTOMER_PAYER(PaymentTool),
|
||||
{customer, #merchstat_CustomerPayer{
|
||||
{customer, #magista_CustomerPayer{
|
||||
customer_id = ?STRING,
|
||||
payment_tool = PaymentTool,
|
||||
email = <<"test@test.ru">>
|
||||
contact_info = ?CONTACT_INFO
|
||||
}}
|
||||
).
|
||||
|
||||
@ -975,9 +943,13 @@
|
||||
|
||||
-define(RECURRENT_PARENT, #merchstat_RecurrentParentPayment{invoice_id = ?STRING, payment_id = ?STRING}).
|
||||
|
||||
-define(STAT_PAYMENT_STATUS_PENDING, {pending, #merchstat_InvoicePaymentPending{}}).
|
||||
-define(STAT_PAYMENT_STATUS_PENDING, {pending, #domain_InvoicePaymentPending{}}).
|
||||
|
||||
-define(STAT_PAYMENT_STATUS_CAPTURED, {captured, #merchstat_InvoicePaymentCaptured{at = ?TIMESTAMP}}).
|
||||
-define(STAT_PAYMENT_STATUS_CAPTURED, {captured, #domain_InvoicePaymentCaptured{}}).
|
||||
|
||||
-define(STAT_PAYMENT_STATUS_FAILED,
|
||||
{failed, #domain_InvoicePaymentFailed{failure = {failure, #domain_Failure{code = <<"error_code">>}}}}
|
||||
).
|
||||
|
||||
-define(STAT_RECORD, #{
|
||||
<<"offset">> => ?INTEGER_BINARY,
|
||||
@ -1063,7 +1035,7 @@
|
||||
reports = [?REPORT]
|
||||
}).
|
||||
|
||||
-define(SNAPSHOT, #'Snapshot'{
|
||||
-define(SNAPSHOT, #'domain_conf_Snapshot'{
|
||||
version = ?INTEGER,
|
||||
domain = #{
|
||||
{category, #domain_CategoryRef{id = ?INTEGER}} =>
|
||||
@ -1080,18 +1052,18 @@
|
||||
data = #domain_BusinessSchedule{
|
||||
name = ?STRING,
|
||||
description = ?STRING,
|
||||
schedule = #'Schedule'{
|
||||
year = {every, #'ScheduleEvery'{}},
|
||||
month = {every, #'ScheduleEvery'{}},
|
||||
day_of_month = {every, #'ScheduleEvery'{}},
|
||||
day_of_week = {every, #'ScheduleEvery'{}},
|
||||
hour = {every, #'ScheduleEvery'{}},
|
||||
minute = {every, #'ScheduleEvery'{}},
|
||||
second = {every, #'ScheduleEvery'{}}
|
||||
schedule = #'base_Schedule'{
|
||||
year = {every, #'base_ScheduleEvery'{}},
|
||||
month = {every, #'base_ScheduleEvery'{}},
|
||||
day_of_month = {every, #'base_ScheduleEvery'{}},
|
||||
day_of_week = {every, #'base_ScheduleEvery'{}},
|
||||
hour = {every, #'base_ScheduleEvery'{}},
|
||||
minute = {every, #'base_ScheduleEvery'{}},
|
||||
second = {every, #'base_ScheduleEvery'{}}
|
||||
},
|
||||
delay = #'TimeSpan'{},
|
||||
delay = #'base_TimeSpan'{},
|
||||
policy = #domain_PayoutCompilationPolicy{
|
||||
assets_freeze_for = #'TimeSpan'{}
|
||||
assets_freeze_for = #'base_TimeSpan'{}
|
||||
}
|
||||
}
|
||||
}},
|
||||
|
@ -4,7 +4,9 @@
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
-export([groups/0]).
|
||||
|
@ -3,8 +3,11 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payment_processing_errors_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_error_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
@ -650,7 +653,7 @@ get_failed_payment_with_invalid_cvv(Config) ->
|
||||
payproc_errors:construct(
|
||||
'PaymentFailure',
|
||||
{authorization_failed,
|
||||
{payment_tool_rejected, {bank_card_rejected, {cvv_invalid, #payprocerr_GeneralFailure{}}}}},
|
||||
{payment_tool_rejected, {bank_card_rejected, {cvv_invalid, #payproc_error_GeneralFailure{}}}}},
|
||||
<<"Reason">>
|
||||
),
|
||||
_ = capi_ct_helper:mock_services(
|
||||
|
@ -3,7 +3,10 @@
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
|
241
apps/capi/test/capi_magista_stat_tests_SUITE.erl
Normal file
241
apps/capi/test/capi_magista_stat_tests_SUITE.erl
Normal file
@ -0,0 +1,241 @@
|
||||
-module(capi_magista_stat_tests_SUITE).
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
-include_lib("magista_proto/include/magista_magista_thrift.hrl").
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
-include_lib("capi_bouncer_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
-export([groups/0]).
|
||||
-export([init_per_suite/1]).
|
||||
-export([end_per_suite/1]).
|
||||
-export([init_per_group/2]).
|
||||
-export([end_per_group/2]).
|
||||
-export([init_per_testcase/2]).
|
||||
-export([end_per_testcase/2]).
|
||||
|
||||
-export([init/1]).
|
||||
|
||||
-export([
|
||||
search_payments_ok_test/1,
|
||||
search_payments_invalid_request_test/1,
|
||||
search_payments_invalid_token_test/1,
|
||||
search_payments_limit_exceeded_test/1
|
||||
]).
|
||||
|
||||
-type test_case_name() :: atom().
|
||||
-type config() :: [{atom(), any()}].
|
||||
-type group_name() :: atom().
|
||||
|
||||
-behaviour(supervisor).
|
||||
|
||||
-spec init([]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
|
||||
init([]) ->
|
||||
{ok, {#{strategy => one_for_all, intensity => 1, period => 1}, []}}.
|
||||
|
||||
-spec all() -> [{group, test_case_name()}].
|
||||
all() ->
|
||||
[
|
||||
{group, operations_by_api_key_token},
|
||||
{group, operations_by_user_session_token}
|
||||
].
|
||||
|
||||
-spec groups() -> [{group_name(), list(), [test_case_name()]}].
|
||||
groups() ->
|
||||
[
|
||||
{operations_by_api_key_token, [], [
|
||||
{group, operations_by_any_token}
|
||||
]},
|
||||
{operations_by_user_session_token, [], [
|
||||
{group, operations_by_any_token}
|
||||
]},
|
||||
{operations_by_any_token, [], [
|
||||
search_payments_ok_test,
|
||||
search_payments_invalid_request_test,
|
||||
search_payments_invalid_token_test,
|
||||
search_payments_limit_exceeded_test
|
||||
]}
|
||||
].
|
||||
|
||||
%%
|
||||
%% starting/stopping
|
||||
%%
|
||||
-spec init_per_suite(config()) -> config().
|
||||
init_per_suite(Config) ->
|
||||
capi_ct_helper:init_suite(?MODULE, Config).
|
||||
|
||||
-spec end_per_suite(config()) -> _.
|
||||
end_per_suite(C) ->
|
||||
_ = capi_ct_helper:stop_mocked_service_sup(?config(suite_test_sup, C)),
|
||||
_ = [application:stop(App) || App <- proplists:get_value(apps, C)],
|
||||
ok.
|
||||
|
||||
-spec init_per_group(group_name(), config()) -> config().
|
||||
init_per_group(operations_by_api_key_token, Config) ->
|
||||
SupPid = capi_ct_helper:start_mocked_service_sup(?MODULE),
|
||||
Apps = capi_ct_helper_token_keeper:mock_api_key_token(?STRING, SupPid),
|
||||
[{context, capi_ct_helper:get_context(?API_TOKEN)}, {group_apps, Apps}, {group_test_sup, SupPid} | Config];
|
||||
init_per_group(operations_by_user_session_token, Config) ->
|
||||
SupPid = capi_ct_helper:start_mocked_service_sup(?MODULE),
|
||||
Apps = capi_ct_helper_token_keeper:mock_user_session_token(SupPid),
|
||||
[{context, capi_ct_helper:get_context(?API_TOKEN)}, {group_apps, Apps}, {group_test_sup, SupPid} | Config];
|
||||
init_per_group(_, Config) ->
|
||||
Config.
|
||||
|
||||
-spec end_per_group(group_name(), config()) -> _.
|
||||
|
||||
end_per_group(Group, C) when
|
||||
Group =:= operations_by_api_key_token;
|
||||
Group =:= operations_by_user_session_token
|
||||
->
|
||||
capi_utils:maybe(?config(group_test_sup, C), fun capi_ct_helper:stop_mocked_service_sup/1);
|
||||
end_per_group(_Group, _C) ->
|
||||
ok.
|
||||
|
||||
-spec init_per_testcase(test_case_name(), config()) -> config().
|
||||
init_per_testcase(_Name, C) ->
|
||||
[{test_sup, capi_ct_helper:start_mocked_service_sup(?MODULE)} | C].
|
||||
|
||||
-spec end_per_testcase(test_case_name(), config()) -> _.
|
||||
end_per_testcase(_Name, C) ->
|
||||
capi_ct_helper:stop_mocked_service_sup(?config(test_sup, C)),
|
||||
ok.
|
||||
|
||||
%%% Tests
|
||||
|
||||
-spec search_payments_ok_test(config()) -> _.
|
||||
search_payments_ok_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
capi_test_hack:get_invoice_mock(),
|
||||
{magista, fun('SearchPayments', _) -> {ok, ?STAT_RESPONSE_PAYMENTS} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
|
||||
<<"SearchPayments">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
Config
|
||||
),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"pending">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"processed">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"captured">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"cancelled">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"refunded">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentStatus', <<"failed">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentFlow', <<"instant">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentFlow', <<"hold">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentMethod', <<"bankCard">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query([{'paymentMethod', <<"paymentTerminal">>}], Config),
|
||||
{ok, _, _} = make_search_payments_query(
|
||||
[
|
||||
{'payerFingerprint', <<"blablablalbalbal">>},
|
||||
{'first6', <<"424242">>},
|
||||
{'last4', <<"2222">>},
|
||||
{'rrn', <<"090909090909">>},
|
||||
{'approvalCode', <<"808080">>},
|
||||
{'paymentAmount', 10000}
|
||||
],
|
||||
Config
|
||||
).
|
||||
|
||||
make_search_payments_query(QueryAdds, Config) ->
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'payerEmail', <<"test@test.ru">>},
|
||||
{'payerIP', <<"192.168.0.1">>},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
capi_client_searches:search_payments(?config(context, Config), ?STRING, Query ++ QueryAdds).
|
||||
|
||||
-spec search_payments_invalid_request_test(config()) -> _.
|
||||
search_payments_invalid_request_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
capi_test_hack:get_invoice_mock(),
|
||||
{magista, fun('SearchPayments', _) -> {throwing, #base_InvalidRequest{errors = [<<"error">>]}} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
|
||||
<<"SearchPayments">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
Config
|
||||
),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
{error, {400, _}} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec search_payments_invalid_token_test(config()) -> _.
|
||||
search_payments_invalid_token_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
capi_test_hack:get_invoice_mock(),
|
||||
{magista, fun('SearchPayments', _) -> {throwing, #magista_BadContinuationToken{reason = <<"">>}} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
|
||||
<<"SearchPayments">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
Config
|
||||
),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
{error, {400, _}} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query).
|
||||
|
||||
-spec search_payments_limit_exceeded_test(config()) -> _.
|
||||
search_payments_limit_exceeded_test(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
capi_test_hack:get_invoice_mock(),
|
||||
{magista, fun('SearchPayments', _) -> {throwing, #magista_LimitExceeded{}} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
_ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx(
|
||||
<<"SearchPayments">>,
|
||||
?STRING,
|
||||
?STRING,
|
||||
<<"testInvoiceID">>,
|
||||
<<"testPaymentID">>,
|
||||
Config
|
||||
),
|
||||
Query = [
|
||||
{limit, 2},
|
||||
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
|
||||
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
|
||||
{'invoiceID', <<"testInvoiceID">>},
|
||||
{'paymentID', <<"testPaymentID">>},
|
||||
{'continuationToken', <<"come_back_next_time">>}
|
||||
],
|
||||
{error, {400, _}} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query).
|
@ -0,0 +1,13 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
|
||||
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
|
||||
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
|
||||
3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2
|
||||
pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX
|
||||
GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il
|
||||
AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF
|
||||
L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k
|
||||
X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
|
||||
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
|
||||
-----END RSA PRIVATE KEY-----
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"use": "enc",
|
||||
"kty": "oct",
|
||||
"kid": "1111",
|
||||
"alg": "dir",
|
||||
"k": "d3JPWmpORzVqbGRrZ2s0aUdjQnJ6ZTh1OW1pdk1kR2Y"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"use": "enc",
|
||||
"kty": "EC",
|
||||
"kid": "kxdD0orVPGoAxWrqAMTeQ0U5MRoK47uZxWiSJdgo0t0",
|
||||
"crv": "P-256",
|
||||
"alg": "ECDH-ES",
|
||||
"x": "nHi7TCgBwfrPuNTf49bGvJMczk6WZOI-mCKAghbrOlM",
|
||||
"y": "_8kiXGOIWkfz57m8K5dmTfbYzCJVYHZZZisCfbYicr0",
|
||||
"d": "i45qDiARZ5qbS_uzeT-CiKnPUe64qHitKaVdAvcN6TI"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"use": "enc",
|
||||
"kty": "EC",
|
||||
"kid": "kxdD0orVPGoAxWrqAMTeQ0U5MRoK47uZxWiSJdgo0t0",
|
||||
"crv": "P-256",
|
||||
"alg": "ECDH-ES",
|
||||
"x": "nHi7TCgBwfrPuNTf49bGvJMczk6WZOI-mCKAghbrOlM",
|
||||
"y": "_8kiXGOIWkfz57m8K5dmTfbYzCJVYHZZZisCfbYicr0"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBOwIBAAJBAK9fx7qOJT7Aoseu7KKgaLagBh3wvDzg7F/ZMtGbPFikJnnvRWvF
|
||||
B5oEGbMPblvtF0/fjqfu+eqjP3Z1tUSn7TkCAwEAAQJABUY5KIgr4JZEjwLYxQ9T
|
||||
9uIbLP1Xe/E7yqoqmBk2GGhSrPY0OeRkYnUVLcP96UPQhF63iuG8VF6uZ7oAPsq+
|
||||
gQIhANZy3jSCzPjXYHRU1kRqQzpt2S+OqoEiqQ6YG1HrC/VxAiEA0Vq6JlQK2tOX
|
||||
37SS00dK0Qog4Qi8dN73GliFQNP18EkCIQC4epSA48zkfJMzQBAbRraSuxDNApPX
|
||||
BzQbo+pMrEDbYQIgY4AncQgIkLB4Qk5kah48JNYXglzQlQtTjiX8Ty9ueGECIQCM
|
||||
GD3UbQKiA0gf5plBA24I4wFVKxxa4wXbW/7SfP6XmQ==
|
||||
-----END RSA PRIVATE KEY-----
|
@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK9fx7qOJT7Aoseu7KKgaLagBh3wvDzg
|
||||
7F/ZMtGbPFikJnnvRWvFB5oEGbMPblvtF0/fjqfu+eqjP3Z1tUSn7TkCAwEAAQ==
|
||||
-----END PUBLIC KEY-----
|
@ -2,8 +2,11 @@
|
||||
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_merchstat_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([all/0]).
|
||||
@ -139,14 +142,5 @@ schema_param_validation(Config) ->
|
||||
|
||||
-spec query_param_validation(config()) -> _.
|
||||
query_param_validation(Config) ->
|
||||
_ = capi_ct_helper:mock_services(
|
||||
[
|
||||
{merchant_stat, fun('GetInvoices', _) -> {ok, ?STAT_RESPONSE_INVOICES} end}
|
||||
],
|
||||
Config
|
||||
),
|
||||
Query0 = [
|
||||
{'payerEmail', <<"te%^st@test.ru">>}
|
||||
],
|
||||
{error, {request_validation_failed, _}} =
|
||||
capi_client_searches:search_invoices(?config(context, Config), ?STRING, Query0).
|
||||
capi_client_invoices:get_invoice_by_external_id(?config(context, Config), <<"">>).
|
||||
|
13
apps/capi/test/capi_test_hack.erl
Normal file
13
apps/capi/test/capi_test_hack.erl
Normal file
@ -0,0 +1,13 @@
|
||||
-module(capi_test_hack).
|
||||
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-include_lib("capi_dummy_data.hrl").
|
||||
|
||||
-export([get_invoice_mock/0]).
|
||||
|
||||
-spec get_invoice_mock() -> _.
|
||||
get_invoice_mock() ->
|
||||
{invoicing, fun('Get', _) -> {ok, ?PAYPROC_INVOICE} end}.
|
@ -1,65 +0,0 @@
|
||||
-module(capi_client_analytics).
|
||||
|
||||
-export([get_payment_conversion_stats/3]).
|
||||
-export([get_payment_revenue_stats/3]).
|
||||
-export([get_payment_geo_stats/3]).
|
||||
-export([get_payment_rate_stats/3]).
|
||||
-export([get_payment_method_stats/3]).
|
||||
|
||||
-type context() :: capi_client_lib:context().
|
||||
-type search_query() :: capi_client_lib:search_query().
|
||||
|
||||
-spec get_payment_conversion_stats(context(), binary(), search_query()) -> {ok, term()} | {error, term()}.
|
||||
get_payment_conversion_stats(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_analytics_api:get_payment_conversion_stats(Url, PreparedParams, Opts),
|
||||
capi_client_lib:handle_response(Response).
|
||||
|
||||
-spec get_payment_revenue_stats(context(), binary(), search_query()) -> {ok, term()} | {error, term()}.
|
||||
get_payment_revenue_stats(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_analytics_api:get_payment_revenue_stats(Url, PreparedParams, Opts),
|
||||
capi_client_lib:handle_response(Response).
|
||||
|
||||
-spec get_payment_geo_stats(context(), binary(), search_query()) -> {ok, term()} | {error, term()}.
|
||||
get_payment_geo_stats(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_analytics_api:get_payment_geo_stats(Url, PreparedParams, Opts),
|
||||
capi_client_lib:handle_response(Response).
|
||||
|
||||
-spec get_payment_rate_stats(context(), binary(), search_query()) -> {ok, term()} | {error, term()}.
|
||||
get_payment_rate_stats(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_analytics_api:get_payment_rate_stats(Url, PreparedParams, Opts),
|
||||
capi_client_lib:handle_response(Response).
|
||||
|
||||
-spec get_payment_method_stats(context(), binary(), search_query()) -> {ok, term()} | {error, term()}.
|
||||
get_payment_method_stats(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_analytics_api:get_payment_method_stats(Url, PreparedParams, Opts),
|
||||
capi_client_lib:handle_response(Response).
|
@ -1,29 +1,10 @@
|
||||
-module(capi_client_searches).
|
||||
|
||||
-export([search_invoices/3]).
|
||||
-export([search_payments/3]).
|
||||
-export([search_refunds/3]).
|
||||
-export([search_payouts/3]).
|
||||
|
||||
-type context() :: capi_client_lib:context().
|
||||
-type search_query() :: capi_client_lib:search_query().
|
||||
|
||||
-spec search_invoices(context(), binary(), search_query()) -> {ok, term(), term()} | {error, term()}.
|
||||
search_invoices(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_search_api:search_invoices(Url, PreparedParams, Opts),
|
||||
case capi_client_lib:handle_response(Response) of
|
||||
{ok, #{<<"totalCount">> := TotalCount, <<"result">> := Invoices}} ->
|
||||
{ok, TotalCount, Invoices};
|
||||
{error, Error} ->
|
||||
{error, Error}
|
||||
end.
|
||||
|
||||
-spec search_payments(context(), binary(), search_query()) -> {ok, term(), term()} | {error, term()}.
|
||||
search_payments(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
@ -39,35 +20,3 @@ search_payments(Context, ShopID, Query) ->
|
||||
{error, Error} ->
|
||||
{error, Error}
|
||||
end.
|
||||
|
||||
-spec search_refunds(context(), binary(), search_query()) -> {ok, term(), term()} | {error, term()}.
|
||||
search_refunds(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_search_api:search_refunds(Url, PreparedParams, Opts),
|
||||
case capi_client_lib:handle_response(Response) of
|
||||
{ok, #{<<"totalCount">> := TotalCount, <<"result">> := Payments}} ->
|
||||
{ok, TotalCount, Payments};
|
||||
{error, Error} ->
|
||||
{error, Error}
|
||||
end.
|
||||
|
||||
-spec search_payouts(context(), binary(), search_query()) -> {ok, term(), term()} | {error, term()}.
|
||||
search_payouts(Context, ShopID, Query) ->
|
||||
Qs = capi_client_lib:make_search_query_string(Query),
|
||||
Params = #{
|
||||
binding => #{<<"shopID">> => ShopID},
|
||||
qs_val => Qs
|
||||
},
|
||||
{Url, PreparedParams, Opts} = capi_client_lib:make_request(Context, Params),
|
||||
Response = swag_client_search_api:search_payouts(Url, PreparedParams, Opts),
|
||||
case capi_client_lib:handle_response(Response) of
|
||||
{ok, #{<<"totalCount">> := TotalCount, <<"result">> := Payments}} ->
|
||||
{ok, TotalCount, Payments};
|
||||
{error, Error} ->
|
||||
{error, Error}
|
||||
end.
|
||||
|
@ -74,11 +74,11 @@ apply_retry_step({wait, Timeout, Retry}, Deadline0, Error) ->
|
||||
|
||||
-spec get_service_modname(service_name()) -> woody:service().
|
||||
get_service_modname(invoicing) ->
|
||||
{dmsl_payment_processing_thrift, 'Invoicing'};
|
||||
{dmsl_payproc_thrift, 'Invoicing'};
|
||||
get_service_modname(invoice_templating) ->
|
||||
{dmsl_payment_processing_thrift, 'InvoiceTemplating'};
|
||||
get_service_modname(merchant_stat) ->
|
||||
{dmsl_merch_stat_thrift, 'MerchantStatistics'};
|
||||
{dmsl_payproc_thrift, 'InvoiceTemplating'};
|
||||
get_service_modname(magista) ->
|
||||
{magista_magista_thrift, 'MerchantStatisticsService'};
|
||||
get_service_modname(reporting) ->
|
||||
{reporter_reports_thrift, 'Reporting'};
|
||||
get_service_modname(payouts) ->
|
||||
@ -86,9 +86,7 @@ get_service_modname(payouts) ->
|
||||
get_service_modname(webhook_manager) ->
|
||||
{dmsl_webhooker_thrift, 'WebhookManager'};
|
||||
get_service_modname(customer_management) ->
|
||||
{dmsl_payment_processing_thrift, 'CustomerManagement'};
|
||||
get_service_modname(party_management) ->
|
||||
{dmsl_payment_processing_thrift, 'PartyManagement'}.
|
||||
{dmsl_payproc_thrift, 'CustomerManagement'}.
|
||||
|
||||
get_service_deadline(ServiceName) ->
|
||||
ServiceDeadlines = genlib_app:env(?MODULE, service_deadlines, #{}),
|
||||
|
@ -36,7 +36,7 @@
|
||||
{woody_user_identity, {git, "https://github.com/valitydev/woody_erlang_user_identity.git", {branch, "master"}}},
|
||||
{damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}},
|
||||
{bender_proto, {git, "https://github.com/valitydev/bender-proto.git", {branch, "master"}}},
|
||||
{bender_client, {git, "https://github.com/valitydev/bender_client_erlang.git", {branch, "master"}}},
|
||||
{bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {branch, "master"}}},
|
||||
{reporter_proto, {git, "https://github.com/valitydev/reporter-proto.git", {branch, "master"}}},
|
||||
{dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {branch, "master"}}},
|
||||
{cowboy_cors, {git, "https://github.com/valitydev/cowboy_cors.git", {branch, "master"}}},
|
||||
@ -51,6 +51,7 @@
|
||||
{party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {branch, master}}},
|
||||
{payout_manager_proto, {git, "https://github.com/valitydev/payout-manager-proto.git", {branch, master}}},
|
||||
{feat, {git, "https://github.com/valitydev/feat.git", {branch, master}}},
|
||||
{magista_proto, {git, "https://github.com/valitydev/magista-proto.git", {branch, master}}},
|
||||
%% Libraries generated with swagger-codegen-erlang from valitydev/swag-payments
|
||||
{swag_server, {git, "https://github.com/valitydev/swag-payments", {branch, "release/erlang/server/v2"}}},
|
||||
{swag_client, {git, "https://github.com/valitydev/swag-payments", {branch, "release/erlang/client/v2"}}}
|
||||
|
36
rebar.lock
36
rebar.lock
@ -1,19 +1,19 @@
|
||||
{"1.2.0",
|
||||
[{<<"bender_client">>,
|
||||
{git,"https://github.com/valitydev/bender_client_erlang.git",
|
||||
{ref,"29501d6f6425bc310ef6b37b62790126bdff356b"}},
|
||||
{git,"https://github.com/valitydev/bender-client-erlang.git",
|
||||
{ref,"4e15070a194ed2f3f033891eb2da935982a06c30"}},
|
||||
0},
|
||||
{<<"bender_proto">>,
|
||||
{git,"https://github.com/valitydev/bender-proto.git",
|
||||
{ref,"e08deadaab22019ff50a5d96ca6befff0034dab3"}},
|
||||
{ref,"71c56878c1cf154cdfab9bbc563ddba25abe7259"}},
|
||||
0},
|
||||
{<<"bouncer_client">>,
|
||||
{git,"https://github.com/valitydev/bouncer-client-erlang.git",
|
||||
{ref,"b6c7be05e24f46121f42ae5a48232b94f78c9c5c"}},
|
||||
{ref,"5bfb7eb98a04f9b638edb4dae56b7509d6fd03f9"}},
|
||||
0},
|
||||
{<<"bouncer_proto">>,
|
||||
{git,"https://github.com/valitydev/bouncer-proto.git",
|
||||
{ref,"96bd74dbf1db33ce1cbc6f6d3ce5a9b598ee29f5"}},
|
||||
{ref,"de15d375ee77c5002c55a1ba9a20a67d2c222115"}},
|
||||
0},
|
||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.6.1">>},2},
|
||||
@ -37,15 +37,15 @@
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1},
|
||||
{<<"damsel">>,
|
||||
{git,"https://github.com/valitydev/damsel.git",
|
||||
{ref,"d384c125d16c0204e23b0d96a6ef791244a72315"}},
|
||||
{ref,"9362c08657d1681240d70f923fc04642bbfecc0a"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"https://github.com/valitydev/dmt_client.git",
|
||||
{ref,"e9b1961b96ce138a34f6cf9cebef6ddf66af1942"}},
|
||||
{ref,"ce6678af1499230fe13f8b34258aabe8b92ac722"}},
|
||||
0},
|
||||
{<<"dmt_core">>,
|
||||
{git,"https://github.com/valitydev/dmt_core.git",
|
||||
{ref,"910e20edbe03ae4645aa3923baea8054003753b5"}},
|
||||
{git,"https://github.com/valitydev/dmt-core.git",
|
||||
{ref,"75841332fe0b40a77da0c12ea8d5dbb994da8e82"}},
|
||||
1},
|
||||
{<<"email_validator">>,{pkg,<<"email_validator">>,<<"1.1.0">>},1},
|
||||
{<<"erl_health">>,
|
||||
@ -80,20 +80,24 @@
|
||||
{git,"https://github.com/valitydev/lechiffre.git",
|
||||
{ref,"ab894bc7c0e830f4372d302036f044d20c76ca73"}},
|
||||
0},
|
||||
{<<"magista_proto">>,
|
||||
{git,"https://github.com/valitydev/magista-proto.git",
|
||||
{ref,"5352f74dd5791bf72e2c4b8b652c794b45aa6a30"}},
|
||||
0},
|
||||
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2},
|
||||
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
|
||||
{<<"msgpack_proto">>,
|
||||
{git,"https://github.com/valitydev/msgpack-proto.git",
|
||||
{ref,"ec15d5e854ea60c58467373077d90c2faf6273d8"}},
|
||||
{ref,"7e447496aa5df4a5f1ace7ef2e3c31248b2a3ed0"}},
|
||||
1},
|
||||
{<<"org_management_proto">>,
|
||||
{git,"https://github.com/valitydev/org-management-proto",
|
||||
{ref,"f433223706284000694e54e839fafb10db84e2b3"}},
|
||||
{ref,"03a269df4805fa604e8fd2d04241619a739e2ae3"}},
|
||||
1},
|
||||
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.1">>},1},
|
||||
{<<"party_client">>,
|
||||
{git,"https://github.com/valitydev/party-client-erlang.git",
|
||||
{ref,"4097004f78a526b7fe748719045dd428c905c2f0"}},
|
||||
{ref,"38c7782286877a63087c19de49f26ab175a37de7"}},
|
||||
0},
|
||||
{<<"payout_manager_proto">>,
|
||||
{git,"https://github.com/valitydev/payout-manager-proto.git",
|
||||
@ -101,12 +105,12 @@
|
||||
0},
|
||||
{<<"payproc_errors">>,
|
||||
{git,"https://github.com/valitydev/payproc-errors-erlang.git",
|
||||
{ref,"ebbfa3775c77d665f519d39ca9afa08c28d7733f"}},
|
||||
{ref,"a19e716966b7206e96fbd767661d6fd3bab3119d"}},
|
||||
0},
|
||||
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1},
|
||||
{<<"reporter_proto">>,
|
||||
{git,"https://github.com/valitydev/reporter-proto.git",
|
||||
{ref,"aafbfac4463711d43f8e8ed4da103967b95e1fb6"}},
|
||||
{ref,"d7d99959b35ab01acb8acedfc459779ddfbef4b4"}},
|
||||
0},
|
||||
{<<"scoper">>,
|
||||
{git,"https://github.com/valitydev/scoper.git",
|
||||
@ -131,11 +135,11 @@
|
||||
1},
|
||||
{<<"token_keeper_client">>,
|
||||
{git,"https://github.com/valitydev/token-keeper-client.git",
|
||||
{ref,"d3673e72c4c3480b4b8ddff85f1450a6ffd5dd34"}},
|
||||
{ref,"4ef858ac5a226789d17d0a29fe40c7e38ed94193"}},
|
||||
0},
|
||||
{<<"token_keeper_proto">>,
|
||||
{git,"https://github.com/valitydev/token-keeper-proto.git",
|
||||
{ref,"e52cb1ca0ea9ca5fbf3792ae211ae87bdc1d4cc5"}},
|
||||
{ref,"094b4f05a4e220df79911c25093feffea1cb868b"}},
|
||||
1},
|
||||
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2},
|
||||
{<<"woody">>,
|
||||
|
Loading…
Reference in New Issue
Block a user