Introduction
.xxxxxxxxxx————–xxxxxxxxxxxxx
Process Steps on Google Cloud Console and Wallet Console
- Enable the Wallet API. Follow steps in this video: https://www.youtube.com/watch?v=yQyxrhJ12vI
- Sign in to Google Cloud Console: https://console.cloud.google.com.
- Create a new project called FDI Healthcare on TfwTech.
- Select the new project, search for Google Wallet API and enable it.
- Create a Service Account. Follow steps in this video: https://www.youtube.com/watch?v=TsOWnk1S-aY
- Sign in to the Google Cloud Console: https://console.cloud.google.com.
- Select the new project, the select the option “IAM & admin”.
- Select “Service Accounts”, then create a new service account:
- Service account name: “
serv acc for FDI“ - Email:
serv-acc-fdi@fdi-healthcare-on-tfwtech.iam.gserviceaccount.com
- Service account name: “
- On the Service Accounts page, under the Action column, click the 3 dots and select ‘Manage Keys’.
- Click ‘ADD KEY’ and select JSON type.
- The service account key file is saved to MJ1900:\projs\60-tf-practice\22-commerce\02-key
- Log in Google Pay & Wallet Console to create FDI Healthcare business
- https://pay.google.com/business/console/info/BCR2DN4T2OYJZ2BE
- Create the business FDI Healthcare which contains the Business Profile and Business Information
- Merchant ID is
BCR2DN4T2OYJZ2BE - Under Google Wallet API section, click ‘Create a pass’ which redirects to the ‘pass’ page
- Click the button ‘Build your first pass’
- Mark down the issuer ID:
3388000000022796818
- Merchant ID is
- Authorize Service Account in the Wallet Console. Follow steps in https://www.youtube.com/watch?v=81RA7fDJV8I
- In the Pay & Wallet Console, click ‘Users’ on the left menu.
- Click ‘Invite a user’.
- Add in the email address of the Service Account in Step 2 and set Access Level to ‘Developer’.
- Click ‘Google Wallet API’ on the left memu, then click ‘Create a class’ to create a ‘loyalty’ class.
- Create the Loyalty class:
- Issuer Name =
FDI Loyalty Prog - Class ID =
fdi-loyalty-prog-issuer-01 - Status =
UNDER_REVIEW - Country Code =
HK - Logo Image URL =
https://tfwtech.com/publi/images/fdi_logo.png - Programme name =
Prog_Name_01 - Make sure the site
https://tfwtech.com/publiis PUBLIC otherwise the class creation will fail. - If changes in the class details are necessary later, this can be done through the Edit button for each section of the class.
- Issuer Name =
Process Steps on WordPress
- Under child theme folder, create folder passes/google
- goto
https://github.com/google-wallet/rest-samples/tree/main/php, download composer.json and demo_loyalty.php to the above google folder. cdto the passes/google folder and runcomposer installwith a non-root account- this will create the
vendorfolder containing the required libraries specified incomposer.json
- this will create the
- Upload an image of the “Add to Google Wallet” to the Media Library and note its URL.
- On the web page that requires the “Add to Google Wallet” button, insert a shortcode built from a suitable PHP snippet plugin. Example code in the snippet:
<?php
require get_stylesheet_directory() . '/passes/google/demo_loyalty.php';
$wpUserId = get_current_user_id();
if ($wpUserId != 0) {
$googleLoyalty = new DemoLoyalty();
$jwtLink = $googleLoyalty->createJwtNewObjects(
'3388000000022796818', // issserID specified in step 3
'fdi-loyalty-prog-issuer-01', // classSuffix specified in step 4.
$wpUserId, // a unique suffix of your choice for your loyalty object
);
echo "<br>The JWT Link: ". $jwtLink. "<br>";
?>
<div style="width: 150px; margin: 30px; text-align=center;">
<a href="<?=$jwtLink?>" target="blank"><img src="/wp-content/uploads/2024/10/Add_to_Google_Wallet_badge.svg.png" alt="Add_to_Google_Wallet_badge"></a>
</div>
<?php
}
Get Pass Class / Object details using GET API
- VS Code Thunder App
- OAuth 2 – Google OAuth consent screen
Reference
- How to add ‘Add to Wallet’ button to website to add coupons to Apple Wallet and Google Pay accounts –
StackOverflow- Follow the answer by Christos Papoulas
- Get-started from Google –
https://developers.google.com/wallet#get-started - PHP examples from Google –
https://github.com/google-wallet/rest-samples/tree/main/php - Google Wallet API –
https://developers.google.com/wallet/reference/rest - Setup Google OAuth sign in –
https://www.youtube.com/watch?v=tgO_ADSvY1I&t=14s
