From b92b8ba9a3748f2e8848ce15c0bed81e8a2d6b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC?= Date: Tue, 5 Mar 2019 17:29:17 +0300 Subject: [PATCH] CAPI-339: Ignore empty cvv in google pay plain card (#322) --- apps/capi/src/capi_handler_tokens.erl | 4 +- .../capi_invoice_access_token_tests_SUITE.erl | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/apps/capi/src/capi_handler_tokens.erl b/apps/capi/src/capi_handler_tokens.erl index f78d010..011435e 100644 --- a/apps/capi/src/capi_handler_tokens.erl +++ b/apps/capi/src/capi_handler_tokens.erl @@ -250,7 +250,9 @@ process_put_card_data_result( {bank_card, BankCard#domain_BankCard{ payment_system = PaymentSystem, masked_pan = capi_utils:define(Last4, BankCard#domain_BankCard.masked_pan), - token_provider = get_payment_token_provider(PaymentDetails, PaymentData) + token_provider = get_payment_token_provider(PaymentDetails, PaymentData), + %% Не учитываем наличие cvv для токенизированных карт, даже если проводим их как обычные. + is_cvv_empty = undefined }}, SessionID }. diff --git a/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl b/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl index ddd07c9..c7bae78 100644 --- a/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl +++ b/apps/capi/test/capi_invoice_access_token_tests_SUITE.erl @@ -36,6 +36,7 @@ get_invoice_payment_methods_ok_test/1, create_payment_ok_test/1, create_payment_with_empty_cvv_ok_test/1, + create_payment_with_googlepay_plain_ok_test/1, get_payments_ok_test/1, get_payment_by_id_ok_test/1, get_client_payment_status_test/1, @@ -81,6 +82,7 @@ invoice_access_token_tests() -> get_invoice_payment_methods_ok_test, create_payment_ok_test, create_payment_with_empty_cvv_ok_test, + create_payment_with_googlepay_plain_ok_test, get_payments_ok_test, get_client_payment_status_test, get_payment_by_id_ok_test, @@ -589,6 +591,74 @@ create_payment_with_empty_cvv_ok_test(Config) -> }, {ok, _} = capi_client_payments:create_payment(?config(context, Config), Req2, ?STRING). +-spec create_payment_with_googlepay_plain_ok_test(_) -> + _. +create_payment_with_googlepay_plain_ok_test(Config) -> + capi_ct_helper:mock_services([ + {payment_tool_provider_google_pay, + fun('Unwrap', _) -> + {ok, ?UNWRAPPED_PAYMENT_TOOL( + ?GOOGLE_PAY_DETAILS, + {card, #paytoolprv_Card{ + pan = <<"1234567890123456">>, + exp_date = #paytoolprv_ExpDate{month = 10, year = 2018} + }} + )} + end + }, + {cds_storage, + fun('PutCardData', _) -> {ok, ?PUT_CARD_DATA_RESULT} end + }, + {invoicing,fun + ('StartPayment', [_UserInfo, _InvoiceID, + #payproc_InvoicePaymentParams{ + payer = {payment_resource, #payproc_PaymentResourcePayerParams{ + resource = #domain_DisposablePaymentResource{ + payment_tool = { + bank_card, + #domain_BankCard{ + is_cvv_empty = undefined, + token_provider = undefined, + payment_system = mastercard + } + } + } + }} + } + ]) -> {ok, ?PAYPROC_PAYMENT} + end}, + {binbase, + fun('Lookup', _) -> {ok, ?BINBASE_LOOKUP_RESULT} end + } + ], Config), + ClientInfo = #{<<"fingerprint">> => <<"test fingerprint">>}, + {ok, #{ + <<"paymentToolDetails">> := Details = #{<<"paymentSystem">> := <<"mastercard">>}, + <<"paymentToolToken">> := Token, + <<"paymentSession">> := Session + } + } = capi_client_tokens:create_payment_resource(?config(context, Config), #{ + <<"paymentTool">> => #{ + <<"paymentToolType">> => <<"TokenizedCardData">>, + <<"provider">> => <<"GooglePay">>, + <<"gatewayMerchantID">> => <<"SomeMerchantID">>, + <<"paymentToken">> => #{} + }, + <<"clientInfo">> => ClientInfo + }), + false = maps:is_key(<<"tokenProvider">>, Details), + Req2 = #{ + <<"flow">> => #{<<"type">> => <<"PaymentFlowInstant">>}, + <<"payer">> => #{ + <<"payerType">> => <<"PaymentResourcePayer">>, + <<"paymentSession">> => Session, + <<"paymentToolToken">> => Token, + <<"contactInfo">> => #{ + <<"email">> => <<"bla@bla.ru">> + } + } + }, + {ok, _} = capi_client_payments:create_payment(?config(context, Config), Req2, ?STRING). -spec get_payments_ok_test(config()) -> _.