Integration and Testing

Authorize.Net API questions and help with your payment integration.

Posts: 1
Registered: ‎12-02-2016

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']);

All Star
Posts: 699
Registered: ‎11-03-2016

Re: Capture Customer Information using PHP

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:




Posts: 1
Registered: ‎05-26-2017

Re: Capture Customer Information using PHP

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.