-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoints about ThreeDSecureRequest object.
- Loading branch information
Showing
5 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package jp.pay.model; | ||
|
||
import jp.pay.exception.*; | ||
import jp.pay.net.APIResource; | ||
import jp.pay.net.APIResource.RequestMethod; | ||
import jp.pay.net.RequestOptions; | ||
|
||
import java.util.Map; | ||
|
||
public class ThreeDSecureRequest extends APIResource { | ||
String id; | ||
String resourceId; | ||
Boolean livemode; | ||
Long created; | ||
String state; | ||
Long startedAt; | ||
Long resultReceivedAt; | ||
Long finishedAt; | ||
Long expiredAt; | ||
String tenantId; | ||
String threeDSecureStatus; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getResourceId() { | ||
return resourceId; | ||
} | ||
|
||
public Boolean getLivemode() { | ||
return livemode; | ||
} | ||
|
||
public Long getCreated() { | ||
return created; | ||
} | ||
|
||
public String getState() { | ||
return state; | ||
} | ||
|
||
public Long getStartedAt() { | ||
return startedAt; | ||
} | ||
|
||
public Long getResultReceivedAt() { | ||
return resultReceivedAt; | ||
} | ||
|
||
public Long getFinishedAt() { | ||
return finishedAt; | ||
} | ||
|
||
public Long getExpiredAt() { | ||
return expiredAt; | ||
} | ||
|
||
public String getTenantId() { | ||
return tenantId; | ||
} | ||
|
||
public String getThreeDSecureStatus() { | ||
return threeDSecureStatus; | ||
} | ||
|
||
public static ThreeDSecureRequest retrieve(String id) throws AuthenticationException, | ||
InvalidRequestException, APIConnectionException, | ||
CardException, APIException { | ||
return retrieve(id, (RequestOptions) null); | ||
} | ||
|
||
public static ThreeDSecureRequestCollection all(Map<String, Object> params) | ||
throws AuthenticationException, InvalidRequestException, | ||
APIConnectionException, CardException, APIException { | ||
return all(params, (RequestOptions) null); | ||
} | ||
|
||
public static ThreeDSecureRequest create(Map<String, Object> params) | ||
throws AuthenticationException, InvalidRequestException, | ||
APIConnectionException, CardException, APIException { | ||
return create(params, (RequestOptions) null); | ||
} | ||
|
||
public static ThreeDSecureRequest retrieve(String id, RequestOptions options) | ||
throws AuthenticationException, InvalidRequestException, | ||
APIConnectionException, CardException, APIException { | ||
return request(RequestMethod.GET, instanceURL( | ||
ThreeDSecureRequest.class, id), null, ThreeDSecureRequest.class, options); | ||
} | ||
|
||
public static ThreeDSecureRequestCollection all(Map<String, Object> params, | ||
RequestOptions options) throws AuthenticationException, | ||
InvalidRequestException, APIConnectionException, | ||
CardException, APIException { | ||
return request(RequestMethod.GET, classURL( | ||
ThreeDSecureRequest.class), params, ThreeDSecureRequestCollection.class, options); | ||
} | ||
|
||
public static ThreeDSecureRequest create(Map<String, Object> params, RequestOptions options) | ||
throws AuthenticationException, InvalidRequestException, | ||
APIConnectionException, CardException, APIException { | ||
return request(RequestMethod.POST, classURL(ThreeDSecureRequest.class), params, | ||
ThreeDSecureRequest.class, options); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/jp/pay/model/ThreeDSecureRequestCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package jp.pay.model; | ||
|
||
public class ThreeDSecureRequestCollection extends PayjpCollection<ThreeDSecureRequest> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.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; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class ThreeDSecureRequestTest extends BasePayjpTest { | ||
@Test | ||
public void testDeserialize() throws PayjpException, IOException { | ||
String json = resource("three_d_secure_request.json"); | ||
ThreeDSecureRequest threeDSecureRequest = APIResource.GSON.fromJson(json, ThreeDSecureRequest.class); | ||
assertEquals(threeDSecureRequest.getId(), "tdsr_125192559c91c4011c1ff56f50a"); | ||
assertEquals(threeDSecureRequest.getResourceId(), "car_4ec110e0700daf893160424fe03c"); | ||
assertEquals(threeDSecureRequest.getLivemode(), true); | ||
assertEquals(threeDSecureRequest.getCreated().longValue(), 1730084767); | ||
assertEquals(threeDSecureRequest.getState(), "created"); | ||
assertEquals(threeDSecureRequest.getThreeDSecureStatus(), "unverified"); | ||
assertEquals(threeDSecureRequest.getStartedAt(), null); | ||
assertEquals(threeDSecureRequest.getResultReceivedAt(), null); | ||
assertEquals(threeDSecureRequest.getFinishedAt(), null); | ||
assertEquals(threeDSecureRequest.getExpiredAt(), null); | ||
assertEquals(threeDSecureRequest.getTenantId(), null); | ||
} | ||
|
||
@Test | ||
public void testRetrieve() throws PayjpException { | ||
stubNetwork(ThreeDSecureRequest.class, "{\"id\":\"tdsr_xxxxx\"}"); | ||
ThreeDSecureRequest threeDSecureRequest = ThreeDSecureRequest.retrieve("tdsr_xxxxx"); | ||
verifyGet(ThreeDSecureRequest.class, "https://api.pay.jp/v1/three_d_secure_requests/tdsr_xxxxx"); | ||
assertEquals(threeDSecureRequest.getId(), "tdsr_xxxxx"); | ||
} | ||
|
||
@Test | ||
public void testList() throws PayjpException { | ||
Map<String, Object> listParams = new HashMap<String, Object>(); | ||
listParams.put("limit", 2); | ||
stubNetwork(ThreeDSecureRequestCollection.class, "{\"count\":2,\"data\":[{\"id\":\"tdsr_xxxxx\"},{\"id\":\"tdsr_yyyyy\"}]}"); | ||
List<ThreeDSecureRequest> threeDSecureRequests = ThreeDSecureRequest.all(listParams).getData(); | ||
verifyGet(ThreeDSecureRequestCollection.class, "https://api.pay.jp/v1/three_d_secure_requests", listParams); | ||
assertEquals(threeDSecureRequests.size(), 2); | ||
assertEquals(threeDSecureRequests.get(0).getId(), "tdsr_xxxxx"); | ||
assertEquals(threeDSecureRequests.get(1).getId(), "tdsr_yyyyy"); | ||
} | ||
|
||
@Test | ||
public void testCreate() throws PayjpException { | ||
stubNetwork(ThreeDSecureRequest.class, "{\"id\":tdsr_xxxxx,\"resource_id\":car_xxxxx}"); | ||
Map<String, Object> createThreeDSecureRequestParams = new HashMap<String, Object>(); | ||
createThreeDSecureRequestParams.put("resource_id", "car_xxxxx"); | ||
ThreeDSecureRequest threeDSecureRequest = ThreeDSecureRequest.create(createThreeDSecureRequestParams); | ||
assertEquals(threeDSecureRequest.getId(), "tdsr_xxxxx"); | ||
assertEquals(threeDSecureRequest.getResourceId(), "car_xxxxx"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/jp/pay/model/three_d_secure_request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"created": 1730084767, | ||
"expired_at": null, | ||
"finished_at": null, | ||
"id": "tdsr_125192559c91c4011c1ff56f50a", | ||
"livemode": true, | ||
"object": "three_d_secure_request", | ||
"resource_id": "car_4ec110e0700daf893160424fe03c", | ||
"result_received_at": null, | ||
"started_at": null, | ||
"state": "created", | ||
"tenant_id": null, | ||
"three_d_secure_status": "unverified" | ||
} |