Repository navigation
[CC-4345] Support SECCI /plans endpoint for Paylater Invoice and Direct Debit (CCD2) #198
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
Open
Ryouzanpaku
wants to merge
11
commits into
main
Choose a base branch
from
feature/CC-4345-secci-paylater-plans
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1211bf9
[CC-4345] Support SECCI /plans endpoint for Paylater Invoice and Dire…
Ryouzanpaku 227e5a0
[CC-4345] Address Copilot review: restore BC setters and mapping over…
Ryouzanpaku 505ed2d
[CC-4345] Address Copilot review: URL-encode query values, null-safe …
Ryouzanpaku afe78cb
[CC-4345] Address Copilot review: URL-encode amount query value
Ryouzanpaku 3539c7e
[CC-4345] Broaden fetch+mapping test to all three plan types
Ryouzanpaku fcf9731
[CC-4345] Un-gate Paylater invoice/direct-debit integration tests
Ryouzanpaku dffc1e4
[CC-4345] Finalize integration error assertions generically
Ryouzanpaku b2bb751
[CC-4345] Apply review findings: tighten tests, encode customerType, …
Ryouzanpaku 0a5ba08
[CC-4345] Expose minimumInstallmentFee on InstallmentPlan
Ryouzanpaku 42f2905
[CC-4345] Assert zero amount is accepted by PAPI plans endpoint
Ryouzanpaku 52a689f
[CC-4345] Apply review feedback: release ownership, amount formatting…
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
88 changes: 21 additions & 67 deletions
88
src/main/java/com/unzer/payment/PaylaterInstallmentPlans.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 |
|---|---|---|
| @@ -1,104 +1,58 @@ | ||
| package com.unzer.payment; | ||
|
|
||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlan; | ||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlanRate; | ||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlans; | ||
| import com.unzer.payment.models.paylater.InstallmentPlan; | ||
| import com.unzer.payment.models.paylater.InstallmentPlanRate; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.Currency; | ||
| import java.util.List; | ||
|
|
||
| public class PaylaterInstallmentPlans { | ||
| /** | ||
| * @deprecated Use {@link PaylaterPlans} instead. Kept as a backward-compatible alias returned by | ||
| * {@link Unzer#fetchPaylaterInstallmentPlans(com.unzer.payment.models.paylater.InstallmentPlansRequest)}. | ||
| * The covariant setter overrides and the {@code map} overload are retained to preserve source and | ||
| * binary compatibility for existing callers. | ||
| */ | ||
| @Deprecated | ||
| public class PaylaterInstallmentPlans extends PaylaterPlans { | ||
|
|
||
| private String id; | ||
|
|
||
| private BigDecimal amount; | ||
| private Currency currency; | ||
| private List<InstallmentPlan> plans = new ArrayList<>(); | ||
| private BaseTransaction.Status status; | ||
|
|
||
| public BigDecimal getAmount() { | ||
| return amount; | ||
| public String getTypeUrl() { | ||
| return "types/paylater-installment/plans"; | ||
| } | ||
|
|
||
| @Override | ||
| public PaylaterInstallmentPlans setAmount(BigDecimal amount) { | ||
| this.amount = amount; | ||
| super.setAmount(amount); | ||
| return this; | ||
| } | ||
|
|
||
| public Currency getCurrency() { | ||
| return currency; | ||
| } | ||
|
|
||
| @Override | ||
| public PaylaterInstallmentPlans setCurrency(Currency currency) { | ||
| this.currency = currency; | ||
| super.setCurrency(currency); | ||
| return this; | ||
| } | ||
|
|
||
| public List<InstallmentPlan> getPlans() { | ||
| return plans; | ||
| } | ||
|
|
||
| @Override | ||
| public PaylaterInstallmentPlans setPlans(List<InstallmentPlan> plans) { | ||
| this.plans = plans; | ||
| super.setPlans(plans); | ||
| return this; | ||
| } | ||
|
|
||
| public String getTypeUrl() { | ||
| return "types/paylater-installment/plans"; | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public PaylaterInstallmentPlans setId(String id) { | ||
| this.id = id; | ||
| super.setId(id); | ||
| return this; | ||
| } | ||
|
|
||
| public BaseTransaction.Status getStatus() { | ||
| return status; | ||
| } | ||
|
|
||
| @Override | ||
| public PaylaterInstallmentPlans setStatus(BaseTransaction.Status status) { | ||
| this.status = status; | ||
| super.setStatus(status); | ||
| return this; | ||
| } | ||
|
|
||
| public PaylaterInstallmentPlans map(PaylaterInstallmentPlans installmentPlans, | ||
| ApiInstallmentPlans jsonInstallmentPlans) { | ||
| if (installmentPlans != null && jsonInstallmentPlans != null) { | ||
| installmentPlans.setId((jsonInstallmentPlans).getId()) | ||
| .setAmount(jsonInstallmentPlans.getAmount()) | ||
| .setCurrency(jsonInstallmentPlans.getCurrency()); | ||
|
|
||
| map(installmentPlans.getPlans(), jsonInstallmentPlans.getPlans()); | ||
| } | ||
| super.map(installmentPlans, jsonInstallmentPlans); | ||
| return installmentPlans; | ||
| } | ||
|
|
||
| private void map(List<InstallmentPlan> installmentPlan, | ||
| List<ApiInstallmentPlan> jsonInstallmentPlan) { | ||
| jsonInstallmentPlan.forEach((plan) -> { | ||
| List<InstallmentPlanRate> planRates = new ArrayList<InstallmentPlanRate>(); | ||
| mapRates(planRates, plan.getInstallmentRates()); | ||
| installmentPlan.add(new InstallmentPlan().setTotalAmount(plan.getTotalAmount()) | ||
| .setNumberOfRates(plan.getNumberOfRates()) | ||
| .setNominalInterestRate(plan.getNominalInterestRate()) | ||
| .setEffectiveInterestRate(plan.getEffectiveInterestRate()).setInstallmentRates(planRates) | ||
| .setSecciUrl(plan.getSecciUrl())); | ||
| }); | ||
| } | ||
|
|
||
| private void mapRates(List<InstallmentPlanRate> installmentPlanRates, | ||
| List<ApiInstallmentPlanRate> json) { | ||
| json.forEach((rate) -> { | ||
| installmentPlanRates.add( | ||
| new InstallmentPlanRate().setRate(rate.getRate()).setDate(rate.getDate())); | ||
| }); | ||
| } | ||
| } | ||
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,107 @@ | ||
| package com.unzer.payment; | ||
|
|
||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlan; | ||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlanRate; | ||
| import com.unzer.payment.communication.json.paylater.ApiInstallmentPlans; | ||
| import com.unzer.payment.models.paylater.InstallmentPlan; | ||
| import com.unzer.payment.models.paylater.InstallmentPlanRate; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.Currency; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Available plans returned by the Paylater {@code /plans} endpoints | ||
| * (installment, invoice or direct debit). Each plan carries its SECCI document url. | ||
| */ | ||
| public class PaylaterPlans { | ||
|
|
||
| private String id; | ||
|
|
||
| private BigDecimal amount; | ||
| private Currency currency; | ||
| private List<InstallmentPlan> plans = new ArrayList<>(); | ||
| private BaseTransaction.Status status; | ||
|
|
||
| public BigDecimal getAmount() { | ||
| return amount; | ||
| } | ||
|
|
||
| public PaylaterPlans setAmount(BigDecimal amount) { | ||
| this.amount = amount; | ||
| return this; | ||
| } | ||
|
|
||
| public Currency getCurrency() { | ||
| return currency; | ||
| } | ||
|
|
||
| public PaylaterPlans setCurrency(Currency currency) { | ||
| this.currency = currency; | ||
| return this; | ||
| } | ||
|
|
||
| public List<InstallmentPlan> getPlans() { | ||
| return plans; | ||
| } | ||
|
|
||
| public PaylaterPlans setPlans(List<InstallmentPlan> plans) { | ||
| this.plans = plans; | ||
| return this; | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public PaylaterPlans setId(String id) { | ||
| this.id = id; | ||
| return this; | ||
| } | ||
|
|
||
| public BaseTransaction.Status getStatus() { | ||
| return status; | ||
| } | ||
|
|
||
| public PaylaterPlans setStatus(BaseTransaction.Status status) { | ||
| this.status = status; | ||
| return this; | ||
| } | ||
|
|
||
| public PaylaterPlans map(PaylaterPlans paylaterPlans, ApiInstallmentPlans jsonPlans) { | ||
| if (paylaterPlans != null && jsonPlans != null) { | ||
| paylaterPlans.setId(jsonPlans.getId()) | ||
| .setAmount(jsonPlans.getAmount()) | ||
| .setCurrency(jsonPlans.getCurrency()); | ||
|
|
||
| map(paylaterPlans.getPlans(), jsonPlans.getPlans()); | ||
| } | ||
| return paylaterPlans; | ||
| } | ||
|
|
||
| private void map(List<InstallmentPlan> plans, List<ApiInstallmentPlan> jsonPlans) { | ||
| if (jsonPlans == null) { | ||
| return; | ||
| } | ||
| jsonPlans.forEach((plan) -> { | ||
| List<InstallmentPlanRate> planRates = new ArrayList<>(); | ||
| mapRates(planRates, plan.getInstallmentRates()); | ||
| plans.add(new InstallmentPlan().setTotalAmount(plan.getTotalAmount()) | ||
| .setNumberOfRates(plan.getNumberOfRates()) | ||
| .setNominalInterestRate(plan.getNominalInterestRate()) | ||
| .setEffectiveInterestRate(plan.getEffectiveInterestRate()) | ||
| .setInstallmentRates(planRates) | ||
| .setSecciUrl(plan.getSecciUrl()) | ||
| .setMinimumInstallmentFee(plan.getMinimumInstallmentFee())); | ||
| }); | ||
| } | ||
|
|
||
| private void mapRates(List<InstallmentPlanRate> planRates, List<ApiInstallmentPlanRate> json) { | ||
| if (json == null) { | ||
| return; | ||
| } | ||
| json.forEach((rate) -> | ||
| planRates.add(new InstallmentPlanRate().setRate(rate.getRate()).setDate(rate.getDate()))); | ||
| } | ||
| } |
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
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.