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->setCardNumber($credit_card); $creditCard->setExpirationDate($_POST['expmonth'] . "-" . $_POST['expyear']); $creditCard->setCardCode($_POST['securitycode']);
12-02-2016 01:51 PM
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(); $customer->setEmail("foo@example.com"); // Bill To $billto = new AnetAPI\CustomerAddressType(); $billto->setFirstName("Ellen"); $billto->setLastName("Johnson"); $billto->setCompany("Souveniropolis"); $billto->setAddress("14 Main Street"); $billto->setCity("Pecan Springs"); $billto->setState("TX"); $billto->setZip("44628"); $billto->setCountry("USA");
Then, add the following two lines to where you're building your $transactionRequestType object:
$transactionRequestType->setCustomer($customer); $transactionRequestType->setBillTo($billto);
12-05-2016 10:31 AM
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.
05-26-2017 02:41 PM