Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ For _Maven_, add the following dependency to your `pom.xml`:
<dependency>
<groupId>me.cryptopay</groupId>
<artifactId>cryptopay-java</artifactId>
<version>2.2.0</version>
<version>3.0.0</version>
</dependency>
```

For _Gradle_, add the following dependency to your `build.gradle`:

```groovy
implementation group: 'me.cryptopay', name: 'cryptopay-java', version: '2.2.0'
implementation group: 'me.cryptopay', name: 'cryptopay-java', version: '3.0.0'
```

### Requirements
Expand Down Expand Up @@ -380,10 +380,7 @@ InvoiceRecalculationResult result = cryptopay.invoices()
```java
UUID invoiceId = UUID.fromString("7e274430-e20f-4321-8748-20824287ae44");

InvoiceRefundParams invoiceRefundParams = new InvoiceRefundParams();
invoiceRefundParams.setAddress("0xf3532c1fd002665ec54d46a50787e0c69c76cd44");

InvoiceRefundResult result = cryptopay.invoices().createRefund(invoiceId, invoiceRefundParams).execute();
InvoiceRefundResult result = cryptopay.invoices().createRefund(invoiceId).execute();
```

#### List invoices
Expand Down
2 changes: 1 addition & 1 deletion example/cryptopay-java-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<properties>
<java.version>11</java.version>
<encoding>UTF-8</encoding>
<cryptopay-java.version>2.2.0</cryptopay-java.version>
<cryptopay-java.version>3.0.0</cryptopay-java.version>
<logback.version>1.2.10</logback.version>
<commons-configuration2.version>2.7</commons-configuration2.version>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>me.cryptopay</groupId>
<artifactId>cryptopay-java</artifactId>
<version>2.2.0</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<name>Cryptopay Java</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/cryptopay/Cryptopay.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class Cryptopay {
public static final String API_URL_SANDBOX = "https://business-sandbox.cryptopay.me";

private static final String USER_AGENT = "Cryptopay Java %s";
private static final String VERSION = "2.2.0";
private static final String VERSION = "3.0.0";

private final ApiClient apiClient;
private final JSON json;
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/me/cryptopay/api/Invoices.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import me.cryptopay.model.InvoiceRecalculationParams;
import me.cryptopay.model.InvoiceRecalculationResult;
import me.cryptopay.model.InvoiceRefundListResult;
import me.cryptopay.model.InvoiceRefundParams;
import me.cryptopay.model.InvoiceRefundResult;
import me.cryptopay.model.InvoiceResult;
import me.cryptopay.net.ApiClient;
Expand Down Expand Up @@ -67,12 +66,10 @@ public CreateRecalculationCall createRecalculation(
* Create invoice refund.
*
* @param invoiceId Invoice ID
* @param invoiceRefundParams
* @return CreateRefundCall
*/
public CreateRefundCall createRefund(
final UUID invoiceId, final InvoiceRefundParams invoiceRefundParams) {
return new CreateRefundCall(invoiceId, invoiceRefundParams);
public CreateRefundCall createRefund(final UUID invoiceId) {
return new CreateRefundCall(invoiceId);
}

/**
Expand Down Expand Up @@ -183,11 +180,20 @@ public InvoiceRecalculationResult execute() throws ApiException {
public final class CreateRefundCall {
private final ApiRequest request;

private CreateRefundCall(
final UUID invoiceId, final InvoiceRefundParams invoiceRefundParams) {
private CreateRefundCall(final UUID invoiceId) {
this.request = new ApiRequest("POST", "/api/invoices/{invoice_id}/refunds");
request.addPathParam("invoice_id", invoiceId.toString());
request.setBody(invoiceRefundParams);
}

/**
* Set body.
*
* @param body
* @return createRefundCall
*/
public CreateRefundCall body(final Object body) {
request.setBody(body);
return this;
}

/**
Expand Down
105 changes: 104 additions & 1 deletion src/main/java/me/cryptopay/model/CoinWithdrawalParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ public final class CoinWithdrawalParams {
@SerializedName("network")
private String network;

@Deprecated
@SerializedName("charged_amount")
private BigDecimal chargedAmount;

@Deprecated
@SerializedName("charged_amount_to_send")
private BigDecimal chargedAmountToSend;

@Deprecated
@SerializedName("received_amount")
private BigDecimal receivedAmount;

Expand All @@ -47,6 +50,18 @@ public final class CoinWithdrawalParams {
@SerializedName("beneficiary")
private Beneficiary beneficiary;

@SerializedName("amount")
private BigDecimal amount;

@SerializedName("amount_currency")
private String amountCurrency;

@SerializedName("amount_includes_processing_fee")
private Boolean amountIncludesProcessingFee;

@SerializedName("amount_includes_network_fee")
private Boolean amountIncludesNetworkFee;

/** Creates a new instance of CoinWithdrawalParams. */
public CoinWithdrawalParams() {}

Expand Down Expand Up @@ -126,7 +141,9 @@ public void setNetwork(final String network) {
* Get chargedAmount.
*
* @return chargedAmount
* @deprecated
*/
@Deprecated
public BigDecimal getChargedAmount() {
return chargedAmount;
}
Expand All @@ -135,7 +152,9 @@ public BigDecimal getChargedAmount() {
* Set chargedAmount.
*
* @param chargedAmount chargedAmount
* @deprecated
*/
@Deprecated
public void setChargedAmount(final BigDecimal chargedAmount) {
this.chargedAmount = chargedAmount;
}
Expand All @@ -144,7 +163,9 @@ public void setChargedAmount(final BigDecimal chargedAmount) {
* Get chargedAmountToSend.
*
* @return chargedAmountToSend
* @deprecated
*/
@Deprecated
public BigDecimal getChargedAmountToSend() {
return chargedAmountToSend;
}
Expand All @@ -153,7 +174,9 @@ public BigDecimal getChargedAmountToSend() {
* Set chargedAmountToSend.
*
* @param chargedAmountToSend chargedAmountToSend
* @deprecated
*/
@Deprecated
public void setChargedAmountToSend(final BigDecimal chargedAmountToSend) {
this.chargedAmountToSend = chargedAmountToSend;
}
Expand All @@ -162,7 +185,9 @@ public void setChargedAmountToSend(final BigDecimal chargedAmountToSend) {
* Get receivedAmount.
*
* @return receivedAmount
* @deprecated
*/
@Deprecated
public BigDecimal getReceivedAmount() {
return receivedAmount;
}
Expand All @@ -171,7 +196,9 @@ public BigDecimal getReceivedAmount() {
* Set receivedAmount.
*
* @param receivedAmount receivedAmount
* @deprecated
*/
@Deprecated
public void setReceivedAmount(final BigDecimal receivedAmount) {
this.receivedAmount = receivedAmount;
}
Expand Down Expand Up @@ -284,6 +311,78 @@ public void setBeneficiary(final Beneficiary beneficiary) {
this.beneficiary = beneficiary;
}

/**
* Get amount.
*
* @return amount
*/
public BigDecimal getAmount() {
return amount;
}

/**
* Set amount.
*
* @param amount amount
*/
public void setAmount(final BigDecimal amount) {
this.amount = amount;
}

/**
* Get amountCurrency.
*
* @return amountCurrency
*/
public String getAmountCurrency() {
return amountCurrency;
}

/**
* Set amountCurrency.
*
* @param amountCurrency amountCurrency
*/
public void setAmountCurrency(final String amountCurrency) {
this.amountCurrency = amountCurrency;
}

/**
* Get amountIncludesProcessingFee.
*
* @return amountIncludesProcessingFee
*/
public Boolean getAmountIncludesProcessingFee() {
return amountIncludesProcessingFee;
}

/**
* Set amountIncludesProcessingFee.
*
* @param amountIncludesProcessingFee amountIncludesProcessingFee
*/
public void setAmountIncludesProcessingFee(final Boolean amountIncludesProcessingFee) {
this.amountIncludesProcessingFee = amountIncludesProcessingFee;
}

/**
* Get amountIncludesNetworkFee.
*
* @return amountIncludesNetworkFee
*/
public Boolean getAmountIncludesNetworkFee() {
return amountIncludesNetworkFee;
}

/**
* Set amountIncludesNetworkFee.
*
* @param amountIncludesNetworkFee amountIncludesNetworkFee
*/
public void setAmountIncludesNetworkFee(final Boolean amountIncludesNetworkFee) {
this.amountIncludesNetworkFee = amountIncludesNetworkFee;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand All @@ -300,7 +399,11 @@ public String toString() {
sb.append("networkFeeLevel=").append(networkFeeLevel).append(", ");
sb.append("forceCommit=").append(forceCommit).append(", ");
sb.append("travelRuleCompliant=").append(travelRuleCompliant).append(", ");
sb.append("beneficiary=").append(beneficiary);
sb.append("beneficiary=").append(beneficiary).append(", ");
sb.append("amount=").append(amount).append(", ");
sb.append("amountCurrency=").append(amountCurrency).append(", ");
sb.append("amountIncludesProcessingFee=").append(amountIncludesProcessingFee).append(", ");
sb.append("amountIncludesNetworkFee=").append(amountIncludesNetworkFee);
sb.append(")");
return sb.toString();
}
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/me/cryptopay/api/InvoicesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ public void createRecalculationTest() throws ApiException {
public void createRefundTest() throws ApiException {
UUID invoiceId = UUID.fromString("7e274430-e20f-4321-8748-20824287ae44");

InvoiceRefundParams invoiceRefundParams = new InvoiceRefundParams();
invoiceRefundParams.setAddress("0xf3532c1fd002665ec54d46a50787e0c69c76cd44");

InvoiceRefundResult result =
cryptopay.invoices().createRefund(invoiceId, invoiceRefundParams).execute();
InvoiceRefundResult result = cryptopay.invoices().createRefund(invoiceId).execute();

assertThat(result.getData(), notNullValue());
}
Expand Down
4 changes: 1 addition & 3 deletions src/test/resources/mappings/api/invoices/create_refund.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"contains": "Cryptopay Java"
}
},
"bodyPatterns": [{
"equalToJson": "{\"address\":\"0xf3532c1fd002665ec54d46a50787e0c69c76cd44\"}"
}]
"bodyPatterns": []
},
"response": {
"status": 201,
Expand Down