【发布时间】:2014-10-10 18:52:56
【问题描述】:
我正在尝试使用 Java 开发一个简单的在线商店应用程序,并且我得到了 google 在线支付的帮助。
我刚刚注册了谷歌商家,并且已经有了我的发行人和密码。
但是我对google提供的示例有一些疑问,以下代码是示例商家请求。
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");
有人能解释一下我应该如何设置这些吗?这些是什么?!
【问题讨论】: