Google’s java SDK for interacting with the checkout API is not a fun experience. It’s generated from the WSDL using JAXB which has a unique ability to generate client interfaces that no human could ever “design”.
It’s not actually that hard to write code with, you just have to think like a deranged machine.
By default, the only allowed shipping destination will be your country. If you wish to allow worldwide shipping, you have to do something like this:
ApiContext apiContext = new ApiContext(environment, "yourMerchantId", "yourMerchantKey", "GBP"); CheckoutShoppingCartBuilder cartBuilder = apiContext.cartPoster().makeCart(); CheckoutShoppingCart cart = cartBuilder.build(); FlatRateShipping frs = new FlatRateShipping(); frs.setName("flat rate"); ShippingRestrictions shippingRestrictions = new ShippingRestrictions(); AllowedAreas allowedAreas = new AllowedAreas(); allowedAreas.getUsStateAreaOrUsZipAreaOrUsCountryArea().add(new WorldArea()); shippingRestrictions.setAllowedAreas(allowedAreas); frs.setShippingRestrictions(shippingRestrictions); ...
I just posted this because I could not find one example on the internet. Crazy I know, but now there is one.