/// <summary> /// Simulate refund by creating a negative payment item. /// </summary> /// <param name="paymentID">The payment item to refund</param> /// <param name="customerID"></param> /// <returns></returns> public Contracts.Payment Refund(long paymentID, Guid customerID) { PaymentDal p_dal = new PaymentDal(); Contracts.Payment refund; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //validate the payment. var payment = p_dal.GetEntity(paymentID); if (payment == null) throw new PaymentException(StringsResource.RefundFailedPaymentNotFound); if (payment.Amount < 0) throw new PaymentException(StringsResource.RefundFailedNegativeAmount); //Refund is a payment record with a negative amount refund = new Contracts.Payment() { ID = Interlocked.Increment(ref paymentID), Amount = 0 - payment.Amount, Date = DateTime.Now, MethodOfPayment = payment.MethodOfPayment, CustomerID = customerID, OrderID = payment.OrderID }; p_dal.CreateEntity(refund); scope.Complete(); } // to make sure the payment is saved we return the payment written to the database. return p_dal.GetEntity(refund.ID); }
/// <summary> /// Create a payment for a ticketing order. An Order can hold a collection of payment items. /// </summary> /// <param name="orderID">Order to pay for</param> /// <param name="customerID">Paying customer</param> /// <param name="amount"></param> /// <param name="methodOfPayment"></param> /// <param name="creditCardNumber">CreditCard information. Relevant only when the payment method is credit card. </param> /// <returns></returns> public Contracts.Payment PayForOrder(Guid orderID, Guid customerID, double amount, PaymentType methodOfPayment, string creditCardNumber) { PaymentDal p_dal = new PaymentDal(); Contracts.Payment newPayment; if (methodOfPayment == PaymentType.CreditCard) ApproveCreditCard(creditCardNumber); newPayment = new Contracts.Payment() { Amount = amount, Date = DateTime.Now, MethodOfPayment = methodOfPayment, CustomerID = customerID, OrderID = orderID }; var id = p_dal.CreateEntity(newPayment); // to make sure the payment is saved we return the payment written to the database. return p_dal.GetEntity(id); }
/// <summary> /// Find a payment record accoring to its ID /// </summary> /// <param name="paymentID"></param> /// <returns></returns> public Contracts.Payment FindPayment(long paymentID) { PaymentDal p_dal = new PaymentDal(); return p_dal.GetEntity(paymentID); }
/// <summary> /// Find a particular payment record. /// </summary> /// <param name="criteria"></param> /// <returns></returns> public Contracts.Payment[] FindPayments(PaymentCriteria criteria) { PaymentDal p_dal = new PaymentDal(); return p_dal.FindPaymentByCriteria(criteria); }
/// <summary> pay to passenger about the traveling /// </summary> public static void PayToDriver(object state) { List <Registeration> registerations = RegisterationDal.GetTravelingsToPay(); PaymentDal.AddPayments(registerations); }
/// <summary> pay to passenger about cancle the traveling /// </summary> public static void PayToPassengerCancel(RegisterationDTO reg, DateTime fromDate, DateTime toDate) { PaymentDal.AddPaymentCancelToP(RegisterationConverters.GetRegisteration(reg), fromDate, toDate); }
/// <summary> pay to driver about cancle the traveling /// </summary> public static void PayToDriverCancel(int id, DateTime fromDate, DateTime toDate) { PaymentDal.AddPaymentCancelToD(id, fromDate, toDate); }
/// <summary> find payment by identity of Driver /// </summary> public static List <PaymentDTO> GetPaymentsD(int id) { return(PaymentConverters.GetListPaymentDTO(PaymentDal.GetPaymentsD(id))); }