惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
D
DataBreaches.Net
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
Recent Announcements
Recent Announcements
The Register - Security
The Register - Security
S
Secure Thoughts
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
腾讯CDC
GbyAI
GbyAI
G
Google Developers Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Help Net Security
Help Net Security
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
AI
AI
MongoDB | Blog
MongoDB | Blog
Scott Helme
Scott Helme
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
H
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
S
Security Affairs
TaoSecurity Blog
TaoSecurity Blog
The GitHub Blog
The GitHub Blog
Hacker News: Ask HN
Hacker News: Ask HN
Martin Fowler
Martin Fowler
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI

Google Developers Blog

Expanding Choice in Gemini Enterprise Agent Platform: Introducing Grounding with Parallel Web Search- Google Developers Blog Systems Engineering Playbook: Optimizing Qwen 3.5-397B MoE on Ironwood (TPU7x)- Google Developers Blog Unlocking the Next Era of On-Device AI with Google Tensor and Pixel- Google Developers Blog LiteRT.js, Google's high performance Web AI Inference- Google Developers Blog Bridging the Domain Gap: AI Race Coach built with Antigravity and Gemini- Google Developers Blog We terminated a TPU mid-training and it recovered in seconds: Introduction to elastic training with MaxText- Google Developers Blog ML Development in VS Code with Google Cloud Power: Workbench Extension Now Available- Google Developers Blog Why we built ADK 2.0- Google Developers Blog Build agentic full-stack apps with Genkit- Google Developers Blog Driving the Agent Quality Flywheel from Your Coding Agent- Google Developers Blog Build reliable multi-agent applications with ADK Go 2.0. Discover our new graph-based workflow engine, built-in human-in-the-loop, and dynamic orchestration- Google Developers Blog Measuring What Matters with Jules- Google Developers Blog Build Cross-Language Multi-Agent Team with Google’s Agent Development Kit and A2A- Google Developers Blog How A2A is Building a World of Collaborative Agents- Google Developers Blog A2UI + MCP Apps: Combining the best of declarative and custom agentic UIs- Google Developers Blog Announcing the Agentic Resource Discovery specification- Google Developers Blog Enhance Security and Trust: New Session Metadata in Sign in with Google- Google Developers Blog Unlocking the Power of the TPU Stack: Introducing our new Developer Hub- Google Developers Blog DiffusionGemma: The Developer Guide Introducing the Google Colab CLI Gemma 4 12B: The Developer Guide Bringing Gemma 4 12B to your Laptop: Unlocking Local, Agentic Workflows with Google AI Edge Supercharge your integration workflow with the Google Pay & Wallet Developer MCP server How the community trained Gemma to "Think" with Tunix and TPUs The latest updates to Google Pay Empowering Service Providers and Hardware Partners with Gemini for Home Announcing ADK for Kotlin and ADK for Android 0.1.0: Building AI Agents on Android and Beyond Blazing fast on-device GenAI with LiteRT-LM One Year of Innovation: Celebrating 100k Members in the Google Cloud x NVIDIA Developer Community All the news from the Google I/O 2026 Developer keynote A Smarter Google AI Edge Gallery: MCP integration, notifications, and session continuity Google Tensor SDK Beta with LiteRT An important update: Transitioning Gemini CLI to Antigravity CLI Accelerating on-device AI: A look at Arm and Google AI Edge optimization Announcing Genkit Middleware: Intercept, extend, and harden your agentic apps Build Long-running AI agents that pause, resume, and never lose context with ADK Supercharging LLM inference on Google TPUs: Achieving 3X speedups with diffusion-style speculative decoding Building with Gemini Embedding 2: Agentic multimodal RAG and beyond Speeding Up AI: Bringing Google Colossus to PyTorch via GCSFS and Rapid Bucket Building real-world on-device AI with LiteRT and NPU Agents CLI in Agent Platform: create to production in one CLI
Enhancing Android Checkout with Dynamic Callbacks in Google Pay
Dominik Mengelt, Nik Heath · 2026-05-26 · via Google Developers Blog

We are excited to bring Express checkout with Google Pay for Android native apps enabling developers to leverage users stored credentials (payment and address) from Google Wallet to streamline their checkout journeys. You will be able to implement familiar callbacks onPaymentDataChanged and onPaymentAuthorized that are already supported on Web now in your Android applications and streamline the checkout funnels. With these callbacks, you can update shipping options, taxes, and total prices dynamically as users interact with the Google Pay sheet, and handle authorization feedback without ever closing the sheet. This is available with play-services-wallet:20.0.0 and onwards.

Why use Dynamic Callbacks?

Dynamic callbacks enable a true "Express Checkout" experience. By moving the Google Pay button upstream to your Product Detail or Cart pages, you can provide the user's shipping address, payment credentials, and contact details all within the Pay sheet.

  • Dynamic Shipping & Taxes: Update shipping methods and calculate tax on-the-fly based on the user's selected address.
  • Upstream Positioning: Place the Pay button earlier in the funnel to drive higher conversion rates.
  • Inline Authorization: Handle transaction authorization and retries directly within the Google Pay interface.

Getting Started

To get started, update your Google Pay dependency in your build.gradle file:

com.google.android.gms:play-services-wallet:20.0.0

Kotlin

Copied

1. Implement the Callback Logic

Extend BasePaymentDataCallbacks to handle the specific events triggered during the checkout process.

import com.google.android.gms.wallet.PaymentData
import com.google.android.gms.wallet.callback.BasePaymentDataCallbacks
import com.google.android.gms.wallet.callback.IntermediatePaymentData
import com.google.android.gms.wallet.callback.OnCompleteListener
import com.google.android.gms.wallet.callback.PaymentAuthorizationResult
import com.google.android.gms.wallet.callback.PaymentDataRequestUpdate
import org.json.JSONObject

class MerchantPaymentDataCallbacks : BasePaymentDataCallbacks() {

    /**
     * Handles payment data changes in the payment sheet such as shipping address and shipping options.
     */
    override fun onPaymentDataChanged(
        request: IntermediatePaymentData,
        onCompleteListener: OnCompleteListener<PaymentDataRequestUpdate>
    ) {

        // Example: Process the request and return updates
        // In a real application, you would likely make a network request to your server
        // to get updated shipping options and cart details based on the new address.

        val shippingAddress = request.shippingAddress
        val shippingOptionData = request.shippingOptionData

        // Construct the response object
        val responseJson = JSONObject().apply {
            // Example: Add new shipping options based on the address
            put("newShippingOptionParameters", JSONObject().apply {
                put("defaultSelectedOptionId", "shipping-001")
                put("shippingOptions", JSONObject().apply {
                    put("id", "shipping-001")
                    put("label", "$0.00: Free shipping")
                    put("description", "Free shipping on all orders")
                })
            })

            // Example: Update transaction info
            put("newTransactionInfo", JSONObject().apply {
                put("totalPriceStatus", "FINAL")
                put("totalPrice", "12.34")
                put("currencyCode", "USD")
            })
        }

        val response = PaymentDataRequestUpdate.fromJson(responseJson.toString())
        onCompleteListener.complete(response)
    }

    /**
     * Called when a payment is authorized in the payment sheet.
     */
    override fun onPaymentAuthorized(
        request: PaymentData,
        onCompleteListener: OnCompleteListener<PaymentAuthorizationResult>
    ) {
        // Log the payment data for debugging
        println("onPaymentAuthorized called with PaymentData: ${request.toJson()}")

        // Example: Process the payment authorization
        // In a real application, you would send the payment token and other data
        // to your server to be processed by your payment service provider.

        // Construct the response object
        val responseJson = JSONObject().apply {
            put("transactionState", "SUCCESS") // Or "ERROR"
            // Optionally include an error message
            // put("error", JSONObject().apply {
            //     put("reason", "PAYMENT_DATA_INVALID")
            //     put("intent", "PAYMENT_AUTHORIZATION")
            //     put("message", "Invalid payment method.")
            // })
        }

        val response = PaymentAuthorizationResult.fromJson(responseJson.toString())
        onCompleteListener.complete(response)
    }
}

Kotlin

Copied

2. Host the Callback Service

Implement a service that extends BasePaymentDataCallbacksService to provide an instance of your callbacks.

import androidx.annotation.NonNull
import com.google.android.gms.wallet.callback.BasePaymentDataCallbacks
import com.google.android.gms.wallet.callback.BasePaymentDataCallbacksService

/**
 * Service class which hosts the payment data callbacks.
 */
class MerchantPaymentDataCallbacksService : BasePaymentDataCallbacksService() {

    @NonNull
    override fun createPaymentDataCallbacks(): BasePaymentDataCallbacks {
        return MerchantPaymentDataCallbacks()
    }
}

Kotlin

Copied

3. Update the Android Manifest

You must declare your service and protect it with the BIND_PAYMENTS_CALLBACK_SERVICE permission.

<service
    android:name=".service.MerchantPaymentDataCallbacksService"
    android:permission="com.google.android.gms.permission.BIND_PAYMENTS_CALLBACK_SERVICE"
    android:exported="true">
    <intent-filter>
        <action android:name="com.google.android.gms.wallet.callback.PAYMENT_DATA_CALLBACKS" />
    </intent-filter>
</service>

XML

Copied

4. Configure the Payment Request

Finally, include the callbackIntents in your PaymentDataRequest JSON object to tell Google Pay which events you want to listen for.

{
  "apiVersion": 2,
  "apiVersionMinor": 0,
  ...
  "callbackIntents": [
    "PAYMENT_AUTHORIZATION",
    "SHIPPING_ADDRESS",
    "SHIPPING_OPTION"
  ]
}

JSON

Copied

Takeaways

Implementing dynamic callbacks on Android allows you to:

  • Reduce Friction: Enable a 1-click experience by moving checkout upstream.
  • Increase Accuracy: Provide real-time shipping and tax pricing.
  • Improve Authorization: Handle success or failure feedback within the Pay sheet to increase conversion.

Dynamic callbacks bring the Google Pay developer platform on Android to parity with its capabilities on the web. For a full implementation guide, see the updated developer documentation: goo.gle/pay-android-dpu