-
Notifications
You must be signed in to change notification settings - Fork 140
[PW-1774]Implement SaleToAcquirerDataModel for sending SaleToAcq… #277
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33d85e0
[WIP][PW-1774]Implement SaleToAcquirerDataModel for sending SaleToAcq…
rikterbeek 0201b57
fix checkstyle issues
rikterbeek f8894a9
change key for test
rikterbeek 813301f
change key for test
rikterbeek 19528d3
Update version to 4.0.0 as breaking change for POS terminal impl.
rikterbeek bed05c7
Always initialize the saleData so applicationInfo is set.
rikterbeek e698944
fix naming
rikterbeek 0dd1378
revert changes
rikterbeek 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
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
210 changes: 210 additions & 0 deletions
210
src/main/java/com/adyen/model/terminal/SaleToAcquirerData.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,210 @@ | ||
/* | ||
* ###### | ||
* ###### | ||
* ############ ####( ###### #####. ###### ############ ############ | ||
* ############# #####( ###### #####. ###### ############# ############# | ||
* ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ###### | ||
* ############# ############# ############# ############# ##### ###### | ||
* ############ ############ ############# ############ ##### ###### | ||
* ###### | ||
* ############# | ||
* ############ | ||
* | ||
* Adyen Java API Library | ||
* | ||
* Copyright (c) 2019 Adyen B.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
*/ | ||
package com.adyen.model.terminal; | ||
|
||
import com.adyen.model.applicationinfo.ApplicationInfo; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import org.apache.commons.codec.binary.Base64; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class SaleToAcquirerData { | ||
|
||
private Map<String, String> metadata; | ||
private String shopperEmail; | ||
private String shopperReference; | ||
private String recurringContract; | ||
private String shopperStatement; | ||
private String recurringDetailName; | ||
private String recurringTokenService; | ||
private String store; | ||
private String merchantAccount; | ||
private String currency; | ||
private ApplicationInfo applicationInfo; | ||
private String tenderOption; | ||
private Map<String, String> additionalData; | ||
private static final Gson PRETTY_PRINT_GSON = new GsonBuilder().setPrettyPrinting().create(); | ||
|
||
public SaleToAcquirerData() { | ||
if (this.applicationInfo == null) { | ||
this.applicationInfo = new ApplicationInfo(); | ||
} | ||
} | ||
|
||
public Map<String, String> getMetadata() { | ||
return metadata; | ||
} | ||
|
||
public void setMetadata(Map<String, String> metadata) { | ||
this.metadata = metadata; | ||
} | ||
|
||
public String getShopperEmail() { | ||
return shopperEmail; | ||
} | ||
|
||
public void setShopperEmail(String shopperEmail) { | ||
this.shopperEmail = shopperEmail; | ||
} | ||
|
||
public String getShopperReference() { | ||
return shopperReference; | ||
} | ||
|
||
public void setShopperReference(String shopperReference) { | ||
this.shopperReference = shopperReference; | ||
} | ||
|
||
public String getRecurringContract() { | ||
return recurringContract; | ||
} | ||
|
||
public void setRecurringContract(String recurringContract) { | ||
this.recurringContract = recurringContract; | ||
} | ||
|
||
public String getShopperStatement() { | ||
return shopperStatement; | ||
} | ||
|
||
public void setShopperStatement(String shopperStatement) { | ||
this.shopperStatement = shopperStatement; | ||
} | ||
|
||
public String getRecurringDetailName() { | ||
return recurringDetailName; | ||
} | ||
|
||
public void setRecurringDetailName(String recurringDetailName) { | ||
this.recurringDetailName = recurringDetailName; | ||
} | ||
|
||
public String getRecurringTokenService() { | ||
return recurringTokenService; | ||
} | ||
|
||
public void setRecurringTokenService(String recurringTokenService) { | ||
this.recurringTokenService = recurringTokenService; | ||
} | ||
|
||
public String getStore() { | ||
return store; | ||
} | ||
|
||
public void setStore(String store) { | ||
this.store = store; | ||
} | ||
|
||
public String getMerchantAccount() { | ||
return merchantAccount; | ||
} | ||
|
||
public void setMerchantAccount(String merchantAccount) { | ||
this.merchantAccount = merchantAccount; | ||
} | ||
|
||
public String getCurrency() { | ||
return currency; | ||
} | ||
|
||
public void setCurrency(String currency) { | ||
this.currency = currency; | ||
} | ||
|
||
public ApplicationInfo getApplicationInfo() { | ||
return applicationInfo; | ||
} | ||
|
||
public void setApplicationInfo(ApplicationInfo applicationInfo) { | ||
this.applicationInfo = applicationInfo; | ||
} | ||
|
||
public String getTenderOption() { | ||
return tenderOption; | ||
} | ||
|
||
public void setTenderOption(String tenderOption) { | ||
this.tenderOption = tenderOption; | ||
} | ||
|
||
public Map<String, String> getAdditionalData() { | ||
return additionalData; | ||
} | ||
|
||
public void setAdditionalData(Map<String, String> additionalData) { | ||
this.additionalData = additionalData; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
SaleToAcquirerData that = (SaleToAcquirerData) o; | ||
return Objects.equals(metadata, that.metadata) && | ||
Objects.equals(shopperEmail, that.shopperEmail) && | ||
Objects.equals(shopperReference, that.shopperReference) && | ||
Objects.equals(recurringContract, that.recurringContract) && | ||
Objects.equals(shopperStatement, that.shopperStatement) && | ||
Objects.equals(recurringDetailName, that.recurringDetailName) && | ||
Objects.equals(recurringTokenService, that.recurringTokenService) && | ||
Objects.equals(store, that.store) && | ||
Objects.equals(merchantAccount, that.merchantAccount) && | ||
Objects.equals(currency, that.currency) && | ||
Objects.equals(applicationInfo, that.applicationInfo) && | ||
Objects.equals(tenderOption, that.tenderOption) && | ||
Objects.equals(additionalData, that.additionalData); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(metadata, shopperEmail, shopperReference, recurringContract, shopperStatement, recurringDetailName, recurringTokenService, store, merchantAccount, currency, applicationInfo, tenderOption, additionalData); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SaleToAcquirerDataModel{" + | ||
"metadata=" + metadata + | ||
", shopperEmail='" + shopperEmail + '\'' + | ||
", shopperReference='" + shopperReference + '\'' + | ||
", recurringContract='" + recurringContract + '\'' + | ||
", shopperStatement='" + shopperStatement + '\'' + | ||
", recurringDetailName='" + recurringDetailName + '\'' + | ||
", recurringTokenService='" + recurringTokenService + '\'' + | ||
", store='" + store + '\'' + | ||
", merchantAccount='" + merchantAccount + '\'' + | ||
", currency='" + currency + '\'' + | ||
", applicationInfo=" + applicationInfo + | ||
", tenderOption='" + tenderOption + '\'' + | ||
", additionalData=" + additionalData + | ||
'}'; | ||
} | ||
|
||
public String toBase64() { | ||
String json = PRETTY_PRINT_GSON.toJson(this); | ||
return new String(Base64.encodeBase64(json.getBytes())); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/adyen/serializer/SaleToAcquirerDataSerializer.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.adyen.serializer; | ||
|
||
import com.adyen.model.terminal.SaleToAcquirerData; | ||
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; | ||
|
||
public class SaleToAcquirerDataSerializer implements JsonSerializer<SaleToAcquirerData> { | ||
|
||
public JsonElement serialize(SaleToAcquirerData saleToAcquirerData, Type typeOfSrc, JsonSerializationContext context) { | ||
return new JsonPrimitive(saleToAcquirerData.toBase64()); | ||
} | ||
} |
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.
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.
Removing/changing type saleToAcquirerData field means release won't be backward compatible.
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.
correct I don't see any other way.