/** * Create a token. */ public static Token create(Map<String, Object> params) throws StripeException { return create(params, (RequestOptions) null); }
/** * Retrieve a token. */ public static Token retrieve(String id) throws StripeException { return retrieve(id, (RequestOptions) null); }
/** * Retrieve a token. */ public static Token retrieve(String id, Map<String, Object> params, RequestOptions options) throws StripeException { return request(RequestMethod.GET, instanceUrl(Token.class, id), params, Token.class, options); } // </editor-fold>
@Test public void testCreate() throws StripeException { final Calendar now = Calendar.getInstance(); final Map<String, Object> card = new HashMap<>(); card.put("number", "4242424242424242"); card.put("exp_month", now.get(Calendar.MONTH)); card.put("exp_year", now.get(Calendar.YEAR) + 1); final Map<String, Object> params = new HashMap<>(); params.put("card", card); final Token token = Token.create(params); assertNotNull(token); verifyRequest( ApiResource.RequestMethod.POST, "/v1/tokens", params ); }
/** * Retrieve a token. */ public static Token retrieve(String id, RequestOptions options) throws StripeException { return retrieve(id, null, options); }
@Test public void testRetrieve() throws StripeException { final Token token = Token.retrieve(TOKEN_ID); assertNotNull(token); verifyRequest( ApiResource.RequestMethod.GET, String.format("/v1/tokens/%s", TOKEN_ID) ); } }