//A number of you (and outside direct forum) have requested details on
the intent call for the Single-Click Checkout in-app payment service.
Sample code provided below.   Feel free to drop me a note with any
questions.  [email protected]



static final int TRANSACTION_CANCELLED = 0;
static final int TRANSACTION_FAILED = 1;
static final int TRANSACTION_SUCCESS = 2;

      static final String SHORT_CODE = "short_code";

/*
      * Launch the Single Click Checkout Approve Intent -- Start a
Transaction
      */
      private OnClickListener button_click = new OnClickListener()
      {
            public void onClick(View v)
            {
                  // Update the text box
 
text.setText(text.getText().toString().concat("\nAttempting purchase
using short code: " + SHORT_CODE));

                  // Create a new intent to launch the checkout screen
                  Intent checkout_intent = new Intent();

                  // Let this intent know that you want to call the
                  // SingleClick checkout
                  checkout_intent.setComponent(new
ComponentName("com.billingrevolution.singleclick.checkout",
"com.billingrevolution.singleclick.checkout.Approve"));

                  // The only required option is a short-code link or
ID
                  checkout_intent.putExtra("short_code", SHORT_CODE);

                  // Additional optional details are supplied.
                  checkout_intent.putExtra("mtid", "abczyx");
                  checkout_intent.putExtra("mcid", "098hjk");

                  // Try to collect funds from the user
                  try
                  {
                        // We use *ForResult so that our
onActivityResult handler gets called once the transaction is complete
                        startActivityForResult(checkout_intent, 1);
                  }
                  catch (ActivityNotFoundException e)
                  {
                        // SCC not installed, fail back to browser
based checkout
                        startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://singleclick.mobi/"; + SHORT_CODE)));
                  }
            }
      };

      /*
      * This is the callback routine that gets called by Single Click
Checkout after the transaction has completed.
      */
      @Override
      protected void onActivityResult(int requestCode, int resultCode,
Intent data)
      {
            switch (resultCode)
            {
                  case TRANSACTION_CANCELLED:
 
text.setText(text.getText().toString().concat("\nReturned Status:
CANCELLED"));
                        break;

                  case TRANSACTION_FAILED:
 
text.setText(text.getText().toString().concat("\nReturned Status:
FAILED"));
                        break;

                  case TRANSACTION_SUCCESS:
 
text.setText(text.getText().toString().concat("\nReturned Status:
SUCCESS"));
                        break;

                  default:
                        break;
            }
      }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to