Skip to content

Commit

Permalink
Criação dos campos de SDWO (#16)
Browse files Browse the repository at this point in the history
* Mensageria SDWO

* Pom e Readme

* Purchase e Cash-in
  • Loading branch information
Vinicius-Brito-Costa committed Jan 17, 2024
1 parent e3db26d commit a4e9c7a
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 6 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,51 @@ maxiPago.sale()
TransactionResponse response = maxiPago.transactionRequest().execute();
```

#### Venda direta com Autenticação 3DS V2 e SDWO (cartão de crédito e débito)
```java
MaxiPago maxiPago = new MaxiPago(environment);

maxiPago.sale()
.setProcessorId("5")
.setReferenceNum("CreateSaleWith3DS")
.setAuthentication("41", Authentication.DECLINE, ChallengePreference.NO_PREFERENCE, "POSTBACK", "Y")
.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")
.device(new Device()
.setColorDepth("1")
.setJavaEnabled(true)
.setLanguage("BR")
.setScreenHeight("550")
.setScreenWidth("550")
.setTimeZoneOffset(3))
.setIpAddress("127.0.0.1")
.billingAndShipping((new Customer())
.setName("Nome como esta gravado no cartao")
.setAddress("Rua Volkswagen 100")
.setAddress2("0")
.setDistrict("Jabaquara")
.setCity("Sao Paulo")
.setState("SP")
.setPostalCode("11111111")
.setCountry("BR")
.setPhone("11111111111")
.setEmail("email.pagador@gmail.com"))
.setCreditCard((new Card())
.setNumber("5221834791042066")
.setExpMonth("12")
.setExpYear("2030")
.setCvvNumber("123"))
.setPayment(new Payment(100.0))
.setWallet(new Wallet()
.setSDWO(new SDWO()
.setId(12345)
.setProcessingType(SDWOProcessingType.CASH_IN)
.setSenderTaxIdentification("56326738000106")
.setBusinessApplicationIdentifier(BusinessApplicationIdentifier.CBPS)));


TransactionResponse response = maxiPago.transactionRequest().execute();
```

#### Criando um Pix
```java
MaxiPago maxiPago = new MaxiPago(environment);
Expand Down
8 changes: 2 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

<groupId>com.maxipago</groupId>
<artifactId>sdk-java-v2</artifactId>
<version>2.1.5</version>
<version>2.1.6</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
Expand Down Expand Up @@ -52,11 +53,6 @@
<artifactId>xercesImpl</artifactId>
<version>[2.12.2,)</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/maxipago/SDWO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.maxipago;

import javax.xml.bind.annotation.XmlElement;

import com.maxipago.enums.BusinessApplicationIdentifier;
import com.maxipago.enums.SDWOProcessingType;

public class SDWO {
@XmlElement
public int id;
@XmlElement
public String processingType;
@XmlElement
public String senderTaxIdentification;
@XmlElement
public String businessApplicationIdentifier;

public SDWO setId(int id) {
this.id = id;
return this;
}

public SDWO setProcessingType(SDWOProcessingType processingType) {
this.processingType = processingType.toString();
return this;
}

public SDWO setSenderTaxIdentification(String senderTaxIdentification) {
this.senderTaxIdentification = senderTaxIdentification;
return this;
}

public SDWO setBusinessApplicationIdentifier(BusinessApplicationIdentifier businessApplicationIdentifier) {
this.businessApplicationIdentifier = businessApplicationIdentifier.toString();
return this;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/maxipago/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public class Transaction {

@XmlElement
public Device device;

@XmlElement
public Wallet wallet;

public Transaction fraudDetails(String fraudProcessorID, String fraudToken) {
return fraudDetails(fraudProcessorID, fraudToken, "N", "N");
Expand Down Expand Up @@ -246,4 +249,9 @@ public Transaction setUserAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}

public Transaction setWallet(Wallet wallet) {
this.wallet = wallet;
return this;
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/maxipago/Wallet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.maxipago;

import javax.xml.bind.annotation.XmlElement;

public class Wallet {
@XmlElement
public String name;
@XmlElement
public SDWO sdwo;

public Wallet setName(String name) {
this.name = name;
return this;
}

public Wallet setSDWO(SDWO sdwo) {
this.sdwo = sdwo;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.maxipago.enums;

public enum BusinessApplicationIdentifier {
CBPS("01");

private String identifier;

BusinessApplicationIdentifier(String identifier){
this.identifier = identifier;
}

@Override
public String toString() {
return this.identifier;
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/maxipago/enums/SDWOProcessingType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.maxipago.enums;

public enum SDWOProcessingType {
PURCHASE("Purchase"), CASH_IN("Cash-in");

private String processingType;

SDWOProcessingType(String processingType){
this.processingType = processingType;
}

@Override
public String toString() {
return this.processingType;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/maxipago/request/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public class Request {

@XmlElement
public FilterOptions filterOptions;

@XmlElement
public Wallet wallet;

public Request setCustomerId(String customerId) {
this.customerId = customerId;
Expand Down Expand Up @@ -315,4 +318,9 @@ public Request setShippingInfo(Customer shippingInfo) {
this.shippingInfo = shippingInfo;
return this;
}

public Request setWallet(Wallet wallet) {
this.wallet = wallet;
return this;
}
}
47 changes: 47 additions & 0 deletions src/test/java/com/maxipago/MaxiPagoTestWiremock.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.mockito.junit.MockitoJUnitRunner;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.maxipago.enums.BusinessApplicationIdentifier;
import com.maxipago.enums.ChallengePreference;
import com.maxipago.enums.ReportsPeriodEnum;
import com.maxipago.enums.SDWOProcessingType;
import com.maxipago.paymentmethod.Boleto;
import com.maxipago.paymentmethod.Card;
import com.maxipago.paymentmethod.OnlineDebit;
Expand Down Expand Up @@ -1132,4 +1134,49 @@ private MaxiPago prepareResponse(String file, String path) {
.withBody(responseXML)));
return maxiPago;
}

@Test
public void shouldCreateSaleWith3DSAndSDWO() throws PropertyException {
MaxiPago maxiPago = prepareResponse(CAPTURED_RESPONSE, UNIVERSAL_API);

maxiPago.sale()
.setProcessorId("5")
.setReferenceNum("CreateSaleWith3DS")
.setAuthentication("41", Authentication.DECLINE, ChallengePreference.NO_PREFERENCE, "POSTBACK", "Y")
.setUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")
.device(new Device()
.setColorDepth("1")
.setJavaEnabled(true)
.setLanguage("BR")
.setScreenHeight("550")
.setScreenWidth("550")
.setTimeZoneOffset(3))
.setIpAddress("127.0.0.1")
.billingAndShipping((new Customer())
.setName("Nome como esta gravado no cartao")
.setAddress("Rua Volkswagen 100")
.setAddress2("0")
.setDistrict("Jabaquara")
.setCity("Sao Paulo")
.setState("SP")
.setPostalCode("11111111")
.setCountry("BR")
.setPhone("11111111111")
.setEmail("email.pagador@gmail.com"))
.setCreditCard((new Card())
.setNumber("5221834791042066")
.setExpMonth("12")
.setExpYear("2030")
.setCvvNumber("123"))
.setPayment(new Payment(100.0))
.setWallet(new Wallet()
.setSDWO(new SDWO()
.setId(12345)
.setProcessingType(SDWOProcessingType.CASH_IN)
.setSenderTaxIdentification("56326738000106")
.setBusinessApplicationIdentifier(BusinessApplicationIdentifier.CBPS)));

TransactionResponse response = maxiPago.transactionRequest().execute();
assertEquals("0", response.responseCode);
}
}

0 comments on commit a4e9c7a

Please sign in to comment.