Skip to content

Commit 907affc

Browse files
committed
Completed Customer Profiles
1 parent 6e48c49 commit 907affc

9 files changed

Lines changed: 316 additions & 36 deletions

File tree

src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static void run(String apiLoginId, String transactionKey) {
2929

3030
CreateCustomerShippingAddressRequest apiRequest = new CreateCustomerShippingAddressRequest();
3131
apiRequest.setCustomerProfileId("10000");
32+
apiRequest.setAddress(customerAddressType);
3233

3334
CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest);
3435
controller.execute();
Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
6+
import net.authorize.api.contract.v1.MerchantAuthenticationType;
7+
import net.authorize.api.controller.base.ApiOperationBase;
8+
import net.authorize.api.controller.GetCustomerShippingAddressController;
9+
import net.authorize.api.controller.base.ApiOperationBase;
210

311
public class GetCustomerShippingAddress {
12+
13+
public static void run(String apiLoginId, String transactionKey) {
14+
15+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
16+
17+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
18+
merchantAuthenticationType.setName(apiLoginId);
19+
merchantAuthenticationType.setTransactionKey(transactionKey);
20+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
21+
22+
GetCustomerShippingAddressRequest apiRequest = new GetCustomerShippingAddressRequest();
23+
apiRequest.setCustomerProfileId("10000");
24+
apiRequest.setCustomerAddressId("30000");
25+
26+
GetCustomerShippingAddressController controller = new GetCustomerShippingAddressController(apiRequest);
27+
controller.execute();
28+
29+
GetCustomerShippingAddressResponse response = new GetCustomerShippingAddressResponse();
30+
response = controller.getApiResponse();
31+
32+
if (response!=null) {
33+
34+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
435

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
36+
System.out.println(response.getMessages().getMessage().get(0).getCode());
37+
System.out.println(response.getMessages().getMessage().get(0).getText());
738

8-
}
39+
System.out.println(response.getAddress().getFirstName());
40+
System.out.println(response.getAddress().getLastName());
41+
System.out.println(response.getAddress().getCompany());
42+
System.out.println(response.getAddress().getAddress());
43+
System.out.println(response.getAddress().getCity());
44+
System.out.println(response.getAddress().getState());
45+
System.out.println(response.getAddress().getZip());
46+
System.out.println(response.getAddress().getCountry());
47+
System.out.println(response.getAddress().getPhoneNumber());
48+
System.out.println(response.getAddress().getFaxNumber());
949

10-
}
50+
System.out.println(response.getAddress().getCustomerAddressId());
51+
}
52+
else
53+
{
54+
System.out.println("Failed to get customer shipping address: " + response.getMessages().getResultCode());
55+
}
56+
}
57+
}
58+
}
Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
6+
import net.authorize.api.contract.v1.MerchantAuthenticationType;
7+
import net.authorize.api.controller.base.ApiOperationBase;
8+
import net.authorize.api.controller.GetHostedProfilePageController;
9+
import net.authorize.api.controller.base.ApiOperationBase;
210

311
public class GetHostedProfilePage {
12+
13+
public static void run(String apiLoginId, String transactionKey) {
14+
15+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
16+
17+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
18+
merchantAuthenticationType.setName(apiLoginId);
19+
merchantAuthenticationType.setTransactionKey(transactionKey);
20+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
21+
22+
SettingType setting = new SettingType();
23+
setting.setSettingName("hostedProfileReturnUrl");
24+
setting.setSettingValue("https://returnurl.com/return/");
25+
26+
ArrayOfSetting alist = new ArrayOfSetting();
27+
alist.getSetting().add(setting);
28+
29+
GetHostedProfilePageRequest apiRequest = new GetHostedProfilePageRequest();
30+
apiRequest.setCustomerProfileId("YourProfileID");
31+
apiRequest.setHostedProfileSettings(alist);
32+
33+
GetHostedProfilePageController controller = new GetHostedProfilePageController(apiRequest);
34+
controller.execute();
35+
36+
GetHostedProfilePageResponse response = new GetHostedProfilePageResponse();
37+
response = controller.getApiResponse();
38+
39+
if (response!=null) {
440

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
41+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
742

8-
}
43+
System.out.println(response.getMessages().getMessage().get(0).getCode());
44+
System.out.println(response.getMessages().getMessage().get(0).getText());
945

10-
}
46+
System.out.println(response.getToken());
47+
}
48+
else
49+
{
50+
System.out.println("Failed to get hosted profile page: " + response.getMessages().getResultCode());
51+
}
52+
}
53+
}
54+
}
Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,67 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
import net.authorize.api.controller.base.ApiOperationBase;
6+
import net.authorize.api.controller.UpdateCustomerPaymentProfileController;
27

38
public class UpdateCustomerPaymentProfile {
9+
10+
public static void run(String apiLoginId, String transactionKey) {
11+
12+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
13+
14+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
15+
merchantAuthenticationType.setName(apiLoginId);
16+
merchantAuthenticationType.setTransactionKey(transactionKey);
17+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
18+
19+
//customer address
20+
CustomerAddressType customerAddress = new CustomerAddressType();
21+
customerAddress.setFirstName("John");
22+
customerAddress.setLastName("Doe");
23+
customerAddress.setAddress("123 Main Street");
24+
customerAddress.setCity("Bellevue");
25+
customerAddress.setState("WA");
26+
customerAddress.setZip("98004");
27+
customerAddress.setCountry("USA");
28+
customerAddress.setPhoneNumber("000-000-0000");
29+
30+
//credit card details
31+
CreditCardType creditCard = new CreditCardType();
32+
creditCard.setCardNumber("4111111111111111");
33+
creditCard.setExpirationDate("2023-12");
34+
35+
PaymentType paymentType = new PaymentType();
36+
paymentType.setCreditCard(creditCard);
37+
38+
CustomerPaymentProfileExType customer = new CustomerPaymentProfileExType();
39+
customer.setPayment(paymentType);
40+
customer.setCustomerPaymentProfileId("20000");
41+
customer.setBillTo(customerAddress);
42+
43+
UpdateCustomerPaymentProfileRequest apiRequest = new UpdateCustomerPaymentProfileRequest();
44+
apiRequest.setCustomerProfileId("10000");
45+
apiRequest.setPaymentProfile(customer);
46+
apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE);
47+
48+
UpdateCustomerPaymentProfileController controller = new UpdateCustomerPaymentProfileController(apiRequest);
49+
controller.execute();
50+
51+
UpdateCustomerPaymentProfileResponse response = new UpdateCustomerPaymentProfileResponse();
52+
response = controller.getApiResponse();
453

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
54+
if (response!=null) {
755

8-
}
56+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
957

10-
}
58+
System.out.println(response.getMessages().getMessage().get(0).getCode());
59+
System.out.println(response.getMessages().getMessage().get(0).getText());
60+
}
61+
else
62+
{
63+
System.out.println("Failed to update customer payment profile: " + response.getMessages().getResultCode());
64+
}
65+
}
66+
}
67+
}
Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,47 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
import net.authorize.api.controller.base.ApiOperationBase;
6+
import net.authorize.api.controller.UpdateCustomerProfileController;
27

38
public class UpdateCustomerProfile {
9+
10+
public static void run(String apiLoginId, String transactionKey) {
11+
12+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
13+
14+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
15+
merchantAuthenticationType.setName(apiLoginId);
16+
merchantAuthenticationType.setTransactionKey(transactionKey);
17+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
18+
19+
CustomerProfileExType customer = new CustomerProfileExType();
20+
customer.setMerchantCustomerId("custId123");
21+
customer.setDescription("some description");
22+
customer.setEmail("[email protected]");
23+
customer.setCustomerProfileId("10000");
24+
25+
UpdateCustomerProfileRequest apiRequest = new UpdateCustomerProfileRequest();
26+
apiRequest.setProfile(customer);
27+
28+
UpdateCustomerProfileController controller = new UpdateCustomerProfileController(apiRequest);
29+
controller.execute();
30+
31+
UpdateCustomerProfileResponse response = new UpdateCustomerProfileResponse();
32+
response = controller.getApiResponse();
433

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
34+
if (response!=null) {
735

8-
}
36+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
937

10-
}
38+
System.out.println(response.getMessages().getMessage().get(0).getCode());
39+
System.out.println(response.getMessages().getMessage().get(0).getText());
40+
}
41+
else
42+
{
43+
System.out.println("Failed to update customer profile: " + response.getMessages().getResultCode());
44+
}
45+
}
46+
}
47+
}
Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
import net.authorize.api.controller.base.ApiOperationBase;
6+
import net.authorize.api.controller.UpdateCustomerShippingAddressController;
27

38
public class UpdateCustomerShippingAddress {
9+
10+
public static void run(String apiLoginId, String transactionKey) {
11+
12+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
13+
14+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
15+
merchantAuthenticationType.setName(apiLoginId);
16+
merchantAuthenticationType.setTransactionKey(transactionKey);
17+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
18+
19+
CustomerAddressExType customer = new CustomerAddressExType();
20+
customer.setFirstName("John");
21+
customer.setLastName("Doe");
22+
customer.setAddress("123 Main St.");
23+
customer.setCity("Bellevue");
24+
customer.setState("WA");
25+
customer.setZip("98004");
26+
customer.setCountry("USA");
27+
customer.setPhoneNumber("000-000-0000");
28+
customer.setCustomerAddressId("30000");
29+
30+
UpdateCustomerShippingAddressRequest apiRequest = new UpdateCustomerShippingAddressRequest();
31+
apiRequest.setCustomerProfileId("10000");
32+
apiRequest.setAddress(customer);
33+
34+
UpdateCustomerShippingAddressController controller = new UpdateCustomerShippingAddressController(apiRequest);
35+
controller.execute();
36+
37+
UpdateCustomerShippingAddressResponse response = new UpdateCustomerShippingAddressResponse();
38+
response = controller.getApiResponse();
439

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
40+
if (response!=null) {
741

8-
}
42+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
943

10-
}
44+
System.out.println(response.getMessages().getMessage().get(0).getCode());
45+
System.out.println(response.getMessages().getMessage().get(0).getText());
46+
}
47+
else
48+
{
49+
System.out.println("Failed to update customer shipping address: " + response.getMessages().getResultCode());
50+
}
51+
}
52+
}
53+
}
Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
1-
package CustomerProfiles;
1+
package net.authorize.sample.CustomerProfiles;
2+
3+
import net.authorize.Environment;
4+
import net.authorize.api.contract.v1.*;
5+
import net.authorize.api.controller.base.ApiOperationBase;
6+
import net.authorize.api.controller.ValidateCustomerPaymentProfileController;
27

38
public class ValidateCustomerPaymentProfile {
9+
10+
public static void run(String apiLoginId, String transactionKey) {
11+
12+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
13+
14+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
15+
merchantAuthenticationType.setName(apiLoginId);
16+
merchantAuthenticationType.setTransactionKey(transactionKey);
17+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
18+
19+
ValidateCustomerPaymentProfileRequest apiRequest = new ValidateCustomerPaymentProfileRequest();
20+
apiRequest.setCustomerProfileId("10000");
21+
apiRequest.setCustomerPaymentProfileId("20000");
22+
apiRequest.setValidationMode(ValidationModeEnum.LIVE_MODE);
23+
24+
ValidateCustomerPaymentProfileController controller = new ValidateCustomerPaymentProfileController(apiRequest);
25+
controller.execute();
26+
27+
ValidateCustomerPaymentProfileResponse response = new ValidateCustomerPaymentProfileResponse();
28+
response = controller.getApiResponse();
429

5-
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
30+
if (response!=null) {
731

8-
}
32+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
933

10-
}
34+
System.out.println(response.getMessages().getMessage().get(0).getCode());
35+
System.out.println(response.getMessages().getMessage().get(0).getText());
36+
System.out.println(response.getDirectResponse());
37+
}
38+
else
39+
{
40+
System.out.println("Failed to validate customer payment profile: " + response.getMessages().getResultCode());
41+
}
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)