问题描述
我使用 repo https://github.com/google-pay/passes-rest-samples 生成谷歌会员卡。这非常有效。
由于这里只有创建方法,我想在这个类集合中添加“补丁”,例如更新余额并向持卡人显示新余额。
更新似乎有效,因为当我在 gPay 应用中打开通行证时,我可以看到更改后的分数。
我的问题是:是否可以在智能手机的锁定屏幕上显示一条消息,以便持卡人可以看到分数已更改。这怎么办?
@Soc 在评论中指出,它可能仅适用于飞行通行证。有人可以确认/否定这个假设吗?
public function updateSkinnyJwt($objectId) {
// get instance
$restMethods = RestMethods::getInstance();
// read objectId
$readobject = $restMethods->getLoyaltyObject($objectId);
// change balance
$balance = new Google_Service_Walletobjects_LoyaltyPointsBalance();
$balance->setString("1.145.530");
$loyaltyPoints = new Google_Service_Walletobjects_LoyaltyPoints();
$loyaltyPoints->setBalance($balance);
$loyaltyPoints->setLabel("Points");
$readobject->setLoyaltyPoints($loyaltyPoints);
$messages = $readobject->getMessages();
// Define new message
$newMessage = array(
'header' => 'Important Notice','body' => 'Your points has been updated!','kind' => 'walletobjects#walletobjectMessage'
);
// Add the new message about updates to the Offer Object
array_push($messages,$newMessage);
$readobject->setMessages($messages);
// update objectId
$ret = $restMethods->updateLoyaltyObject($objectId,$readobject);
print_r($ret); // just for debug
echo "update done\n";
}
public function updateLoyaltyObject($objectId,$loyaltyObject){
$response = NULL;
// Use the Google Pay API for Passes Java client lib to insert an Loyalty object
//// check the devsite for newest client lib: https://developers.google.com/pay/passes/support/libraries#libraries
//// check reference API to see the underlying REST call:
//// https://developers.google.com/pay/passes/reference/v1/loyaltyobject/insert
//// The methods to call these from client library are in Walletobjects.PHP
$service = new Google_Service_Walletobjects($this->client);
try {
$response = $service->loyaltyobject->patch($objectId,$loyaltyObject);
$response["code"] = 200;
} catch (Google_Service_Exception $gException) {
$response = $gException->getErrors();
$response["code"] = $gException->getCode();
echo("\n>>>> [START] Google Server Error response:");
var_dump($response);
echo("\n>>>> [END] Google Server Error response\n");
} catch (Exception $e){
var_dump($e->getMessage());
}
return $response;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)