Google Pay™ with QuickStream REST API
Our QuickStream REST API allows you to create a Payment Request Button in your payment form with QuickStream-API.js.
Getting started
This page explains how to add Google Pay to your existing QuickStream REST API integration. If you haven't done this integration yet, refer to our API reference and the QuickStream-API.js library reference.
To get started with your Google Pay integration:
- Register with the Google Pay Business Console and use the assigned merchant ID in
googleMerchantId
for your integration. - Make sure that you have received your Publishable and Secret REST API keys for our QuickStream REST API.
- Sign in to QuickStream portal and activate Google Pay.
- Create a payment form that you want to add an Google Pay button to. Your payment form is a webpage that you will display to your customers when they choose their payment method.
- Set up your back-end implementation to take a payment using the Transactions API.
All merchants must adhere to the Google Pay APIs Acceptable Use Policy and accept the terms defined in the Google Pay API Terms of Service.
How to implement Google Pay in your payment form
-
Add the QuickStream-API.js library to your payment form.
<script type="text/javascript" src="https://api.quickstream.westpac.com.au/rest/v1/quickstream-api-1.0.min.js"></script>
-
Add the Payment Request Button Container to your payment form that will drop-in the Google Pay button on Google Chrome and supported Android devices.
<div data-quickstream-api="paymentRequestButtonContainer"></div>
-
Initialise QuickStream-API.js with your Publishable API key for your QuickStream facility.
QuickstreamAPI.init( { publishableApiKey: "PUBLISHABLE_API_KEY" } );
-
Create the PaymentRequestConfigObject for your customer.
var config = { supplierBusinessCode: "SUPPLIER_CODE", googleMerchantId: "YOUR_GOOGLE_MERCHANT_ID", details: { total: { label: "Your company name", amount: { value: "50.00", currency: "AUD" } } } };
-
Create the Payment Request Button with the PaymentRequestConfigObject.
Handle errors or retrieve the
singleUseTokenId
property from the PaymentRequestResponseObject.QuickstreamAPI.paymentRequestButton.createButton(config, function(errors, paymentResponse) { if (errors) { // Handle errors here } else { console.log("singleUseTokenId is " + paymentResponse.singleUseTokenId); // perform the payment on your server here before calling below. paymentResponse.complete("success"); } });
Take a payment
-
After obtaining the
singleUseTokenId
pass this to your server. -
From your server, request POST
/v1/transactions
using your Secret REST API key, specifying:singleUseTokenId
: ThepaymentResponse.singleUseTokenId
from thecreateButton
function.
POST / HTTP/1.1 Host: https://api.quickstream.westpac.com.au/rest/v1/transactions Authorization: Basic A8d8sdk938damcheyt7= Idempotency-Key: a8f4bd70-5435-11ea-8d77-2e728ce88125 Content-Type: application/json { "transactionType" : "PAYMENT", "singleUseTokenId": "dec2075f-da92-49df-8a92-f7e494f89c22", "supplierBusinessCode": "SUPPLIER_CODE", "principalAmount": 5.00, "currency" : "AUD", "eci": "INTERNET", "ipAddress" : "192.168.1.1" }
See Process a transaction using a single-use-token for more.
The response contains the result of the payment.
Present the result
Use the status
that you received in your transaction response to present the result to your payer by updating the Payment Sheet using the PaymentRequestResponseObject complete
function.
QuickstreamAPI.paymentRequestButton.createButton(config, function(errors, paymentResponse) {
if (errors) {
// Handle errors here
} else {
// provide success or fail to present the result to the client
paymentResponse.complete("success");
}
});
Testing Google Pay with QuickStream
The QuickStream test environment is linked to the Google Pay TEST
environment. You can test the payment process using the Google Pay Test card suite.
- You require a Google account to access the test suite and use a Google Wallet. You may be required to add a chargeable card to your Google Wallet for the test cards to show up. Transactions in the test environment will never charge a card.
- You can use any value for
googleMerchantId
in the test environment. However, it is good practice to register a merchant ID using the Google Pay Business Console in preparation for your Production integration. - Follow the Google Pay Web integration checklist
Refer to:
- the QuickStream test account numbers for approve and decline rules while testing.
- the QuickStream REST API reference for testing, duplicate payments and error handling requirements.
- the Google Pay Web developer documentation
- the Google Pay Web brand guidelines
Go Live
Once you are ready to go live you must:
- Request production access for Google Pay. Ensure you receive a Google Pay merchant ID and that you have received approval for your integration submission to get production access.
- Sign in to QuickStream portal and activate Google Pay.
- Complete your integration with the QuickStream REST API in the production environment.