Showing results for 
Search instead for 
Did you mean: 

Capture Customer Information using PHP

How do I capture other fields like "last name", "first name", and "email" so that they show up in the transaction details?  I am using php.  My form correctly passes the credit card number, expiration date, and amount.  What code can I use to pass other fields?


Here's mycode that is correctly passing the credit card information:

$creditCard = new AnetAPI\CreditCardType();
$creditCard->setExpirationDate($_POST['expmonth'] . "-" . $_POST['expyear']);


Hi @aaron0045,


Sending other information is very similar to the way you're sending the card information. In addition to making a new CreditCardType(), you'd make an instance of one of the other classes, like CustomerDataType(), NameAndAddressType(), or CustomerAddressType(). If you want to see where all of these classes are defined, you can dig into the PHP SDK in vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1.


In your case, you'd do something like this:


// Customer info 
$customer = new AnetAPI\CustomerDataType();

// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setAddress("14 Main Street");
$billto->setCity("Pecan Springs");

Then, add the following two lines to where you're building your $transactionRequestType object:




All Star

Thanks for this!


This was very confusing at first because the CustomerAddressType provides a setEmail() method, but it doesn't seem to have any effect.