public void Next_Returns_A_Random()
 {
     CreditCardSource source = new CreditCardSource();
     var value = source.Next(null);
     Debug.WriteLine(string.Format("the credit card number was : {0}", value));
     Assert.IsNotNullOrEmpty(value);
 }
예제 #2
0
        public void Next_Returns_A_Discover_Card()
        {
            CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.Discover);
            var value = source.Next(null);

            Assert.IsTrue(value == "6011 1111 1111 1117");
        }
예제 #3
0
        public void Next_Returns_An_American_Express()
        {
            CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.AmericanExpress);
            var value = source.Next(null);

            Assert.IsTrue(value == "3782 822463 10005");
        }
예제 #4
0
        public void Next_Returns_A_Visa()
        {
            CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.Visa);
            var value = source.Next(null);

            Assert.IsTrue(value == "4111 1111 1111 1111");
        }
예제 #5
0
        public void Next_Returns_A_MasterCard()
        {
            CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.MasterCard);
            var value = source.Next(null);

            Assert.IsTrue(value == "5105 1051 0510 5100");
        }
예제 #6
0
        public void Next_Returns_A_Random()
        {
            CreditCardSource source = new CreditCardSource();
            var value = source.Next(null);

            Debug.WriteLine(string.Format("the credit card number was : {0}", value));
            Assert.That(value, Is.Not.Null.And.Not.Empty);
        }
예제 #7
0
 ///<summary>Returns number of times token is in use.  Token was duplicated once and caused the wrong card to be charged.</summary>
 public static int GetTokenCount(string token, CreditCardSource ccSource)
 {
     //No need to check RemotingRole; no call to db.
     return(GetTokenCount(token, new List <CreditCardSource>()
     {
         ccSource
     }));
 }
예제 #8
0
        ///<summary>Gets every credit card in the db with an X-Charge token that was created from the specified source.</summary>
        public static List <CreditCard> GetCardsWithXChargeTokens(CreditCardSource ccSource = CreditCardSource.XServer)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <CreditCard> >(MethodBase.GetCurrentMethod(), ccSource));
            }
            string command = "SELECT * FROM creditcard WHERE XChargeToken!=\"\" "
                             + "AND CCSource=" + POut.Int((int)ccSource);

            return(Crud.CreditCardCrud.SelectMany(command));
        }
        public void GenerateAndValidateNumber()
        {
            for (int i = 0; i < 100; i++)
            {
                var cardNumber = CreditCardSource.GenerateNumber(CreditCardSource.CreditCardType.Visa);
                cardNumber.Should().NotBeNullOrEmpty();
                cardNumber.Length.Should().Be(16);

                var valid = CreditCardSource.IsValidNumber(cardNumber);
                valid.Should().BeTrue();
            }
        }
예제 #10
0
 ///<summary>These fields should persist from instance to instance for the same OTK.</summary>
 public void SetPersistentFields(long xWebResponseNum, string transactionType, long patNum, long provNum, long clinicNum, double amount, string otk,
                                 string hpfUrl, DateTime hpfExpiration, string debugError, string payNote, CreditCardSource ccSource)
 {
     XWebResponseNum = xWebResponseNum;
     TransactionType = transactionType;
     PatNum          = patNum;
     ProvNum         = provNum;
     ClinicNum       = clinicNum;
     Amount          = amount;
     OTK             = otk;
     HpfUrl          = hpfUrl;
     HpfExpiration   = hpfExpiration;
     DebugError      = debugError;
     PayNote         = payNote;
     CCSource        = ccSource;
 }
예제 #11
0
 public XWebInputHpfPayment(long patNum, bool isMobile, double amount, string payNote, bool createAlias, CreditCardSource ccSource)
     : base(XWebTransactionType.CreditSaleTransaction, patNum, isMobile)
 {
     _amount      = amount;
     _payNote     = payNote;
     _createAlias = createAlias;
     _ccSource    = ccSource;
     if (_ccSource != CreditCardSource.XWeb && _ccSource != CreditCardSource.XWebPortalLogin)
     {
         throw new ODException("Invalid CreditCardSource: " + _ccSource.ToString(), ODException.ErrorCodes.OtkArgsInvalid);
     }
     //Validate the amount.
     if (_amount < 0.00 || _amount > 99999.99)
     {
         throw new ODException("Invalid Amount", ODException.ErrorCodes.OtkArgsInvalid);
     }
     if (string.IsNullOrEmpty(_payNote))
     {
         throw new ODException("Invalid PayNote", ODException.ErrorCodes.OtkArgsInvalid);
     }
 }
예제 #12
0
 ///<summary>Creates and returns the HPF URL and validation OTK which can be used to make a payment for an unspecified credit card.  Throws exceptions.</summary>
 public static XWebResponse GetHpfUrlForPayment(long patNum, string payNote, bool isMobile, double amount, bool createAlias,
                                                CreditCardSource ccSource)
 {
     //No need to check RemotingRole;no call to db.
     return(new XWebInputHpfPayment(patNum, isMobile, amount, payNote, createAlias, ccSource).GenerateOutput());
 }
예제 #13
0
 public void Next_Returns_A_Discover_Card()
 {
     CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.Discover);
     var value = source.Next(null);
     Assert.IsTrue(value == "6011 1111 1111 1117");
 }
예제 #14
0
        ///<summary>Creates and returns the EdgeExpress URL and validation OTK which can be used to make a payment for an unspecified credit card.
        ///</summary>
        public static XWebResponse GetEdgeExpressUrlForPayment(long patNum, string payNote, double amount, bool createAlias, CreditCardSource ccSource)
        {
            //No need to check RemotingRole;no call to db.
            if (ccSource != CreditCardSource.XWeb && ccSource != CreditCardSource.XWebPortalLogin)
            {
                throw new ODException("Invalid CreditCardSource: " + ccSource.ToString(), ODException.ErrorCodes.OtkArgsInvalid);
            }
            //Validate the amount.
            if (amount < 0.00 || amount > 99999.99)
            {
                throw new ODException("Invalid Amount", ODException.ErrorCodes.OtkArgsInvalid);
            }
            if (string.IsNullOrEmpty(payNote))
            {
                throw new ODException("Invalid PayNote", ODException.ErrorCodes.OtkArgsInvalid);
            }
            XWebResponse response = SendEdgeExpressRequest(patNum, EdgeExpressTransactionType.CreditSale, _edgeExpressHostPayUrl, amount,
                                                           doCreateAlias: createAlias);

            response.Amount   = amount;
            response.PayNote  = payNote;
            response.CCSource = ccSource;
            FinishEdgeExpressUrlRequest(response);
            return(response);
        }
예제 #15
0
 ///<summary>Checks if token already exists in db.</summary>
 public static bool TokenExists(string token, CreditCardSource ccSource)
 {
     //No need to check RemotingRole; no call to db.
     return(GetTokenCount(token, ccSource) >= 1);
 }
예제 #16
0
        ///<summary>Creates and returns the HPF URL and validation OTK which can be used to make a payment for an unspecified credit card.  Throws exceptions.</summary>
        public static string GetHpfUrlForPayment(Patient pat, string accountToken, string payNote, bool isMobile, double amount, bool saveToken, CreditCardSource ccSource)
        {
            if (pat == null)
            {
                throw new ODException("No Patient Found", ODException.ErrorCodes.NoPatientFound);
            }
            if (string.IsNullOrWhiteSpace(accountToken))
            {
                throw new ODException("Invalid Account Token", ODException.ErrorCodes.OtkArgsInvalid);
            }
            if (amount < 0.00 || amount > 99999.99)
            {
                throw new ODException("Invalid Amount", ODException.ErrorCodes.OtkArgsInvalid);
            }
            if (string.IsNullOrEmpty(payNote))
            {
                throw new ODException("Invalid PayNote", ODException.ErrorCodes.OtkArgsInvalid);
            }
            PayConnectResponseWeb responseWeb = new PayConnectResponseWeb()
            {
                Amount           = amount,
                AccountToken     = accountToken,
                PatNum           = pat.PatNum,
                ProcessingStatus = PayConnectWebStatus.Created,
                PayNote          = payNote,
                CCSource         = ccSource,
                IsTokenSaved     = saveToken,
            };

            PayConnectResponseWebs.Insert(responseWeb);
            try {
                string url;
                PayConnectREST.PostPaymentRequest(responseWeb, out url);
                PayConnectResponseWebs.Update(responseWeb);
                WakeupWebPaymentsMonitor?.Invoke(url, new EventArgs());
                return(url);
            }
            catch (Exception e) {
                PayConnectResponseWebs.HandleResponseError(responseWeb, "Error calling PostPaymentRequest: " + e.Message);
                PayConnectResponseWebs.Update(responseWeb);
                throw;
            }
        }
예제 #17
0
 private void UpsertCreditCard(PaySimple.ApiResponse apiResponse, string ccNumberMasked, CreditCardSource ccSource, DateTime ccExp)
 {
     if (_creditCardCur == null)           //new account
     {
         _creditCardCur        = new CreditCard();
         _creditCardCur.IsNew  = true;
         _creditCardCur.PatNum = _patCur.PatNum;
         List <CreditCard> itemOrderCount = CreditCards.Refresh(_patCur.PatNum);
         _creditCardCur.ItemOrder = itemOrderCount.Count;
     }
     if (ccExp.Year > 1880)
     {
         _creditCardCur.CCExpiration = ccExp;
     }
     _creditCardCur.CCNumberMasked = ccNumberMasked;
     _creditCardCur.Zip            = textZipCode.Text;
     _creditCardCur.PaySimpleToken = apiResponse.PaySimpleToken;
     _creditCardCur.CCSource       = ccSource;
     if (_creditCardCur.IsNew)
     {
         _creditCardCur.ClinicNum  = _clinicNum;
         _creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs);
         CreditCards.Insert(_creditCardCur);
     }
     else
     {
         CreditCards.Update(_creditCardCur);
     }
 }
예제 #18
0
        ///<summary>Insert Payment and PaySplit. Returns newly inserted Payment.PayNum.  Throws exceptions if XWeb Program Properties are invalid.</summary>
        public static long InsertFromXWeb(long patNum, long provNum, long clinicNum, double amount, string payNote, string receipt, CreditCardSource ccSource)
        {
            //No need to check RemotingRole;no call to db.
            OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties xwebProperties;
            OpenDentBusiness.ProgramProperties.GetXWebCreds(clinicNum, out xwebProperties);
            long ret = Payments.Insert(new Payment()
            {
                ClinicNum     = clinicNum,
                IsRecurringCC = false,
                IsSplit       = false,
                PatNum        = patNum,
                PayAmt        = amount,
                PayDate       = DateTime.Now,
                PaymentSource = ccSource,
                PayType       = xwebProperties.PaymentTypeDefNum,
                ProcessStatus = ProcessStat.OnlinePending,
                Receipt       = receipt,
                PayNote       = payNote,
            });

            PaySplits.Insert(new PaySplit()
            {
                ClinicNum = clinicNum,
                DatePay   = DateTime.Now,
                PatNum    = patNum,
                PayNum    = ret,
                ProvNum   = provNum,
                SplitAmt  = amount,
            });
            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, patNum, Lans.g("Payments.InsertFromXWeb", "XWeb payment by") + " "
                                      + OpenDentBusiness.Patients.GetLim(patNum).GetNameLF() + ", " + amount.ToString("c"), LogSources.PatientPortal);
            return(ret);
        }
예제 #19
0
 public void Next_Returns_A_Visa()
 {
     CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.Visa);
     var value = source.Next(null);
     Assert.IsTrue(value == "4111 1111 1111 1111");
 }
예제 #20
0
        ///<summary>Insert Payment and PaySplit. Returns newly inserted Payment.PayNum.  Throws exceptions if PayConnect Program Properties are invalid.</summary>
        public static long InsertFromPayConnect(long patNum, long provNum, long clinicNum, double amount, string payNote, string receipt, CreditCardSource ccSource)
        {
            //No need to check RemotingRole;no call to db.
            long ret = Payments.Insert(new Payment()
            {
                ClinicNum     = clinicNum,
                IsRecurringCC = false,
                IsSplit       = false,
                PatNum        = patNum,
                PayAmt        = amount,
                PayDate       = DateTime.Now,
                PaymentSource = ccSource,
                PayType       = PIn.Long(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PayConnect).ProgramNum, "PaymentType", clinicNum)),
                ProcessStatus = ProcessStat.OnlinePending,
                Receipt       = receipt,
                PayNote       = payNote,
            });

            PaySplits.Insert(new PaySplit()
            {
                ClinicNum = clinicNum,
                DatePay   = DateTime.Now,
                PatNum    = patNum,
                PayNum    = ret,
                ProvNum   = provNum,
                SplitAmt  = amount,
            });
            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, patNum, Lans.g("Payments.InsertFromPayConnect", "PayConnect payment by") + " "
                                      + OpenDentBusiness.Patients.GetLim(patNum).GetNameLF() + ", " + amount.ToString("c"), LogSources.PatientPortal);
            return(ret);
        }
예제 #21
0
 public void Next_Returns_A_MasterCard()
 {
     CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.MasterCard);
     var value = source.Next(null);
     Assert.IsTrue(value == "5105 1051 0510 5100");
 }
예제 #22
0
 public void Next_Returns_An_American_Express()
 {
     CreditCardSource source = new CreditCardSource(CreditCardSource.CreditCardType.AmericanExpress);
     var value = source.Next(null);
     Assert.IsTrue(value == "3782 822463 10005");
 }