forked from AuthorizeNet/sample-code-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateSplitTenderGroup.java
More file actions
53 lines (41 loc) · 2.22 KB
/
Copy pathUpdateSplitTenderGroup.java
File metadata and controls
53 lines (41 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package net.authorize.sample.PaymentTransactions;
import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.controller.base.ApiOperationBase;
import net.authorize.api.controller.UpdateSplitTenderGroupController;
/**
*
* @author gnongsie
*/
public class UpdateSplitTenderGroup {
public static ANetApiResponse run(String apiLoginId, String transactionKey) {
System.out.println("Update Split Tender Group Sample Code");
//Common code to set for all requests
ApiOperationBase.setEnvironment(Environment.SANDBOX);
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
// Provide a split tender Id
// To get a split Tender ID in sandbox, authorize any transaction with amount = 462.25 [if card present] and set allowPartialAuth = true
String splitTenderId = "115901";
// Create a request
UpdateSplitTenderGroupRequest request = new UpdateSplitTenderGroupRequest();
request.setMerchantAuthentication(merchantAuthenticationType);
request.setSplitTenderId(splitTenderId);
// Set the Split Tender Status (VOIDED or HELD or COMPLETED)
request.setSplitTenderStatus(SplitTenderStatusEnum.VOIDED);
UpdateSplitTenderGroupController controller = new UpdateSplitTenderGroupController(request);
controller.execute();
UpdateSplitTenderGroupResponse response = controller.getApiResponse();
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
System.out.println(response.getMessages().getMessage().get(0).getCode());
System.out.println(response.getMessages().getMessage().get(0).getText());
}
else {
System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() +
" " + response.getMessages().getMessage().get(0).getText());
}
return response;
}
}