Esempio n. 1
0
        ///<summary>Throws exceptions.  Will purposefully throw ODExceptions that are already translated and and formatted.
        ///Returns the PaymentId given by PaySimple.</summary>
        private static ApiResponse MakePaymentNoPat(decimal payAmt, string ccNum, DateTime ccExpDate, string billingZipCode = "", string cvv = "", long clinicNum = -1)
        {
            ValidateProgram(clinicNum);
            if (string.IsNullOrWhiteSpace(ccNum) || ccExpDate.Year < DateTime.Today.Year)
            {
                throw new ODException(Lans.g("PaySimple", "Error making payment"));
            }
            long        psCustomerId = AddCustomer("UNKNOWN", "UNKNOWN", "", clinicNum);
            ApiResponse apiResponse  = AddCreditCard(psCustomerId, ccNum, ccExpDate, billingZipCode);
            string      accountId    = apiResponse.PaySimpleToken;

            return(PaySimpleApi.PostPayment(GetAuthHeader(clinicNum), PaySimpleApi.MakeNewPaymentData(PIn.Long(accountId), payAmt, cvv)));
        }
Esempio n. 2
0
 ///<summary>Throws exceptions.  Will purposefully throw ODExceptions that are already translated and and formatted.
 ///If PatNum is 0, we will make a one time payment for an UNKNOWN patient.  This is currently only intended for prepaid insurance cards.
 ///Returns the PaymentId given by PaySimple.</summary>
 public static ApiResponse MakePayment(long patNum, CreditCard cc, decimal payAmt, string ccNum, DateTime ccExpDate, bool isOneTimePayment, string billingZipCode = "", string cvv = "", long clinicNum = -1)
 {
     ValidateProgram(clinicNum);
     if (patNum == 0)
     {
         //MakePaymentNoPat will validate its credentials.
         return(MakePaymentNoPat(payAmt, ccNum, ccExpDate, billingZipCode, cvv, clinicNum));
     }
     if ((cc == null || string.IsNullOrWhiteSpace(cc.PaySimpleToken)) && (string.IsNullOrWhiteSpace(ccNum) || ccExpDate.Year < DateTime.Today.Year))
     {
         throw new ODException(Lans.g("PaySimple", "Error making payment"));
     }
     if (cc == null)
     {
         cc = new CreditCard()
         {
             PatNum         = patNum,
             PaySimpleToken = "",
         };
     }
     if (string.IsNullOrWhiteSpace(cc.PaySimpleToken))
     {
         Patient patCur = Patients.GetPat(cc.PatNum);
         if (patCur == null)
         {
             patCur = new Patient()
             {
                 PatNum = patNum,
                 FName  = "",
                 LName  = "",
             };
         }
         long        psCustomerId = GetCustomerIdForPat(patCur.PatNum, patCur.FName, patCur.LName, clinicNum);
         ApiResponse apiResponse  = AddCreditCard(psCustomerId, ccNum, ccExpDate, billingZipCode, clinicNum);
         cc.PaySimpleToken = apiResponse.PaySimpleToken;
         if (!isOneTimePayment && cc.CreditCardNum > 0)               //If the user doesn't want Open Dental to store their account id, we will let them continue entering their CC info.
         {
             CreditCards.Update(cc);
         }
     }
     return(PaySimpleApi.PostPayment(GetAuthHeader(clinicNum), PaySimpleApi.MakeNewPaymentData(PIn.Long(cc.PaySimpleToken), payAmt, cvv)));
 }