Saboor880 9 Junior Poster

Hello to all! Hope you are fine. I am developing an e-commerce android app and integrating Stripe payment gateway in it and using Google Fire base as real time database.

I browsed the official website of stripe and took the source code from there. I used my test key from there. I successfully generated Stripe Token and saved it on my server (i-e Fire base). But I am unable to make an actual charge by using that token. That means no transaction shows on my stripe account. I am pasting my code, guide me what should i do to create/make charge?

Card cardToSave = cardInputWidget.getCard();
               if (cardToSave == null) {
                  Toast.makeText(getActivity(),"Invalid Card Data",Toast.LENGTH_LONG).show();

               }
               else{

                   Stripe stripe = new Stripe(MainActivity.mcont,
               "pk_test_XZFc6CW7wmDMl4WWESxtvWd300ibs1wr85");

                         stripe.createToken(
                           cardToSave,
                           new TokenCallback() {
                               public void onSuccess(final Token token) {
                                   // Send token to your server
                                   customer_ref =
                              database.getReference("Customers").child(MainActivity.user.getUid());
                                    final String tokenid = token.getId();

                                             //saving the tokenID on my server(i-e fiebase)

                                           final Map<String, Object> params = new HashMap<>();
                                           params.put("amount", paid);
                                           params.put("currency", "usd");
                                           params.put("description", "Example charge");
                                           params.put("source", tokenid);

                                           HashMap map = new HashMap();
                                           map.put("StripeToken",tokenid);
                                           customer_ref.updateChildren(map);

                                           try {
                                               // creating charge object
                                               Charge charge = Charge.create(params);

                                           } catch (AuthenticationException e) {
                                               e.printStackTrace();
                                           } catch (InvalidRequestException e) {
                                               e.printStackTrace();
                                           } catch (APIConnectionException e) {
                                               e.printStackTrace();
                                           } catch (CardException e) {
                                               e.printStackTrace();
                                           } catch (APIException e) {
                                               e.printStackTrace();
                                           }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.