我正在尝试使用Java开发一个简单的在线商店应用程序,我得到谷歌的在线支付。
我刚刚注册了谷歌商家,并且已经拥有我的发行人和密码
但我对谷歌提供的示例有一些疑问,以下代码是示例商家请求。
private String getJWT() throws InvalidKeyException, SignatureException {
JsonToken token = null;
token = createToken();
return token.serializeAndSign();
}
private JsonToken createToken() throws InvalidKeyException{
//Current time and signing algorithm
Calendar cal = Calendar.getInstance();
HmacSHA256Signer signer = new HmacSHA256Signer(ISSUER, null, SIGNING_KEY.getBytes());
//Configure JSON token
JsonToken token = new JsonToken(signer);
token.setAudience("Google");
token.setParam("typ", "google/payments/inapp/item/v1");
token.setIssuedAt(new Instant(cal.getTimeInMillis()));
token.setExpiration(new Instant(cal.getTimeInMillis() + 60000L));
//Configure request object
JsonObject request = new JsonObject();
request.addProperty("name", "Piece of Cake");
request.addProperty("description", "Virtual chocolate cake to fill your virtual tummy");
request.addProperty("price", "10.50");
request.addProperty("currencyCode", "USD");
request.addProperty("sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j");
JsonObject payload = token.getPayloadAsJsonObject();
payload.add("request", request);
return token;
}
除了这一行,一切都很清楚
request.addProperty("sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j");
有人会解释我应该如何设置这些?这些是什么?!
答案 0 :(得分:0)
终于找到了它:D
https://developers.google.com/wallet/digital/docs/jsreference#jwt
它是可选字段,当事务成功发送者回发uri时谷歌会发送相同的数据。