Reply
Contributor
Posts: 19
Registered: ‎12-08-2016
Accepted Solution

Missing fields Order Number and Email Address

Hi,

 

I'm using the php-sdk, and I have created a CustomerAddressType->setEmail('..') and added it to the TransactionRequestType()->setBillTo(...)

 

All the other information, including the phone number, shows up in the "Customer Billing Information" of the Sandbox transaction detail, but the email address is missing from that window. Why?

 

Also, when I click on "print" the receipt it creates has the Customer PO number that I provided, as well as the Invoice Number that I provided. But Order Number is empty. I don't see how to populate that value. Where do I set that?

 

Thanks,

-Dustin


Accepted Solutions
Solution
Accepted by topic author dustin1
‎04-07-2017 11:33 AM
All Star
Posts: 699
Registered: ‎11-03-2016

Re: Missing fields Order Number and Email Address

Hi @dustin1,

 

The email address is not part of the <billTo> element in the API, it's part of the <customer> element.

 

Consequently, it's not something you set in an instance of CustomerAddressType(), it's something you set in an instance of CustomerDataType().

 

See the API Reference if you want to see where everything fits in the heirarchy, or go back to my last post for specific code examples to implement this.

View solution in original post


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

Re: Missing fields Order Number and Email Address

Hi @dustin1,

 

The SDK follows the heirarchy of the API (or at least should). If you look at the basic payment transaction in the API Reference, email address is actually part of the "customer" element. In SDK terms, that means you'd declare a variable $foo as an instance of CustomerDataType():

 

$foo = new AnetAPI\CustomerDataType();

Then use the email setter like so:

$foo->setEmail("developer@authorize.net");

Then, add that to your transaction request (previously set up as "$bar"):

$bar->setCustomer($foo);

 

As far as the order # on the printout goes, I honestly don't know if that's connected to anything at all. It doesn't match up with the known fields, which you're already seeing represented. There is an orderId field used with Visa Checkout, but I honestly couldn't say if that's related.

Contributor
Posts: 19
Registered: ‎12-08-2016

Re: Missing fields Order Number and Email Address

I do that.

 

        // Bill To Information
        $billToCustomer = new AnetAPI\CustomerAddressType();
        $billToCustomer->setCompany('XYZ Video Systems');
        $billToCustomer->setFirstName('Nitsud');
        $billToCustomer->setLastName('Maharg');
        $billToCustomer->setAddress('123 Somewhere Road');
        $billToCustomer->setCity('Fallbrook');
        $billToCustomer->setState('CA');
        $billToCustomer->setZip('92028');
        $billToCustomer->setCountry('USA');
        $shipToCustomer = clone($billToCustomer);
        $billToCustomer->setEmail('example@example.com');
        $billToCustomer->setPhoneNumber('555-123-4567');
        
        //create a transaction
        $transactionRequestType = new AnetAPI\TransactionRequestType();
        $transactionRequestType->setTransactionType('authCaptureTransaction');
        $transactionRequestType->setAmount($amount);
        $transactionRequestType->setOrder($order);
        $transactionRequestType->setPayment($paymentOne);
        $transactionRequestType->setBillTo($billToCustomer);
        $transactionRequestType->setShipTo($shipToCustomer);
        $transactionRequestType->setCustomerIP($customerIp);
        $transactionRequestType->setPoNumber($customerPo);
        $transactionRequestType->addToLineItems($lineItem);

But, the email address doesn't show up in the transaction detail report.

Solution
Accepted by topic author dustin1
‎04-07-2017 11:33 AM
All Star
Posts: 699
Registered: ‎11-03-2016

Re: Missing fields Order Number and Email Address

Hi @dustin1,

 

The email address is not part of the <billTo> element in the API, it's part of the <customer> element.

 

Consequently, it's not something you set in an instance of CustomerAddressType(), it's something you set in an instance of CustomerDataType().

 

See the API Reference if you want to see where everything fits in the heirarchy, or go back to my last post for specific code examples to implement this.

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

Re: Missing fields Order Number and Email Address

Also, check out our sample code for another example of using the CustomerDataType

Contributor
Posts: 19
Registered: ‎12-08-2016

Re: Missing fields Order Number and Email Address

Hi Aaron,

 

I noticed that it was missing from the API.

 

It is, however, available on the CustomerAddressType.php file here:

 

https://github.com/AuthorizeNet/sdk-php/blob/master/lib/net/authorize/api/contract/v1/CustomerAddres...

 

    /**
     * Sets a new email
     *
     * @param string $email
     * @return self
     */
    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }

 

This is why I expected it to be available in the TransactionRequestType per this:

 

https://github.com/AuthorizeNet/sdk-php/blob/master/lib/net/authorize/api/contract/v1/TransactionReq... where you can see it's clearly documented that CustomerAddressType is the parameter for the Bill To element.

 

    /**
     * Sets a new billTo
     *
     * @param \net\authorize\api\contract\v1\CustomerAddressType $billTo
     * @return self
     */
    public function setBillTo(\net\authorize\api\contract\v1\CustomerAddressType $billTo)
    {
        $this->billTo = $billTo;
        return $this;
    }

 

But, yes, it seems the AuthorizeNet php sdk doesn't line up with the API. And the API doesn't have email address as a type. I'll refer to the API to determine which fields are valid on which elements. Might be nice to have the sdk match.

 

Thanks for the help. Understood now.