-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathUpdateCustomerPaymentProfile.java
More file actions
72 lines (57 loc) · 2.78 KB
/
UpdateCustomerPaymentProfile.java
File metadata and controls
72 lines (57 loc) · 2.78 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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.UpdateCustomerPaymentProfileController;
import net.authorize.sample.SampleCodeTest.*;
public class UpdateCustomerPaymentProfile {
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);
//customer address
CustomerAddressType customerAddress = new CustomerAddressType();
customerAddress.setFirstName("John");
customerAddress.setLastName("Doe");
customerAddress.setAddress("123 Main Street");
customerAddress.setCity("Bellevue");
customerAddress.setState("WA");
customerAddress.setZip("98004");
customerAddress.setCountry("USA");
customerAddress.setPhoneNumber("000-000-0000");
//credit card details
CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber("4111111111111111");
creditCard.setExpirationDate("2023-12");
PaymentType paymentType = new PaymentType();
paymentType.setCreditCard(creditCard);
CustomerPaymentProfileExType customer = new CustomerPaymentProfileExType();
customer.setPayment(paymentType);
customer.setCustomerPaymentProfileId(customerPaymentProfileId);
customer.setBillTo(customerAddress);
UpdateCustomerPaymentProfileRequest apiRequest = new UpdateCustomerPaymentProfileRequest();
apiRequest.setCustomerProfileId(customerProfileId);
apiRequest.setPaymentProfile(customer);
apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE);
UpdateCustomerPaymentProfileController controller = new UpdateCustomerPaymentProfileController(apiRequest);
controller.execute();
UpdateCustomerPaymentProfileResponse response = new UpdateCustomerPaymentProfileResponse();
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 update customer payment profile: " + response.getMessages().getResultCode());
}
}
return response;
}
}