diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index bde0448..fe3e9cb 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,9 +11,9 @@ jobs:
java-version: [8, 11]
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Set up JDK
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
diff --git a/README.md b/README.md
index 73822b6..6902945 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Add this dependency to your project's POM:
jp.pay
payjp-java
- 0.6.2
+ 0.7.0
```
@@ -27,7 +27,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
-compile "jp.pay:payjp-java:0.6.2"
+compile "jp.pay:payjp-java:0.7.0"
```
### Others
@@ -62,7 +62,7 @@ import jp.pay.net.RequestOptions;
public class PayjpExample {
public static void main(String[] args) {
- Payjp.apiKey = "sk_test_c62fade9d045b54cd76d7036";
+ Payjp.apiKey = "your_secret_key";
Map chargeMap = new HashMap();
chargeMap.put("amount", 3500);
chargeMap.put("currency", "jpy");
diff --git a/VERSION b/VERSION
index b616048..faef31a 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.6.2
+0.7.0
diff --git a/pom.xml b/pom.xml
index 40aec18..f62d524 100755
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
jp.pay
payjp-java
jar
- 0.6.2
+ 0.7.0
pay-java
https://github.com/payjp/payjp-java
diff --git a/src/main/java/jp/pay/Payjp.java b/src/main/java/jp/pay/Payjp.java
index f1a92a6..7b21439 100644
--- a/src/main/java/jp/pay/Payjp.java
+++ b/src/main/java/jp/pay/Payjp.java
@@ -25,7 +25,7 @@
public abstract class Payjp {
public static final String LIVE_API_BASE = "https://api.pay.jp";
- public static final String VERSION = "0.6.2";
+ public static final String VERSION = "0.7.0";
public static volatile String apiKey;
public static volatile String apiVersion;
public static volatile Integer maxRetry = 0;
diff --git a/src/main/java/jp/pay/model/Balance.java b/src/main/java/jp/pay/model/Balance.java
new file mode 100644
index 0000000..d30fa44
--- /dev/null
+++ b/src/main/java/jp/pay/model/Balance.java
@@ -0,0 +1,88 @@
+package jp.pay.model;
+
+import jp.pay.exception.*;
+import jp.pay.net.APIResource;
+import jp.pay.net.RequestOptions;
+
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.List;
+
+
+public class Balance extends APIResource {
+ Long created;
+ String id;
+ Boolean livemode;
+ BigInteger net;
+ String tenantId;
+ List statements;
+ String state;
+ Boolean closed;
+ String dueDate;
+ BankInfo bankInfo;
+
+ public Long getCreated() {
+ return created;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Boolean getLivemode() {
+ return livemode;
+ }
+
+ public BigInteger getNet() {
+ return net;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public List getStatements() {
+ return statements;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Boolean getClosed() {
+ return closed;
+ }
+
+ public String getDueDate() {
+ return dueDate;
+ }
+
+ public BankInfo getBankInfo() {
+ return bankInfo;
+ }
+
+ public static Balance retrieve(String id) throws AuthenticationException,
+ InvalidRequestException, APIConnectionException,
+ CardException, APIException {
+ return retrieve(id, (RequestOptions) null);
+ }
+
+ public static BalanceCollection all(Map params)
+ throws AuthenticationException, InvalidRequestException,
+ APIConnectionException, CardException, APIException {
+ return all(params, (RequestOptions) null);
+ }
+
+ public static Balance retrieve(String id, RequestOptions options)
+ throws AuthenticationException, InvalidRequestException,
+ APIConnectionException, CardException, APIException {
+ return request(RequestMethod.GET, instanceURL(Balance.class, id), null, Balance.class, options);
+ }
+
+ public static BalanceCollection all(Map params,
+ RequestOptions options) throws AuthenticationException,
+ InvalidRequestException, APIConnectionException,
+ CardException, APIException {
+ return request(RequestMethod.GET, classURL(Balance.class), params, BalanceCollection.class, options);
+ }
+}
diff --git a/src/main/java/jp/pay/model/BalanceCollection.java b/src/main/java/jp/pay/model/BalanceCollection.java
new file mode 100644
index 0000000..1b70ce5
--- /dev/null
+++ b/src/main/java/jp/pay/model/BalanceCollection.java
@@ -0,0 +1,4 @@
+package jp.pay.model;
+
+public class BalanceCollection extends PayjpCollection {
+}
diff --git a/src/main/java/jp/pay/model/BankInfo.java b/src/main/java/jp/pay/model/BankInfo.java
new file mode 100644
index 0000000..8af82dc
--- /dev/null
+++ b/src/main/java/jp/pay/model/BankInfo.java
@@ -0,0 +1,35 @@
+package jp.pay.model;
+
+public class BankInfo {
+ String bankCode;
+ String bankBranchCode;
+ String bankAccountType;
+ String bankAccountNumber;
+ String bankAccountHolderName;
+ String bankAccountStatus;
+
+ public String getBankCode() {
+ return bankCode;
+ }
+
+ public String getBankBranchCode() {
+ return bankBranchCode;
+ }
+
+ public String getBankAccountType() {
+ return bankAccountType;
+ }
+
+ public String getBankAccountNumber() {
+ return bankAccountNumber;
+ }
+
+ public String getBankAccountHolderName() {
+ return bankAccountHolderName;
+ }
+
+ public String getBankAccountStatus() {
+ return bankAccountStatus;
+ }
+
+}
diff --git a/src/main/java/jp/pay/model/Charge.java b/src/main/java/jp/pay/model/Charge.java
index 1233866..e1b6055 100644
--- a/src/main/java/jp/pay/model/Charge.java
+++ b/src/main/java/jp/pay/model/Charge.java
@@ -55,6 +55,7 @@ public class Charge extends APIResource implements MetadataStore {
Map metadata = new HashMap();
String feeRate;
String threeDSecureStatus;
+ String termId;
public String getId() {
return id;
@@ -196,6 +197,10 @@ public Map getMetadata() {
return metadata;
}
+ public String getTermId() {
+ return termId;
+ }
+
/**
* Assigning a whole collection from outside the object is not quite a right thing to do.
* Be stick to use getMetadata().
diff --git a/src/main/java/jp/pay/model/PayjpObjectDeserializer.java b/src/main/java/jp/pay/model/PayjpObjectDeserializer.java
index 67e7dd2..279803c 100644
--- a/src/main/java/jp/pay/model/PayjpObjectDeserializer.java
+++ b/src/main/java/jp/pay/model/PayjpObjectDeserializer.java
@@ -52,6 +52,9 @@ public class PayjpObjectDeserializer implements JsonDeserializer {
objectMap.put("transfer", Transfer.class);
objectMap.put("summary", Summary.class);
objectMap.put("card", Card.class);
+ objectMap.put("term", Term.class);
+ objectMap.put("statement", Statement.class);
+ objectMap.put("balance", Balance.class);
}
private Object deserializeJsonPrimitive(JsonPrimitive element) {
diff --git a/src/main/java/jp/pay/model/Statement.java b/src/main/java/jp/pay/model/Statement.java
index def9eab..a6354ef 100644
--- a/src/main/java/jp/pay/model/Statement.java
+++ b/src/main/java/jp/pay/model/Statement.java
@@ -4,6 +4,7 @@
import jp.pay.net.APIResource;
import jp.pay.net.RequestOptions;
+import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@@ -15,6 +16,11 @@ public class Statement extends APIResource {
Boolean livemode;
String title;
Long updated;
+ Term term;
+ String balanceId;
+ String tenantId;
+ String type;
+ BigInteger net;
public class StatementItem {
Integer amount;
@@ -47,6 +53,14 @@ public Long getCreated() {
return created;
}
+ public String getTitle() {
+ return title;
+ }
+
+ public Long getUpdated() {
+ return updated;
+ }
+
public String getId() {
return id;
}
@@ -59,6 +73,25 @@ public void setLivemode(Boolean livemode) {
this.livemode = livemode;
}
+ public Term getTerm() {
+ return term;
+ }
+
+ public String getBalanceId() {
+ return balanceId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public BigInteger getNet() {
+ return net;
+ }
public static Statement retrieve(String id) throws AuthenticationException,
InvalidRequestException, APIConnectionException,
diff --git a/src/main/java/jp/pay/model/Term.java b/src/main/java/jp/pay/model/Term.java
new file mode 100644
index 0000000..988fe2b
--- /dev/null
+++ b/src/main/java/jp/pay/model/Term.java
@@ -0,0 +1,72 @@
+package jp.pay.model;
+
+import jp.pay.exception.*;
+import jp.pay.net.APIResource;
+import jp.pay.net.RequestOptions;
+
+import java.util.Map;
+
+
+public class Term extends APIResource {
+ String id;
+ Boolean livemode;
+ Long startAt;
+ Long endAt;
+ Integer chargeCount;
+ Integer refundCount;
+ Integer disputeCount;
+
+ public String getId() {
+ return id;
+ }
+
+ public Boolean getLivemode() {
+ return livemode;
+ }
+
+ public Long getStartAt() {
+ return startAt;
+ }
+
+ public Long getEndAt() {
+ return endAt;
+ }
+
+ public Integer getChargeCount() {
+ return chargeCount;
+ }
+
+ public Integer getRefundCount() {
+ return refundCount;
+ }
+
+ public Integer getDisputeCount() {
+ return disputeCount;
+ }
+
+
+ public static Term retrieve(String id) throws AuthenticationException,
+ InvalidRequestException, APIConnectionException,
+ CardException, APIException {
+ return retrieve(id, (RequestOptions) null);
+ }
+
+ public static TermCollection all(Map params)
+ throws AuthenticationException, InvalidRequestException,
+ APIConnectionException, CardException, APIException {
+ return all(params, (RequestOptions) null);
+ }
+
+ public static Term retrieve(String id, RequestOptions options)
+ throws AuthenticationException, InvalidRequestException,
+ APIConnectionException, CardException, APIException {
+ return request(RequestMethod.GET, instanceURL(Term.class, id), null, Term.class, options);
+ }
+
+ public static TermCollection all(Map params,
+ RequestOptions options) throws AuthenticationException,
+ InvalidRequestException, APIConnectionException,
+ CardException, APIException {
+ return request(RequestMethod.GET, classURL(Term.class), params, TermCollection.class, options);
+ }
+}
diff --git a/src/main/java/jp/pay/model/TermCollection.java b/src/main/java/jp/pay/model/TermCollection.java
new file mode 100644
index 0000000..cea33b5
--- /dev/null
+++ b/src/main/java/jp/pay/model/TermCollection.java
@@ -0,0 +1,4 @@
+package jp.pay.model;
+
+public class TermCollection extends PayjpCollection {
+}
diff --git a/src/test/java/jp/pay/BasePayjpTest.java b/src/test/java/jp/pay/BasePayjpTest.java
index 8b21b98..813c04e 100644
--- a/src/test/java/jp/pay/BasePayjpTest.java
+++ b/src/test/java/jp/pay/BasePayjpTest.java
@@ -23,6 +23,7 @@
*/
package jp.pay;
+import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.mockito.ArgumentMatcher;
@@ -45,6 +46,9 @@
import jp.pay.net.RequestOptions;
import jp.pay.net.PayjpResponseGetter;
import jp.pay.net.LivePayjpResponseGetter;
+
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
public class BasePayjpTest {
@@ -203,4 +207,20 @@ protected String resource(String path) throws IOException {
return os.toString("utf8");
}
+
+ @Before
+ public void mockPayjpResponseGetter() {
+ APIResource.setPayjpResponseGetter(networkMock);
+ }
+
+ @After
+ public void unmockPayjpResponseGetter() {
+ /* This needs to be done because tests aren't isolated in Java */
+ APIResource.setPayjpResponseGetter(new LivePayjpResponseGetter());
+ }
+
+ @BeforeClass
+ public static void setApiKey() {
+ Payjp.apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // public api key for test
+ }
}
diff --git a/src/test/java/jp/pay/PayjpScenarioTest.java b/src/test/java/jp/pay/PayjpScenarioTest.java
index 0bb379d..9b67ac9 100644
--- a/src/test/java/jp/pay/PayjpScenarioTest.java
+++ b/src/test/java/jp/pay/PayjpScenarioTest.java
@@ -37,7 +37,7 @@
public class PayjpScenarioTest extends BasePayjpTest {
@BeforeClass
public static void setUp() {
- Payjp.apiKey = "sk_test_c62fade9d045b54cd76d7036"; // public api key for test
+ Payjp.apiKey = "your_secret_key"; // public api key for test
}
@Ignore
diff --git a/src/test/java/jp/pay/PayjpTest.java b/src/test/java/jp/pay/PayjpTest.java
index f669257..ff2b66c 100644
--- a/src/test/java/jp/pay/PayjpTest.java
+++ b/src/test/java/jp/pay/PayjpTest.java
@@ -84,17 +84,6 @@ static Map getSubscriptionParams() throws PayjpException {
return subscriptionParams;
}
- @Before
- public void mockPayjpResponseGetter() {
- APIResource.setPayjpResponseGetter(networkMock);
- }
-
- @After
- public void unmockPayjpResponseGetter() {
- /* This needs to be done because tests aren't isolated in Java */
- APIResource.setPayjpResponseGetter(new LivePayjpResponseGetter());
- }
-
@Before
public void before() {
Payjp.apiVersion = null;
@@ -102,8 +91,6 @@ public void before() {
@BeforeClass
public static void setUp() {
- Payjp.apiKey = "sk_test_c62fade9d045b54cd76d7036"; // public api key for test
-
cardSupportedRequestOptions = RequestOptions.builder().setPayjpVersion("2015-06-23").build();
defaultCardParams.put("number", "4242424242424242");
diff --git a/src/test/java/jp/pay/model/BalanceTest.java b/src/test/java/jp/pay/model/BalanceTest.java
new file mode 100644
index 0000000..383e335
--- /dev/null
+++ b/src/test/java/jp/pay/model/BalanceTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010-2011 Stripe (http://stripe.com)
+ * Copyright (c) 2024 PAY, Inc. (http://pay.co.jp/)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.pay.model;
+
+
+import jp.pay.net.APIResource;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jp.pay.exception.PayjpException;
+import jp.pay.BasePayjpTest;
+import static org.junit.Assert.assertEquals;
+
+public class BalanceTest extends BasePayjpTest {
+ @Test
+ public void testDeserialize() throws PayjpException, IOException {
+ String json = resource("balance.json");
+ Balance balance = APIResource.GSON.fromJson(json, Balance.class);
+
+ assertEquals("ba_b92b879e60f62b532d6756ae56af", balance.getId());
+ assertEquals(Long.valueOf("1438354824"), balance.getCreated());
+ assertEquals(Boolean.FALSE, balance.getLivemode());
+ assertEquals(BigInteger.valueOf(Long.valueOf("12300000000")), balance.getNet());
+ assertEquals("ten_4f2a6b6b8f4b0f1e8b0fa8bca8b0", balance.getTenantId());
+ assertEquals("collecting", balance.getState());
+ assertEquals(Boolean.FALSE, balance.getClosed());
+ assertEquals(null, balance.getDueDate());
+
+ BankInfo bankInfo = balance.getBankInfo();
+ assertEquals("0000", bankInfo.getBankCode());
+ assertEquals("123", bankInfo.getBankBranchCode());
+ assertEquals("普通", bankInfo.getBankAccountType());
+ assertEquals("1234567", bankInfo.getBankAccountNumber());
+ assertEquals("ペイ タロウ", bankInfo.getBankAccountHolderName());
+ assertEquals("pending", bankInfo.getBankAccountStatus());
+
+ List statements = balance.getStatements();
+ assertEquals("st_178fd25dc7ab7b75906f1c3c4b0e6", statements.get(0).getId());
+ assertEquals("st_b4a569b0122a7d08b358f198cf263", statements.get(1).getId());
+ }
+
+ @Test
+ public void testRetrieve() throws PayjpException {
+ stubNetwork(Balance.class, "{\"id\":\"balance1\"}");
+ Balance balance = Balance.retrieve("balance1");
+ verifyGet(Balance.class, "https://api.pay.jp/v1/balances/balance1");
+ assertEquals(balance.getId(), "balance1");
+ }
+
+ @Test
+ public void testList() throws PayjpException {
+ Map listParams = new HashMap();
+ listParams.put("limit", 2);
+ stubNetwork(BalanceCollection.class, "{\"count\":2,\"data\":[{\"id\":\"balance1\"},{\"id\":\"balance2\"}]}");
+ List balances = Balance.all(listParams).getData();
+ verifyGet(BalanceCollection.class, "https://api.pay.jp/v1/balances", listParams);
+ assertEquals(balances.size(), 2);
+ assertEquals(balances.get(0).getId(), "balance1");
+ assertEquals(balances.get(1).getId(), "balance2");
+ }
+
+}
diff --git a/src/test/java/jp/pay/model/ChargeTest.java b/src/test/java/jp/pay/model/ChargeTest.java
index 236226a..425b143 100644
--- a/src/test/java/jp/pay/model/ChargeTest.java
+++ b/src/test/java/jp/pay/model/ChargeTest.java
@@ -84,6 +84,7 @@ public void testDeserialize() throws PayjpException, IOException {
assertNull(ch.getMetadata());
assertEquals("3.00", ch.getFeeRate());
assertEquals("attempt", ch.getThreeDSecureStatus());
+ assertEquals("tm_b92b879e60f62b532d6756ae12cc", ch.getTermId());
Card ca = ch.getCard();
assertEquals("car_d0e44730f83b0a19ba6caee04160", ca.getId());
diff --git a/src/test/java/jp/pay/model/DeserializerTest.java b/src/test/java/jp/pay/model/DeserializerTest.java
index 4c8a2fc..00c8f70 100644
--- a/src/test/java/jp/pay/model/DeserializerTest.java
+++ b/src/test/java/jp/pay/model/DeserializerTest.java
@@ -28,9 +28,9 @@
import org.junit.Test;
import java.io.IOException;
+import java.math.BigInteger;
import jp.pay.BasePayjpTest;
-import jp.pay.model.Event;
import jp.pay.net.APIResource;
import static org.junit.Assert.assertEquals;
@@ -48,4 +48,42 @@ public void deserializeEventDataAccountEvent() throws IOException {
Subscription sub = (Subscription)e.getData();
assertEquals("sub_dca9de79e5240009adb994d52974", sub.getId());
}
+
+ @Test
+ public void deserializeTermEvent() throws IOException {
+ String json = resource("term_event.json");
+ Event e = gson.fromJson(json, Event.class);
+
+ assertEquals(Term.class, e.getData().getClass());
+
+ Term term = (Term)e.getData();
+ assertEquals("tm_b92b879e60f62b532d6756ae12bb", term.getId());
+ }
+
+ @Test
+ public void deserializeStatementEvent() throws IOException {
+ String json = resource("statement_event.json");
+ Event e = gson.fromJson(json, Event.class);
+
+ assertEquals(Statement.class, e.getData().getClass());
+
+ Statement obj = (Statement)e.getData();
+ assertEquals("st_178fd25dc7ab7b75906f5d4c4b0e6", obj.getId());
+ assertEquals("ba_b92b879e60f62b532d6756ae90af", obj.getBalanceId());
+ assertEquals(BigInteger.valueOf(Long.valueOf("12340000000")), obj.getNet());
+
+ Term term = obj.getTerm();
+ assertEquals("tm_b92b879e60f62b532d6756ae12dd", term.getId());
+ }
+
+ @Test
+ public void deserializeBalanceEvent() throws IOException {
+ String json = resource("balance_event.json");
+ Event e = gson.fromJson(json, Event.class);
+
+ assertEquals(Balance.class, e.getData().getClass());
+
+ Balance obj = (Balance)e.getData();
+ assertEquals("ba_b92b879e60f62b532d6756ae78af", obj.getId());
+ }
}
diff --git a/src/test/java/jp/pay/model/TermTest.java b/src/test/java/jp/pay/model/TermTest.java
new file mode 100644
index 0000000..77c032c
--- /dev/null
+++ b/src/test/java/jp/pay/model/TermTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2010-2011 Stripe (http://stripe.com)
+ * Copyright (c) 2024 PAY, Inc. (http://pay.co.jp/)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.pay.model;
+
+
+import jp.pay.net.APIResource;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jp.pay.exception.PayjpException;
+import jp.pay.BasePayjpTest;
+import static org.junit.Assert.assertEquals;
+
+public class TermTest extends BasePayjpTest {
+ @Test
+ public void testDeserialize() throws PayjpException, IOException {
+ String json = resource("term.json");
+ Term term = APIResource.GSON.fromJson(json, Term.class);
+ assertEquals(Boolean.FALSE, term.getLivemode());
+ assertEquals("tm_b92b879e60f62b532d6756ae12aa", term.getId());
+ assertEquals(Long.valueOf("1438354802"), term.getStartAt());
+ assertEquals(Long.valueOf("1439650803"), term.getEndAt());
+ assertEquals((Integer)987, term.getChargeCount());
+ assertEquals((Integer)58, term.getRefundCount());
+ assertEquals((Integer)5, term.getDisputeCount());
+ }
+
+ @Test
+ public void testRetrieve() throws PayjpException {
+ stubNetwork(Term.class, "{\"id\":\"term1\"}");
+ Term term = Term.retrieve("term1");
+ verifyGet(Term.class, "https://api.pay.jp/v1/terms/term1");
+ assertEquals(term.getId(), "term1");
+ }
+
+ @Test
+ public void testList() throws PayjpException {
+ Map listParams = new HashMap();
+ listParams.put("limit", 2);
+ stubNetwork(TermCollection.class, "{\"count\":2,\"data\":[{\"id\":\"term1\"},{\"id\":\"term2\"}]}");
+ List terms = Term.all(listParams).getData();
+ verifyGet(TermCollection.class, "https://api.pay.jp/v1/terms", listParams);
+ assertEquals(terms.size(), 2);
+ assertEquals(terms.get(0).getId(), "term1");
+ assertEquals(terms.get(1).getId(), "term2");
+ }
+
+}
diff --git a/src/test/resources/jp/pay/model/balance.json b/src/test/resources/jp/pay/model/balance.json
new file mode 100755
index 0000000..f73df80
--- /dev/null
+++ b/src/test/resources/jp/pay/model/balance.json
@@ -0,0 +1,84 @@
+{
+ "created": 1438354824,
+ "id": "ba_b92b879e60f62b532d6756ae56af",
+ "livemode": false,
+ "net": 12300000000,
+ "object": "balance",
+ "state": "collecting",
+ "statements": [
+ {
+ "created": 1695892351,
+ "id": "st_178fd25dc7ab7b75906f1c3c4b0e6",
+ "items": [
+ {
+ "amount": 25,
+ "name": "チャージバックによる手数料返還",
+ "subject": "chargeback_fee_offset",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -775,
+ "name": "チャージバック",
+ "subject": "chargeback",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 36,
+ "name": "返金による手数料返還",
+ "subject": "refund_fee_offset",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -1800,
+ "name": "返金",
+ "subject": "gross_refund",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -75,
+ "name": "決済手数料",
+ "subject": "fee",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 3125,
+ "name": "売上",
+ "subject": "gross_sales",
+ "tax_rate": "0.00"
+ }
+ ],
+ "object": "statement",
+ "livemode": true,
+ "title": null,
+ "updated": 1695892351
+ },
+ {
+ "created": 1695892350,
+ "id": "st_b4a569b0122a7d08b358f198cf263",
+ "items": [
+ {
+ "amount": -10000,
+ "name": "プロプラン利用料",
+ "subject": "proplan",
+ "tax_rate": "10.00"
+ }
+ ],
+ "object": "statement",
+ "livemode": true,
+ "title": "プロプラン月額料金",
+ "updated": 1695892350
+ }
+ ],
+ "closed": false,
+ "due_date": null,
+ "bank_info": {
+ "bank_code": "0000",
+ "bank_branch_code": "123",
+ "bank_account_type": "普通",
+ "bank_account_number": "1234567",
+ "bank_account_holder_name": "ペイ タロウ",
+ "bank_account_status": "pending"
+ },
+
+ "tenant_id": "ten_4f2a6b6b8f4b0f1e8b0fa8bca8b0"
+}
\ No newline at end of file
diff --git a/src/test/resources/jp/pay/model/balance_event.json b/src/test/resources/jp/pay/model/balance_event.json
new file mode 100755
index 0000000..c1246cc
--- /dev/null
+++ b/src/test/resources/jp/pay/model/balance_event.json
@@ -0,0 +1,91 @@
+{
+ "created": 1432973142,
+ "data": {
+ "created": 1438354824,
+ "id": "ba_b92b879e60f62b532d6756ae78af",
+ "livemode": false,
+ "net": 12300000000,
+ "object": "balance",
+ "state": "collecting",
+ "statements": [
+ {
+ "created": 1695892351,
+ "id": "st_178fd25dc7ab7b75906f1c3c4b0e5",
+ "items": [
+ {
+ "amount": 25,
+ "name": "チャージバックによる手数料返還",
+ "subject": "chargeback_fee_offset",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -775,
+ "name": "チャージバック",
+ "subject": "chargeback",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 36,
+ "name": "返金による手数料返還",
+ "subject": "refund_fee_offset",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -1800,
+ "name": "返金",
+ "subject": "gross_refund",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -75,
+ "name": "決済手数料",
+ "subject": "fee",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 3125,
+ "name": "売上",
+ "subject": "gross_sales",
+ "tax_rate": "0.00"
+ }
+ ],
+ "object": "statement",
+ "livemode": true,
+ "title": null,
+ "updated": 1695892351
+ },
+ {
+ "created": 1695892350,
+ "id": "st_b4a569b0122a7d08b358f198cf263",
+ "items": [
+ {
+ "amount": -10000,
+ "name": "プロプラン利用料",
+ "subject": "proplan",
+ "tax_rate": "10.00"
+ }
+ ],
+ "object": "statement",
+ "livemode": true,
+ "title": "プロプラン月額料金",
+ "updated": 1695892350
+ }
+ ],
+ "closed": false,
+ "due_date": null,
+ "bank_info": {
+ "bank_code": "0000",
+ "bank_branch_code": "123",
+ "bank_account_type": "普通",
+ "bank_account_number": "1234567",
+ "bank_account_holder_name": "ペイ タロウ",
+ "bank_account_status": "pending"
+ },
+ "tenant_id": "ten_4f2a6b6b8f4b0f1e8b0fa8bca8b3"
+ },
+ "id": "evnt_2f7436fe0017098bc8d22221d1e",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "type": "balance.created"
+}
\ No newline at end of file
diff --git a/src/test/resources/jp/pay/model/charge.json b/src/test/resources/jp/pay/model/charge.json
index db37d9f..1b1027a 100755
--- a/src/test/resources/jp/pay/model/charge.json
+++ b/src/test/resources/jp/pay/model/charge.json
@@ -43,5 +43,6 @@
"subscription": null,
"tenant": "ten_121673955bd7aa144de5a8f6c262",
"total_platform_fee": 350,
- "three_d_secure_status": "attempt"
+ "three_d_secure_status": "attempt",
+ "term_id": "tm_b92b879e60f62b532d6756ae12cc"
}
\ No newline at end of file
diff --git a/src/test/resources/jp/pay/model/statement_event.json b/src/test/resources/jp/pay/model/statement_event.json
new file mode 100755
index 0000000..635184b
--- /dev/null
+++ b/src/test/resources/jp/pay/model/statement_event.json
@@ -0,0 +1,67 @@
+{
+ "created": 1432973142,
+ "data": {
+ "created": 1695892351,
+ "id": "st_178fd25dc7ab7b75906f5d4c4b0e6",
+ "items": [
+ {
+ "amount": 3125,
+ "name": "売上",
+ "subject": "gross_sales",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -75,
+ "name": "決済手数料",
+ "subject": "fee",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -1800,
+ "name": "返金",
+ "subject": "gross_refund",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 36,
+ "name": "返金による手数料返還",
+ "subject": "refund_fee_offset",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": -775,
+ "name": "チャージバック",
+ "subject": "chargeback",
+ "tax_rate": "0.00"
+ },
+ {
+ "amount": 25,
+ "name": "チャージバックによる手数料返還",
+ "subject": "chargeback_fee_offset",
+ "tax_rate": "0.00"
+ }
+ ],
+ "livemode": true,
+ "object": "statement",
+ "title": null,
+ "updated": 1695892351,
+ "term": {
+ "created": 1438354812,
+ "id": "tm_b92b879e60f62b532d6756ae12dd",
+ "livemode": false,
+ "object": "term",
+ "charge_count": 987,
+ "refund_count": 57,
+ "dispute_count": 4,
+ "end_at": 1439650800,
+ "start_at": 1438354801
+ },
+ "balance_id": "ba_b92b879e60f62b532d6756ae90af",
+ "net": 12340000000
+ },
+ "id": "evnt_2f7436fe0017098bc8d22221d1e",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "type": "statement.resumed"
+}
\ No newline at end of file
diff --git a/src/test/resources/jp/pay/model/term.json b/src/test/resources/jp/pay/model/term.json
new file mode 100755
index 0000000..22a269f
--- /dev/null
+++ b/src/test/resources/jp/pay/model/term.json
@@ -0,0 +1,10 @@
+{
+ "id": "tm_b92b879e60f62b532d6756ae12aa",
+ "livemode": false,
+ "object": "term",
+ "charge_count": 987,
+ "refund_count": 58,
+ "dispute_count": 5,
+ "end_at": 1439650803,
+ "start_at": 1438354802
+}
\ No newline at end of file
diff --git a/src/test/resources/jp/pay/model/term_event.json b/src/test/resources/jp/pay/model/term_event.json
new file mode 100755
index 0000000..0d54c71
--- /dev/null
+++ b/src/test/resources/jp/pay/model/term_event.json
@@ -0,0 +1,19 @@
+{
+ "created": 1432973142,
+ "data": {
+ "created": 1438354800,
+ "id": "tm_b92b879e60f62b532d6756ae12bb",
+ "livemode": false,
+ "object": "term",
+ "charge_count": 158,
+ "refund_count": 25,
+ "dispute_count": 2,
+ "end_at": 1439650800,
+ "start_at": 1438354801
+ },
+ "id": "evnt_2f7436fe0017098bc8d222215bc",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "type": "term.created"
+}
\ No newline at end of file