Button payButton = findViewById(R.id.payButton);
WeakReference weakActivity = new WeakReference<>(this);
payButton.setOnClickListener((View view) -> {
// Get the card details from the card widget
CardInputWidget cardInputWidget = findViewById(R.id.cardInputWidget);
Card card = cardInputWidget.getCard();
if (card != null) {
// Create a Stripe token from the card details
stripe = new Stripe(getApplicationContext(), PaymentConfiguration.getInstance(getApplicationContext()).getPublishableKey());
stripe.createToken(card, new ApiResultCallback() {
@Override
public void onSuccess(@NonNull Token result) {