public abstract void OnSucesiveTransactionReceived(RedsysSuccessiveTransaction sucesiveTransaction);
public static void ProcessRecurringTransactions(IRedsysService lcs,DateTime now) { Expression<Func<RedsysRecurringTransaction, bool>> rTxShouldBeProcessed = rTx => rTx.Amount > 0 && rTx.Order != null && now >= rTx.StartDate && now < rTx.EndDate && !rTx.SucessiveTransactions.Any(sTx => sTx.Date > now.AddDays(-rTx.Frequency) && sTx.Date < now); IEnumerable<RedsysRecurringTransaction> recurrentTransactions = lcs.GetRecurrentTransactions() .AsQueryable() .Where(rTxShouldBeProcessed) .ToArray(); foreach (RedsysRecurringTransaction rtx in recurrentTransactions) { string signature = SignatureHelper.GetSignature(rtx.Amount, rtx.Order, lcs.MerchantCode, 978, RedsysTransactionType.SuccessiveTransaction, lcs.NotificationUrl, lcs.Secret); /*RestClient restClient = new RestClient(lcs.TestEnviroment ? "https://sis-t.redsys.es:25443/sis" : "https://sis.redsys.es/sis"); RestRequest restRequest = new RestRequest("/realizarPago"); restRequest.AddParameter("Ds_Merchant_Amount", (int) Math.Round(rtx.Amount*100, 2)); restRequest.AddParameter("Ds_Merchant_TransactionType", 6); restRequest.AddParameter("Ds_Merchant_MerchantCode", lcs.MerchantCode); restRequest.AddParameter("Ds_Merchant_Terminal", lcs.Terminal); restRequest.AddParameter("Ds_Merchant_Order", rtx.Order); restRequest.AddParameter("Ds_Merchant_Currency", 978); restRequest.AddParameter("Ds_Merchant_MerchantSignature", signature); IRestResponse response = restClient.Post(restRequest); if (response.Content == "Whyyt")*/ { RedsysSuccessiveTransaction stx = new RedsysSuccessiveTransaction(); rtx.SucessiveTransactions.Add(stx); stx.RecurrentTransaction = rtx; stx.Date = now; lcs.OnSucesiveTransactionReceived(stx); } } }