-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Silviana Ghita
committed
Sep 13, 2023
1 parent
7b7918f
commit d6cde0a
Showing
9 changed files
with
279 additions
and
26 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
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 |
---|---|---|
|
@@ -57,5 +57,10 @@ public enum PayInPaymentType { | |
/** | ||
* MBWAY payment type | ||
*/ | ||
MBWAY | ||
MBWAY, | ||
|
||
/** | ||
* KLARNA payment type | ||
*/ | ||
KLARNA | ||
} |
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
126 changes: 126 additions & 0 deletions
126
src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsKlarna.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,126 @@ | ||
package com.mangopay.entities.subentities; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import com.mangopay.core.Billing; | ||
import com.mangopay.core.Dto; | ||
import com.mangopay.core.LineItem; | ||
import com.mangopay.core.Shipping; | ||
import com.mangopay.core.interfaces.PayInPaymentDetails; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Class representing the KLARNA type for mean of payment in PayIn entity. | ||
*/ | ||
public class PayInPaymentDetailsKlarna extends Dto implements PayInPaymentDetails { | ||
|
||
@SerializedName("LineItems") | ||
private List<LineItem> lineItems; | ||
|
||
@SerializedName("Shipping") | ||
private Shipping shipping; | ||
|
||
@SerializedName("Billing") | ||
private Billing billing; | ||
|
||
@SerializedName("PaymentMethod") | ||
private String paymentMethod; | ||
|
||
@SerializedName("Country") | ||
private String country; | ||
|
||
@SerializedName("Culture") | ||
private String culture; | ||
|
||
@SerializedName("AdditionalData") | ||
private String additionalData; | ||
|
||
@SerializedName("Phone") | ||
private String phone; | ||
|
||
@SerializedName("Email") | ||
private String email; | ||
|
||
@SerializedName("MerchantOrderId") | ||
private String merchantOrderId; | ||
|
||
public List<LineItem> getLineItems() { | ||
return lineItems; | ||
} | ||
|
||
public void setLineItems(List<LineItem> lineItems) { | ||
this.lineItems = lineItems; | ||
} | ||
|
||
public Shipping getShipping() { | ||
return shipping; | ||
} | ||
|
||
public void setShipping(Shipping shipping) { | ||
this.shipping = shipping; | ||
} | ||
|
||
public Billing getBilling() { | ||
return billing; | ||
} | ||
|
||
public void setBilling(Billing billing) { | ||
this.billing = billing; | ||
} | ||
|
||
public String getPaymentMethod() { | ||
return paymentMethod; | ||
} | ||
|
||
public void setPaymentMethod(String paymentMethod) { | ||
this.paymentMethod = paymentMethod; | ||
} | ||
|
||
public String getCountry() { | ||
return country; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
|
||
public String getCulture() { | ||
return culture; | ||
} | ||
|
||
public void setCulture(String culture) { | ||
this.culture = culture; | ||
} | ||
|
||
public String getAdditionalData() { | ||
return additionalData; | ||
} | ||
|
||
public void setAdditionalData(String additionalData) { | ||
this.additionalData = additionalData; | ||
} | ||
|
||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getMerchantOrderId() { | ||
return merchantOrderId; | ||
} | ||
|
||
public void setMerchantOrderId(String merchantOrderId) { | ||
this.merchantOrderId = merchantOrderId; | ||
} | ||
} |
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,2 +1,2 @@ | ||
#Fri Jul 28 16:19:09 EEST 2023 | ||
#Wed Sep 13 11:15:01 EEST 2023 | ||
version=2.30.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,9 +222,9 @@ protected UserLegal getMatrix() throws Exception { | |
} | ||
|
||
/** | ||
Current optional fields are: | ||
HeadquartersAddress, LegalRepresentativeAddress, LegalRepresentativeEmail, CompanyNumber | ||
*/ | ||
* Current optional fields are: | ||
* HeadquartersAddress, LegalRepresentativeAddress, LegalRepresentativeEmail, CompanyNumber | ||
*/ | ||
protected UserLegal getMatrixWithoutOptionalFields() throws Exception { | ||
if (BaseTest.MATRIX == null) { | ||
UserNatural john = this.getJohn(); | ||
|
@@ -483,8 +483,8 @@ private PayInExecutionDetailsWeb getPayInExecutionDetailsWeb() { | |
BaseTest.PAYIN_EXECUTION_DETAILS_WEB.setSecureMode(SecureMode.DEFAULT); | ||
BaseTest.PAYIN_EXECUTION_DETAILS_WEB.setCulture(CultureCode.FR); | ||
BaseTest.PAYIN_EXECUTION_DETAILS_WEB.setReturnUrl("https://test.com"); | ||
if(BaseTest.PAYIN_TEMPLATE_URL_OPTIONS == null) { | ||
|
||
if (BaseTest.PAYIN_TEMPLATE_URL_OPTIONS == null) { | ||
BaseTest.PAYIN_TEMPLATE_URL_OPTIONS = new PayInTemplateURLOptions(); | ||
BaseTest.PAYIN_TEMPLATE_URL_OPTIONS.PAYLINE = "https://www.maysite.com/payline_template/"; | ||
BaseTest.PAYIN_TEMPLATE_URL_OPTIONS.PAYLINEV2 = "https://www.maysite.com/payline_template/"; | ||
|
@@ -556,6 +556,12 @@ protected PayIn getNewPayInMbwayDirect(String userId) throws Exception { | |
return this.api.getPayInApi().create(payIn); | ||
} | ||
|
||
protected PayIn getNewPayInKlarnaWeb(String userId) throws Exception { | ||
PayIn payIn = getPayInKlarnaWeb(userId); | ||
|
||
return this.api.getPayInApi().create(payIn); | ||
} | ||
|
||
private PayIn getPayInCardDirect(String userId) throws Exception { | ||
|
||
Wallet wallet = this.getJohnsWalletWithMoney(); | ||
|
@@ -632,6 +638,57 @@ private PayIn getPayInMbwayDirect(String userId) throws Exception { | |
return payIn; | ||
} | ||
|
||
private PayIn getPayInKlarnaWeb(String userId) throws Exception { | ||
Wallet wallet = this.getJohnsWalletWithMoney(); | ||
|
||
if (userId == null) { | ||
UserNatural user = this.getJohn(); | ||
userId = user.getId(); | ||
} | ||
// create pay-in KLARNA WEB | ||
PayIn payIn = new PayIn(); | ||
payIn.setAuthorId(userId); | ||
payIn.setCreditedWalletId(wallet.getId()); | ||
payIn.setDebitedFunds(new Money()); | ||
payIn.getDebitedFunds().setAmount(1000); | ||
payIn.getDebitedFunds().setCurrency(CurrencyIso.EUR); | ||
payIn.setFees(new Money()); | ||
payIn.getFees().setAmount(100); | ||
payIn.getFees().setCurrency(CurrencyIso.EUR); | ||
payIn.setTag("Klarna test"); | ||
|
||
// payment type as KLARNA | ||
|
||
PayInPaymentDetailsKlarna payInPaymentDetailsKlarna = new PayInPaymentDetailsKlarna(); | ||
List<LineItem> lineItems = new ArrayList<>(); | ||
lineItems.add(new LineItem( | ||
"test", | ||
1, | ||
1000, | ||
0, | ||
"test descr" | ||
)); | ||
payInPaymentDetailsKlarna.setLineItems(lineItems); | ||
payInPaymentDetailsKlarna.setCountry(CountryIso.FR.name()); | ||
payInPaymentDetailsKlarna.setCulture(CountryIso.FR.name()); | ||
payInPaymentDetailsKlarna.setPhone("33#607080900"); | ||
payInPaymentDetailsKlarna.setEmail("[email protected]"); | ||
payInPaymentDetailsKlarna.setAdditionalData("{}"); | ||
payInPaymentDetailsKlarna.setMerchantOrderId("afd48-879d-48fg"); | ||
|
||
payInPaymentDetailsKlarna.setBilling(getNewBilling()); | ||
payInPaymentDetailsKlarna.setShipping(getNewShipping()); | ||
payIn.setPaymentDetails(payInPaymentDetailsKlarna); | ||
|
||
|
||
// execution type as WEB | ||
PayInExecutionDetailsWeb executionDetails = new PayInExecutionDetailsWeb(); | ||
executionDetails.setReturnUrl("http://www.my-site.com/returnURL"); | ||
payIn.setExecutionDetails(executionDetails); | ||
|
||
return this.api.getPayInApi().create(payIn); | ||
} | ||
|
||
protected PayIn getNewPayInCardDirectWithRequested3DSVersion() throws Exception { | ||
PayIn payIn = getPayInCardDirect(null); | ||
|
||
|
@@ -673,15 +730,15 @@ protected BrowserInfo getNewBrowserInfo() { | |
return browserInfo; | ||
} | ||
|
||
protected PayIn getNewPayInCardDirectWithBrowserInfo() throws Exception{ | ||
protected PayIn getNewPayInCardDirectWithBrowserInfo() throws Exception { | ||
PayIn payIn = getPayInCardDirect(null); | ||
|
||
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setBrowserInfo(getNewBrowserInfo()); | ||
|
||
return this.api.getPayInApi().create(payIn); | ||
} | ||
|
||
protected PayIn getNewPayInCardDirectWithIpAddress() throws Exception{ | ||
protected PayIn getNewPayInCardDirectWithIpAddress() throws Exception { | ||
PayIn payIn = getPayInCardDirect(null); | ||
|
||
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setIpAddress("2001:0620:0000:0000:0211:24FF:FE80:C12C"); | ||
|
@@ -933,10 +990,10 @@ protected String getPaylineCorrectRegistartionDataForDeposit(CardRegistration ca | |
protected String getPaylineCorrectRegistartionData3DSecureForCardNumber(CardRegistration cardRegistration, String cardNumber) throws MalformedURLException, IOException, Exception { | ||
|
||
String data = "data=" + cardRegistration.getPreregistrationData() + | ||
"&accessKeyRef=" + cardRegistration.getAccessKey() + | ||
"&cardNumber=" + cardNumber + | ||
"&cardExpirationDate=1224" + | ||
"&cardCvx=123"; | ||
"&accessKeyRef=" + cardRegistration.getAccessKey() + | ||
"&cardNumber=" + cardNumber + | ||
"&cardExpirationDate=1224" + | ||
"&cardCvx=123"; | ||
|
||
URL url = new URL(cardRegistration.getCardRegistrationUrl()); | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
|
@@ -1102,12 +1159,12 @@ protected Deposit createNewDeposit() throws Exception { | |
Money debitedFunds = new Money(CurrencyIso.EUR, 1000); | ||
|
||
CreateDeposit dto = new CreateDeposit( | ||
john.getId(), | ||
debitedFunds, | ||
cardRegistration.getCardId(), | ||
"http://lorem", | ||
"2001:0620:0000:0000:0211:24FF:FE80:C12C", | ||
getNewBrowserInfo() | ||
john.getId(), | ||
debitedFunds, | ||
cardRegistration.getCardId(), | ||
"http://lorem", | ||
"2001:0620:0000:0000:0211:24FF:FE80:C12C", | ||
getNewBrowserInfo() | ||
); | ||
|
||
return this.api.getDepositApi().create(dto, null); | ||
|
Oops, something went wrong.