-
Notifications
You must be signed in to change notification settings - Fork 458
/
Copy pathGetCustomerPaymentProfile.java
74 lines (58 loc) · 3.72 KB
/
GetCustomerPaymentProfile.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package net.authorize.sample.CustomerProfiles;
import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.contract.v1.MerchantAuthenticationType;
import net.authorize.api.controller.base.ApiOperationBase;
import net.authorize.api.controller.GetCustomerPaymentProfileController;
import net.authorize.api.controller.base.ApiOperationBase;
import net.authorize.sample.SampleCodeTest.*;
public class GetCustomerPaymentProfile {
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId,
String customerPaymentProfileId) {
if ( null == ApiOperationBase.getEnvironment() )
{
ApiOperationBase.setEnvironment(Environment.SANDBOX);
}
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
GetCustomerPaymentProfileRequest apiRequest = new GetCustomerPaymentProfileRequest();
apiRequest.setCustomerProfileId(customerProfileId);
apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId);
GetCustomerPaymentProfileController controller = new GetCustomerPaymentProfileController(apiRequest);
controller.execute();
GetCustomerPaymentProfileResponse response = new GetCustomerPaymentProfileResponse();
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());
System.out.println(response.getPaymentProfile().getBillTo().getFirstName());
System.out.println(response.getPaymentProfile().getBillTo().getLastName());
System.out.println(response.getPaymentProfile().getBillTo().getCompany());
System.out.println(response.getPaymentProfile().getBillTo().getAddress());
System.out.println(response.getPaymentProfile().getBillTo().getCity());
System.out.println(response.getPaymentProfile().getBillTo().getState());
System.out.println(response.getPaymentProfile().getBillTo().getZip());
System.out.println(response.getPaymentProfile().getBillTo().getCountry());
System.out.println(response.getPaymentProfile().getBillTo().getPhoneNumber());
System.out.println(response.getPaymentProfile().getBillTo().getFaxNumber());
System.out.println(response.getPaymentProfile().getCustomerPaymentProfileId());
System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getCardNumber());
System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getExpirationDate());
if((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) &&
(!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())){
System.out.println("List of subscriptions:");
for(String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId())
System.out.println(subscriptionid);
}
}
else
{
System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode());
}
}
return response;
}
}