1.0.11 • Published 1 year ago
google-wallet-package v1.0.11
Overview
This document provides information on the payload structure and details for the google wallet pass card.
//Sample Pass Payload
const passPayload = {
id: "",
type: CardTypeEnum.schufaLLC,
logoUrl:
"https://applogyxps.s3.us-west-2.amazonaws.com/1%2C701%2C946%2C970%2C885-png-logo.png",
title: "Mieterauskunft Mit SCHUFA-Bönitats...",
subheader: "Kundenname",
header: "Alex McJacobs",
rows: [
{
left_label: "Kaufen Sie Am",
left_value: "Jan 12, 2023",
middle_label: "",
middle_value: "",
right_label: "Gültig Bis",
right_value: "Mar 12, 2023",
},
{
left_label: "Validerungscode",
left_value: "QGHU-96X-67DT",
middle_label: "",
middle_value: "",
right_label: "Powered By",
right_value: "SCHUFA",
},
],
barcode: {
isEnable: true,
value: "https://google.com",
alternateText: "google",
},
hexaBackground: "#29ccab",
heroImageUrl:
"https://applogyxps.s3.us-west-2.amazonaws.com/1%2C696%2C848%2C555%2C070-image_2023_10_09T10_47_18_170Z.png",
details: [
{
title: "Über deine Mieterauskunft",
body: "Mit der bonify Mieterauskunft kannst du ganz einfach Vertrauen zwischen dir und deinem Vermieter aufbauen, in dem du ihm deine Zahlungszuverlässigkeit beweist.",
},
{
title: "Inhalt der Mieterauskunft",
body: "Der BonitätsCheck enthält folgende Informationen: SCHUFA-Bonitätsprüfung Einkommensnachweis Nachweis der Mietzahlung Nachweis der Identitätsprüfung",
},
{
title: "Gültigkeit",
body: "Deine Mieterauskunft ist ab dem Erwerb für 60 Tage gültig. Nach dem Ablauf musst du deine Mieterauskunft erneut erwerben, um dir eine neue erstellen und herunterladen zu können.",
},
{
title: "Verbessere deinen Bonitätsscore",
body: "Hier findest du Tipps wie du deinen Scorewert verbessern kannst: Um deine Bonität zu verbessern, musst du sie zunächst kennen. Wir empfehlen dir, deine Bonität monatlich zu überprüfen. Bei bonify kannst du deine Bonitätsdaten jederzeit kostenlos einsehen.",
},
{
title: "Preis",
body: "€29.99",
},
{
title: "Erworben am",
body: "March 15, 2023",
},
{
title: "Validierungscode",
body: "QGHU-96X-67DT",
},
{
title: "Kundenservice",
body: "Solltest du Hilfe mit deiner Auskunft oder deinem bonify Konto benötigen, erreichst du uns unter +49 30 346 466 707 oder via support@bonify.de",
},
],
};
Type Definition for PassPayload
type PassPayload = {
/**
* Data requrired in Request Payload
*/
id: string;
type: CardTypeEnum;
logoUrl?: string;
title?: string;
subheader?: string;
header?: string;
rows: RowsType[];
hexaBackground?: string;
heroImageUrl?: string;
details: DetailsType[];
barcode: BarcodeType;
};
enum CardTypeEnum {
schufaLLC = "schufaLLC",
bonifyFinFitness = "bonifyFinFitness",
schufaBasisScore = "schufaBasisScore",
bonifyLLC = "bonifyLLC",
}
type RowsType = {
left_label?: string;
left_value?: string;
middle_label?: string;
middle_value?: string;
right_label?: string;
right_value?: string;
};
type DetailsType = {
title?: string;
body?: string;
};
type BarcodeType = {
isEnable?: boolean;
value?: string;
alternateText?: string;
};
Pass Payload description
Creation of Google Pass
const { createGooglePass } = require("package-name"); // replace the package name
// Example usage
const createPass = async () => {
try {
const payload = {
/* Your PassPayload object */
};
const credentials = {
/* Your GoogleAuthOptions credentials */
};
const ISSUER_ID = "your_issuer_id";
const private_key = "your_private_key";
const client_email = "your_client_email";
const result = await createGooglePass(
payload,
credentials,
ISSUER_ID,
private_key,
client_email
);
} catch (error) {
console.error(error);
}
};
createPass();
Updation of Google Pass
const { updateGooglePass } = require("package-name"); // replace the package name
// Example usage
const updatePass = async () => {
try {
const passId = "your_pass_id";
const payload = {
/* Your updated PassPayload object */
};
const credentials = {
/* Your GoogleAuthOptions credentials */
};
const ISSUER_ID = "your_issuer_id";
const private_key = "your_private_key";
const client_email = "your_client_email";
const result = await updateGooglePass(
passId,
payload,
credentials,
ISSUER_ID,
private_key,
client_email
);
} catch (error) {
console.error(error);
}
};
updatePass();
Updation of Google Pass With Notification
This Function will update the google pass details and will send a notification to the user.
const { updateGooglePassAndNotify } = require("package-name"); // replace the package name
// Example usage
const updatePass = async () => {
try {
const passId = "your_pass_id";
const payload = {
/* Your updated PassPayload object */
};
const credentials = {
/* Your GoogleAuthOptions credentials */
};
const ISSUER_ID = "your_issuer_id";
const private_key = "your_private_key";
const client_email = "your_client_email";
const result = await updateGooglePassAndNotify(
passId,
payload,
credentials,
ISSUER_ID,
private_key,
client_email
);
} catch (error) {
console.error(error);
}
};
updatePass();
Functions Paramenter and description
Paramenter | Description |
---|---|
passId | (type: string): The passId of the Google wallet pass to be updated. It should be unique for every pass, avoid using special characters, function will return the new passId, you can save the updated passId in the database |
payload | (type: PassPayload): The payload containing the updated information for the passs. |
credentials | (type: GoogleAuthOptions"credentials"): Google authentication options. This Credentials object will be given by google cloud platform |
ISSUER_ID | (type: string): The issuer ID associated with the google wallet api. This can be found in google wallet and pay console |
private_key | (type: string): The private key for signing the pass. It can be found in credentials options |
client_email | (type: string): The client email for authentication. It can be found in credentials options |
saveUrl | (type: string): It will be the URL to use to redirect the user to add to wallet page |
status | (type: boolean): It will contain the success response status |
message | (type: string): This will contain the detailed message for functions |
Functions | Description | Parameters | Response |
---|---|---|---|
createGooglePass | This function will take the payload and will call the google pay api and according to the passType it will create the google Pass by calling google-wallet-api and it will give you a response as saveUrl and passId . saveUrl will contain a URL which you can use to redirect the user to Google Wallet (APP/Web) and passId will contain the updatedId which you can save along with passPayload for updation in future. | payload credentials ISSUER_ID private_key client_emai | saveUrl passId |
updateGooglePass | This function can be used to update the Google Passes without sending notification to the user. It will take the additional parameter passId to identify the pass and will update the fields passed in payload . It will return an object with keys status and message , where status will have the boolean value. true in case of success response. | passId payload credentials ISSUER_ID private_key client_emai | status message |
udmteGooglePasmAndNotify | This function can be used to update the Google Passes and sending notification to the user. It will take the additional parameter passId to identify the pass and will update the fields passed in payload . It will return an object with keys status and message , where status will have the boolean value. true in case of success response. It will send a notification to user after 30sec of success response. | passId payload credentials ISSUER_ID private_key client_emai | status message |