private ChargeCreditCardTokenRequest Request_ChargeCreditCard() { // DEVELOPER NOTE: This method charges the credit card using tokenization, // which is PCI-Compliant. This is the default method to use when charging credit cards. // Fetch our credit card token. var token = ExigoApiContext.CreatePaymentContext().FetchCreditCardToken("4111111111111111", 9, 2018); var request = new ChargeCreditCardTokenRequest(); request.OrderID = 5188994; request.CreditCardToken = token; request.BillingName = "test"; request.CvcCode = "123"; request.BillingAddress = "707 e main st"; request.BillingCity = "LEHI"; request.BillingState = "Utah"; request.BillingZip = "84043"; request.BillingCountry = "US"; return(request); }
/// <remarks/> public void ChargeCreditCardTokenAsync(ChargeCreditCardTokenRequest ChargeCreditCardTokenRequest, object userState) { if ((this.ChargeCreditCardTokenOperationCompleted == null)) { this.ChargeCreditCardTokenOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChargeCreditCardTokenOperationCompleted); } this.InvokeAsync("ChargeCreditCardToken", new object[] { ChargeCreditCardTokenRequest}, this.ChargeCreditCardTokenOperationCompleted, userState); }
public ActionResult SubmitCheckout() { if (!PropertyBag.IsSubmitting) { PropertyBag.IsSubmitting = true; _propertyBag = ExigoDAL.PropertyBags.Update(PropertyBag); try { // Start creating the API requests var apiRequests = new List <ApiRequest>(); // Create the customer var customerRequest = new CreateCustomerRequest(PropertyBag.Customer) { InsertEnrollerTree = true, EnrollerID = PropertyBag.EnrollerID, CustomerType = CustomerTypes.Distributor, EntryDate = DateTime.Now.ToCST(), CustomerStatus = CustomerStatuses.Active, CanLogin = true, DefaultWarehouseID = OrderConfiguration.WarehouseID, Notes = "Distributor was entered by Distributor #{0}. Created by the API Enrollment at ".FormatWith(Identity.Owner.CustomerID) + HttpContext.Request.Url.Host + HttpContext.Request.Url.LocalPath + " on " + DateTime.Now.ToCST().ToString("dddd, MMMM d, yyyy h:mmtt") + " CST at IP " + Common.GlobalUtilities.GetClientIP() + " using " + HttpContext.Request.Browser.Browser + " " + HttpContext.Request.Browser.Version + " (" + HttpContext.Request.Browser.Platform + ")." }; ///IF Unilevel Place in Sponsor Tree Now, Binary will be placed post transactional envelope if (!GlobalSettings.Exigo.UseBinary) { customerRequest.InsertUnilevelTree = true; customerRequest.SponsorID = customerRequest.EnrollerID; } apiRequests.Add(customerRequest); // Set a few variables up for our shippping address, order/auto order items and the default auto order payment type var shippingAddress = PropertyBag.ShippingAddress; var orderItems = ShoppingCart.Items.Where(i => i.Type == ShoppingCartItemType.Order || i.Type == ShoppingCartItemType.EnrollmentPack).ToList(); var autoOrderItems = ShoppingCart.Items.Where(i => i.Type == ShoppingCartItemType.AutoOrder || i.Type == ShoppingCartItemType.EnrollmentAutoOrderPack).ToList(); var autoOrderPaymentType = AutoOrderPaymentType.PrimaryCreditCard; // Create initial order var orderRequest = new CreateOrderRequest(OrderConfiguration, PropertyBag.ShipMethodID, orderItems, shippingAddress); // Add order request now if we need to do any testing with the accepted functionality apiRequests.Add(orderRequest); if (PropertyBag.PaymentMethod.CanBeParsedAs <BankAccount>()) { var bankAccount = PropertyBag.PaymentMethod.As <BankAccount>(); if (bankAccount.Type == ExigoService.BankAccountType.New) { apiRequests.Add(new DebitBankAccountRequest(bankAccount)); } else { apiRequests.Add(new DebitBankAccountOnFileRequest(bankAccount)); } } // Create subscription autoorder if an autoorder has been chosen if (autoOrderItems != null && autoOrderItems.Count() > 0) { var autoOrderRequest = new CreateAutoOrderRequest(AutoOrderConfiguration, autoOrderPaymentType, DateTime.Now.AddMonths(1).ToCST(), PropertyBag.ShipMethodID, autoOrderItems, shippingAddress); autoOrderRequest.Frequency = FrequencyType.Monthly; apiRequests.Add(autoOrderRequest); } // Create customer site var customerSiteRequest = new SetCustomerSiteRequest(PropertyBag.Customer); apiRequests.Add(customerSiteRequest); // Add the new credit card to the customer's record and charge it for the current order if (PropertyBag.PaymentMethod.CanBeParsedAs <CreditCard>()) { var creditCard = PropertyBag.PaymentMethod.As <CreditCard>(); if (!creditCard.IsTestCreditCard && !Request.IsLocal) { var saveCCRequest = new SetAccountCreditCardTokenRequest(creditCard); apiRequests.Add(saveCCRequest); var chargeCCRequest = new ChargeCreditCardTokenRequest(creditCard); apiRequests.Add(chargeCCRequest); } else { orderRequest.OrderStatus = GlobalUtilities.GetDefaultOrderStatusType(); } } // Process the transaction var transaction = new TransactionalRequest { TransactionRequests = apiRequests.ToArray() }; var response = ExigoDAL.WebService().ProcessTransaction(transaction); var newcustomerid = 0; var neworderid = 0; var newautoorderid = 0; if (response.Result.Status == ResultStatus.Success) { foreach (var apiresponse in response.TransactionResponses) { if (apiresponse.CanBeParsedAs <CreateCustomerResponse>()) { newcustomerid = apiresponse.As <CreateCustomerResponse>().CustomerID; } if (apiresponse.CanBeParsedAs <CreateOrderResponse>()) { neworderid = apiresponse.As <CreateOrderResponse>().OrderID; } if (apiresponse.CanBeParsedAs <CreateAutoOrderResponse>()) { newautoorderid = apiresponse.As <CreateAutoOrderResponse>().AutoOrderID; } } } ///If Binary Place Node Now if (GlobalSettings.Exigo.UseBinary) { var placeNodeRequest = new PlaceBinaryNodeRequest { CustomerID = newcustomerid, ToParentID = PropertyBag.EnrollerID, PlacementType = BinaryPlacementType.EvenFill }; ExigoDAL.WebService().PlaceBinaryNode(placeNodeRequest); } PropertyBag.NewCustomerID = newcustomerid; PropertyBag.NewOrderID = neworderid; PropertyBag.NewAutoOrderID = newautoorderid; _propertyBag = ExigoDAL.PropertyBags.Update(PropertyBag); // If the transaction was successful, then send the customer an email that will allow them to confirm thier opt in choice if (PropertyBag.Customer.IsOptedIn) { ExigoDAL.SendEmailVerification(newcustomerid, PropertyBag.Customer.Email); } var token = Security.Encrypt(new { CustomerID = newcustomerid, OrderID = neworderid, AutoOrderID = newautoorderid }); // Enrollment complete, now delete the Property Bag ExigoDAL.PropertyBags.Delete(PropertyBag); ExigoDAL.PropertyBags.Delete(ShoppingCart); return(new JsonNetResult(new { success = true, token = token })); } catch (Exception exception) { PropertyBag.OrderException = exception.Message; PropertyBag.IsSubmitting = false; _propertyBag = ExigoDAL.PropertyBags.Update(PropertyBag); return(new JsonNetResult(new { success = false, message = exception.Message })); } } else { if (PropertyBag.NewCustomerID > 0) { var token = Security.Encrypt(new { CustomerID = PropertyBag.NewCustomerID, OrderID = PropertyBag.NewOrderID, AutoOrderID = PropertyBag.NewAutoOrderID }); return(new JsonNetResult(new { success = true, token = token })); } else { return(new JsonNetResult(new { success = false, message = Resources.Common.YourOrderIsSubmitting })); } } }
/// <remarks/> public void ChargeCreditCardTokenAsync(ChargeCreditCardTokenRequest ChargeCreditCardTokenRequest) { this.ChargeCreditCardTokenAsync(ChargeCreditCardTokenRequest, null); }
private ChargeCreditCardTokenRequest Request_ChargeNewCreditCard() { ChargeCreditCardTokenRequest request = new ChargeCreditCardTokenRequest(); request.CreditCardToken = NewCreditCardPaymentToken; request.BillingName = Shopping.PropertyBag.CreditCardNameOnCard; request.BillingAddress = Shopping.PropertyBag.CreditCardBillingAddress; request.BillingCity = Shopping.PropertyBag.CreditCardBillingCity; request.BillingState = Shopping.PropertyBag.CreditCardBillingState; request.BillingZip = Shopping.PropertyBag.CreditCardBillingZip; request.BillingCountry = Shopping.PropertyBag.CreditCardBillingCountry; return request; }