Reminder: By Aug 31, 2025, all new apps and updates to existing apps must use Billing Library version 7 or newer. If you need more time to update your app, you can request an extension until Nov 1, 2025. Learn about Play Billing Library version deprecation.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Hệ thống thanh toán của Google Play là một dịch vụ hỗ trợ bạn bán các sản phẩm và nội dung kỹ thuật số trong ứng dụng Android, dù bạn muốn kiếm tiền thông qua các giao dịch mua hàng một lần hay muốn bán gói thuê bao dịch vụ. Google Play cung cấp một bộ API đầy đủ để tích hợp với cả ứng dụng Android và phần phụ trợ máy chủ, qua đó giúp người dùng làm quen và đảm bảo an toàn khi mua hàng trên Google Play.
Cấu trúc tích hợp
Phần này giới thiệu nhiều mô-đun chức năng mà bạn có thể xây dựng, cũng như các API và thư viện có sẵn để đơn giản hoá quy trình.
Hình 1. Sơ đồ về một tính năng tích hợp thanh toán điển hình của Google Play.
Bạn có thể tích hợp hệ thống thanh toán của Google Play với ứng dụng Android bằng cách dùng Thư viện Play Billing. Thư viện này cho phép giao tiếp với lớp Dịch vụ Google Play. Lớp này cung cấp sản phẩm đã bản địa hoá cho mỗi người dùng trong ứng dụng, cũng như các phương thức để xử lý các thao tác cần thiết khác của người dùng, chẳng hạn như khởi chạy quy trình mua và xử lý kết quả của quy trình đó.
Bạn cũng nên tích hợp hệ thống thanh toán của Google Play với phần phụ trợ của máy chủ để tạo các luồng cần thiết cho nhà phát triển. Điều này là rất quan trọng để đảm bảo tính an toàn và hiệu quả của hoạt động quản lý mua hàng cũng như các quyền trên nhiều nền tảng.
Bạn có thể tạo tính năng tích hợp này bằng API gói thuê bao và mua hàng trong ứng dụng do API Nhà phát triển Google Play cung cấp. Việc tích hợp phần phụ trợ cũng tận dụng một số công cụ trên nền tảng Google Cloud.
Hình 2. Các API và dịch vụ do API Nhà phát triển Google Play cung cấp.
Thuật ngữ
Phần này liệt kê và mô tả các công nghệ và khái niệm cấp cao mà bạn có thể gặp khi tích hợp hệ thống thanh toán của Google Play vào ứng dụng. Hãy tham khảo danh sách này khi bạn tiếp tục tìm hiểu hướng dẫn tích hợp.
Công nghệ
Google Play. Cửa hàng trực tuyến nơi người dùng có thể tải ứng dụng và các sản phẩm kỹ thuật số khác xuống.
Google Play Console. Một nền tảng cung cấp giao diện để bạn có thể phát hành ứng dụng lên Google Play. Google Play Console cũng hiển thị thông tin chi tiết về ứng dụng, bao gồm mọi sản phẩm hoặc nội dung mà bạn bán trên Google Play.
Bảng điều khiển Google Cloud. Một nền tảng quản lý các API phụ trợ, chẳng hạn như API Nhà phát triển Google Play.
Thư viện Google Play Billing. API mà bạn có thể sử dụng để tích hợp hệ thống thanh toán của Google Play vào ứng dụng.
API Nhà phát triển Google Play.
API REST mà bạn có thể dùng để xử lý các tác vụ phát hành và quản lý ứng dụng theo phương thức lập trình.
Cloud Pub/Sub. Dịch vụ thông báo theo thời gian thực được quản lý toàn diện, cho phép bạn gửi và nhận thông báo giữa các ứng dụng độc lập. Google Play sử dụng Cloud Pub/Sub để gửi Thông báo theo thời gian thực dành cho nhà phát triển. Để sử dụng Cloud Pub/Sub, bạn phải có một dự án trên Google Cloud Platform (GCP) và bật API Cloud Pub/Sub. Nếu bạn chưa hiểu rõ về GCP và Cloud Pub/Sub, hãy xem phần Hướng dẫn nhanh.
Máy chủ phụ trợ an toàn. Trong quá trình tích hợp hệ thống thanh toán của Google Play vào ứng dụng, bạn nên sử dụng máy chủ phụ trợ an toàn để triển khai các nhiệm vụ liên quan đến thanh toán, chẳng hạn như xác minh giao dịch mua, các tính năng dành riêng cho gói thuê bao và xử lý Thông báo theo thời gian thực dành cho nhà phát triển.
Ứng dụng Cửa hàng Google Play. Một ứng dụng quản lý mọi thao tác liên quan đến Google Play. Tất cả các yêu cầu mà ứng dụng đưa ra đều được Cửa hàng Google Play xử lý.
Khái niệm
Quy trình Một quy trình hiển thị các bước đặc trưng trong một tác vụ thanh toán. Ví dụ: một quy trình mua hàng liệt kê các bước liên quan khi người dùng mua sản phẩm. Một quy trình thuê bao có thể cho biết cách một gói thuê bao chuyển đổi giữa các trạng thái.
Quyền. Khi người dùng mua sản phẩm trong ứng dụng, họ sẽ có quyền đối với sản phẩm đó trong ứng dụng. Đối với sản phẩm tính phí một lần, điều này có nghĩa là người dùng hiện có quyền truy cập vĩnh viễn vào sản phẩm.
Đối với các gói thuê bao, điều này nghĩa là người dùng sẽ có quyền truy cập trong khi trạng thái của gói thuê bao là đang hoạt động.
Mã sản phẩm. Mã của một loại sản phẩm cụ thể.
Mã thông báo giao dịch mua. Một chuỗi thể hiện quyền của người mua đối với sản phẩm trên Google Play. Mã này cho biết người dùng Google đã thanh toán cho một sản phẩm cụ thể.
Mã đơn hàng. Một chuỗi đại diện cho một giao dịch tài chính trên Google Play.
Mã đơn hàng được tạo mỗi khi có giao dịch tài chính. Chuỗi này đi kèm trong biên nhận được gửi qua email cho người mua. Bạn có thể sử dụng mã đơn đặt hàng để quản lý việc hoàn tiền trong mục Quản lý đơn đặt hàng của Google Play Console. Các mã đơn hàng cũng được dùng trong các báo cáo thanh toán và bán hàng.
Các bước tiếp theo
Để bắt đầu tích hợp hệ thống thanh toán của Google Play vào phần phụ trợ của ứng dụng và máy chủ, vui lòng xem hướng dẫn thiết lập.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Google Play's billing system is a service that enables you to sell digital products\nand content in your Android app, whether you want to monetize through one-time\npurchases or offer subscriptions to your services. Google Play offers a full set\nof APIs for integration with both your Android app and your server backend that\nunlock the familiarity and safety of Google Play purchases for your users.\n| **Note:** Google Play's billing system is only for digital items. For physical goods and services, or other non-digital content, see the [Google Pay SDK](https://developers.google.com/pay/api/android/overview).\n\nIntegration architecture\n------------------------\n\nThis section introduces the different functional modules that you can build and\nthe APIs and libraries available to simplify the process.\n**Figure 1.** Diagram of a typical Google Play billing integration.\n\nYou can integrate Google Play's billing system with your Android app using the [Play\nBilling Library](/reference/com/android/billingclient/classes). This library\nenables communication with the Google Play Services layer that provides the\nlocalized product offering available to each user in your app, as well as\nmethods to handle other necessary user operations, like launching the purchase\nflow and handling its outcome.\n\nYou should also integrate Google Play's billing system with your server backend to\ncreate the necessary developer flows. This is essential to guarantee that your\npurchase management and cross-platform entitlements are efficient and secure.\nYou can create this integration with the [Subscriptions and in-app purchases\nAPI](https://developers.google.com/android-publisher#subscriptions) provided by\nthe Google Play Developer API. The backend integration also leverages some\nGoogle Cloud platform tools.\n**Figure 2.** APIs and services provided by the Google Play Developer API.\n\nTerminology\n-----------\n\nThis section lists and describes the high-level technologies and concepts that\nyou might encounter when integrating Google Play's billing system into your app.\nReference this list as you proceed through the integration guidance.\n\n### Technologies\n\n- [**Google Play**](https://play.google.com). An online store where users can download apps and other digital products.\n- [**Google Play Console**](https://play.google.com/console). A platform that provides an interface where you can publish your app to Google Play. The Google Play Console also shows details about your app, including any products or content that you sell with Google Play.\n- [**Google Cloud Console**](https://console.developers.google.com/). A platform that manages backend APIs, such as the Google Play Developer API.\n- [**Google Play Billing Library**](/google/play/billing/integrate). An API that you can use to integrate Google Play's billing system into your app.\n- [**Google Play Developer API**](https://developers.google.com/android-publisher/). A REST API that you can use to programmatically handle publishing and app management tasks.\n- [**Cloud Pub/Sub**](https://cloud.google.com/pubsub/). A fully managed real-time messaging service that enables you to send and receive messages between independent applications. Google Play uses Cloud Pub/Sub to deliver Real-time developer notifications. To use [Cloud\n Pub/Sub](https://cloud.google.com/pubsub/), you must have a project on the [Google Cloud Platform (GCP)](https://cloud.google.com/) with the Cloud Pub/Sub API enabled. If you aren't familiar with GCP and Cloud Pub/Sub, see the [Quickstart guide](https://cloud.google.com/pubsub/docs/quickstart-console).\n- [**Real-time developer notifications**](/google/play/billing/getting-ready#configure-rtdn). A mechanism that lets you monitor state changes for Google Play-managed subscriptions in real time by leveraging [Cloud\n Pub/Sub](https://cloud.google.com/pubsub).\n- **Secure backend server**. As part of integrating Google Play's billing system into your app, we strongly recommend that you use a secure backend server to implement billing-related tasks such as purchase verification, subscription-specific features, and handling Real-time developer notifications.\n- **Google Play Store app**. An app that manages all operations related to Google Play. All requests made by your app are handled by the Google Play Store app.\n\n### Concepts\n\n- **Flow** . A flow shows the typical steps involved in a billing-related task. For example, a *purchase flow* outlines the steps involved when a user purchases your product. A *subscription flow* might show how a subscription transitions between states.\n- **Entitlement** . When a user purchases an in-app product, they are then *entitled* to that product within your app. For one-time products, this means that the user should now have permanent access to the product. For subscriptions, this means that the user should have access while the subscription is active.\n- **Product ID**. The ID of a specific product type.\n- **Purchase token**. A string that represents a buyer's entitlement to a product on Google Play. It indicates that a Google user has paid for a specific product.\n- **Order ID** . A string that represents a financial transaction on Google Play. An order ID is created every time a financial transaction occurs. This string is included in a receipt that is emailed to the buyer. You can use the order ID to manage refunds in the **Order Management** section of the Google Play Console. Order IDs are also used in sales and payout reports.\n\nNext steps\n----------\n\nTo begin integrating Google Play's billing system with your app and server backend,\nsee the [setup guide](/google/play/billing/getting-ready)."]]