forked from 2600hz/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAZOO-6064: [master] ask bookkeepers for early running recurring char…
…ges (2600hz#5585) * KAZOO-6064: ask bookkeepers for early running recurring charges * make apis and fix typo * ZOO-6064: is last/current month collected? * KAZOO-6064: better time reporting in log * KAZOO-6064: how they did not formatted? * KAZOO-6064: add due-timestamp to recurring req * fix date, specs and publishing message
- Loading branch information
1 parent
73453b1
commit c42aaf5
Showing
8 changed files
with
753 additions
and
203 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
applications/braintree/src/braintree_collect_recurring_req.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
%%%----------------------------------------------------------------------------- | ||
%%% @copyright (C) 2013-2019, 2600Hz | ||
%%% @doc | ||
%%% @end | ||
%%%----------------------------------------------------------------------------- | ||
-module(braintree_collect_recurring_req). | ||
|
||
-export([handle_req/2]). | ||
|
||
-include("braintree.hrl"). | ||
|
||
%%------------------------------------------------------------------------------ | ||
%% @doc | ||
%% @end | ||
%%------------------------------------------------------------------------------ | ||
-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. | ||
handle_req(JObj, _Props) -> | ||
'true' = kapi_bookkeepers:collect_recurring_req_v(JObj), | ||
Response = kz_json:from_list( | ||
[{<<"Account-ID">>, kz_json:get_ne_binary_value(<<"Account-ID">>, JObj)} | ||
,{<<"Bookkeeper-ID">>, kz_json:get_ne_binary_value(<<"Bookkeeper-ID">>, JObj)} | ||
,{<<"Bookkeeper-Type">>, kz_json:get_ne_binary_value(<<"Bookkeeper-Type">>, JObj)} | ||
,{<<"Message">>, <<"Braintree performs recurring charges automatically">>} | ||
,{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} | ||
,{<<"Status">>, kz_services_recurring:status_good()} | ||
] ++ kz_api:default_headers(?APP_NAME, ?APP_VERSION) | ||
), | ||
RespQ = kz_json:get_ne_binary_value(<<"Server-ID">>, JObj), | ||
|
||
PublishFun = fun(P) -> kapi_bookkeepers:publish_collect_recurring_resp(RespQ, P) end, | ||
|
||
case kz_json:get_ne_binary_value(<<"Bookkeeper-Type">>, JObj) =:= ?APP_NAME of | ||
'false' -> | ||
lager:debug("skipping collect recurring for another bookkeeper"); | ||
'true' -> | ||
kz_amqp_worker:cast(Response, PublishFun) | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ions/crossbar/priv/couchdb/schemas/kapi.bookkeepers.collect_recurring_req_definition.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"_id": "kapi.bookkeepers.collect_recurring_req_definition", | ||
"description": "AMQP API for bookkeepers.collect_recurring_req_definition", | ||
"properties": { | ||
"Account-ID": { | ||
"type": "string" | ||
}, | ||
"Audit-Log": { | ||
"type": "string" | ||
}, | ||
"Bookkeeper-ID": { | ||
"type": "string" | ||
}, | ||
"Bookkeeper-Type": { | ||
"type": "string" | ||
}, | ||
"Due-Timestamp": { | ||
"type": "string" | ||
}, | ||
"Event-Category": { | ||
"enum": [ | ||
"bookkeepers" | ||
], | ||
"type": "string" | ||
}, | ||
"Event-Name": { | ||
"enum": [ | ||
"collect_recurring_req" | ||
], | ||
"type": "string" | ||
}, | ||
"Vendor-ID": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"Account-ID", | ||
"Bookkeeper-ID", | ||
"Bookkeeper-Type", | ||
"Vendor-ID" | ||
], | ||
"type": "object" | ||
} |
53 changes: 53 additions & 0 deletions
53
...ons/crossbar/priv/couchdb/schemas/kapi.bookkeepers.collect_recurring_resp_definition.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"_id": "kapi.bookkeepers.collect_recurring_resp_definition", | ||
"description": "AMQP API for bookkeepers.collect_recurring_resp_definition", | ||
"properties": { | ||
"Account-ID": { | ||
"type": "string" | ||
}, | ||
"Bookkeeper-ID": { | ||
"type": "string" | ||
}, | ||
"Bookkeeper-Type": { | ||
"type": "string" | ||
}, | ||
"Details": { | ||
"type": "string" | ||
}, | ||
"Event-Category": { | ||
"enum": [ | ||
"bookkeepers" | ||
], | ||
"type": "string" | ||
}, | ||
"Event-Name": { | ||
"enum": [ | ||
"collect_recurring_resp" | ||
], | ||
"type": "string" | ||
}, | ||
"Message": { | ||
"type": "string" | ||
}, | ||
"Reason": { | ||
"type": "string" | ||
}, | ||
"Status": { | ||
"type": "string" | ||
}, | ||
"Transaction-DB": { | ||
"type": "string" | ||
}, | ||
"Transaction-ID": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"Account-ID", | ||
"Bookkeeper-ID", | ||
"Bookkeeper-Type", | ||
"Status" | ||
], | ||
"type": "object" | ||
} |
Oops, something went wrong.