Debit and credit card recognition  |  Google Pay API for Android  |  Google for Developers (2024)

  • Home
  • Products
  • Google Pay
  • Payment Card Recognition
  • Google Pay for Payments
  • Android
Stay organized with collections Save and categorize content based on your preferences.

The Google payment card recognition API provides the ability to use a camera to recognize information from payment cards. The API supports recognition of the primary account number (PAN) and the expiration date from a credit card or a debit card through optical character recognition (OCR). The API delegates the task of scanning the card to Google Play services. Therefore, your app doesn't need to request camera permission and only receives the scan results. All image processing occurs on the device and Google doesn't store the results or share the image data.

To ensure the optimal user experience and functionality, the API has the following constraints:

  • The device has a Google account logged in.
  • The device has at least 1GB of RAM.
  • The device has a back facing camera.
  • The device has the latest Google Play services version.
  • The device supports PORTRAIT orientation.

Create a request

Create a PaymentsClient instance in the onCreate method in your Activity. You can use PaymentsClient to interact with the Google Pay API.

Kotlin

 fun createPaymentsClient(activity: Activity): PaymentsClient { val walletOptions = Wallet.WalletOptions.Builder() .setEnvironment(Constants.PAYMENTS_ENVIRONMENT) .build() return Wallet.getPaymentsClient(activity, walletOptions) }

Java

 public static PaymentsClient createPaymentsClient(Activity activity) { Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder().setEnvironment(Constants.PAYMENTS_ENVIRONMENT).build(); return Wallet.getPaymentsClient(activity, walletOptions); }

After you create the response, you can then send an asynchronous request for a PendingIntent, which you can use to start the payment card recognition activity.

Keep in mind that the request doesn't always succeed. If there is no API enablement, the request fails. We suggest that you adjust your app's behavior according to the response to the request. In the sample app, we display the button only after we receive a successful response.

Kotlin

 private fun possiblyShowPaymentCardOcrButton() { // The request can be used to configure the type of the payment card recognition. Currently // the only supported type is card OCR, so it is sufficient to call the getDefaultInstance() // method. val request = PaymentCardRecognitionIntentRequest.getDefaultInstance() paymentsClient .getPaymentCardRecognitionIntent(request) .addOnSuccessListener { intentResponse -> cardRecognitionPendingIntent = intentResponse.paymentCardRecognitionPendingIntent paymentCardOcrButton.visibility = View.VISIBLE } .addOnFailureListener { e -> // The API is not available either because the feature is not enabled on the device // or because your app is not registered. Log.e(TAG, "Payment card ocr not available.", e) } }

Java

 public void possiblyShowPaymentCardOcrButton() { // The request can be used to configure the type of the payment card recognition. Currently the // only supported type is card OCR, so it is sufficient to call the getDefaultInstance() method. PaymentCardRecognitionIntentRequest request = PaymentCardRecognitionIntentRequest.getDefaultInstance(); paymentsClient .getPaymentCardRecognitionIntent(request) .addOnSuccessListener(intentResponse -> { cardRecognitionPendingIntent = intentResponse.getPaymentCardRecognitionPendingIntent(); paymentCardOcrButton.setVisibility(View.VISIBLE); }) .addOnFailureListener(e -> { // The API is not available either because the feature is not enabled on the device // or because your app is not registered. Log.e(TAG, "Payment card ocr not available.", e); }); }

To start the payment card recognition activity, use the following code sample:

Kotlin

 private fun startPaymentCardOcr() { try { ActivityCompat.startIntentSenderForResult( this@CheckoutActivity, cardRecognitionPendingIntent.intentSender, PAYMENT_CARD_RECOGNITION_REQUEST_CODE, null, 0, 0, 0, null ) } catch (e: SendIntentException) { throw RuntimeException("Failed to start payment card recognition.", e) } }

Java

 public void startPaymentCardOcr(View view) { try { ActivityCompat.startIntentSenderForResult( CheckoutActivity.this, cardRecognitionPendingIntent.getIntentSender(), PAYMENT_CARD_RECOGNITION_REQUEST_CODE, null, 0, 0, 0, null); } catch (SendIntentException e) { throw new RuntimeException("Failed to start payment card recognition.", e); } }

Interpret the result

During the recognition process, our algorithm attempts to recognize the payment card. If it successfully recognizes a result, then the API returns the result as a PaymentCardRecognitionResult. The result always contains a card number. The expiration date might not be present if the algorithm fails to detect one, or if the date shows that the card is past its expiration date. For various reasons, a card might not be recognizable. This usually results when a user cancels a flow and the API returns Activity.RESULT_CANCELLED.

Kotlin

 private fun handlePaymentCardRecognitionSuccess( cardRecognitionResult: PaymentCardRecognitionResult ) { val creditCardExpirationDate = cardRecognitionResult.creditCardExpirationDate val expirationDate = creditCardExpirationDate?.let { "%02d/%d".format(it.month, it.year) } val cardResultText = "PAN: ${cardRecognitionResult.pan}\nExpiration date: $expirationDate" Toast.makeText(this, cardResultText, Toast.LENGTH_LONG).show() }

Java

 private void handleCardRecognitionSuccess(PaymentCardRecognitionResult cardResult) { String expirationDate = null; Locale locale = Locale.getDefault(); CreditCardExpirationDate cardExpirationDate = cardResult.getCreditCardExpirationDate(); if(cardExpirationDate != null) { expirationDate = String.format(locale, "%02d/%d", cardExpirationDate.getMonth(), cardExpirationDate.getYear()); } String cardResultString = String.format(locale, "PAN: %s\nExpiration date: %s", cardResult.getPan(), expirationDate); Toast.makeText(this, cardResultString, Toast.LENGTH_LONG).show(); }

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-09-13 UTC.

Debit and credit card recognition  |  Google Pay API for Android  |  Google for Developers (2024)

FAQs

Can I use debit card for Google developer account? ›

You can pay for your Google developer account registration through GPay or using your credit or debit card. Prepaid cards are not accepted. The type of cards accepted may vary by location. After making payment, a pop-up will appear confirming that you have created your Google Developer account.

Is the Google Pay API free? ›

Does Google Pay charge any fees? Google Pay doesn't additionally charge users, merchants, and developers additional fees to use the Google Pay API for payments. Merchants, specifically, continue to pay processing fees to their payment processor.

How to create a Google Pay developer account? ›

Register for a Google Play Developer account
  1. Step 1: Sign up for a Play Console developer account.
  2. Step 2: Accept the Developer Distribution Agreement.
  3. Step 3: Pay registration fee.
  4. Step 4: Choose a developer account type.
  5. Step 5: Verify your developer identity information.

Is Google Pay PCI compliant? ›

PCI compliance

Google Payment Corp. is both a Level 1 Merchant and a Service Provider, and therefore undergoes an annual assessment by an external Qualified Security Assessor (QSA). Our Attestation of Compliance is produced by the QSA and reported to the major card brands and our acquiring banks.

Can you set up Google Pay with a debit card? ›

You can add, remove, or update your credit and debit cards in your Google Pay account. Important: The “Add credit or debit cards'' feature is available for Android devices only. If you can't find this option, update your Google Pay app. Learn more about supported cards and payment modes.

How do I withdraw money from my Google developer account? ›

First, you'll create a payment profile under Merchant Account in Settings. There, you will enter information about yourself relative to the business. Next, you will be asked to provide banking account information through the console to receive the payout from Google (under Payment Settings).

Does Google API need credit card? ›

Some Google APIs charge for usage, and you need to enable billing before you can start using these APIs. Enabling billing for the APIs that your projects use also has other advantages: Some APIs allow free usage up to a courtesy usage limit, and in some cases this free limit is increased when you enable billing.

Which Google APIs are free? ›

All use of Google Search Console API is free of charge.

Does it cost money to use Google APIs? ›

API Keys is free of charge. If you use Cloud Endpoints to manage your API, you might incur charges at high traffic volumes.

How to use Google Pay on Android? ›

Hold your Android device near the card reader and wait for the checkmark. Pay with your default card or select another. Google Pay will handle the rest. Order free stickers for your business to let customers know you accept Google Pay.

Is Google Pay built into Android? ›

To pay in stores using your phone, you'll need to make sure Google Pay is downloaded and set up on your phone first. Get the Google Pay app on your Android phone. It only takes a few minutes to set up Google Pay on your phone. You'll need your credit or debit card info handy to get the app set up.

How do I make my own Google Pay? ›

Get the Google Pay app

Download Google Pay on phones running Android versions 6+. Enter your phone number. Sign in with your Google Account. Follow the instructions to secure your Google Pay app and add a bank account.

Is Google Pay safe for debit cards? ›

Is Google Wallet safe? Security and privacy are built into every part of Google Wallet to keep all your essentials protected. When you tap to pay with your Android phone, Google Pay doesn't share your real credit card number with the business, so your payment info stays safe. What is Google Wallet used for?

Which card type is not accepted in Google Pay? ›

Try another credit card (not a debit card)

Due to issues with the 3D Secure verification service, we can't accept Indian debit cards for automatic payments at this time. We also can't accept certain Indian credit cards. If your card is being rejected, try another credit card.

Which bank does Google Pay use? ›

Supported banks
Bank or companyNetwork providerCard type
Federal BankMastercardDebit card
VISADebit card
Credit (OneCard BIN only)
HDFC BankMastercardCredit card
33 more rows

Does Google accept debit cards? ›

You don't need to add money to Google Pay in order to pay. All you need to do is add a payment method, like a debit or credit card. When you use Google Pay, it's just like how you would normally use your card.

Can I use debit card for Google cloud? ›

In many countries, you can set up a credit card, debit card, or bank account as a primary payment method. You can also set up a backup credit or debit card to act as a safety net; if your primary payment method fails, we'll charge your costs to your backup payment method.

Is it safe to add debit card to Google Account? ›

Google Pay is secure. When you add a card, your card details are replaced with a virtual account number. Your card details are not stored on the device or disclosed and transmitted when you make a payment with Google Pay.

How to pay developer registration fee? ›

2 Answers. There is a US$25 one-time registration fee that you can pay using either a debit card or credit card. The cards which are accepted by Google Play Console are Visa, American Express, Mastercard, etc. but prepaid cards are not accepted depending on where you are (location).

Top Articles
Cross-Currency Swap: Definition, How It Works, Uses, and Example
Community Review of IXL | Common Sense Education
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 6656

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.