/// <summary> /// Sets up the CustomerAccount to pay for services on a recurring basis /// using a credit card. /// </summary> /// <param name="strCreditCardNumber"></param> /// <param name="strNameOnCard"></param> /// <param name="strExpirationDate"></param> public void ActivateRecurringUsingCreditCard( [RequiredItem()][CreditCardNumber()] string strCreditCardNumber, [RequiredItem()] string strNameOnCard, [RequiredItem()][ValidCCDate()] string strExpirationDate) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.RecurringCredit, this.m_can.AccountNumber16); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCreditCardNumber, strNameOnCard, strExpirationDate); validator.Validate(); // convert the accountNumber. CreditCardNumber creditCardNumber = (CreditCardNumber)TypeDescriptor.GetConverter( typeof(CreditCardNumber)).ConvertFrom(strCreditCardNumber); // Credit card validation logEntry.PaymentType = creditCardNumber.PaymentType; DateTime dttmExpirationDate = ValidCCDateAttribute.ToDate(strExpirationDate); // set the siteId information logEntry.SiteId = SiteId; // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); int intStatementCode = 0; try{ intStatementCode = int.Parse(m_can.StatementCode); }catch { /*don't care*/ } // check nsf status checkNSFStatus(true); // assure that the length of the customer name does NOT exceed 32 characters! if (strNameOnCard.Length >= 32) { strNameOnCard = strNameOnCard.Substring(0, 31); } // Build input elements Request.INL00073 inl73 = new INL00073Helper(dal.GetMopByUserPaymentType( UserName, (int)creditCardNumber.PaymentType), creditCardNumber.AccountNumber, strNameOnCard, dttmExpirationDate, intStatementCode, false); Request.MAC00027 mac27 = new Mac00027Helper(SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl73); // invoke and get the response object. this.Invoke((Request.MAC00027)mac27); } catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } catch (Exception exc) { logEntry.SetError(exc.Message); throw; } } }
} // PayUsingElectronicCheck() /// <summary> /// This method provides functionality to pay a statement using /// a credit card as the method of payment. /// </summary> /// <param name="strCreditCardNumber"> /// Thie customer credit card number used to pay the bill. /// </param> /// <param name="strNameOnCard"> /// The name on the customer credit card. /// </param> /// <param name="strExpirationDate"> /// The expiration date of the customer credit card. /// </param> /// <param name="dblAmount"> /// The amount to be paid to the customer service account. /// </param> /// <returns> /// A payment receipt instance is returned with the results from /// the requested payment. /// </returns> public PaymentReceipt PayUsingCreditCard( [RequiredItem()][CreditCardNumberAttribute()] string strCreditCardNumber, [RequiredItem()] string strNameOnCard, [RequiredItem()][ValidCCDate()] string strExpirationDate, [RequiredItem()][DoubleRange(0.00, 9999999.99)] double dblAmount) { BillingLogEntry logEntry = new BillingLogEntry( eBillingActivityType.PayCredit, this.m_can.AccountNumber16, dblAmount); using (Log log = CreateLog(logEntry)) { try { MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), strCreditCardNumber, strNameOnCard, strExpirationDate, dblAmount); validator.Validate(); // convert the accountNumber. CreditCardNumber creditCardNumber = (CreditCardNumber)TypeDescriptor.GetConverter( typeof(CreditCardNumber)).ConvertFrom(strCreditCardNumber); // Credit card validation logEntry.PaymentType = creditCardNumber.PaymentType; DateTime dttmExpirationDate = ValidCCDateAttribute.ToDate(strExpirationDate); // set the siteId information logEntry.SiteId = SiteId; checkNSFStatus(true); // Create a DAL to transalate Mop codes DalMethodOfPayment dal = new DalMethodOfPayment(); DalPaymentReceipt dalPaymentReceipt = new DalPaymentReceipt(); string paymentReceiptType = dalPaymentReceipt.GetPaymentReceiptType(_userId); paymentReceiptType = paymentReceiptType == string.Empty?CmConstant.kstrDefaultReceiptType:paymentReceiptType; PaymentReceipt rcpt = new PaymentReceipt(); // assure that the length of the customer name does NOT exceed 32 characters! if (strNameOnCard.Length >= 32) { strNameOnCard = strNameOnCard.Substring(0, 31); } // Build input elements Request.INL00072 inl72 = new INL00072Helper( dblAmount, dblAmount, CmConstant.kstrNegative, creditCardNumber.AccountNumber, strNameOnCard, dttmExpirationDate, dal.GetMopByUserPaymentType(UserName, (int)creditCardNumber.PaymentType), CmConstant.kstrNegative, m_can.StatementCode, paymentReceiptType, CmConstant.kstrDefaultWorkstation); Request.MAC00027 mac27 = new Mac00027Helper( SiteId.ToString(), m_can.AccountNumber9, CmConstant.kstrDefaultTaskCode, inl72); // Use inherited functions to get a response Response.MAC00027 mac27Response = (Response.MAC00027) this.Invoke((Request.MAC00027)mac27); Response.INL00072 inl72Response = mac27Response.Items[0] as Response.INL00072; int intErrorCode = toInt32(inl72Response.IGIRTRNCODE); if (intErrorCode > 0) { throw TranslateCmException( intErrorCode, string.Format("Authorization failed with error - ErrorCode: {0} ErrorText: {1}", inl72Response.IGIRTRNCODE, inl72Response.IGIMESGTEXT), null); } rcpt.AccountNumber16 = m_can.AccountNumber16; rcpt.AmountPaid = (inl72Response.AMNTTOAPLY.Length > 0) ? Double.Parse(inl72Response.AMNTTOAPLY): 0.00; rcpt.PaymentType = (ePaymentType) new MopPaymentType(this.UserName, inl72Response.MTHDOFPAYCODE); rcpt.Status = ePaymentStatus.Success; rcpt.TransactionDate = new IcomsDate(inl72Response.ATHRZTNDATE).Date; return(rcpt); } // try catch (BusinessLogicLayerException blle) { //the dal threw an exception logEntry.SetError(blle.Message); throw; } catch (DataSourceException excDSE) { //the dal threw an exception logEntry.SetError(excDSE.Message); throw new DataSourceUnavailableException(excDSE); } catch (CmErrorException excCm) { logEntry.SetError(excCm.Message, excCm.ErrorCode); throw TranslateCmException(excCm); } // catch( CmErrorException excCm ) catch (Exception exc) { logEntry.SetError(exc.Message); throw; } // catch( Exception exc ) } // using( Log log = CreateLog( logEntry ) ) } // PayUsingCreditCard()