/** * Attach a listener that creates a token using an {@link android.app.IntentService} and the * synchronous {@link com.stripe.android.Stripe#createTokenSynchronous(Card, string)} method. * * Only gets attached once, unless you call {@link #clearReferences()}. * * @param button a button that, when clicked, gets a token. * @return a reference to the {@link IntentServiceTokenController} */ public IntentServiceTokenController AttachIntentServiceTokenController( AppCompatActivity appCompatActivity, Button button) { if (mIntentServiceTokenController == null) { mIntentServiceTokenController = new IntentServiceTokenController( appCompatActivity, button, mCardInputWidget, mErrorDialogHandler, mListViewController, mProgresDialogController, PUBLISHABLE_KEY); } return(mIntentServiceTokenController); }
/** * Clear all the references so that we can start over again. */ public void ClearReferences() { if (mAsyncTaskController != null) { mAsyncTaskController.Detach(); } if (mRxTokenController != null) { // mRxTokenController.Detach(); } if (mIntentServiceTokenController != null) { mIntentServiceTokenController.Detach(); } mAsyncTaskController = null; mRxTokenController = null; mIntentServiceTokenController = null; }