mirror of
https://github.com/valitydev/capi-v2.git
synced 2024-11-06 10:05:21 +00:00
CAPI-366: Offset refund ids (#414)
This commit is contained in:
parent
be66e0eae7
commit
d9cafafef1
@ -6,6 +6,7 @@
|
||||
-type woody_context() :: woody_context:ctx().
|
||||
-type context_data() :: #{binary() => term()}.
|
||||
-type bender_context() :: #{binary() => term()}.
|
||||
-type sequence_params() :: #{minimum => integer()}.
|
||||
-export_type([
|
||||
bender_context/0,
|
||||
context_data/0
|
||||
@ -15,6 +16,7 @@
|
||||
-export([gen_by_snowflake/3]).
|
||||
-export([gen_by_sequence/4]).
|
||||
-export([gen_by_sequence/5]).
|
||||
-export([gen_by_sequence/6]).
|
||||
-export([gen_by_constant/4]).
|
||||
-export([gen_by_constant/5]).
|
||||
-export([get_idempotent_key/3]).
|
||||
@ -49,8 +51,17 @@ gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyContext) ->
|
||||
{error, {external_id_conflict, binary()}}.
|
||||
|
||||
gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyContext, CtxData) ->
|
||||
gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyContext, CtxData, #{}).
|
||||
|
||||
-spec gen_by_sequence(binary(), binary(), integer(), woody_context(), context_data(), sequence_params()) ->
|
||||
{ok, binary()} |
|
||||
{error, {external_id_conflict, binary()}}.
|
||||
|
||||
gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyContext, CtxData, Params) ->
|
||||
Minimum = maps:get(minimum, Params, undefined),
|
||||
Sequence = {sequence, #bender_SequenceSchema{
|
||||
sequence_id = SequenceID
|
||||
sequence_id = SequenceID,
|
||||
minimum = Minimum
|
||||
}},
|
||||
generate_id(IdempotentKey, Sequence, Hash, WoodyContext, CtxData).
|
||||
|
||||
|
@ -441,7 +441,7 @@ create_refund(InvoiceID, PaymentID, RefundParams, #{woody_context := WoodyCtx} =
|
||||
SequenceID = create_sequence_id([InvoiceID, PaymentID], BenderPrefix),
|
||||
CtxData = #{<<"invoice_id">> => InvoiceID, <<"payment_id">> => PaymentID},
|
||||
Hash = erlang:phash2(RefundParams),
|
||||
case capi_bender:gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyCtx, CtxData) of
|
||||
case capi_bender:gen_by_sequence(IdempotentKey, SequenceID, Hash, WoodyCtx, CtxData, #{minimum => 100}) of
|
||||
{ok, ID} ->
|
||||
Params = #payproc_InvoicePaymentRefundParams{
|
||||
id = ID,
|
||||
|
Loading…
Reference in New Issue
Block a user