【问题标题】:Need help to setup google merchant request需要帮助来设置 Google 商家请求
【发布时间】: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");

有人能解释一下我应该如何设置这些吗?这些是什么?!

【问题讨论】:

    标签: java sandbox payment


    【解决方案1】:

    终于找到了:D
    https://developers.google.com/wallet/digital/docs/jsreference#jwt
    它是可选字段,当交易成功时,google 会发送相同的数据到 issuer postback uri。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-27
      • 2016-12-07
      • 2020-02-24
      • 1970-01-01
      • 2012-04-25
      • 2021-12-13
      • 2010-12-08
      • 1970-01-01
      相关资源
      最近更新 更多