Shopify / mobile-buy-sdk-android

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.
MIT License
214 stars 136 forks source link

checkoutCreate response is null. #566

Closed Networld301 closed 5 years ago

Networld301 commented 6 years ago

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());
            }
        });
rebeccajfriedman commented 5 years ago

Are you still experiencing this issue?

rebeccajfriedman commented 5 years ago

Closing this issue due to inactivity.

fabritronixdesignlabs commented 3 years ago

Still i am facing same issue

PeOS-China commented 1 year ago

Still i am facing same issue, My shop is test mode