我已经使用java库jsontoken实现了Subscriptions流程,但是收到错误500.发生在sandox和production中。知道为什么会这样吗?
这是错误:
POST https://checkout.google.com/inapp/api/v1/purchase_options 500(内部服务器错误)
这是代码:
Calendar cal = Calendar.getInstance();
HmacSHA256Signer signer = new HmacSHA256Signer(ISSUER, null, SIGNING_KEY.getBytes());
JsonToken token = new JsonToken(signer);
token.setAudience("Google");
token.setParam("typ", "google/payments/inapp/subscription/v1");
token.setIssuedAt(new Instant(cal.getTimeInMillis()));
token.setExpiration(new Instant(cal.getTimeInMillis() + 60000L));
long prorated =cal.getTimeInMillis() + 2592000000L;
JsonObject request = new JsonObject();
request.addProperty("name", "Piece of Cake");
request.addProperty("description", "Virtual chocolate cake to fill your virtual tummy");
request.addProperty("sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j");
request.addProperty("initialPayment", "{\"price\" : \"1.49\",\"currencyCode\" : \"USD\",\"paymentType\" : \"prorated\",}");
request.addProperty("recurrence", "{\"price\" : \"4.99\",\"currencyCode\" : \"USD\",\"startTime\" : \""+prorated+"\",\"frequency\" : \"monthly\",\"numRecurrences\" : \"12\",}");
JsonObject payload = token.getPayloadAsJsonObject();
payload.add("request", request);
token.serializeAndSign();