Skip to content

Commit f1d0963

Browse files
authored
UMCS-696 Add new chargeAuthorization method (#102)
2 parents 8b770a1 + 88d0bcd commit f1d0963

19 files changed

Lines changed: 320 additions & 101 deletions

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,38 @@ This release introduces Unzer PayPal Express in Java SDK.
1818
* Added `com.unzer.payment.Unzer::updateCharge()`, `com.unzer.payment.Unzer::updateAuthorization()` which must be invoked after Paypal-Express transaction is resumed.
1919
* Added fields `orderId` and `invoiceId` to `Authorize`, `Charge` and `Cancel` transactions.
2020
* Added authorize support for Paypage. Use `Paypage::setAction(Paypage.Action.AUTHORIZE)`
21+
* Added new capture (charge authorization) methods. See: `com.unzer.payment.Unzer.chargeAuthorization(charge)` and `com.unzer.payment.Unzer.chargeAuthorization(paymentId, charge)`
22+
23+
### Changed
24+
25+
* Reduced multiple `com.unzer.payment.service.PaymentService.chargeAuthorization` methods to one with `Charge` argument.
2126

2227
### Deprecated
2328

2429
* Deprecated `com.unzer.payment.paymenttypes.Invoice`. Use `com.unzer.payment.paymenttypes.PaylaterInvoice` instead
30+
* Deprecated behavioral methods for data objects. Please, use Unzer facade instead. List of deprecations:
31+
* `AbstractTransaction` (base class of `Authorization`, `Cancel`, `Charge`, `Payout`, `Recurring`, `Shipment`, `MarketplaceAuthorization`, `MarketplaceCharge`, `MarketplacePayment`, `MarketplaceCancel`):
32+
* `getUnzer`/`setUnzer`
33+
* `Charge`:
34+
* `cancel`
35+
* `Authorization`:
36+
* `charge`
37+
* `cancel`
38+
* `Payment`:
39+
* `charge`
40+
* `authorize`
41+
* `cancel`
42+
* `MarketplaceCharge`:
43+
* `cancel`
44+
* `MarketplaceAuthorization`:
45+
* `charge`
46+
* `cancel`
47+
* `MarketplacePayment`:
48+
* `marketplaceFullChargesCancel`
49+
* `fullChargeAuthorizations`
50+
* `marketplaceFullAuthorizeCancel`
51+
* `AbstractPayment`:
52+
* `fetchBasket`, `fetchMetadata`, `fetchCustomer`, `fetchPaymentType`
2553

2654
## [3.0.0][3.0.0]
2755

src/main/java/com/unzer/payment/AbstractPayment.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public abstract class AbstractPayment implements PaymentType {
4040
private Basket basket;
4141
private transient Unzer unzer;
4242

43+
@Deprecated
4344
public AbstractPayment(Unzer unzer) {
4445
super();
4546
this.setUnzer(unzer);
@@ -57,10 +58,12 @@ public void setId(String id) {
5758
this.id = id;
5859
}
5960

61+
@Deprecated
6062
public Unzer getUnzer() {
6163
return unzer;
6264
}
6365

66+
@Deprecated
6467
public void setUnzer(Unzer unzer) {
6568
this.unzer = unzer;
6669
}
@@ -189,18 +192,34 @@ protected boolean isNotEmpty(String value) {
189192
return value != null && !"".equalsIgnoreCase(value.trim());
190193
}
191194

195+
/**
196+
* @deprecated use {@link Unzer#fetchPaymentType(String)} instead
197+
*/
198+
@Deprecated
192199
protected PaymentType fetchPaymentType(String paymentTypeId) throws HttpCommunicationException {
193200
return getUnzer().fetchPaymentType(paymentTypeId);
194201
}
195202

203+
/**
204+
* @deprecated use {@link Unzer#fetchCustomer(String)} instead
205+
*/
206+
@Deprecated
196207
protected Customer fetchCustomer(String customerId) throws HttpCommunicationException {
197208
return getUnzer().fetchCustomer(customerId);
198209
}
199210

211+
/**
212+
* @deprecated use {@link Unzer#fetchMetadata(String)} instead
213+
*/
214+
@Deprecated
200215
protected Metadata fetchMetadata(String metadataId) throws HttpCommunicationException {
201216
return getUnzer().fetchMetadata(metadataId);
202217
}
203218

219+
/**
220+
* @deprecated use {@link Unzer#fetchBasket(String)} instead
221+
*/
222+
@Deprecated
204223
protected Basket fetchBasket(String basketId) throws HttpCommunicationException {
205224
return getUnzer().fetchBasket(basketId);
206225
}

src/main/java/com/unzer/payment/AbstractTransaction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public AbstractTransaction() {
5858
super();
5959
}
6060

61+
@Deprecated
6162
public AbstractTransaction(Unzer unzer) {
6263
this.unzer = unzer;
6364
}
@@ -223,10 +224,12 @@ public AbstractTransaction<T> setPayment(T payment) {
223224
return this;
224225
}
225226

227+
@Deprecated
226228
public Unzer getUnzer() {
227229
return unzer;
228230
}
229231

232+
@Deprecated
230233
public AbstractTransaction<T> setUnzer(Unzer unzer) {
231234
this.unzer = unzer;
232235
return this;

src/main/java/com/unzer/payment/Authorization.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,55 @@ public Authorization() {
4040
super();
4141
}
4242

43+
@Deprecated
4344
public Authorization(Unzer unzer) {
4445
super(unzer);
4546
}
4647

48+
/**
49+
* @deprecated use {@link Unzer#chargeAuthorization(Charge)} instead
50+
*/
51+
@Deprecated
4752
public Charge charge() throws HttpCommunicationException {
4853
return getUnzer().chargeAuthorization(getPayment().getId());
4954
}
5055

56+
/**
57+
* @deprecated use {@link Unzer#chargeAuthorization(Charge)} instead
58+
*/
59+
@Deprecated
5160
public Charge charge(BigDecimal amount) throws HttpCommunicationException {
5261
return getUnzer().chargeAuthorization(getPayment().getId(), amount);
5362
}
5463

64+
/**
65+
* @deprecated use {@link Unzer#chargeAuthorization(Charge)} instead
66+
*/
67+
@Deprecated
5568
public Charge charge(BigDecimal amount, String paymentReference) throws HttpCommunicationException {
5669
return getUnzer().chargeAuthorization(getPayment().getId(), amount, paymentReference);
5770
}
5871

72+
/**
73+
* @deprecated use {@link Unzer#cancelAuthorization(String, Cancel)} instead
74+
*/
75+
@Deprecated
5976
public Cancel cancel() throws HttpCommunicationException {
6077
return getUnzer().cancelAuthorization(getPayment().getId());
6178
}
6279

80+
/**
81+
* @deprecated use {@link Unzer#cancelAuthorization(String, Cancel)} instead
82+
*/
83+
@Deprecated
6384
public Cancel cancel(BigDecimal amount) throws HttpCommunicationException {
6485
return getUnzer().cancelAuthorization(getPayment().getId(), amount);
6586
}
6687

88+
/**
89+
* @deprecated use {@link Unzer#cancelAuthorization(String, Cancel)} instead
90+
*/
91+
@Deprecated
6792
public Cancel cancel(Cancel cancel) throws HttpCommunicationException {
6893
return getUnzer().cancelAuthorization(getPayment().getId(), cancel);
6994
}

src/main/java/com/unzer/payment/Cancel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public Cancel() {
3636
super();
3737
}
3838

39+
@Deprecated
3940
public Cancel(Unzer unzer) {
4041
super(unzer);
4142
}

src/main/java/com/unzer/payment/Charge.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
import com.unzer.payment.paymenttypes.PaymentType;
2121

2222
import java.math.BigDecimal;
23+
import java.net.URL;
2324
import java.util.ArrayList;
25+
import java.util.Currency;
2426
import java.util.List;
27+
import java.util.Optional;
2528

2629
/**
2730
* Business object for Charge. Amount, currency and typeId are mandatory parameter to
@@ -39,19 +42,32 @@ public Charge() {
3942
setCancelList(new ArrayList<Cancel>());
4043
}
4144

45+
@Deprecated
4246
public Charge(Unzer unzer) {
4347
super(unzer);
4448
setCancelList(new ArrayList<Cancel>());
4549
}
4650

51+
/**
52+
* @deprecated use {@link Unzer#cancelCharge(String, String)} instead
53+
*/
54+
@Deprecated
4755
public Cancel cancel() throws HttpCommunicationException {
4856
return getUnzer().cancelCharge(getPayment().getId(), getId());
4957
}
5058

59+
/**
60+
* @deprecated use {@link Unzer#cancelCharge(String, String, Cancel)} instead
61+
*/
62+
@Deprecated
5163
public Cancel cancel(BigDecimal amount) throws HttpCommunicationException {
5264
return getUnzer().cancelCharge(getPayment().getId(), getId(), amount);
5365
}
5466

67+
/**
68+
* @deprecated use {@link Unzer#cancelCharge(String, String, Cancel)} instead
69+
*/
70+
@Deprecated
5571
public Cancel cancel(Cancel cancel) throws HttpCommunicationException {
5672
return getUnzer().cancelCharge(getPayment().getId(), getId(), cancel);
5773
}

src/main/java/com/unzer/payment/Metadata.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ public String getTypeUrl() {
6363
return "metadata";
6464
}
6565

66+
@Deprecated
6667
public Unzer getUnzer() {
6768
return unzer;
6869
}
6970

71+
@Deprecated
7072
public void setUnzer(Unzer unzer) {
7173
this.unzer = unzer;
7274
}

src/main/java/com/unzer/payment/Payment.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,54 +45,103 @@ public Payment() {
4545
super();
4646
}
4747

48+
@Deprecated
4849
public Payment(Unzer unzer) {
4950
super(unzer);
5051
}
5152

53+
/**
54+
* @deprecated use {@link Unzer#charge(Charge)} instead
55+
*/
56+
@Deprecated
5257
public Charge charge() throws HttpCommunicationException {
5358
return getUnzer().chargeAuthorization(getId());
5459
}
5560

61+
/**
62+
* @deprecated use {@link Unzer#charge(Charge)} instead
63+
*/
64+
@Deprecated
5665
public Charge charge(BigDecimal amount) throws HttpCommunicationException {
5766
return getUnzer().chargeAuthorization(getId(), amount);
5867
}
5968

69+
/**
70+
* @deprecated use {@link Unzer#charge(Charge)} instead
71+
*/
72+
@Deprecated
6073
public Charge charge(BigDecimal amount, Currency currency, String typeId) throws HttpCommunicationException {
6174
return getUnzer().charge(amount, currency, typeId);
6275
}
6376

77+
/**
78+
* @deprecated use {@link Unzer#charge(Charge)} instead
79+
*/
80+
@Deprecated
6481
public Charge charge(BigDecimal amount, Currency currency, String typeId, String customerId) throws HttpCommunicationException {
6582
return getUnzer().charge(amount, currency, typeId, customerId);
6683
}
6784

85+
/**
86+
* @deprecated use {@link Unzer#charge(Charge)} instead
87+
*/
88+
@Deprecated
6889
public Charge charge(BigDecimal amount, Currency currency, PaymentType paymentType) throws HttpCommunicationException {
6990
return getUnzer().charge(amount, currency, paymentType);
7091
}
7192

93+
/**
94+
* @deprecated use {@link Unzer#charge(Charge)} instead
95+
*/
96+
@Deprecated
7297
public Charge charge(BigDecimal amount, Currency currency, String typeId, URL returnUrl) throws HttpCommunicationException {
7398
return getUnzer().charge(amount, currency, typeId, returnUrl);
7499
}
75100

101+
/**
102+
* @deprecated use {@link Unzer#charge(Charge)} instead
103+
*/
104+
@Deprecated
76105
public Charge charge(BigDecimal amount, Currency currency, String typeId, URL returnUrl, String customerId) throws HttpCommunicationException {
77106
return getUnzer().charge(amount, currency, typeId, returnUrl, customerId);
78107
}
79108

109+
/**
110+
* @deprecated use {@link Unzer#charge(Charge)} instead
111+
*/
112+
@Deprecated
80113
public Charge charge(BigDecimal amount, Currency currency, PaymentType paymentType, URL returnUrl, Customer customer) throws HttpCommunicationException {
81114
return getUnzer().charge(amount, currency, paymentType, returnUrl, customer);
82115
}
83116

117+
/**
118+
* @deprecated use {@link Unzer#authorize(Authorization)} instead
119+
*/
120+
@Deprecated
84121
public Authorization authorize(BigDecimal amount, Currency currency, String typeId, URL returnUrl) throws HttpCommunicationException {
85122
return getUnzer().authorize(amount, currency, typeId, returnUrl);
86123
}
87124

125+
/**
126+
* @deprecated use {@link Unzer#authorize(Authorization)} instead
127+
*/
128+
@Deprecated
88129
public Authorization authorize(BigDecimal amount, Currency currency, String typeId, URL returnUrl, String customerId) throws HttpCommunicationException {
89130
return getUnzer().authorize(amount, currency, typeId, returnUrl, customerId);
90131
}
91132

133+
/**
134+
* @deprecated use {@link Unzer#authorize(Authorization)} instead
135+
*/
136+
@Deprecated
92137
public Authorization authorize(BigDecimal amount, Currency currency, PaymentType paymentType, URL returnUrl, Customer customer) throws HttpCommunicationException {
93138
return getUnzer().authorize(amount, currency, paymentType, returnUrl, customer);
94139
}
95140

141+
/**
142+
* @deprecated use {@link Unzer#cancelAuthorization(String, Cancel)} or {@link Unzer#cancelCharge(String, String)} instead
143+
*/
144+
@Deprecated
96145
public Cancel cancel() throws HttpCommunicationException {
97146
if (getAuthorization() == null) {
98147
List<PaymentError> paymentErrorList = new ArrayList<PaymentError>();
@@ -103,6 +152,10 @@ public Cancel cancel() throws HttpCommunicationException {
103152
return getAuthorization().cancel();
104153
}
105154

155+
/**
156+
* @deprecated use {@link Unzer#cancelAuthorization(String, Cancel)} or {@link Unzer#cancelCharge(String, String)} instead
157+
*/
158+
@Deprecated
106159
public Cancel cancel(BigDecimal amount) throws HttpCommunicationException {
107160
if (getAuthorization() == null) {
108161
List<PaymentError> paymentErrorList = new ArrayList<>();

src/main/java/com/unzer/payment/Payout.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Payout extends AbstractTransaction<Payment> {
2323
public Payout() {
2424
}
2525

26+
@Deprecated
2627
public Payout(Unzer unzer) {
2728
super(unzer);
2829
}

0 commit comments

Comments
 (0)