-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathCancelSubscription.java
More file actions
41 lines (34 loc) · 1.73 KB
/
CancelSubscription.java
File metadata and controls
41 lines (34 loc) · 1.73 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
package net.authorize.sample.RecurringBilling;
import java.math.BigDecimal;
import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.controller.base.ApiOperationBase;
import net.authorize.api.controller.ARBCancelSubscriptionController;
import javax.xml.datatype.XMLGregorianCalendar;
public class CancelSubscription {
public static ANetApiResponse run(String apiLoginId, String transactionKey, String subscriptionId) {
//Common code to set for all requests
ApiOperationBase.setEnvironment(Environment.SANDBOX);
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
// Make the API Request
ARBCancelSubscriptionRequest apiRequest = new ARBCancelSubscriptionRequest();
apiRequest.setSubscriptionId(subscriptionId);
ARBCancelSubscriptionController controller = new ARBCancelSubscriptionController(apiRequest);
controller.execute();
ARBCancelSubscriptionResponse response = controller.getApiResponse();
if (response!=null) {
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("Failed to cancel Subscription: " + response.getMessages().getResultCode());
}
}
return response;
}
}