public Donation CreateDonation(Donation donation) { using (var db = new DataAccess()) { db.CreateStoredProcCommand("dbo.CreateDonation"); db.AddInputParameter("@DonationProviderId", donation.DonationProviderId); db.AddInputParameter("@UserId", donation.UserId); db.AddInputParameter("@ExternalId", donation.ExternalId); db.AddInputParameter("@ExternalStatus", donation.ExternalStatus); db.AddInputParameter("@IsCompleted", donation.IsCompleted); db.AddInputParameter("@CountryId", donation.CountryId); db.AddInputParameter("@StateId", donation.StateId); db.AddInputParameter("@CityId", donation.CityId); db.AddInputParameter("@Amount", donation.Amount); db.AddInputParameter("@Currency", donation.Currency); db.AddInputParameter("@UserMessage", donation.UserMessage); db.AddInputParameter("@ProviderData", donation.ProviderXml); db.AddInputParameter("@DonationSubscriptionId", donation.DonationSubscriptionId); db.AddInputParameter("@TransactionType", donation.TransactionType); db.AddOutputParameter("@DonationId", DbType.Int32); try { db.ExecuteNonQuery(); donation.DonationId = db.GetParameterValue<int>("@DonationId"); } catch (Exception ex) { Log.Error("Error while creating donation.", ex); throw; } } return donation; }
public void UpdateUserMessage(Donation donation) { using (var db = new DataAccess()) { db.CreateStoredProcCommand("dbo.UpdateUserMessage"); db.AddInputParameter("@DonationId", DbType.Int32, donation.DonationId); db.AddInputParameter("@UserId", DbType.Int32, donation.UserId); db.AddInputParameter("@UserMessage", DbType.String, donation.UserMessage); try { db.ExecuteNonQuery(); } catch (Exception ex) { Log.Error("Error while updating user message.", ex); throw; } } }
public Donation RefundDonation(string externalId, string externalStatus) { using (var db = new DataAccess()) { db.CreateStoredProcCommand("dbo.RefundDonation"); db.AddInputParameter("@ExternalId", externalId); db.AddInputParameter("@ExternalStatus", externalStatus); try { var donation = new Donation(); db.ReadInto(donation); return donation; } catch (Exception ex) { Log.Error("Error while refunding donation.", ex); throw; } } }
private bool HandleVerified(PayPalVariables variables, Donation donation) { Log.InfoFormat("{0} - {1}, {2} - OK", variables.txn_id, variables.mc_gross, variables.mc_currency); if (variables.payment_status.Equals("completed", StringComparison.OrdinalIgnoreCase)) { donation.IsCompleted = true; donation.ExternalStatus = variables.payment_status; try { GeoLocation location; if (_geocodeService.TryGetGeoLocation(variables, out location)) { donation.CityId = location.City.CityId; donation.StateId = location.State.StateId; donation.CountryId = location.Country.CountryId; } var custom = JsonConvert.DeserializeObject<PayPalCustom>(variables.custom); _donationRepository.CompleteTransaction(donation); if (location != null && location.Address != null) { _accountRepository.UpdateUserProfileAddress(custom.UserId, location.Address); } //var contactInfo = _accountRepository.GetUserContactInfo(custom.UserId); //if (contactInfo != null) //{ // _emailService.SendEmail(variables.ReplyEmail, contactInfo.Email, variables.EmailSubject, variables.EmailMessage); //} return true; } catch (Exception ex) { Log.Error("Manual investigation required.", ex); } } return false; }
public void CompleteTransaction(Donation donation) { using (var db = new DataAccess()) { db.CreateStoredProcCommand("dbo.CompleteDonation"); db.AddInputParameter("@ExternalId", DbType.String, donation.ExternalId); db.AddInputParameter("@ExternalStatus", DbType.String, donation.ExternalStatus); db.AddInputParameter("@IsCompleted", DbType.Boolean, donation.IsCompleted); db.AddInputParameter("@CountryId", DbType.Int32, donation.CountryId); db.AddInputParameter("@StateId", DbType.Int32, donation.StateId); db.AddInputParameter("@CityId", DbType.Int32, donation.CityId); try { db.ExecuteNonQuery(); } catch (Exception ex) { Log.Error("Error while verifying donation.", ex); throw; } } }