Esempio n. 1
0
		public void MakePayment(List<InvoiceDataHolder> invoices, decimal amount, Usr usr, int promoterK, int actionUsrK, string cardFullName, string cardAddressStreet, string cardAddressArea, string cardAddressTown, string cardAddressCounty, int cardAddressCountryK, string cardAddressPostCode, string cardAddressCountry, string cardNumber, DateTime cardExpiryDate, string cardCV2, Transfer.FraudCheckEnum fraudCheckEnum, bool saveCard, Guid duplicateGuid, DateTime cardStartDate, string cardIssueNumber)
		{
			this.amount = Math.Round(amount, 2);
			if (this.amount <= 0)
			{
				throw new Exception("Cannot make a payment for " + this.amount.ToString("c") + ". It must be a positive amount.");
			}
			else
			{
				this.cardNumber = cardNumber.Trim().Replace(" ", "");
				this.cardAddressCountry = cardAddressCountry.Trim();
				this.fraudCheckEnum = fraudCheckEnum;
				this.invoiceDataHolders = invoices;
				this.transfer.Guid = Guid.NewGuid();
				this.transfer.DuplicateGuid = duplicateGuid;
				this.transfer.Amount = this.amount;
				this.transfer.Type = Transfer.TransferTypes.Payment;
				this.transfer.Method = Transfer.Methods.Card;
				this.transfer.Company = Model.Entities.Transfer.CompanyEnum.DH;
				this.transfer.CardAddress1 = cardAddressStreet.Trim();
				this.transfer.CardAddressArea = cardAddressArea;
				this.transfer.CardAddressCounty = cardAddressCounty;
				this.transfer.CardAddressTown = cardAddressTown;
				this.transfer.CardAddressCountryK = cardAddressCountryK;
				this.transfer.CardPostcode = cardAddressPostCode.Trim();
				this.transfer.CardName = cardFullName.Trim();
				this.transfer.CardCV2 = cardCV2.Trim();
				this.transfer.CardExpires = cardExpiryDate;
				this.transfer.CardStart = cardStartDate;
				if (cardIssueNumber.Length > 0)
					this.transfer.CardIssue = Convert.ToInt32(cardIssueNumber);
				this.transfer.SetUsrAndActionUsr(usr);
				this.transfer.DateTimeCreated = DateTime.Now;
				this.transfer.PromoterK = promoterK;
				this.usr = usr;

				this.transfer.StoreCardEndAndHashAndCardType(this.cardNumber);

				ValidateMinimumDetails();

				try
				{
					response = secVpnService.validateCardFull(
									userName,
									password,
									transfer.Guid.ToString(),				// DSI created SecPay Transaction Id "tran0001"
                                    ipAddress,								// Credit Card user IP address "127.0.0.1"
									cardFullName,							// User Name "Mr Cardholder"
									cardNumber,								// User card number "4444333322221111"
Esempio n. 2
0
		public void MakePayment(List<InvoiceDataHolder> invoices, decimal amount, Usr usr, int promoterK, int actionUsrK, string cardFullName, string cardAddressStreet, string cardAddressArea, string cardAddressTown, string cardAddressCounty, int cardAddressCountryK, string cardAddressPostCode, string cardAddressCountry, string cardNumber, DateTime cardExpiryDate, string cardCV2, Transfer.FraudCheckEnum fraudCheckEnum, bool saveCard, Guid duplicateGuid, DateTime cardStartDate, string cardIssueNumber)
		{
			this.amount = Math.Round(amount, 2);
			if (this.amount <= 0)
			{
				throw new Exception("Cannot make a payment for " + this.amount.ToString("c") + ". It must be a positive amount.");
			}
			else
			{
				this.cardNumber = cardNumber.Trim().Replace(" ", "");
				this.cardAddressCountry = cardAddressCountry.Trim();
				this.fraudCheckEnum = fraudCheckEnum;
				this.invoiceDataHolders = invoices;
				this.transfer.Guid = Guid.NewGuid();
				this.transfer.DuplicateGuid = duplicateGuid;
				this.transfer.Amount = this.amount;
				this.transfer.Type = Transfer.TransferTypes.Payment;
				this.transfer.Method = Transfer.Methods.Card;
				this.transfer.Company = Model.Entities.Transfer.CompanyEnum.DH;
				this.transfer.CardAddress1 = cardAddressStreet.Trim();
				this.transfer.CardAddressArea = cardAddressArea;
				this.transfer.CardAddressCounty = cardAddressCounty;
				this.transfer.CardAddressTown = cardAddressTown;
				this.transfer.CardAddressCountryK = cardAddressCountryK;
				this.transfer.CardPostcode = cardAddressPostCode.Trim();
				this.transfer.CardName = cardFullName.Trim();
				this.transfer.CardCV2 = cardCV2.Trim();
				this.transfer.CardExpires = cardExpiryDate;
				this.transfer.CardStart = cardStartDate;
				if (cardIssueNumber.Length > 0)
					this.transfer.CardIssue = Convert.ToInt32(cardIssueNumber);
				this.transfer.SetUsrAndActionUsr(usr);
				this.transfer.DateTimeCreated = DateTime.Now;
				this.transfer.PromoterK = promoterK;
				this.usr = usr;

				this.transfer.StoreCardEndAndHashAndCardType(this.cardNumber);

				ValidateMinimumDetails();

				try
				{
					response = secVpnService.validateCardFull(
									userName,
									password,
									transfer.Guid.ToString(),				// DSI created SecPay Transaction Id "tran0001"
                                    ipAddress,								// Credit Card user IP address "127.0.0.1"
									cardFullName,							// User Name "Mr Cardholder"
									cardNumber,								// User card number "4444333322221111"
									transfer.Amount.ToString(MONEY_FORMAT),	// because of deferred=true in Options, will only do shadow payment of just £1 while checking details validate
									DateToString(cardExpiryDate),			// expiry date "1208"
									cardIssueNumber,						// Card Issue Number
									DateToString(cardStartDate),			// start date "0102"
									OrderToString(),
									ShippingToString(),
									BillingToString(),
									OptionsToString());  					// options from Options() "name=Fred+Bloggs,company=Online+Shop+Ltd,addr_1=Dotcom+House,addr_2=London+Road,city=Townville,state=Countyshire,post_code=AB1+C23,tel=01234+567+890,fax=09876+543+210,email=somebody%40secpay.com,url=http%3A%2F%2Fwww.somedomain.com,test_status=true,dups=false,card_type=Visa,mand_cv2avs=[false|true,deferred=true]"

					// Log SecPay Response to transfer and save transfer details
					ResponseParser(this.PerformSecurityCheck);

					if (this.transfer.Status.Equals(Transfer.StatusEnum.Success))
					{
						this.transfer.CardSaved = saveCard;

						// Make sure there is only one saved transfer for each card
						if (saveCard == true)
						{
							TransferSet savedTransferSet = new TransferSet(new Query(new And(new Q(Transfer.Columns.CardNumberHash, this.transfer.CardNumberHash),
																							 new Q(Transfer.Columns.CardSaved, true))));
							foreach (Transfer savedTransfer in savedTransferSet)
							{
								savedTransfer.CardSaved = false;
								savedTransfer.Update();
							}
						}

						if (this.PerformSecurityCheck)
						{
							response = secVpnService.releaseCardFull(
								userName,
								password,
								transfer.Guid.ToString(),
								transfer.Amount.ToString(MONEY_FORMAT),
								password,
								transfer.Guid.ToString());

							// run this through again with the new response
							ResponseParser();
						}
					}

					ProcessPaymentResults();
				}
				catch (Exception ex)
				{
					EmailSecPayException(ex);

					throw new Exception("SecPay Payment failed. See transfer #" + this.transfer.K.ToString() + " for details");
				}
			}
		}
Esempio n. 3
0
		public void MakePaymentUsingSavedTransferDetails(List<InvoiceDataHolder> invoices, decimal amount, Usr usr, Transfer previouslySavedTransfer, Transfer.FraudCheckEnum fraudCheckEnum, Guid duplicateGuid)
		{
			if (previouslySavedTransfer.UsrK != usr.K)
				throw new Exception("User doesn't match!");

			if (!previouslySavedTransfer.CardSaved)
				throw new Exception("Card not saved!");

			this.amount = Math.Round(amount, 2);
			if (this.amount <= 0)
			{
				throw new Exception("Cannot make a payment for " + this.amount.ToString("c") + ". It must be a positive amount.");
			}
			else
			{
				this.invoiceDataHolders = invoices;
				this.fraudCheckEnum = fraudCheckEnum;
                
                //this.SelectDSIBankAccount(invoices);
				
                this.transfer = previouslySavedTransfer.CopyThisTransfer();
				// Previously saved transfer could be using different promoter account
				if (invoices.Count > 0)
					this.transfer.PromoterK = invoices[0].PromoterK;
				this.transfer.DuplicateGuid = duplicateGuid;

				this.transfer.SetUsrAndActionUsr(usr);
				this.transfer.CardSavedTransferK = previouslySavedTransfer.K;

				if (this.transfer.PromoterK == 0 && invoices.Count > 0)
					this.transfer.PromoterK = invoices[0].PromoterK;

				this.transfer.Amount = this.amount;

				this.transfer.Type = Transfer.TransferTypes.Payment;
				this.transfer.DateTimeCreated = DateTime.Now;
				try
				{
					response = secVpnService.repeatCardFullAddr(
									userName,
									password,
									previouslySavedTransfer.Guid.ToString(),// DSI created SecPay Transaction Id "tran0001"
									transfer.Amount.ToString(MONEY_FORMAT),	// amount "50.00"
                                    password,
									transfer.Guid.ToString(),				// DSI created SecPay Transaction Id "tran0001"
									DateToString(transfer.CardExpires),		// User card number "4444333322221111"
									OrderToString(),
									BillingToString(),
									ShippingToString(),
									OptionsToString());  					// options from Options() "name=Fred+Bloggs,company=Online+Shop+Ltd,addr_1=Dotcom+House,addr_2=London+Road,city=Townville,state=Countyshire,post_code=AB1+C23,tel=01234+567+890,fax=09876+543+210,email=somebody%40secpay.com,url=http%3A%2F%2Fwww.somedomain.com,test_status=true,dups=false,card_type=Visa,mand_cv2avs=[false|true,deferred=true]"

					// Log SecPay Response to transfer and save transfer details
					ResponseParser(this.PerformSecurityCheck);

					if (this.transfer.Status == Transfer.StatusEnum.Success && this.PerformSecurityCheck)
					{
						response = secVpnService.releaseCardFull(
							userName,
							password,
							transfer.Guid.ToString(),
							transfer.Amount.ToString(MONEY_FORMAT),
							password,
							transfer.Guid.ToString());

						// run this through again with the new response
						ResponseParser();
					}

					ProcessPaymentResults();
				}
				catch (Exception ex)
				{
					EmailSecPayException(ex);

					throw new Exception("SecPay Refund failed. See transfer #" + this.transfer.K + " for details");
				}
			}
		}