Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue64668 null pointer exception resolved #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,77 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub

ApiOperationBase.setEnvironment(Environment.SANDBOX);

MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType();
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber("4111111111111111");
creditCard.setExpirationDate("0621");
creditCard.setExpirationDate("0621");

PaymentType paymentType = new PaymentType();
paymentType.setCreditCard(creditCard);

TransactionRequestType requestInternal = new TransactionRequestType();
requestInternal.setTransactionType("authOnlyTransaction");
requestInternal.setPayment(paymentType);
requestInternal.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING));

CustomerDataType customer = new CustomerDataType();
customer.setEmail(email);
requestInternal.setCustomer(customer);

CreateTransactionRequest request = new CreateTransactionRequest();
request.setTransactionRequest(requestInternal);

CreateTransactionController controller = new CreateTransactionController(request);
controller.execute();

CreateTransactionResponse response = controller.getApiResponse();

CustomerProfileBaseType customerProfile = new CustomerProfileBaseType();
customerProfile.setMerchantCustomerId("123213");
customerProfile.setEmail("[email protected]");
customerProfile.setDescription("This is a sample customer profile");
customerProfile.setDescription("This is a sample customer profile");

CreateCustomerProfileFromTransactionRequest transaction_request = new CreateCustomerProfileFromTransactionRequest();
transaction_request.setTransId(response.getTransactionResponse().getTransId());
// You can either specify the customer information in form of customerProfileBaseType object
if (response != null)
transaction_request.setTransId(response.getTransactionResponse().getTransId());
else {
ANetApiResponse errorResponse = controller.getErrorResponse();
if (errorResponse != null) {
System.out.println("Error: " + errorResponse.getMessages().getMessage().get(0).getCode() + " \n"
+ errorResponse.getMessages().getMessage().get(0).getText());
} else {
System.out.println("Failed to get error response");
}
return errorResponse;

}

// You can either specify the customer information in form of
// customerProfileBaseType object
transaction_request.setCustomer(customerProfile);
// OR
// OR
// You can just provide the customer Profile ID
// transaction_request.setCustomerProfileId("1232132");

CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(transaction_request);

CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(
transaction_request);
createProfileController.execute();
CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse();

if (customer_response != null) {
System.out.println(transaction_request.getTransId());
} else {
ANetApiResponse transerrorResponse = controller.getErrorResponse();
if (transerrorResponse != null) {
System.out.println("Error: " + transerrorResponse.getMessages().getMessage().get(0).getCode() + " \n"
+ transerrorResponse.getMessages().getMessage().get(0).getText());
} else {
System.out.println("Failed to get error response");
}
}
return customer_response;
}
Expand Down