-
Notifications
You must be signed in to change notification settings - Fork 2
CC-2673/add-wero #178
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
Merged
Merged
CC-2673/add-wero #178
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0a15fc0
[CC-2673] Add wero method.
Ryouzanpaku 1079b69
[CC-2673] Add wero method.
Ryouzanpaku d5906ae
[CC-2673] Add wero method.
Ryouzanpaku 5bcc5e7
[CC-2673] Add wero method.
Ryouzanpaku 6fb13d6
[CC-2673] Add wero method.
Ryouzanpaku d05d0a5
[CC-2673] Add wero method.
Ryouzanpaku fb2902c
[CC-2673] Add wero method.
Ryouzanpaku 4978c8f
[CC-2673] Add orderId to klarna tests
Ryouzanpaku ec5a52e
[CC-2673] [CC-2787 ] Fix format for risk.registrationDate
Ryouzanpaku a81a4cb
[CC-2673] Cleanup tests.
Ryouzanpaku a09a151
[CC-2673] Cleanup tests.
Ryouzanpaku 2945b2b
[CC-2673] Cleanup tests.
Ryouzanpaku 245bfe6
[CC-2673] Update class name for EventDependentPayment.
Ryouzanpaku 16762b8
[CC-2673] Combine Wero test cases to minimize redundancy
Ryouzanpaku 49f623a
[CC-2673] Fix basket test assertThat usage.
Ryouzanpaku 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 hidden or 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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/unzer/payment/communication/RiskRegistrationDateConverter.java
This file contains hidden or 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,48 @@ | ||
| package com.unzer.payment.communication; | ||
|
|
||
| import com.google.gson.JsonDeserializationContext; | ||
| import com.google.gson.JsonDeserializer; | ||
| import com.google.gson.JsonElement; | ||
| import com.google.gson.JsonPrimitive; | ||
| import com.google.gson.JsonSerializationContext; | ||
| import com.google.gson.JsonSerializer; | ||
|
|
||
| import java.lang.reflect.Type; | ||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.Date; | ||
| import java.util.TimeZone; | ||
|
|
||
| /** | ||
| * Gson converter for dates in format yyyyMMdd. | ||
| */ | ||
| public class RiskRegistrationDateConverter implements JsonDeserializer<Date>, JsonSerializer<Date> { | ||
|
|
||
| public static final String DATE_FORMAT = "yyyyMMdd"; | ||
|
|
||
| @Override | ||
| public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { | ||
| String value = json.getAsString(); | ||
| if (value == null || value.isEmpty()) { | ||
| return null; | ||
| } | ||
| SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); | ||
| df.setLenient(false); | ||
| // Interpret as UTC start of day when only date is given | ||
| df.setTimeZone(TimeZone.getTimeZone("UTC")); | ||
| try { | ||
| return df.parse(value); | ||
| } catch (ParseException e) { | ||
| throw new RuntimeException("Failed to parse date in format '" + DATE_FORMAT + "': " + value, e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { | ||
| SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); | ||
| df.setLenient(false); | ||
| df.setTimeZone(TimeZone.getTimeZone("UTC")); | ||
| return new JsonPrimitive(df.format(src)); | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/unzer/payment/models/WeroEventDependentPayment.java
This file contains hidden or 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,41 @@ | ||
| package com.unzer.payment.models; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import lombok.Data; | ||
|
|
||
| /** | ||
| * Event dependent payment configuration for Wero payments. | ||
Ryouzanpaku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| @Data | ||
| public class WeroEventDependentPayment { | ||
| private CaptureTrigger captureTrigger; | ||
| private AmountPaymentType amountPaymentType; | ||
| /** | ||
| * Maximum time from authorization to capture in seconds. | ||
| */ | ||
| private Integer maxAuthToCaptureTime; | ||
| /** | ||
| * Whether multiple captures are allowed. | ||
| */ | ||
| private Boolean multiCapturesAllowed; | ||
|
|
||
| public enum CaptureTrigger { | ||
| @SerializedName("shipping") | ||
| SHIPPING, | ||
| @SerializedName("delivery") | ||
| DELIVERY, | ||
| @SerializedName("availability") | ||
| AVAILABILITY, | ||
| @SerializedName("servicefulfilment") | ||
| SERVICEFULFILMENT, | ||
| @SerializedName("other") | ||
| OTHER | ||
| } | ||
|
|
||
| public enum AmountPaymentType { | ||
| @SerializedName("pay") | ||
| PAY, | ||
| @SerializedName("payupto") | ||
| PAYUPTO | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/main/java/com/unzer/payment/models/WeroTransactionData.java
This file contains hidden or 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,16 @@ | ||
| package com.unzer.payment.models; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| import com.fasterxml.jackson.annotation.JsonTypeName; | ||
| import lombok.Data; | ||
|
|
||
| /** | ||
| * Additional transaction data for Wero payments. | ||
| * Wrapped under the key "wero" inside additionalTransactionData. | ||
| */ | ||
| @Data | ||
| @JsonTypeName("wero") | ||
| @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) | ||
| public class WeroTransactionData { | ||
| private WeroEventDependentPayment eventDependentPayment; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| package com.unzer.payment.paymenttypes; | ||
|
|
||
| import com.unzer.payment.GeoLocation; | ||
| import com.unzer.payment.communication.json.ApiIdObject; | ||
| import com.unzer.payment.communication.json.ApiObject; | ||
|
|
||
| public class Wero extends BasePaymentType { | ||
|
|
||
| @Override | ||
| public String getResourceUrl() { | ||
| return "/v1/types/wero/<resourceId>"; | ||
| } | ||
|
|
||
| @Override | ||
| public PaymentType map(PaymentType wero, ApiObject jsonId) { | ||
| ((Wero) wero).setId(jsonId.getId()); | ||
| ((Wero) wero).setRecurring(((ApiIdObject) jsonId).getRecurring()); | ||
| GeoLocation tempGeoLocation = | ||
| new GeoLocation(((ApiIdObject) jsonId).getGeoLocation().getClientIp(), | ||
| ((ApiIdObject) jsonId).getGeoLocation().getCountryIsoA2()); | ||
| ((Wero) wero).setGeoLocation(tempGeoLocation); | ||
| return wero; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.