forked from AuthorizeNet/sample-code-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidateCustomerPaymentProfile.java
More file actions
48 lines (36 loc) · 1.99 KB
/
Copy pathValidateCustomerPaymentProfile.java
File metadata and controls
48 lines (36 loc) · 1.99 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
package net.authorize.sample.CustomerProfiles;
import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.controller.base.ApiOperationBase;
import net.authorize.api.controller.ValidateCustomerPaymentProfileController;
public class ValidateCustomerPaymentProfile {
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId, String customerPaymentProfileId) {
ApiOperationBase.setEnvironment(Environment.SANDBOX);
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
ValidateCustomerPaymentProfileRequest apiRequest = new ValidateCustomerPaymentProfileRequest();
apiRequest.setCustomerProfileId(customerProfileId);
apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId);
apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE);
apiRequest.setCardCode("122");
apiRequest.setCustomerShippingAddressId("1");
ValidateCustomerPaymentProfileController controller = new ValidateCustomerPaymentProfileController(apiRequest);
controller.execute();
ValidateCustomerPaymentProfileResponse response = new ValidateCustomerPaymentProfileResponse();
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.getDirectResponse());
}
else
{
System.out.println("Failed to validate customer payment profile: " + response.getMessages().getResultCode());
}
}
return response;
}
}