diff --git a/CHANGELOG b/CHANGELOG index 85e32b3e4b5..4b46bf377a2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +=== 1.1.18 2013-03-19 +* Add support for charge capture. + === 1.1.17 2013-02-18 * Add ability to deserialize account-related events. * Add user ID to Event object. diff --git a/README.md b/README.md index 4d0eb661a40..18451ef43f7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add this dependency to your project's POM: com.stripe stripe-java - 1.1.17 + 1.1.18 ### Others diff --git a/VERSION b/VERSION index cbb8cbae401..852ed67cfdd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.17 +1.1.18 diff --git a/pom.xml b/pom.xml index dfbcaf4ec4f..c2a09c73e2e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.stripe stripe-java jar - 1.1.17 + 1.1.18 stripe-java https://github.com/stripe/stripe-java diff --git a/src/main/java/com/stripe/Stripe.java b/src/main/java/com/stripe/Stripe.java index afa7c4e94e5..7f9deb21e9f 100644 --- a/src/main/java/com/stripe/Stripe.java +++ b/src/main/java/com/stripe/Stripe.java @@ -3,7 +3,7 @@ public abstract class Stripe { public static final String API_BASE = "https://api.stripe.com"; - public static final String VERSION = "1.1.17"; + public static final String VERSION = "1.1.18"; public static String apiKey; public static String apiVersion; } diff --git a/src/main/java/com/stripe/model/Charge.java b/src/main/java/com/stripe/model/Charge.java index 78c393636df..6d52aeb5092 100644 --- a/src/main/java/com/stripe/model/Charge.java +++ b/src/main/java/com/stripe/model/Charge.java @@ -19,6 +19,7 @@ public class Charge extends APIResource { Boolean paid; Boolean refunded; Boolean disputed; + Boolean captured; Integer fee; String description; String failureMessage; @@ -85,6 +86,14 @@ public void setRefunded(Boolean refunded) { this.refunded = refunded; } + public Boolean getCaptured() { + return captured; + } + + public void setCaptured(Boolean captured) { + this.captured = captured; + } + public Boolean getDisputed() { return disputed; } @@ -189,12 +198,24 @@ public Charge refund() throws AuthenticationException, return this.refund(null, null); } + public Charge capture() throws AuthenticationException, + InvalidRequestException, APIConnectionException, CardException, + APIException { + return this.capture(null, null); + } + public Charge refund(Map params) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { return this.refund(params, null); } + public Charge capture(Map params) + throws AuthenticationException, InvalidRequestException, + APIConnectionException, CardException, APIException { + return this.capture(params, null); + } + public static Charge create(Map params, String apiKey) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { @@ -222,6 +243,12 @@ public Charge refund(String apiKey) throws AuthenticationException, return this.refund((Map) null, apiKey); // full refund } + public Charge capture(String apiKey) throws AuthenticationException, + InvalidRequestException, APIConnectionException, CardException, + APIException { + return this.capture((Map) null, apiKey); + } + public Charge refund(Map params, String apiKey) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { @@ -232,6 +259,16 @@ public Charge refund(Map params, String apiKey) Charge.class, apiKey); } + public Charge capture(Map params, String apiKey) + throws AuthenticationException, InvalidRequestException, + APIConnectionException, CardException, APIException { + return request( + RequestMethod.POST, + String.format("%s/capture", + instanceURL(Charge.class, this.getId())), params, + Charge.class, apiKey); + } + public Dispute updateDispute(Map params, String apiKey) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { diff --git a/src/test/java/com/stripe/StripeTest.java b/src/test/java/com/stripe/StripeTest.java index 692769f057d..270d7373caf 100644 --- a/src/test/java/com/stripe/StripeTest.java +++ b/src/test/java/com/stripe/StripeTest.java @@ -34,12 +34,12 @@ import com.stripe.model.Token; public class StripeTest { - static Map defaultCardParams = new HashMap(); - static Map defaultChargeParams = new HashMap(); - static Map defaultCustomerParams = new HashMap(); - static Map defaultPlanParams = new HashMap(); - static Map defaultCouponParams = new HashMap(); - static Map defaultTokenParams = new HashMap(); + static HashMap defaultCardParams = new HashMap(); + static HashMap defaultChargeParams = new HashMap(); + static HashMap defaultCustomerParams = new HashMap(); + static HashMap defaultPlanParams = new HashMap(); + static HashMap defaultCouponParams = new HashMap(); + static HashMap defaultTokenParams = new HashMap(); static String getUniquePlanId() { return String.format("JAVA-PLAN-%s", UUID.randomUUID()); @@ -159,6 +159,18 @@ public void testChargeRefund() throws StripeException { assertTrue(refundedCharge.getRefunded()); } + @Test + public void testChargeCapture() throws StripeException { + HashMap options = (HashMap)defaultChargeParams.clone(); + options.put("capture", false); + + Charge created = Charge.create(options); + assertFalse(created.getCaptured()); + + Charge captured = created.capture(); + assertTrue(captured.getCaptured()); + } + @Test public void testChargePartialRefund() throws StripeException { Charge createdCharge = Charge.create(defaultChargeParams); @@ -480,7 +492,7 @@ public void testEventList() throws StripeException { /** * Ensure the provided parameter for API key is actually being used. All * other PerCallAPIKey methods assume this part works. - * + * * @throws StripeException */ @Test