public order_payment GetPayment(string id) { order_payment payment = new order_payment(); List <order_payment> todos = new List <order_payment>(); try { todos = orderPaymentFactory.GetAll(); var email = todos.Select(x => (x.order_reference)).ToList(); foreach (order_payment uno in todos) { if (id == uno.order_reference) { payment = uno; } } return(payment); } catch (System.Exception ex) { throw ex; } }
private void SaveLogInterface(POSAirPortClassesDataContext _posDB, OrderHeader order, order_session new_session_order) { // order_header db save var new_order_header = new order_header(); new_order_header.session_id = new_session_order.id; new_order_header.order_type = order.Flight.Terminal; new_order_header.member_id = order.NewOrder.MemberID; new_order_header.full_name = order.Billing.FirstName + " " + order.Billing.LastName; new_order_header.passport_no = order.Billing.PassportNo; new_order_header.country = order.Billing.CountryCode; new_order_header.airport_code = order.Flight.AirportCode; new_order_header.terminal_code = order.Flight.Terminal; new_order_header.airline_code = order.Flight.AirlineCode; new_order_header.flight_code = order.Flight.FlightCode; new_order_header.flight_no = order.Flight.FlightCode; //new_order_header.flight_ new_order_header.reference_1 = ""; new_order_header.reference_2 = ""; new_order_header.reference_3 = ""; new_order_header.remark = ""; new_order_header.create_date = DateTime.Now; _omDB.order_headers.InsertOnSubmit(new_order_header); _omDB.SubmitChanges(); // db save new order_detail and order_discount foreach (var item in order.Items.Select((value, index) => new { Value = value, Index = index })) { order_detail new_item = new order_detail(); new_item.header_id = new_order_header.id; new_item.line_no = item.Index + 1; new_item.sub_order_type = "I"; new_item.article_code = item.Value.MaterialCode; new_item.quantity = item.Value.Quantity; new_item.selling_price = item.Value.SellingPrice; new_item.total_amt = item.Value.Amount; new_item.dis_rate = item.Value.DiscountRate; new_item.dis_amt = item.Value.Discount; new_item.dis_pro_code = item.Value.PromoCode; new_item.sp_dis_amt = item.Value.SPDiscount; new_item.sp_dis_rate = item.Value.SPDiscountRate; new_item.sp_dis_pro_code = item.Value.SPPromoCode; new_item.net_amt = item.Value.TotalNet; new_item.reference_1 = ""; new_item.reference_2 = ""; new_item.reference_3 = ""; _omDB.order_details.InsertOnSubmit(new_item); _omDB.SubmitChanges(); } // new df_payment_onl var master_paymath = _posDB.df_paymeths.ToList(); foreach (var payment in order.Payments.Select((value, index) => new { Value = value, Index = index })) { decimal amt_curr = 0; var paymath = master_paymath.FirstOrDefault(x => x.method_code.Trim() == payment.Value.Code.Trim()); if (paymath != null) { if (paymath.check_voucher || paymath.is_cashcard) { amt_curr = 0; } else { amt_curr = payment.Value.Amount * 1; } } order_payment new_payment = new order_payment(); new_payment.header_id = new_order_header.id; new_payment.payment_type = payment.Value.Code; new_payment.paymemt_agent = ""; new_payment.paymemt_session_id = ""; new_payment.paymemt_ref_no = ""; new_payment.payment_code = payment.Value.Code; new_payment.paymemt_amt = payment.Value.Amount; new_payment.paymemt_datetime = DateTime.Now; _omDB.order_payments.InsertOnSubmit(new_payment); _omDB.SubmitChanges(); } }
public void ProcessNotification(PaymentNotificationData data) { try { int orderId = 0; if (int.TryParse(data.mnt_transaction_id, out orderId)) { var orderApiClient = ByDesignAPIHelper.CreateOrderAPIClient(); var orderApiCred = orderApiClient.CreateCredentials(); var response = orderApiClient.GetOrderInfo_V2(orderApiCred, orderId); if (response.Success > 0) { int custNum = 0; if (int.TryParse(response.CustomerNumber, out custNum)) { if (custNum >= 2000) { var orderDetailsResponse = orderApiClient.GetOrderDetailsInfo_V2(orderApiCred, orderId); if (orderDetailsResponse.Success == 0) { throw new InvalidOperationException(orderDetailsResponse.Message); } if (orderDetailsResponse.OrderDetailsResponse .Any(x => x.ProductID.Equals(Properties.Settings.Default.Freedom_VipKitItemId))) { // change customer type var onlineApiClient = ByDesignAPIHelper.CreateOnlineAPIClient(); var onlineApiCred = onlineApiClient.CreateCredentials(); var types = onlineApiClient.GetCustomerTypes(onlineApiCred); var preferredType = types.FirstOrDefault(x => x.Abbreviation.Equals(CustomerType_Preferred)); if (preferredType != null) { onlineApiClient.SetCustomerType(onlineApiCred, response.CustomerNumber, preferredType.ID); } } } } OrderStatus currentStatus = OrderStatus.Unknown; if (Enum.TryParse(response.Status, out currentStatus)) { if (currentStatus == OrderStatus.Entered) { orderApiClient.SetStatusPosted(orderApiCred, orderId, 0); using (BiWellEntities context = new BiWellEntities()) { order_payment payment = new order_payment { order_id = orderId, amount = decimal.Parse(data.mnt_amount, CultureInfo.InvariantCulture), created_at = DateTime.UtcNow }; context.order_payment.Add(payment); context.SaveChanges(); } } } } } } catch (Exception ex) { _looger.Log(ex.Message); } }
public DataTable PrepararPedidos() { DataTable Prestashop = new DataTable("Ordenes"); DataColumn column; DataRow row; pedidosEcommerce = ListaPedidosPagados(); customer cliente = new customer(); address direccion_cli = new address(); address direccion_ent = new address(); order_payment pago = new order_payment(); column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "ped_id"; column.Caption = "ped_id"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ped_ref"; column.Caption = "ped_ref"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ped_fecha"; column.Caption = "ped_fecha"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ped_ubigeo_ent"; column.Caption = "ped_ubigeo_ent"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ped_dir_ent"; column.Caption = "ped_dir_ent"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_total_sigv"; column.Caption = "ped_total_sigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_total_cigv"; column.Caption = "ped_total_cigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_dcto_sigv"; column.Caption = "ped_dcto_sigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_dcto_cigv"; column.Caption = "ped_dcto_cigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_ship_sigv"; column.Caption = "ped_ship_sigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Decimal"); column.ColumnName = "ped_ship_cigv"; column.Caption = "ped_ship_cigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "cli_id"; column.Caption = "cli_id"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_nombres"; column.Caption = "cli_nombres"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_apellidos"; column.Caption = "cli_apellidos"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_fec_nac"; column.Caption = "cli_fec_nac"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_email"; column.Caption = "cli_email"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_ubigeo"; column.Caption = "cli_ubigeo"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_direc"; column.Caption = "cli_direc"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_telf"; column.Caption = "cli_telf"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "cli_dni"; column.Caption = "cli_dni"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "det_artic"; column.Caption = "det_artic"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "det_artic_ref"; column.Caption = "det_artic_ref"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "det_desc_artic"; column.Caption = "det_desc_artic"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "det_cant"; column.Caption = "det_cant"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Double"); column.ColumnName = "det_prec_sigv"; column.ColumnName = "det_prec_sigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Double"); column.ColumnName = "det_dcto_sigv"; column.ColumnName = "det_dcto_sigv"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "pag_metodo"; column.ColumnName = "pag_metodo"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "pag_nro_trans"; column.ColumnName = "pag_nro_trans"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "pag_nro_tarj"; column.ColumnName = "pag_nro_tarj"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "pag_fecha"; column.ColumnName = "pag_fecha"; Prestashop.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Double"); column.ColumnName = "pag_monto"; column.ColumnName = "pag_monto"; Prestashop.Columns.Add(column); foreach (order orden in pedidosEcommerce) { int idCliente = Convert.ToInt32((orden).id_customer); cliente = GetCliente(idCliente); int idDireccion = Convert.ToInt32((orden).id_address_delivery); direccion_ent = GetDireccion(idDireccion); int idDireccion2 = Convert.ToInt32((orden).id_address_invoice); direccion_cli = GetDireccion(idDireccion); string idPago = Convert.ToString((orden).reference); pago = GetPayment(idPago); foreach (order_row detalle in orden.associations.order_rows) { row = Prestashop.NewRow(); row["ped_id"] = orden.id; row["ped_ref"] = orden.reference; row["ped_fecha"] = orden.date_add; row["ped_ubigeo_ent"] = direccion_ent.id_state; row["ped_dir_ent"] = direccion_ent.address1; row["ped_total_sigv"] = orden.total_paid_tax_excl; row["ped_total_cigv"] = orden.total_paid_real; row["ped_dcto_sigv"] = orden.total_discounts_tax_excl; row["ped_dcto_cigv"] = orden.total_discounts; row["ped_ship_sigv"] = orden.total_shipping_tax_excl; row["ped_ship_cigv"] = orden.total_shipping; row["cli_id"] = orden.id_customer; row["cli_nombres"] = cliente.firstname; row["cli_apellidos"] = cliente.lastname; row["cli_fec_nac"] = cliente.birthday; row["cli_email"] = cliente.email; row["cli_ubigeo"] = direccion_cli.id_state; row["cli_direc"] = direccion_cli.address1; row["cli_telf"] = direccion_cli.phone; row["cli_dni"] = direccion_cli.dni; row["det_artic"] = detalle.product_id; row["det_artic_ref"] = detalle.product_reference; row["det_desc_artic"] = detalle.product_name; row["det_cant"] = detalle.product_quantity; row["det_prec_sigv"] = detalle.product_price; row["det_dcto_sigv"] = detalle.unit_price_tax_excl; row["pag_metodo"] = pago.payment_method; row["pag_nro_trans"] = pago.transaction_id; row["pag_nro_tarj"] = pago.card_number; row["pag_fecha"] = pago.date_add; row["pag_monto"] = pago.amount; Prestashop.Rows.Add(row); } } return(Prestashop); }