FF-102: FIX - payment system convert (#116)

* fixed

* refixed

* micro

* removed comments
This commit is contained in:
Артем 2019-08-23 17:25:18 +03:00 committed by GitHub
parent f849b9d4b0
commit fcca901e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -98,8 +98,19 @@ decode_msgpack({arr, V}) when is_list(V) -> [decode_msgpack(ListItem) || List
decode_msgpack({obj, V}) when is_map(V) ->
maps:fold(fun(Key, Value, Map) -> Map#{decode_msgpack(Key) => decode_msgpack(Value)} end, #{}, V).
decode_payment_system(PaymentSystem) ->
binary_to_existing_atom(PaymentSystem, utf8).
decode_payment_system(<<"VISA">>) -> visa;
decode_payment_system(<<"VISA/DANKORT">>) -> visa;
decode_payment_system(<<"MASTERCARD">>) -> mastercard;
decode_payment_system(<<"MAESTRO">>) -> maestro;
decode_payment_system(<<"DANKORT">>) -> dankort;
decode_payment_system(<<"AMERICAN EXPRESS">>) -> amex;
decode_payment_system(<<"DINERS CLUB INTERNATIONAL">>) -> dinersclub;
decode_payment_system(<<"DISCOVER">>) -> discover;
decode_payment_system(<<"UNIONPAY">>) -> unionpay;
decode_payment_system(<<"JCB">>) -> jcb;
decode_payment_system(<<"NSPK MIR">>) -> nspkmir;
decode_payment_system(_) ->
erlang:error({decode_payment_system, invalid_payment_system}).
decode_card_type(undefined) ->
undefined;
@ -113,7 +124,7 @@ decode_residence(Residence) when is_binary(Residence) ->
list_to_existing_atom(string:to_lower(binary_to_list(Residence)))
catch
error:badarg ->
throw({decode_residence, invalid_residence})
erlang:error({decode_residence, invalid_residence})
end.
call_binbase(Function, Args) ->

View File

@ -15,7 +15,7 @@
handle_function('GetByCardToken', [_Token], _Context, _Opts) ->
{ok, #binbase_ResponseData{
bin_data = #binbase_BinData{
payment_system = <<"visa">>,
payment_system = <<"VISA">>,
bank_name = <<"sber">>,
iso_country_code = <<"RUS">>,
bin_data_id = {i, 123}
@ -25,7 +25,7 @@ handle_function('GetByCardToken', [_Token], _Context, _Opts) ->
handle_function('GetByBinDataId', [ID], _Context, _Opts) ->
{ok, #binbase_ResponseData{
bin_data = #binbase_BinData{
payment_system = <<"visa">>,
payment_system = <<"VISA">>,
bank_name = <<"sber">>,
iso_country_code = <<"RUS">>,
bin_data_id = ID