-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add endpoints about ThreeDSecureRequest object. #45
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.7.3 | ||
0.8.0 |
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
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,91 @@ | ||
/* | ||
* 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"); | ||
verifyPost(ThreeDSecureRequest.class, "https://api.pay.jp/v1/three_d_secure_requests", createThreeDSecureRequestParams); | ||
} | ||
} |
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" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここら辺に
verifyPost(ThreeDSecureRequest.class, "https://api.pay.jp/v1/three_d_secure_requests", createThreeDSecureRequestParams);
とか追加したいThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました✍
イメージあってますかね?
8c52bf7