title: Stripe Integration in Android, what to do after?
body: <p>I'm developing a credit card payment using Stripe. After creating a Token (which I've done yet), I don't know how to go on.</p>
  <p>Official documentation says:</p>
  <blockquote>
  <p><strong>Using tokens</strong></p>
  <p>Using the payment token, however it was obtained, requires an API call from your server using your secret API key. (For security purposes, you should never embed your secret API key in your app.)
  Set up an endpoint on your server that can receive an HTTP POST call for the token. In the onActivityResult method (for Android Pay) or the onSuccess callback (when using your own form), you’ll need to POST the supplied token to your server. Make sure any communication with your server is SSL secured to prevent eavesdropping.
  Take a look at the full example application to see everything put together.</p>
  </blockquote>
  <p>And my code is:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public class FragmentThree extends Fragment {
  
      private static final String TAG = "FragmentThree";
      //Stripe
      private Card card;
  
      private TextView mResponse;
      private Button mPaymentBtn;
      private ProgressBar mProgressBar;
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.fragment_three, container, false);
  
          return view;
      }
  
      @Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          setRetainInstance(true);
  
          mResponse = (TextView) getActivity().findViewById(R.id.response);
          mPaymentBtn = (Button) getActivity().findViewById(R.id.paymentBtn);
          mProgressBar = (ProgressBar)getActivity().findViewById(R.id.progressBar);
  
          mPaymentBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  mProgressBar.setVisibility(View.VISIBLE);
                  if(isNetworkAvailable()){
  
                      String cardNumber = "4242-4242-4242-4242";
                      int cardExpMonth = 12;
                      int cardExpYear = 2018;
                      String cardCVC = "123";
  
                      card = new Card( //We create a new Card
                              cardNumber,
                              cardExpMonth,
                              cardExpYear,
                              cardCVC
                      );
  
                      if (!card.validateCard()){ //The card is not a valid one
  
                          mProgressBar.setVisibility(View.GONE);
                          Toast.makeText(getActivity(), R.string.Not_Valid_Card, Toast.LENGTH_SHORT).show();
                      }else{
  
                          Stripe stripe = null;
  
                          try {
  
                              //TODO Change with LIVE KEY
                              stripe = new Stripe("pk_test_wt0efdvgYxds7CywHYKCqnhX");
  
                          } catch (AuthenticationException e) {
  
                              mProgressBar.setVisibility(View.GONE);
                              Toast.makeText(getActivity(),
                                      R.string.Merchant_Does_Not_Exist, Toast.LENGTH_SHORT).show();
  
                          }
  
                          if(stripe != null){
  
                              stripe.createToken(
                                      card,
                                      new TokenCallback() {
                                          public void onSuccess(Token token) {
                                              // Send token to your server
  
                                              Log.d(TAG, "The token number is: " + token.getId());
                                              mProgressBar.setVisibility(View.GONE);
                                          }
                                          public void onError(Exception error) {
                                              // Show localized error message
                                              Toast.makeText(getActivity(),
                                                      error.getLocalizedMessage(), Toast.LENGTH_LONG).show();
  
                                              mProgressBar.setVisibility(View.GONE);
                                          }
                                      }
                              );
                          }
  
  
                      }
                  }else{
  
                      mProgressBar.setVisibility(View.GONE);
                      Toast.makeText(getActivity(),
                              R.string.No_Internet_Connection, Toast.LENGTH_SHORT).show();
                  }
              }
          });
  
  
      }
  
      private boolean isNetworkAvailable() {
          ConnectivityManager connectivityManager
                  = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
          return activeNetworkInfo != null &amp;&amp; activeNetworkInfo.isConnected();
      }
  }</code></pre>
  </div>
  </div>
  </p>
  <p>How to let a Server (which I don't own) know about my Token? And what to do after that? How to make an API call from the Server or Firebase?
  I can use Firebase: Do I have to use It? And what do I have to implement there?</p>
  <p>Server side, for me, represents a problem.</p>
  <p>Can someone write me a step by step implementation so that I Know how to handle tokens and what i can do next?</p>
  <p>And how to be sure about SSL Security?</p>
  <p>Sorry for my questions but I never did It before.</p>
  <p>Thank you, Gaetano</p>