Refundable One Time Payment Code
Overview
Google Standard Payments supports cash-based FOPs (forms of payment) like convenience store purchases (such as a 7-Eleven). At a high level, a user who wants to pay for goods generates a reference number through the Payment integrator. The user then takes this reference number to a convenience store, kiosk, or bank and pays the reference number.
![]() |
![]() |
![]() |
Concepts and terminology
符號和會議
「必須」使用的重要詞彙是「必須」「絕對不要」「必要」「SHALL」、「"SHALL NOT,「應」"不應"「建議」「你好」:和「OPTIONAL」並依照 RFC 2119 中的說明解讀。
時間戳記
所有時間戳記都會以世界標準時間 (UTC) 自 Unix 紀元 (1970 年 1 月 1 日) 表示的毫秒數。
例如:
- 2019 年 4 月 23 日下午 8:23:25 (GMT = 1556051005000 毫秒)
- 2018 年 8 月 16 日中午 12:28:35 (格林威治標準時間) = 1534422515000 毫秒
金額
這個 API 中的貨幣值格式為「微量」。成為 Google 的一項標準微量是整數的固定精確度格式,如要表示金額 (以百萬分之一為單位),請將標準貨幣值乘以 1,000,000。
例如:
- $1.23 美元 = 1230,000 美元
- $0.01 美元 = 10,000 美元
冪等
這個 API 中的所有方法呼叫都必須具有冪等行為。Google 會偶爾重試要求,確保兩邊的交易狀態都相同。整合商不得嘗試重新處理已經成功處理的任何要求。請回報成功處理的回應。所有方法都有通用的 RequestHeader
,其中包含 requestId。此 requestId 是所有呼叫的冪等鍵。
任何非終端機回應 (非 HTTP 200 成功) 都不得冪等處理。因此,如果要求之前收到 400 (錯誤要求/失敗的先決條件),在第二次呼叫時,該請求不得冪等地傳回 400,所以必須重新評估。重新評估時,可能會傳回 400 或已成功處理。
如要進一步瞭解冪等性,請參閱這份詳細指南。
整合商
使用 Google 付款平台處理業務的公司。可以是 YouTube 或 AdWords 等內部 (1P) 公司,也可以是 YouTube 或 AdWords 等外部企業,且想將自家服務與 Google 生態系統整合。
付款方式
付款方式。這比樂器更為廣泛。Visa、MasterCard 和 PayPal 皆為 FOP。
樂器
特定客戶的特定付款方式實例。例如使用者的信用卡或 PayPal 帳戶。個別客戶的代碼化 FOP 也是一種付款方式,因為它對該客戶的付款方式而言會安全地儲存在我們的系統中。
權杖
代表特定使用者的付款方式,並在 Google 系統中代表。因為其中包含購物所需的一切資訊,因此權杖也是一種工具。這可能包括使用者向整合商提供的帳號等這類資訊。
Key flows
Google uses two key flows to create and pay these reference numbers:
- Generate Reference Number Flow.
- Pay Reference Number Flow.
Later, reconciliation and settlement from resulting purchases are handled by the remittance flow.
The diagram below illustrates each of these flows.
Cash FOP overview
The first two flows are described in more detail in the following sections. See the Remittance flow page if you want to know more about that flow.
Generate reference number
The purpose of the generate reference number flow is to create and exchange an identifier (reference number) that both Google and the integrator can use to identify a purchase. The user can then use this reference number at a convenience store, kiosk, or bank to complete the purchase. This identifier is generated by the integrator at Google's request by calling the generateReferenceNumber
method. The request for generation of the reference number includes an amount and a transaction description.
The following diagram illustrates how a reference number is generated and sent to the customer with instructions.
Generate reference number flow
Here is a list of the objects and what they represent:
- User: This is the person who wants to pay for something using this form of payment.
- Google UI: This is the interface where the User makes their purchase. It could be through the web or through an app.
- Google Server: The backend server at Google that requests the generation of the reference number and creates payment instructions for the user.
- Payment Integrator Server: The backend server of the Payment Integrator that keeps track of the payment details and generates the reference number.
This flow begins with the user who wants to use this cash form of payment.
- The User accesses the Google UI which sends sends a request for a reference number.
- The Google UI sends a message to the Google Server that it needs a reference number (
getReferenceNumber
). - The Google Server asks the Payment Integrator Server to generate a reference number (
generateReferenceNumber
). - The Payment Integrator Server generates and sends the reference number to the Google Server.
- The Google Server creates payment instructions to go along with the reference number. Then it sends this information to the Google UI.
- The Google UI sends these instructions and reference number to the User.
Notes on reference numbers
Reference numbers can only be paid once, and they can be cancelled through the cancel reference number flow. Also, reference numbers must be alphanumeric, and it must support multiple display formats.
In addition to displaying the reference number, Google's UIs can optionally represent the reference number in the Code 128 format (a barcode format). Other barcode formats can be supported by request.
Pay Reference Number
The user will use this reference number at a convenience store, kiosk, or bank to identify the purchase the user wants to pay for. The integrator should have the user confirm the purchase being paid by displaying the purchase amount, date, and transaction description prior to paying.
Once the user chooses to pay, they must pay in full, and only pay once. This API does not support over or under payments on a single reference number. Multiple payments to a single reference number is also not supported.
Once the user pays, the integrator must immediately notify Google that this reference number has been paid via the
method. By calling this method within seconds of the user physically paying, the integrator allows the user to quickly receive their goods. (This call can be added to a queue if the network is down.)referenceNumberPaidNotification
Once paid, the reference number and amount will be included in the remittance statement sent on T+2 days.
Here is a sequence diagram that illustrates the payment of a reference number.
Pay reference number flow
The objects in the diagram represent the following:
- User: This is the person who wants to pay for something using this form of payment.
- Convenience Store: The location where the user makes their payment using the reference number and instructions given, such as a convenience store.
- Payment Integrator Server: The backend server of the Payment Integrator that keeps track of the payment details.
- Google Server: The backend server at Google that requests the generation of the reference number and creates payment instructions for the user.
This flow begins with the user who goes to a convenience store in order to make a payment according to the instructions given to them.
- The User goes to a Convenience Store to make a payment.
- After the transaction is complete, the convenience store notifies the payment integrator of payment.
- The Payment Integrator Server sends a success message to the Convenience Store.
- The Convenience Store conveys that the transaction was a success to the User, and the goods will be delivered to the User soon.
- The Payment Integrator Server sends a message to Google’s Server that the reference number has been paid (
). This step must not block step 4.referenceNumberPaidNotification
- The Google Server responds with a message of success to the Payment Integrator Server.
Cancel reference number
Reference numbers can be cancelled by Google. If Google cancels a reference number, the cancelReferenceNumber
method will be called. Upon successful return of this call, it is invalid to pay that reference number, and the integrator must refuse payment for this number. Upon success of this call, all future calls to the
will fail.referenceNumberPaidNotification
If the payment process has already started, for example if the user has entered their reference number into a kiosk but has not yet paid, the integrator should return a HTTP 423 response code with ErrorResponse containing [USER_ACTION_IN_PROGRESS
][google.standardpayments.v1.ErrorResponse].
Refund
Paid reference numbers can be refunded by Google using the request ID of the original generateReferenceNumber
call (note that refunds will NOT use the reference number). If Google refunds a reference number, the refund
method will be called. This method can be called multiple times with amounts totalling less than or equal to the original paid amount.
Next: Remittance flow