public static String createOAuthGrant(BraintreeGateway gateway, String merchantId, String scope) { Http http = new Http(gateway.getConfiguration()); OAuthGrantRequest request = new OAuthGrantRequest().scope(scope).merchantId(merchantId); NodeWrapper node = http.post("/oauth_testing/grants", request); return node.findString("code"); }
/** Please use gateway.transparentRedirect().confirmCreditCard() instead */ @Deprecated public Result<CreditCard> confirmTransparentRedirect(String queryString) { TransparentRedirectRequest trRequest = new TransparentRedirectRequest(configuration, queryString); NodeWrapper node = http.post("/payment_methods/all/confirm_transparent_redirect_request", trRequest); return new Result<CreditCard>(node, CreditCard.class); }
public List<Discount> all() { NodeWrapper node = http.get("/discounts"); List<Discount> discounts = new ArrayList<Discount>(); for (NodeWrapper discountResponse : node.findAll("discount")) { discounts.add(new Discount(discountResponse)); } return discounts; }
public List<AddOn> all() { NodeWrapper node = http.get("/add_ons"); List<AddOn> addOns = new ArrayList<AddOn>(); for (NodeWrapper addOnResponse : node.findAll("add-on")) { addOns.add(new AddOn(addOnResponse)); } return addOns; }
List<CreditCard> fetchExpiringCreditCards(List<String> ids, String queryString) { IdsSearchRequest query = new IdsSearchRequest().ids().in(ids); NodeWrapper response = http.post("/payment_methods/all/expiring?" + queryString, query); List<CreditCard> items = new ArrayList<CreditCard>(); for (NodeWrapper node : response.findAll("credit-card")) { items.add(new CreditCard(node)); } return items; }
/** * Finds a {@link CreditCard}. * * @param token the CreditCard's token. * @return the {@link CreditCard} or raises a {@link * com.braintreegateway.exceptions.NotFoundException}. */ public CreditCard find(String token) { if (token.trim().equals("") || token == null) throw new NotFoundException(); return new CreditCard(http.get("/payment_methods/" + token)); }
/** * Deletes a {@link CreditCard}. * * @param token the CreditCard's token. * @return a {@link Result}. */ public Result<CreditCard> delete(String token) { http.delete("/payment_methods/" + token); return new Result<CreditCard>(); }
/** * Creates an {@link CreditCard}. * * @param request the request. * @return a {@link Result}. */ public Result<CreditCard> create(CreditCardRequest request) { NodeWrapper node = http.post("/payment_methods", request); return new Result<CreditCard>(node, CreditCard.class); }
/** * Returns a {@link ResourceCollection} of all credit cards expiring between the given calendars. * * @return a {@link ResourceCollection}. */ public ResourceCollection<CreditCard> expiringBetween(Calendar start, Calendar end) { String queryString = dateQueryString(start, end); NodeWrapper response = http.post("/payment_methods/all/expiring_ids?" + queryString); return new ResourceCollection<CreditCard>( new ExpiringCreditCardPager(this, queryString), response); }
/** * Returns a {@link ResourceCollection} of all expired credit cards. * * @return a {@link ResourceCollection}. */ public ResourceCollection<CreditCard> expired() { NodeWrapper response = http.post("/payment_methods/all/expired_ids"); return new ResourceCollection<CreditCard>(new ExpiredCreditCardPager(this), response); }
/** * Updates a {@link CreditCard}. * * @param token the CreditCard's token. * @param request the request. * @return a {@link Result}. */ public Result<CreditCard> update(String token, CreditCardRequest request) { NodeWrapper node = http.put("/payment_methods/" + token, request); return new Result<CreditCard>(node, CreditCard.class); }