public async Task <PaymentManagerReversalPaymentResponse> ReversalPaymentAsync(string bankType, ReversalRequest request, CancellationToken cancellation) { var result = new PaymentManagerReversalPaymentResponse(); Logger.LogCategory("ReversalPaymentAsync"); Logger.Log(new { Request = request }); var _provider = _providerFactory.GetProvider(bankType); if (_provider != null) { var providerResponse = await _provider.ReversalAsync(request); result = await SaveReversalPaymentAsync(request, providerResponse, cancellation); } else { result.Status = "NoPaymentProviderFoundForReversal"; Logger.Log("No PaymentProvider found for Reversal"); } Logger.Log($"Result = {result.Status}"); return(result); }
private async Task <PaymentManagerReversalPaymentResponse> SaveReversalPaymentAsync(ReversalRequest request, PaymentProviderReversalPaymentResponse providerResponse, CancellationToken cancellation) { var result = new PaymentManagerReversalPaymentResponse(); result.Request = request; var dbOk = false; Logger.LogCategory("SaveReversalPaymentAsync"); if (providerResponse.Succeeded || !Config.SaveOnlySuccessfulOperations) { Logger.Log("Start saving in the database"); var args = new { Result = CommandParameter.Output(SqlDbType.VarChar, 50), PaymentCode = request.PaymentCode, BankType = providerResponse.ProviderType, StepStatus = SafeClrConvert.ToString(providerResponse.Status), StepDate = providerResponse.Date, StepSucceeded = providerResponse.Succeeded, @StepData = "" }; var cmd = _db.GetCommand("usp1_Payment_save_reversal_step"); result.DbResult = await _db.ExecuteNonQueryAsync(cmd, args, cancellation); if (result.DbResult.Success) { result.Status = args.Result.Value.ToString(); Logger.Log("DbStatus = " + result.Status); dbOk = result.Status == "Success"; if (!dbOk) { result.Status = "SaveError"; } } else { Logger.Log("Failed: " + result.DbResult.Exception.ToString(",")); result.Failed(result.DbResult.Exception); } } else { dbOk = true; } if (providerResponse.Succeeded && dbOk) { result.Succeeded(); } return(result); }
public PaymentManagerReversalPaymentResponse ReversalPayment(string bankType, ReversalRequest request) { var result = new PaymentManagerReversalPaymentResponse(); Logger.LogCategory("ReversalPayment"); Logger.Log(new { Request = request }); var _provider = _providerFactory.GetProvider(bankType); if (_provider != null) { var providerResponse = _provider.ReversalPayment(request); result = SaveReversalPayment(request, providerResponse); } else { result.Status = "NoPaymentProviderFoundForReversal"; Logger.Log("No PaymentProvider found for Reversal"); } Logger.Log($"Result = {result.Status}"); return(result); }