public void _001_TestApiAuthorization() { try { var Service = new ChargeService(); var Option1 = new AuthLineitemOption(); Option1.optName = "Test Option 1"; Option1.optValue = "Large"; Option1.optSurcharge = (decimal)1.00; var Options = new List <AuthLineitemOption>(); Options.Add(Option1); var LineItem1 = new AuthLineitem(); LineItem1.name = "test item"; LineItem1.price = (decimal)10.00; LineItem1.quantity = 1; LineItem1.options = Options; var Lineitems = new List <AuthLineitem>(); Lineitems.Add(LineItem1); var Billing = new AuthBillingAddress(); Billing.addrLine1 = "123 test st"; Billing.city = "Columbus"; Billing.zipCode = "43123"; Billing.state = "OH"; Billing.country = "USA"; Billing.name = "Testing Tester"; Billing.email = "*****@*****.**"; Billing.phoneNumber = "5555555555"; var Shipping = new AuthShippingAddress(); Shipping.addrLine1 = "123 test st"; Shipping.city = "Columbus"; Shipping.state = "OH"; Shipping.country = "USA"; Shipping.name = "Testing Tester"; var Sale = new ChargeAuthorizeServiceOptions(); Sale.lineItems = Lineitems; Sale.currency = "USD"; Sale.merchantOrderId = "123"; Sale.billingAddr = Billing; Sale.shippingAddr = Shipping; Sale.token = token; var Charge = new ChargeService(); var result = Charge.Authorize(Sale); Assert.IsInstanceOf <Authorization>(result); } catch (TwoCheckoutException e) { Assert.IsInstanceOf <TwoCheckoutException>(e); } }
static void Main(string[] args) { TwoCheckoutConfig.SellerID = "901288242"; TwoCheckoutConfig.PrivateKey = "80D02EA2-4847-4AC0-9E11-77B50CDFBB97"; TwoCheckoutConfig.Sandbox = true; //<-- Set Mode to use your 2Checkout sandbox account System.Console.Write("Enter cc token:"); var token = System.Console.ReadLine();; try { var Billing = new AuthBillingAddress(); Billing.addrLine1 = "123 test st"; Billing.city = "Columbus"; Billing.zipCode = "43123"; Billing.state = "OH"; Billing.country = "USA"; Billing.name = "Testing Tester"; Billing.email = "*****@*****.**"; Billing.phoneNumber = "5555555555"; var Customer = new ChargeAuthorizeServiceOptions(); Customer.total = (decimal)1.00; Customer.currency = "USD"; Customer.merchantOrderId = "123"; Customer.billingAddr = Billing; Customer.token = token; Customer.lineItems = new List <AuthLineitem>(); Customer.lineItems.Add(new AuthLineitem { price = 1, name = "Baygon", productId = "5567", type = "product", // TODO: this should be passed in from outside. Possible values: ‘product’, ‘shipping’, ‘tax’ or ‘coupon’ quantity = 1 // TODO: this should be passed in from outside. Possible values: 1-999 }); var Charge = new ChargeService(); var result = Charge.Authorize(Customer); System.Console.Write("[INFO] - Charging is success. Response code: " + result.responseCode + ", message: " + result.responseMsg); } catch (TwoCheckoutException e) { System.Console.Write("[ERROR] - Charing is failed. Exception: " + e.Message); } }
public PaymentGatewayResponse CheckOutTwoCheckOut(ChargeAuthorizeServiceOptions charge) { TwoCheckoutConfig.SellerID = ConfigurationManager.AppSettings["TwoCheckOutSellerId"]; TwoCheckoutConfig.PrivateKey = ConfigurationManager.AppSettings["TwoCheckOutPrivateKey"];; TwoCheckoutConfig.Sandbox = true; var _res = new PaymentGatewayResponse(); try { var Charge = new ChargeService(); var result = Charge.Authorize(charge); _res.amount = result.total; _res.refNo = result.transactionId.ToString(); _res.responseStatus = result.responseCode; _res.message = result.responseMsg; if (charge.total == result.total) { _res.PaymentStatus = "paid"; } else if (charge.total > result.total) { _res.PaymentStatus = "partial"; } return(_res); } catch (Exception ex) { _res.responseStatus = "failed"; _res.message = ex.Message; return(_res); } }
//Pass Order and Buyer to 2Checkout public JsonResult Checkout() { TwoCheckoutConfig.SellerID = "250626767898"; TwoCheckoutConfig.PrivateKey = "77F2977B-F739-49F1-8152-616F5E231313"; //TwoCheckoutConfig.Sandbox = true; <-- Set Mode to use your 2Checkout sandbox account try { var Billing = new AuthBillingAddress(); Billing.addrLine1 = "123 test st"; Billing.city = "Columbus"; Billing.zipCode = "43123"; Billing.state = "OH"; Billing.country = "USA"; Billing.name = "Testing Tester"; Billing.email = "*****@*****.**"; Billing.phoneNumber = "5555555555"; var Customer = new ChargeAuthorizeServiceOptions(); Customer.total = (decimal)1.00; Customer.currency = "USD"; Customer.merchantOrderId = "123"; Customer.billingAddr = Billing; Customer.token = "MzIwNzI3ZWQtMjdiNy00NTVhLWFhZTEtZGUyZGQ3MTk1ZDMw"; var Charge = new ChargeService(); var result = Charge.Authorize(Customer); return(Json(result, JsonRequestBehavior.AllowGet)); } catch (TwoCheckoutException e) { Console.Write(e); return(Json(e.Message, JsonRequestBehavior.AllowGet)); } }
static void Main(string[] args) { TwoCheckoutConfig.SellerID = "901421388"; TwoCheckoutConfig.PrivateKey = "53424946-7352-4966-9245-38A7A1BF4ED9"; //var ServiceObject = new SaleService(); //ServiceObject.List(); //TwoCheckoutConfig.SellerID = "901288242"; //TwoCheckoutConfig.PrivateKey = "80D02EA2-4847-4AC0-9E11-77B50CDFBB97"; TwoCheckoutConfig.Sandbox = true; //<-- Set Mode to use your 2Checkout sandbox account try { var Billing = new AuthBillingAddress(); Billing.addrLine1 = "123 Main Street"; Billing.city = "Townsville"; Billing.zipCode = "43206"; Billing.state = "Ohio"; Billing.country = "USA"; Billing.name = "Joe Flagster"; Billing.email = "*****@*****.**"; Billing.phoneNumber = "5555555555"; var Customer = new ChargeAuthorizeServiceOptions(); Customer.total = (decimal)1.00; Customer.currency = "USD"; Customer.merchantOrderId = "123"; Customer.billingAddr = Billing; Customer.token = "YjFkYjYxZWItNjQ1MS00NWQ0LTg4NDEtMDk0MmYxYmJlN2Vh"; //Customer.lineItems = new System.Collections.Generic.List<AuthLineitem>(); //Customer.lineItems.Add(new AuthLineitem //{ // price = 2, // name = "tetsPro", // productId = "123456", // type = "product", // TODO: this should be passed in from outside. Possible values: ‘product’, ‘shipping’, ‘tax’ or ‘coupon’ // quantity = 1 // TODO: this should be passed in from outside. Possible values: 1-999 //}); var Charge = new ChargeService(); String token = "YjFkYjYxZWItNjQ1MS00NWQ0LTg4NDEtMDk0MmYxYmJlN2Vh"; var Shipping = new AuthShippingAddress(); Shipping.addrLine1 = "123 test st"; Shipping.city = "Columbus"; Shipping.state = "OH"; Shipping.country = "USA"; Shipping.name = "Testing Tester"; var Sale = new ChargeAuthorizeServiceOptions(); Sale.lineItems = Customer.lineItems; Sale.currency = "USD"; Sale.merchantOrderId = "123"; Sale.billingAddr = Billing; Sale.shippingAddr = Shipping; Sale.token = token; Sale.returnUrl = "http://www.2checkout.com/documentation"; var result = Charge.Authorize(Customer); Console.Write(result); } catch (TwoCheckoutException e) { Console.Write(e); } TwoCheckoutConfig.ApiUsername = "******"; TwoCheckoutConfig.ApiPassword = "******"; try { //var ServiceObject = new SaleService(); //ServiceObject.List(); //var ArgsObject = new SaleRefundServiceOptions(); //ArgsObject.invoice_id = invoice_id; //ArgsObject.comment = "test refund"; //ArgsObject.category = 5; //var result = ServiceObject.Refund(ArgsObject); } catch (TwoCheckoutException e) { // read e.message } Console.WriteLine("Hello World!"); }
public ActionResult PaywithCreditCard(UserModel objCard) { TwoCheckoutConfig.SellerID = "901325328"; TwoCheckoutConfig.PrivateKey = "F94D20FF-0DA7-4177-BD6E-B3140DD59326"; TwoCheckoutConfig.Sandbox = true; // Set Mode to use your 2Checkout sandbox account TwoCheckoutConfig.ApiUsername = "******"; TwoCheckoutConfig.ApiPassword = "******"; TwoCheckoutConfig.Demo = true; TwoCheckoutConfig.SecretWord = "Yzc4NzIwZDUtODg0MC00N2YwLTk3MGMtNjk2ZGFhZjVkNGUx"; TwoCheckoutConfig.SandboxUrl = "https://sandbox.2checkout.com/checkout/api/1/" + TwoCheckoutConfig.SellerID + "/rs/authService"; //TwoCheckoutConfig.BaseUrl = "https://www.2checkout.com/checkout/api/1/" + TwoCheckoutConfig.SellerID + "/rs/authService"; var subscriptionDetails = new DataAccess.Subscription(); try { #region Payment Sample Code //var LineItemOptions = new AuthLineitemOption(); //LineItemOptions.optName = "Sample Option"; //LineItemOptions.optSurcharge = (decimal)1.00; //LineItemOptions.optValue = "1"; //var LineItemOptionsList = new List<AuthLineitemOption>(); //LineItemOptionsList.Add(LineItemOptions); var Items = new AuthLineitem(); Items.name = objCard.PlanName; //Items.options = LineItemOptionsList; Items.price = Convert.ToDecimal(objCard.Amount); Items.productId = "123"; Items.quantity = 1; Items.type = "product"; Items.recurrence = "N"; Items.tangible = "N"; var ItemsList = new List <AuthLineitem>(); ItemsList.Add(Items); var user = this._userRepository.Find(x => x.UserId == UserId).FirstOrDefault(); var Shipping = new AuthShippingAddress(); var Billing = new AuthBillingAddress(); Billing.addrLine2 = user.Address; Billing.addrLine1 = user.Address; Billing.city = user.Address; Billing.zipCode = user.PinCode; Billing.state = Enum.GetName(typeof(Core.States), user.State); Billing.country = Enum.GetName(typeof(Core.States), user.State); Billing.name = user.FirstName + " " + user.LastName; Billing.email = user.Email; Billing.phoneNumber = user.MobileNumber; #endregion End of Region var Auth = new ChargeAuthorizeServiceOptions(); Auth.currency = "USD"; Auth.merchantOrderId = "456"; Auth.token = objCard.token; Auth.total = (decimal)Convert.ToDecimal(objCard.Amount); Auth.billingAddr = Billing; Auth.lineItems = ItemsList; //Auth.shippingAddr = Shipping; var Charge = new ChargeService(); var result = Charge.Authorize(Auth); subscriptionDetails.Status = result.responseCode == "APPROVED" ? true : false; subscriptionDetails.ReferenceNumber = result.orderNumber.ToString(); SubscriptionStatus(objCard, subscriptionDetails); TempData["IsSucess"] = true; } catch (TwoCheckoutException e) { subscriptionDetails.Status = false; SubscriptionStatus(objCard, subscriptionDetails); TempData["IsSucess"] = false; } return(RedirectToAction("CardDetails", "Account")); }