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
Symbols & Conventions
The key words "MUST," "MUST NOT," "REQUIRED," "SHALL," "SHALL NOT," "SHOULD," "SHOULD NOT," "RECOMMENDED," "MAY," and "OPTIONAL" in these documents are to be interpreted as described in RFC 2119.
Timestamps
All timestamps are represented as milliseconds since the Unix epoch (Jan 1, 1970) in UTC.
For example:
- April 23, 2019 8:23:25 PM GMT = 1556051005000 milliseconds
- August 16, 2018 12:28:35 PM GMT = 1534422515000 milliseconds
Amounts
Monetary values in this API are in a format called "micros," a standard at Google. Micros are an integer based, fixed precision format. To represent a monetary value in micros, multiply the standard currency value by 1,000,000.
For example:
- USD$1.23 = 1230000 micro USD
- USD$0.01 = 10000 micro USD
Idempotency
All method calls within this API must have idempotent behavior. Google will sporadically retry requests to ensure that transactions are in the same state on both sides. Integrators should not attempt to reprocess any request already successfully processed. The response for the successful processing should be reported instead. All methods have a common RequestHeader
which contains a requestId. This requestId is the idempotency key for all calls.
Any non terminal response (a non HTTP 200-success), must not be idempotently processed. So a request that previously got a 400 (bad request/failed precondition), when called a second time, must not idempotently return 400, it must be re-evaluated. At re-evaluation, it could return a 400 or be processed successfully.
For more information on idempotency see this detailed guide.
Integrator
A company who uses Google’s Payment Platform for their business. It could be internal (1P), such as Youtube or AdWords, It can also be an external (3P) business wanting to integrate their service to work with Google’s ecosystem.
FOP
Form of Payment. This is more general than an instrument. Visa, MasterCard, and PayPal are all FOPs.
Instrument
A particular instance of a form of payment by a specific customer. For instance, a user’s credit card, or their PayPal account. A tokenized FOP for a particular customer is also an instrument, because it is an instance of a form of payment for that customer, securely stored on our system.
Token
A representation, on Google’s system, of a specific user’s payment method. Since it contains all the information needed to make a purchase, a token is also an instrument. This may include such information as an account number a user has with their integrator.
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
.
Next: Remittance flow