/** * Create an example Offer Object * * @param String $issuerId Wallet Object merchant account id. * @param String $classId Wallet Class that this wallet object references. * @param String $objectId Unique identifier for a wallet object. * @return Object $wobObject Offerobject resource. */ public static function generateOfferObject($issuerId, $classId, $objectId) { // Define barcode type and value. $barcode = new Google_Service_Walletobjects_Barcode(); $barcode->setType('upcA'); $barcode->setValue('123456789012'); $barcode->setAlternateText('12345'); $barcode->setLabel('Offer Code'); // Create wallet object. $wobObject = new Google_Service_Walletobjects_OfferObject(); $wobObject->setClassId($issuerId . '.' . $classId); $wobObject->setId($issuerId . '.' . $objectId); $wobObject->setBarcode($barcode); $wobObject->setState('active'); $wobObject->setVersion(1); return $wobObject; }
/** * Generates a GiftCard Object * * @param String $issuerId Wallet Object merchant account id. * @param String $classId Wallet Class that this wallet object references. * @param String $objectId Unique identifier for a wallet object. * @return Object $wobObject Loyaltyobject resource. */ public static function generateGiftCardObject($issuerId, $classId, $objectId) { // Define barcode type and value. $barcode = new Google_Service_Walletobjects_Barcode(); $barcode->setAlternateText('12345'); $barcode->setLabel('User Id'); $barcode->setType('qrCode'); $barcode->setValue('28343E3'); // Define text module data. $textModulesData = array(array('header' => 'Earn double points', 'body' => 'Jane, don\'t forget to use your Baconrista Rewards when ' . 'paying with this gift card to earn additional points')); // Define links module data. $linksModuleData = new Google_Service_Walletobjects_LinksModuleData(); $uris = array(array('uri' => 'http://www.baconrista.com/mybalance?id=1234567890', 'kind' => 'walletobjecs#uri', 'description' => 'My Baconrista Gift Card Purchases')); $linksModuleData->setUris($uris); $balance = new Google_Service_Walletobjects_Money(); $balance->setKind('walletobjects#money'); $balance->setMicros(20000000); $balance->setCurrencyCode('USD'); $balanceUpdateTime = new Google_Service_Walletobjects_DateTime(); date_default_timezone_set('UTC'); $balanceUpdateTime->setDate(date("Y-m-d\\TH:i:s.u\\Z")); // Create wallet object. $wobObject = new Google_Service_Walletobjects_GiftCardObject(); $wobObject->setClassId($issuerId . "." . $classId); $wobObject->setId($issuerId . "." . $objectId); $wobObject->setState('active'); $wobObject->setVersion(1); $wobObject->setBarcode($barcode); $wobObject->setLinksModuleData($linksModuleData); $wobObject->setTextModulesData($textModulesData); $wobObject->setBalance($balance); $wobObject->setBalanceUpdateTime($balanceUpdateTime); $wobObject->setCardNumber('123jkl4889'); $wobObject->setEventNumber('123456'); $wobObject->setPin('1111'); return $wobObject; }
/** * Generates a Loyalty Object * * @param String $issuerId Wallet Object merchant account id. * @param String $classId Wallet Class that this wallet object references. * @param String $objectId Unique identifier for a wallet object. * @return Object $wobObject Loyaltyobject resource. */ public static function generateLoyaltyObject($issuerId, $classId, $objectId) { // Define barcode type and value. $barcode = new Google_Service_Walletobjects_Barcode(); $barcode->setAlternateText('12345'); $barcode->setLabel('User Id'); $barcode->setType('qrCode'); $barcode->setValue('28343E3'); // Define text module data. $textModulesData = array(array('header' => 'Janes Baconrista Rewards', 'body' => 'Save more at your local Mountain View store Jane. ' . 'You get 1 bacon fat latte for every 5 coffees purchased. ' . 'Also just for you, 10% off all pastries in the Mountain View store.')); // Define links module data. $linksModuleData = new Google_Service_Walletobjects_LinksModuleData(); $uris = array(array('uri' => 'http://www.baconrista.com/myaccount?id=1234567890', 'kind' => 'walletobjecs#uri', 'description' => 'My Baconrista Account')); $linksModuleData->setUris($uris); // Define label values. $labelValueRows = array(array('hexFontColor' => '#F8EDC1', 'hexBackgroundColor' => '#922635', 'columns' => array(array('label' => 'Next Reward in', 'value' => '2 coffees'), array('label' => 'Member Since', 'value' => '01/15/2013'))), array('hexFontColor' => '#F8EDC1', 'hexBackgroundColor' => '#922635', 'columns' => array(array('label' => 'Local Store', 'value' => 'Mountain View')))); // Define info module data. $infoModuleData = new Google_Service_Walletobjects_InfoModuleData(); $infoModuleData->setHexBackgroundColor('#442905'); $infoModuleData->setHexFontColor('#F8EDC1'); $infoModuleData->setShowLastUpdateTime(true); $infoModuleData->setLabelValueRows($labelValueRows); // Messages to be displayed. $messages = array(array('actionUri' => array('kind' => 'walletobjects#uri', 'uri' => 'http://baconrista.com'), 'header' => 'Jane, welcome to Banconrista Rewards!', 'body' => 'Thanks for joining our program. Show this message to ' . 'our barista for your first free coffee on us!', 'image' => array('kind' => 'walletobjects#image', 'sourceUri' => array('kind' => 'walletobjects#uri', 'uri' => 'http://farm4.staticflickr.com/3723/' . '11177041115_6e6a3b6f49_o.jpg')), 'kind' => 'walletobjects#walletObjectMessage')); // Reward points a user has. $points = new Google_Service_Walletobjects_LoyaltyPoints(); $balance = new Google_Service_Walletobjects_LoyaltyPointsBalance(); $balance->setString('500'); $points->setBalance($balance); $points->setLabel('Points'); $points->setPointsType('points'); // Create wallet object. $wobObject = new Google_Service_Walletobjects_LoyaltyObject(); $wobObject->setClassId($issuerId . "." . $classId); $wobObject->setId($issuerId . "." . $objectId); $wobObject->setState('active'); $wobObject->setVersion(1); $wobObject->setBarcode($barcode); $wobObject->setInfoModuleData($infoModuleData); $wobObject->setLinksModuleData($linksModuleData); $wobObject->setTextModulesData($textModulesData); $wobObject->setAccountName('Jane Doe'); $wobObject->setAccountId('1234567890'); $wobObject->setLoyaltyPoints($points); $wobObject->setMessages($messages); return $wobObject; }