//Get Order public async Task <dynamic> GetOrderDetails(OrderDetailModel model) { SecurityToken token = await GetSecurityToken(); var client = new PaymentGateway.IeBizServiceClient(); var data = await client.GetSalesOrderAsync(token, model.customerId, model.subCustomerId, model.salesOrderNo, model.salesOrderInternalId); return(data); }
public async Task <dynamic> SyncOrders(SyncDetailModel model) { SecurityToken token = await GetSecurityToken(); var client = new PaymentGateway.IeBizServiceClient(); List <SyncOrderReponse> orderReponses = new List <SyncOrderReponse>(); SyncResponseModel response = new SyncResponseModel(); foreach (var item in model.salesOrders) { SyncOrderReponse orderreponse = new SyncOrderReponse(); try { if (string.IsNullOrEmpty(item.CustomerId)) { orderreponse.Status = "Failure"; orderreponse.Message = "You must select an existing customer"; orderreponse.OrderNo = item.SalesOrderNumber; orderreponse.OrderInternalId = ""; orderReponses.Add(orderreponse); } else { var order = await client.GetSalesOrderAsync(token, item.CustomerId, "", item.SalesOrderNumber, ""); item.SalesOrderInternalId = order.SalesOrderInternalId; item.SalesOrderNumber = order.SalesOrderNumber; item.CustomerId = order.CustomerId; var updatecust = await new OrderManager().UpdateSalesOrder(token, item); orderreponse.Status = updatecust.Status; orderreponse.Message = "Succesfuly Updated"; orderreponse.OrderNo = order.SalesOrderNumber; orderreponse.OrderInternalId = updatecust.SalesOrderInternalId; orderReponses.Add(orderreponse); } } catch (Exception ex) { if (ex.Message.ToString() == "Not Found" && item != null) { var neworder = await new OrderManager().AddSalesOrder(token, item); orderreponse.Status = neworder.Status; orderreponse.Message = "Succesfuly Created"; orderreponse.OrderNo = item.SalesOrderNumber; orderreponse.OrderInternalId = neworder.SalesOrderInternalId; orderReponses.Add(orderreponse); } } } response.orderReponses = orderReponses; return(response.orderReponses); }
//Save Transaction without saving payment details public async Task <dynamic> SaveCustTransaction(CustomerTransactionModel model) { Response response = new Response(); // if paymentmethod is empty then first add payment method also check customer token as well. //if customer token available then search on cstmr token otherwise on id. //if paymentmethodid = "" then add and save card details // paymentmethodid from model string custIntlId = ""; string invoiceIntlId = ""; string orderIntlId = ""; SecurityToken token = await GetSecurityToken(); var client = new PaymentGateway.IeBizServiceClient(); if (!string.IsNullOrEmpty(model.customer?.CustomerId)) { try { model.customer = await client.GetCustomerAsync(token, model.customer.CustomerId, ""); //getCustomer( by id customer?.CustomerId //assigne to custIntlId = customerInternalID custIntlId = model.customer.CustomerInternalId; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found") { custIntlId = ""; } } } if (string.IsNullOrEmpty(custIntlId.ToString()) && model.customer != null) { //Add customer response.CustomerResponse = await new CustomerManager().AddNewCustomer(model.customer, token); //get customertoken model.customer.CustomerToken = await client.GetCustomerTokenAsync(token, model.customer.CustomerId, model.customer.CustomerInternalId); custIntlId = response.CustomerResponse.CustomerInternalId; } if (string.IsNullOrEmpty(model.paymentMethod) && model.paymentMethodProfile != null) { //Add Payment method (use custIntlId //if secondrySort == 0 then call SetAsDefault // values must come from controller. response.PaymentMethodProfileResponse = await new PaymentManager().AddNewPaymentDetails(model.customer.CustomerInternalId, model.paymentMethodProfile); model.paymentMethod = response.PaymentMethodProfileResponse; // this logic also implemented in controller. if (model.paymentMethodProfile.SecondarySort == "0") { PaymentProfile obj = new PaymentProfile(); obj.customerToken = model.customer.CustomerToken; obj.paymentMethod = response.PaymentMethodProfileResponse; obj.securityToken = token; var status = await new PaymentManager().SetDefaultPaymentMethodProfile(obj); } } if (!string.IsNullOrEmpty(model.customerTransaction?.Details?.Invoice) && model.isOrder == false) { try { model.invoice = await client.GetInvoiceAsync(token, model.customer.CustomerId, "", model.customerTransaction.Details.Invoice, ""); invoiceIntlId = model.invoice.InvoiceInternalId; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found") { invoiceIntlId = ""; } } } if (string.IsNullOrEmpty(invoiceIntlId.ToString()) && model.invoice != null && model.isOrder == false) { //Add new Invoice response.Invoice = await new InvoiceManager().AddInvoices(model.invoice, token); invoiceIntlId = response.Invoice.InvoiceInternalId; } if (!string.IsNullOrEmpty(model.customerTransaction?.Details?.OrderID) && model.isOrder == true) { try { model.salesOrder = await client.GetSalesOrderAsync(token, model.customer.CustomerId, model.customer.CustomerInternalId, model.customerTransaction.Details.OrderID, ""); orderIntlId = model.salesOrder.SalesOrderInternalId; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found") { orderIntlId = ""; } } } if (string.IsNullOrEmpty(orderIntlId.ToString()) && model.salesOrder != null && model.isOrder == true) { //Add new Invoice response.SalesOrder = await new OrderManager().AddSalesOrder(token, model.salesOrder); orderIntlId = response.SalesOrder.SalesOrderInternalId; } //Call Run Customer transaction /// //end var result = await client.runCustomerTransactionAsync(token, model.customer.CustomerToken, model.paymentMethod, model.customerTransaction); if (model.isOrder == true) { if (!string.IsNullOrEmpty(model.customerTransaction.Details.OrderID)) { ApplicationTransactionRequest obj = new ApplicationTransactionRequest(); { obj.CustomerInternalId = custIntlId; obj.LinkedToInternalId = orderIntlId; //sales order internal id or invoice internal id obj.LinkedToTypeId = model.customerTransaction.Details.OrderID; //sales order number or invoice number obj.TransactionId = result.RefNum; obj.TransactionDate = DateTime.Now.ToString(); obj.TransactionTypeId = "AuthOnly"; obj.SoftwareId = ".NetApi"; } response.AppTransResponse = await client.AddApplicationTransactionAsync(token, obj); } } else { if (!string.IsNullOrEmpty(model.customerTransaction.Details.Invoice)) { ApplicationTransactionRequest obj = new ApplicationTransactionRequest(); { obj.CustomerInternalId = custIntlId; obj.LinkedToInternalId = invoiceIntlId; //sales order internal id or invoice internal id obj.LinkedToTypeId = model.customerTransaction.Details.Invoice; //sales order number or invoice number obj.TransactionId = result.RefNum; obj.TransactionDate = DateTime.Now.ToString(); obj.TransactionTypeId = "AuthOnly"; obj.SoftwareId = ".NetApi"; } response.AppTransResponse = await client.AddApplicationTransactionAsync(token, obj); } } if (result.ResultCode == "A") { response.TransResponse = result; } else { response.TransResponse = result; } return(response); }
public async Task <EmailResponse> GetEmailPaymentTemplate(EmailDetailModel model) { EmailResponse response = new EmailResponse(); SecurityToken token = await GetSecurityToken(); var client = new PaymentGateway.IeBizServiceClient(); if (!string.IsNullOrEmpty(model.ebizWebForm?.CustomerId)) { try { Customer customer = await client.GetCustomerAsync(token, model.ebizWebForm.CustomerId, ""); model.ebizWebForm.CustFullName = customer.FirstName + " " + customer.LastName; model.customer = customer; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found" && model.customer != null) { Customer customer = new Customer(); customer.CustomerId = model.ebizWebForm.CustomerId; customer.CompanyName = model.ebizWebForm.CustFullName; //model.customer response.Customer = await new CustomerManager().AddNewCustomer(customer, token); model.ebizWebForm.CustomerId = response.Customer.CustomerId; model.ebizWebForm.CustFullName = model.customer.FirstName + " " + model.customer.LastName; model.customer.CustomerInternalId = response.Customer.CustomerInternalId; } } } //ShowViewSalesOrderLink //ShowViewInvoiceLink if (!string.IsNullOrEmpty(model.ebizWebForm?.InvoiceNumber)) { try { var invoice = await client.GetInvoiceAsync(token, model.ebizWebForm.CustomerId, "", model.ebizWebForm.InvoiceNumber, model.ebizWebForm.InvoiceInternalId); model.ebizWebForm.InvoiceNumber = invoice.InvoiceNumber; model.ebizWebForm.InvoiceInternalId = invoice.InvoiceInternalId; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found" && model.invoice != null) { //model.invoice Invoice invoice = new Invoice(); invoice.CustomerId = model.ebizWebForm.CustomerId; invoice.AmountDue = model.ebizWebForm.AmountDue; invoice.InvoiceNumber = model.ebizWebForm?.InvoiceNumber; invoice.InvoiceDueDate = model.ebizWebForm.DueDate?.ToString(); var addinvoice = await client.AddInvoiceAsync(token, invoice); response.Invoice = addinvoice; model.ebizWebForm.InvoiceNumber = invoice.InvoiceNumber; model.ebizWebForm.InvoiceInternalId = addinvoice.InvoiceInternalId; } } } if (!string.IsNullOrEmpty(model.ebizWebForm?.OrderId)) { try { var salesOrder = await client.GetSalesOrderAsync(token, model.ebizWebForm?.CustomerId, model.customer?.CustomerInternalId, model.ebizWebForm?.OrderId, model.salesOrder?.SalesOrderInternalId); model.ebizWebForm.SalesOrderInternalId = salesOrder.SalesOrderInternalId; } catch (Exception ex) { if (ex.Message.ToString() == "Not Found" && model.salesOrder != null) { //model.salesOrder //SalesOrder salesOrder = new SalesOrder(); var addOrder = await client.AddSalesOrderAsync(token, model.salesOrder); response.SalesOrder = addOrder; model.ebizWebForm.SalesOrderInternalId = addOrder.SalesOrderInternalId; } } } var data = await client.GetEbizWebFormURLAsync(token, model.ebizWebForm); response.EbizWebFormLink = data; return(response); }