Ejemplo n.º 1
0
 public Payment CreatePayment(decimal amount, string description, DateTime date_created, Currency currency, Invoice invoice, Client client, Gateway gateway, PaymentStatus status)
 {
     using (var db = new wbpaymentsEntities())
     {
         //create a new payment with the data from params and add it to db
         Payment creation = new Payment {
             amount = amount, date_created = date_created, description = description, client_id = client.client_id, payment_status_id = status.payment_status_id, currency_id = currency.currency_id, invoice_id = invoice.invoice_id, gateway_id = gateway.gateway_id
         };
         db.Payment.Add(creation);
         db.SaveChanges();
         return(creation);
     }
 }
Ejemplo n.º 2
0
 public Payment ConfirmPaymentAddingGatewayPaymentData(Payment payment, PaymentStatus status, string gatewayResponse, string gatewayReference, DateTime date)
 {
     using (var db = new wbpaymentsEntities())
     {
         //create the gateway payment data
         GatewayPaymentData creation = new GatewayPaymentData {
             gateway_response = gatewayResponse, gateway_reference = gatewayReference, date_created = date, payment_id = payment.payment_id
         };
         db.GatewayPaymentData.Add(creation);
         //get the payment from de db
         var result = db.Payment.SingleOrDefault(p => p.payment_id == payment.payment_id);
         //update payment's status
         result.payment_status_id = status.payment_status_id;
         db.SaveChanges();
         return(result);
     }
 }
Ejemplo n.º 3
0
 public Payment CreatePaymentAndInvoice(string invoiceNumber, string clientId, string currencyId, DateTime date, decimal amount, string description, Gateway gateway, PaymentStatus status)
 {
     using (var db = new wbpaymentsEntities())
     {
         //create a new invoice with the data from params and add it to the db
         Invoice invoice = new Invoice {
             invoice_number = invoiceNumber, client_id = clientId, date_created = date
         };
         db.Invoice.Add(invoice);
         //create a new payment with the data from params and the invoice just created
         Payment creation = new Payment {
             amount = amount, date_created = date, description = description, client_id = clientId, payment_status_id = status.payment_status_id, currency_id = currencyId, invoice_id = invoice.invoice_id, gateway_id = gateway.gateway_id
         };
         db.Payment.Add(creation);
         db.SaveChanges();
         return(creation);
     }
 }