Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
Hi,
I am new to Shopify and I am developing an android app using Shopify storefront ,
I integrated the checkoutCreate SDK but the response is always null.
Below is my code
ArrayList<Storefront.CheckoutLineItemInput> arrCheckout = new ArrayList<>();
for (int i = 0; i < shops.size(); i++) {
int quantity = Integer.parseInt(shops.get(i).getQty());
String VariantID = shops.get(i).getPrdid();
String Variant = ("gid://shopify/ProductVariant/" + VariantID);
byte[] data = new byte[0];
try {
data = Variant.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String VariantID64 = Base64.encodeToString(data, Base64.DEFAULT);
Storefront.CheckoutLineItemInput item = new Storefront.CheckoutLineItemInput(quantity, new ID(VariantID64));
arrCheckout.add(item);
}
Storefront.CheckoutCreateInput input = new Storefront.CheckoutCreateInput()
.setLineItemsInput(Input.value(arrCheckout));
Storefront.MutationQuery query = Storefront.mutation(mutationQuery -> mutationQuery
.checkoutCreate(input, createPayloadQuery -> createPayloadQuery
.checkout(checkoutQuery -> checkoutQuery
.webUrl()
.totalPrice()
.subtotalPrice()
)
.userErrors(userErrorQuery -> userErrorQuery
.field()
.message()
)
)
);
graphClient.mutateGraph(query).enqueue(new GraphCall.Callback<Storefront.Mutation>() {
@Override
public void onResponse(@NonNull GraphResponse<Storefront.Mutation> response) {
if (response.data()==null) {
Log.e("response, "checkout null");
} else {
String checkoutId = response.data().getCheckoutCreate().getCheckout().getId().toString();
String checkoutWebUrl = response.data().getCheckoutCreate().getCheckout().getWebUrl();
}
}
@Override
public void onFailure(@NonNull GraphError error) {
// handle errorscheckoutWebUrl
Log.e("error", error.getMessage().toString());
}
});
Hi, I am new to Shopify and I am developing an android app using Shopify storefront , I integrated the checkoutCreate SDK but the response is always null. Below is my code