Question

I am creating an Android application that will offer users a subscription option if the user has his credit card information stored in their device. If he does not, I am thinking about offering different methods for the user to use the application.

Does anyone know if there is a way to check if a user has his credit card information stored in their device?

To clarify what I am looking for:

Android devices allow users to store credit card information so they don't have to re-enter the information for every purchase. I'm talking about identifying that the user has that data stored. I am not talking about storing that information myself for the user or trying to get it. All I need is a boolean method that will tell me if the user has the data stored or something similar.

Was it helpful?

Solution

Credit Card information isn't really stored "on the device." In the case of devices that are connected to the Play Store, Google account credentials are stored and payments are made through Google Wallet. I don't have a lot of experience with other types of devices, but I imagine they all work in a similar fashion, for example a Kindle Fire will keep Amazon account credentials, etc.

If you're looking to create an application that provides in-app purchases and will be available on the Play Store, you can click here to read about Google's In-App Billing API that allows your users to use their Google Wallet to make payments. For Kindle Devices, Amazon has a similar API.

It would be a pretty major security concern if arbitrary apps had access to the device owner's credit card information. If you're writing an app that you intend to distribute outside of a reputable app store and therefore without a built-in in-app purchase api, you're going to have to use your own payment mechanism. If this is the case, I wouldn't recommend creating your own. I believe PayPal has an Android API, and a quick Google search came up with a few other less notable brands that offer this service, though if you do intend to use the Play Store or Amazon's app store, using a 3rd party payment API usually goes against their terms of service.

Edit: The AccountManager class allows you to view info about accounts on the device, however, I don't believe that you can use it to discover if the user has a payment method set up through Google Wallet. I found this SO question that goes into detail about what the AccountManager can be used for. If this is a Play Store app, I'd look into the Google In-App Billing API, it's probably the best option for what you're trying to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top