OpenCart has now a built-in REST-API. Here you can get a Java API which provides functions for all REST-Calls of this built-in REST-API.
The API provides:
- Android support
- Data transfer objects
- Error handling
- and more...
Please visit http://opencartjavaapi.weberinformatics.com/ for the details of the API.
Examples of usage:
APIProperties.SHOP_URL = "yourshop.com";
LoginService login = new LoginService();
//you have to specify it in opencart backend
login.login("yourAPIusername", "yourAPIpassword");
CartService cart = new CartService();
OCResult result = cart.addProduct(46, 2.0, null);
OCProducts products = cart.listProducts();
cart.editProduct(products.getProducts().get(0).getKey(), 55.0);
cart.listProducts();
cart.removeProduct(products.getProducts().get(0).getKey());
cart.listProducts();
cart.addProduct(46, 2.0, null);
CouponService coupon = new CouponService();
result = coupon.redeemCoupon("2222");
CustomerService customer = new CustomerService();
customer.modifyCustomer(null, "Peter", "Mayer", "info@mail.com", "07122", null, "customfield", "784512");
PaymentService payment = new PaymentService();
payment.setPaymentAdress("Werner", "Kerner", "Servus Str. 77", "123123", "1234", "stuttgart", 1, 1);
OCPaymentMethods paymentMethods = payment.initPaymentMethods();
payment.setPaymentMethod("cod");
ShippingService shipping = new ShippingService();
shipping.setShippingAddress("werner", "kerner", "Dorf Str. 77", null, "55555", "Berlin", 1, 1, "customfield", "Weber Informatics LLC");
OCShippingMethods shippingMethods = shipping.initShippingMethods();
shipping.setShippingMethod("flat.flat");
OrderService order = new OrderService();
OCOrder orderresult = order.addOrder("flat.flat", "my comment", null, 1);
result = order.editOrder(orderresult.getOrder_id(), "flat.flat", "my other comment", null, 1);
order.addOrderHistory(orderresult.getOrder_id(), 1, "history comment", true);
result = order.deleteOrder(orderresult.getOrder_id());
RewardService reward = new RewardService();
reward.showRewardMaximum();
result = reward.redeemReward(10);
reward.showRewardAvailable();
VoucherService voucher = new VoucherService();
voucher.addVoucher("Peter", "peter@aol.com", "Werner", "werner@aol.com", 1, 55.0);
voucher.redeemVoucher("123");
Login and write down your comment.
Login my OpenCart Account