Week 11
AUTHORIZE_API_LOGIN_ID
AUTHORIZE_TRANSACTION_KEY
All requests to the Authorize.net API are sent via the HTTP POST method to one of our API endpoint URLs.
Sandbox API Endpoint: https://apitest.authorize.net/xml/v1/request.api
Production API Endpoint: https://api.authorize.net/xml/v1/request.api
If you open the "External Libraries" folder in IntelliJ, you will see all of Authorize.net's required dependencies.
run(
Config.getEnv("AUTHORIZE_API_LOGIN_ID"),
Config.getEnv("AUTHORIZE_TRANSACTION_KEY"),
25.00);
Successfully created transaction with Transaction ID: 0
Response Code: 1
Message Code: 1
Description: This transaction has been approved.
Auth Code: 000000
run(String apiLoginId, String transactionKey, Double amount, String[] creditCardInfo)
CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber(creditCardInfo[0]);
creditCard.setExpirationDate(creditCardInfo[1]);
creditCard.setCardCode(creditCardInfo[2]);
run(
Config.getEnv("AUTHORIZE_API_LOGIN_ID"),
Config.getEnv("AUTHORIZE_TRANSACTION_KEY"),
25.00,
new String[]{"4242424242424242", "0835", "111"});
public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount, String[] creditCardInfo, String[] billingInfo, String[] shippingInfo)
run(
Config.getEnv("AUTHORIZE_API_LOGIN_ID"),
Config.getEnv("AUTHORIZE_TRANSACTION_KEY"),25.00,
new String[]{"370000000000002", "0835", "1111"},
new String[]{"John", "Doe", "123 Main Street", "Cedar Rapids","IA","52404","USA","3191234567"},
new String[]{"John", "Doe", "123 Main Street", "Cedar Rapids", "IA", "52404", "USA"});
// Billing Address (includes cardholder name)
CustomerAddressType billingAddress = new CustomerAddressType();
billingAddress.setFirstName(billingInfo[0]);
billingAddress.setLastName(billingInfo[1]);
billingAddress.setAddress(billingInfo[2]);
billingAddress.setCity(billingInfo[3]);
billingAddress.setState(billingInfo[4]);
billingAddress.setZip(billingInfo[5]);
billingAddress.setCountry(billingInfo[6]);
billingAddress.setPhoneNumber(billingInfo[7]);
// Shipping Address
CustomerAddressType shippingAddress = new CustomerAddressType();
shippingAddress.setFirstName(shippingInfo[0]);
shippingAddress.setLastName(shippingInfo[1]);
shippingAddress.setAddress(shippingInfo[2]);
shippingAddress.setCity(shippingInfo[3]);
shippingAddress.setState(shippingInfo[4]);
shippingAddress.setZip(shippingInfo[5]);
shippingAddress.setCountry(shippingInfo[6]);
// code omitted
txnRequest.setBillTo(billingAddress);
txnRequest.setShipTo(shippingAddress);