fixed mntx op provisioning
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (s *Service) submitCardPayout(ctx context.Context, payment *model.Payment) error {
|
||||
func (s *Service) submitCardPayout(ctx context.Context, operationRef string, payment *model.Payment) error {
|
||||
if payment == nil {
|
||||
return merrors.InvalidArgument("payment is required")
|
||||
}
|
||||
@@ -133,6 +133,8 @@ func (s *Service) submitCardPayout(ctx context.Context, payment *model.Payment)
|
||||
CardExpMonth: card.ExpMonth,
|
||||
CardHolder: holder,
|
||||
Metadata: meta,
|
||||
IntentRef: payment.Intent.Ref,
|
||||
OperationRef: operationRef,
|
||||
}
|
||||
resp, err := s.deps.mntx.client.CreateCardPayout(ctx, req)
|
||||
if err != nil {
|
||||
@@ -173,7 +175,8 @@ func (s *Service) submitCardPayout(ctx context.Context, payment *model.Payment)
|
||||
updateExecutionPlanTotalNetworkFee(plan)
|
||||
}
|
||||
|
||||
s.logger.Info("card payout submitted", zap.String("payment_ref", payment.PaymentRef), zap.String("payout_id", exec.CardPayoutRef))
|
||||
s.logger.Info("card payout submitted", zap.String("payment_ref", payment.PaymentRef),
|
||||
zap.String("payout_id", exec.CardPayoutRef), zap.String("operation_ref", state.OperationRef))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestSubmitCardPayout_UsesSettlementAmount(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if err := svc.submitCardPayout(ctx, payment); err != nil {
|
||||
if err := svc.submitCardPayout(ctx, "op-ref", payment); err != nil {
|
||||
t.Fatalf("submitCardPayout error: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ type paymentEventHandler struct {
|
||||
repo storage.Repository
|
||||
ensureRepo func(ctx context.Context) error
|
||||
logger mlogger.Logger
|
||||
submitCardPayout func(ctx context.Context, payment *model.Payment) error
|
||||
submitCardPayout func(ctx context.Context, operationRef string, payment *model.Payment) error
|
||||
resumePlan func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error
|
||||
releaseHold func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error
|
||||
}
|
||||
|
||||
func newPaymentEventHandler(repo storage.Repository, ensure func(ctx context.Context) error, logger mlogger.Logger, submitCardPayout func(ctx context.Context, payment *model.Payment) error, resumePlan func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error, releaseHold func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error) *paymentEventHandler {
|
||||
func newPaymentEventHandler(repo storage.Repository, ensure func(ctx context.Context) error, logger mlogger.Logger, submitCardPayout func(ctx context.Context, operationRef string, payment *model.Payment) error, resumePlan func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error, releaseHold func(ctx context.Context, store storage.PaymentsStore, payment *model.Payment) error) *paymentEventHandler {
|
||||
return &paymentEventHandler{
|
||||
repo: repo,
|
||||
ensureRepo: ensure,
|
||||
@@ -140,7 +140,7 @@ func (h *paymentEventHandler) processTransferUpdate(ctx context.Context, req *or
|
||||
payment.State = model.PaymentStateFundsReserved
|
||||
if h.submitCardPayout == nil {
|
||||
h.logger.Warn("card payout execution skipped", zap.String("payment_ref", payment.PaymentRef))
|
||||
} else if err := h.submitCardPayout(ctx, payment); err != nil {
|
||||
} else if err := h.submitCardPayout(ctx, transfer.GetOperationRef(), payment); err != nil {
|
||||
payment.State = model.PaymentStateFailed
|
||||
payment.FailureCode = model.PaymentFailureCodePolicy
|
||||
payment.FailureReason = strings.TrimSpace(err.Error())
|
||||
|
||||
@@ -269,7 +269,7 @@ func TestProcessTransferUpdateHandler_CardFundingWaitsForSources(t *testing.T) {
|
||||
}
|
||||
|
||||
payoutCalls := 0
|
||||
submit := func(ctx context.Context, payment *model.Payment) error {
|
||||
submit := func(ctx context.Context, operationRef string, payment *model.Payment) error {
|
||||
payoutCalls++
|
||||
if payment.Execution == nil {
|
||||
payment.Execution = &model.ExecutionRefs{}
|
||||
@@ -279,6 +279,7 @@ func TestProcessTransferUpdateHandler_CardFundingWaitsForSources(t *testing.T) {
|
||||
step := ensureExecutionStep(plan, stepCodeCardPayout)
|
||||
setExecutionStepRole(step, executionStepRoleConsumer)
|
||||
step.TransferRef = "payout-1"
|
||||
step.OperationRef = operationRef
|
||||
setExecutionStepStatus(step, model.OperationStateWaiting)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user